01 | 
function get_ip_data(){   | 
 
 
02 | 
$ip=file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".get_client_ip()); | 
 
 
03 | 
    $ip = json_decode($ip); | 
 
 
07 | 
    $data = (array) $ip->data; | 
 
 
08 | 
    if($data['city']=='上海市' && !isCrawler()){ | 
 
 
09 | 
       // exit('https://www.xmy7.com'); | 
 
 
12 | 
/*     header("location:".getenv("HTTP_REFERER")); // 返回其调用页面 */ | 
 
 
17 | 
function isCrawler() { | 
 
 
31 | 
                        "Java (Often spam bot)", | 
 
 
42 | 
                        "Alexa (IA Archiver)", | 
 
 
53 | 
                        "The web archive (IA Archiver)", | 
 
 
62 | 
        if(in_array(strtolower($_SERVER['HTTP_USER_AGENT']),$spiderSite)){ | 
 
 
70 | 
function get_client_ip() | 
 
 
73 | 
            if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){ | 
 
 
74 | 
                $realip = $_SERVER["HTTP_X_FORWARDED_FOR"]; | 
 
 
75 | 
            } else if (isset($_SERVER["HTTP_CLIENT_IP"])) { | 
 
 
76 | 
                $realip = $_SERVER["HTTP_CLIENT_IP"]; | 
 
 
78 | 
                $realip = $_SERVER["REMOTE_ADDR"]; | 
 
 
81 | 
            if (getenv("HTTP_X_FORWARDED_FOR")){ | 
 
 
82 | 
                $realip = getenv("HTTP_X_FORWARDED_FOR"); | 
 
 
83 | 
            } else if (getenv("HTTP_CLIENT_IP")) { | 
 
 
84 | 
                $realip = getenv("HTTP_CLIENT_IP"); | 
 
 
86 | 
                $realip = getenv("REMOTE_ADDR"); | 
 
 
93 | 
    ShowMsg("你的IP被禁止!","-1"); | 
 
 
 | 
评论(0)