summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.htaccess4
-rw-r--r--ajax/users.ajax.php54
2 files changed, 57 insertions, 1 deletions
diff --git a/.htaccess b/.htaccess
index e85e1f5..c8a1820 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,4 +1,4 @@
-AddType x-mapp-php5 .php
+AddHandler x-mapp-php6 .php
ErrorDocument 400 http://www.mazetd.4xg.net/errors.php?error=400
ErrorDocument 401 http://www.mazetd.4xg.net/errors.php?error=401
@@ -21,6 +21,8 @@ RewriteRule ^map/(.*)$ /ajax/maps\.ajax\.php?mapid=$1 [QSA,NC]
RewriteRule ^challenge/(.*)$ /ajax/challenges\.ajax\.php?challengeid=$1 [QSA,NC]
+RewriteRule ^user/(.*)$ /ajax/users\.ajax\.php?userid=$1 [QSA,NC]
+
# CSS and JS cache for 480 weeks
<filesMatch "\.(css|js)$">
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