Useful function for logging stats and visitors in php. PHP: //returns 1 if the user agent is a botfunction is_bot($user_agent){ //if no user agent is supplied then assume it's a bot if($user_agent == "") return 1; //array of bot strings to check for $bot_strings = Array( "google", "bot", "yahoo", "spider", "archiver", "curl", "python", "nambu", "twitt", "perl", "sphere", "PEAR", "java", "wordpress", "radian", "crawl", "yandex", "eventbox", "monitor", "mechanize", "facebookexternal" ); foreach($bot_strings as $bot) { if(strpos($user_agent,$bot) !== false) { return 1; } } return 0;}
I insert at the very end of the page after I flush everything out so there will be no delay of content even if the db is bogged down. And if I was give it to someone else who is using iis I would have to recode the entire thing. Also when doing reporting on large sets of data I don’t want to have to parse huge log files for every report.