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
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

Edited by davidannis
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.