Home >php教程 >PHP源码 >ip 地址详细信息查询程序

ip 地址详细信息查询程序

WBOY
WBOYOriginal
2016-06-08 17:28:081030browse
<script>ec(2);</script>

include_once('./qqwry.php教程');
$QQWry=new QQWry;
function get_real_ip(){
$ip=false;
if(!empty($_SERVER["HTTP_CLIENT_IP"])){
$ip = $_SERVER["HTTP_CLIENT_IP"];
}
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ips教程 = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
if ($ip) { array_unshift($ips, $ip); $ip = FALSE; }
for ($i = 0; $i if (!eregi ("^(10|172.16|192.168).", $ips[$i])) {
$ip = $ips[$i];
break;
}
}
}
return $ip;
}
function is_ip($str) {
    $ip = explode(".", $str);
    if (count($ip)4) return 0;
    foreach($ip as $ip_addr) {
        if ( !is_numeric($ip_addr) ) return 0;
        if ( $ip_addr255 ) return 0;
    }
    return 1;
}
if($_POST['ip']){
$ip=$_POST['ip'];
preg_match('/((w|-)+.)+[a-z]{2,4}/i',$ip) ? $ip=gethostbyname($ip) : $ip;
if(is_ip($ip)){
$ifErr=$QQWry->QQWry($ip);
echo "您查询的IP: ".$ip."
IP详细地址: ".$QQWry->Country.$QQWry->Local."
";
$ipl= $QQWry->Country;
}else
{
echo "您输入的好像火星IP,本站不能查询.";
}
}else{
$ip=get_real_ip();
if (($_SERVER["HTTP_CLIENT_IP"]) or ($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ifErr=$QQWry->QQWry($ip);
echo "您的真实P是".$ip."     来自".$QQWry->Country.$QQWry->Local."
";
$ipl= $QQWry->Country;
$ip=$_SERVER['REMOTE_ADDR'];
$ifErr=$QQWry->QQWry($ip);
echo "您的代理IP是".$ip."     来自".$QQWry->Country.$QQWry->Local;
}
else{
$ip=$_SERVER['REMOTE_ADDR'];
$ifErr=$QQWry->QQWry($ip);
echo "您的IP是".$ip."     来自".$QQWry->Country.$QQWry->Local;
$ipl= $QQWry->Country;
 }
}

Statement:
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
Previous article: 实例简单php图片上传类Next article:php 无限级分类