r3246 push last SNMP changes into trunk
[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
067d799f 14if ($op == 'addFile' && !isset($_FILES['file']['error'])) {
0cc24e9a 15 throw new RuntimeException("File upload error, it's size probably exceeds upload_max_filesize directive in php.ini");
e1ae3fb4 16}
da958e52 17fixContext();
e673ee24 18
329ec966 19
067d799f 20if (!isset ($ophandler[$pageno][$tabno][$op]))
e673ee24 21{
0cc24e9a 22 throw new RuntimeException("Invalid request in operation broker: page '${pageno}', tab '${tabno}', op '${op}'");
e673ee24
DO
23}
24
25// We have a chance to handle an error before starting HTTP header.
46f92ff7 26if (!isset ($delayauth[$pageno][$tabno][$op]) and !permitted())
db55cf54 27 $location = buildWideRedirectURL (oneLiner (157)); // operation not permitted
46f92ff7 28else
7056988c 29{
46f92ff7 30 $location = $ophandler[$pageno][$tabno][$op]();
59a83bd8 31 if (!strlen ($location))
7056988c 32 {
0cc24e9a 33 throw new RuntimeException('Operation handler failed to return its status');
7056988c
DO
34 }
35}
e673ee24 36header ("Location: " . $location);
90a3d6d8
DY
37ob_end_flush();
38}
39catch (Exception $e)
40{
41 ob_end_clean();
42 printException($e);
43}
44?>
e673ee24
DO
45
46?>