mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-17 10:04:41 +00:00
(util.inc) php7 fix ip_in_subnet()
This commit is contained in:
parent
8067e9bdd1
commit
7100fedbbb
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user