diff options
author | Chris Smith <toonarmy@phpbb.com> | 2009-02-07 20:15:31 +0000 |
---|---|---|
committer | Chris Smith <toonarmy@phpbb.com> | 2009-02-07 20:15:31 +0000 |
commit | 14438749e0a4384f8596014878db54dce8ffb44c (patch) | |
tree | 4fa2e515f8462246a71206d38ec5bc57b8c1e64e /phpBB | |
parent | b6c056c1dbe401125a9bbf3e856f70cb1844ab52 (diff) | |
download | forums-14438749e0a4384f8596014878db54dce8ffb44c.tar forums-14438749e0a4384f8596014878db54dce8ffb44c.tar.gz forums-14438749e0a4384f8596014878db54dce8ffb44c.tar.bz2 forums-14438749e0a4384f8596014878db54dce8ffb44c.tar.xz forums-14438749e0a4384f8596014878db54dce8ffb44c.zip |
Whois now works reliably for RIRs other than APNIC and RIPE
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9315 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/docs/CHANGELOG.html | 1 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 47 |
2 files changed, 29 insertions, 19 deletions
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 91261ba90d..cf5953d279 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -96,6 +96,7 @@ <li>[Fix] Added missing read permission information for some phpbb_chmod() calls</li> <li>[Fix] Correctly display future dates (Bug #38755)</li> <li>[Fix] Fix guest/bot session problems with apache authentication plugin (Bug #41085)</li> + <li>[Fix] Whois now works reliably for RIRs other than APNIC and RIPE</li> <li>[Change] Allow download of conflicting file for later reference in automatic updater</li> <li>[Change] Default difference view is now 'inline' instead of 'side by side'</li> <li>[Change] Added new option for merging differences to conflicting files in automatic updater</li> diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index d1b0fc7e0d..b38f7a049e 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1151,16 +1151,9 @@ function user_ipwhois($ip) return ''; } - $match = array( - '#RIPE\.NET#is' => 'whois.ripe.net', - '#whois\.apnic\.net#is' => 'whois.apnic.net', - '#nic\.ad\.jp#is' => 'whois.nic.ad.jp', - '#whois\.registro\.br#is' => 'whois.registro.br' - ); - if (($fsk = @fsockopen('whois.arin.net', 43))) { - fputs($fsk, "$ip\n"); + fputs($fsk, "$ip\r\n"); while (!feof($fsk)) { $ipwhois .= fgets($fsk, 1024); @@ -1168,22 +1161,38 @@ function user_ipwhois($ip) @fclose($fsk); } - foreach (array_keys($match) as $server) + $match = array(); + + // Test for referrals from ARIN to other whois databases, roll on rwhois + if (preg_match('#ReferralServer: whois://(.+)#im', $ipwhois, $match)) { - if (preg_match($server, $ipwhois)) + if (strpos($match[1], ':') !== false) + { + $pos = strrpos($match[1], ':'); + $server = substr($match[1], 0, $pos); + $port = (int) substr($match[1], $pos + 1); + unset($pos); + } + else + { + $server = $match[1]; + $port = 43; + } + + $buffer = ''; + + if (($fsk = @fsockopen($server, $port))) { - $ipwhois = ''; - if (($fsk = @fsockopen($match[$server], 43))) + fputs($fsk, "$ip\r\n"); + while (!feof($fsk)) { - fputs($fsk, "$ip\n"); - while (!feof($fsk)) - { - $ipwhois .= fgets($fsk, 1024); - } - @fclose($fsk); + $buffer .= fgets($fsk, 1024); } - break; + @fclose($fsk); } + + // Use the result from ARIN if we don't get any result here + $ipwhois = (empty($buffer)) ? $ipwhois : $buffer; } $ipwhois = htmlspecialchars($ipwhois); |