From 13e5ebe14a18fb0d217fdc6fc4fc786a678889da Mon Sep 17 00:00:00 2001 From: paulr Date: Wed, 5 Oct 2011 03:51:25 +1100 Subject: [PATCH] working on the interfaces page --- libcbfwr/fwui.php | 75 +++++++++++++++++++++++++++++++++++++++++++++++----- libcbfwr/web.php | 9 ++++++ 2 files changed, 76 insertions(+), 8 deletions(-) diff --git a/libcbfwr/fwui.php b/libcbfwr/fwui.php index bb2fc8e..adc9541 100644 --- a/libcbfwr/fwui.php +++ b/libcbfwr/fwui.php @@ -192,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])) { @@ -216,7 +241,6 @@ function CBFWInterfacesChange() global $BASE_URL, $MENU_ITEMS; $comms = new Comms(); - $comms->sendMessage("interface eth0 changename poof"); header("Location: $BASE_URL/interfaces"); } @@ -225,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 "
"; echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo "
Name
HW Address
Zone
IPv4 Address
IPv6 Address
Speed
Duplex
Name
HW Address$extra
Zone
IPv4 Address
IPv6 Address
Speed
Duplex
"; echo "
"; //echo "Back"; diff --git a/libcbfwr/web.php b/libcbfwr/web.php index 6977dc6..6f97675 100644 --- a/libcbfwr/web.php +++ b/libcbfwr/web.php @@ -5,6 +5,8 @@ $MENU_ITEMS["20_Objects"]["link"] = "$BASE_URL/objects"; $MENU_ITEMS["20_Objects"]["name"] = "Objects"; $MENU_ITEMS["30_Rules"]["link"] = "$BASE_URL/rules"; $MENU_ITEMS["30_Rules"]["name"] = "Rules"; +$MENU_ITEMS["15_Routes"]["link"] = "$BASE_URL/routing"; +$MENU_ITEMS["15_Routes"]["name"] = "Routing"; $MENU_ITEMS["10_Interfaces"]["link"] = "$BASE_URL/interfaces"; $MENU_ITEMS["10_Interfaces"]["name"] = "Interfaces"; $MENU_ITEMS["05_Admin"]["link"] = "$BASE_URL/admin"; @@ -57,6 +59,9 @@ class CBFWWeb { case "objects": CBFWObjectsPage($url_s); break; + case "routing": + CBFWRoutingPage($url_s); + break; case "rules": $bodyFunction = "CBFWRulesPage"; break; @@ -92,6 +97,10 @@ function CBFBuildHomePage($urls) print_r($comms->getConfig(2)); echo "\n\n\n"; print_r($comms->getConfig(3)); + echo "\n\n\n"; + print_r($comms->getConfig(4)); + echo "\n\n\n"; + print_r($comms->getConfig(5)); echo ""; } -- 1.7.0.4