ICANN RST Fixes

This commit is contained in:
Pinga 2025-04-28 14:20:34 +03:00
parent b598925bc5
commit 193cac6d0e
3 changed files with 53 additions and 36 deletions

View file

@ -1032,4 +1032,12 @@ function validateHostName(string $hostName): bool
'/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/',
$asciiHostName
);
}
function ipMatches($ip, $cidr) {
list($subnet, $mask) = explode('/', $cidr);
$ipLong = ip2long($ip);
$subnetLong = ip2long($subnet);
$maskLong = -1 << (32 - (int)$mask);
return ($ipLong & $maskLong) === ($subnetLong & $maskLong);
}