//百度ip地址查询接口powby:qq:1620016116;

function ipToArea($ip=""){

    $api="http://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query=".$ip."&co=&resource_id=6006";

    $ch = curl_init();

    curl_setopt($ch,CURLOPT_URL,$api);

    curl_setopt($ch,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);

    curl_setopt($ch,CURLOPT_HTTPHEADER,C('IP138_TOKEN'));

    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,3);

    $handles = curl_exec($ch);

    curl_close($ch);

    $handles= iconv('GB2312', 'UTF-8', $handles);

    $arr=json_decode($handles,true);

    return $arr[data][0][location];

}