Move the check_cidr function
This commit is contained in:
parent
3a3d2f6f2c
commit
90a177c84a
|
|
@ -109,10 +109,6 @@ require_once "resources/require.php";
|
||||||
|
|
||||||
//check the cidr range
|
//check the cidr range
|
||||||
if (is_array($_SESSION['provision']["cidr"])) {
|
if (is_array($_SESSION['provision']["cidr"])) {
|
||||||
function check_cidr ($cidr,$ip_address) {
|
|
||||||
list ($subnet, $mask) = explode ('/', $cidr);
|
|
||||||
return ( ip2long ($ip_address) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($subnet);
|
|
||||||
}
|
|
||||||
$found = false;
|
$found = false;
|
||||||
foreach($_SESSION['provision']["cidr"] as $cidr) {
|
foreach($_SESSION['provision']["cidr"] as $cidr) {
|
||||||
if (check_cidr($cidr, $_SERVER['REMOTE_ADDR'])) {
|
if (check_cidr($cidr, $_SERVER['REMOTE_ADDR'])) {
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('check_cidr')) {
|
||||||
|
function check_cidr ($cidr,$ip_address) {
|
||||||
|
list ($subnet, $mask) = explode ('/', $cidr);
|
||||||
|
return ( ip2long ($ip_address) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($subnet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!function_exists('fix_postback')) {
|
if (!function_exists('fix_postback')) {
|
||||||
function fix_postback($post_array) {
|
function fix_postback($post_array) {
|
||||||
foreach ($post_array as $index => $value) {
|
foreach ($post_array as $index => $value) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue