r3864 copy recent exceptions-related commits into trunk
[racktables] / index.php
1 <?php
2 ob_start();
3 try {
4 require 'inc/interface.php';
5 require 'inc/init.php';
6 prepareNavigation();
7 // no ctx override is necessary
8 fixContext();
9 redirectIfNecessary();
10 if (!permitted())
11 renderAccessDenied();
12 header ('Content-Type: text/html; charset=UTF-8');
13 // Only store the tab name after clearance is got. Any failure is unhandleable.
14 $_SESSION['RTLT'][$pageno] = $tabno;
15
16 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
17 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'."\n";
18 echo '<head><title>' . getTitle ($pageno) . "</title>\n";
19 printPageHeaders();
20 ?>
21 </head>
22 <body>
23 <table border=0 cellpadding=0 cellspacing=0 width='100%' height='100%' class=maintable>
24 <tr class=mainheader>
25 <td colspan=2>
26 <table width='100%' cellspacing=0 cellpadding=2 border=0>
27 <tr>
28 <td valign=top><a href='http://racktables.org/'><?php printImageHREF ('logo'); ?></a></td>
29 <td valign=top><div class=greeting><?php printGreeting(); ?></div></td>
30 </tr>
31 </table>
32 </td>
33 </tr>
34
35 <tr>
36 <td class="menubar" colspan=2>
37 <table border="0" width="100%" cellpadding="3" cellspacing="0">
38 <tr>
39 <?php showPathAndSearch ($pageno); ?>
40 </tr>
41 </table>
42 </td>
43 </tr>
44
45 <tr>
46 <?php
47 showTabs ($pageno, $tabno);
48 ?>
49 </tr>
50
51 <tr>
52 <td colspan=2>
53 <?php
54 if (isset ($tabhandler[$pageno][$tabno]))
55 {
56 if (isset ($page[$pageno]['bypass']) && isset ($page[$pageno]['bypass_type']))
57 {
58 switch ($page[$pageno]['bypass_type'])
59 {
60 case 'uint':
61 assertUIntArg ($page[$pageno]['bypass']);
62 break;
63 case 'uint0':
64 assertUIntArg ($page[$pageno]['bypass'], TRUE);
65 break;
66 case 'inet4':
67 assertIPv4Arg ($page[$pageno]['bypass']);
68 break;
69 case 'string':
70 assertStringArg ($page[$pageno]['bypass']);
71 break;
72 default:
73 throw new RackTablesError ('Dispatching error for bypass parameter', RackTablesError::INTERNAL);
74 }
75 showMessageOrError();
76 call_user_func ($tabhandler[$pageno][$tabno], $_REQUEST[$page[$pageno]['bypass']]);
77 }
78 else
79 {
80 showMessageOrError();
81 call_user_func ($tabhandler[$pageno][$tabno]);
82 }
83 }
84 elseif (isset ($page[$pageno]['handler']))
85 {
86 showMessageOrError();
87 $page[$pageno]['handler'] ($tabno);
88 }
89 else
90 throw new RackTablesError ("Failed to find handler for page '${pageno}', tab '${tabno}'", RackTablesError::INTERNAL);
91 ?>
92 </td>
93 </tr>
94 </table>
95 </body>
96 </html>
97 <?php
98 ob_end_flush();
99 } catch (Exception $e) {
100 ob_end_clean();
101 printException($e);
102 }