Move the check_cidr function

This commit is contained in:
Mark Crane
2014-07-29 04:08:39 +00:00
parent 76e972ef30
commit 7b0c11b1f7
2 changed files with 7 additions and 4 deletions

View File

@@ -109,10 +109,6 @@ require_once "resources/require.php";
//check the cidr range
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;
foreach($_SESSION['provision']["cidr"] as $cidr) {
if (check_cidr($cidr, $_SERVER['REMOTE_ADDR'])) {