Provisioning, Only check the CIDR if its provided.

This commit is contained in:
Mark Crane
2013-12-28 22:02:57 +00:00
parent 9f2f19ea16
commit d9f7333eed
+9 -7
View File
@@ -309,13 +309,15 @@ include "resources/classes/template.php";
unset ($prep_statement); unset ($prep_statement);
//check to see if the IP address is in the CIDR range //check to see if the IP address is in the CIDR range
function check_cidr ($cidr,$ip_address) { if (strlen($provision["cidr"]) > 0) {
list ($subnet, $mask) = explode ('/', $cidr); function check_cidr ($cidr,$ip_address) {
return ( ip2long ($ip_address) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($subnet); list ($subnet, $mask) = explode ('/', $cidr);
} return ( ip2long ($ip_address) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($subnet);
if (!check_cidr($provision["cidr"], $_SERVER['REMOTE_ADDR'])) { }
echo "access denied"; if (!check_cidr($provision["cidr"], $_SERVER['REMOTE_ADDR'])) {
exit; echo "access denied";
exit;
}
} }
//if the domain name directory exists then only use templates from it //if the domain name directory exists then only use templates from it