Lots of changes
[PHPIPManager.git] / lib / www.php
diff --git a/lib/www.php b/lib/www.php
new file mode 100644 (file)
index 0000000..c45de8a
--- /dev/null
@@ -0,0 +1,105 @@
+<?php
+// The www class file.
+$actionRegister["addsuper"] = "www_ip_addSuperRange";
+
+class www {
+       function Go() {
+               // this is the web page entry function.
+               global $db;
+               
+               $db->connect();
+               //if($db->connect()!=0) {
+                       //$this->doInstaller();
+                       //exit(0);
+               //}
+               
+               // its up to auth as to wether "this" url requires auth.
+               $authThis = new auth();
+               $authThis->Go();
+               
+               if(isset($_REQUEST["action"])) {
+                       $this->doAction($_REQUEST["action"]);
+               } else {
+                       $this->mainAction();
+               }
+       }
+       
+       function doAction($actionName)
+       {
+               global $actionRegister;
+               
+               error_log("im here");
+               if(isset($actionRegister[$actionName])) {
+                       $func = $actionRegister[$actionName];
+                       error_log("im here 2");
+                       $func();
+               } else {
+                       error_log("im here 3");
+                       $this->mainAction();
+               }
+       }
+       
+       function mainAction()
+       {
+               // we build a frame of framey's
+               $this->header();
+               $this->mainPage();              
+               $this->footer();
+       }
+       
+       function mainPage()
+       {
+               global $db;
+               
+               echo "<h1>Welcome to PHPIPManager</h1>";
+               ?>
+<form method="post" action="?action=addsuper">
+Create Supernet: name <input type="text" name="name"></input>
+Subnet Address <input type="text" name="subnet"></input>
+Mask <input type="text" name="mask"></input>
+Description <input type="text" name="desc"></input>
+<input type="submit" name="go" Value="Create"></input>
+</form>
+               <?php 
+       }
+       
+       function header()
+       {
+               ?>
+<html>
+<head>
+</head>
+<body>
+               <?php
+       }
+       
+       function footer()
+       {
+               ?>
+</body></html>
+               <?php
+       }
+       
+       
+       function doInstaller()
+       {
+               header("Location: install.php");
+       }
+}
+
+function www_ip_addSuperRange()
+{
+       global $db;
+       
+       $name = $_REQUEST["name"];
+       $sn = $_REQUEST["subnet"];
+       $mask = $_REQUEST["mask"];
+       $desc = $_REQUEST["desc"];
+       
+       $sql = "insert into supernet values (NULL, '$name', '$sn', '$mask', '$desc')";
+       $db->dbobject->query($sql);
+
+       header("Location: index.php");
+}
+
+?>
\ No newline at end of file