douyan8267 2014-06-02 13:37
浏览 97

Whois Arin和php

I have a problem with php and 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."
") or die('Request impossibile');
while (!feof($sk)) {
  $info.= fgets ($sk, 2048);
}

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

The error that appears is

ARIN WHOIS data and services are subject to the Terms of Use

Query terms are ambiguous. The query is assumed to be: n xx-xx-xx-xx

What is the problem?

  • 写回答

1条回答 默认 最新

  • dougua4836 2014-06-02 14:45
    关注

    A very simple PHP whois function that supports ARIN would look like this:

    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 . "
    ");
    
        if(!$connection OR !$request){
           return "Error $errno: $errstr.";
        }
    
        // get the whois data
        $data = '';
        while(!feof($connection)){
                $data .= fgets($connection);
        }
    
        fclose($connection);
        return trim($data);
    }
    

    Then you can call the function like so:

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

报告相同问题?

悬赏问题

  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥15 看一下OPENMV原理图有没有错误
  • ¥100 H5网页如何调用微信扫一扫功能?
  • ¥15 讲解电路图,付费求解
  • ¥15 有偿请教计算电磁学的问题涉及到空间中时域UTD和FDTD算法结合的
  • ¥15 vite打包后,页面出现h.createElement is not a function,但本地运行正常
  • ¥15 Java,消息推送配置
  • ¥15 Java计划序号重编制功能,此功能会对所有序号重新排序,排序后不改变前后置关系。
  • ¥15 关于哈夫曼树应用得到一些问题
  • ¥15 使用sql server语句实现下面两个实验(需要代码和运行结果截图)