Jump to content

Bot Detection


intenseone345

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.