summaryrefslogtreecommitdiffstats
path: root/ajax
diff options
context:
space:
mode:
Diffstat (limited to 'ajax')
-rw-r--r--ajax/scores.ajax.php61
1 files changed, 56 insertions, 5 deletions
diff --git a/ajax/scores.ajax.php b/ajax/scores.ajax.php
index 2b27ca2..b95d22e 100644
--- a/ajax/scores.ajax.php
+++ b/ajax/scores.ajax.php
@@ -1,20 +1,71 @@
<?
+// Session as read-only to not lock the file.
session_start();
session_write_close();
-//Just doing this as evidence that $_SESSION as read-only is still available.
+
$userID = $_SESSION['userID'];
require('../includes/maps.php');
require('../includes/mapclass.php');
require('../includes/datas.php');
+if ($_GET['getmap'] == 'true') {
+ $mapID = $_GET['mapID'];
+ $code = getMapCode($mapID);
+ $map = GenerateMapByCode($code);
+ echo displaymap($map, $mapID);
+}
+
+
+if ($_GET['getscores'] == 'true') {
+
+}
+
+if ($_GET['getmaplist'] == 'true') {
+ $daysAgo = $_GET['daysago'];
+ //echo "$daysAgo";
+ $todaysScoreMaps = getMapsPlayed($daysAgo);
+ echo getMapNavigation($todaysScoreMaps);
+}
+
+
+function getMapsPlayed($daysAgo) {
+ $sql = "
+ SELECT `mapID`, `code`, `mapType`
+ FROM `mapOfTheDay`
+ INNER JOIN `maps` ON `mapID` = maps.ID
+ WHERE DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
+ mapDate AND
+ `mapType` IN (1, 2, 3, 4)
+ ";
+ $result = mysql_query($sql) or die(mysql_error());
+ if (mysql_num_rows($result) == 0)
+ return -1;
+ global $mapNamesByType;
+ $r = array();
+ while($data = mysql_fetch_array($result)) {
+ $code = $data['code'];
+ $mapID = $data['mapID'];
+ $mapType = $data['mapType'];
+ $map = new map($code);
+ if ($map->name == '')
+ $map->name = $mapNamesByType[$mapType];
+ $r[$mapID] = $map;
-$mapID = $_GET['mapID'];
+ }
+ return $r;
+}
-$code = getMapCode($mapID);
-$map = GenerateMapByCode($code);
-echo displaymap($map, $mapID);
+function getMapNavigation(&$maps) {
+ foreach ($maps as $mapID => &$map) {
+ $r .= "<div class='mapThumbnail' onclick='displayMap($mapID)'>";
+ $r .= $map->name;
+ $r .= DisplayMapThumbnail($map);
+ $r .= "</div>";;
+ }
+ return $r;
+}