annotate save.php @ 637:df6c09f5835d Dev_main

Implemented Bug/Feature #1649. Edit the exit text by modifying <exitText>, see mushra_example.xml for example.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Tue, 22 Mar 2016 13:44:59 +0000
parents 0794fefefbd8
children 0256f3748b27
rev   line source
n@292 1 <?php
giuliomoro@583 2 error_reporting(0);
b@343 3 header('Access-Control-Allow-Origin: *');
nicholas@345 4 header("Content-type: text/xml");
n@292 5 $postText = file_get_contents('php://input');
n@589 6 $file_key = $_GET['key'];
n@589 7 $filename = "saves/save-".$file_key.".xml";
n@589 8 $fileHandle = fopen($filename, 'w');
nicholas@345 9 if ($fileHandle == FALSE)
nicholas@345 10 {
nicholas@345 11 // Filehandle failed
nicholas@345 12 $xml = '<response state="error"><message>Could not open file</message></response>';
nicholas@345 13 echo $xml;
nicholas@345 14 return;
nicholas@345 15 }
nicholas@345 16 $wbytes = fwrite($fileHandle, $postText);
giuliomoro@556 17 if ($wbytes === FALSE)
nicholas@345 18 {
nicholas@345 19 // FileWrite failed
n@600 20 $xml = '<response state="error"><message>Could not write file "'.$filename.'"</message></response>';
nicholas@345 21 echo $xml;
nicholas@345 22 return;
nicholas@345 23 }
n@292 24 fclose($fileHandle);
nicholas@345 25
n@600 26 // Return XML confirmation data
n@600 27 $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"'.$filename.'"</file></response>';
nicholas@345 28 echo $xml;
n@600 29 ?>