jxyuhua的地盘

PHP WEB开发 电子商务

查询域名是否注册(WHOIS)

以下是一个简单的WHOIS程序,原出处不详,它实现的功能也不够全面,希望有个抛砖引玉的功能:

<?

//本例用PHP4实现顶级域名查询

if ($domain)

{

if ($domain)

        {

         //连接到internic域名服务器

        $fp = fsockopen( "rs.internic.net", 43, &$errno, &$errstr, 100);

        if (!$fp)

    {

        echo  "$errstr ($errno)<br>/n";

        }

        else

        {

        fputs($fp, "$domain/r/n");

        while(!feof($fp))

                {

                $buf = fgets($fp,128);

                if (ereg( "Whois Server:", $buf))

                        {

                        $server = str_replace( "Whois Server: ",  "", $buf);

                        $server = trim($server);

                        }

                }

        fclose($fp);

        }

     

       

        if ($server)

                {

                echo  "<B>$domain 的注册服务器是 $server:</B><BR>";

                echo  "<PRE>";

                $fp = fsockopen($server, 43, &$errno, &$errstr, 10);

                if(!$fp)

                        {

                        echo  "不能连接到服务器 $server 43端口./n";

                        echo  "$errstr ($errno)<br>/n";

                        }

                else

                        {

                        fputs($fp, "$domain/r/n");

                        while(!feof($fp))

                                {

                                echo fgets($fp,128);

                                }

                        fclose($fp);

                        }

                }

        else    {

                echo( "<b>$domain 没有注册。</b><BR>");

                }

        echo ( "</PRE><BR>");

        }

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

}

?>

 

<FORM ACTION=" <?PHP echo($PHP_SELF); ?>" METHOD="post">

  只能查询.com,.net.org的域名<br>

  输入域名:<INPUT TYPE="text" NAME="domain" SIZE="30" MAXLENGTH="100">

  <INPUT TYPE=submit VALUE=" ">

</FORM>

 

阅读更多
个人分类: PHP
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

查询域名是否注册(WHOIS)

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭