To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / save.php

History | View | Annotate | Download (962 Bytes)

1
<?php
2
        // error_reporting(0);
3
        $saveFilenamePrefix = isset($_GET['saveFilenamePrefix']) ? $_GET['saveFilenamePrefix'].'-' : '';
4
        header('Access-Control-Allow-Origin: *');
5
        header("Content-type: text/xml");
6
        $postText = file_get_contents('php://input');
7
    $file_key = $_GET['key'];
8
    $filename = 'saves/'.$saveFilenamePrefix.'save-'.$file_key.".xml";
9
        $fileHandle = fopen($filename, 'w');
10
        if ($fileHandle == FALSE)
11
        {
12
                // Filehandle failed
13
                $xml = '<response state="error"><message>Could not open file</message></response>';
14
                echo $xml;
15
                return;
16
        }
17
        $wbytes = fwrite($fileHandle, $postText);
18
        if ($wbytes === FALSE)
19
        {
20
                // FileWrite failed
21
                $xml = '<response state="error"><message>Could not write file "'.$filename.'"</message></response>';
22
                echo $xml;
23
                return;
24
        }
25
        fclose($fileHandle);
26
        
27
        // Return XML confirmation data
28
        $xml = '<response state="OK"><message>OK</message><file bytes="'.$wbytes.'">"'.$filename.'"</file></response>';
29
        echo $xml;
30
?>