From: paulr Date: Fri, 23 Sep 2011 05:00:12 +0000 (+1000) Subject: stuff X-Git-Url: http://git.pjr.cc/?p=CBFWR.git;a=commitdiff_plain;h=c6a0d901040bc483d89d8596661dcf0d5a48ffb2 stuff --- diff --git a/libcbfwr/comms.php b/libcbfwr/comms.php index 7f89650..8e7ed32 100644 --- a/libcbfwr/comms.php +++ b/libcbfwr/comms.php @@ -49,6 +49,9 @@ class Comms { // type = 1 for the boot hardware config // type = 2 for running config // type = 3 for web config + + // type = 4 for merged running config cache + // type = 5 for merged web config cache function putConfig($config, $type=0) { global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY, $CONF_STORE_SIZE; diff --git a/libcbfwr/fwui.php b/libcbfwr/fwui.php index fb9ef70..4bcfed5 100644 --- a/libcbfwr/fwui.php +++ b/libcbfwr/fwui.php @@ -16,12 +16,14 @@ function CBFWZonesPage($urls) $newname = $_REQUEST["zonename"]; $renewname = null; + error_log("comparing \"$oldname\" to \"$newname\""); if($oldname != $newname) { $renewname = " rename $newname"; } - $oldconf = $comms->getConfig(0); + $oldconf = getWebUserConfig(); $olddesc = $oldconf["zone"][$oldname]["description"]; + error_log("Comparing \"$olddesc\" and \"$desc\""); if($desc != $olddesc) { $newdesc = " # $desc"; } else $newdesc = null; @@ -31,6 +33,7 @@ function CBFWZonesPage($urls) if($renewname == null && $newdesc == null) { header("Location: $BASE_URL/zones"); + error_log("no changes?"); return; } @@ -104,12 +107,7 @@ function CBFWZonesEditPage($urls) $zone = $urls[2]; - $comms = new Comms(); - $myconf = new Config(); - - $config = $comms->getConfig(); - $conf2 = $comms->getConfig(3); - $config = $myconf->mergeConfig($config, $conf2); + $config = getWebUserConfig(); echo "

Edit Zone $zone

"; @@ -124,16 +122,38 @@ function CBFWZonesEditPage($urls) echo ""; } -function CBFWZonesPageDisplay() +function getWebUserConfig() { - global $BASE_URL, $MENU_ITEMS; - $comms = new Comms(); $myconf = new Config(); - $config = $comms->getConfig(); + + // check to see if pre-cache config matches change level of config change buffer + $config = $comms->getConfig(5); $conf2 = $comms->getConfig(3); - $config = $myconf->mergeConfig($config, $conf2); + if(isset($config["status"])) { + if($config["status"] == $conf2["status"]) { + // it did, return the pre-cache + error_log("got pre-cache config"); + return $config; + } + } + + // it did not, do a new merge and cache + $config = $myconf->mergeConfig($comms->getConfig(), $conf2); + $reconfig = $config; + $reconfig["status"] = $conf2["status"]; + error_log("put pre-cache config"); + $comms->putConfig($reconfig, 5); + + return $config; +} + +function CBFWZonesPageDisplay() +{ + global $BASE_URL, $MENU_ITEMS; + + $config = getWebUserConfig(); echo "

Zones

"; echo "";
ZoneInterfacesDescriptionEdit