<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>IP地址查询_511Cha.com</title>
<style type="text/css">
.p_input {width:600px; margin:10px auto; text-align:center;}
body {font-size:14px;line-height:150%;}
form{margin:0;padding:0;}
h1{padding:0;margin:0;font-size:14px;}
.result {width:600px; margin:0 auto; text-align:center; font-size:16px; font-weight:bold; color:#FF0000;}
.vtitle {width:600px; margin:10px auto 0 auto; text-align:center;}
.vcontent{width:600px; margin:0 auto;}
.history {width:600px; margin:5px auto 0 auto; overflow:hidden;height:2em;}
.history ul,.history li{padding:0; margin:0; list-style:none;}
.history li {float:left;width:25%; overflow:hidden:}
</style>
<script src="global.js" type="text/javascript"></script>
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkIP()
{
	var ipArray,ip,j;
	ip = document.ipform.ip.value;
	
	if(/[A-Za-z_-]/.test(ip)){
		if(!/^([\w-]+\.)+((com)|(net)|(org)|(gov\.cn)|(info)|(cc)|(com\.cn)|(net\.cn)|(org\.cn)|(com\.ru)|(net\.ru)|(org\.ru)|(name)|(biz)|(hk)|(tv)|(cn))$/.test(ip)){
			alert("不是正确的域名");
			document.ipform.ip.focus();
			return false;
		}
	}
	else{
		ipArray = ip.split(".");
		j = ipArray.length
		if(j!=4)
		{
			alert("不是正确的IP");
			document.ipform.ip.focus();
			return false;
		}

		for(var i=0;i<4;i++)
		{
			if(ipArray[i].length==0 || ipArray[i]>255)
			{
				alert("不是正确的IP");
				document.ipform.ip.focus();
				return false;
			}
		}
	}
}
//-->
</SCRIPT>
</head>
<body>
<table bgcolor='#FFFFFF' bordercolorlight='#5391EE' border=1 cellspacing=0 cellpadding=3 bordercolordark='#FFFFFF' width=760 align='center'>
  <tr>
    <td height='25' bgcolor="#FFFFFF"><a href="http://www.511cha.com/">511Cha实用查询</a> &gt; <a href="http://www.511cha.com/ip/">IP地址查询</a></td>
  </tr>
</table>
<table bgcolor='#FFFFFF' bordercolorlight='#5391EE' border=1 cellspacing=0 cellpadding=3 bordercolordark='#FFFFFF' width=760 align='center'>
          <tr>
            <td height="30" align="center">
<div class="c">
	<div>
<FORM METHOD=POST ACTION="" name="ipform" onsubmit="return checkIP();">
<p>
<input type="text" name="ip" size="36" maxlength="100" id="url"> 
<input type="submit" value="查 询" id="sub">
<INPUT TYPE="hidden" name="action" value="2">
</p>
</FORM>
<?php
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 < count($ips); $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 || count($ip)>4) return 0;
    foreach($ip as $ip_addr) {
        if ( !is_numeric($ip_addr) ) return 0;
        if ( $ip_addr<0 || $ip_addr>255 ) 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:&nbsp;".$ip."<br>IP详细地址:&nbsp;".$QQWry->Country.$QQWry->Local."<br/>"; 
}else
{
echo "囧，你输入的IP,511Cha居然不能查询到!";
}
}else{
$ip=get_real_ip();
if (($_SERVER["HTTP_CLIENT_IP"]) or ($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ifErr=$QQWry->QQWry($ip); 
echo "您的真实P是".$ip."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;来自".$QQWry->Country.$QQWry->Local."<br/>"; 
$ip=$_SERVER['REMOTE_ADDR'];
$ifErr=$QQWry->QQWry($ip); 
echo "您的代理IP是".$ip."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;来自".$QQWry->Country.$QQWry->Local; 
}
else{
$ip=$_SERVER['REMOTE_ADDR']; 
$ifErr=$QQWry->QQWry($ip); 
echo "您的IP是：".$ip."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;来自：".$QQWry->Country.$QQWry->Local; 
 }
}
?>
	</div>
</div>
</td>
          </tr>
          </table>
<table bgcolor='#FFFFFF' bordercolorlight='#5391EE' border=1 cellspacing=0 cellpadding=3 bordercolordark='#FFFFFF' width=760 align='center'>
          <tr>
            <td height="30">
<div>
<p>　　提示：输入IP地址（如 61.160.23.195）或域名（如 www.baidu.com）后点击查询按钮即可，<font color=red>输入域名时不要加 http:// 前缀</font>。注意 www.baidu.com 和 baidu.com 代可能表了不同的服务器，其返回结果是有区别的！</p>
<p>　　输入IP地址即可查询IP地址所在的地理位置；输入域名，可以查出域名对应的IP地址，并通过这个IP地址查出域名的地理位置。
</p>
<p>　　本站拥有全国最新最全的IP数据库，每10天自动更新一次。收集了包括中国电信、中国网通、长城宽带、网通宽带、聚友宽带等 ISP 的最新准确 IP 地址数据，包括最全的网吧数据。为各位网友提供专业IP地址查询、地理位置查询、精确IP数据库等服务。
</p>
</div>
</td>
          </tr>
          </table>
<table bgcolor='#FFFFFF' bordercolorlight='#5391EE' border=1 cellspacing=0 cellpadding=3 bordercolordark='#FFFFFF' width=760 align='center'>
          <tr align="center">
                  <td height="30"><span class="Green"><script language="javascript1.2" src="http://www.511cha.com/ip/IpInfo.asp?sType=0"></script></span></td>
              </tr>
                <tr>
                  <td height="30"><script src="http://www.511cha.com/images/urlcopy.js"></script></td>
                </tr></table>
<br><center>Copyright &copy; <a href="http://www.511cha.com/">511Cha.com</a> All Rights Reserved</center>
</body>
</html>