view save.php @ 1116:c44fbf72f7f2

All interfaces support comment boxes. Comment box identification matches presented tag (for instance, AB will be Comment on fragment A, rather than 1). Tighter buffer loading protocol, audioObjects register with the buffer rather than checking for buffer existence (which can be buggy depending on the buffer state). Buffers now have a state to ensure exact location in loading chain (downloading, decoding, LUFS, ready).
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 29 Jan 2016 11:11:57 +0000
parents
children 2647dd909229 b5bf2f57187c 9ee921c8cdd3
line wrap: on
line source
<?php
	header('Access-Control-Allow-Origin: *');
	header("Content-type: text/xml");
	$postText = file_get_contents('php://input');
	$sha1_hash = sha1($postText);
	$datetime = date('ymdHis');
	$xmlfile = "save".$datetime."-".$sha1_hash.".xml";
	$fileHandle = fopen("saves/".$xmlfile, '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 "saves/'.$xmlfile.'"</message></response>';
		echo $xml;
		return;
	}
	fclose($fileHandle);
	
	// Return JSON confirmation data
	$xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"saves/'.$xmlfile.'"</file></response>';
	echo $xml;
?>