Detector bots in PHP


// detector bots function isBot($ua=null){ if ($ua===null) { if ($_SERVER['HTTP_CONNECTION'] == 'TE, close' || $_SERVER['HTTP_CONNECTION'] == 'close' || $_SERVER['HTTP_CONNECTION'] == 'TE' ) return 1; $ua = strtolower($_SERVER['HTTP_USER_AGENT']); } if (!$ua) return true; $list = array('bot', 'spider', 'googlebot', 'yammybot', 'openbot', 'yahoo', 'slurp', 'msnbot', 'ia_archiver', 'lycos', 'scooter', 'altaVista', 'teoma', 'gigabot', 'googlebot-mobile', 'poe-component-client', 'craw', 'mediapartners-google', 'wget','indexer'); foreach ($list as $key => &$value){ if (strpos($ua, $value)!==false) return 1; } return 0; }