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) . ' '; } } ?> Link to comment https://forums.phpfreaks.com/topic/285510-bot-detection/ Share on other sites More sharing options...
davidannis Posted January 20, 2014 Share Posted January 20, 2014 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 Link to comment https://forums.phpfreaks.com/topic/285510-bot-detection/#findComment-1465826 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. Link to comment https://forums.phpfreaks.com/topic/285510-bot-detection/#findComment-1465827 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. Link to comment https://forums.phpfreaks.com/topic/285510-bot-detection/#findComment-1465853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.