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
|
<?
ob_start("ob_gzhandler");
//include('../includes/mapclass.php');
//include('../includes/maps.php');
include_once('../includes/sqlEmbedded.php');
//Remove the ending .js
$tmp = explode(".", $_GET['userid']);
$userID = $tmp[0] * 1;
if (!is_int($userID)) exit;
$user = getUserObjectByID($userID);
//$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($user);
exit;
function getUserObjectByID($userID) {
global $mysqli;
$sql = " SELECT
users.ID as ID,
users.displayName as display,
users.totalMoves,
(
SELECT IFNULL(SUM(moves),0)
FROM solutions
INNER JOIN mapOfTheDay ON solutions.mapID = mapOfTheDay.mapID
WHERE solutions.userID = users.ID
AND mapOfTheDay.mapExpireTime BETWEEN DATE_SUB(NOW(), INTERVAL 7 DAY) AND NOW()
) AS totalMovesThisWeek,
users.championPoints as championPoints,
users.totalMazes as totalMazes,
users.totalWins as totalWins,
users.totalTies as totalTies,
users.wallColor,
users.displayColor,
users.wallEmblem,
UNIX_TIMESTAMP(users.datejoined) as dateJoined,
UNIX_TIMESTAMP(users.dateLogin) as dateLogin
FROM `users`
WHERE users.ID = '$userID'
";
$result = $mysqli->query($sql);
$row = $result->fetch_array(MYSQLI_ASSOC);
return $row;
}
?>
|