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
This commit is contained in:
Chris Smith 2009-02-07 20:15:31 +00:00
parent b6c056c1db
commit 14438749e0
2 changed files with 31 additions and 21 deletions

View file

@ -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>

View file

@ -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);