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

PHP
在PHP中以root身份运行外部命令
PHP编程常用技巧四则
实例学习PHP之投票程序篇
PHP中的加密功能
PHP VS ASP
PHP生成动态WAP页面
PHP中for循环语句的几种变型
PHP5.0对象模型探索之对象串行化
PHP5.0对象模型探索之重载
浅议PHP程序开发中的模板选择
用PHP写的身份证验证程序
PHP.MVC的模板标签系统之初识PHP.MVC
PHP程序加速探索之代码优化
PHP程序加速探索之压缩输出gzip
用PHP文件上传的具体思路及实现
使用PHP编写基于Web的文件管理系统
理解PHP中的MVC编程之控制器
PHP程序加速探索之缓存输出
让你的PHP引擎全速运转的三个绝招
PHP程序加速探索之加速工具软件

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 143 ::
收藏到网摘: 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'");
}
 
?>