X-Git-Url: http://git.pjr.cc/?p=CBFWR.git;a=blobdiff_plain;f=libcbfwr%2Ffwui.php;h=adc95416a886aa96ab5a9c21287fe547ba1c89eb;hp=decadf2dc393e704177cbac262de7160cfa0dbb4;hb=13e5ebe14a18fb0d217fdc6fc4fc786a678889da;hpb=0f5458e4a9c18595f7d9501880011369e4e65942
diff --git a/libcbfwr/fwui.php b/libcbfwr/fwui.php
index decadf2..adc9541 100644
--- a/libcbfwr/fwui.php
+++ b/libcbfwr/fwui.php
@@ -7,16 +7,80 @@ function CBFWZonesPage($urls)
if(isset($urls[1])) {
switch($urls[1]) {
+ case "modify":
+
+ if($_REQUEST["description"] != "") $desc = $_REQUEST["description"];
+ else $desc = null;
+
+ $oldname = $_REQUEST["oldname"];
+ $newname = $_REQUEST["zonename"];
+
+ $renewname = null;
+ error_log("comparing \"$oldname\" to \"$newname\"");
+ if($oldname != $newname) {
+ $renewname = " rename $newname";
+ }
+
+ $oldconf = getWebUserConfig();
+ $olddesc = $oldconf["zone"][$oldname]["description"];
+ error_log("Comparing \"$olddesc\" and \"$desc\"");
+ if($desc != $olddesc) {
+ $newdesc = " # $desc";
+ } else $newdesc = null;
+
+ //echo "confs: \"$olddesc\", \"$newdesc\", $oldname, $newname
";
+ //exit(0);
+
+ if($renewname == null && $newdesc == null) {
+ header("Location: $BASE_URL/zones");
+ error_log("no changes?");
+ return;
+ }
+
+
+ $conf = $comms->getConfig(3);
+ $changes = $conf["status"];
+ if($changes == "nochange") $conf["status"] = 1;
+ else $conf["status"] = $changes + 1;
+ $cnum = $conf["status"];
+
+ $conf[$cnum]["modify"] = "zone $oldname$renewname$newdesc";
+ $comms->putConfig($conf, 3);
+ header("Location: $BASE_URL/zones");
+
+ break;
+
+
case "edit":
+ CBFWpageBuilder(null, "CBFWZonesEditPage", null, null, $urls);
break;
- case "change":
+
+
+ case "delete":
+ $zonetodelete = $urls[2];
+
+ addWebUserChange("delete zone name $zonetodelete");
+ header("Location: $BASE_URL/zones");
break;
+
+
case "add":
+
+ // UGLY
$nametoadd = $_REQUEST["toadd"];
- $comms->sendMessage("zone add $nametoadd");
- //if($_REQUEST["desc"] != "") $comms->sendMessage("zone ")
+ $desc = $_REQUEST["desc"];
+
+ $descbit = "";
+ if($desc != "") $descbit = " # $desc";
+ if($nametoadd == "" || $nametoadd == null) {
+ return;
+ }
+
+ addWebUserChange("zone name $nametoadd $descbit");
header("Location: $BASE_URL/zones");
break;
+
+
default:
CBFWpageBuilder(null, "CBFWZonesPageDisplay");
}
@@ -25,20 +89,97 @@ function CBFWZonesPage($urls)
}
}
-function CBFWZonesPageDisplay()
+function CBFWZonesEditPage($urls)
{
global $BASE_URL, $MENU_ITEMS;
+ $zone = $urls[2];
+
+ $config = getWebUserConfig();
+
+
+ echo "
Edit Zone $zone
";
+ echo "";
+}
+
+function addWebUserChange($change)
+{
+ $comms = new Comms();
+ $myconf = new Config();
+
+ $conf = $comms->getConfig(3);
+
+ if(!isset($conf["status"])) {
+ $conf["status"] = "nochange";
+ }
+
+ $changes = $conf["status"];
+ if($changes == "nochange") $conf["status"] = 1;
+ else $conf["status"] = $changes + 1;
+ $cnum = $conf["status"];
+
+ $conf["changes"][$cnum] = "$change";
+ $comms->putConfig($conf, 3);
+
+}
+
+// TODO: we need to really sit and think about this one
+function getWebUserConfig()
+{
$comms = new Comms();
+ $myconf = new Config();
+
+
+ // check to see if pre-cache config matches change level of config change buffer
+ $config = $comms->getConfig(5);
+ $conf2 = $comms->getConfig(3);
+ 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
+ // TODO: need to do this part
$config = $comms->getConfig();
+ $reconfig = $config;
+ $myconf->setConfig($config);
+ if(isset($conf2["changes"])) foreach($conf2["changes"] as $key => $var) {
+ error_log("Adding config line $key, $var");
+ $myconf->addConfigLine($var);
+ }
+ $reconfig = $myconf->getConfig();
+ $reconfig["status"] = $conf2["status"];
+ error_log("put pre-cache config");
+ $comms->putConfig($reconfig, 5);
+
+ return $reconfig;
+}
+
+function CBFWZonesPageDisplay()
+{
+ global $BASE_URL, $MENU_ITEMS;
+
+ $config = getWebUserConfig();
echo "Zones
";
- echo "Zone | Interfaces | Edit |
";
+ echo "Zone | Interfaces | Description | Edit |
";
foreach($config["zone"] as $key => $var) {
$name = $key;
$url = "Edit";
- echo "$name | ... | $url |
";
+ $url2 = "Delete";
+ $desc = $var["description"];
+ echo "$name | ... | $desc | $url $url2 |
";
}
echo "
";
@@ -51,6 +192,31 @@ function CBFWZonesPageDisplay()
}
+function CBFWRoutingPage($urls)
+{
+ if(isset($urls[1])) {
+ switch($urls[1]) {
+ case "edit":
+ CBFWpageBuilder(null, "CBFWRoutingPageEdit", null, null, $urls[2]);
+ break;
+ case "change":
+ CBFWRoutingChange();
+ break;
+ default:
+ CBFWpageBuilder(null, "CBFWRoutingPageDisplay");
+ }
+ } else {
+ error_log("main interface page");
+ CBFWpageBuilder(null, "CBFWRoutingPageDisplay");
+ }
+
+}
+
+function CBFWRoutingPageDisplay()
+{
+ echo "Routing
";
+}
+
function CBFWInterfacesPage($urls)
{
if(isset($urls[1])) {
@@ -75,7 +241,6 @@ function CBFWInterfacesChange()
global $BASE_URL, $MENU_ITEMS;
$comms = new Comms();
- $comms->sendMessage("interface eth0 changename poof");
header("Location: $BASE_URL/interfaces");
}
@@ -84,16 +249,51 @@ function CBFWInterfacesPageEdit($urls)
global $BASE_URL, $MENU_ITEMS;
$interface = $urls;
+ $comms = new Comms();
+
+ $config = getWebUserConfig();
+ $boot_config = $comms->getConfig(1);
+
+ if(isset($config["interface"]["dev"]["$interface"]["name"])) $name = $config["interface"]["dev"]["$interface"]["name"];
+ else $name = "";
+
+ $extra2 = "";
+ if(file_exists("/sys/class/net/$interface/address")) {
+ $extra2 = trim(file_get_contents("/sys/class/net/$interface/address"));
+ }
+
+ $extra = "";
+ if(isset($boot_config["hardware"]["netdev"]["$interface"]["hwaddress"])) {
+ $hwaddr = $boot_config["hardware"]["netdev"]["$interface"]["hwaddress"];
+ $extra = " Original address: $hwaddr";
+ if($hwaddr != $extra2 && $extra2 != "") {
+ $extra .= " Current Address: $hwaddr";
+ }
+ }
+ if(isset($config["interface"]["dev"]["$interface"]["hwaddress"])) $hwaddr = $config["interface"]["dev"]["$interface"]["hwaddress"];
+
+ if(isset($config["interface"]["dev"]["$interface"]["zone"])) $zone = $config["interface"]["dev"]["$interface"]["zone"];
+
+ if(isset($config["interface"]["dev"]["$interface"]["address4"])) $ip4 = $config["interface"]["dev"]["$interface"]["address4"];
+
+ if(isset($config["interface"]["dev"]["$interface"]["address6"])) $ip6 = $config["interface"]["dev"]["$interface"]["address6"];
+
+ if(isset($boot_config["hardware"]["netdev"]["$interface"]["speed"])) $speed = $boot_config["hardware"]["netdev"]["$interface"]["speed"];
+ if(isset($boot_config["hardware"]["netdev"]["$interface"]["duplex"])) $duplex = $boot_config["hardware"]["netdev"]["$interface"]["duplex"];
+ if(isset($config["interface"]["dev"]["$interface"]["speed"])) $speed = $config["interface"]["dev"]["$interface"]["speed"];
+ if(isset($config["interface"]["dev"]["$interface"]["duplex"])) $duplex = $config["interface"]["dev"]["$interface"]["duplex"];
+
echo "Edit Interface $interface
";
echo "