diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2013-02-17 03:08:22 -0800 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2013-02-17 03:08:22 -0800 |
commit | 1ca6e18e28e8f87e3c77e824034d186aff1686aa (patch) | |
tree | a525ac527483d53e2c539b6c4ea97c0ae5ecf3a3 /ajax/challenges.ajax.php | |
parent | e6ecd5ae507731050d7281f2a2a192849f41912b (diff) | |
download | pathery-1ca6e18e28e8f87e3c77e824034d186aff1686aa.tar.xz |
Challenge maps can be accessed with domain/challenge/ID.js
Diffstat (limited to 'ajax/challenges.ajax.php')
-rw-r--r-- | ajax/challenges.ajax.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ajax/challenges.ajax.php b/ajax/challenges.ajax.php new file mode 100644 index 0000000..68d6ae3 --- /dev/null +++ b/ajax/challenges.ajax.php @@ -0,0 +1,35 @@ +<?
+ob_start("ob_gzhandler");
+
+include('../includes/mapclass.php');
+include('../includes/maps.php');
+
+//Remove the ending .js
+$tmp = explode(".", $_GET['challengeid']);
+$challengeID = $tmp[0] * 1;
+if (!is_int($challengeID)) exit;
+
+$map = new map(getChallengeCode($challengeID), $challengeID);
+
+
+function getChallengeCode($challengeID) {
+ include_once('../includes/sqlEmbedded.php');
+ $sql = "SELECT `code`
+ FROM `challengeMaps`
+ WHERE `ID` = '$challengeID'
+ ";
+ $result = mysql_query($sql);
+ if (mysql_num_rows($result) > 0) {
+ list($map) = mysql_fetch_row($result);
+ return $map;
+ }
+}
+
+//62 days
+$expires = 62*24*60*60;
+// header("Cache-Control: public, maxage=".$expires);
+// header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
+// header("Content-type: text/javascript");
+echo json_encode($map);
+
+?>
\ No newline at end of file |