* Modify check ip function.

This commit is contained in:
caoyanyi
2022-04-28 14:06:08 +08:00
parent d517513c69
commit 5fd5b34e97
+11 -11
View File
@@ -2532,17 +2532,6 @@ EOD;
/* The ip is same as ip in white list. */
if($ip == $ipWhiteList) return true;
/* If the ip in white list is like 192.168.1.1-192.168.1.10. */
if(strpos($ipWhiteList, '-') !== false)
{
list($min, $max) = explode('-', $ipWhiteList);
$min = ip2long(trim($min));
$max = ip2long(trim($max));
$ip = ip2long(trim($ip));
return $ip >= $min and $ip <= $max;
}
/* If the ip in white list is like 192.168.1.1,192.168.1.10. */
if(strpos($ipWhiteList, ',') !== false)
{
@@ -2554,6 +2543,17 @@ EOD;
return false;
}
/* If the ip in white list is like 192.168.1.1-192.168.1.10. */
if(strpos($ipWhiteList, '-') !== false)
{
list($min, $max) = explode('-', $ipWhiteList);
$min = ip2long(trim($min));
$max = ip2long(trim($max));
$ip = ip2long(trim($ip));
return $ip >= $min and $ip <= $max;
}
/* If the ip in white list is like 192.168.1.*. */
if(strpos($ipWhiteList, '*') !== false)
{