From: paulr Date: Sun, 2 Oct 2011 16:59:00 +0000 (+1100) Subject: making config changes all happen in "addConfigLine" X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=86842492eae6203c9df0df46363b4e809d577c70;p=CBFWR.git making config changes all happen in "addConfigLine" --- diff --git a/libcbfwr/config.php b/libcbfwr/config.php index 372bd04..f2aaa52 100644 --- a/libcbfwr/config.php +++ b/libcbfwr/config.php @@ -76,6 +76,10 @@ class Config { return $this->config; } + function setConfig($config) { + $this->config = $config; + } + function applyConfig() { global $AM_DAEMON; @@ -85,87 +89,7 @@ class Config { return true; } - function mergeConfig($configone, $configtwo) - { - // yep this means apply changes in configtwo to configone - $newconf = $configone; - - // this is gunna be tough its gunna be a meet on meet sandwitch - foreach($configtwo as $key => $var) { - if($key != "status") { - error_log("apply change $key"); - foreach($var as $key2=>$var2) { - error_log("which is $key2"); - $splits = explode(" ", $var2); - - // find a description - $description = null; - $hasdescription = false; - for($i=0; $iparseLine($line, $i++); + if($line != "") $this->addConfigLine($line, $i++); } } - function parseLine($line, $lineno) + function addConfigLine($line, $lineno=0) { $expl = preg_split("/ +/", $line); @@ -217,22 +141,51 @@ class Config { $expl = $expl_r; } + $delete = false; + // check for delete on the line + if($expl[0] == "delete") { + $delete = true; + + // re-order the array + for($i=0; $i < (count($expl)-1); $i++) { + $expl[$i] = $expl[$i+1]; + } + unset($expl[count($expl)-1]); + } + switch($expl[0]) { case "hostname": // set the hostname to $1 - $this->config["hostname"] = $expl[1]; + if($delete) { + unset($this->config["hostname"]); + } else { + $this->config["hostname"] = $expl[1]; + } break; case "domainname": // set the hostname to $1 - $this->config["domainname"] = $expl[1]; + if($delete) { + unset($this->config["domainname"]); + } else { + $this->config["domainname"] = $expl[1]; + } break; case "zone": - if($hasdescription) { - $this->config["zone"][$expl[2]]["description"] = $description; + if($delete) { + error_log("delete zone ".$expl[2]); + unset($this->config["zone"][$expl[2]]); + if(count($this->config["zone"]) < 1) { + error_log("zone now empty, delete zones"); + unset($this->config["zone"]); + } + } else { + if($hasdescription) { + $this->config["zone"][$expl[2]]["description"] = $description; + } + $this->config["zone"][$expl[2]]["name"] = true; } - $this->config["zone"][$expl[2]]["name"] = true; break; case "interface": @@ -308,54 +261,65 @@ class Config { case "login": - $this->config["login"][$expl[1]] = $expl[3]; - if($hasdescription) { - $this->config["login"][$expl[1]]["description"] = $description; + if($delete) { + unset($this->config["login"][$expl[1]]); + } else { + $this->config["login"][$expl[1]] = $expl[3]; + if($hasdescription) { + $this->config["login"][$expl[1]]["description"] = $description; + } } break; case "route4": - $route = $expl[1]; - $via = $expl[2]; - $dest = $expl[3]; - if($via == "to") { - $this->config["route4"][$route]["address"] = $dest; + if($delete) { + unset($this->config["route4"][$expl[1]]); } else { - $this->config["route4"][$route]["device"] = $dest; - } - if(isset($expl[4])) { - if($expl[4] == "dev") { - if(isset($expl[5])) { - $this->config["route4"][$route]["device"] = $expl[5]; + $route = $expl[1]; + $via = $expl[2]; + $dest = $expl[3]; + if($via == "to") { + $this->config["route4"][$route]["address"] = $dest; + } else { + $this->config["route4"][$route]["device"] = $dest; + } + if(isset($expl[4])) { + if($expl[4] == "dev") { + if(isset($expl[5])) { + $this->config["route4"][$route]["device"] = $expl[5]; + } } } - } - if($hasdescription) { - $this->config["route4"][$route]["description"] = $description; + if($hasdescription) { + $this->config["route4"][$route]["description"] = $description; + } } break; case "route6": - $route = $expl[1]; - $via = $expl[2]; - $dest = $expl[3]; - if($via == "to") { - $this->config["route6"][$route]["address"] = $dest; + if($delete) { + unset($this->config["route6"][$expl[1]]); } else { - $this->config["route6"][$route]["device"] = $dest; - } - if(isset($expl[4])) { - if($expl[4] == "dev") { - if(isset($expl[5])) { - $this->config["route6"][$route]["device"] = $expl[5]; + $route = $expl[1]; + $via = $expl[2]; + $dest = $expl[3]; + if($via == "to") { + $this->config["route6"][$route]["address"] = $dest; + } else { + $this->config["route6"][$route]["device"] = $dest; + } + if(isset($expl[4])) { + if($expl[4] == "dev") { + if(isset($expl[5])) { + $this->config["route6"][$route]["device"] = $expl[5]; + } } } + if($hasdescription) { + $this->config["route6"][$route]["description"] = $description; + } } - if($hasdescription) { - $this->config["route6"][$route]["description"] = $description; - } - // here we should check "$route" break; diff --git a/libcbfwr/fwui.php b/libcbfwr/fwui.php index 4bcfed5..e827c2c 100644 --- a/libcbfwr/fwui.php +++ b/libcbfwr/fwui.php @@ -334,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() @@ -348,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
+
+
+
+"; @@ -177,11 +172,11 @@ function CBFWpageBuilder($bodyClass, $bodyFunction, $bodycontent=null, $title="C // page top echo "

CBFW


"; - echo "
"; + echo "
"; CBFWMessageBuilder(); - echo ""; + echo ""; CBFWConfigStatus(); - echo "
"; + echo "
"; // menu, then body echo "
"; diff --git a/www/css/normal.css b/www/css/normal.css index bf63908..7c79ef7 100644 --- a/www/css/normal.css +++ b/www/css/normal.css @@ -128,11 +128,6 @@ div.wrapper { background-color:#dadaf8; } -input[type=text] { - width: 200px; - -} - input.storage { width: 400px; } \ No newline at end of file