本款源碼是一款php 網站同IP查詢代碼哦,如果你喜歡就進來看看吧。
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 '
';
for($i=0;$i echo '
- '.$ipArr[$i].'
';
}
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;
}
?>
同IP網站查詢
0){ ?>
同IP網站查詢 |
|
輸入欄位名或者IP地址,查詢同一IP地址的伺服器上有哪些網站。 |
if($chaxun_status==1){ echo ''.$title.' > 網域名稱: '.$q; }elseif($chaxun_status==2){ echo ''.$title.' > IP: '.$ip; }else{ echo $title; } ?> |
if(!$q){ $ipq = '您的IP地址是:'.$ip.''; }elseif($chaxun_status == 0){ $ipq = '出錯啦!沒有找到與 '.$q.' 匹配的結果,請確定IP/網域名稱的格式是否寫對!
你的IP地址是:'.$ip; }elseif($chaxun_status==1){ $ipq = '你查詢的網域名稱 '.$q.' 網域名稱的IP: '.$ip.''; }else{ $ipq = "你查詢的IP:".$ip; } echo $ipq; ?> 0){ ?>
相關查詢: Alexa查詢 | 網域名稱註冊查詢 | Whois查詢 | IP地址查詢 | PR查詢 | 天氣預報查詢 | 模仿蜘蛛 | 友情連結查詢
|
© 2009 站長工具
同IP查詢代碼下載包
http://www.bkjia.com/PHPjc/445038.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445038.htmlTechArticle本款源碼是一款php 網站同IP查詢代碼哦,如果你喜歡就進來看看吧。 ?php if(function_exists('date_default_timezone_set')){ date_default_timezone_set('Asia/Sha...