Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | Email

43.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>