Expose permission problem in XML request via XML
authorJoey Schulze <joey@infodrom.org>
Sun, 13 Feb 2011 23:25:41 +0000 (00:25 +0100)
committerJoey Schulze <joey@infodrom.org>
Sun, 13 Feb 2011 23:25:41 +0000 (00:25 +0100)
... so that it will be properly handled in the frontend

lib/general.php

index 7781afe..bc8a029 100644 (file)
@@ -12,6 +12,22 @@ function format_ajax($data)
   exit;
 }
 
+function format_xml($errmsg)
+{
+  header("Cache-Control: no-cache");
+  header("Pragma: no-cache");
+  header("Expires: ".gmdate("D, d M Y H:i:s",time()+(-1*60))." GMT");
+  header("Content-type: text/xml");
+
+  echo "<?xml version='1.0' encoding='UTF-8'?".">\n";
+  echo "\n<ajax-response><response type='object'>";
+  echo "\n<error>";
+  echo "\n".htmlspecialchars($errmsg);
+  echo "\n</error>";
+  echo "\n</response></ajax-response>";
+  exit;
+}
+
 function check_permissions($name)
 {
   $sql = sprintf("SELECT count(*) AS count FROM sys_mask "
@@ -71,7 +87,7 @@ function check_session()
     if (check_permissions(substr($_GET['id'],5)))
       return true;
     else
-      format_ajax(array('error' => 'No permission to access data'));
+      format_xml('No permission to access data');
   }
 
   /* table connections */