first set of commands arrive from index_rd_ifra.php handler
[brisk.git] / web / spush / sac-a-push.phh
index 8dfea84..fef79ac 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function spu_process_info($stream_info, &$header, &$get, &$post)
+function spu_process_info($stream_info, $method, &$header, &$get, &$post, &$cookie)
 {
     $check_post = FALSE;
     $header = array();
@@ -14,8 +14,21 @@ function spu_process_info($stream_info, &$header, &$get, &$post)
             }
             $req = explode(" ", $header['The-Request']);
             $method = $req[0];
+
+            if (isset($header['Cookie'])) {
+                $cookies = explode(";", $header['Cookie']);
+                for ($i = 0 ; $i < count($cookies) ; $i++) {
+                    $nameval = explode("=", trim($cookies[$i]));
+                    if (count($nameval) != 2) {
+                        printf("WARNING: malformat cookie element [%s]\n", $cookies[$i]);
+                        continue;
+                    }
+                    $cookie[$nameval[0]] = urldecode($nameval[1]);
+                }
+            }
             // GET params management
             $get_vars = explode('?', $req[1], 2);
+            $path =   $get_vars[0];
             if (count($get_vars) > 1) {
                 $a = explode('&', $get_vars[1]);
                 printf("A COUNT: [%s] %d\n", $a[0], count($a));
@@ -47,7 +60,20 @@ function spu_process_info($stream_info, &$header, &$get, &$post)
         $split = explode(":", $line, 2);
         $header[$split[0]] = $split[1];        
     }
-    return $method;
+    return $path;
 }
 
-?>
\ No newline at end of file
+function gpcs_var($name, $get, $post, $cookie)
+{
+    if (isset($GLOBALS[$name])) 
+        return FALSE;
+    else if (isset($cookie[$name])) 
+        return ($cookie[$name]);
+    else if (isset($post[$name])) 
+        return ($post[$name]);
+    else if (isset($get[$name])) 
+        return ($get[$name]);
+
+    return FALSE;
+}
+?>