当前位置:Gxlcms > PHP教程 > php判断访问者是搜索引擎还是真实用户的代码

php判断访问者是搜索引擎还是真实用户的代码

时间:2021-07-01 10:21:17 帮助过:25人阅读

  1. /**
  2. * 判断访问来源 搜索引擎还是真实用户
  3. * site bbs.it-home.org
  4. */
  5. function is_bot()
  6. {
  7. /* This function will check whether the visitor is a search engine robot */
  8. //根据需要扩充此数组
  9. $botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi",
  10. "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory",
  11. "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
  12. "crawler", "bbs.it-home.org", "Googlebot", "Scooter", "Slurp",
  13. "msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
  14. "Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
  15. "Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot",
  16. "Butterfly","Twitturls","Me.dium","Twiceler");
  17. foreach($botlist as $bot)
  18. {
  19. if(strpos($_SERVER['HTTP_USER_AGENT'],$bot)!==false)
  20. return true; // Is a bot
  21. }
  22. return false; // Not a bot
  23. }
  24. ?>

人气教程排行