X-Git-Url: http://git.pjr.cc/?p=CBFWR.git;a=blobdiff_plain;f=libcbfwr%2Ffwui.php;h=e827c2ca879676fd4af03b2940af6e27a0aa8e16;hp=decadf2dc393e704177cbac262de7160cfa0dbb4;hb=86842492eae6203c9df0df46363b4e809d577c70;hpb=0f5458e4a9c18595f7d9501880011369e4e65942 diff --git a/libcbfwr/fwui.php b/libcbfwr/fwui.php index decadf2..e827c2c 100644 --- a/libcbfwr/fwui.php +++ b/libcbfwr/fwui.php @@ -7,16 +7,92 @@ 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]; + + $conf = $comms->getConfig(3); + $changes = $conf["status"]; + if($changes == "nochange") $conf["status"] = 1; + else $conf["status"] = $changes + 1; + $cnum = $conf["status"]; + + $conf[$cnum]["delete"] = "zone $zonetodelete"; + $comms->putConfig($conf, 3); + header("Location: $BASE_URL/zones"); break; + + case "add": + + // UGLY + $cnum = 0; $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; + } + $conf = $comms->getConfig(3); + $changes = $conf["status"]; + if($changes == "nochange") $conf["status"] = 1; + else $conf["status"] = $changes + 1; + $cnum = $conf["status"]; + $conf[$cnum]["add"] = "zone $nametoadd$descbit"; + $comms->putConfig($conf, 3); header("Location: $BASE_URL/zones"); break; + + default: CBFWpageBuilder(null, "CBFWZonesPageDisplay"); } @@ -25,20 +101,68 @@ function CBFWZonesPage($urls) } } -function CBFWZonesPageDisplay() +function CBFWZonesEditPage($urls) { global $BASE_URL, $MENU_ITEMS; + $zone = $urls[2]; + + $config = getWebUserConfig(); + + + echo "

Edit Zone $zone

"; + echo "
"; + echo ""; + echo "Name:
"; + + if(isset($config["zone"][$zone]["description"])) $desc = $config["zone"][$zone]["description"]; + + echo "Description:
"; + echo ""; + echo "
"; +} + +function getWebUserConfig() +{ $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); + 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 ""; + echo "
ZoneInterfacesEdit
"; foreach($config["zone"] as $key => $var) { $name = $key; $url = "Edit"; - echo ""; + $url2 = "Delete"; + $desc = $var["description"]; + echo ""; } echo "
ZoneInterfacesDescriptionEdit
$name...$url
$name...$desc$url $url2

"; @@ -122,6 +246,9 @@ function CBFWInterfacesPageDisplay() // hw address if(isset($val["hwaddress"])) $table[$key]["hwaddress"] = $val["hwaddress"]; + + // current mtu + if(isset($val["mtu"])) $table[$key]["mtu"] = $val["mtu"]; } foreach($config["hardware"]["netdev"] as $key=>$val) { @@ -207,11 +334,84 @@ function CBFWInterfacesPageDisplay() echo ""; } -function CBFWObjectsPage() +function CBFWObjectsPage($urls) { $comms = new Comms(); $config = $comms->getConfig(); + + CBFWpageBuilder(null, "CBFWObjectsDisplay"); +} + +function CBFWObjectsDisplay() +{ + global $BASE_URL, $MENU_ITEMS; + $config = getWebUserConfig(); + + echo "

Objects

"; + + if(isset($config["objects"])) { + echo ""; + echo ""; + echo "
NetworksHostsServicesNetwork GroupsHost GroupsService Groups
"; + foreach($config["objects"] as $key => $var) { + } + } else { + echo "No objects set\n"; + } + + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + + echo "
"; + echo "

Create Network


"; + echo "
"; + echo "Name
"; + echo "IPv4 /
"; + echo "IPv6 /
"; + echo ""; + echo "
"; + echo "
"; + echo "

Create Host


"; + echo "
"; + echo "Name
"; + echo "IPv4
"; + echo "IPv6
"; + echo ""; + echo "
"; + echo "
"; + echo "

Service


"; + echo "
"; + echo "Name
"; + echo "Port "; + echo "
"; + echo ""; + echo "
"; + echo "
"; + echo "

Network Group

"; + echo "
"; + echo "Name
"; + echo "
"; + echo "
"; + echo "

Host Group

"; + echo "
"; + echo "Name
"; + echo "
"; + echo "
"; + echo "

Service Group

"; + echo "
"; + echo "Name
"; + echo "
"; + echo "
"; + } function CBFWRulesPage() @@ -221,6 +421,58 @@ function CBFWRulesPage() $config = $comms->getConfig(); } +function CBFWAdminPage($urls) +{ + $comms = new Comms(); + + $config = $comms->getConfig(); + + CBFWpageBuilder(null, "CBFWAdminDisplay"); +} + +function CBFWAdminDisplay() +{ +?> +

Administration

+ + + + + +
+

Users

+ + + +
UsernameDescriptionEnabled?
AdminTwattleYes
+
+

Add User

+
+Username
+Password
+Description
+
+
+
+

Network Access

+ + + +
FromInterfaceType
Anytwaddlehttp,https,ssh
+
+

Add Access

+
+From either "any", an address (1.2.3.4) or a network (1.2.3.4/23)
+Interface +Protocols HTTP HTTPS SSH
+
+
+
+