Mercurial > hg > webaudioevaluationtool
comparison php/save.php @ 2320:ae69e61a6b76
#46 PHP server now beautifies incoming XMLs. Could solve future #25 errors.
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Fri, 29 Apr 2016 16:40:13 +0100 |
parents | 760719986df3 |
children | d347dbab980d |
comparison
equal
deleted
inserted
replaced
2319:6897339ac651 | 2320:ae69e61a6b76 |
---|---|
3 header('Access-Control-Allow-Origin: *'); | 3 header('Access-Control-Allow-Origin: *'); |
4 header("Content-type: text/xml"); | 4 header("Content-type: text/xml"); |
5 $postText = file_get_contents('php://input'); | 5 $postText = file_get_contents('php://input'); |
6 $file_key = $_GET['key']; | 6 $file_key = $_GET['key']; |
7 $filename = "../saves/save-".$file_key.".xml"; | 7 $filename = "../saves/save-".$file_key.".xml"; |
8 $doc = new DOMDocument; | |
9 $doc->preserveWhiteSpace = false; | |
10 $doc->formatOutput = true; | |
11 $doc->loadXML($postText); | |
12 $postText = $doc->saveXML(); | |
8 $fileHandle = fopen($filename, 'w'); | 13 $fileHandle = fopen($filename, 'w'); |
9 if ($fileHandle == FALSE) | 14 if ($fileHandle == FALSE) |
10 { | 15 { |
11 // Filehandle failed | 16 // Filehandle failed |
12 $xml = '<response state="error"><message>Could not open file</message></response>'; | 17 $xml = '<response state="error"><message>Could not open file</message></response>'; |