diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2011-04-21 12:11:22 -0700 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2011-04-21 12:11:22 -0700 |
commit | 257e02d25a629a1b6d6fbb133b38b06dcfbc7777 (patch) | |
tree | 1462cb26eaef680a2e314cd79520902d4d0db82b /app.php | |
parent | 5c76c4160bff16cdd3494736033b427e76d76e73 (diff) | |
download | pathery-257e02d25a629a1b6d6fbb133b38b06dcfbc7777.tar.xz |
Support for shaped maps.
A lot of additions and changes, specifically regarding how the map is pathed and generated. Removing some assumptions for actual code.
Diffstat (limited to 'app.php')
-rw-r--r-- | app.php | 80 |
1 files changed, 80 insertions, 0 deletions
@@ -9,6 +9,86 @@ include "includes/datas.php"; //echo "working...";
+if ($_GET['act'] == "test") {
+
+//header('Content-Type: text/xml');
+header("Content-Type: text/plain");
+
+if ($_POST['XMLRequest']) {
+ $string = $_POST['XMLRequest'];
+} else {
+ $string = '<!-- request -->
+<BrainMazeAPI version="0.1">
+ <APIRequest>
+ <SubmitScore>
+ <MapID>5</MapID>
+ <Username>FiftyToo</Username>
+ <Score>50</Score>
+ </SubmitScore>
+ </APIRequest>
+</BrainMazeAPI>';
+}
+
+$xml = simplexml_load_string($string);
+
+//echo $xml->APIRequest->SubmitScore->MapID;
+//print_r ($xml);
+
+
+
+
+$score = $xml->APIRequest[0]->SubmitScore[0]->Score;
+$username = $xml->APIRequest[0]->SubmitScore[0]->Username;
+
+//echo $xml->getName() . "<br />";
+// foreach($xml->children() as $child) {
+// echo $child->getName() . ": " . $child . "<br />";
+// }
+
+
+//$score = 50;
+$previousScore = 49;
+$rank = 1;
+
+//Begin XML Response
+$w = new XMLWriter();
+$w->openMemory();
+$w->startDocument('1.0','UTF-8');
+$w->startElement("BrainMazeAPI");
+ $w->writeAttribute("version", "0.1");
+ $w->startElement("APIResponse");
+ $w->startElement("SubmitScore");
+ $w->writeAttribute("result", "SUCCESS");
+
+ $w->startElement("rank");
+ $w->text($rank);
+ $w->endElement();
+
+ $w->startElement("update");
+ $w->text('true');
+ $w->endElement();
+
+ $w->startElement("UsernameUsed");
+ $w->text($username);
+ $w->endElement();
+
+ $w->startElement("SubmittedScore");
+ $w->text($score);
+ $w->endElement();
+
+ $w->startElement("PreviousHighScore");
+ $w->text($previousScore);
+ $w->endElement();
+
+ $w->endElement();
+ $w->endElement();
+$w->endElement();
+echo $w->outputMemory(true);
+
+}
+
+
+
if ($_GET['act'] == "submit") {
header('Content-Type: text/xml');
echo '<!-- response -->
|