Mercurial > hg > webaudioevaluationtool
view php/save.php @ 2524:dde81c372fdc
Merge score_parser2 into score_parser
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Tue, 08 Nov 2016 09:58:31 +0000 |
parents | d26623bd65e0 |
children | 464c6c6692d6 |
line wrap: on
line source
<?php header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); error_reporting(0); $saveFilenamePrefix = isset($_GET['saveFilenamePrefix']) ? $_GET['saveFilenamePrefix'].'-' : ''; header('Access-Control-Allow-Origin: *'); header("Content-type: text/xml"); $postText = file_get_contents('php://input'); $file_key = $_GET['key']; $filename = '../saves/'.$saveFilenamePrefix.'save-'.$file_key.".xml"; $doc = new DOMDocument; $doc->preserveWhiteSpace = false; $doc->formatOutput = true; $doc->loadXML($postText); $postText = $doc->saveXML(); $fileHandle = fopen($filename, 'w'); if ($fileHandle == FALSE) { // Filehandle failed $xml = '<response state="error"><message>Could not open file</message></response>'; echo $xml; return; } $wbytes = fwrite($fileHandle, $postText); if ($wbytes === FALSE) { // FileWrite failed $xml = '<response state="error"><message>Could not write file "'.$filename.'"</message></response>'; echo $xml; return; } fclose($fileHandle); // Return XML confirmation data $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"'.$filename.'"</file></response>'; echo $xml; ?>