【问题标题】:Whois Arin and phpWhois Arin 和 php
【发布时间】:2014-06-02 13:37:25
【问题描述】:

我对 php 和 whois.arin.net 有疑问

$whois="whois.arin.net";
$ip="xx.xx.xx.xx";
$sk=fsockopen($whois, 43, $errno, $errstr, 30) or die('Connessione impossibile');
fputs ($sk, $ip."\r\n") or die('Request impossibile');
while (!feof($sk)) {
  $info.= fgets ($sk, 2048);
}

$i=explode("\n",$info);
foreach($i as $val){
  $descr=explode("\n",$val);
  echo $descr[0];
}

出现的错误是

ARIN WHOIS 数据和服务受使用条款的约束

查询词不明确。假设查询为:n xx-xx-xx-xx

有什么问题?

【问题讨论】:

  • 你试过fputs($sk, 'n '.$ip."\r\n"); 吗?似乎是在说这是假定的命令。
  • 如果我修改,消失,错误查询不明确,但仍然错误 ARIN WHOIS 数据和服务受使用条款约束

标签: php whois


【解决方案1】:

一个非常简单的支持 ARIN 的 PHP whois 函数如下所示:

function whois($domain, $server) {

    // format input for the specific server
    if($server == 'whois.arin.net') {
        $domain = "n + $domain";
    }

    // connect and send whois query
    $connection = fsockopen($server, 43, $errno, $errstr, 30);
    $request = fputs($connection, $domain . "\r\n");

    if(!$connection OR !$request){
       return "Error $errno: $errstr.";
    }

    // get the whois data
    $data = '';
    while(!feof($connection)){
            $data .= fgets($connection);
    }

    fclose($connection);
    return trim($data);
}

然后你可以像这样调用函数:

echo whois('8.8.8.8', 'whois.arin.net');

【讨论】:

  • 我们可以在其中添加 rwhois.hostwinds.com 数据吗?
  • 只是一个注释。这不适用于大多数共享主机环境,因为这些天由于安全风险,传出端口通常在共享主机上关闭。共享托管脚本应使用以 XML 或 JSON 形式返回 Whois 数据的 Whois RWS API。更多信息请访问:whois.arin.net/ui
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-14
  • 2021-05-07
  • 1970-01-01
相关资源
最近更新 更多