c45de8ae91c027fd75473afa7f2656d4f204535e
[PHPIPManager.git] / lib / www.php
1 <?php
2 // The www class file.
3 $actionRegister["addsuper"] = "www_ip_addSuperRange";
4
5 class www {
6         function Go() {
7                 // this is the web page entry function.
8                 global $db;
9                 
10                 $db->connect();
11                 //if($db->connect()!=0) {
12                         //$this->doInstaller();
13                         //exit(0);
14                 //}
15                 
16                 // its up to auth as to wether "this" url requires auth.
17                 $authThis = new auth();
18                 $authThis->Go();
19                 
20                 if(isset($_REQUEST["action"])) {
21                         $this->doAction($_REQUEST["action"]);
22                 } else {
23                         $this->mainAction();
24                 }
25         }
26         
27         function doAction($actionName)
28         {
29                 global $actionRegister;
30                 
31                 error_log("im here");
32                 if(isset($actionRegister[$actionName])) {
33                         $func = $actionRegister[$actionName];
34                         error_log("im here 2");
35                         $func();
36                 } else {
37                         error_log("im here 3");
38                         $this->mainAction();
39                 }
40         }
41         
42         function mainAction()
43         {
44                 // we build a frame of framey's
45                 $this->header();
46                 $this->mainPage();              
47                 $this->footer();
48         }
49         
50         function mainPage()
51         {
52                 global $db;
53                 
54                 echo "<h1>Welcome to PHPIPManager</h1>";
55                 ?>
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>
62 </form>
63                 <?php 
64         }
65         
66         function header()
67         {
68                 ?>
69 <html>
70 <head>
71 </head>
72 <body>
73                 <?php
74         }
75         
76         function footer()
77         {
78                 ?>
79 </body></html>
80                 <?php
81         }
82         
83         
84         function doInstaller()
85         {
86                 header("Location: install.php");
87         }
88 }
89
90 function www_ip_addSuperRange()
91 {
92         global $db;
93         
94         $name = $_REQUEST["name"];
95         $sn = $_REQUEST["subnet"];
96         $mask = $_REQUEST["mask"];
97         $desc = $_REQUEST["desc"];
98         
99         $sql = "insert into supernet values (NULL, '$name', '$sn', '$mask', '$desc')";
100         $db->dbobject->query($sql);
101
102         header("Location: index.php");
103 }
104
105 ?>