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 @@
  • [Fix] Added missing read permission information for some phpbb_chmod() calls
  • [Fix] Correctly display future dates (Bug #38755)
  • [Fix] Fix guest/bot session problems with apache authentication plugin (Bug #41085)
  • +
  • [Fix] Whois now works reliably for RIRs other than APNIC and RIPE
  • [Change] Allow download of conflicting file for later reference in automatic updater
  • [Change] Default difference view is now 'inline' instead of 'side by side'
  • [Change] Added new option for merging differences to conflicting files in automatic updater
  • 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) { - $ipwhois = ''; - if (($fsk = @fsockopen($match[$server], 43))) - { - fputs($fsk, "$ip\n"); - while (!feof($fsk)) - { - $ipwhois .= fgets($fsk, 1024); - } - @fclose($fsk); - } - break; + $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))) + { + fputs($fsk, "$ip\r\n"); + while (!feof($fsk)) + { + $buffer .= fgets($fsk, 1024); + } + @fclose($fsk); + } + + // Use the result from ARIN if we don't get any result here + $ipwhois = (empty($buffer)) ? $ipwhois : $buffer; } $ipwhois = htmlspecialchars($ipwhois);