stuff
[CBFWR.git] / libcbfwr / fwui.php
index fb9ef70..4bcfed5 100644 (file)
@@ -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 "<h2>Edit Zone $zone</h2>";
@@ -124,16 +122,38 @@ function CBFWZonesEditPage($urls)
        echo "</form>";
 }
 
-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 "<h2>Zones</h2>";
        echo "<table border=\"1\"><tr><th>Zone</th><th>Interfaces</th><th>Description</th><th>Edit</th></tr>";