r4114 updIPv4Prefix(): sayonara
[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();
08408472
AA
13$location = buildWideRedirectURL();
14
e1ae3fb4 15// FIXME: find a better way to handle this error
e8900a2b 16if ($op == 'addFile' && !isset($_FILES['file']['error']))
3a089a44 17 throw new RackTablesError ('File upload error, check upload_max_filesize in php.ini', RackTablesError::MISCONFIGURED);
da958e52 18fixContext();
e673ee24 19
cde28cf0
DO
20if
21(
22 !isset ($ophandler[$pageno][$tabno][$op]) or
23 (!is_array ($ophandler[$pageno][$tabno][$op]) and !function_exists ($ophandler[$pageno][$tabno][$op]))
24)
3a089a44 25 throw new RackTablesError ("Invalid navigation data for '${pageno}-${tabno}-${op}'", RackTablesError::INTERNAL);
15c65ce4 26
e673ee24 27// We have a chance to handle an error before starting HTTP header.
46f92ff7 28if (!isset ($delayauth[$pageno][$tabno][$op]) and !permitted())
08408472 29 showError ('Operation not permitted');
46f92ff7 30else
7056988c 31{
1d356026
DO
32 // Call below does the job of bypass argument assertion, if such is required,
33 // so the ophandler function doesn't have to re-assert this portion of its
34 // arguments. And it would be even better to pass returned value to ophandler,
35 // so it is not necessary to remember the name of bypass in it.
36 getBypassValue();
cde28cf0 37 if (!is_array ($ophandler[$pageno][$tabno][$op]))
08408472 38 $redirect_to = call_user_func ($ophandler[$pageno][$tabno][$op]);
cde28cf0 39 else
08408472
AA
40 $redirect_to = tableHandler ($ophandler[$pageno][$tabno][$op]);
41 if (strlen ($redirect_to))
42 $location = $redirect_to;
7056988c 43}
e673ee24 44header ("Location: " . $location);
90a3d6d8
DY
45ob_end_flush();
46}
3a089a44
DO
47// "soft" failures only require a short error message
48catch (InvalidRequestArgException $e)
49{
50 ob_end_clean();
08408472
AA
51 showError ('Assertion failed: ' . $e->getMessage());
52 header ('Location: ' . $location);
3a089a44 53}
ec523868 54catch (RTDatabaseError $e)
3a089a44
DO
55{
56 ob_end_clean();
08408472
AA
57 showError ('Database error: ' . $e->getMessage());
58 header ('Location: ' . $location);
3a089a44
DO
59}
60// the rest ends up in a dedicated page
90a3d6d8
DY
61catch (Exception $e)
62{
63 ob_end_clean();
3a089a44 64 printException ($e);
90a3d6d8 65}
e673ee24
DO
66
67?>