Jun.11

PHP – Check for bot visit

function is_bot () {
    $botlist = array("googlebot", "mediapartners-google", "feedfetcher-google", ... );
    $bottest = strtolower($_SERVER['HTTP_USER_AGENT']);
    foreach($botlist as $bot) {
        if(strpos($bottest,$bot)!==false) {
            $thebot = $bot;
            break;
        }
    }
    return ( $thebot ? $thebot : false );
}

-*-

Web Programming,Web SEO