blob: b95d22ed0c94ef8a1bae204cf079dfe6f8a36134 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<?
// Session as read-only to not lock the file.
session_start();
session_write_close();
$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;
}
return $r;
}
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;
}
?>
|