{"id":919,"date":"2021-03-10T17:41:36","date_gmt":"2021-03-10T09:41:36","guid":{"rendered":"http:\/\/www.tra56.com\/?p=919"},"modified":"2021-03-10T17:41:36","modified_gmt":"2021-03-10T09:41:36","slug":"919","status":"publish","type":"post","link":"https:\/\/www.tra56.com\/919.html","title":{"rendered":"PHP\u8bb0\u5f55\u641c\u7d22\u5f15\u64ce\u8718\u86db\u8bbf\u95ee\u7f51\u7ad9\u8db3\u8ff9\u7684\u65b9\u6cd5"},"content":{"rendered":"

\u672c\u6587\u5b9e\u4f8b\u8bb2\u8ff0\u4e86PHP\u8bb0\u5f55\u641c\u7d22\u5f15\u64ce\u8718\u86db\u8bbf\u95ee\u7f51\u7ad9\u8db3\u8ff9\u7684\u65b9\u6cd5\u3002\u5206\u4eab\u7ed9\u5927\u5bb6\u4f9b\u5927\u5bb6\u53c2\u8003\u3002\u5177\u4f53\u5206\u6790\u5982\u4e0b\uff1a<\/p>\n

\u641c\u7d22\u5f15\u64ce\u7684\u8718\u86db\u8bbf\u95ee\u7f51\u7ad9\u662f\u901a\u8fc7\u8fdc\u7a0b\u6293\u53d6\u9875\u9762\u6765\u8fdb\u884c\u7684\uff0c\u6211\u4eec\u4e0d\u80fd\u4f7f\u7528JS\u4ee3\u7801\u6765\u53d6\u5f97\u8718\u86db\u7684Agent\u4fe1\u606f\uff0c\u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7image\u6807\u7b7e\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u5f97\u5230\u8718\u86db\u7684agent\u8d44\u6599\u4e86\uff0c\u901a\u8fc7\u5bf9agent\u8d44\u6599\u7684\u5206\u6790\uff0c\u5c31\u53ef\u4ee5\u786e\u5b9a\u8718\u86db\u7684\u79cd\u7c7b\u3001\u6027\u522b\u7b49\u56e0\u7d20\uff0c\u6211\u4eec\u5728\u901a\u8fc7\u6570\u636e\u5e93\u6216\u8005\u6587\u672c\u6765\u8bb0\u5f55\u5c31\u53ef\u4ee5\u8fdb\u884c\u7edf\u8ba1\u4e86\u3002<\/p>\n

\u6570\u636e\u5e93\u7ed3\u6784\uff1a<\/p>\n

\u4ee5\u4e0b\u4e3a\u5f15\u7528\u7684\u5185\u5bb9\uff1a<\/p>\n

#\r\n# \u8868\u7684\u7ed3\u6784 `naps_stats_bot`\r\n#\r\n\r\nCREATE TABLE `naps_stats_bot` (\r\n`botid` int(10) unsigned NOT NULL auto_increment,\r\n`botname` varchar(100) NOT NULL default '',\r\n`botagent` varchar(200) NOT NULL default '',\r\n`bottag` varchar(100) NOT NULL default '',\r\n`botcount` int(11) NOT NULL default '0',\r\n`botlast` datetime NOT NULL default '0000-00-00 00:00:00',\r\n`botlasturl` varchar(250) NOT NULL default '',\r\nUNIQUE KEY `botid` (`botid`),\r\nKEY `botname` (`botname`)\r\n) TYPE=MyISAM AUTO_INCREMENT=9 ;\r\n#\r\n# \u5bfc\u51fa\u8868\u4e2d\u7684\u6570\u636e `naps_stats_bot`\r\n#\r\nINSERT INTO `naps_stats_bot` VALUES (1, 'Googlebot', 'Googlebot\/2.X (+http:\/\/www.googlebot.com\/bot.html)', 'googlebot', 0, '0000-00-00 00:00:00', '');\r\nINSERT INTO `naps_stats_bot` VALUES (2, 'MSNbot', 'MSNBOT\/0.1 (http:\/\/search.msn.com\/msnbot.htm)', 'msnbot', 0, '0000-00-00 00:00:00', '');\r\nINSERT INTO `naps_stats_bot` VALUES (3, 'Inktomi Slurp', 'Slurp\/2.0', 'slurp', 0, '0000-00-00 00:00:00', '');\r\nINSERT INTO `naps_stats_bot` VALUES (4, 'Baiduspider', 'Baiduspider+(+http:\/\/www.baidu.com\/search\/spider.htm)', 'baiduspider', 0, '0000-00-00 00:00:00', '');\r\nINSERT INTO `naps_stats_bot` VALUES (5, 'Yahoobot', 'Mozilla\/5.0+(compatible;+Yahoo!+Slurp;+http:\/\/help.yahoo.com\/help\/us\/ysearch\/slurp)', 'slurp', 0, '0000-00-00 00:00:00', '');\r\nINSERT INTO `naps_stats_bot` VALUES (6, 'Sohubot', 'sohu-search', 'sohu-search', 0, '0000-00-00 00:00:00', '');\r\nINSERT INTO `naps_stats_bot` VALUES (7, 'Lycos', 'Lycos\/x.x', 'lycos', 0, '0000-00-00 00:00:00', '');\r\nINSERT INTO `naps_stats_bot` VALUES (8, 'Robozilla', 'Robozilla\/1.0', 'robozilla', 0, '0000-00-00 00:00:00', '');<\/pre>\n

PHP\u7a0b\u5e8f\u5982\u4e0b\uff1a<\/p>\n

\u4ee5\u4e0b\u4e3a\u5f15\u7528\u7684\u5185\u5bb9\uff1a<\/p>\n

<?php\r\n\/************************\r\n* NAPS -- Network Article Publish System\r\n* ----------------------------------------------\r\n*     bot.php\r\n*     -------------------\r\n*  begin  : 2004-08-15\r\n*\r\n************************\/\r\n\/************************\r\n*\r\n*  This program is free software; you can redistribute it and\/or modify\r\n*  it under the terms of the GNU General Public License as published by\r\n*  the Free Software Foundation; either version 2 of the License.\r\n*\r\n************************\/\r\n\/************************\r\n*\r\n*  NAPS\u4ea7\u54c1\u662f\u81ea\u7531\u8f6f\u4ef6\u3002\u4f60\u53ef\u4ee5\u4e14\u5fc5\u987b\u6839\u636e\u300aGNU GPL-GNU\u901a\u7528\u516c\u5171\u8bb8\u53ef\u8bc1\u300b\u7684\u76f8\u5173\u89c4\u5b9a\r\n*  \u590d\u5236\u3001\u4fee\u6539\u53ca\u5206\u53d1NAPS\u4ea7\u54c1\u3002\u4efb\u4f55\u4ee5NAPS\u4ea7\u54c1\u4e3a\u57fa\u7840\u7684\u884d\u751f\u53d1\u884c\u7248\u672a\u5fc5\u987b\u7ecf\u8fc7\u98d8\u98d8\u7684\u6388\u6743\u3002\r\n*\r\n************************\/\r\nerror_reporting(E_ALL & ~E_NOTICE);\r\nfunction get_naps_bot()\r\n{\r\n $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);\r\n if (strpos($useragent, 'googlebot') !== false){\r\n  return 'Googlebot';\r\n }\r\n if (strpos($useragent, 'msnbot') !== false){\r\n  return 'MSNbot';\r\n }\r\n if (strpos($useragent, 'slurp') !== false){\r\n  return 'Yahoobot';\r\n }\r\n if (strpos($useragent, 'baiduspider') !== false){\r\n  return 'Baiduspider';\r\n }\r\n if (strpos($useragent, 'sohu-search') !== false){\r\n  return 'Sohubot';\r\n }\r\n if (strpos($useragent, 'lycos') !== false){\r\n  return 'Lycos';\r\n }\r\n if (strpos($useragent, 'robozilla') !== false){\r\n  return 'Robozilla';\r\n }    \r\n return false;\r\n}\r\n$tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']);\r\n\/\/\u6dfb\u52a0\u8718\u86db\u7684\u6293\u53d6\u8bb0\u5f55\r\n$searchbot = get_naps_bot();\r\nif ($searchbot) {\r\n $DB_naps->query("UPDATE naps_stats_bot SET botcount=botcount+1, botlast=NOW(), botlasturl='$tlc_thispage' WHERE botname='$searchbot'");\r\n}\r\n?><\/pre>\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

\u672c\u6587\u5b9e\u4f8b\u8bb2\u8ff0\u4e86PHP\u8bb0\u5f55\u641c\u7d22\u5f15\u64ce\u8718\u86db\u8bbf\u95ee\u7f51\u7ad9\u8db3\u8ff9\u7684\u65b9\u6cd5\u3002\u5206\u4eab\u7ed9\u5927\u5bb6\u4f9b\u5927\u5bb6\u53c2\u8003\u3002\u5177\u4f53\u5206\u6790\u5982\u4e0b\uff1a \u641c\u7d22\u5f15\u64ce\u7684\u8718\u86db\u8bbf […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[26,72,70],"class_list":["post-919","post","type-post","status-publish","format-standard","hentry","category-php","tag-php"],"_links":{"self":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/919"}],"collection":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/comments?post=919"}],"version-history":[{"count":1,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/919\/revisions"}],"predecessor-version":[{"id":920,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/919\/revisions\/920"}],"wp:attachment":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/media?parent=919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/categories?post=919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/tags?post=919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}