r4178 bugfix: PHP warnings were appearing before rackspace on SLB object page, defaul...
[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 $location = buildWideRedirectURL();
14
15 // FIXME: find a better way to handle this error
16 if ($op == 'addFile' && !isset($_FILES['file']['error']))
17 throw new RackTablesError ('File upload error, check upload_max_filesize in php.ini', RackTablesError::MISCONFIGURED);
18 fixContext();
19
20 if
21 (
22 !isset ($ophandler[$pageno][$tabno][$op]) or
23 !function_exists ($ophandler[$pageno][$tabno][$op])
24 )
25 throw new RackTablesError ("Invalid navigation data for '${pageno}-${tabno}-${op}'", RackTablesError::INTERNAL);
26
27 // We have a chance to handle an error before starting HTTP header.
28 if (!isset ($delayauth[$pageno][$tabno][$op]) and !permitted())
29 showError ('Operation not permitted');
30 else
31 {
32 // Call below does the job of bypass argument assertion, if such is required,
33 // so the ophandler function doesn't have to re-assert this portion of its
34 // arguments. And it would be even better to pass returned value to ophandler,
35 // so it is not necessary to remember the name of bypass in it.
36 getBypassValue();
37 if (strlen ($redirect_to = call_user_func ($ophandler[$pageno][$tabno][$op])))
38 $location = $redirect_to;
39 }
40 header ("Location: " . $location);
41 ob_end_flush();
42 }
43 // "soft" failures only require a short error message
44 catch (InvalidRequestArgException $e)
45 {
46 ob_end_clean();
47 showError ('Assertion failed: ' . $e->getMessage());
48 header ('Location: ' . $location);
49 }
50 catch (RTDatabaseError $e)
51 {
52 ob_end_clean();
53 showError ('Database error: ' . $e->getMessage());
54 header ('Location: ' . $location);
55 }
56 // the rest ends up in a dedicated page
57 catch (Exception $e)
58 {
59 ob_end_clean();
60 printException ($e);
61 }
62
63 ?>