Ipwhois query, domain whois query

Source: Internet
Author: User
Tags explode php tutorial trim tld

<div class=contentbox>
<div class= "Content_nav" ><span class= "tt" >ip/domain name whois query </span></div>
<div class=toolitem>
<br>
<form action= "" method= "get" >
ip/domain name: <input style= "height:26px;border:1px solid RGB (126, 157, 185); Background-color:white, "id=" Query "maxlength=" size= "name=" "Q" autocomplete= "Off" type= "text" value= " PHP tutorial echo $q?> ">
<span class= "Backgroundbord" ><button class= "Srh_onesearch" type= "submit" > Enquiry </button></span >
</form>
</div>
</div>
<?php
require_once $_server[' document_root ']. ' /ad/mid.php ';
if ($q 2<> ') {
if ($isdomain) {
Echo ' <div class=contentbox> ';
Echo ' <div class= "Content_nav" ><span class= "tt" > Query result </span></div> ';
Echo ' <div class=topmenuitem> ';
Server List File
$config [' server_list '] = "./whois/servers.lst";
Whois ($domain);
Echo ' </div> ';
Echo ' </div> ';
}elseif ($ISIP) {
Echo ' <div class=contentbox> ';
Echo ' <div class= "Content_nav" ><span class= "tt" > Query result </span></div> ';
Echo ' <div class=topmenuitem> ';
$sourcecode =getsourcecode (". NET tutorial/apnic-bin/whois.pl?searchtext=". $q ">http://wq.apnic.net/apnic-bin/ Whois.pl?searchtext= ". $q);
Echo $sourcecode;
Preg_match ('/(<pre><b><u>.*?) <div class= "Highlight" id= "key" >/s ', $sourcecode, $ipwhois);
$result = $ipwhois [1];
$result =nl2br ($result);
echo $result;
Echo ' </div> ';
Echo ' </div> ';
}else{
Echo ' <div class=contentbox> ';
Echo ' <div class= "Content_nav" ><span class= "tt" >error! </span></div> ';
Echo ' <div Class=topmenuitem><p><font color=red>error! </font> Please make sure that you do not enter the domain name (Chinese domain name is not supported) is IP, if you enter the phone number and so we can not find! </p> ';
Echo ' </div> ';
Echo ' </div> ';
}
}else{
Echo ' <div class=contentbox> ';
Echo ' <div class= "Content_nav" ><span class= "tt" > Tool description </span></div> ';
Echo ' <div class=topmenuitem><p> Please enter IP or domain name, such as chaxun.la or xxx.xxx.xxx.xxx</p> ';
Echo ' </div> ';
Echo ' </div> ';
}
function whois () {
Global $domain;
if (! $server = Get_server ()) {
Die ("Cannot query this type of domain name");
}
$result = Whois_request ($server [' Server '], $domain);
if (! $result) {
echo "Cannot connect to server";
Die ();
}
$server [' Info ']=trim ($server [' info ']);
if ($server [' info ']) {
$he = Strpos ($result, $server [' info ']) + strlen ($server [' info ']);
$le = Strpos ($result, "", $he);
$whois _server = Trim (substr ($result, $he, $le-$he));
$result 2 = whois_request ($whois _server, $domain);
if ($result 2) {
Echo nl2br ($result. "The following information comes from:". $whois _server. " ". $result 2);
}else {
echo nl2br ($result);
}
}else {
echo nl2br ($result);
}
}
/*function whois () {
Global $domain;
if (! $server = Get_server ()) {
echo "Cannot query this type of domain name";
}else{
$result = Whois_request ($server [' Server '], $domain);
if (! $result) {
echo "Cannot connect to server";
} else {
echo $result;
}
}
}
*/
function Whois_request ($server, $query)
{
$data = "";
if (! $fp = @fsockopen ($server, 43)) {
return false;
} else {
Fputs ($FP, $query. " ");
while (!feof ($fp)) {
$data. = Fread ($fp, 1000);
}
Fclose ($FP);
}
Return nl2br ($data);
return $data;
}

Function Get_server () {
 global $config, $domain;
  $serverarray = file ($config [' server_list ']);
  $i = 0;
 foreach ($serverarray as $key => $val) {
  if (substr ($val, 0,1)!= "#") {
     $server _p = explode ("|", $val);
    $server [$i] [' tld '] = $server _p[0];
    $server [$i] [' server '] = $server _p[1];
    $server [$i] [' avail '] = $server _p[2];
    $server [$i] [' infoserver '] = $server _p[3];
    $server [$i] [' backserver '] = $server _p[4];
    $server [$i] [' info '] = $server _p[5];
  }
   $i + +;
 }

$domain _c = Explode (".", $domain);
$partnum = count ($domain _c);
$last _part_1 = $domain _c[$partnum-1];
$last _part_2 = $domain _c[$partnum-2];

foreach ($server as $key => $val) {
if ($val [' tld '] = = = $last _part_2. ". $last _part_1) {
return $val;
} elseif ($val [' tld '] = = $last _part_1) {
return $val;
}
}
return false;
}

$q =trim ($_get[' Q ']);
$q 2= $q;
if ($q <> ') {
if ($q =matchip ($q 2)) {
$isip = 1;
}elseif ($q =matchdomain ($q 2)) {
$domain =topdomain ($q 2);
$isdomain = 1;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.