Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / examples / restful / remote / lib / request.php
index 60c1df2..bb8461e 100644 (file)
@@ -24,12 +24,31 @@ class Request {
             fclose($httpContent);
             $params = array();
             parse_str($raw, $params);
-            $this->id = (isset($params['id'])) ? $params['id'] : null;
-            $this->params = (isset($params['data'])) ? json_decode(stripslashes($params['data']), true) : null;
+
+            if (isset($params['data'])) {
+                $this->params =  json_decode(stripslashes($params['data']));
+            } else {
+                $params = json_decode(stripslashes($raw));
+                $this->params = $params;
+            }
         } else {
             // grab JSON data if there...
-            $this->params = (isset($_REQUEST['data'])) ? json_decode(stripslashes($_REQUEST['data']), true) : null;
-            $this->id = (isset($_REQUEST['id'])) ? json_decode(stripslashes($_REQUEST['id']), true) : null;
+            $this->params = (isset($_REQUEST['data'])) ? json_decode(stripslashes($_REQUEST['data'])) : null;
+
+            if (isset($_REQUEST['data'])) {
+                $this->params =  json_decode(stripslashes($_REQUEST['data']));
+            } else {
+                $raw  = '';
+                $httpContent = fopen('php://input', 'r');
+                while ($kb = fread($httpContent, 1024)) {
+                    $raw .= $kb;
+                }
+                $params = json_decode(stripslashes($raw));
+                if ($params) {
+                    $this->params = $params;
+                }
+            }
+
         }
         // Quickndirty PATH_INFO parser
         if (isset($_SERVER["PATH_INFO"])){