由两部分组成,一个index.php文件,一个whois的接口文件;
1 2 3域名到期查询 4 5 6 7 8 9 20域名到期查询:
21
whois.php
1 domain = $udomain; 6 } 7 // 8 // 获取whois并分析域名状态 9 // ok 未被注册 10 // 非空值 过期时间 11 // 空值 未知 12 // 13 function GetInfo(){ 14 /* 15 $dinfo = trim($this->GetWhois()); 16 if($dinfo=="") return ""; 17 if(eregi("no match",$dinfo)) return "ok"; 18 //return $rs; 19 */ 20 $wl = ""; 21 $w_server = $this->GetServer(); 22 if($w_server=="") return ""; 23 $fp = fsockopen($w_server, 43, $errno, $errstr, 30); 24 if(!$fp){ 25 echo $errstr; 26 return ""; 27 } 28 29 $out = $this->domain."\r\n"; 30 $out .= "Connection: Close\r\n\r\n"; 31 fputs($fp, $out); 32 33 while (!feof($fp)){ 34 $wl = fgets($fp, 255); 35 36 if(eregi("no match",$wl)){ 37 fclose($fp); 38 return "ok"; 39 } 40 if(eregi("Expiration Date",$wl)){ 41 $lines = split(":",$wl); 42 $t = trim($lines[1]); 43 $ts = split(" ",$t); 44 $t = $ts[0]; 45 if(ereg("[^0-9-]",$t)){ 46 $ts = split("-",$t); 47 $t = $ts[2]."-".$this->MonthToNum($ts[1])."-".$ts[0]; 48 } 49 fclose($fp); 50 return $t; 51 } 52 } 53 fclose($fp); 54 return ""; 55 } 56 // 57 //获得域名的整个whois信息 58 // 59 function GetWhois(){ 60 $wh = ""; 61 $w_server = $this->GetServer(); 62 if($w_server=="") return ""; 63 $fp = fsockopen($w_server, 43, $errno, $errstr, 30); 64 65 if(!$fp){ 66 echo $errstr; 67 return ""; 68 } 69 $out = $this->domain."\r\n"; 70 $out .= "Connection: Close\r\n\r\n"; 71 fputs($fp, $out); 72 while (!feof($fp)){ 73 $wh .= nl2br(fgets($fp, 255)); 74 } 75 fclose($fp); 76 return $wh; 77 } 78 // 79 //输出当前域名的状态信息 80 // 81 function PrintSta(){ 82 $rs = $this->GetInfo(); 83 if($rs=="ok") echo "
注意两点:
1,index.php要include一下whois文件。
2,通过post方式传name = "yuming"这个值来实现查询,index.php传,whois.php接收。
接收方式
1 //接收域名值 2 if ($_SERVER["REQUEST_METHOD"] == "POST"){ 3 $yuming = test_input($_POST["yuming"]); 4 } 5 6 function test_input($data){ 7 $data = trim($data); 8 $data = stripslashes($data); 9 $data = htmlspecialchars($data);10 return $data;11 }