Debian Codegraph @

dojox/rpc/tests/resources/fakestore.php

raw symbols SCIP
1 <?php
2 session_start();
3 header("Content-Type: " . ($_SERVER["CONTENT_TYPE"] == 'application/json' ? 'application/json' : 'text/plain'));
4
5 $fn = preg_replace("/\W/","",$_REQUEST["location"]);
6 switch ($_SERVER["REQUEST_METHOD"]) {
7 case "GET" :
8 if (isset($_SESSION[$fn])) {
9 print($_SESSION[$fn]);
10 }
11 else {
12 $fh = fopen($fn, 'r');
13 print(fread($fh, filesize($fn)));
14 fclose($fh);
15 }
16 break;
17 case "PUT" :
18 $contents = file_get_contents('php://input');
19 print($contents);
20 $_SESSION[$fn]=$contents;
21 break;
22 case "POST" :
23 if (isset($_SESSION[$fn])) {
24 $old = $_SESSION[$fn];
25 }
26 else {
27 $fh = fopen($fn, 'r');
28 $old = fread($fh, filesize($fn));
29 fclose($fh);
30 }
31 $contents = file_get_contents('php://input');
32 $_SESSION[$fn]=$old . $contents;
33 break;
34 case "DELETE" :
35 $_SESSION[$fn]="deleted";
36 break;
37 }
38 ?>