r3245 push fix for ticket:307 into trunk
[racktables] / process.php
CommitLineData
b325120a 1<?php
90a3d6d8
DY
2ob_start();
3try {
b6a7d936
DO
4// Include init after ophandlers, not before, so local.php can redefine things later.
5require 'inc/ophandlers.php';
e673ee24 6require 'inc/init.php';
0cc24e9a 7assertStringArg ('op');
067d799f 8$op = $_REQUEST['op'];
329ec966 9prepareNavigation();
e1ae3fb4 10// FIXME: find a better way to handle this error
067d799f 11if ($op == 'addFile' && !isset($_FILES['file']['error'])) {
0cc24e9a 12 throw new RuntimeException("File upload error, it's size probably exceeds upload_max_filesize directive in php.ini");
e1ae3fb4 13}
da958e52 14fixContext();
e673ee24 15
329ec966 16
067d799f 17if (!isset ($ophandler[$pageno][$tabno][$op]))
e673ee24 18{
0cc24e9a 19 throw new RuntimeException("Invalid request in operation broker: page '${pageno}', tab '${tabno}', op '${op}'");
e673ee24
DO
20}
21
56a797ef
DO
22// This is the only exception at the moment, so its handling is hardcoded.
23if ($op == 'querySNMPData')
24 include 'inc/snmp.php';
25
e673ee24 26// We have a chance to handle an error before starting HTTP header.
46f92ff7 27if (!isset ($delayauth[$pageno][$tabno][$op]) and !permitted())
db55cf54 28 $location = buildWideRedirectURL (oneLiner (157)); // operation not permitted
46f92ff7 29else
7056988c 30{
46f92ff7 31 $location = $ophandler[$pageno][$tabno][$op]();
59a83bd8 32 if (!strlen ($location))
7056988c 33 {
0cc24e9a 34 throw new RuntimeException('Operation handler failed to return its status');
7056988c
DO
35 }
36}
e673ee24 37header ("Location: " . $location);
90a3d6d8
DY
38ob_end_flush();
39}
40catch (Exception $e)
41{
42 ob_end_clean();
43 printException($e);
44}
45?>
e673ee24
DO
46
47?>