r2829 Added basic infrastructure for exceptions
[racktables] / ajax.php
1 <?php
2 ob_start();
3 try {
4
5 require 'inc/init.php';
6 $_REQUEST['page'] = 'perms';
7 $_REQUEST['tab'] = 'edit';
8 fixContext();
9
10 // We have a chance to handle an error before starting HTTP header.
11 if (!permitted())
12 {
13 $errlog = array
14 (
15 'v' => 2,
16 'm' => array (0 => array ('c' => 157)) // operation not permitted
17 );
18 echo "NAK\nPermission denied";
19 exit();
20 }
21
22 switch ($_REQUEST['ac'])
23 {
24 case 'verifyCode':
25 $code = str_replace ('\r', '', str_replace ('\n', "\n", $_REQUEST['code']));
26 $result = getRackCode($code);
27 if ($result['result'] == 'ACK')
28 echo 'ACK';
29 else
30 echo "NAK\n".$result['load'];
31 break;
32 }
33 ob_end_flush();
34 }
35 catch (Exception $e)
36 {
37 ob_end_clean();
38 printException($e);
39 }
40
41
42 ?>