--- /dev/null
+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);
--- /dev/null
+<?php
+
+class auth {
+ function Go()
+ {
+ // there is no spoon
+ return true;
+ }
+}
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+
+// this is the only configurable
+
+$DB_URI = "sqlite:/tmp/db.db";
+
+
+global $DB_URI;
+
+?>
\ No newline at end of file
--- /dev/null
+<?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
--- /dev/null
+<?php
+
+class ip {
+ function addSupernet($supernet)
+ {
+
+ }
+
+ function addSubnet($subnet)
+ {
+
+ }
+
+ function isConflicting($subnet)
+ {
+
+ }
+
+ public $supers = "";
+ public $subs = "";
+}
+?>
\ No newline at end of file
<?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
--- /dev/null
+<?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
<?php
-require_once "../lib.php";
+require_once "../lib/lib.php";
-wwwConnector->Go();
+$wwwConnector = new www();
+$wwwConnector->Go();
?>