From 15eb3c5652d043951dc1ddf623a4e73155563f8d Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 3 Apr 2015 12:12:43 +0200 Subject: [PATCH] gateways: more potential fails of legacy code vs. new config system --- src/www/status_gateway_groups.php | 8 +++++++- src/www/system_gateway_groups.php | 11 ++++++++++- src/www/system_gateway_groups_edit.php | 7 ++++++- src/www/system_gateways.php | 10 ++++++++-- src/www/system_gateways_edit.php | 7 ++++++- src/www/wizards/setup_wizard.xml | 6 +++++- 6 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/www/status_gateway_groups.php b/src/www/status_gateway_groups.php index 4d4cba16a..3093c01ff 100755 --- a/src/www/status_gateway_groups.php +++ b/src/www/status_gateway_groups.php @@ -1,4 +1,5 @@ . @@ -28,8 +29,13 @@ require_once("guiconfig.inc"); -if (!is_array($config['gateways']['gateway_group'])) +if (!is_array($config['gateways'])) { + $config['gateways'] = array(); +} + +if (!is_array($config['gateways']['gateway_group'])) { $config['gateways']['gateway_group'] = array(); +} $a_gateway_groups = &$config['gateways']['gateway_group']; $changedesc = gettext("Gateway Groups") . ": "; diff --git a/src/www/system_gateway_groups.php b/src/www/system_gateway_groups.php index a6bdecac6..16a9824d1 100644 --- a/src/www/system_gateway_groups.php +++ b/src/www/system_gateway_groups.php @@ -33,8 +33,17 @@ require_once("filter.inc"); require_once("shaper.inc"); require_once("openvpn.inc"); -if (!is_array($config['gateways']['gateway_group'])) +if (!is_array($config['gateways'])) { + $config['gateways'] = array(); +} + +if (!is_array($config['gateways']['gateway_item'])) { + $config['gateways']['gateway_item'] = array(); +} + +if (!is_array($config['gateways']['gateway_group'])) { $config['gateways']['gateway_group'] = array(); +} $a_gateway_groups = &$config['gateways']['gateway_group']; $a_gateways = &$config['gateways']['gateway_item']; diff --git a/src/www/system_gateway_groups_edit.php b/src/www/system_gateway_groups_edit.php index 806cd60a4..0c4765265 100644 --- a/src/www/system_gateway_groups_edit.php +++ b/src/www/system_gateway_groups_edit.php @@ -32,8 +32,13 @@ require_once("vpn.inc"); $referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/system_gateway_groups.php'); -if (!is_array($config['gateways']['gateway_group'])) +if (!is_array($config['gateways'])) { + $config['gateways'] = array(); +} + +if (!is_array($config['gateways']['gateway_group'])) { $config['gateways']['gateway_group'] = array(); +} $a_gateway_groups = &$config['gateways']['gateway_group']; $a_gateways = return_gateways_array(); diff --git a/src/www/system_gateways.php b/src/www/system_gateways.php index c91057fb5..5948afeec 100644 --- a/src/www/system_gateways.php +++ b/src/www/system_gateways.php @@ -33,12 +33,18 @@ require_once("shaper.inc"); $a_gateways = return_gateways_array(true, false, true); $a_gateways_arr = array(); -foreach ($a_gateways as $gw) +foreach ($a_gateways as $gw) { $a_gateways_arr[] = $gw; +} $a_gateways = $a_gateways_arr; -if (!is_array($config['gateways']['gateway_item'])) +if (!is_array($config['gateways'])) { + $config['gateways'] = array(); +} + +if (!is_array($config['gateways']['gateway_item'])) { $config['gateways']['gateway_item'] = array(); +} $a_gateway_item = &$config['gateways']['gateway_item']; diff --git a/src/www/system_gateways_edit.php b/src/www/system_gateways_edit.php index 05eabe819..bc2e1be01 100644 --- a/src/www/system_gateways_edit.php +++ b/src/www/system_gateways_edit.php @@ -37,8 +37,13 @@ foreach($a_gateways as $gw) { } $a_gateways = $a_gateways_arr; -if (!is_array($config['gateways']['gateway_item'])) +if (!is_array($config['gateways'])) { + $config['gateways'] = array(); +} + +if (!is_array($config['gateways']['gateway_item'])) { $config['gateways']['gateway_item'] = array(); +} $a_gateway_item = &$config['gateways']['gateway_item']; $apinger_default = return_apinger_defaults(); diff --git a/src/www/wizards/setup_wizard.xml b/src/www/wizards/setup_wizard.xml index 4a39b9067..127871dfc 100644 --- a/src/www/wizards/setup_wizard.xml +++ b/src/www/wizards/setup_wizard.xml @@ -579,8 +579,12 @@ $config['system']['hostname'] = $config['wizardtemp']['system']['hostname']; $config['system']['domain'] = $config['wizardtemp']['system']['domain']; if (!empty($config['wizardtemp']['wangateway'])) { - if (!is_array($config['gateways']['gateway_item'])) + if (!is_array($config['gateways'])) { + $config['gateways'] = array(); + } + if (!is_array($config['gateways']['gateway_item'])) { $config['gateways']['gateway_item'] = array(); + } $found = false; $defaultgw_found = false; foreach ($config['gateways']['gateway_item'] as & $gw) {