desc))
{
$loc = $location->province.$location->city.$location->district.$location->isp;
}
else
{
$loc = $location->desc;
}
return $loc;
}
function get_ip_local($ip)
{
$url="http://ip.taobao.com/service/getIpInfo.php?ip=".$ip;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; // 获取数据返回
$result=json_decode(curl_exec($ch));
if((string)$result->code=='1')
return false;
return (array)$result->data;
}
// $ip=$_GET["IP"];
//
// echo 'IP: '.$ip.'
';
//
// $obj=get_ip_local($ip);
//
// if($ip==false)
// {
// echo "erro";
// return;
// }
//
// echo 'country:'.$obj["country"].'
';
// echo 'area:'.$obj["area"].'
';
// echo 'region:'.$obj["region"].'
';
// echo 'city:'.$obj["city"].'
';
// echo 'isp:'.$obj["isp"].'
';