Commit 808a2604 authored by Franco Fichtner's avatar Franco Fichtner

www: purge $changedesc; closes #394

This one and the former were good ideas, but:

o They only affected a very small percentage of the actual code, and
o Reviewing changes is best done in the config.xml, not the revision message.
parent 31293e66
...@@ -338,13 +338,6 @@ function gentitle($title) { ...@@ -338,13 +338,6 @@ function gentitle($title) {
return join($navlevelsep, $title); return join($navlevelsep, $title);
} }
function update_changedesc($update)
{
global $changedesc;
$changedesc .= " {$update}";
}
function clear_log($logfile, $restart_syslogd = true) function clear_log($logfile, $restart_syslogd = true)
{ {
if ($restart_syslogd) { if ($restart_syslogd) {
...@@ -469,26 +462,20 @@ function dump_log($logfile, $tail, $withorig = true, $grepfor = '', $grepinvert ...@@ -469,26 +462,20 @@ function dump_log($logfile, $tail, $withorig = true, $grepfor = '', $grepinvert
* orig = original value * orig = original value
* new = new value * new = new value
*/ */
function update_if_changed($varname, & $orig, $new) { function update_if_changed($varname, &$orig, $new)
{
if (is_array($orig) && is_array($new)) { if (is_array($orig) && is_array($new)) {
$a_diff = array_diff($orig, $new); $a_diff = array_diff($orig, $new);
foreach ($a_diff as $diff) {
update_changedesc("removed {$varname}: \"{$diff}\"");
}
$a_diff = array_diff($new, $orig); $a_diff = array_diff($new, $orig);
foreach ($a_diff as $diff) {
update_changedesc("added {$varname}: \"{$diff}\"");
}
$orig = $new; $orig = $new;
return true; return true;
}
} else { if ($orig != $new) {
if ($orig != $new) { $orig = $new;
update_changedesc("{$varname}: \"{$orig}\" -> \"{$new}\""); return true;
$orig = $new;
return true;
}
} }
return false; return false;
} }
......
...@@ -127,8 +127,6 @@ if (isset($id) && $a_monitor[$id]) { ...@@ -127,8 +127,6 @@ if (isset($id) && $a_monitor[$id]) {
$pconfig['options']['code'] = 200; $pconfig['options']['code'] = 200;
} }
$changedesc = gettext("Load Balancer: Monitor:") . " ";
if ($_POST) { if ($_POST) {
unset($input_errors); unset($input_errors);
$pconfig = $_POST; $pconfig = $_POST;
...@@ -200,10 +198,10 @@ if ($_POST) { ...@@ -200,10 +198,10 @@ if ($_POST) {
if (!$input_errors) { if (!$input_errors) {
$monent = array(); $monent = array();
if(isset($id) && $a_monitor[$id])
if (isset($id) && $a_monitor[$id]) {
$monent = $a_monitor[$id]; $monent = $a_monitor[$id];
if($monent['name'] != "") }
$changedesc .= " " . sprintf(gettext("modified '%s' monitor:"), $monent['name']);
update_if_changed("name", $monent['name'], $pconfig['name']); update_if_changed("name", $monent['name'], $pconfig['name']);
update_if_changed("type", $monent['type'], $pconfig['type']); update_if_changed("type", $monent['type'], $pconfig['type']);
...@@ -242,7 +240,7 @@ if ($_POST) { ...@@ -242,7 +240,7 @@ if ($_POST) {
} }
mark_subsystem_dirty('loadbalancer'); mark_subsystem_dirty('loadbalancer');
write_config($changedesc); write_config();
header("Location: load_balancer_monitor.php"); header("Location: load_balancer_monitor.php");
exit; exit;
} }
......
...@@ -54,8 +54,6 @@ if (isset($id) && $a_pool[$id]) { ...@@ -54,8 +54,6 @@ if (isset($id) && $a_pool[$id]) {
$pconfig['monitor'] = $a_pool[$id]['monitor']; $pconfig['monitor'] = $a_pool[$id]['monitor'];
} }
$changedesc = gettext("Load Balancer: Pool:") . " ";
if ($_POST) { if ($_POST) {
unset($input_errors); unset($input_errors);
$pconfig = $_POST; $pconfig = $_POST;
...@@ -116,10 +114,10 @@ if ($_POST) { ...@@ -116,10 +114,10 @@ if ($_POST) {
if (!$input_errors) { if (!$input_errors) {
$poolent = array(); $poolent = array();
if(isset($id) && $a_pool[$id])
if (isset($id) && $a_pool[$id]) {
$poolent = $a_pool[$id]; $poolent = $a_pool[$id];
if($poolent['name'] != "") }
$changedesc .= sprintf(gettext(" modified '%s' pool:"), $poolent['name']);
update_if_changed("name", $poolent['name'], $_POST['name']); update_if_changed("name", $poolent['name'], $_POST['name']);
update_if_changed("mode", $poolent['mode'], $_POST['mode']); update_if_changed("mode", $poolent['mode'], $_POST['mode']);
...@@ -142,7 +140,7 @@ if ($_POST) { ...@@ -142,7 +140,7 @@ if ($_POST) {
} }
mark_subsystem_dirty('loadbalancer'); mark_subsystem_dirty('loadbalancer');
write_config($changedesc); write_config();
header("Location: load_balancer_pool.php"); header("Location: load_balancer_pool.php");
exit; exit;
} }
......
...@@ -54,8 +54,6 @@ if (isset($id) && $a_action[$id]) { ...@@ -54,8 +54,6 @@ if (isset($id) && $a_action[$id]) {
$pconfig['action'] = 'change'; $pconfig['action'] = 'change';
} }
$changedesc = gettext("Load Balancer: Relay Action:") . " ";
$kv = array('key', 'value'); $kv = array('key', 'value');
$vk = array('value', 'key'); $vk = array('value', 'key');
$hr_actions = array(); $hr_actions = array();
...@@ -117,10 +115,9 @@ if ($_POST) { ...@@ -117,10 +115,9 @@ if ($_POST) {
if (!$input_errors) { if (!$input_errors) {
$actent = array(); $actent = array();
if(isset($id) && $a_action[$id]) if (isset($id) && $a_action[$id]) {
$actent = $a_action[$id]; $actent = $a_action[$id];
if($actent['name'] != "") }
$changedesc .= " " . sprintf(gettext("modified '%s' action:"), $actent['name']);
update_if_changed("name", $actent['name'], $pconfig['name']); update_if_changed("name", $actent['name'], $pconfig['name']);
update_if_changed("protocol", $actent['protocol'], $pconfig['protocol']); update_if_changed("protocol", $actent['protocol'], $pconfig['protocol']);
...@@ -157,7 +154,7 @@ if ($_POST) { ...@@ -157,7 +154,7 @@ if ($_POST) {
} }
mark_subsystem_dirty('loadbalancer'); mark_subsystem_dirty('loadbalancer');
write_config($changedesc); write_config();
header("Location: load_balancer_relay_action.php"); header("Location: load_balancer_relay_action.php");
exit; exit;
} }
......
...@@ -53,8 +53,6 @@ if (isset($id) && $a_protocol[$id]) { ...@@ -53,8 +53,6 @@ if (isset($id) && $a_protocol[$id]) {
$pconfig['type'] = 'http'; $pconfig['type'] = 'http';
} }
$changedesc = gettext("Load Balancer: Relay Protocol:") . " ";
if ($_POST) { if ($_POST) {
unset($input_errors); unset($input_errors);
$pconfig = $_POST; $pconfig = $_POST;
...@@ -85,10 +83,10 @@ if ($_POST) { ...@@ -85,10 +83,10 @@ if ($_POST) {
if (!$input_errors) { if (!$input_errors) {
$protent = array(); $protent = array();
if(isset($id) && $a_protocol[$id])
if(isset($id) && $a_protocol[$id]) {
$protent = $a_protocol[$id]; $protent = $a_protocol[$id];
if($protent['name'] != "") }
$changedesc .= " " . sprintf(gettext("modified '%s' load balancing protocol:"), $protent['name']);
update_if_changed(gettext("name"), $protent['name'], $pconfig['name']); update_if_changed(gettext("name"), $protent['name'], $pconfig['name']);
update_if_changed(gettext("type"), $protent['type'], $pconfig['type']); update_if_changed(gettext("type"), $protent['type'], $pconfig['type']);
...@@ -110,7 +108,7 @@ if ($_POST) { ...@@ -110,7 +108,7 @@ if ($_POST) {
} }
mark_subsystem_dirty('loadbalancer'); mark_subsystem_dirty('loadbalancer');
write_config($changedesc); write_config();
header("Location: load_balancer_relay_protocol.php"); header("Location: load_balancer_relay_protocol.php");
exit; exit;
} }
......
...@@ -52,8 +52,6 @@ if (isset($id) && $a_vs[$id]) { ...@@ -52,8 +52,6 @@ if (isset($id) && $a_vs[$id]) {
$pconfig['mode'] = 'redirect'; $pconfig['mode'] = 'redirect';
} }
$changedesc = gettext("Load Balancer: Virtual Server:") . " ";
if ($_POST) { if ($_POST) {
unset($input_errors); unset($input_errors);
$pconfig = $_POST; $pconfig = $_POST;
...@@ -94,12 +92,10 @@ if ($_POST) { ...@@ -94,12 +92,10 @@ if ($_POST) {
if (!$input_errors) { if (!$input_errors) {
$vsent = array(); $vsent = array();
if(isset($id) && $a_vs[$id])
if (isset($id) && $a_vs[$id]) {
$vsent = $a_vs[$id]; $vsent = $a_vs[$id];
if($vsent['name'] != "") }
$changedesc .= " " . sprintf(gettext("modified '%s' vs:"), $vsent['name']);
else
$changedesc .= " " . sprintf(gettext("created '%s' vs:"), $_POST['name']);
update_if_changed("name", $vsent['name'], $_POST['name']); update_if_changed("name", $vsent['name'], $_POST['name']);
update_if_changed("descr", $vsent['descr'], $_POST['descr']); update_if_changed("descr", $vsent['descr'], $_POST['descr']);
...@@ -124,7 +120,7 @@ if ($_POST) { ...@@ -124,7 +120,7 @@ if ($_POST) {
} }
mark_subsystem_dirty('loadbalancer'); mark_subsystem_dirty('loadbalancer');
write_config($changedesc); write_config();
header("Location: load_balancer_virtual_server.php"); header("Location: load_balancer_virtual_server.php");
exit; exit;
} }
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
require_once("guiconfig.inc"); require_once("guiconfig.inc");
function lookup_gateway_monitor_ip_by_name($name) { function lookup_gateway_monitor_ip_by_name($name)
{
$gateways_arr = return_gateways_array(false, true); $gateways_arr = return_gateways_array(false, true);
if (!empty($gateways_arr[$name])) { if (!empty($gateways_arr[$name])) {
$gateway = $gateways_arr[$name]; $gateway = $gateways_arr[$name];
...@@ -53,7 +53,6 @@ if (!is_array($config['gateways']['gateway_group'])) { ...@@ -53,7 +53,6 @@ if (!is_array($config['gateways']['gateway_group'])) {
} }
$a_gateway_groups = &$config['gateways']['gateway_group']; $a_gateway_groups = &$config['gateways']['gateway_group'];
$changedesc = gettext("Gateway Groups") . ": ";
$gateways_status = return_gateways_status(); $gateways_status = return_gateways_status();
......
...@@ -78,7 +78,6 @@ if (!is_array($config['gateways']['gateway_group'])) { ...@@ -78,7 +78,6 @@ if (!is_array($config['gateways']['gateway_group'])) {
$a_gateway_groups = &$config['gateways']['gateway_group']; $a_gateway_groups = &$config['gateways']['gateway_group'];
$a_gateways = &$config['gateways']['gateway_item']; $a_gateways = &$config['gateways']['gateway_item'];
$changedesc = gettext("Gateway Groups") . ": ";
if ($_POST) { if ($_POST) {
$pconfig = $_POST; $pconfig = $_POST;
...@@ -112,14 +111,13 @@ if ($_POST) { ...@@ -112,14 +111,13 @@ if ($_POST) {
if ($_GET['act'] == "del") { if ($_GET['act'] == "del") {
if ($a_gateway_groups[$_GET['id']]) { if ($a_gateway_groups[$_GET['id']]) {
$changedesc .= gettext("removed gateway group") . " {$_GET['id']}";
foreach ($config['filter']['rule'] as $idx => $rule) { foreach ($config['filter']['rule'] as $idx => $rule) {
if ($rule['gateway'] == $a_gateway_groups[$_GET['id']]['name']) { if ($rule['gateway'] == $a_gateway_groups[$_GET['id']]['name']) {
unset($config['filter']['rule'][$idx]['gateway']); unset($config['filter']['rule'][$idx]['gateway']);
} }
} }
unset($a_gateway_groups[$_GET['id']]); unset($a_gateway_groups[$_GET['id']]);
write_config($changedesc); write_config();
mark_subsystem_dirty('staticroutes'); mark_subsystem_dirty('staticroutes');
header("Location: system_gateway_groups.php"); header("Location: system_gateway_groups.php");
exit; exit;
......
...@@ -44,7 +44,6 @@ if (!is_array($config['staticroutes']['route'])) { ...@@ -44,7 +44,6 @@ if (!is_array($config['staticroutes']['route'])) {
$a_routes = &$config['staticroutes']['route']; $a_routes = &$config['staticroutes']['route'];
$a_gateways = return_gateways_array(true, true, true); $a_gateways = return_gateways_array(true, true, true);
$changedesc_prefix = gettext("Static Routes") . ": ";
if ($_POST) { if ($_POST) {
$pconfig = $_POST; $pconfig = $_POST;
...@@ -75,7 +74,7 @@ if ($_POST) { ...@@ -75,7 +74,7 @@ if ($_POST) {
function delete_static_route($id) function delete_static_route($id)
{ {
global $config, $a_routes, $changedesc_prefix; global $config, $a_routes;
if (!isset($a_routes[$id])) { if (!isset($a_routes[$id])) {
return; return;
...@@ -108,10 +107,9 @@ function delete_static_route($id) ...@@ -108,10 +107,9 @@ function delete_static_route($id)
if ($_GET['act'] == "del") { if ($_GET['act'] == "del") {
if ($a_routes[$_GET['id']]) { if ($a_routes[$_GET['id']]) {
$changedesc = $changedesc_prefix . gettext("removed route to") . " " . $a_routes[$_GET['id']]['network'];
delete_static_route($_GET['id']); delete_static_route($_GET['id']);
unset($a_routes[$_GET['id']]); unset($a_routes[$_GET['id']]);
write_config($changedesc); write_config();
header("Location: system_routes.php"); header("Location: system_routes.php");
exit; exit;
} }
...@@ -120,13 +118,11 @@ if ($_GET['act'] == "del") { ...@@ -120,13 +118,11 @@ if ($_GET['act'] == "del") {
if (isset($_POST['del_x'])) { if (isset($_POST['del_x'])) {
/* delete selected routes */ /* delete selected routes */
if (is_array($_POST['route']) && count($_POST['route'])) { if (is_array($_POST['route']) && count($_POST['route'])) {
$changedesc = $changedesc_prefix . gettext("removed route to");
foreach ($_POST['route'] as $routei) { foreach ($_POST['route'] as $routei) {
$changedesc .= " " . $a_routes[$routei]['network'];
delete_static_route($routei); delete_static_route($routei);
unset($a_routes[$routei]); unset($a_routes[$routei]);
} }
write_config($changedesc); write_config();
header("Location: system_routes.php"); header("Location: system_routes.php");
exit; exit;
} }
...@@ -135,16 +131,13 @@ if (isset($_POST['del_x'])) { ...@@ -135,16 +131,13 @@ if (isset($_POST['del_x'])) {
if ($a_routes[$_GET['id']]) { if ($a_routes[$_GET['id']]) {
if (isset($a_routes[$_GET['id']]['disabled'])) { if (isset($a_routes[$_GET['id']]['disabled'])) {
unset($a_routes[$_GET['id']]['disabled']); unset($a_routes[$_GET['id']]['disabled']);
$changedesc = $changedesc_prefix . gettext("enabled route to") . " " . $a_routes[$id]['network'];
} else { } else {
delete_static_route($_GET['id']); delete_static_route($_GET['id']);
$a_routes[$_GET['id']]['disabled'] = true; $a_routes[$_GET['id']]['disabled'] = true;
$changedesc = $changedesc_prefix . gettext("disabled route to") . " " . $a_routes[$id]['network'];
} }
if (write_config($changedesc)) { write_config();
mark_subsystem_dirty('staticroutes'); mark_subsystem_dirty('staticroutes');
}
header("Location: system_routes.php"); header("Location: system_routes.php");
exit; exit;
} }
......
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