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

WBOY
Release: 2016-07-13 16:56:12
Original
1314 people have browsed it

文章利用了第三方接口来实现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?>



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!