r3888 Michael Tiernan: If anyone is interested, I modified the
[racktables] / ajax.php
index eccfb921c980518f42c65ae32e1b1607fd4199a7..928507c92c808236f8037471b2014075bf8b285c 100644 (file)
--- a/ajax.php
+++ b/ajax.php
@@ -1,33 +1,34 @@
 <?php
+ob_start();
+try {
 
 require 'inc/init.php';
-
+$pageno = 'perms';
+$tabno = 'edit';
 fixContext();
 
-// We have a chance to handle an error before starting HTTP header.
 if (!permitted())
 {
-       $errlog = array
-       (
-               'v' => 2,
-               'm' => array (0 => array ('c' => 157)) // operation not permitted
-       );
-       $location = buildWideRedirectURL ($errlog);
-       header ("Location: " . $location);
+       echo "NAK\nPermission denied";
        exit();
 }
 
-switch ($_GET['ac'])
+switch ($_REQUEST['ac'])
 {
        case 'verifyCode':
-               $code = $_REQUEST['code'];
-               $result = getRackCode($code);
+               $result = getRackCode (dos2unix ($_REQUEST['code']));
                if ($result['result'] == 'ACK')
-                       echo 'ACK';
+                       echo "ACK\n";
                else
                        echo "NAK\n".$result['load'];
        break;
 }
-
+ob_end_flush();
+}
+catch (Exception $e)
+{
+       ob_end_clean();
+       echo "NAK\nRuntime exception";
+}
 
 ?>