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