php获取ip地址所在地查询程序_PHP教程

WBOY
Freigeben: 2016-07-13 16:56:12
Original
1315 人浏览过

文章利用了第三方接口来实现ip地址查询,这里根据用户提交的IP地址就可以方便的查出IP地址真实所在地。

 代码如下 复制代码

0){$urlip=array_keys($_GET);$urlip=str_replace("_",".",$urlip[0]);}?>




$ip=$_POST['ip']?$_POST['ip']:$urlip;if(!$ip)$ip=get_real_ip();
$ip=preg_match('/((w|-)+.)+[a-z]{2,4}/i',$ip)?gethostbyname($ip) : $ip;
$ipdata=ipdata($ip,'all');
?>

 

 


 

IP查询



 

 


IP地址或域名:




   if(is_ip($ip)){
  $ipaddress=$ipdata->country;
  if($ipdata->region==$ipdata->city){$ipaddress.=$ipdata->city;}else{$ipaddress.=$ipdata->region.$ipdata->city;}
  $ipaddress.=$ipdata->isp;
  echo "您查询的IP: [".$ip."]IP详细地址: [".$ipaddress."]
";
 }else{echo "?澹?闶淙氲?P,居然不能查询到!不是输入错误?";}
 $ipdaili=$_SERVER['REMOTE_ADDR'];
 if(!in_array($ipdaili,array('127.0.0.1',$ip,$_SERVER['SERVER_ADDR'],get_real_ip()))){
  echo "您的代理IP是[".$ipdaili."]     来自".ipdata($ipdaili)."";
 }
$whiosip=$_POST['ip']?$_POST['ip']:$urlip;
if($whiosip){preg_match('/((w|-)+.)+[a-z]{2,4}/i',$whiosip) ? $whois=str_replace("www.","",$whiosip):"";}
if($whois){echo "

点击查看域名 ".$whois." 的WhoIs信息";}
?>







IP 国家/地区 省份 城市 运营商
=$ip;?> =$ipdata->country.$ipdata->area?> =$ipdata->region?> =$ipdata->city?> =$ipdata->county?> =$ipdata->isp?>



Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!