diff --git a/composer.json b/composer.json index c955ecf..31f9e4f 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,6 @@ "email": "tylerjc@hotmail.co.uk" } ], - "minimum-stability": "dev", "require": { "php": ">=5.3.0" }, diff --git a/src/NoBadBots/BeGone.php b/src/NoBadBots/BeGone.php index bc8e106..c7d7d00 100644 --- a/src/NoBadBots/BeGone.php +++ b/src/NoBadBots/BeGone.php @@ -5,6 +5,7 @@ class BeGone { public static $uas = ['headlesschrome','gotnoheadeua','nikto','sqlmap','curl','planetwork','purebot','pycurl','skygrid','sucker','turnit','vikspid','zmeu','zune','dotbot','feedfinder','flicky','ia_archiver','kmccrew','libwww','nutch','binlar','casper','checkprivacy','cmsworldmap','comodo','curious','diavol','doco','ZmEu','python']; + public static $bips = ['178.79.138.22']; public static $badness = 0; @@ -24,6 +25,16 @@ public static function shoo() { } } + if(!empty($_SERVER['REMOTE_ADDR'])){ + foreach(self::$bips as $ip){ + if(self::getUserIP() == $ua) { + self::$badness++; + } + } + } else { + self::$badness++; + } + return self::$badness; } @@ -34,4 +45,18 @@ public static function bomb(){ if (ob_get_level()) ob_end_clean(); readfile('10G.gzip'); } + + public static function getUserIP() { + if( array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) { + if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')>0) { + $addr = explode(",",$_SERVER['HTTP_X_FORWARDED_FOR']); + return trim($addr[0]); + } else { + return $_SERVER['HTTP_X_FORWARDED_FOR']; + } + } + else { + return $_SERVER['REMOTE_ADDR']; + } + } } \ No newline at end of file