PHP fsockopen WHOIS

发布于 2024-12-20 00:39:13 字数 1271 浏览 2 评论 0原文

我目前正在尝试通过 fsockopen 连接到 nominet whois 服务,但我在阅读回复时遇到问题。

使用的代码:

$fp = fsockopen("whois.nic.uk", 43, $errno, $errstr);

if (!$fp) {
    echo "ERROR: $errno - $errstr<br />\n";
} else {
echo "<h1>Connected To The WHOIS Server.</h1>\n\n";
}


fwrite($fp, "madeupdomain.co.uk\r\n");
$lookup = fread($fp, 4096);
fclose($fp);


echo $lookup;

现在我成功连接到 WHOIS 服务器并收到回复,但总是错过结尾。

域名:madeupdomain.co.uk 注册人:Made Up Inc. 注册人类型:未知 注册人地址:123 Fake Road City UK 注册商:Made Up。 t/a Madeup[Tag = MADEUP] URL:http://www.madeupadomain.com 相关日期:注册于: 1955 年 2 月 14 日 续订日期: 2016 年 2 月 11 日 最后更新: 2001 年 2 月 11 日 注册状态: 注册至续订日期。名称服务器: ns1.madeupnamesrver.com ns2.madeupnamesrver.com ns3.madeupnamesrver.com ns4.madeupnamesrver.com WHOIS 查询于 2011 年 12 月 7 日 00:00:00 进行 - 此 WHOIS 信息由 Nominet UK 免费提供.uk 域名的中央注册机构。此信息和 .uk WHOIS 均为:Copyright Nominet UK 1996 - 2011。您不得访问 .uk WHOIS 或使用其中的任何数据,除非 http://www.nominet.org.uk/whois,其中包括以下限制:(A) 将数据用于广告、或者其重新打包、重新编译、重新分发

正如您所看到的,它缺少真正的 whois 查找的最后一部分,这种情况总是会发生,但它被切断的位置会根据我查询的域而变化。

有人有什么建议吗?

谢谢。

I am currently trying to connect to nominets whois service via fsockopen but I'm having a problem reading the reply.

code used:

$fp = fsockopen("whois.nic.uk", 43, $errno, $errstr);

if (!$fp) {
    echo "ERROR: $errno - $errstr<br />\n";
} else {
echo "<h1>Connected To The WHOIS Server.</h1>\n\n";
}


fwrite($fp, "madeupdomain.co.uk\r\n");
$lookup = fread($fp, 4096);
fclose($fp);


echo $lookup;

Now I succesfully connect to the WHOIS server and receive a reply but it always misses the end off.

Domain name: madeupdomain.co.uk Registrant: Made Up Inc. Registrant type: Unknown Registrant's address: 123 Fake Road City UK Registrar: Made Up. t/a Madeup[Tag = MADEUP] URL: http://www.madeupadomain.com Relevant dates: Registered on: 14-Feb-1955 Renewal date: 11-Feb-2016 Last updated: 11-Feb-2001 Registration status: Registered until renewal date. Name servers: ns1.madeupnamesrver.com ns2.madeupnamesrver.com ns3.madeupnamesrver.com ns4.madeupnamesrver.com WHOIS lookup made at 00:00:00 07-Dec-2011 -- This WHOIS information is provided for free by Nominet UK the central registry for .uk domain names. This information and the .uk WHOIS are: Copyright Nominet UK 1996 - 2011. You may not access the .uk WHOIS or use any data from it except as permitted by the terms of use available in full at http://www.nominet.org.uk/whois, which includes restrictions on: (A) use of the data for advertising, or its repackaging, recompilation, redistribut

As you can see it's missing the last part of a true whois lookup, this always happens but the position where it is cut off changes depending on what domain I query.

Does anyone have any suggestions?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只想待在家 2024-12-27 00:39:13

您只读取了 4096 个字节:

fread($fp, 4096);

如果您想读取更多字节(显然您需要),只需增加数字或循环直到 EOF:

while (!feof($fp)) {
   $contents .= fread($fp, 8192);
}

You only read 4096 bytes:

fread($fp, 4096);

If you want to read more than that (which you obviously need to) just increase the number or loop until EOF:

while (!feof($fp)) {
   $contents .= fread($fp, 8192);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文