3 $actionRegister["addsuper"] = "www_ip_addSuperRange";
4 $actionRegister["allocate"] = "www_ip_allocateSubRange";
8 // this is the web page entry function.
12 //if($db->connect()!=0) {
13 //$this->doInstaller();
17 // its up to auth as to wether "this" url requires auth.
18 $authThis = new auth();
21 if(isset($_REQUEST["action"])) {
22 $this->doAction($_REQUEST["action"]);
28 function doAction($actionName)
30 global $actionRegister;
33 if(isset($actionRegister[$actionName])) {
34 $func = $actionRegister[$actionName];
35 error_log("im here 2");
38 error_log("im here 3");
45 // we build a frame of framey's
57 <form method="post" action="?action=addsuper">
58 Create Supernet: name <input type="text" name="name"></input>
59 Subnet Address <input type="text" name="subnet"></input>
60 Mask <input type="text" name="mask"></input>
61 Description <input type="text" name="desc"></input>
62 <input type="submit" name="go" Value="Create"></input>
66 // now print the super nets
67 $res = $db->dbobject->query("select * from supernet");
68 foreach($res as $row) {
72 echo "<table border=\"1\"><tr><th>".$row["sn_name"]."</th><td>".$row["sn_ip"]."/".$row["sn_mask"]."</td><td>".$row["sn_desc"]."</td>";
73 echo "<td><a href=\"?action=allocate&id=".$row["sn_id"]."\">Allocate Subnet</a></td>";
74 echo "<td><a href=\"?action=delete&id=".$row["sn_id"]."\">Delete Supernet</a></td>";
75 // now we search for sub's
82 if(isset($_REQUEST["error"]))
84 echo "<font color=\"red\">".$_REQUEST["error"]."</font>";
86 if(isset($_REQUEST["notice"]))
88 echo "<font color=\"green\">".$_REQUEST["notice"]."</font>";
93 function header($title = "Welcome to PHP IP Manager")
97 <head><title><?php echo $title ?></title>
99 <body><h1><?php echo $title ?></h1>
111 function doInstaller()
113 header("Location: install.php");
117 function www_ip_addSuperRange()
121 $name = $_REQUEST["name"];
122 $sn = $_REQUEST["subnet"];
123 $mask = $_REQUEST["mask"];
124 $desc = $_REQUEST["desc"];
126 if(ip::isValid($sn, $mask)) {
127 $sn = ip::truncateNetwork($sn, $mask);
128 $sql = "insert into supernet values (NULL, '$name', '$sn', '$mask', '$desc')";
129 $db->dbobject->query($sql);
130 header("Location: index.php?notice=range added");
132 header("Location: index.php?error=invalid ipaddress");
136 function www_ip_allocateSubRange()
138 global $db, $wwwConnector;
140 $id = $_REQUEST["id"];
142 $res = $db->dbobject->query("select * from supernet where sn_id=='$id'");
144 foreach($res as $row) {
147 $wwwConnector->header();
148 $wwwConnector->printError();
150 sql is <?php echo "select * from supernet where sn_id=='$id" ?><br>
151 <form method="post" action="?action=allocatesub&id=<?php echo $id ?>">
153 <tr><td>Subnet Name</td><td><input type="text" name="subname"></td></tr>
154 <tr><td>Subnet IP</td><td><input type="text" name="subip" value="<?php echo $sn?>"></td></tr>
155 <tr><td>Subnet Mask</td><td><input type="text" name="subip"></td></tr>
156 <tr><td>Description</td><td><input type="text" name="subdesc"></td></tr>
157 <tr><td><input type="submit" name="add" value="Add"></td></tr>
162 $wwwConnector->footer();