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