X-Git-Url: http://git.pjr.cc/?p=CBFWR.git;a=blobdiff_plain;f=libcbfwr%2Ffwui.php;h=e19e9a4b11597c8456ba91f9dd5a2c9399817d58;hp=a94b4ad1d6568403e4da3581d1b89e9c5f97b7f2;hb=cb45585d92144a65ff25bc1109cde4cbf60913de;hpb=9d42ecae8d0c5139e119af983a5fe65f4b0fe149
diff --git a/libcbfwr/fwui.php b/libcbfwr/fwui.php
index a94b4ad..e19e9a4 100644
--- a/libcbfwr/fwui.php
+++ b/libcbfwr/fwui.php
@@ -1,22 +1,339 @@
";
+ //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 "delete":
+ $zonetodelete = $urls[2];
+
+ addWebUserChange("delete zone name $zonetodelete");
+ header("Location: $BASE_URL/zones");
+ break;
+
+
+ case "add":
+
+ // UGLY
+ $nametoadd = $_REQUEST["toadd"];
+ $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");
+ }
+ } else {
+ CBFWpageBuilder(null, "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);
+
}
-function CBFWInterfacesPage()
+// 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 | Description | Edit |
";
+ foreach($config["zone"] as $key => $var) {
+ $name = $key;
+ $url = "Edit";
+ $url2 = "Delete";
+ $desc = $var["description"];
+ echo "$name | ... | $desc | $url $url2 |
";
+ }
+
+ echo "
";
+ echo "";
+
}
-function CBFWObjectsPage()
+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 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 "Networks | Hosts | Services | Network Groups | Host Groups | Service Groups |
";
+ echo "
";
+ foreach($config["objects"] as $key => $var) {
+ }
+ } else {
+ echo "No objects set\n";
+ }
+
+ echo "
";
+ echo "";
+ echo "";
+ echo "Create Network ";
+ echo "";
+ echo " | ";
+ echo "";
+ echo "Create Host ";
+ echo "";
+ echo " | ";
+ echo "";
+ echo "Service ";
+ echo "";
+ echo " | ";
+ echo "
";
+ echo "";
+ echo "Network Group";
+ echo "";
+ echo " | ";
+ echo "";
+ echo "Host Group";
+ echo "";
+ echo " | ";
+ echo "";
+ echo "Service Group";
+ echo "";
+ echo " | ";
+
+
+ echo "
";
+
+}
+
+function CBFWChangesPage($urls)
+{
+ global $BASE_URL, $MENU_ITEMS;
+
+ if(isset($urls[1])) {
+ switch($urls[1]) {
+ case "show":
+ CBFWpageBuilder(null, "CBFWChangesDisplay");
+ break;
+ case "delete":
+ $delete = $urls[2];
+ error_log("would delete change $delete");
+ header("Location: $BASE_URL/changes/show");
+ break;
+ }
+ }
+}
+
+function CBFWChangesDisplay()
+{
+ global $BASE_URL, $MENU_ITEMS;
+ $comms = new Comms();
+
+ $config = $comms->getConfig(3);
+
+ echo "Changes
";
+ echo "This page shows the changes on the web from the currently running configuration
";
+ if($config["status"] == "nochange") {
+ echo "There are currently no changes from the running configuraiton.";
+ } else {
+ echo "";
+ echo "Change No | Change | Control |
";
+ foreach($config["changes"] as $key => $var) {
+ echo "$key | $var | Delete |
";
+ }
+ echo "
";
+ }
}
function CBFWRulesPage()
@@ -26,6 +343,58 @@ function CBFWRulesPage()
$config = $comms->getConfig();
}
+function CBFWAdminPage($urls)
+{
+ $comms = new Comms();
+
+ $config = $comms->getConfig();
+
+ CBFWpageBuilder(null, "CBFWAdminDisplay");
+}
+
+function CBFWAdminDisplay()
+{
+?>
+Administration
+
+
+
+Users
+
+Username | Description | Enabled? |
+Admin | Twattle | Yes |
+
+
+Add User
+
+ |
+
+Network Access
+
+From | Interface | Type |
+Any | twaddle | http,https,ssh |
+
+
+Add Access
+
+ |
+
+
+