Add LiveGrid SQL backend
authorJoey Schulze <joey@infodrom.org>
Wed, 20 Jan 2010 10:02:10 +0000 (11:02 +0100)
committerJoey Schulze <joey@infodrom.org>
Wed, 20 Jan 2010 10:02:10 +0000 (11:02 +0100)
ajax/ricoXMLquery.php [new file with mode: 0644]

diff --git a/ajax/ricoXMLquery.php b/ajax/ricoXMLquery.php
new file mode 100644 (file)
index 0000000..4c5713b
--- /dev/null
@@ -0,0 +1,61 @@
+<?php\r
+\r
+require_once('../config.php');\r
+\r
+header("Cache-Control: no-cache");\r
+header("Pragma: no-cache");\r
+header("Expires: ".gmdate("D, d M Y H:i:s",time()+(-1*60))." GMT");\r
+header("Content-type: text/xml");\r
+echo "<?xml version='1.0' encoding='UTF-8'?".">\n";\r
+\r
+require_once('../lib/dbase.php');\r
+require_once('../lib/dbClass.php');\r
+require_once('../lib/rico/ricoXmlResponse.php');\r
+\r
+$id=isset($_GET["id"]) ? $_GET["id"] : "";\r
+$offset=isset($_GET["offset"]) ? $_GET["offset"] : "0";\r
+$size=isset($_GET["page_size"]) ? $_GET["page_size"] : "";\r
+$total=isset($_GET["get_total"]) ? strtolower($_GET["get_total"]) : "false";\r
+$distinct=isset($_GET["distinct"]) ? $_GET["distinct"] : "";\r
+\r
+echo "\n<ajax-response><response type='object' id='".$id."_updater'>";\r
+if (empty($id)) {\r
+  ErrorResponse("No ID provided!");\r
+} elseif ($distinct=="" && !is_numeric($offset)) {\r
+  ErrorResponse("Invalid offset!");\r
+} elseif ($distinct=="" && !is_numeric($size)) {\r
+  ErrorResponse("Invalid size!");\r
+} elseif ($distinct!="" && !is_numeric($distinct)) {\r
+  ErrorResponse("Invalid distinct parameter!");\r
+} elseif (!isset($_SESSION[$id])) {\r
+  ErrorResponse("Your connection with the server was idle for too long and timed out. Please refresh this page and try again.");\r
+} elseif (!OpenDB()) {\r
+  ErrorResponse(htmlspecialchars($oDB->LastErrorMsg));\r
+} else {\r
+  $filters=isset($_SESSION[$id . ".filters"]) ? $_SESSION[$id . ".filters"] : array();\r
+  $oDB->DisplayErrors=false;\r
+  $oDB->ErrMsgFmt="MULTILINE";\r
+  $oXmlResp= new ricoXmlResponse();\r
+  $oXmlResp->sendDebugMsgs=true;\r
+  $oXmlResp->convertCharSet=false;  // Database is already in UTF-8\r
+  if ($distinct=="") {\r
+    $oXmlResp->Query2xml($_SESSION[$id], intval($offset), intval($size), $total!="false", $filters);\r
+  } else {\r
+    $oXmlResp->Query2xmlDistinct($_SESSION[$id], intval($distinct), -1, $filters);\r
+  }\r
+  if (!empty($oDB->LastErrorMsg)) {\r
+    echo "\n<error>";\r
+    echo "\n".htmlspecialchars($oDB->LastErrorMsg);\r
+    echo "\n</error>";\r
+  }\r
+  $oXmlResp=NULL;\r
+  # CloseApp();\r
+}\r
+echo "\n</response></ajax-response>";\r
+\r
+\r
+function ErrorResponse($msg) {\r
+  echo "\n<rows update_ui='false' /><error>" . $msg . "</error>";\r
+}\r
+\r
+?>\r