r3342 index.php: employ call_user_func() for callback
[racktables] / process.php
1 <?php
2 ob_start();
3 try {
4 // Include init after ophandlers/snmp, not before, so local.php can redefine things.
5 require 'inc/ophandlers.php';
6 // snmp.php is an exception, it is treated by a special hack
7 if (isset ($_REQUEST['op']) and $_REQUEST['op'] == 'querySNMPData')
8 include 'inc/snmp.php';
9 require 'inc/init.php';
10 assertStringArg ('op');
11 $op = $_REQUEST['op'];
12 prepareNavigation();
13 // FIXME: find a better way to handle this error
14 if ($op == 'addFile' && !isset($_FILES['file']['error'])) {
15 throw new RuntimeException("File upload error, it's size probably exceeds upload_max_filesize directive in php.ini");
16 }
17 fixContext();
18
19
20 if (!isset ($ophandler[$pageno][$tabno][$op]))
21 {
22 throw new RuntimeException("Invalid request in operation broker: page '${pageno}', tab '${tabno}', op '${op}'");
23 }
24
25 // We have a chance to handle an error before starting HTTP header.
26 if (!isset ($delayauth[$pageno][$tabno][$op]) and !permitted())
27 $location = buildWideRedirectURL (oneLiner (157)); // operation not permitted
28 else
29 {
30 $location = call_user_func ($ophandler[$pageno][$tabno][$op]);
31 if (!strlen ($location))
32 {
33 throw new RuntimeException('Operation handler failed to return its status');
34 }
35 }
36 header ("Location: " . $location);
37 ob_end_flush();
38 }
39 catch (Exception $e)
40 {
41 ob_end_clean();
42 printException($e);
43 }
44
45 ?>