function _autoban_cidr_match in Automatic IP ban (Autoban) 7
Is IP address in subnet?
Parameters
string $ip: IP address for match check.
string $network: IP subnet.
string $cidr: CIDR.
Return value
bool IP mathes for subnet or wrong arguments.
1 call to _autoban_cidr_match()
- autoban_whitelist_ip in ./
autoban.module - Is IP address in whitelist
File
- ./
autoban.module, line 797 - Main file for autoban module.
Code
function _autoban_cidr_match($ip, $network, $cidr) {
$cidr = intval($cidr);
if ($cidr > 32) {
return FALSE;
}
return (ip2long($ip) & ~((1 << 32 - $cidr) - 1)) == ip2long(trim($network));
}