From 99c613527106c165d3d3fc662bc1ef9546a6718d Mon Sep 17 00:00:00 2001 From: Ermal Date: Thu, 16 Sep 2010 17:01:48 +0000 Subject: Bring code up to speed with latest world. --- usr/local/www/system_gateways_edit.php | 46 ++++++++++++---------------------- 1 file changed, 16 insertions(+), 30 deletions(-) (limited to 'usr/local/www/system_gateways_edit.php') diff --git a/usr/local/www/system_gateways_edit.php b/usr/local/www/system_gateways_edit.php index 3901d84..159444a 100755 --- a/usr/local/www/system_gateways_edit.php +++ b/usr/local/www/system_gateways_edit.php @@ -42,7 +42,7 @@ require("guiconfig.inc"); require("pkg-utils.inc"); -$a_gateways = return_gateways_array(); +$a_gateways = return_gateways_array(true); $a_gateways_arr = array(); foreach($a_gateways as $gw) { $a_gateways_arr[] = $gw; @@ -76,11 +76,7 @@ if (isset($id) && $a_gateways[$id]) { $pconfig['down'] = $a_gateway_item[$id]['down']; if (isset($a_gateways[$id]['dynamic'])) $pconfig['dynamic'] = true; - if(($a_gateways[$id]['monitor'] <> "") && ($a_gateways[$id]['attribute'] != "system") && ($a_gateways[$id]['gateway'] != "dynamic")) { - $pconfig['monitor'] = $a_gateways[$id]['monitor']; - } else { - $pconfig['monitor'] == ""; - } + $pconfig['monitor'] = $a_gateways[$id]['monitor']; $pconfig['descr'] = $a_gateways[$id]['descr']; $pconfig['attribute'] = $a_gateways[$id]['attribute']; } @@ -95,8 +91,8 @@ if ($_POST) { unset($input_errors); /* input validation */ - $reqdfields = explode(" ", "name"); - $reqdfieldsn = array(gettext("Name")); + $reqdfields = explode(" ", "name interface"); + $reqdfieldsn = array(gettext("Name", "Interface")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); @@ -199,18 +195,14 @@ if ($_POST) { $_POST['defaultgw'] || ($_POST['gateway'] && $_POST['gateway'] != "dynamic")) $save = true; /* if we are processing a system gateway only save the monitorip */ - if (!$save && empty($_POST['interface']) && empty($_POST['gateway'])) { + if (!$save && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic")) { if (is_ipaddr($_POST['monitor'])) { - if (empty($_POST['interface'])) - $interface = $pconfig['friendlyiface']; - else - $interface = $_POST['interface']; + $interface = $_POST['interface']; $config['interfaces'][$interface]['monitorip'] = $_POST['monitor']; } /* when dynamic gateway is not anymore a default the entry is no more needed. */ - if (isset($id) && $a_gateway_item[$id]) { + if (isset($id) && $a_gateway_item[$id]) unset($a_gateway_item[$id]); - } } else { /* Manual gateways are handled differently */ @@ -222,12 +214,12 @@ if ($_POST) { $gateway['name'] = $_POST['name']; $gateway['weight'] = $_POST['weight']; $gateway['descr'] = $_POST['descr']; - if(is_ipaddr($_POST['monitor'])) { + if (is_ipaddr($_POST['monitor'])) $gateway['monitor'] = $_POST['monitor']; - } else { + else unset($gateway['monitor']); - } - if ($_POST['defaultgw'] == "yes" or $_POST['defaultgw'] == "on") { + + if ($_POST['defaultgw'] == "yes" || $_POST['defaultgw'] == "on") { $i = 0; foreach($a_gateway_item as $gw) { unset($config['gateways']['gateway_item'][$i]['defaultgw']); @@ -235,9 +227,8 @@ if ($_POST) { } $gateway['defaultgw'] = true; $reloadif = true; - } else { + } else unset($gateway['defaultgw']); - } if ($_POST['latencylow']) $gateway['latencylow'] = $_POST['latencylow']; @@ -251,13 +242,11 @@ if ($_POST) { $gateway['down'] = $_POST['down']; /* when saving the manual gateway we use the attribute which has the corresponding id */ - if (isset($id) && $a_gateway_item[$id]) { + if (isset($id) && $a_gateway_item[$id]) $a_gateway_item[$id] = $gateway; - } else { + else $a_gateway_item[] = $gateway; - } } - system_resolvconf_generate(); mark_subsystem_dirty('staticroutes'); write_config(); @@ -266,15 +255,12 @@ if ($_POST) { echo $_POST['name']; exit; } else if ($reloadif == true) - interface_configure($_POST['interface']); + send_event("interface reconfigure {$_POST['interface']}"); header("Location: system_gateways.php"); exit; - } else { + } else $pconfig = $_POST; - if (empty($_POST['friendlyiface'])) - $pconfig['friendlyiface'] = $_POST['interface']; - } } -- cgit v1.1