various stuff
authorpaulr <me@pjr.cc>
Sat, 11 Sep 2010 18:21:48 +0000 (04:21 +1000)
committerpaulr <me@pjr.cc>
Sat, 11 Sep 2010 18:21:48 +0000 (04:21 +1000)
lib/db.php
lib/ip.php
lib/www.php
www/index.php

index afa6679..77a9068 100644 (file)
@@ -10,10 +10,10 @@ class db {
                $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);';
+               $sql = 'CREATE TABLE subnet ("sn_id" INTEGER PRIMARY KEY AUTOINCREMENT,"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);';
+               $sql = 'CREATE TABLE supernet ("sn_id" INTEGER PRIMARY KEY AUTOINCREMENT,"sn_name" TEXT,"sn_ip" TEXT,"sn_mask" TEXT,"sn_desc" TEXT);';
                $this->dbobject->query($sql);
        }
        
index 95d71b0..a1c6a8a 100644 (file)
@@ -80,9 +80,7 @@ class ip {
                                                        error_log("no 3");
                                                        return false;
                                                }
-                                               $slt .= $pss[$i].":";
                                        }
-                                       $slt .= ":0";
                                        
                                        // we are still a valid ipv6 ip address/mask
                                        error_log("Valid");
index 1b8085d..79409a8 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 // The www class file.
 $actionRegister["addsuper"] = "www_ip_addSuperRange";
+$actionRegister["allocate"] = "www_ip_allocateSubRange";
 
 class www {
        function Go() {
@@ -69,8 +70,8 @@ Description <input type="text" name="desc"></input>
                //      print_r($row);
                //      echo "</pre><hr>";
                        echo "<table border=\"1\"><tr><th>".$row["sn_name"]."</th><td>".$row["sn_ip"]."/".$row["sn_mask"]."</td><td>".$row["sn_desc"]."</td>";
-                       echo "<td><a href=\"?action=allocate\">Allocate Subnet</a></td>";
-                       echo "<td><a href=\"?action=delete\">Delete Supernet</a></td>";
+                       echo "<td><a href=\"?action=allocate&id=".$row["sn_id"]."\">Allocate Subnet</a></td>";
+                       echo "<td><a href=\"?action=delete&id=".$row["sn_id"]."\">Delete Supernet</a></td>";
                        // now we search for sub's
                        echo "</table><br>";
                }
@@ -130,7 +131,35 @@ function www_ip_addSuperRange()
        } else {
                header("Location: index.php?error=invalid ipaddress");
        }
+}
+
+function www_ip_allocateSubRange()
+{
+       global $db, $wwwConnector;
+
+       $id = $_REQUEST["id"];
+       
+       $res = $db->dbobject->query("select * from supernet where sn_id=='$id'");
+       
+       foreach($res as $row) {
+               $sn = $row["sn_ip"];
+       }
+       $wwwConnector->header();
+       $wwwConnector->printError();
+       ?>
+sql is <?php echo "select * from supernet where sn_id=='$id" ?><br>
+<form method="post" action="?action=allocatesub&id=<?php echo $id ?>">
+<table>
+<tr><td>Subnet Name</td><td><input type="text" name="subname"></td></tr>
+<tr><td>Subnet IP</td><td><input type="text" name="subip" value="<?php echo $sn?>"></td></tr>
+<tr><td>Subnet Mask</td><td><input type="text" name="subip"></td></tr>
+<tr><td>Description</td><td><input type="text" name="subdesc"></td></tr>
+<tr><td><input type="submit" name="add" value="Add"></td></tr>
+</table>
+</form>
+<?php
 
+       $wwwConnector->footer();
 }
 
 ?>
\ No newline at end of file
index 353a053..a477d79 100644 (file)
@@ -3,6 +3,7 @@
 require_once "../lib/lib.php";
 
 $wwwConnector = new www();
+global $wwwConnector;
 $wwwConnector->Go();
 
 ?>