r4073 minor change in UI for recent change: VST form commit on ENTER and hints on...
[racktables] / process.php
... / ...
CommitLineData
1<?php
2ob_start();
3try {
4// Include init after ophandlers/snmp, not before, so local.php can redefine things.
5require 'inc/ophandlers.php';
6// snmp.php is an exception, it is treated by a special hack
7if (isset ($_REQUEST['op']) and $_REQUEST['op'] == 'querySNMPData')
8 include 'inc/snmp.php';
9require 'inc/init.php';
10assertStringArg ('op');
11$op = $_REQUEST['op'];
12prepareNavigation();
13// FIXME: find a better way to handle this error
14if ($op == 'addFile' && !isset($_FILES['file']['error']))
15 throw new RackTablesError ('File upload error, check upload_max_filesize in php.ini', RackTablesError::MISCONFIGURED);
16fixContext();
17
18if (!isset ($ophandler[$pageno][$tabno][$op]) or !function_exists ($ophandler[$pageno][$tabno][$op]))
19 throw new RackTablesError ("Invalid navigation data for '${pageno}-${tabno}-${op}'", RackTablesError::INTERNAL);
20
21// We have a chance to handle an error before starting HTTP header.
22if (!isset ($delayauth[$pageno][$tabno][$op]) and !permitted())
23 $location = buildWideRedirectURL (oneLiner (157)); // operation not permitted
24else
25{
26 $location = call_user_func ($ophandler[$pageno][$tabno][$op]);
27 if (!strlen ($location))
28 throw new RackTablesError ('Operation handler failed to return its status', RackTablesError::INTERNAL);
29}
30header ("Location: " . $location);
31ob_end_flush();
32}
33// "soft" failures only require a short error message
34catch (InvalidRequestArgException $e)
35{
36 ob_end_clean();
37 header ('Location: ' . buildWideRedirectURL (oneLiner (107, array ($e->getMessage()))));
38}
39catch (RTDatabaseError $e)
40{
41 ob_end_clean();
42 header ('Location: ' . buildWideRedirectURL (oneLiner (108, array ($e->getMessage()))));
43}
44// the rest ends up in a dedicated page
45catch (Exception $e)
46{
47 ob_end_clean();
48 printException ($e);
49}
50
51?>