annotate save.php @ 1417:3c67469e315a
Scripts: generate_report.py accepts folder names with spaces - uses package 'grffile'. Minor correction to Instructions (manual emergency saves).
author |
Brecht De Man <b.deman@qmul.ac.uk> |
date |
Tue, 08 Dec 2015 17:17:39 +0100 |
parents |
1de4c0257fa4 |
children |
2647dd909229 b5bf2f57187c 9ee921c8cdd3 |
rev |
line source |
b@1402
|
1 <?php
|
b@1402
|
2 header('Access-Control-Allow-Origin: *');
|
b@1402
|
3 header("Content-type: text/xml");
|
b@1402
|
4 $postText = file_get_contents('php://input');
|
b@1402
|
5 $sha1_hash = sha1($postText);
|
b@1402
|
6 $datetime = date('ymdHis');
|
b@1402
|
7 $xmlfile = "save".$datetime."-".$sha1_hash.".xml";
|
b@1402
|
8 $fileHandle = fopen("saves/".$xmlfile, 'w');
|
b@1402
|
9 if ($fileHandle == FALSE)
|
b@1402
|
10 {
|
b@1402
|
11 // Filehandle failed
|
b@1402
|
12 $xml = '<response state="error"><message>Could not open file</message></response>';
|
b@1402
|
13 echo $xml;
|
b@1402
|
14 return;
|
b@1402
|
15 }
|
b@1402
|
16 $wbytes = fwrite($fileHandle, $postText);
|
b@1402
|
17 if ($wbytes == FALSE)
|
b@1402
|
18 {
|
b@1402
|
19 // FileWrite failed
|
b@1402
|
20 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
|
b@1402
|
21 echo $xml;
|
b@1402
|
22 return;
|
b@1402
|
23 }
|
b@1402
|
24 fclose($fileHandle);
|
b@1402
|
25
|
b@1402
|
26 // Return JSON confirmation data
|
b@1402
|
27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
|
b@1402
|
28 echo $xml;
|
b@1402
|
29 ?> |