zoukankan      html  css  js  c++  java
  • [转载]PHP判断来访是蜘蛛还是普通用户

    PHP判断来访是蜘蛛还是普通用户--------------收藏(红黑联盟)
    <?php
    $flag = false;
    $tmp = $_SERVER['HTTP_USER_AGENT'];
    if(strpos($tmp, 'Googlebot') !== false){
        $flag = true;
    } else if(strpos($tmp, 'Baiduspider') >0){
        $flag = true;
    } else if(strpos($tmp, 'Yahoo! Slurp') !== false){
        $flag = true;
    } else if(strpos($tmp, 'msnbot') !== false){
        $flag = true;
    } else if(strpos($tmp, 'Sosospider') !== false){
        $flag = true;
    } else if(strpos($tmp, 'YodaoBot') !== false || strpos($tmp, 'OutfoxBot') !== false){
        $flag = true;
    } else if(strpos($tmp, 'Sogou web spider') !== false || strpos($tmp, 'Sogou Orion spider') !== false){
        $flag = true;
    } else if(strpos($tmp, 'fast-webcrawler') !== false){
        $flag = true;
    } else if(strpos($tmp, 'Gaisbot') !== false){
        $flag = true;
    } else if(strpos($tmp, 'ia_archiver') !== false){
        $flag = true;
    } else if(strpos($tmp, 'altavista') !== false){
        $flag = true;
    } else if(strpos($tmp, 'lycos_spider') !== false){
        $flag = true;
    } else if(strpos($tmp, 'Inktomi slurp') !== false){
        $flag = true;
    }
    if($flag == false){
       header("Location: http://www.hao123.com" . $_SERVER['REQUEST_URI']);
        // 自动转到http://www.hao123.com 对应的网页
        // $_SERVER['REQUEST_URI'] 为域名后面的路径
        // 或 换成header("Location: http://www.hao123.com/abc/d.php");
       exit();
    }
    ?>
  • 相关阅读:
    firewall详解
    Fiddler使用
    Asp.net Core过滤器
    单例模式
    C# 收银机顾显(客显)及打印小票(58热敏打印机)
    sqlite批量处理数据性能优化
    sqlite 插入数据 too many variables
    winform textbox控件keydown、keypress、keyup简单介绍
    ie兼容placeholder效果
    asp.net mvc全局异常捕获
  • 原文地址:https://www.cnblogs.com/linewman/p/9918847.html
Copyright © 2011-2022 走看看