http://www.csdn.net/expert/topic/915/915093.xml?temp=.129925

解决方案 »

  1.   

    <? 
    $PORT=43; 
    $MAX_RETRIES=5; 
    $SLEEP_TIME=2; 
    function Getserver($domain) 

    $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" 
    ); 

    $domain=preg_replace("/^([^\.]*)\.([^\.]*)\./","",$domain);
    return $Servers[$domain]; 
    } function connect($Server) 

    global $RETRY,$PORT,$SLEEP_TIME; 
    if ($Server=="") {return(-1);} 
    $retry=0; 
    while ($retry<=$MAX_RETRIES) 

    $ptr=fsockopen($Server,$PORT); 
    if ($ptr>0) 

    return ($ptr); 

    else 

    $retry++; 
    sleep($SLEEP_TIME); 


    return(-1); 

    function Lookup($domainname,$server="") 

    global $result; 
    if(empty($server))$server=Getserver($domainname); 
    if (empty($server)) 

    $result="没有与该域名匹配的Whois服务器,是否拼错了?"; 
    return $result; 

    $ptr=connect($server); 
    if ($ptr==-1) 

    $result="无法连接到Whois服务器$server"; 
    return $result; 

    else 

    $result="";
    fputs($ptr, preg_replace("/^([^\.]*)\./","",$domainname)."\015\012"); 
    while (!feof($ptr)) $result .= fgets($ptr,128) . "<br>"; 
    fclose($ptr); 
    if(preg_match("|Whois Server:\s(.+)\n|",$result,$matches)&&$matches[1]!=$server)
    $result=Lookup($domainname,$matches[1]);//added by qiushuiwuhen(2002-8-18)
    return $result; 
    } } ?> <html> 
    <head> 
    <title>Untitled Document</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
    </head> 
    <form action=<?=$PHP_SELF?>>请输入欲查询的域名(带后缀):<input name=domainname></form>
    <body> 
    <? 
    echo "查询结果如下:"; 
    echo "<hr>"; 
    if(empty($domainname))$domainname="www.csdn.net"; 
    print Getserver($domainname); 
    print "<hr>"; 
    $result=Lookup($domainname); 
    echo $result; 
    ?> 
    </body> 
    </html>
      

  2.   

    tv用whois.tv,如下<? 
    $PORT=43; 
    $MAX_RETRIES=5; 
    $SLEEP_TIME=2; 
    function Getserver($domain) 

    $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" 
    ); 

    $domain=preg_replace("/^([^\.]*)\.([^\.]*)\./","",$domain);
    return $Servers[$domain]; 
    /*
    return "whois.nic.cc";
    return "whois.OnlineNIC.com";
    return "whois.nsiregistry.net";
    return "whois.cnnic.net.cn";
    return "rs.internic.net";
    return "whois.edu.cn"; //教育网
    return "whois.OnlineNic.com";
    */
    return "whois.nsiregistry.net";
    return "whois.networksolutions.com";//csdn
    return "whois.arin.net";
    return "whois.InterNIC.net";
    return "whois.verisign-grs.com";
    return "whois.geektools.com";
    } function connect($Server) 

    global $RETRY,$PORT,$SLEEP_TIME; 
    if ($Server=="") {return(-1);} 
    $retry=0; 
    while ($retry<=$MAX_RETRIES) 

    $ptr=fsockopen($Server,$PORT); 
    if ($ptr>0) 

    return ($ptr); 

    else 

    $retry++; 
    sleep($SLEEP_TIME); 


    return(-1); 

    function Lookup($domainname,$server="") 

    global $result; 
    if(empty($server))$server=Getserver($domainname); 
    if (empty($server)) 

    $result="没有与该域名匹配的Whois服务器,是否拼错了?"; 
    return $result; 

    $ptr=connect($server); 
    if ($ptr==-1) 

    $result="无法连接到Whois服务器$server"; 
    return $result; 

    else 

    $result="";
    fputs($ptr, preg_replace("/^([^\.]*)\./","",$domainname)."\015\012"); 
    while (!feof($ptr)) $result .= fgets($ptr,128) . "<br>"; 
    fclose($ptr); 
    if(preg_match("|Whois Server:\s(.+)\n|",$result,$matches)&&$matches[1]!=$server)
    $result=Lookup($domainname,$matches[1]);//added by qiushuiwuhen(2002-8-18)
    return $result; 
    } } ?> <html> 
    <head> 
    <title>Untitled Document</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
    </head> 
    <form action=<?=$PHP_SELF?>>请输入欲查询的域名(带后缀):<input name=domainname></form>
    <body> 
    <? 
    echo "查询结果如下:"; 
    echo "<hr>"; 
    if(empty($domainname))$domainname="www.matrox.tv"; 
    print Getserver($domainname); 
    print "<hr>"; 
    $result=Lookup($domainname); 
    echo $result; 
    ?> 
    </body> 
    </html>
      

  3.   

    呵呵,谢了,我只需要这几个字whois.tv