3 $actionRegister["addsuper"] = "www_ip_addSuperRange";
4 $actionRegister["allocate"] = "www_ip_allocateRange";
5 $actionRegister["allocatesub"] = "www_ip_allocateSubRange";
6 $actionRegister["dumpdb"] = "www_db_dumpdb";
7 $actionRegister["restoredb"] = "www_db_restoredb";
11 // this is the web page entry function.
15 //if($db->connect()!=0) {
16 //$this->doInstaller();
20 // its up to auth as to wether "this" url requires auth.
21 $authThis = new auth();
24 if(isset($_REQUEST["action"])) {
25 $this->doAction($_REQUEST["action"]);
31 function doAction($actionName)
33 global $actionRegister;
36 if(isset($actionRegister[$actionName])) {
37 $func = $actionRegister[$actionName];
38 error_log("im here 2");
41 error_log("im here 3");
48 // we build a frame of framey's
60 <form method="post" action="?action=addsuper">
61 Create Supernet: name <input type="text" name="name"></input>
62 Subnet Address <input type="text" name="subnet"></input>
63 Mask <input type="text" name="mask"></input>
64 Description <input type="text" name="desc"></input>
65 <input type="submit" name="go" Value="Create"></input>
69 // now print the super nets
70 $res = $db->dbobject->query("select * from supernet");
71 foreach($res as $row) {
75 echo "<table border=\"1\"><tr><th>".$row["sn_name"]."</th><td>".$row["sn_ip"]."/".$row["sn_mask"]."</td><td>".$row["sn_desc"]."</td>";
76 echo "<td><a href=\"?action=allocate&id=".$row["sn_id"]."\">Allocate Subnet</a></td>";
77 echo "<td><a href=\"?action=delete&id=".$row["sn_id"]."\">Delete Supernet</a></td>";
78 // now we search for sub's
82 echo "<a href=\"?action=dumpdb\">dump database</a> <a href=\"?action=restoredb\">restore database</a>";
87 if(isset($_REQUEST["error"]))
89 echo "<font color=\"red\">".$_REQUEST["error"]."</font>";
91 if(isset($_REQUEST["notice"]))
93 echo "<font color=\"green\">".$_REQUEST["notice"]."</font>";
98 function header($title = "Welcome to PHP IP Manager")
102 <head><title><?php echo $title ?></title>
104 <body><h1><?php echo $title ?></h1>
116 function doInstaller()
118 header("Location: install.php");
122 function www_ip_addSuperRange()
126 $name = $_REQUEST["name"];
127 $sn = $_REQUEST["subnet"];
128 $mask = $_REQUEST["mask"];
129 $desc = $_REQUEST["desc"];
133 if($myip->addSupernet($name, $sn, $mask, $desc)) {
134 header("Location: index.php?notice=range added");
136 header("Location: index.php?error=invalid ipaddress");
140 function www_ip_allocateRange()
142 global $db, $wwwConnector;
144 $id = $_REQUEST["id"];
146 $res = $db->dbobject->query("select * from supernet where sn_id=='$id'");
148 foreach($res as $row) {
151 $wwwConnector->header();
152 $wwwConnector->printError();
154 <form method="post" action="?action=allocatesub&id=<?php echo $id ?>">
155 <input type="hidden" name="superid" value="<?php echo $id ?>">
157 <tr><td>Subnet Name</td><td><input type="text" name="subname"></td></tr>
158 <tr><td>Subnet IP</td><td><input type="text" name="subip" value="<?php echo $sn?>"></td></tr>
159 <tr><td>Subnet Mask</td><td><input type="text" name="submask"></td></tr>
160 <tr><td>Description</td><td><input type="text" name="subdesc"></td></tr>
161 <tr><td><input type="submit" name="add" value="Add"></td></tr>
166 $wwwConnector->footer();
169 function www_ip_allocateSubRange()
171 global $db, $wwwConnector;
173 $superid = $_REQUEST["superid"];
174 $name = $_REQUEST["subname"];
175 $subip = $_REQUEST["subip"];
176 $mask = $_REQUEST["submask"];
177 $desc = $_REQUEST["subdesc"];
180 if($myip->addSubnet($name, $subip, $mask, $desc, $superid)) {
181 header("Location: index.php?notice=range added");
183 header("Location: index.php?error=invalid ipaddress");
187 function www_db_dumpdb()
191 function www_db_restoredb()