Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * is_real_agent() - Check if user agent given as a parameter is a search robot or a "real" visitor (list is absolutely incomplete :-) )
- * Original source (code modified below): http://neo22s.com/function-to-check-if-visitor-is-a-bot/
- * @param string $HTTP_USER_AGENT - böngésző ($_SERVER['HTTP_USER_AGENT'])
- * @return bool is_real_agent - is it a "real" visitor?
- */
- function is_real_agent( $HTTP_USER_AGENT ){
- $unreal_agent_list = array(
- "W3C_Validator", // not a search robot, but isn't a "real" visitor
- "blahblahblahblahblah" // modify as you wish
- );
- $botlist = array(
- "Googlebot", "Feedfetcher-Google", "Mediapartners-Google",
- "Teoma", "alexa", "froogle", "Gigabot", "inktomi",
- "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory",
- "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
- "crawler", "www.galaxy.com", "Scooter", "Slurp",
- "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
- "Baiduspider", "TechnoratiSnoop", "Rankivabot",
- "Sogou web spider", "WebAlta Crawler","TweetmemeBot",
- "Butterfly","Twitturls", "Me.dium", "Twiceler"
- );
- foreach($unreal_agent_list as $unreal_agent){
- if(stripos($HTTP_USER_AGENT, $unreal_agent)!==false){
- return false; // Is not real
- }
- }
- foreach($botlist as $bot){
- if(stripos($HTTP_USER_AGENT, $bot)!==false){
- return false; // Is a bot
- }
- }
- return true; // Not a bot
- }
- /// ............
- // using the function below:
- // if user agent header is set, we can check if it's a search robot or a real (e.g. human :D) visitor
- if( !empty($_SERVER['HTTP_USER_AGENT']) ) {
- $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
- if(false == is_real_agent($HTTP_USER_AGENT)){
- $real_visitor = 'false';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement