Update index.php

Minor changes. Use the provision array to get the cidr details.
This commit is contained in:
FusionPBX
2024-07-04 18:01:50 -06:00
committed by GitHub
parent 1d7bcbe0ee
commit 0ff2503240
+6 -9
View File
@@ -213,13 +213,13 @@
http_error('404'); http_error('404');
} }
//keep backwards compatibility //get all provision settings
$provision_cidrs = $settings->get('provision','cidr', []); $provision = $settings->get('provision', null, []);
//check the cidr range //check the cidr range
if (!empty($provision_cidrs)) { if (!empty($provision['cidr'])) {
$found = false; $found = false;
foreach($provision_cidrs as $cidr) { foreach($provision['cidr'] as $cidr) {
if (check_cidr($cidr, $_SERVER['REMOTE_ADDR'])) { if (check_cidr($cidr, $_SERVER['REMOTE_ADDR'])) {
$found = true; $found = true;
break; break;
@@ -231,10 +231,6 @@
} }
} }
//get all provision settings
$provision = $settings->get('provision', null, []);
$auth_passwords = $settings->get('provision', 'http_auth_password', []);
//http authentication - digest //http authentication - digest
if (!empty($provision["http_auth_username"]) && empty($provision["http_auth_type"])) { $provision["http_auth_type"] = "digest"; } if (!empty($provision["http_auth_username"]) && empty($provision["http_auth_type"])) { $provision["http_auth_type"] = "digest"; }
if (!empty($provision["http_auth_username"]) && $provision["http_auth_type"] === "digest" && !empty($provision["http_auth_enabled"]) && $provision["http_auth_enabled"] === "true") { if (!empty($provision["http_auth_username"]) && $provision["http_auth_type"] === "digest" && !empty($provision["http_auth_enabled"]) && $provision["http_auth_enabled"] === "true") {
@@ -321,6 +317,7 @@
} }
else { else {
$authorized = false; $authorized = false;
$auth_passwords = $settings->get('provision', 'http_auth_password', []);
foreach ($auth_passwords as $password) { foreach ($auth_passwords as $password) {
if ($_SERVER['PHP_AUTH_PW'] == $password) { if ($_SERVER['PHP_AUTH_PW'] == $password) {
$authorized = true; $authorized = true;
@@ -343,7 +340,7 @@
} }
} }
//if password was defined in the Default Settings page then require the password. //if the password was defined in the settings then require the password.
if (!empty($provision['password'])) { if (!empty($provision['password'])) {
//deny access if the password doesn't match //deny access if the password doesn't match
if ($provision['password'] != check_str($_REQUEST['password'])) { if ($provision['password'] != check_str($_REQUEST['password'])) {