aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_user.php
diff options
context:
space:
mode:
authorJosh Woody <a_jelly_doughnut@phpbb.com>2010-08-19 10:48:41 -0500
committerJosh Woody <a_jelly_doughnut@phpbb.com>2010-08-19 10:48:41 -0500
commit6343e67fab431ac15d62cff7d014e990a00c69f1 (patch)
tree6f65c4987a57da4cf59339b73472bae2f0965c12 /phpBB/includes/functions_user.php
parent5eb175cefd2bd240e28bb6eef1d2c9b08f97b361 (diff)
parentc0183cabd09994839170238fd5e2a87f1b48880b (diff)
downloadforums-6343e67fab431ac15d62cff7d014e990a00c69f1.tar
forums-6343e67fab431ac15d62cff7d014e990a00c69f1.tar.gz
forums-6343e67fab431ac15d62cff7d014e990a00c69f1.tar.bz2
forums-6343e67fab431ac15d62cff7d014e990a00c69f1.tar.xz
forums-6343e67fab431ac15d62cff7d014e990a00c69f1.zip
Merge branch 'ticket/bantu/9534' into develop-olympus
* ticket/bantu/9534: [ticket/9534] Update function documentation for user_ipwhois(). [ticket/9534] Adding support for IPv6 addresses in user_ipwhois().
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r--phpBB/includes/functions_user.php35
1 files changed, 26 insertions, 9 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 0b26f28864..d5ec720b4b 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1229,22 +1229,39 @@ function user_unban($mode, $ban)
}
/**
-* Whois facility
+* Internet Protocol Address Whois
+* RFC3912: WHOIS Protocol Specification
*
-* @link http://tools.ietf.org/html/rfc3912 RFC3912: WHOIS Protocol Specification
+* @param string $ip Ip address, either IPv4 or IPv6.
+*
+* @return string Empty string if not a valid ip address.
+* Otherwise make_clickable()'ed whois result.
*/
function user_ipwhois($ip)
{
- $ipwhois = '';
+ if (empty($ip))
+ {
+ return '';
+ }
- // Check IP
- // Only supporting IPv4 at the moment...
- if (empty($ip) || !preg_match(get_preg_expression('ipv4'), $ip))
+ if (preg_match(get_preg_expression('ipv4'), $ip))
+ {
+ // IPv4 address
+ $whois_host = 'whois.arin.net.';
+ }
+ else if (preg_match(get_preg_expression('ipv6'), $ip))
+ {
+ // IPv6 address
+ $whois_host = 'whois.sixxs.net.';
+ }
+ else
{
return '';
}
- if (($fsk = @fsockopen('whois.arin.net', 43)))
+ $ipwhois = '';
+
+ if (($fsk = @fsockopen($whois_host, 43)))
{
// CRLF as per RFC3912
fputs($fsk, "$ip\r\n");
@@ -1257,7 +1274,7 @@ function user_ipwhois($ip)
$match = array();
- // Test for referrals from ARIN to other whois databases, roll on rwhois
+ // Test for referrals from $whois_host to other whois databases, roll on rwhois
if (preg_match('#ReferralServer: whois://(.+)#im', $ipwhois, $match))
{
if (strpos($match[1], ':') !== false)
@@ -1285,7 +1302,7 @@ function user_ipwhois($ip)
@fclose($fsk);
}
- // Use the result from ARIN if we don't get any result here
+ // Use the result from $whois_host if we don't get any result here
$ipwhois = (empty($buffer)) ? $ipwhois : $buffer;
}