3 $actionRegister["addsuper"] = "www_ip_addSuperRange";
7 // this is the web page entry function.
11 //if($db->connect()!=0) {
12 //$this->doInstaller();
16 // its up to auth as to wether "this" url requires auth.
17 $authThis = new auth();
20 if(isset($_REQUEST["action"])) {
21 $this->doAction($_REQUEST["action"]);
27 function doAction($actionName)
29 global $actionRegister;
32 if(isset($actionRegister[$actionName])) {
33 $func = $actionRegister[$actionName];
34 error_log("im here 2");
37 error_log("im here 3");
44 // we build a frame of framey's
56 <form method="post" action="?action=addsuper">
57 Create Supernet: name <input type="text" name="name"></input>
58 Subnet Address <input type="text" name="subnet"></input>
59 Mask <input type="text" name="mask"></input>
60 Description <input type="text" name="desc"></input>
61 <input type="submit" name="go" Value="Create"></input>
65 // now print the super nets
66 $res = $db->dbobject->query("select * from supernet");
67 foreach($res as $row) {
71 echo "<table border=\"1\"><tr><th>".$row["sn_name"]."</th><td>".$row["sn_ip"]."/".$row["sn_mask"]."</td><td>".$row["sn_desc"]."</td>";
72 echo "<td><a href=\"?action=allocate\">Allocate Subnet</a></td>";
73 echo "<td><a href=\"?action=delete\">Delete Supernet</a></td>";
74 // now we search for sub's
81 if(isset($_REQUEST["error"]))
83 echo "<font color=\"red\">".$_REQUEST["error"]."</font>";
85 if(isset($_REQUEST["notice"]))
87 echo "<font color=\"green\">".$_REQUEST["notice"]."</font>";
92 function header($title = "Welcome to PHP IP Manager")
96 <head><title><?php echo $title ?></title>
98 <body><h1><?php echo $title ?></h1>
110 function doInstaller()
112 header("Location: install.php");
116 function www_ip_addSuperRange()
120 $name = $_REQUEST["name"];
121 $sn = $_REQUEST["subnet"];
122 $mask = $_REQUEST["mask"];
123 $desc = $_REQUEST["desc"];
125 if(ip::isValid($sn, $mask)) {
126 $sn = ip::truncateNetwork($sn, $mask);
127 $sql = "insert into supernet values (NULL, '$name', '$sn', '$mask', '$desc')";
128 $db->dbobject->query($sql);
129 header("Location: index.php?notice=range added");
131 header("Location: index.php?error=invalid ipaddress");