Skip to content

Instantly share code, notes, and snippets.

View cdsalmons's full-sized avatar

Dustin Salmons cdsalmons

View GitHub Profile
@cdsalmons
cdsalmons / image_optimize-wordpress.php
Last active August 29, 2015 14:26 — forked from wycks/image_optimize-wordpress.php
Remove WordPress full size images from being inserted into a post + option to and add max size to to prevent users from inserting massive images.
<?php
/**
*
* This removes the ability to add the FULL image size into a post, it does not alter or delete the image
* Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size
*
* For now we have to do it this way to make the labels translatable, see trac ref below.
*
* If your theme has $content_width GLOBAL make sure and remove it
WordPress block botnet brute force with Mod_security
SecAction phase:1,nolog,pass,initcol:ip=%{REMOTE_ADDR},initcol:user=%{REMOTE_ADDR},id:5000134
<Locationmatch "/wp-login.php">
# Setup brute force detection.
# React if block flag has been set.
SecRule user:bf_block "@gt 0" "deny,status:401,log,id:5000135,msg:'ip address blocked for 5 minutes, more than 10 login attempts in 3 minutes.'"
# Setup Tracking. On a successful login, a 302 redirect is performed, a 200 indicates login failed.
SecRule RESPONSE_STATUS "^302" "phase:5,t:none,nolog,pass,setvar:ip.bf_counter=0,id:5000136"
SecRule RESPONSE_STATUS "^200" "phase:5,chain,t:none,nolog,pass,setvar:ip.bf_counter=+1,deprecatevar:ip.bf_counter=1/180,id:5000137"
@cdsalmons
cdsalmons / GhettoPress.php
Last active August 29, 2015 14:26 — forked from wycks/GhettoPress.php
WordPress Ghetto Loader - stop doing this, you
<?php
//Load WorsPress quick and dirty into something not WordPress. This is horrible I know,
//But the database queries they are so low, and it's just so dirty
//install WordPress in a dir like /lib or something and stick classPageLoader.php in there, ha!
//Example use for a index.php or whatever, no autoloading here!
#######################################################
require('lib/classPageLoader.php');
$content = new LoadWpContent();
@cdsalmons
cdsalmons / override_plugin_stylesheet.php
Last active August 29, 2015 14:25 — forked from strangerstudios/override_plugin_stylesheet.php
Look for a stylesheet in a WP child theme or theme before loading a default plugin stylesheet.
//figure out which css to load
if(file_exists(get_stylesheet_directory() . "/pluginname/frontend.css"))
$css_url = get_stylesheet_directory_uri() . "/pluginname/frontend.css";
elseif(file_exists(get_template_directory() . "/pluginname/frontend.css"))
$css_url = get_template_directory_uri() . "/pluginname/frontend.css";
else
$css_url = plugins_url('css/frontend.css',dirname(__FILE__) );
//load it
wp_enqueue_style('pluginname-frontend', $css_url);
#!/usr/bin/perl
use cPanel::PublicAPI;
use Getopt::Long;
&Getopt::Long::config('bundling');
# Options args
my $conf = GetOptions(
"H|hostname=s" => \$conf_host,
"P|port=i" => \$conf_port,