blob: f3b6da69d2af5af3d376a9b458cd208799c4c74c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
<?php
require_once("inc/messages.inc");
define("SAVEDIR", "data/save");
function genXML($v, $k, $xml) {
if(is_object($v))
{
if(is_callable(array($v, "addToXML")))
$v->addToXML($xml->addChild($k));
}
else
$xml->addChild($k, $v);
}
function genSave() {
header("Content-Type: application/xml");
$save = new SimpleXMLElement("<save/>");
array_walk_recursive($_SESSION, "genXML", $save);
return $save;
echo $save->asXML();
}
function genFilename() {
return "craftmine-".date("d-m-Y_H-i-s").".save.xml";
}
function saveGame() {
$save = genSave();
if($save->asXML(SAVEDIR."/".genFilename())) sendInfo("gamesave_ok");
else sendError("gamesave_error");
}
function downSave() {
$save = genSave();
header("Content-Type: application/xml");
header("Content-Disposition: attachment; filename=".genFilename());
header("Pragma: no-cache");
echo $save->asXML();
}
?>
|