r3342 index.php: employ call_user_func() for callback
[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";
e673ee24
DO
19echo "<link rel=stylesheet type='text/css' href=pi.css />\n";
20echo "<link rel=icon href='" . getFaviconURL() . "' type='image/x-icon' />";
24d3182a 21printStyle();
e673ee24 22?>
57c69e9c 23 <script language='javascript' type='text/javascript' src='js/racktables.js'></script>
11048491 24 <script language='javascript' type='text/javascript' src='js/jquery-1.3.1.min.js'></script>
a30489ac 25 <script language='javascript' type='text/javascript' src='js/live_validation.js'></script>
54592771 26 <script language='javascript' type='text/javascript' src='js/codepress/codepress.js'></script>
e673ee24
DO
27 </head>
28<body>
29 <table border=0 cellpadding=0 cellspacing=0 width='100%' height='100%' class=maintable>
30 <tr class=mainheader>
c4d215e8 31 <td colspan=2>
e673ee24
DO
32 <table width='100%' cellspacing=0 cellpadding=2 border=0>
33 <tr>
1db97c25 34 <td valign=top><a href='http://racktables.org/'><?php printImageHREF ('logo'); ?></a></td>
b325120a 35 <td valign=top><div class=greeting><?php printGreeting(); ?></div></td>
e673ee24
DO
36 </tr>
37 </table>
38 </td>
39 </tr>
40
41 <tr>
c4d215e8 42 <td class="menubar" colspan=2>
e673ee24
DO
43 <table border="0" width="100%" cellpadding="3" cellspacing="0">
44 <tr>
b325120a 45<?php showPathAndSearch ($pageno); ?>
e673ee24
DO
46 </tr>
47 </table>
48 </td>
49 </tr>
50
51 <tr>
b325120a 52<?php
e673ee24
DO
53 showTabs ($pageno, $tabno);
54?>
55 </tr>
56
57 <tr>
c4d215e8 58 <td colspan=2>
b325120a 59<?php
e45a78d7
DO
60if (isset ($tabhandler[$pageno][$tabno]))
61{
3bebaebd
DO
62 if (isset ($page[$pageno]['bypass']) && isset ($page[$pageno]['bypass_type']))
63 {
64 switch ($page[$pageno]['bypass_type'])
65 {
66 case 'uint':
2c6c7645 67 assertUIntArg ($page[$pageno]['bypass'], 'index');
3bebaebd 68 break;
105cea6e 69 case 'uint0':
2c6c7645 70 assertUIntArg ($page[$pageno]['bypass'], 'index', TRUE);
105cea6e 71 break;
1fbc9fd6
DO
72 case 'inet4':
73 assertIPv4Arg ($page[$pageno]['bypass'], 'index');
74 break;
e1ae3fb4
AD
75 case 'string':
76 assertStringArg ($page[$pageno]['bypass'], 'index');
77 break;
3bebaebd 78 default:
0cc24e9a 79 throw new RuntimeException ('Dispatching error for bypass parameter');
3bebaebd 80 }
9a289f12 81 showMessageOrError();
3a7bdcc6 82 call_user_func ($tabhandler[$pageno][$tabno], $_REQUEST[$page[$pageno]['bypass']]);
3bebaebd 83 }
e45a78d7 84 else
9a289f12
DO
85 {
86 showMessageOrError();
3a7bdcc6 87 call_user_func ($tabhandler[$pageno][$tabno]);
9a289f12 88 }
e45a78d7
DO
89}
90elseif (isset ($page[$pageno]['handler']))
9a289f12
DO
91{
92 showMessageOrError();
e673ee24 93 $page[$pageno]['handler'] ($tabno);
9a289f12 94}
e673ee24 95else
0cc24e9a 96 throw new RuntimeException ("Failed to find handler for page '${pageno}', tab '${tabno}'");
e673ee24
DO
97?>
98 </td>
99 </tr>
100 </table>
101</body>
102</html>
90a3d6d8
DY
103<?php
104 ob_end_flush();
105} catch (Exception $e) {
106 ob_end_clean();
107 printException($e);
108}