I have a simple script that gets visitor environment and stores it in to a db.
I am trying to skip all visits by bots to my site.
I added this code to accomplish it:
function is_bot(){
$bots = array("alexa", "appie", "Ask Jeeves", "Baiduspider", "bingbot", "Butterfly", "crawler", "facebookexternalhit", "FAST", "Feedfetcher-Google", "Firefly", "froogle", "Gigabot", "girafabot", "Googlebot", "InfoSeek", "inktomi", "looksmart", "Me.dium", "Mediapartners-Google", "msnbot", "NationalDirectory", "rabaz", "Rankivabot", "Scooter", "Slurp", "Sogou web spider", "Spade", "TechnoratiSnoop", "TECNOSEEK", "Teoma", "TweetmemeBot", "Twiceler", "Twitturls", "URL_Spider_SQL", "WebAlta Crawler", "WebBug", "WebFindBot", "www.galaxy.com", "ZyBorg");
foreach($bots as $bot){
if(strpos($_SERVER['HTTP_USER_AGENT'],$bot)!==false)
return 1; // Is a bot
}
return 0; // Not a bot
}
if (!is_bot()) {
// store in db
}
For some reason I keep seeing results like this in my db table:
Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)
Am I missing anything?