r2021 + fix IPv4 address bypass arg handling
[racktables] / index.php
1 <?php
2
3 require 'inc/init.php';
4 // no ctx override is necessary
5 fixContext();
6 if (!permitted())
7 {
8 renderAccessDenied();
9 die;
10 }
11
12 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
13 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'."\n";
14 echo '<head><title>' . getTitle ($pageno, $tabno) . "</title>\n";
15 echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
16 echo "<link rel=stylesheet type='text/css' href=pi.css />\n";
17 echo "<link rel=icon href='" . getFaviconURL() . "' type='image/x-icon' />";
18 echo "<style type='text/css'>\n";
19 // Print style information
20 foreach (array ('F', 'A', 'U', 'T', 'Th', 'Tw', 'Thw') as $statecode)
21 {
22 echo "td.state_${statecode} {\n";
23 echo "\ttext-align: center;\n";
24 echo "\tbackground-color: #" . (getConfigVar ('color_' . $statecode)) . ";\n";
25 echo "\tfont: bold 10px Verdana, sans-serif;\n";
26 echo "}\n\n";
27 }
28 ?>
29 .validation-error {
30 border:1px solid red;
31 }
32
33 .validation-success {
34 border:1px solid green;
35 }
36 </style>
37 <script language='javascript' type='text/javascript' src='js/live_validation.js'></script>
38 <script type="text/javascript">
39 function init() {
40 document.add_new_range.range.setAttribute('match', "^\\d\\d?\\d?\\.\\d\\d?\\d?\\.\\d\\d?\\d?\\.\\d\\d?\\d?\\/\\d\\d?$");
41
42 Validate.init();
43 }
44 window.onload=init;
45 </script>
46 </head>
47 <body>
48 <table border=0 cellpadding=0 cellspacing=0 width='100%' height='100%' class=maintable>
49 <tr class=mainheader>
50 <td colspan=2>
51 <table width='100%' cellspacing=0 cellpadding=2 border=0>
52 <tr>
53 <td valign=top><a href='http://racktables.org/'><?php printImageHREF ('logo'); ?></a></td>
54 <td valign=top><div class=greeting><?php printGreeting(); ?></div></td>
55 </tr>
56 </table>
57 </td>
58 </tr>
59
60 <tr>
61 <td class="menubar" colspan=2>
62 <table border="0" width="100%" cellpadding="3" cellspacing="0">
63 <tr>
64 <?php showPathAndSearch ($pageno); ?>
65 </tr>
66 </table>
67 </td>
68 </tr>
69
70 <tr>
71 <?php
72 showTabs ($pageno, $tabno);
73 ?>
74 </tr>
75
76 <tr>
77 <td colspan=2>
78 <?php
79 if (isset ($tabhandler[$pageno][$tabno]))
80 {
81 if (isset ($page[$pageno]['bypass']) && isset ($page[$pageno]['bypass_type']))
82 {
83 switch ($page[$pageno]['bypass_type'])
84 {
85 case 'uint':
86 assertUIntArg ($page[$pageno]['bypass'], 'index');
87 break;
88 case 'uint0':
89 assertUIntArg ($page[$pageno]['bypass'], 'index', TRUE);
90 break;
91 case 'inet4':
92 assertIPv4Arg ($page[$pageno]['bypass'], 'index');
93 break;
94 default:
95 showError ("Dispatching error for bypass parameter");
96 break;
97 }
98 $tabhandler[$pageno][$tabno] ($_REQUEST[$page[$pageno]['bypass']]);
99 }
100 else
101 $tabhandler[$pageno][$tabno] ();
102 }
103 elseif (isset ($page[$pageno]['handler']))
104 $page[$pageno]['handler'] ($tabno);
105 else
106 showError ("Failed to find handler for page '${pageno}', tab '${tabno}'");
107 ?>
108 </td>
109 </tr>
110 </table>
111 </body>
112 </html>