r3830 make 0.17.11 pre-release justifications
[racktables] / process.php
CommitLineData
b325120a 1<?php
90a3d6d8
DY
2ob_start();
3try {
7e87a291 4// Include init after ophandlers/snmp, not before, so local.php can redefine things.
b6a7d936 5require 'inc/ophandlers.php';
7e87a291
DO
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';
e673ee24 9require 'inc/init.php';
0cc24e9a 10assertStringArg ('op');
067d799f 11$op = $_REQUEST['op'];
329ec966 12prepareNavigation();
e1ae3fb4 13// FIXME: find a better way to handle this error
e8900a2b
DO
14if ($op == 'addFile' && !isset($_FILES['file']['error']))
15 throw new Exception ('File upload error, check upload_max_filesize in php.ini', E_INTERNAL);
da958e52 16fixContext();
e673ee24 17
e8900a2b
DO
18if (!isset ($ophandler[$pageno][$tabno][$op]) or !function_exists ($ophandler[$pageno][$tabno][$op]))
19 throw new Exception ("Invalid navigation data for '${pageno}-${tabno}-${op}'", E_INTERNAL);
15c65ce4 20
e673ee24 21// We have a chance to handle an error before starting HTTP header.
46f92ff7 22if (!isset ($delayauth[$pageno][$tabno][$op]) and !permitted())
db55cf54 23 $location = buildWideRedirectURL (oneLiner (157)); // operation not permitted
46f92ff7 24else
7056988c 25{
3a7bdcc6 26 $location = call_user_func ($ophandler[$pageno][$tabno][$op]);
59a83bd8 27 if (!strlen ($location))
e8900a2b 28 throw new Exception ('Operation handler failed to return its status', E_INTERNAL);
7056988c 29}
e673ee24 30header ("Location: " . $location);
90a3d6d8
DY
31ob_end_flush();
32}
33catch (Exception $e)
34{
35 ob_end_clean();
5f054512
DO
36 if ($e->getCode() == E_DB_CONSTRAINT)
37 header ('Location: ' . buildWideRedirectURL (oneLiner (108, array ($e->getMessage()))));
38 else
39 printException($e);
90a3d6d8 40}
e673ee24
DO
41
42?>