r4273 Initial implementation of #389, section 3.3.
[racktables] / wwwroot / index.php
1 <?php
2 ob_start();
3 try {
4 require 'inc/init.php';
5 if (array_key_exists ('module', $_REQUEST))
6 {
7 switch ($_REQUEST['module'])
8 {
9 case 'tsuri':
10 genericAssertion ('uri', 'string');
11 proxyStaticURI ($_REQUEST['uri']);
12 break;
13 default:
14 throw new InvalidRequestArgException ('module', $_REQUEST['module']);
15 }
16 exit;
17 }
18
19 require 'inc/interface.php';
20 prepareNavigation();
21 // no ctx override is necessary
22 fixContext();
23 redirectIfNecessary();
24 if (!permitted())
25 renderAccessDenied();
26 header ('Content-Type: text/html; charset=UTF-8');
27 // Only store the tab name after clearance is got. Any failure is unhandleable.
28 if (isset ($_REQUEST['tab']) and ! isset ($_SESSION['RTLT'][$pageno]['dont_remember']))
29 $_SESSION['RTLT'][$pageno] = array ('tabname' => $tabno, 'time' => time());
30
31 // call the main handler - page or tab handler.
32 // catch exception and show its error message instead of page/tab content
33 try {
34 if (isset ($tabhandler[$pageno][$tabno]))
35 call_user_func ($tabhandler[$pageno][$tabno], getBypassValue());
36 elseif (isset ($page[$pageno]['handler']))
37 $page[$pageno]['handler'] ($tabno);
38 else
39 showError ("Failed to find handler for page '${pageno}', tab '${tabno}'");
40 $content = ob_get_clean();
41 } catch (Exception $e) {
42 ob_clean();
43 $content = '';
44 showError ("Unhandled exception: " . $e->getMessage());
45 }
46
47 ob_start();
48 ?>
49 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
50 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
51 <head><title><?php echo getTitle ($pageno); ?></title>
52 <?php printPageHeaders(); ?>
53 </head>
54 <body>
55 <table border=0 cellpadding=0 cellspacing=0 width="100%" height="100%" class="maintable">
56 <tr class="mainheader"><td>
57 <table width="100%" cellspacing="0" cellpadding="2" border="0">
58 <tr>
59 <td valign=top><a href="http://racktables.org/"><?php printImageHREF ('logo'); ?></a></td>
60 <td valign=top><div class=greeting><?php printGreeting(); ?></div></td>
61 </tr>
62 </table>
63 </td></tr>
64 <tr><td class="menubar">
65 <table border="0" width="100%" cellpadding="3" cellspacing="0">
66 <tr><?php showPathAndSearch ($pageno); ?></tr>
67 </table>
68 </td></tr>
69 <tr><td><?php showTabs ($pageno, $tabno); ?></td></tr>
70 <tr><td><?php showMessageOrError(); ?></td></tr>
71 <tr><td><?php echo $content; ?></td></tr>
72 </table>
73 </body>
74 </html>
75 <?php
76 ob_flush();
77 } catch (Exception $e) {
78 ob_end_clean();
79 printException($e);
80 }
81 clearMessages(); // prevent message appearing in foreign tab
82 ?>