Commit 8e5f1724 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) zap update_if_changed

parent b0a36982
...@@ -464,29 +464,6 @@ function dump_log($logfile, $tail, $grepfor = '') ...@@ -464,29 +464,6 @@ function dump_log($logfile, $tail, $grepfor = '')
print_dump($logarr); print_dump($logarr);
} }
/* Check if variable has changed, update and log if it has
* returns true if var changed
* varname = variable name in plain text
* orig = original value
* new = new value
*/
function update_if_changed($varname, &$orig, $new)
{
if (is_array($orig) && is_array($new)) {
$a_diff = array_diff($orig, $new);
$a_diff = array_diff($new, $orig);
$orig = $new;
return true;
}
if ($orig != $new) {
$orig = $new;
return true;
}
return false;
}
function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) { function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
if (isset($adr['any'])) if (isset($adr['any']))
$padr = "any"; $padr = "any";
......
...@@ -203,14 +203,14 @@ if ($_POST) { ...@@ -203,14 +203,14 @@ if ($_POST) {
$monent = $a_monitor[$id]; $monent = $a_monitor[$id];
} }
update_if_changed("name", $monent['name'], $pconfig['name']); $monent['name'] = $pconfig['name'];
update_if_changed("type", $monent['type'], $pconfig['type']); $monent['type'] = $pconfig['type'];
update_if_changed("description", $monent['descr'], $pconfig['descr']); $monent['descr'] = $pconfig['descr'];
if($pconfig['type'] == "http" || $pconfig['type'] == "https" ) { if($pconfig['type'] == "http" || $pconfig['type'] == "https" ) {
/* log updates, then clear array and reassign - dumb, but easiest way to have a clear array */ /* log updates, then clear array and reassign - dumb, but easiest way to have a clear array */
update_if_changed("path", $monent['options']['path'], $pconfig['options']['path']); $monent['options']['path'] = $pconfig['options']['path'];
update_if_changed("host", $monent['options']['host'], $pconfig['options']['host']); $monent['options']['host'] = $pconfig['options']['host'];
update_if_changed("code", $monent['options']['code'], $pconfig['options']['code']); $monent['options']['code'] = $pconfig['options']['code'];
$monent['options'] = array(); $monent['options'] = array();
$monent['options']['path'] = $pconfig['options']['path']; $monent['options']['path'] = $pconfig['options']['path'];
$monent['options']['host'] = $pconfig['options']['host']; $monent['options']['host'] = $pconfig['options']['host'];
...@@ -218,8 +218,9 @@ if ($_POST) { ...@@ -218,8 +218,9 @@ if ($_POST) {
} }
if($pconfig['type'] == "send" ) { if($pconfig['type'] == "send" ) {
/* log updates, then clear array and reassign - dumb, but easiest way to have a clear array */ /* log updates, then clear array and reassign - dumb, but easiest way to have a clear array */
update_if_changed("send", $monent['options']['send'], $pconfig['options']['send']); $monent['options']['send'] = $pconfig['options']['send'];
update_if_changed("expect", $monent['options']['expect'], $pconfig['options']['expect']); $monent['options']['expect'] = $pconfig['options']['expect'];
$monent['options'] = array(); $monent['options'] = array();
$monent['options']['send'] = $pconfig['options']['send']; $monent['options']['send'] = $pconfig['options']['send'];
$monent['options']['expect'] = $pconfig['options']['expect']; $monent['options']['expect'] = $pconfig['options']['expect'];
......
...@@ -119,14 +119,14 @@ if ($_POST) { ...@@ -119,14 +119,14 @@ if ($_POST) {
$poolent = $a_pool[$id]; $poolent = $a_pool[$id];
} }
update_if_changed("name", $poolent['name'], $_POST['name']); $poolent['name'] = $_POST['name'];
update_if_changed("mode", $poolent['mode'], $_POST['mode']); $poolent['mode'] = $_POST['mode'];
update_if_changed("description", $poolent['descr'], $_POST['descr']); $poolent['descr'] = $_POST['descr'];
update_if_changed("port", $poolent['port'], $_POST['port']); $poolent['port'] = $_POST['port'];
update_if_changed("retry", $poolent['retry'], $_POST['retry']); $poolent['retry'] = $_POST['retry'];
update_if_changed("servers", $poolent['servers'], $_POST['servers']); $poolent['servers'] = $_POST['servers'];
update_if_changed("serversdisabled", $poolent['serversdisabled'], $_POST['serversdisabled']); $poolent['serversdisabled'] = $_POST['serversdisabled'];
update_if_changed("monitor", $poolent['monitor'], $_POST['monitor']); $poolent['monitor'] = $_POST['monitor'];
if (isset($id) && $a_pool[$id]) { if (isset($id) && $a_pool[$id]) {
/* modify all virtual servers with this name */ /* modify all virtual servers with this name */
......
...@@ -97,14 +97,14 @@ if ($_POST) { ...@@ -97,14 +97,14 @@ if ($_POST) {
$vsent = $a_vs[$id]; $vsent = $a_vs[$id];
} }
update_if_changed("name", $vsent['name'], $_POST['name']); $vsent['name'] = $_POST['name'];
update_if_changed("descr", $vsent['descr'], $_POST['descr']); $vsent['descr'] = $_POST['descr'];
update_if_changed("poolname", $vsent['poolname'], $_POST['poolname']); $vsent['poolname'] = $_POST['poolname'];
update_if_changed("port", $vsent['port'], $_POST['port']); $vsent['port'] = $_POST['port'];
update_if_changed("sitedown", $vsent['sitedown'], $_POST['sitedown']); $vsent['sitedown'] = $_POST['sitedown'];
update_if_changed("ipaddr", $vsent['ipaddr'], $_POST['ipaddr']); $vsent['ipaddr'] = $_POST['ipaddr'];
update_if_changed("mode", $vsent['mode'], $_POST['mode']); $vsent['mode'] = $_POST['mode'];
update_if_changed("relay protocol", $vsent['relay_protocol'], $_POST['relay_protocol']); $vsent['relay_protocol'] = $_POST['relay_protocol'];
if($_POST['sitedown'] == "") if($_POST['sitedown'] == "")
unset($vsent['sitedown']); unset($vsent['sitedown']);
......
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