mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 14:48:53 +00:00
Send statistics now check for IPv6 and send private network status as a boolean
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10370 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
04945c5432
commit
9ad40c8821
2 changed files with 45 additions and 10 deletions
|
@ -130,6 +130,7 @@
|
||||||
<li>[Change] Alter ACP user quick tools interface to reduce confusion with the delete operation.</li>
|
<li>[Change] Alter ACP user quick tools interface to reduce confusion with the delete operation.</li>
|
||||||
<li>[Change] Remove item limit from "All forums" feed.</li>
|
<li>[Change] Remove item limit from "All forums" feed.</li>
|
||||||
<li>[Change] "All topics" feed now returns newest board topics.</li>
|
<li>[Change] "All topics" feed now returns newest board topics.</li>
|
||||||
|
<li>[Change] Send statistics now check for IPv6 and send private network status as a boolean.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<a name="v305"></a><h3>1.ii. Changes since 3.0.5</h3>
|
<a name="v305"></a><h3>1.ii. Changes since 3.0.5</h3>
|
||||||
|
|
|
@ -162,25 +162,59 @@ class phpbb_questionnaire_system_data_provider
|
||||||
$server_address = $_SERVER['LOCAL_ADDR'];
|
$server_address = $_SERVER['LOCAL_ADDR'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$ip_address_ary = explode('.', $server_address);
|
|
||||||
|
|
||||||
// build ip
|
|
||||||
if (!isset($ip_address_ary[0]) || !isset($ip_address_ary[1]))
|
|
||||||
{
|
|
||||||
$ip_address_ary = explode('.', '0.0.0.0');
|
|
||||||
}
|
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'os' => PHP_OS,
|
'os' => PHP_OS,
|
||||||
'httpd' => $_SERVER['SERVER_SOFTWARE'],
|
'httpd' => $_SERVER['SERVER_SOFTWARE'],
|
||||||
// we don't want the real IP address (for privacy policy reasons) but only
|
// we don't want the real IP address (for privacy policy reasons) but only
|
||||||
// a network address to see whether your installation is running on a private or public network.
|
// a network address to see whether your installation is running on a private or public network.
|
||||||
|
'private_ip' => is_private_ip($server_address),
|
||||||
|
'ipv6' => strpos($server_address, ':') !== false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the given IP is in a private network.
|
||||||
|
*
|
||||||
|
* @param string $ip IP in v4 dot-decimal or v6 hex format
|
||||||
|
* @return bool true if the IP is from a private network, else false
|
||||||
|
*/
|
||||||
|
function is_private_ip($ip)
|
||||||
|
{
|
||||||
|
// IPv4
|
||||||
|
if (strpos($ip, ':') === false)
|
||||||
|
{
|
||||||
|
$ip_address_ary = explode('.', $ip);
|
||||||
|
|
||||||
|
// build ip
|
||||||
|
if (!isset($ip_address_ary[0]) || !isset($ip_address_ary[1]))
|
||||||
|
{
|
||||||
|
$ip_address_ary = explode('.', '0.0.0.0');
|
||||||
|
}
|
||||||
|
|
||||||
// IANA reserved addresses for private networks (RFC 1918) are:
|
// IANA reserved addresses for private networks (RFC 1918) are:
|
||||||
// - 10.0.0.0/8
|
// - 10.0.0.0/8
|
||||||
// - 172.16.0.0/12
|
// - 172.16.0.0/12
|
||||||
// - 192.168.0.0/16
|
// - 192.168.0.0/16
|
||||||
'ip' => $ip_address_ary[0] . '.' . $ip_address_ary[1] . '.XXX.YYY',
|
if ($ip_address_ary[0] == '10' ||
|
||||||
);
|
($ip_address_ary[0] == '172' && intval($ip_address_ary[1]) > 15 && intval($ip_address_ary[1]) < 32) ||
|
||||||
|
($ip_address_ary[0] == '192' && $ip_address_ary[1] == '168') ||
|
||||||
|
($ip_address_ary[0] == '192' && $ip_address_ary[1] == '168'))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// IPv6
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// unique local unicast
|
||||||
|
$prefix = substr($ip, 0, 2);
|
||||||
|
if ($prefix == 'fc' || $prefix == 'fd')
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue