summaryrefslogtreecommitdiffstats
path: root/ajax/challenges.ajax.php
blob: 68d6ae3fab51d9ab307c8843c2efda1e2b47acbc (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
<?
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);

?>