Merge from branch "WAC2016"
author |
Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
date |
Mon, 23 Nov 2015 09:13:12 +0000 |
parents |
9c579fc05a09 |
children |
cfe755cc2bc2 |
rev |
line source |
n@816
|
1 <?php
|
n@820
|
2 header('Access-Control-Allow-Origin: *');
|
n@820
|
3 header("Content-type: text/xml");
|
n@816
|
4 $postText = file_get_contents('php://input');
|
n@816
|
5 $datetime = date('ymdHis');
|
n@816
|
6 $xmlfile = "save".$datetime.".xml";
|
n@816
|
7 $fileHandle = fopen("saves/".$xmlfile, 'w');
|
n@820
|
8 if ($fileHandle == FALSE)
|
n@820
|
9 {
|
n@820
|
10 // Filehandle failed
|
n@820
|
11 $xml = '<response state="error"><message>Could not open file</message></response>';
|
n@820
|
12 echo $xml;
|
n@820
|
13 return;
|
n@820
|
14 }
|
n@820
|
15 $wbytes = fwrite($fileHandle, $postText);
|
n@820
|
16 if ($wbytes == FALSE)
|
n@820
|
17 {
|
n@820
|
18 // FileWrite failed
|
n@820
|
19 $xml = '<response state="error"><message>Could not write file "saves/'.$xmlfile.'"</message></response>';
|
n@820
|
20 echo $xml;
|
n@820
|
21 return;
|
n@820
|
22 }
|
n@816
|
23 fclose($fileHandle);
|
n@820
|
24
|
n@820
|
25 // Return JSON confirmation data
|
n@820
|
26 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
|
n@820
|
27 echo $xml;
|
n@816
|
28 ?> |