intenseone345 Posted January 20, 2014 Share Posted January 20, 2014 Hello, i have a bot detection script here that im unsure if its correct, could someone look at it and see if there are errors in it? thanks for the help <b>Bots online:</b> <?php function GetBotList(){ $BotList = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi", "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory", "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot", "crawler", "www.galaxy.com", "Googlebot", "Googlebot/2.1", "Google Webmaster", "Scooter", "James Bond", "Slurp", "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz", "Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot", "Mediapartners-Google", "Sogou web spider", "WebAlta Crawler", "MJ12bot", "Yandex/", "YaDirectBot", "StackRambler","DotBot","dotbot","Baidu Ezooms","Ezooms","AdsBot-Google","Mediapartners-Google","Mediapartners","Googlebot-Video/1.0","Googlebot-News"); return $BotList; } function DetectBot(){ $BotList = GetBotList(); foreach($BotList as $bot) { if(strpos($bot, $_SERVER['HTTP_USER_AGENT'])) { return $bot; } } return false; } $is_robot = DetectBot(); if($is_robot){ foreach ($is_robot as $is_robot) { echo ucfirst($is_robot) . ' '; } } ?> Quote Link to comment Share on other sites More sharing options...
davidannis Posted January 20, 2014 Share Posted January 20, 2014 (edited) I don't understand why you do this: if($is_robot){ foreach ($is_robot as $is_robot) { echo ucfirst($is_robot) . ' '; } $is_robot is not an array as far as I can see, so I think it should be: if($is_robot){ echo ucfirst($is_robot) . ' '; } In the first part, instead of looping through the array, think about using http://www.php.net/in_array Edited January 20, 2014 by davidannis Quote Link to comment Share on other sites More sharing options...
intenseone345 Posted January 20, 2014 Author Share Posted January 20, 2014 Thanks for the help i will give it a whirl, i did not work befor maybe it will now. Quote Link to comment Share on other sites More sharing options...
davidannis Posted January 20, 2014 Share Posted January 20, 2014 If it doesn't work, post the error message / result. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.