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

PHP
MySQL数据库常见函数详解(1)
MySQL数据库常见函数详解(2)
MySQL数据库常见函数详解(3)
PHP5中新增加的日期(date)函数的常量
PHP:实现给上传图片加水印的程序代码
PHP动态网站开发中常用的8个小技巧
用PHP程序直接调用文本文件内容分析
简单学习PHP向MYSQL中插入数据的代码
PHP中常用的几个 mysql 语句
初学PHP指导:php.ini 配置详细选项
用动态网页技术PHP生成验证码图片的源代码
PHP动态网页开发实现支持页面回跳的方法
实例:PHP生成word文档格式试卷的代码
PHP开发技巧之用递归替换数组中的内容
实用技巧:PHP中调用Java类的两种方法
PHP的mb_substr和mb_strcut的区别
学习动态网页技术PHP:GD库安装问题详解
动态网页制作技术PHP的拼写检查函数库
通过PHP服务器端特性的配置加强PHP的安全
由浅入深学习动态网页制作PHP的编程与应用

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


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