我的服务器上没有安装 whois(显然它正在开发中,但没有真正的新闻)。我想知道是否有人知道一种模拟它的功能的方法。我想我应该将一些数据发布到某个网址,但我不知道什么,也不知道在哪里。

基本上我完全不知所措,非常感谢任何帮助,甚至是我可以研究的东西。

有帮助吗?

解决方案

您可以使用 PHP域名注册API 。这将允许您访问的WHOIS记录。要使用该功能有在该页面的底部的链接来一个类。请确保您有这一点。

其他提示

这里有一个我写前一阵子使用简单的一招(而不列出了所有的域名注册服务器)。我将它转换从Perl中,而且它也在C#和COM对象太

它不会做所有的WHOIS查询一些领域registars的贪婪* $!要你支付查找,选择不公开。还有的网页上关于它的详细信息。

<强>更新结果 下面的代码保存你下载。我写的使用PHP 3.X所以可能需要的一些PHP5按摩:

class Whois
{
    /*
     * Optional parameter for the server to be used for the lookup.
     * If this is not set, an appropriate whois server for the domain name
     * specified is automagically found by the Whois class. 
     * @type string
     * @access public
     */
    var $whois_server;
    /*
     * The timeout, in seconds, for the lookup. Default is 30. 
     * @type integer
     * @access public
     */
    var $timeout = 30;

    /*
     * Returns a string, with new-lines (\n) converted to non-breaking spaces (&lt;BR&gt;),
     * with details for the domain specified by $domain. 
     * @access public
     * @param string $domain the domain to lookup, excluding http:// and www
     * @return string the results of the whois
     */
    function lookup($domain)
    {
        $result = "";
        $parts  = array();
        $host   = "";

        // .tv don't allow access to their whois
        if (strstr($domain,".tv"))
        {
            $result = "'.tv' domain names require you to have an account to do whois searches.";
        // New domains fix (half work, half don't)
        } elseif (strstr($domain,".name") || strstr($domain,".pro") >0){
            $result = ".name,.pro require you to have an account to do whois searches.";
        } else{
            if (empty($this->whois_server))
            {
                $parts    = explode(".",$domain);
                $testhost = $parts[sizeof($parts)-1];
                $whoisserver   = $testhost . ".whois-servers.net";
                $this->host     = gethostbyname($whoisserver);
                $this->host     = gethostbyaddr($this->host);

                if ($this->host == $testhost)
                {
                    $this->host = "whois.internic.net";
                }
                flush();
            }
            $whoisSocket = fsockopen($this->host,43, $errno, $errstr, $this->timeout);

            if ($whoisSocket)
            {
                fputs($whoisSocket, $domain."\015\012");
                while (!feof($whoisSocket))
                {
                    $result .= fgets($whoisSocket,128) . "<br>";
                }
                fclose($whoisSocket);
            }
        }
        return $result;
    }
}

示例用法

$whois = new Whois();
echo "<B>compaq.it</B><BR>";
echo $whois->lookup("compaq.it");
echo "<HR>";

您也可以利用 Net_Whois此梨包

声明:我这个包的维护者

看一看 RFC3912 时,它定义了whois协议。基本上你只需要在端口43打开一个TCP套接字,由CR + LF终止的一条线发送您的请求,并从服务器读取回文本的斑点。

标准(不幸)没有定义查询的格式,也没有回复的,也没怎么找到合适的域名服务器根据你需要做什么来查询。

请看看我的更多细节这个其他的答复: https://unix.stackexchange.com/a /二十一万一千八百三十三分之四十零万七千零三十〇

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top