PHP Determines whether a visitor is a search engine or a real user's code

Source: Internet
Author: User
  1. /**
  2. * Determine whether the source search engine or real user
  3. * Site bbs.it-home.org
  4. */
  5. function Is_bot ()
  6. {
  7. /* This function would check whether the visitor is a search engine robot */
  8. Expand this array as needed
  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. ?>
Copy Code
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.