<?php
header("Content-type:application/json;charset=utf-8");
if(empty($_GET['ip'])){
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip=$_GET['ip'];
}
$ipinfo=@file_get_contents("http://whois.pconline.com.cn/ipJson.jsp?ip=".$ip."&json=true");
$ipinfo=iconv("GB2312","UTF-8",$ipinfo);
$ipinfo=json_decode($ipinfo);
foreach($ipinfo as $ii=>$ii2){
$$ii = $ii2;
echo '{"ip":"'.$ip.'","pro":"'.$pro.'","city":"'.$city.'","addr":"'.trim($addr).'"}';