Commit 7100fedb authored by Ad Schellevis's avatar Ad Schellevis

(util.inc) php7 fix ip_in_subnet()

parent 8067e9bd
......@@ -1168,11 +1168,14 @@ function ip_in_subnet($addr,$subnet)
{
if (is_ipaddrv6($addr)) {
return (Net_IPv6::isInNetmask($addr, $subnet));
} else { /* XXX: Maybe check for IPv4 */
} elseif (is_ipaddrv4($addr)) {
list($ip, $mask) = explode('/', $subnet);
$mask = (0xffffffff << (32 - $mask)) & 0xffffffff;
return ((ip2long($addr) & $mask) == (ip2long($ip) & $mask));
if (is_ipaddrv4($ip) && $mask <= 32) {
$mask = (0xffffffff << (32 - $mask)) & 0xffffffff;
return ((ip2long($addr) & $mask) == (ip2long($ip) & $mask));
}
}
return false;
}
function is_private_ip($iptocheck)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment