PHP 批量 WHOIS 检查器和烦人的数组
我的项目的目标是创建一个批量 WHOIS 检查器,它输出多个 WHOIS 记录中的选择信息。
我想我已经很接近完成它了,只是有一个我无法弄清楚的烦人的错误。 (这可能是非常简单的事情)
我的代码如下;
$domain = explode("\r\n", $domains);
print_r($domain);
echo "<br /><br />";
foreach ($domain as $item) {
fwrite($fp, $item . "\r\n");
while (!feof($fp)) {
$lookup .= fread($fp, 8192);
}
$value = explode("\r\n\r\n", $lookup);
$whois_data = array();
foreach ($value as $values) {
$details = explode(":\r\n", $values, 2);
$whois_data[trim($details[0])] = $details[1];
}
echo "Show WHOIS data for " . $item . "<br />";
print_r($whois_data);
unset($whois_data);
echo "<br /><br />";
}
$domains 是一个文本区域框,每行一个域,我的 PHP 输出如下;
数组 ( [0] => madeupdomainname.co.uk [1] => anothermadeupdomain.co.uk )
显示 madeupdomainname.co.uk 的 WHOIS 数据
Array ( [域名] => madeupdomainname.co.uk [注册人] => Made Up Inc. [注册人类型] => 未知 [注册人地址] => 123 Fake Road City UK [注册商] => Made Up Inc. t/a Made Up [标签 = MADEUP] URL:madeupdomainname.co.uk [相关日期] =>注册日期:1929 年 2 月 14 日 续订日期:2023 年 2 月 11 日 最后更新:2031 年 2 月 12 日 [注册状态] => 已注册至续订日期。 ns2.madeupdomainname.co.uk ns3.madeupdomainname.co.uk ns4.madeupdomainname.co.uk [WHOIS 查询于 2011 年 12 月 8 日 01:09:24 进行] => [-- 此 WHOIS 信息由 .uk 域名中央注册机构 Nominet UK 免费提供。此信息和 .uk WHOIS 是: ] => [版权提名英国 1996 - 2011。] => [您不得访问 .uk WHOIS 或使用其中的任何数据,除非经 nominet.org.uk/whois 上提供的完整使用条款允许,其中包括以下限制:(A) 将数据用于广告,或其重新打包、重新编译、重新分发或再利用 (B) 模糊、删除或隐藏本通知的任何或全部内容以及 (C) 超出查询率或数量限制。数据按“原样”提供,可能落后于寄存器。访问权限可能随时被撤销或限制。] => )
显示 anothermadeupdomain.co.uk 的 WHOIS 数据
Array ( [域名] => madeupdomainname.co.uk [注册人] => Made Up Inc. [注册人类型] => 未知 [注册人地址] => 123 Fake Road City UK [注册商] => Made Up Inc. t/a Made Up [标签 = MADEUP] URL:madeupdomainname.co.uk [相关日期] =>注册日期:1929 年 2 月 14 日 续订日期:2023 年 2 月 11 日 最后更新:2031 年 2 月 12 日 [注册状态] => 已注册至续订日期。 ns2.madeupdomainname.co.uk ns3.madeupdomainname.co.uk ns4.madeupdomainname.co.uk [WHOIS 查询于 2011 年 12 月 8 日 01:09:24 进行] => [-- 此 WHOIS 信息由 .uk 域名中央注册机构 Nominet UK 免费提供。此信息和 .uk WHOIS 是: ] => [版权提名英国 1996 - 2011。] => [您不得访问 .uk WHOIS 或使用其中的任何数据,除非经 nominet.org.uk/whois 上提供的完整使用条款允许,其中包括以下限制:(A) 将数据用于广告,或其重新打包、重新编译、重新分发或再利用 (B) 模糊、删除或隐藏本通知的任何或全部内容以及 (C) 超出查询率或数量限制。数据按“原样”提供,可能落后于寄存器。访问权限可能随时被撤销或限制。] => )
正如您所看到的,它正确地从第一个域获取 WHOIS 数据,但随后忽略第二个域,只是重新使用第一个域的 WHOIS 信息,这确实让我烦恼。有什么建议吗?
谢谢。
The aim of my project is to create a bulk WHOIS checker which outputs select information from multiple whois records.
I think I'm quite close to finishing it there is just an annoying bug which I can't figure out. (It's probabaly something really simple)
My code is as follows;
$domain = explode("\r\n", $domains);
print_r($domain);
echo "<br /><br />";
foreach ($domain as $item) {
fwrite($fp, $item . "\r\n");
while (!feof($fp)) {
$lookup .= fread($fp, 8192);
}
$value = explode("\r\n\r\n", $lookup);
$whois_data = array();
foreach ($value as $values) {
$details = explode(":\r\n", $values, 2);
$whois_data[trim($details[0])] = $details[1];
}
echo "Show WHOIS data for " . $item . "<br />";
print_r($whois_data);
unset($whois_data);
echo "<br /><br />";
}
$domains is a textarea box with one domain per line, my output from this PHP is as follows;
Array ( [0] => madeupdomainname.co.uk [1] => anothermadeupdomain.co.uk )
Show WHOIS data for madeupdomainname.co.uk
Array ( [Domain name] => madeupdomainname.co.uk [Registrant] => Made Up Inc. [Registrant type] => Unknown [Registrant's address] => 123 Fake Road City UK [Registrar] => Made Up Inc. t/a Made Up [Tag = MADEUP] URL: madeupdomainname.co.uk [Relevant dates] => Registered on: 14-Feb-1929 Renewal date: 11-Feb-2023 Last updated: 12-Feb-2031 [Registration status] => Registered until renewal date. [Name servers] => ns1.madeupdomainname.co.uk ns2.madeupdomainname.co.uk ns3.madeupdomainname.co.uk ns4.madeupdomainname.co.uk [WHOIS lookup made at 01:09:24 08-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 nominet.org.uk/whois, which includes restrictions on: (A) use of the data for advertising, or its repackaging, recompilation, redistribution or reuse (B) obscuring, removing or hiding any or all of this notice and (C) exceeding query rate or volume limits. The data is provided on an 'as-is' basis and may lag behind the register. Access may be withdrawn or restricted at any time.] => )
Show WHOIS data for anothermadeupdomain.co.uk
Array ( [Domain name] => madeupdomainname.co.uk [Registrant] => Made Up Inc. [Registrant type] => Unknown [Registrant's address] => 123 Fake Road City UK [Registrar] => Made Up Inc. t/a Made Up [Tag = MADEUP] URL: madeupdomainname.co.uk [Relevant dates] => Registered on: 14-Feb-1929 Renewal date: 11-Feb-2023 Last updated: 12-Feb-2031 [Registration status] => Registered until renewal date. [Name servers] => ns1.madeupdomainname.co.uk ns2.madeupdomainname.co.uk ns3.madeupdomainname.co.uk ns4.madeupdomainname.co.uk [WHOIS lookup made at 01:09:24 08-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 nominet.org.uk/whois, which includes restrictions on: (A) use of the data for advertising, or its repackaging, recompilation, redistribution or reuse (B) obscuring, removing or hiding any or all of this notice and (C) exceeding query rate or volume limits. The data is provided on an 'as-is' basis and may lag behind the register. Access may be withdrawn or restricted at any time.] => )
As you can see it's grabbing the WHOIS data from the first domain correctly but then ignoring the second domain and just re using the first domains WHOS information which is really bugging me. Any suggestions?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WHOIS 协议仅允许每个连接发出一个请求。您必须为每个请求打开一个新连接。
The WHOIS protocol only allows for one request per connection. You must open a new connection for each request.