summaryrefslogtreecommitdiffstats
path: root/ajax/maps.ajax.php
diff options
context:
space:
mode:
Diffstat (limited to 'ajax/maps.ajax.php')
-rw-r--r--ajax/maps.ajax.php62
1 files changed, 49 insertions, 13 deletions
diff --git a/ajax/maps.ajax.php b/ajax/maps.ajax.php
index 611080d..8ceade5 100644
--- a/ajax/maps.ajax.php
+++ b/ajax/maps.ajax.php
@@ -3,21 +3,35 @@ ob_start("ob_gzhandler");
include('../includes/mapclass.php');
include('../includes/maps.php');
+include('../includes/sqlEmbedded.php');
-//Remove the ending .js
-$tmp = explode(".", $_GET['mapid']);
-$mapID = $tmp[0] * 1;
-if (!is_int($mapID)) exit;
-
-$map = getMapObjectByID($mapID);
+if (isset($_GET['getmapidsbydate'])) {
+ //Remove the ending .js
+ $tmp = explode(".", $_GET['getmapidsbydate']);
+ $requestDate = $tmp[0];
+ sendCacheHeaders();
+ echo json_encode(getMapIDsByDate($requestDate));
+ exit;
+}
+if (isset($_GET['mapid'])) {
+ //Remove the ending .js
+ $tmp = explode(".", $_GET['mapid']);
+ $mapID = $tmp[0] * 1;
+ if (!is_int($mapID)) exit;
+ $map = getMapObjectByID($mapID);
+ sendCacheHeaders();
+ echo json_encode($map);
+ exit;
+}
-$expires = 365*24*60*60;
-//TODO: Remove this line once we're confident in data in the mapObject.
-$expires = 1*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);
+function sendCacheHeaders() {
+ $expires = 365*24*60*60;
+ //TODO: Remove this line once we're confident in data in the mapObject.
+ $expires = 120;
+ header("Cache-Control: public, maxage=".$expires);
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
+ header("Content-type: text/javascript");
+}
function getMapObjectByID($mapID) {
include_once('../includes/sqlEmbedded.php');
@@ -37,5 +51,27 @@ function getMapObjectByID($mapID) {
}
}
+function getMapIDsByDate($date) {
+ global $mysqli;
+ $sql = "SELECT MIN(mapOfTheDay.mapId) AS mapId
+ FROM `mapOfTheDay`
+ INNER JOIN
+ (
+ SELECT mapType, MIN(mapExpireTime) AS mapExpireTime
+ FROM mapOfTheDay
+ WHERE mapExpireTime > ?
+ GROUP BY mapType
+ ) AS expireTimes ON mapOfTheDay.mapType = expireTimes.mapType
+ AND mapOfTheDay.mapExpireTime = expireTimes.mapExpireTime
+ GROUP BY mapOfTheDay.mapType";
+ $stmt = $mysqli->prepare($sql);
+ $stmt->bind_param("s", $date);
+ $stmt->execute();
+ $stmt->bind_result($mapID);
+ while ($stmt->fetch()) {
+ $ids[] = $mapID;
+ }
+ return $ids;
+}
?> \ No newline at end of file