Lots of changes
authorpaulr <me@pjr.cc>
Fri, 10 Sep 2010 03:28:20 +0000 (13:28 +1000)
committerpaulr <me@pjr.cc>
Fri, 10 Sep 2010 03:28:20 +0000 (13:28 +1000)
db/db.sqlite [new file with mode: 0644]
db/schema.sql [new file with mode: 0644]
lib/auth.php [new file with mode: 0644]
lib/config.php [new file with mode: 0644]
lib/db.php [new file with mode: 0644]
lib/ip.php [new file with mode: 0644]
lib/lib.php
lib/www.php [new file with mode: 0644]
www/index.php

diff --git a/db/db.sqlite b/db/db.sqlite
new file mode 100644 (file)
index 0000000..e3f5ace
Binary files /dev/null and b/db/db.sqlite differ
diff --git a/db/schema.sql b/db/schema.sql
new file mode 100644 (file)
index 0000000..b7db164
--- /dev/null
@@ -0,0 +1,21 @@
+CREATE TABLE sqlite_sequence(name,seq);
+CREATE TABLE "hosts" (
+    "ho_id" INTEGER PRIMARY KEY AUTOINCREMENT,
+    "ho_sn_id" INTEGER,
+    "ho_ip" TEXT,
+    "ho_name" TEXT,
+    "ho_desc" TEXT
+);
+CREATE TABLE subnet (
+    "sn_id" INTEGER,
+    "snid_id" INTEGER,
+    "sn_ip" TEXT,
+    "sn_mask" TEXT,
+    "sn_name" TEXT
+, "sn_desc" TEXT);
+CREATE TABLE supernet (
+    "sn_id" INTEGER,
+    "sn_name" TEXT,
+    "sn_ip" TEXT,
+    "sn_mask" TEXT
+, "sn_desc" TEXT);
diff --git a/lib/auth.php b/lib/auth.php
new file mode 100644 (file)
index 0000000..6220a79
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+class auth {
+       function Go()
+       {
+               // there is no spoon
+               return true;
+       }       
+}
+
+?>
\ No newline at end of file
diff --git a/lib/config.php b/lib/config.php
new file mode 100644 (file)
index 0000000..b12b2b5
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+// this is the only configurable
+
+$DB_URI = "sqlite:/tmp/db.db";
+
+
+global $DB_URI;
+
+?>
\ No newline at end of file
diff --git a/lib/db.php b/lib/db.php
new file mode 100644 (file)
index 0000000..afa6679
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+// i really dont know why i do another obfuscation layer for db's with adodb.
+class db {
+       function init() {
+
+               $sql = 'CREATE TABLE sqlite_sequence(name,seq);';
+               $this->dbobject->query($sql);
+               
+               $sql = 'CREATE TABLE "hosts" ("ho_id" INTEGER PRIMARY KEY AUTOINCREMENT,"ho_sn_id" INTEGER,"ho_ip" TEXT,"ho_name" TEXT,"ho_desc" TEXT);';
+               $this->dbobject->query($sql);
+               
+               $sql = 'CREATE TABLE subnet ("sn_id" INTEGER,"snid_id" INTEGER,"sn_ip" TEXT,"sn_mask" TEXT,"sn_name" TEXT, "sn_desc" TEXT);';
+               $this->dbobject->query($sql);
+               
+               $sql = 'CREATE TABLE supernet ("sn_id" INTEGER,"sn_name" TEXT,"sn_ip" TEXT,"sn_mask" TEXT,"sn_desc" TEXT);';
+               $this->dbobject->query($sql);
+       }
+       
+       function connect() {
+               global $DB_URI;
+               
+               try {
+                       $this->dbobject = new PDO("$DB_URI");
+                       error_log("channy is a poof");
+               } catch(PDOException $exep) {
+                       error_log("execpt on db open");
+               }
+               
+               if(!$this->dbobject->query("select * from hosts")) {
+                       error_log("db open for init");
+                       $this->init();
+               }
+       }
+
+       public $dbobject = "";
+}
+
+
+
+$db = new db();
+global $db;
+
+?>
\ No newline at end of file
diff --git a/lib/ip.php b/lib/ip.php
new file mode 100644 (file)
index 0000000..e07eb30
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+class ip {
+       function addSupernet($supernet)
+       {
+               
+       }
+       
+       function addSubnet($subnet)
+       {
+               
+       }
+       
+       function isConflicting($subnet)
+       {
+               
+       }
+       
+       public $supers = "";
+       public $subs = "";
+}
+?>
\ No newline at end of file
index b3d9bbc..5190d28 100644 (file)
@@ -1 +1,11 @@
 <?php
+
+global $actionRegister;
+
+require_once "config.php";
+require_once "www.php";
+require_once "db.php";
+require_once "auth.php";
+require_once "ip.php";
+
+?>
\ No newline at end of file
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
index f8a86e6..353a053 100644 (file)
@@ -1,7 +1,8 @@
 <?php
 
-require_once "../lib.php";
+require_once "../lib/lib.php";
 
-wwwConnector->Go();
+$wwwConnector = new www();
+$wwwConnector->Go();
 
 ?>