This repository has been archived on 2022-12-28. You can view files and clone it, but cannot push or open issues or pull requests.
apiOld/ipinfo/api.php

15 lines
456 B
PHP
Raw Normal View History

2021-01-01 07:48:55 +00:00
<?php
header("Content-type:application/json;charset=utf-8");
if(empty($_GET['ip'])){
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip=$_GET['ip'];
}
2021-02-07 14:28:02 +00:00
$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;
2021-01-01 07:48:55 +00:00
}
2021-02-07 14:28:02 +00:00
echo '{"ip":"'.$ip.'","pro":"'.$pro.'","city":"'.$city.'","addr":"'.trim($addr).'"}';