To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / keygen.php
History | View | Annotate | Download (1.25 KB)
| 1 |
<?php
|
|---|---|
| 2 |
// This checks the key sent by the JavaScript against the current bunch of saves
|
| 3 |
// XML Saves location - assumes it will be saves/
|
| 4 |
$saves = glob("saves/*.xml"); |
| 5 |
|
| 6 |
$key_requested = $_GET['key']; |
| 7 |
|
| 8 |
$xml_good = "<response><state>OK</state><key>".$key_requested."</key></response>"; |
| 9 |
$xml_bad = "<response><state>NO</state><key>".$key_requested."</key></response>"; |
| 10 |
$xml_error = "<response><state>ERROR</state><key>".$key_requested."</key></response>"; |
| 11 |
if (is_array($saves)) |
| 12 |
{
|
| 13 |
foreach($saves as $filename) { |
| 14 |
$xml_string = file_get_contents($filename, FILE_TEXT); |
| 15 |
$xml_object = simplexml_load_string($xml_string); |
| 16 |
if ($xml_object != false) { |
| 17 |
if (isset($value['key'])) |
| 18 |
{
|
| 19 |
if ($value['key'] == $key_requested) { |
| 20 |
echo $xml_bad; |
| 21 |
return;
|
| 22 |
} |
| 23 |
} |
| 24 |
} |
| 25 |
} |
| 26 |
echo $xml_good; |
| 27 |
// TODO:
|
| 28 |
// Generate the XML Base file and save it
|
| 29 |
$doc_struct = new SimpleXMLElement('<waetresult/>'); |
| 30 |
$doc_struct->addAttribute("key",$key_requested); |
| 31 |
// Add start time
|
| 32 |
// Add IP Address information
|
| 33 |
// Save the file
|
| 34 |
$doc_struct->asXML("saves/save-".$key_requested.".xml"); |
| 35 |
return;
|
| 36 |
} else {
|
| 37 |
echo $xml_error; |
| 38 |
return;
|
| 39 |
} |
| 40 |
?>
|