[core] allow ip_in_range to match exact IPs

This commit is contained in:
Shish
2024-01-04 15:07:07 +00:00
parent c5395df243
commit e49fcfa0c7
2 changed files with 14 additions and 1 deletions

View File

@ -36,7 +36,11 @@ function array_iunique(array $array): array
*/
function ip_in_range(string $IP, string $CIDR): bool
{
list($net, $mask) = explode("/", $CIDR);
$parts = explode("/", $CIDR);
if(count($parts) == 1) {
$parts[1] = "32";
}
list($net, $mask) = $parts;
$ip_net = ip2long($net);
$ip_mask = ~((1 << (32 - (int)$mask)) - 1);