- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
嗨,我一直在弄乱我从网上获得的这个 Whois 脚本,并且一直在弄乱变量和数组,一直试图弄清楚为什么它不会返回 Google 和 Facebook 的 whois 结果(我测试了谷歌,因为这是显而易见的),然后在了解到它与 Whois 垃圾邮件有关后测试了 facebook,并且人们添加了此脚本选择的 google.com 子域(同样发生在 facebook 上)...
完成作业后,我设法让它返回所有结果的列表(通过删除脚本中将所需的“=”.$domain 添加到域变量的部分。
在那之后,所有结果都返回了,我了解到脚本正在获取第一个结果的 Whois 服务器(这是一个 google.com.with.added.spam.com),因此“google.com”可以在与“google.com.with.added.spam.com”相同的 whois 服务器上找不到,因此它返回空白。
为了修复它,我已经尝试了所有方法,从反转 preg_match_all 数组(以获取最后一个 whois 服务器)到编辑我能想到的所有变量..
如有任何帮助,我们将不胜感激。
提前致谢!!!
现在是代码:
<?php
$domain = $_GET['domain'];
// For the full list of TLDs/Whois servers see http://www.iana.org/domains/root/db/ and http://www.whois365.com/en/listtld/
$whoisservers = array(
"ac" =>"whois.nic.ac",
"ae" =>"whois.nic.ae",
"aero"=>"whois.aero",
"af" =>"whois.nic.af",
"ag" =>"whois.nic.ag",
"al" =>"whois.ripe.net",
"am" =>"whois.amnic.net",
"arpa" =>"whois.iana.org",
"as" =>"whois.nic.as",
"asia" =>"whois.nic.asia",
"at" =>"whois.nic.at",
"au" =>"whois.aunic.net",
"az" =>"whois.ripe.net",
"ba" =>"whois.ripe.net",
"be" =>"whois.dns.be",
"bg" =>"whois.register.bg",
"bi" =>"whois.nic.bi",
"biz" =>"whois.biz",
"bj" =>"whois.nic.bj",
"br" =>"whois.registro.br",
"bt" =>"whois.netnames.net",
"by" =>"whois.ripe.net",
"bz" =>"whois.belizenic.bz",
"ca" =>"whois.cira.ca",
"cat" =>"whois.cat",
"cc" =>"whois.nic.cc",
"cd" =>"whois.nic.cd",
"ch" =>"whois.nic.ch",
"ci" =>"whois.nic.ci",
"ck" =>"whois.nic.ck",
"cl" =>"whois.nic.cl",
"cn" =>"whois.cnnic.net.cn",
"com" =>"whois.verisign-grs.com",
"coop" =>"whois.nic.coop",
"cx" =>"whois.nic.cx",
"cy" =>"whois.ripe.net",
"cz" =>"whois.nic.cz",
"de" =>"whois.denic.de",
"dk" =>"whois.dk-hostmaster.dk",
"dm" =>"whois.nic.cx",
"dz" =>"whois.ripe.net",
"edu" =>"whois.educause.edu",
"ee" =>"whois.eenet.ee",
"eg" =>"whois.ripe.net",
"es" =>"whois.ripe.net",
"eu" =>"whois.eu",
"fi" =>"whois.ficora.fi",
"fo" =>"whois.ripe.net",
"fr" =>"whois.nic.fr",
"gb" =>"whois.ripe.net",
"gd" =>"whois.adamsnames.com",
"ge" =>"whois.ripe.net",
"gg" =>"whois.channelisles.net",
"gi" =>"whois2.afilias-grs.net",
"gl" =>"whois.ripe.net",
"gm" =>"whois.ripe.net",
"gov" =>"whois.nic.gov",
"gr" =>"whois.ripe.net",
"gs" =>"whois.nic.gs",
"gw" =>"whois.nic.gw",
"gy" =>"whois.registry.gy",
"hk" =>"whois.hkirc.hk",
"hm" =>"whois.registry.hm",
"hn" =>"whois2.afilias-grs.net",
"hr" =>"whois.ripe.net",
"hu" =>"whois.nic.hu",
"ie" =>"whois.domainregistry.ie",
"il" =>"whois.isoc.org.il",
"in" =>"whois.inregistry.net",
"info" =>"whois.afilias.net",
"int" =>"whois.iana.org",
"io" =>"whois.nic.io",
"iq" =>"vrx.net",
"ir" =>"whois.nic.ir",
"is" =>"whois.isnic.is",
"it" =>"whois.nic.it",
"je" =>"whois.channelisles.net",
"jobs" =>"jobswhois.verisign-grs.com",
"jp" =>"whois.jprs.jp",
"ke" =>"whois.kenic.or.ke",
"kg" =>"www.domain.kg",
"ki" =>"whois.nic.ki",
"kr" =>"whois.nic.or.kr",
"kz" =>"whois.nic.kz",
"la" =>"whois.nic.la",
"li" =>"whois.nic.li",
"lt" =>"whois.domreg.lt",
"lu" =>"whois.dns.lu",
"lv" =>"whois.nic.lv",
"ly" =>"whois.nic.ly",
"ma" =>"whois.iam.net.ma",
"mc" =>"whois.ripe.net",
"md" =>"whois.ripe.net",
"me" =>"whois.meregistry.net",
"mg" =>"whois.nic.mg",
"mil" =>"whois.nic.mil",
"mn" =>"whois.nic.mn",
"mobi" =>"whois.dotmobiregistry.net",
"ms" =>"whois.adamsnames.tc",
"mt" =>"whois.ripe.net",
"mu" =>"whois.nic.mu",
"museum" =>"whois.museum",
"mx" =>"whois.nic.mx",
"my" =>"whois.mynic.net.my",
"na" =>"whois.na-nic.com.na",
"name" =>"whois.nic.name",
"net" =>"whois.verisign-grs.net",
"nf" =>"whois.nic.nf",
"nl" =>"whois.domain-registry.nl",
"no" =>"whois.norid.no",
"nu" =>"whois.nic.nu",
"nz" =>"whois.srs.net.nz",
"org" =>"whois.pir.org",
"pl" =>"whois.dns.pl",
"pm" =>"whois.nic.pm",
"pr" =>"whois.uprr.pr",
"pro" =>"whois.registrypro.pro",
"pt" =>"whois.dns.pt",
"re" =>"whois.nic.re",
"ro" =>"whois.rotld.ro",
"ru" =>"whois.ripn.net",
"sa" =>"whois.nic.net.sa",
"sb" =>"whois.nic.net.sb",
"sc" =>"whois2.afilias-grs.net",
"se" =>"whois.iis.se",
"sg" =>"whois.nic.net.sg",
"sh" =>"whois.nic.sh",
"si" =>"whois.arnes.si",
"sk" =>"whois.ripe.net",
"sm" =>"whois.ripe.net",
"st" =>"whois.nic.st",
"su" =>"whois.ripn.net",
"tc" =>"whois.adamsnames.tc",
"tel" =>"whois.nic.tel",
"tf" =>"whois.nic.tf",
"th" =>"whois.thnic.net",
"tj" =>"whois.nic.tj",
"tk" =>"whois.dot.tk",
"tl" =>"whois.nic.tl",
"tm" =>"whois.nic.tm",
"tn" =>"whois.ripe.net",
"to" =>"whois.tonic.to",
"tp" =>"whois.nic.tl",
"tr" =>"whois.nic.tr",
"travel" =>"whois.nic.travel",
"tv" => "tvwhois.verisign-grs.com",
"tw" =>"whois.twnic.net.tw",
"ua" =>"whois.net.ua",
"ug" =>"whois.co.ug",
"uk" =>"whois.nic.uk",
"us" =>"whois.nic.us",
"uy" =>"nic.uy",
"uz" =>"whois.cctld.uz",
"va" =>"whois.ripe.net",
"vc" =>"whois2.afilias-grs.net",
"ve" =>"whois.nic.ve",
"vg" =>"whois.adamsnames.tc",
"wf" =>"whois.nic.wf",
"ws" =>"whois.website.ws",
"yt" =>"whois.nic.yt",
"yu" =>"whois.ripe.net");
function LookupDomain($domain){
global $whoisservers;
$domain_parts = explode(".", $domain);
$tld = strtolower(array_pop($domain_parts));
$whoisserver = $whoisservers[$tld];
if(!$whoisserver) {
return "Error: No appropriate Whois server found for $domain domain!";
}
$result = QueryWhoisServer($whoisserver, $domain);
if(!$result) {
return "Error: No results retrieved from $whoisserver server for $domain domain!";
}
else {
while(strpos($result, "Whois Server:") !== FALSE){
preg_match("/Whois Server: (.*)/", $result, $matches);
$secondary = $matches[1];
if($secondary) {
$result = QueryWhoisServer($secondary, $domain);
$whoisserver = $secondary;
}
}
}
return "$domain domain lookup results from $whoisserver server:\n\n" . $result;
}
function LookupIP($ip) {
$whoisservers = array(
//"whois.afrinic.net", // Africa - returns timeout error :-(
"whois.lacnic.net", // Latin America and Caribbean - returns data for ALL locations worldwide :-)
"whois.apnic.net", // Asia/Pacific only
"whois.arin.net", // North America only
"whois.ripe.net" // Europe, Middle East and Central Asia only
);
$results = array();
foreach($whoisservers as $whoisserver) {
$result = QueryWhoisServer($whoisserver, $ip);
if($result && !in_array($result, $results)) {
$results[$whoisserver]= $result;
}
}
$res = "RESULTS FOUND: " . count($results);
foreach($results as $whoisserver=>$result) {
$res .= "\n\n-------------\nLookup results for $ip from $whoisserver server:\n\n$result";
}
return $res;
}
function ValidateIP($ip) {
$ipnums = explode(".", $ip);
if(count($ipnums) != 4) {
return false;
}
foreach($ipnums as $ipnum) {
if(!is_numeric($ipnum) || ($ipnum > 255)) {
return false;
}
}
return $ip;
}
function ValidateDomain($domain) {
if(!preg_match("/^([-a-z0-9]{2,100})\.([a-z\.]{2,8})$/i", $domain)) {
return false;
}
return $domain;
}
function QueryWhoisServer($whoisserver, $domain) {
$port = 43;
$timeout = 10;
$fp = @fsockopen($whoisserver, $port, $errno, $errstr, $timeout) or die("Socket Error " . $errno . " - " . $errstr);
if($whoisserver == "whois.verisign-grs.com") $domain = "=".$domain; // whois.verisign-grs.com requires the equals sign ("=") or it returns any result containing the searched string.
fputs($fp, $domain . "\r\n");
$out = "";
while(!feof($fp)){
$out .= fgets($fp);
}
fclose($fp);
$res = "";
if((strpos(strtolower($out), "error") === FALSE) && (strpos(strtolower($out), "not allocated") === FALSE)) {
$rows = explode("\n", $out);
foreach($rows as $row) {
$row = trim($row);
if(($row != '') && ($row{0} != '#') && ($row{0} != '%')) {
$res .= $row."\n";
}
}
}
return $res;
}
?>
<html>
<head>
<title>Whois Lookup Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="<?=$_SERVER['PHP_SELF'];?>">
<p><b><label for="domain">Domain/IP Address:</label></b> <input type="text" name="domain" id="domain" value="<?=$domain;?>"> <input type="submit" value="Lookup"></p>
</form>
<?
if($domain) {
$domain = trim($domain);
if(substr(strtolower($domain), 0, 7) == "http://") $domain = substr($domain, 7);
if(substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4);
if(ValidateIP($domain)) {
$result = LookupIP($domain);
}
elseif(ValidateDomain($domain)) {
$result = LookupDomain($domain);
}
else die("Invalid Input!");
echo "<pre>\n" . $result . "\n</pre>\n";
}
?>
</body>
</html>
最佳答案
当您尝试将域(例如:google.com)从表单发送到您的脚本时,不要将其作为“google.com”发送,而是添加“域”一词,即(域 google.com)。
这是做什么的,它告诉 whois 服务器找到这个域(即 google.com),而不是任何其他包含单词 google 的域。
所以在函数“LookupDomain($domain)”中确保 $domain 的值应该是'domain google.com' 以显示正确的结果。
关于php - Whois 服务器不返回结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4146468/
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
在编码时,我问了自己这个问题: 这样更快吗: if(false) return true; else return false; 比这个? if(false) return true; return
如何在逻辑条件下进行“返回”? 在这样的情况下这会很有用 checkConfig() || return false; var iNeedThis=doSomething() || return fa
这是我的正则表达式 demo 如问题所述: 如果第一个数字是 1 则返回 1 但如果是 145 则返回 145 但如果是 133 则返回 133 样本数据a: K'8134567 K'81345678
在代码高尔夫问答部分查看谜题和答案时,我遇到了 this solution返回 1 的最长和最晦涩的方法 引用答案, int foo(void) { return! 0; } int bar(
我想在下面返回 JSON。 { "name": "jackie" } postman 给我错误。说明 Unexpected 'n' 这里是 Spring Boot 的新手。 1日龄。有没有正确的方法来
只要“is”返回 True,“==”不应该返回 True 吗? In [101]: np.NAN is np.nan is np.NaN Out[101]: True In [102]: np.NAN
我需要获取所有在 6 号或 7 号房间或根本不在任何房间的学生的详细信息。如果他们在其他房间,简单地说,我不希望有那个记录。 我的架构是: students(roll_no, name,class,.
我有一个表单,我将它发送到 php 以通过 ajax 插入到 mysql 数据库中。一切顺利,php 返回 "true" 值,但在 ajax 中它显示 false 消息。 在这里你可以查看php代码:
我在 Kotlin 中遇到了一个非常奇怪的无法解释的值比较问题,以下代码打印 假 data class Foo ( val a: Byte ) fun main() { val NUM
请注意,这并非特定于 Protractor。问题在于 Angular 2 的内置 Testability service Protractor 碰巧使用。 Protractor 调用 Testabil
在调试窗口中,以下表达式均返回 1。 Application.WorksheetFunction.CountA(Cells(4 + (i - 1) * rows_per_record, 28) & "
我在本地使用 jsonplaceholder ( http://jsonplaceholder.typicode.com/)。我正在通过 extjs rest 代理测试我的 GET 和 POST 调用
这是 Postman 为成功调用我的页面而提供的(修改后的)代码段。 var client = new RestClient("http://sub.example.com/wp-json/wp/v2
这个问题在这里已经有了答案: What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must
我想我对 C 命令行参数有点生疏。我查看了我的一些旧代码,但无论这个版本是什么,都会出现段错误。 运行方式是 ./foo -n num(其中 num 是用户在命令行中输入的数字) 但不知何故它不起作用
我已经编写了一个类来处理命名管道连接,如果我创建了一个实例,关闭它,然后尝试创建另一个实例,调用 CreateFile() 返回 INVALID_HANDLE_VALUE,并且 GetLastErro
即使 is_writable() 返回 true,我也无法写入文件。当然,该文件存在并且显然是可读的。这是代码: $file = "data"; echo file_get_contents($fil
下面代码中的变量 $response 为 NULL,尽管它应该是 SOAP 请求的值。 (潮汐列表)。当我调用 $client->__getLastResponse() 时,我从 SOAP 服务获得了
我一直在网上的不同论坛上搜索答案,但似乎没有与我的情况相符的... 我正在使用 Windows 7,VS2010。 我有一个使用定时器来调用任务栏刷新功能的应用程序。在该任务栏函数中包含对 LoadI
我是一名优秀的程序员,十分优秀!