Commit b0aa1be3 authored by Franco Fichtner's avatar Franco Fichtner

www: more cleanups possible for #1733

parent 8ad27fbe
...@@ -30,10 +30,6 @@ ...@@ -30,10 +30,6 @@
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
// init $config['virtualip']['vip']
if ( !isset($config['virtualip']['vip']) || !is_array($config['virtualip']['vip'])) {
$config['virtualip']['vip'] = array();
}
$a_vip = &config_read_array('virtualip', 'vip'); $a_vip = &config_read_array('virtualip', 'vip');
$act = null; $act = null;
......
...@@ -100,8 +100,8 @@ function easyrule_block_rule_exists($int = 'wan', $ipproto = "inet") { ...@@ -100,8 +100,8 @@ function easyrule_block_rule_exists($int = 'wan', $ipproto = "inet") {
return false; return false;
} }
function easyrule_block_rule_create($int = 'wan', $ipproto = "inet") { function easyrule_block_rule_create($int = 'wan', $ipproto = "inet")
global $config; {
$blockaliasname = 'EasyRuleBlockHosts'; $blockaliasname = 'EasyRuleBlockHosts';
/* If the alias doesn't exist, exit. /* If the alias doesn't exist, exit.
* Can't create an empty alias, and we don't know a host */ * Can't create an empty alias, and we don't know a host */
...@@ -114,13 +114,9 @@ function easyrule_block_rule_create($int = 'wan', $ipproto = "inet") { ...@@ -114,13 +114,9 @@ function easyrule_block_rule_create($int = 'wan', $ipproto = "inet") {
return true; return true;
} }
/* No rules, start a new array */ $a_filter = &config_read_array('filter', 'rule');
if (!is_array($config['filter']['rule'])) {
$config['filter']['rule'] = array();
}
filter_rules_sort(); filter_rules_sort();
$a_filter = &config_read_array('filter', 'rule');
/* Make up a new rule */ /* Make up a new rule */
$filterent = array(); $filterent = array();
...@@ -157,8 +153,8 @@ function easyrule_block_alias_getid($int = 'wan') ...@@ -157,8 +153,8 @@ function easyrule_block_alias_getid($int = 'wan')
return false; return false;
} }
function easyrule_block_alias_add($host, $int = 'wan') { function easyrule_block_alias_add($host, $int = 'wan')
global $config; {
$blockaliasname = 'EasyRuleBlockHosts'; $blockaliasname = 'EasyRuleBlockHosts';
/* If the host isn't a valid IP address, bail */ /* If the host isn't a valid IP address, bail */
$host = trim($host, "[]"); $host = trim($host, "[]");
...@@ -166,13 +162,6 @@ function easyrule_block_alias_add($host, $int = 'wan') { ...@@ -166,13 +162,6 @@ function easyrule_block_alias_add($host, $int = 'wan') {
return false; return false;
} }
/* If there are no aliases, start an array */
if (!isset($config['aliases']) || !is_array($config['aliases'])) {
$config['aliases'] = array();
}
if (!isset($config['aliases']['alias'])) {
$config['aliases']['alias'] = array();
}
$a_aliases = &config_read_array('aliases', 'alias'); $a_aliases = &config_read_array('aliases', 'alias');
/* Try to get the ID if the alias already exists */ /* Try to get the ID if the alias already exists */
...@@ -269,16 +258,11 @@ function easyrule_block_host_add($host, $int = 'wan', $ipproto = "inet") { ...@@ -269,16 +258,11 @@ function easyrule_block_host_add($host, $int = 'wan', $ipproto = "inet") {
} }
} }
function easyrule_pass_rule_add($int, $proto, $srchost, $dsthost, $dstport, $ipproto) { function easyrule_pass_rule_add($int, $proto, $srchost, $dsthost, $dstport, $ipproto)
global $config; {
$a_filter = &config_read_array('filter', 'rule');
/* No rules, start a new array */
if (!isset($config['filter']['rule'])) {
$config['filter']['rule'] = array();
}
filter_rules_sort(); filter_rules_sort();
$a_filter = &config_read_array('filter', 'rule');
/* Make up a new rule */ /* Make up a new rule */
$filterent = array(); $filterent = array();
......
...@@ -29,12 +29,7 @@ ...@@ -29,12 +29,7 @@
require_once("guiconfig.inc"); require_once("guiconfig.inc");
if (!isset($config['aliases']) || !is_array($config['aliases'])) { config_read_array('aliases', 'alias');
$config['aliases'] = array();
}
if (!isset($config['aliases']['alias'])) {
$config['aliases']['alias'] = array();
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// initialize form vars // initialize form vars
......
...@@ -37,10 +37,8 @@ if (isset($_REQUEST['closenotice'])) { ...@@ -37,10 +37,8 @@ if (isset($_REQUEST['closenotice'])) {
exit; exit;
} }
##if no config entry found, initialize config entry // if no config entry found, initialize config entry
if (empty($config['widgets']) || !is_array($config['widgets'])) { config_read_array('widgets');
$config['widgets'] = array();
}
$widgetCollection = array(); $widgetCollection = array();
......
...@@ -32,13 +32,6 @@ require_once("system.inc"); ...@@ -32,13 +32,6 @@ require_once("system.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("services.inc"); require_once("services.inc");
if (!isset($config['bridges']) || !is_array($config['bridges'])) {
$config['bridges'] = array();
}
if (!isset($config['bridges']['bridged']) || !is_array($config['bridges']['bridged'])) {
$config['bridges']['bridged'] = array();
}
$a_bridges = &config_read_array('bridges', 'bridged'); $a_bridges = &config_read_array('bridges', 'bridged');
// interface list // interface list
......
...@@ -121,12 +121,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -121,12 +121,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
} }
if (empty($config['dhcpd'][$if])) {
$config['dhcpd'][$if] = array();
}
if (empty($config['dhcpd'][$if]['pool'])) {
$config['dhcpd'][$if]['pool'] = array();
}
$a_pools = &config_read_array('dhcpd', $if, 'pool'); $a_pools = &config_read_array('dhcpd', $if, 'pool');
if (!empty($_GET['act'])) { if (!empty($_GET['act'])) {
...@@ -179,12 +173,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -179,12 +173,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pool = $_POST['pool']; $pool = $_POST['pool'];
} }
} }
if (empty($config['dhcpd'][$if])) {
$config['dhcpd'][$if] = array();
}
if (empty($config['dhcpd'][$if]['pool'])) {
$config['dhcpd'][$if]['pool'] = array();
}
$a_pools = &config_read_array('dhcpd', $if, 'pool'); $a_pools = &config_read_array('dhcpd', $if, 'pool');
if (!empty($_POST['act'])) { if (!empty($_POST['act'])) {
......
...@@ -86,6 +86,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -86,6 +86,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pconfig = $_POST; $pconfig = $_POST;
// handle identifiers and actions // handle identifiers and actions
if (!empty($pconfig['if']) && !empty($config['interfaces'][$pconfig['if']])) { if (!empty($pconfig['if']) && !empty($config['interfaces'][$pconfig['if']])) {
$if = $pconfig['if']; $if = $pconfig['if'];
...@@ -93,15 +94,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -93,15 +94,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!empty($config['dhcpd'][$if]['staticmap'][$pconfig['id']])) { if (!empty($config['dhcpd'][$if]['staticmap'][$pconfig['id']])) {
$id = $pconfig['id']; $id = $pconfig['id'];
} }
if (empty($config['dhcpd'])) {
$config['dhcpd'] = array();
}
if (empty($config['dhcpd'][$if])) {
$config['dhcpd'][$if] = array();
}
if (empty($config['dhcpd'][$if]['staticmap'])) {
$config['dhcpd'][$if]['staticmap'] = array();
}
$a_maps = &config_read_array('dhcpd', $if, 'staticmap'); $a_maps = &config_read_array('dhcpd', $if, 'staticmap');
$input_errors = array(); $input_errors = array();
......
...@@ -237,13 +237,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -237,13 +237,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
if (count($input_errors) == 0) { if (count($input_errors) == 0) {
config_read_array('dhcpdv6', $if);
$dhcpdconf = array(); $dhcpdconf = array();
if (empty($config['dhcpdv6']) || !is_array($config['dhcpdv6'])) {
$config['dhcpdv6'] = array();
}
if (empty($config['dhcpdv6'][$if]) || !is_array($config['dhcpdv6'][$if])) {
$config['dhcpdv6'][$if] = array();
}
// simple 1-on-1 copy // simple 1-on-1 copy
$config_copy_fieldsnames = array('defaultleasetime', 'maxleasetime', 'netmask', 'domain', 'domainsearchlist', $config_copy_fieldsnames = array('defaultleasetime', 'maxleasetime', 'netmask', 'domain', 'domainsearchlist',
......
...@@ -64,6 +64,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -64,6 +64,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$input_errors = array(); $input_errors = array();
$pconfig = $_POST; $pconfig = $_POST;
// handle identifiers and actions // handle identifiers and actions
if (!empty($pconfig['if']) && !empty($config['interfaces'][$pconfig['if']])) { if (!empty($pconfig['if']) && !empty($config['interfaces'][$pconfig['if']])) {
$if = $pconfig['if']; $if = $pconfig['if'];
...@@ -71,15 +72,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -71,15 +72,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!empty($config['dhcpdv6'][$if]['staticmap'][$pconfig['id']])) { if (!empty($config['dhcpdv6'][$if]['staticmap'][$pconfig['id']])) {
$id = $pconfig['id']; $id = $pconfig['id'];
} }
if (empty($config['dhcpdv6']) || !is_array($config['dhcpdv6'])) {
$config['dhcpdv6'] = array(); config_read_array('dhcpdv6', $if, 'staticmap');
}
if (empty($config['dhcpdv6'][$if]) || !is_array($config['dhcpdv6'][$if])) {
$config['dhcpdv6'][$if] = array();
}
if (empty($config['dhcpdv6'][$if]['staticmap']) || !is_array($config['dhcpdv6'][$if]['staticmap'])) {
$config['dhcpdv6'][$if]['staticmap'] = array();
}
/* input validation */ /* input validation */
$reqdfields = explode(" ", "duid"); $reqdfields = explode(" ", "duid");
$reqdfieldsn = array(gettext("DUID Identifier")); $reqdfieldsn = array(gettext("DUID Identifier"));
......
...@@ -33,13 +33,8 @@ require_once("filter.inc"); ...@@ -33,13 +33,8 @@ require_once("filter.inc");
require_once("services.inc"); require_once("services.inc");
require_once("system.inc"); require_once("system.inc");
if (empty($config['dnsmasq']['hosts']) || !is_array($config['dnsmasq']['hosts'])) { config_read_array('dnsmasq', 'hosts');
$config['dnsmasq']['hosts'] = array(); config_read_array('dnsmasq', 'domainoverrides');
}
if (empty($config['dnsmasq']['domainoverrides']) || !is_array($config['dnsmasq']['domainoverrides'])) {
$config['dnsmasq']['domainoverrides'] = array();
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig = array(); $pconfig = array();
......
...@@ -34,9 +34,7 @@ require_once("system.inc"); ...@@ -34,9 +34,7 @@ require_once("system.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("plugins.inc.d/ntpd.inc"); require_once("plugins.inc.d/ntpd.inc");
if (!isset($config['ntpd']['gps'])) { config_read_array('ntpd', 'gps');
$config['ntpd']['gps'] = array();
}
$copy_fields = array('port', 'type', 'speed', 'nmea', 'fudge1', 'fudge2', 'stratum', 'prefer', 'noselect', $copy_fields = array('port', 'type', 'speed', 'nmea', 'fudge1', 'fudge2', 'stratum', 'prefer', 'noselect',
'flag1', 'flag2', 'flag3', 'flag4', 'subsec', 'refid', 'initcmd'); 'flag1', 'flag2', 'flag3', 'flag4', 'subsec', 'refid', 'initcmd');
......
...@@ -33,12 +33,7 @@ require_once("system.inc"); ...@@ -33,12 +33,7 @@ require_once("system.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("plugins.inc.d/ntpd.inc"); require_once("plugins.inc.d/ntpd.inc");
if (!isset($config['ntpd']) || !is_array($config['ntpd'])) { config_read_array('ntpd', 'pps');
$config['ntpd'] = array();
}
if (!isset($config['ntpd']['pps'])) {
$config['ntpd']['pps'] = array();
}
$copy_fields = array('port', 'fudge1', 'stratum', 'flag2', 'flag3', 'flag4', 'refid'); $copy_fields = array('port', 'fudge1', 'stratum', 'flag2', 'flag3', 'flag4', 'refid');
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
......
...@@ -32,9 +32,7 @@ require_once("system.inc"); ...@@ -32,9 +32,7 @@ require_once("system.inc");
require_once("services.inc"); require_once("services.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
if (empty($config['opendns']) || !is_array($config['opendns'])) { config_read_array('opendns');
$config['opendns'] = array();
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['enable'] = isset($config['opendns']['enable']); $pconfig['enable'] = isset($config['opendns']['enable']);
......
...@@ -120,9 +120,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -120,9 +120,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
if (count($input_errors) == 0) { if (count($input_errors) == 0) {
if (!is_array($config['dhcpdv6'][$if])) { config_read_array('dhcpdv6', $if);
$config['dhcpdv6'][$if] = array();
}
$config['dhcpdv6'][$if]['ramode'] = $pconfig['ramode']; $config['dhcpdv6'][$if]['ramode'] = $pconfig['ramode'];
$config['dhcpdv6'][$if]['rapriority'] = $pconfig['rapriority']; $config['dhcpdv6'][$if]['rapriority'] = $pconfig['rapriority'];
......
...@@ -31,9 +31,7 @@ require_once("guiconfig.inc"); ...@@ -31,9 +31,7 @@ require_once("guiconfig.inc");
require_once("system.inc"); require_once("system.inc");
require_once("services.inc"); require_once("services.inc");
if(empty($config['unbound']) || !is_array($config['unbound'])) { config_read_array('unbound');
$config['unbound'] = array();
}
$copy_fields = array( $copy_fields = array(
'cache_max_ttl', 'cache_max_ttl',
......
...@@ -34,6 +34,8 @@ require_once("system.inc"); ...@@ -34,6 +34,8 @@ require_once("system.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
$a_hosts = &config_read_array('unbound', 'hosts'); $a_hosts = &config_read_array('unbound', 'hosts');
config_read_array('unbound', 'domainoverrides');
/* Backwards compatibility for records created before introducing RR types. */ /* Backwards compatibility for records created before introducing RR types. */
foreach ($a_hosts as $i => $hostent) { foreach ($a_hosts as $i => $hostent) {
if (!isset($hostent['rr'])) { if (!isset($hostent['rr'])) {
...@@ -41,10 +43,6 @@ foreach ($a_hosts as $i => $hostent) { ...@@ -41,10 +43,6 @@ foreach ($a_hosts as $i => $hostent) {
} }
} }
if (empty($config['unbound']['domainoverrides']) || !is_array($config['unbound']['domainoverrides'])) {
$config['unbound']['domainoverrides'] = array();
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pconfig = $_POST; $pconfig = $_POST;
if (!empty($pconfig['apply'])) { if (!empty($pconfig['apply'])) {
......
...@@ -27,19 +27,15 @@ ...@@ -27,19 +27,15 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("auth.inc"); require_once("auth.inc");
$authFactory = new \OPNsense\Auth\AuthenticationFactory(); $authFactory = new \OPNsense\Auth\AuthenticationFactory();
$authCNFOptions = $authFactory->listConfigOptions(); $authCNFOptions = $authFactory->listConfigOptions();
if (!isset($config['system']['authserver'])) { config_read_array('system', 'authserver');
$config['system']['authserver'] = array(); config_read_array('ca');
}
if (empty($config['ca']) || !is_array($config['ca'])) {
$config['ca'] = array();
}
$a_servers = auth_get_authserver_list(); $a_servers = auth_get_authserver_list();
$a_server = array(); $a_server = array();
......
...@@ -150,12 +150,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -150,12 +150,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} elseif (isset($id) && isset($pconfig['act']) && $pconfig['act'] == "toggle") { } elseif (isset($id) && isset($pconfig['act']) && $pconfig['act'] == "toggle") {
// Toggle active/in-active // Toggle active/in-active
$realid = $a_gateways[$id]['attribute']; $realid = $a_gateways[$id]['attribute'];
if (!is_array($config['gateways'])) {
$config['gateways'] = array();
}
if (!is_array($config['gateways']['gateway_item'])) {
$config['gateways']['gateway_item'] = array();
}
$a_gateway_item = &config_read_array('gateways', 'gateway_item'); $a_gateway_item = &config_read_array('gateways', 'gateway_item');
if (isset($a_gateway_item[$realid]['disabled'])) { if (isset($a_gateway_item[$realid]['disabled'])) {
......
...@@ -321,13 +321,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ...@@ -321,13 +321,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} }
if (count($input_errors) == 0) { if (count($input_errors) == 0) {
if (!isset($config['gateways']) || !is_array($config['gateways'])) {
$config['gateways'] = array();
}
if (!isset($config['gateways']['gateway_item']) || !is_array($config['gateways']['gateway_item'])) {
$config['gateways']['gateway_item'] = array();
}
// A result of obfuscating the list of gateways is that over here we need to map things back that should // A result of obfuscating the list of gateways is that over here we need to map things back that should
// be aligned with the configuration. Not going to fix this now. // be aligned with the configuration. Not going to fix this now.
if (isset($a_gateways[$id]['attribute']) && is_numeric($a_gateways[$id]['attribute']) ) { if (isset($a_gateways[$id]['attribute']) && is_numeric($a_gateways[$id]['attribute']) ) {
......
...@@ -33,15 +33,8 @@ require_once("filter.inc"); ...@@ -33,15 +33,8 @@ require_once("filter.inc");
require_once("services.inc"); require_once("services.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
if (!isset($config['ipsec']) || !is_array($config['ipsec'])) { config_read_array('ipsec', 'mobilekey');
$config['ipsec'] = array(); ipsec_mobilekey_sort();
}
if (!is_array($config['ipsec']['mobilekey'])) {
$config['ipsec']['mobilekey'] = array();
} else {
ipsec_mobilekey_sort();
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['act']) && isset($_POST['id']) && is_numericint($_POST['id']) && $_POST['act'] == "del") { if (isset($_POST['act']) && isset($_POST['id']) && is_numericint($_POST['id']) && $_POST['act'] == "del") {
......
...@@ -32,15 +32,8 @@ require_once("interfaces.inc"); ...@@ -32,15 +32,8 @@ require_once("interfaces.inc");
require_once("services.inc"); require_once("services.inc");
require_once("plugins.inc.d/ipsec.inc"); require_once("plugins.inc.d/ipsec.inc");
if (!isset($config['ipsec']) || !is_array($config['ipsec'])) { config_read_aray('ipsec', 'mobilekey');
$config['ipsec'] = array(); ipsec_mobilekey_sort();
}
if (!isset($config['ipsec']['mobilekey'])) {
$config['ipsec']['mobilekey'] = array();
} else {
ipsec_mobilekey_sort();
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig = array(); $pconfig = array();
......
...@@ -33,17 +33,8 @@ require_once("filter.inc"); ...@@ -33,17 +33,8 @@ require_once("filter.inc");
require_once("services.inc"); require_once("services.inc");
require_once("plugins.inc.d/ipsec.inc"); require_once("plugins.inc.d/ipsec.inc");
if (!isset($config['ipsec']) || !is_array($config['ipsec'])) { config_read_array('ipsec', 'client');
$config['ipsec'] = array(); config_read_array('ipsec', 'phase1');
}
if (!isset($config['ipsec']['phase1'])) {
$config['ipsec']['phase1'] = array();
}
if (!isset($config['ipsec']['client'])) {
$config['ipsec']['client'] = array();
}
// define formfields // define formfields
$form_fields = "user_source,group_source,pool_address,pool_netbits,net_list $form_fields = "user_source,group_source,pool_address,pool_netbits,net_list
......
...@@ -130,17 +130,8 @@ function getIndexByUniqueId($uniqid) ...@@ -130,17 +130,8 @@ function getIndexByUniqueId($uniqid)
return $p2index; return $p2index;
} }
if (!isset($config['ipsec']) || !is_array($config['ipsec'])) { config_read_array('ipsec', 'client');
$config['ipsec'] = array(); config_read_array('ipsec', 'phase2');
}
if (!isset($config['ipsec']['client'])) {
$config['ipsec']['client'] = array();
}
if (!isset($config['ipsec']['phase2'])) {
$config['ipsec']['phase2'] = array();
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// lookup p2index // lookup p2index
......
...@@ -33,9 +33,7 @@ require_once("plugins.inc.d/ipsec.inc"); ...@@ -33,9 +33,7 @@ require_once("plugins.inc.d/ipsec.inc");
require_once("services.inc"); require_once("services.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
if (!isset($config['ipsec']) || !is_array($config['ipsec'])) { config_read_array('ipsec');
$config['ipsec'] = array();
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// fetch form data // fetch form data
......
...@@ -31,9 +31,7 @@ ...@@ -31,9 +31,7 @@
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
if (!isset($config['virtualip']['vip'])) { config_read_array('virtualip', 'vip');
$config['virtualip']['vip'] = array();
}
?> ?>
<table class="table table-striped table-condensed"> <table class="table table-striped table-condensed">
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
require_once("guiconfig.inc"); require_once("guiconfig.inc");
config_read_array('widgets', 'thermal_sensors_widget');
function validate_temp_value($value) function validate_temp_value($value)
{ {
if (is_numeric($value) && (int)$value == $value && $value >= 0 and $value <= 100) { if (is_numeric($value) && (int)$value == $value && $value >= 0 and $value <= 100) {
...@@ -45,10 +47,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -45,10 +47,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig[$fieldname] = !empty($config['widgets']['thermal_sensors_widget'][$fieldname]) ? $config['widgets']['thermal_sensors_widget'][$fieldname] : $defaultValue; $pconfig[$fieldname] = !empty($config['widgets']['thermal_sensors_widget'][$fieldname]) ? $config['widgets']['thermal_sensors_widget'][$fieldname] : $defaultValue;
} }
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
// save widget config
if (empty($config['widgets']['thermal_sensors_widget']) || !is_array($config['widgets']['thermal_sensors_widget'])) {
$config['widgets']['thermal_sensors_widget'] = array();
}
foreach ($fieldnames as $fieldname) { foreach ($fieldnames as $fieldname) {
$defaultValue = strpos($fieldname, 'critical') !== false ? 80 : 70; $defaultValue = strpos($fieldname, 'critical') !== false ? 80 : 70;
$newValue = !empty($_POST[$fieldname]) ? $_POST[$fieldname] : ""; $newValue = !empty($_POST[$fieldname]) ? $_POST[$fieldname] : "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment