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

PHP
详细讲解PHP编程中分页显示的制作
PHP开发技巧:PHP关于图像颜色的操作
PHP程序安全基础:手工php注入总结
PHP动态网页程序中常用的表单验证类
用PHP程序实现支持页面后退的两种方法
PHP代码:基本数据结构和php内置函数
php实现图片远程采集(PHP采集)
巧用PHP记录搜索引擎蜘蛛访问网站的足迹
PHP的常用的几大模板引擎
PHP采集图片实例(PHP采集)
用PHP读取RSS内容,实现与BLOG的同步
php生成静态页面的方法(简单,实用)
PHP+CSS实现打印简单数据报表功能
PHP制作简单的内容采集器实例教程
技巧:使用PHP中的字符串函数
PHP文件或目录权限检查函数
PHP实例——PHP创建动态图像
PHP自定义的加密和解密程序
轻松实现php代码防注入,保护代码安全!
PHP与MySQL中的SQL注入式漏洞

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


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