aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_user.php
diff options
context:
space:
mode:
authorChris Smith <toonarmy@phpbb.com>2009-02-07 20:15:31 +0000
committerChris Smith <toonarmy@phpbb.com>2009-02-07 20:15:31 +0000
commit14438749e0a4384f8596014878db54dce8ffb44c (patch)
tree4fa2e515f8462246a71206d38ec5bc57b8c1e64e /phpBB/includes/functions_user.php
parentb6c056c1dbe401125a9bbf3e856f70cb1844ab52 (diff)
downloadforums-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/includes/functions_user.php')
-rw-r--r--phpBB/includes/functions_user.php47
1 files changed, 28 insertions, 19 deletions
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);