diff --git a/src/index.php b/src/index.php index 1d4ff3a..aec891d 100755 --- a/src/index.php +++ b/src/index.php @@ -3,12 +3,22 @@ /** * Plugin Name: Spider Blocker * Description: Spider Blocker will block most common bots that consume bandwidth and slow down your server. - * Version: 1.0.4 + * Version: 1.0.5 * Runtime: 5.3 * Author: NiteoWeb Ltd. * Author URI: www.niteoweb.com */ +if (!function_exists('apache_get_version')) { + function apache_get_version() + { + if (stristr($_ENV["SERVER_SOFTWARE"], 'Apache')) { + return $_ENV["SERVER_SOFTWARE"]; + } + return false; + } +} + if (version_compare(PHP_VERSION, '5.3.0', '<')) { ?>
@@ -106,7 +116,7 @@ function activatePluginNotice() */ function activatePlugin() { - if (!apache_get_version() || !SpiderBlocker::modRewriteEnabled()) { + if (!apache_get_version()) { ?>

This plugin requires Apache2 server with mod_rewrite support. Please contact your hosting provider @@ -143,19 +153,12 @@ function generateBlockRules() $htaccess_file = $home_path . '.htaccess'; if ((!file_exists($htaccess_file) && is_writable($home_path)) || is_writable($htaccess_file)) { - if ($this->modRewriteEnabled()) { - insert_with_markers($htaccess_file, 'NiteowebSpiderBlocker', $this->getRules()); - } + insert_with_markers($htaccess_file, 'NiteowebSpiderBlocker', $this->getRules()); } $wp_rewrite->flush_rules(); } - static function modRewriteEnabled() - { - return function_exists('apache_mod_loaded') ? apache_mod_loaded('mod_rewrite', false) : false; - } - /** * Generate block rules based on enabled bots * @@ -206,9 +209,7 @@ function removeBlockRules() $htaccess_file = $home_path . '.htaccess'; $empty = array(); if ((!file_exists($htaccess_file) && is_writable($home_path)) || is_writable($htaccess_file)) { - if ($this->modRewriteEnabled()) { - insert_with_markers($htaccess_file, 'NiteowebSpiderBlocker', $empty); - } + insert_with_markers($htaccess_file, 'NiteowebSpiderBlocker', $empty); } $wp_rewrite->flush_rules();