Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | Email

47.2.  whois 域名查詢

 		
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>whois</title>
</head>
<body>
<fieldset>
<legend>whois</legend>
<form name="form1" method="post" action="<? $PHP_SELF ?>">
<input type="text" name="domainname">
.cn
<input type="submit" name="Submit" value="查詢">
</form>
</fieldset>

查詢域名:
<?echo $domainname;?>
.cn
<?php
$fp = fsockopen ("whois.cnnic.cn", 43 , $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs ($fp, "$domainname".".cn"."\r\n");
echo "<pre>";
while (!feof($fp)) {

$data = fgets ($fp,1024);
$data = str_replace("no matching record", "該域名沒有被註冊\n<a href='http://www.cnwwwcn.com'>我想註冊該域名</a>", $data);
/*
$data = fgetc ($fp);

if($data == "\n"){
echo "<br>";
}
*/
echo $data;
//no matching record
}
echo "</pre>";
fclose ($fp);
}
?>
</body>
</html>