diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2013-02-20 02:09:51 -0800 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2013-02-20 02:09:51 -0800 |
commit | cca5872bd5f6e50626faedd42fc298cef0b001db (patch) | |
tree | 459251a467feceead625036c91ff5903a1456383 /ajax/users.ajax.php | |
parent | 7ae48075590b09e4892daf1e218ef32c6717bfc0 (diff) | |
download | pathery-cca5872bd5f6e50626faedd42fc298cef0b001db.tar.xz |
Switched to PHP 5.4 . Added domain/user/id.js to the url rewrite. Added users.ajax.php
Diffstat (limited to 'ajax/users.ajax.php')
-rw-r--r-- | ajax/users.ajax.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/ajax/users.ajax.php b/ajax/users.ajax.php new file mode 100644 index 0000000..7ee9cc2 --- /dev/null +++ b/ajax/users.ajax.php @@ -0,0 +1,54 @@ +<?
+ob_start("ob_gzhandler");
+
+//include('../includes/mapclass.php');
+//include('../includes/maps.php');
+include_once('../includes/sqli.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;
+}
+
+?>
\ No newline at end of file |