--- /dev/null
+<?php
+
+// some global menu stuff
+$MENUS["home"]["url"] = "?action=home";
+$MENUS["home"]["name"] = "Home";
+$MENUS["hosts"]["url"] = "?action=hosts";
+$MENUS["hosts"]["name"] = "Hosts";
+$MENUS["add"]["url"] = "?action=addhost";
+$MENUS["add"]["name"] = "Add Host";
+$MENUS["config"]["url"] = "?action=config";
+$MENUS["config"]["name"] = "Configure";
+
+$FUNCTIONS["config"] = "www_configure";
+$FUNCTIONS["addhost"] = "www_addhost";
+$FUNCTIONS["addhostnext"] = "www_addHostStageTwo";
+$FUNCTIONS["addhostthree"] = "www_addHostStageThree";
+
+
+function www_header()
+{
+ ?>
+<html>
+<title>Network Config Manager</title>
+<body>
+ <?php
+}
+
+function www_pageLayout()
+{
+ ?>
+<table>
+<tr><td colspan="2"><h1>Network Config Manager</h1></td></tr>
+<tr valign="top"><td><?php www_menu() ?></td><td><?php www_body() ?></td></tr>
+</table>
+
+ <?php
+}
+
+function www_footer()
+{
+ ?>
+<br><font size="-1"><i>Copyright 2003-2011, Paul J Robinson</i></font><br>
+</body>
+</html>
+ <?php
+}
+
+function www_menu()
+{
+ global $MENUS;
+ foreach($MENUS as $menuitems) {
+ $url = $menuitems["url"];
+ $name = $menuitems["name"];
+ echo "<a href=\"$url\">$name</a><br>";
+ }
+}
+
+function www_body()
+{
+ global $FUNCTIONS;
+
+ $called = false;
+ if(isset($_REQUEST["action"])) {
+ $req = $_REQUEST["action"];
+ if(isset($FUNCTIONS["$req"])) {
+ $func = $FUNCTIONS["$req"];
+ if(function_exists($func)) {
+ $func();
+ return true;
+ }
+ }
+ }
+
+ $db = db_getDB();
+
+ // here we do the normal body, whatever that
+ // we'll list the hosts, the size of the current config and
+ // the last time it was updated, plus the number of versions
+
+}
+
+function www_hostTypesDropDown()
+{
+ global $HOST_TYPE;
+
+ foreach($HOST_TYPE as $tloop => $types) {
+ $typename = $types["name"];
+ $typever = $tloop;
+ echo "<option value=\"$typever\">$typename</option>";
+ }
+}
+
+function www_addhost()
+{
+ ?>
+<form method="post" action="?action=addhostnext">
+<table>
+<tr><td>Name</td><td><input type="text" name="cname"></td></tr>
+<tr><td>Hostname/IP Address</td><td><input type="text" name="hname"></td></tr>
+<tr><td>Host Type</td><td><select name="hosttype"><?php www_hostTypesDropDown() ?></select></td></tr>
+</table>
+<input type="submit" value="Next" name="Next">
+</form>
+ <?php
+}
+
+function www_addHostStageTwo()
+{
+ global $HOST_TYPE;
+ if(isset($_REQUEST["hosttype"])) {
+ $htype = $_REQUEST["hosttype"];
+ $func = $HOST_TYPE["$htype"]["configform"];
+ if(function_exists($func)) {
+ echo "<form method=\"post\" action=\"?action=addhostthree&hosttype=$htype\">";
+ $func();
+ echo "<input type=\"submit\" value=\"Add\" name=\"Add\">";
+ } else echo "would call $func for $htype but it doesnt exist\n";
+ }
+}
+
+function www_addHostStageThree()
+{
+ global $HOST_TYPE;
+ if(isset($_REQUEST["hosttype"])) {
+ $htype = $_REQUEST["htype"];
+ $func = $HOST_TYPE["$htype"]["postfunction"];
+ if(function_exists($func)) {
+ $func();
+ } else echo "would call $func for $htype but it doesnt exist\n";
+ }
+
+}
+?>
\ No newline at end of file