r3695 get rid of CodeCompilationError class
[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
15c65ce4
DO
25if (!function_exists ($ophandler[$pageno][$tabno][$op]))
26 throw new RuntimeException
27 (
28 "Dispatching error at position '${pageno}-${tabno}-${op}': function '" .
29 $ophandler[$pageno][$tabno][$op] . "' does not exist."
30 );
31
e673ee24 32// We have a chance to handle an error before starting HTTP header.
46f92ff7 33if (!isset ($delayauth[$pageno][$tabno][$op]) and !permitted())
db55cf54 34 $location = buildWideRedirectURL (oneLiner (157)); // operation not permitted
46f92ff7 35else
7056988c 36{
3a7bdcc6 37 $location = call_user_func ($ophandler[$pageno][$tabno][$op]);
59a83bd8 38 if (!strlen ($location))
7056988c 39 {
0cc24e9a 40 throw new RuntimeException('Operation handler failed to return its status');
7056988c
DO
41 }
42}
e673ee24 43header ("Location: " . $location);
90a3d6d8
DY
44ob_end_flush();
45}
46catch (Exception $e)
47{
48 ob_end_clean();
49 printException($e);
50}
e673ee24
DO
51
52?>