Home > Backend Development > PHP Tutorial > PHP code to determine whether the visitor is a search engine or a real user

PHP code to determine whether the visitor is a search engine or a real user

WBOY
Release: 2016-07-25 09:00:03
Original
1658 people have browsed it
  1. /**
  2. * Determine whether the access source is a search engine or a real user
  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. ?>
复制代码


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template