This source code is a php website with the same IP address query code. If you like it, please come and check it out.
<? Php
If (function_exists ('date _ default_timezone_set ')){
Date_default_timezone_set ('Asia/Shanghai'); // set the time zone
}
Define ("APP_ROOT", dirname (_ FILE _); // The website root directory
Function visitorIP () {// visitor 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) {// sort domain names $ w = 1 filter www. prefix $ w = 0 do not filter
$ Q = htmlspecialchars (strtolower (trim ($ q )));
If (substr ($ q,) = "http: //" | substr ($ q,) = "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;
}
// Obtain the webpage
Class HTTPRequest
{
/*
Get webpage
*/
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/123'. $ 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 ){
// Save the webpage code to a string
$ R = new HTTPRequest ($ siteurl );
$ Htm = $ r-> DownloadToString ();
Return $ htm;
}
$ Visitorip = visitorIP ();
$ Q = cleanDomain ($ _ POST ['q']);
$ Q_encode = urlencode ($ q );
$ Title = "Same IP Site query ";
$ Chaxun_status = 0; // query status-1: No query parameter; 0: Query error; 1: query domain name; 2: Query IP
If (isset ($ _ GET ['action']) & trim ($ _ GET ['action']) = "do") {// call up data through AJAX
$ IpArr = ReverseIP ($ q );
If (count ($ ipArr)> 0 ){
Echo '<p class = "f14"> here, the IP addresses locate'. count ($ ipArr). 'domain names, see: </p> ';
Echo '<ul class = "lst"> ';
For ($ I = 0; $ I <count ($ ipArr); $ I ++ ){
Echo '<li> <a href = "http ://'. $ ipArr [$ I]. '/"title =" access '. $ ipArr [$ I]. '"target =" _ blank "class =" f14 l200 "> '. $ ipArr [$ I]. '</a> </li> ';
}
Echo '</ul> <div class = "cboth"> </div> ';
} Else {
Echo '<p class = "f14"> the Domain Name Record corresponding to IP'. $ ip. 'is not found! </P> ';
}
Die ();
}
Function IpToInt ($ Ip) {// convert IP to a number
$ 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/'.20.q );
Preg_match_all ('/<a href = "/whois/(. *)"> Whois </a>/', $ htm, $ tt );
$ Res = $ tt [1];
Return $ res;
}
If (preg_match ("/[a-zA-Z-_] +/si", $ q) {// if the domain name is queried
$ 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) {// If the IP address is queried
$ Ip = $ q;
$ Chaxun_status = 2;
} Else {
$ Ip = $ visitorip;
}
?>
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> same IP Site query </title>
<Style>
* {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 ;}
</Style>
<? If ($ chaxun_status> 0) {?>
<SCRIPT type = "text/javascript">
<! --
Var xmlHttp;
Function creatXMLHttpRequest (){
If (window. ActiveXObject ){
XmlHttp = new ActiveXObject ('Microsoft. xmlhttp ');
} Else if (window. XMLHttpRequest ){
XmlHttp = new XMLHttpRequest ();
}
}
Function startRequest (){
Var queryString;
Var domain = "<? = $ Ip?> ";
QueryString = "q =" + domain;
CreatXMLHttpRequest ();
XmlHttp. open ("POST ","./? Action = do "," true ");
XmlHttp. onreadystatechange = handleStateChange;
XmlHttp. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded ;");
XmlHttp. send (queryString );
}
Function handleStateChange (){
If (xmlHttp. readyState = 1 ){
Document.getElementById('ipresult').style.css Text = "";
Document. getElementById ('ipresult'). innerHTML = '<span class = "green"> loading result... </span> ';
}
If (xmlHttp. readyState = 4 ){
If (xmlHttp. status = 200 ){
Document.getElementById('ipresult').style.css Text = "";
Var allcon = xmlHttp. responseText;
Document. getElementById ('ipresult'). innerHTML = allcon;
}
}
}
// -->
</SCRIPT>
<? }?>
</Head>
<Body>
<Div align = "center">
<Table cellspacing = "4" cellpadding = "0" style = "background-color: # f7f7f7; border-bottom: 1px solid # dfdfdf;" width = "778">
<Tr>
<Td align = "left"> <a href = "/" target = "_ blank"> webmaster tools </a> & gt; <a href = ". /"target =" _ blank "> same IP Site query </a> </td>
<Td align = "right"> <a href = "javascript:;" onClick = "window. external. addFavorite (document. location. href, document. title); "> Add this page to favorites </a> </td> </tr> </table>
<Div id = "result"> <br/>
<Table width = "700" cellpadding = "2" cellspacing = "0" style = "border: 1px solid # B2D0EA;">
<Tr>
<Th align = "left"> <a href = "./" target = "_ blank"> same IP Site query </a> </th>
</Tr>
<Tr> <td align = "center">
<Table border = "0" cellPadding = "0" cellSpacing = "1">
<Tr> <td style = "font-size: 14px">
<Br/>
<Form action = "" method = "post" name = "f1"> IP address or domain name <input name = "q" id = "q" type = "text" size =" 18 "delay =" 0 "value =" <? If ($ chaxun_status> 0) echo $ q;?> "Style =" width: 200px; height: 22px; font-size: 16px; font-family: Geneva, Arial, Helvetica, sans-serif; "/> <input type =" submit "value =" query "/> </form>
</Td> </tr> </table> <br/>
</Td> </tr>
<Tr> <td align = "center" valign = "middle" height = "40" style = "font-size: 12px"> enter the domain name or IP address, query the websites on servers with the same IP address. </Td> </tr>
</Table>
<Br/>
<Table width = "700" cellpadding = 2 cellspacing = 0 style = "border: 1px solid # B2D0EA;">
<Tr>
<Th align = "left"> <?
If ($ chaxun_status = 1 ){
Echo '<a href = "./">'. $ title. '</a> & gt; Domain Name:'. $ q;
} Elseif ($ chaxun_status = 2 ){
Echo '<a href = "./">'. $ title. '</a> & gt; IP:'. $ ip;
} Else {
Echo $ title;
}
?> </Th>
</Tr>
<Tr> <td align = "left">
<Div style = "padding: 20px">
<P class = "f14">
<?
If (! $ Q ){
$ Ipq = 'your ip address is: <span class = "blue f14"> '. $ ip.' </span> ';
} Elseif ($ chaxun_status = 0 ){
$ Ipq = '<B class = "red f14"> error! </B> not found with <B class = "blue f14"> '. $ q. '</B> check whether the IP/Domain Name format is correct! </P> <p class = "f14 blue"> your ip address is '. $ ip;
} Elseif ($ chaxun_status = 1 ){
$ Ipq = 'your queried domain name <span class = "blue f14"> '. $ q. '</span> </p> <p class = "f14"> IP address of the domain name: <span class = "blue f14"> '. $ ip. '</span> ';
} Else {
$ Ipq = "Your queried IP Address:". $ ip;
}
Echo $ ipq;
?> </P> <? If ($ chaxun_status> 0) {?>
<Div id = "ipresult"> </div> <script> startRequest (); </script>
<? }?> </P> </Div>
</Td> </tr>
</Table> <br/>
</Div>
</Div>
<Div id = "footer"> & copy; 2009 <a href = "http://tool.111cn.cn/"> webmaster tools </a> </div>
<Div style = "display: none;"> </div>
</Body>
</Html>
Download Code from the same IP address