Skip to content

Commit

Permalink
remove htaccess bad bot blocking awesomemotive#657
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltorbert committed Jan 19, 2017
1 parent 34373e2 commit 6b227bf
Showing 1 changed file with 0 additions and 56 deletions.
56 changes: 0 additions & 56 deletions modules/aioseop_bad_robots.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function __construct() {
'block_bots' => __( 'Block requests from user agents that are known to misbehave with 503.', 'all-in-one-seo-pack' ),
'block_refer' => __( 'Block Referral Spam using HTTP.', 'all-in-one-seo-pack' ),
'track_blocks' => __( 'Log and show recent requests from blocked bots.', 'all-in-one-seo-pack' ),
'htaccess_rules' => __( 'Block bad robots via Apache .htaccess rules. Warning: this will change your web server configuration, make sure you are able to edit this file manually as well.', 'all-in-one-seo-pack' ),
'edit_blocks' => __( 'Check this to edit the list of disallowed user agents for blocking bad bots.', 'all-in-one-seo-pack' ),
'blocklist' => __( 'This is the list of disallowed user agents used for blocking bad bots.', 'all-in-one-seo-pack' ),
'referlist' => __( 'This is the list of disallowed referers used for blocking bad bots.', 'all-in-one-seo-pack' ),
Expand All @@ -34,7 +33,6 @@ function __construct() {
'block_bots' => array( 'name' => __( 'Block Bad Bots using HTTP', 'all-in-one-seo-pack' ) ),
'block_refer' => array( 'name' => __( 'Block Referral Spam using HTTP', 'all-in-one-seo-pack' ) ),
'track_blocks' => array( 'name' => __( 'Track Blocked Bots', 'all-in-one-seo-pack' ) ),
'htaccess_rules' => array( 'name' => __( 'Block Bad Bots using .htaccess', 'all-in-one-seo-pack' ) ),
'edit_blocks' => array( 'name' => __( 'Use Custom Blocklists', 'all-in-one-seo-pack' ) ),
'blocklist' => array(
'name' => __( 'User Agent Blocklist', 'all-in-one-seo-pack' ),
Expand Down Expand Up @@ -68,14 +66,6 @@ function __construct() {
'condshow' => array( "{$this->prefix}track_blocks" => 'on' ),
),
);
$is_apache = false;
if ( ! empty( $_SERVER['SERVER_SOFTWARE'] ) && stristr( $_SERVER['SERVER_SOFTWARE'], 'Apache' ) !== false ) {
$is_apache = true;
add_action( $this->prefix . 'settings_update', array( $this, 'generate_htaccess_blocklist' ), 10 );
} else {
unset( $this->default_options['htaccess_rules'] );
unset( $help_text['htaccess_rules'] );
}

if ( ! empty( $help_text ) ) {
foreach ( $help_text as $k => $v ) {
Expand Down Expand Up @@ -137,52 +127,6 @@ function validate_ip( $ip ) {

}

function generate_htaccess_blocklist() {
if ( ! $this->option_isset( 'htaccess_rules' ) ) {

if ( insert_with_markers( get_home_path() . '.htaccess', $this->name, '' ) ) {
aioseop_output_notice( __( 'Updated .htaccess rules.', 'all-in-one-seo-pack' ) );
} else {
aioseop_output_notice( __( 'Failed to update .htaccess rules!', 'all-in-one-seo-pack' ), '', 'error' );
}

return;

}

if ( function_exists( 'apache_get_modules' ) ) {
$modules = apache_get_modules();
foreach ( array( 'mod_authz_host', 'mod_setenvif' ) as $m ) {
if ( ! in_array( $m, $modules ) ) {
aioseop_output_notice( sprintf( __( 'Apache module %s is required!', 'all-in-one-seo-pack' ), $m ), '', 'error' );
}
}
}
$botlist = $this->default_bad_bots();
$botlist = apply_filters( $this->prefix . 'badbotlist', $botlist );
if ( ! empty( $botlist ) ) {
$regex = $this->quote_list_for_regex( $botlist, '"' );
$htaccess = array();
$htaccess[] = 'SetEnvIfNoCase User-Agent "' . $regex . '" bad_bot';
if ( $this->option_isset( 'edit_blocks' ) && $this->option_isset( 'block_refer' ) && $this->option_isset( 'referlist' ) ) {
$referlist = $this->default_bad_referers();
$referlist = apply_filters( $this->prefix . 'badreferlist', $botlist );
if ( ! empty( $referlist ) ) {
$regex = $this->quote_list_for_regex( $referlist, '"' );
$htaccess[] = 'SetEnvIfNoCase Referer "' . $regex . '" bad_bot';
}
}
$htaccess[] = 'Deny from env=bad_bot';
if ( insert_with_markers( get_home_path() . '.htaccess', $this->name, $htaccess ) ) {
aioseop_output_notice( __( 'Updated .htaccess rules.', 'all-in-one-seo-pack' ) );
} else {
aioseop_output_notice( __( 'Failed to update .htaccess rules!', 'all-in-one-seo-pack' ), '', 'error' );
}
} else {
aioseop_output_notice( __( 'No rules to update!', 'all-in-one-seo-pack' ), '', 'error' );
}
}

/**
* @param $referlist
*
Expand Down

0 comments on commit 6b227bf

Please sign in to comment.