本款源码是一款php 网站同IP查询代码哦,如果你喜欢就进来看看吧。
<?php
if(function_exists(‘date_default_timezone_set’)){
date_default_timezone_set(‘Asia/Shanghai’); //设定时区
}
define(“APP_ROOT”,dirname(dirname(__FILE__))); //网站根目录
function visitorIP(){ //访问者IP
if($_SERVER[‘HTTP_X_FORWARDED_FOR’]){
$ipa = $_SERVER[‘HTTP_X_FORWARDED_FOR’];
}elseif($_SERVER[‘HTTP_CLIENT_IP’]){
$ipa = $_SERVER[‘HTTP_CLIENT_IP’];
}else{
$ipa = $_SERVER[‘REMOTE_ADDR’];
}
return $ipa;
}
function cleanDomain($q,$w=0){ //整理域名 $w=1过滤www.前缀 $w=0不过滤
$q = htmlspecialchars(strtolower(trim($q)));
if(substr($q,0,7) == “http://” || substr($q,0,8) == “https://” || substr($q,0,6) == “ftp://”){
$q = str_replace(“http:/”,””,$q);
$q = str_replace(“https:/”,””,$q);
$q = str_replace(“ftp:/”,””,$q);
}
if(substr($q,0,4) == “www.” && $w==1) {
$q = str_replace(“www.”,””,$q);
}
$q = trim($q,”/”);
return $q;
}
//获取网页
class HTTPRequest
{
/*
获取网页
*/
var $_fp; // HTTP socket
var $_url; // full URL
var $_host; // HTTP host
var $_protocol; // protocol (HTTP/HTTPS)
var $_uri; // request URI
var $_port; // port
// scan url
function _scan_url()
{
$req = $this->_url;
$pos = strpos($req, ‘://’);
$this->_protocol = strtolower(substr($req, 0, $pos));
$req = substr($req, $pos+3);
$pos = strpos($req, ‘/’);
if($pos === false)
$pos = strlen($req);
$host = substr($req, 0, $pos);
if(strpos($host, ‘:’) !== false)
{
list($this->_host, $this->_port) = explode(‘:’, $host);
}
else
{
$this->_host = $host;
$this->_port = ($this->_protocol == ‘https’) ? 443 : 80;
}
$this->_uri = substr($req, $pos);
if($this->_uri == ”)
$this->_uri = ‘/’;
}
// constructor
function HTTPRequest($url)
{
$this->_url = $url;
$this->_scan_url();
}
// download URL to string
function DownloadToString()
{
$crlf = “rn”;
$response=””;
// generate request
$req = ‘GET ‘ . $this->_uri . ‘ HTTP/1.0’ . $crlf
. ‘Host: ‘ . $this->_host . $crlf
. $crlf;
// fetch
$this->_fp = @fsockopen(($this->_protocol == ‘https’ ? ‘ssl://’ : ”) . $this->_host, $this->_port);
@fwrite($this->_fp, $req);
while(is_resource($this->_fp) && $this->_fp && !feof($this->_fp))
$response .= fread($this->_fp, 1024);
@fclose($this->_fp);
// split header and body
$pos = strpos($response, $crlf . $crlf);
if($pos === false)
return($response);
$header = substr($response, 0, $pos);
$body = substr($response, $pos + 2 * strlen($crlf));
// parse headers
$headers = array();
$lines = explode($crlf, $header);
foreach($lines as $line)
if(($pos = strpos($line, ‘:’)) !== false)
$headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos+1));
// redirection?
if(isset($headers[‘location’]))
{
$http = new HTTPRequest($headers[‘location’]);
return($http->DownloadToString($http));
}
else
{
return($body);
}
}
}
function get_html($siteurl) {
//将网页代码存入字符串
$r=new HTTPRequest($siteurl);
$htm=$r->DownloadToString();
return $htm;
}
$visitorip = visitorIP();
$q = cleanDomain($_POST[‘q’]);
$q_encode = urlencode($q);
$title = “同IP站点查询”;
$chaxun_status = 0; //查询状态 -1是没有查询参数,0是查询出错,1是查域名,2是查IP
if(isset($_GET[‘action’]) && trim($_GET[‘action’]) == “do”){ //AJAX调出数据
$ipArr = ReverseIP($q);
if(count($ipArr)>0){
echo ‘
在此IP找到了’.count($ipArr).’个域名,见下:
‘;
echo ‘
- ‘;
- ‘.$ipArr[$i].’
for($i=0;$i<count($ipArr);$i++){
echo ‘
‘;
}
echo ‘
‘;
}else{
echo ‘
没有找到IP ‘.$ip.’ 对应的域名记录!
‘;
}
die();
}
function IpToInt($Ip){ //IP转为数字
$array=explode(‘.’,$Ip);
$Int=($array[0] * 256*256*256) + ($array[1]*256*256) + ($array[2]*256) + $array[3];
return $Int;
}
function ReverseIP($q){
$htm = get_html(‘http://www.ip-adress.com/reverse_ip/’.$q);
preg_match_all(‘/Whois/’, $htm, $tt);
$res = $tt[1];
return $res;
}
if(preg_match(“/[a-zA-Z-_]+/si”,$q)){ //如果查询的是域名
$ip = gethostbyname($q);
if($ip == $q){
$ip = $visitorip;
$chaxun_status = -1;
}else{
$chaxun_status = 1;
}
}elseif(ereg(“^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$”,$q)){ //如果查询的是IP
$ip = $q;
$chaxun_status = 2;
}else{
$ip = $visitorip;
}
?>
*{margin:0;padding:0;}
body{font-size:12px;font-family: Geneva, Arial, Helvetica, sans-serif;}
a img {border:0;}
.red{color:#f00;}
.center{text-align:center;}
p{padding:5px 0 6px 0;word-break:break-all;word-wrap:break-word;}
.f14{font-size:14px;}
a,a:visited{color:#0353ce;}
table {font-size:12px;}
table th {font-size:12px;font-weight:bold;background-color:#f7f7f7;line-height:200%;padding: 0 5px;}
table th {font-size:12px;font-weight:bold;background:#EDF7FF;padding: 0 5px;color:#014198;line-height:200%;}
.red{color:red}
.blue{color:blue}
#footer{line-height:150%;text-align:center;color:#9c9c9c;padding: 8px 0;}
#footer a,#footer a:visited{color:#9c9c9c;}
ul.lst{padding:0;margin:0;width:100%;}
ul.lst li{list-style-type:none;float:left;padding:0 0 0 12px;line-height:24px;height:24px;overflow:hidden;}
ul.lst li{width:258px!important;width:270px;}
0){ ?>
站长工具 > 同IP站点查询 | 收藏本页 |
同IP站点查询 | |
---|---|
|
|
输入域名或者IP地址,查询同一IP地址的服务器上有哪些网站。 |
<? if($chaxun_status==1){ echo ”.$title.’ > 域名: ‘.$q; }elseif($chaxun_status==2){ echo ”.$title.’ > IP: ‘.$ip; }else{ echo $title; } ?> |
---|
<? 你的IP地址是:’.$ip; 域名的IP: ‘.$ip.’‘; 0){ ?> 相关查询: Alexa查询 | 域名注册查询 | Whois查询 | IP地址查询 | PR查询 | 天气预报查询 | 模仿蜘蛛 | 友情链接查询 |
© 2009 站长工具
同IP查询代码下载包