From 90a177c84a85ece9d76f4d899752da98d9be7f43 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Tue, 29 Jul 2014 04:08:39 +0000 Subject: [PATCH] Move the check_cidr function --- app/provision/index.php | 4 ---- resources/functions.php | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/provision/index.php b/app/provision/index.php index 39310c2bbe..d837b0211e 100644 --- a/app/provision/index.php +++ b/app/provision/index.php @@ -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'])) { diff --git a/resources/functions.php b/resources/functions.php index 0c43a10d16..b6f6c2950c 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -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')) { function fix_postback($post_array) { foreach ($post_array as $index => $value) {