Commit | Line | Data |
---|---|---|
b325120a | 1 | <?php |
90a3d6d8 DY |
2 | ob_start(); |
3 | try { | |
36ef72d9 DO |
4 | if (array_key_exists ('module', $_REQUEST)) |
5 | { | |
6 | switch ($_REQUEST['module']) | |
7 | { | |
8 | case 'tsuri': | |
4afb4c10 | 9 | require_once 'inc/init.php'; |
36ef72d9 DO |
10 | genericAssertion ('uri', 'string'); |
11 | proxyStaticURI ($_REQUEST['uri']); | |
12 | break; | |
0415b520 | 13 | case 'download': |
4afb4c10 | 14 | require_once 'inc/init.php'; |
0415b520 DO |
15 | $pageno = 'file'; |
16 | $tabno = 'download'; | |
17 | fixContext(); | |
18 | if (!permitted()) | |
19 | { | |
20 | require_once 'inc/interface.php'; | |
21 | renderAccessDenied(); | |
22 | } | |
23 | ||
24 | $asattach = (isset ($_REQUEST['asattach']) and $_REQUEST['asattach'] == 'no') ? FALSE : TRUE; | |
25 | $file = getFile (getBypassValue()); | |
26 | header("Content-Type: {$file['type']}"); | |
27 | header("Content-Length: {$file['size']}"); | |
28 | if ($asattach) | |
29 | header("Content-Disposition: attachment; filename={$file['name']}"); | |
30 | echo $file['contents']; | |
31 | break; | |
4afb4c10 DO |
32 | case 'image': |
33 | require_once 'inc/render_image.php'; | |
34 | // 'progressbar's never change, attempt an IMS chortcut before loading init.php | |
35 | checkIMSCondition(); | |
36 | require_once 'inc/init.php'; | |
37 | try | |
38 | { | |
39 | dispatchImageRequest(); | |
40 | } | |
41 | catch (Exception $e) | |
42 | { | |
43 | renderError(); | |
44 | } | |
45 | break; | |
36ef72d9 DO |
46 | default: |
47 | throw new InvalidRequestArgException ('module', $_REQUEST['module']); | |
48 | } | |
0415b520 | 49 | ob_end_flush(); |
36ef72d9 DO |
50 | exit; |
51 | } | |
52 | ||
b52cc354 DO |
53 | require_once 'inc/interface.php'; |
54 | # init.php has to be included after interface.php, otherwise the bits | |
55 | # set by local.php get lost | |
56 | require_once 'inc/init.php'; | |
329ec966 | 57 | prepareNavigation(); |
da958e52 DO |
58 | // no ctx override is necessary |
59 | fixContext(); | |
750d26d2 | 60 | redirectIfNecessary(); |
da958e52 | 61 | if (!permitted()) |
da958e52 | 62 | renderAccessDenied(); |
878512c6 | 63 | header ('Content-Type: text/html; charset=UTF-8'); |
b0348307 | 64 | // Only store the tab name after clearance is got. Any failure is unhandleable. |
fa5b2764 AA |
65 | if (isset ($_REQUEST['tab']) and ! isset ($_SESSION['RTLT'][$pageno]['dont_remember'])) |
66 | $_SESSION['RTLT'][$pageno] = array ('tabname' => $tabno, 'time' => time()); | |
e673ee24 | 67 | |
1d4d254b AA |
68 | // call the main handler - page or tab handler. |
69 | // catch exception and show its error message instead of page/tab content | |
70 | try { | |
e45a78d7 | 71 | if (isset ($tabhandler[$pageno][$tabno])) |
08408472 | 72 | call_user_func ($tabhandler[$pageno][$tabno], getBypassValue()); |
e45a78d7 | 73 | elseif (isset ($page[$pageno]['handler'])) |
e673ee24 DO |
74 | $page[$pageno]['handler'] ($tabno); |
75 | else | |
1d4d254b | 76 | showError ("Failed to find handler for page '${pageno}', tab '${tabno}'"); |
08408472 | 77 | $content = ob_get_clean(); |
1d4d254b AA |
78 | } catch (Exception $e) { |
79 | ob_clean(); | |
80 | $content = ''; | |
81 | showError ("Unhandled exception: " . $e->getMessage()); | |
82 | } | |
83 | ||
08408472 | 84 | ob_start(); |
e673ee24 | 85 | ?> |
08408472 AA |
86 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
87 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
88 | <head><title><?php echo getTitle ($pageno); ?></title> | |
89 | <?php printPageHeaders(); ?> | |
90 | </head> | |
91 | <body> | |
92 | <table border=0 cellpadding=0 cellspacing=0 width="100%" height="100%" class="maintable"> | |
93 | <tr class="mainheader"><td> | |
94 | <table width="100%" cellspacing="0" cellpadding="2" border="0"> | |
95 | <tr> | |
96 | <td valign=top><a href="http://racktables.org/"><?php printImageHREF ('logo'); ?></a></td> | |
97 | <td valign=top><div class=greeting><?php printGreeting(); ?></div></td> | |
98 | </tr> | |
99 | </table> | |
100 | </td></tr> | |
101 | <tr><td class="menubar"> | |
102 | <table border="0" width="100%" cellpadding="3" cellspacing="0"> | |
103 | <tr><?php showPathAndSearch ($pageno); ?></tr> | |
104 | </table> | |
105 | </td></tr> | |
106 | <tr><td><?php showTabs ($pageno, $tabno); ?></td></tr> | |
1d4d254b | 107 | <tr><td><?php showMessageOrError(); ?></td></tr> |
08408472 AA |
108 | <tr><td><?php echo $content; ?></td></tr> |
109 | </table> | |
110 | </body> | |
111 | </html> | |
e410ebfc | 112 | <?php |
65e557dd | 113 | ob_flush(); |
90a3d6d8 DY |
114 | } catch (Exception $e) { |
115 | ob_end_clean(); | |
116 | printException($e); | |
117 | } | |
1d4d254b | 118 | clearMessages(); // prevent message appearing in foreign tab |
e410ebfc | 119 | ?> |