r4104 show page/tab handler exception messages embedded in main page interface
[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 if (isset ($_REQUEST['tab']) and ! isset ($_SESSION['RTLT'][$pageno]['dont_remember']))
15 $_SESSION['RTLT'][$pageno] = array ('tabname' => $tabno, 'time' => time());
16
17 // call the main handler - page or tab handler.
18 // catch exception and show its error message instead of page/tab content
19 try {
20 if (isset ($tabhandler[$pageno][$tabno]))
21 call_user_func ($tabhandler[$pageno][$tabno], getBypassValue());
22 elseif (isset ($page[$pageno]['handler']))
23 $page[$pageno]['handler'] ($tabno);
24 else
25 showError ("Failed to find handler for page '${pageno}', tab '${tabno}'");
26 $content = ob_get_clean();
27 } catch (Exception $e) {
28 ob_clean();
29 $content = '';
30 showError ("Unhandled exception: " . $e->getMessage());
31 }
32
33 ob_start();
34 ?>
35 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
36 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
37 <head><title><?php echo getTitle ($pageno); ?></title>
38 <?php printPageHeaders(); ?>
39 </head>
40 <body>
41 <table border=0 cellpadding=0 cellspacing=0 width="100%" height="100%" class="maintable">
42 <tr class="mainheader"><td>
43 <table width="100%" cellspacing="0" cellpadding="2" border="0">
44 <tr>
45 <td valign=top><a href="http://racktables.org/"><?php printImageHREF ('logo'); ?></a></td>
46 <td valign=top><div class=greeting><?php printGreeting(); ?></div></td>
47 </tr>
48 </table>
49 </td></tr>
50 <tr><td class="menubar">
51 <table border="0" width="100%" cellpadding="3" cellspacing="0">
52 <tr><?php showPathAndSearch ($pageno); ?></tr>
53 </table>
54 </td></tr>
55 <tr><td><?php showTabs ($pageno, $tabno); ?></td></tr>
56 <tr><td><?php showMessageOrError(); ?></td></tr>
57 <tr><td><?php echo $content; ?></td></tr>
58 </table>
59 </body>
60 </html>
61 <?php
62 ob_flush();
63 } catch (Exception $e) {
64 ob_end_clean();
65 printException($e);
66 }
67 clearMessages(); // prevent message appearing in foreign tab
68 ?>