Created
April 20, 2013 14:56
-
-
Save merouanekhalili/5426250 to your computer and use it in GitHub Desktop.
PHP : detect bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function isBot() { | |
$bots = array( | |
'googlebot', | |
'adsbot-google', | |
'feedfetcher-google', | |
'yahoo', | |
'lycos', | |
'bloglines subscriber', | |
'dumbot', | |
'sosoimagespider', | |
'qihoobot', | |
'fast-webcrawler', | |
'superdownloads spiderman', | |
'linkwalker', | |
'msnbot', | |
'aspseek', | |
'webalta crawler', | |
'youdaobot', | |
'scooter', | |
'gigabot', | |
'charlotte', | |
'estyle', | |
'aciorobot', | |
'geonabot', | |
'msnbot-media', | |
'baidu', | |
'cococrawler', | |
'google', | |
'charlotte t', | |
'yahoo! slurp china', | |
'sogou web spider', | |
'yodaobot', | |
'msrbot', | |
'abachobot', | |
'sogou head spider', | |
'altavista', | |
'idbot', | |
'sosospider', | |
'yahoo! slurp', | |
'java vm', | |
'dotbot', | |
'litefinder', | |
'yeti', | |
'rambler', | |
'scrubby', | |
'baiduspider', | |
'accoona' | |
); | |
foreach($bots as $bot) { | |
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), trim($bot)) !== false) { | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment