当前位置: 首页 > 图文教程 > 网络编程 > PHP > 巧用PHP记录搜索引擎蜘蛛访问网站的足迹

PHP
如何防止入侵:My SQL各种攻击方法大全
教你使用MySQL:MySQL常用命令一览
教你如何在linux下建立mysql镜像数据库
实际应用:MySQL5存储过程编写实践
MySQL手册版本 5.0.20-MySQL同步
MySQL手册版本 5.0.20-MySQL同步(二)
MySQL手册版本 5.0.20-MySQL同步(三)
MySQL 版本 卸载与安装
[Mysql]Mysql中mysqldump命令使用详解 (1)
[Mysql]Mysql中mysqldump命令使用详解 (2)
通过缓存数据库结果提高PHP性能(1)
通过缓存数据库结果提高PHP性能(2)
通过缓存数据库结果提高PHP性能(3)
通过缓存数据库结果提高PHP性能(4)
如何使用SQL Server 2005 INSTEAD-OF触发器
实例讲解MySQL数据库的查询优化技术 (1)(2)
实例讲解MySQL数据库的查询优化技术 (1)
高手心得:提高MySQL性能的方法 (1)(2)
高手心得:提高MySQL性能的方法 (1)
工作笔记:配置MySQL为高可用集群 (1)(2)

巧用PHP记录搜索引擎蜘蛛访问网站的足迹


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 215 ::
收藏到网摘: n/a

PHP程序:

以下为引用的内容:

<?php
/***************************************************************************
* NAPS -- Network Article Publish System
* ----------------------------------------------
*                                 bot.php
*                            -------------------
*   begin                : 2004-08-15
*   copyright            : (C) 2004 week9
*   email                : [email protected]
*   homepage             : http://www.week9.com
*                          http://www.wapshow.com
*
***************************************************************************/
 
/***************************************************************************
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation; either version 2 of the License.
*
***************************************************************************/
 
/***************************************************************************
*
*   NAPS产品是自由软件。你可以且必须根据《GNU GPL-GNU通用公共许可证》的相关规定
*   复制、修改及分发NAPS产品。任何以NAPS产品为基础的衍生发行版未必须经过飘飘的授权。
*
***************************************************************************/
 
error_reporting(E_ALL & ~E_NOTICE);
 
function get_naps_bot()
{
        $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
                      
        if (strpos($useragent, 'googlebot') !== false){
                return 'Googlebot';
        }
      
        if (strpos($useragent, 'msnbot') !== false){
                return 'MSNbot';
        }
      
        if (strpos($useragent, 'slurp') !== false){
                return 'Yahoobot';
        }
      
        if (strpos($useragent, 'baiduspider') !== false){
                return 'Baiduspider';
        }
      
        if (strpos($useragent, 'sohu-search') !== false){
                return 'Sohubot';
        }
      
        if (strpos($useragent, 'lycos') !== false){
                return 'Lycos';
        }
      
        if (strpos($useragent, 'robozilla') !== false){
                return 'Robozilla';
        }      
        return false;
}
 
$tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']);
//添加蜘蛛的抓取记录
$searchbot = get_naps_bot();
if ($searchbot) {
        $DB_naps->query("UPDATE naps_stats_bot SET botcount=botcount+1, botlast=NOW(), botlasturl='$tlc_thispage' WHERE botname='$searchbot'");
}
 
?>