summaryrefslogtreecommitdiffstats
path: root/includes/datas.php
diff options
context:
space:
mode:
authorBlueRaja <BlueRaja.admin@gmail.com>2012-08-27 00:36:38 -0500
committerBlueRaja <BlueRaja.admin@gmail.com>2012-08-27 00:36:38 -0500
commit79d84f2040068424994eecf542fee3686849845c (patch)
treee785a3fc0280a61fade600e4ead8b649aaec14ec /includes/datas.php
parent9f7611ee27cec55de6c697312389d8fd0bc072ff (diff)
downloadpathery-79d84f2040068424994eecf542fee3686849845c.tar.xz
Created remanants of a challenge page (loaded completely from the database). Kept the old challenge page, because Snap will probably want to reuse the Javascript.
Diffstat (limited to 'includes/datas.php')
-rw-r--r--includes/datas.php57
1 files changed, 56 insertions, 1 deletions
diff --git a/includes/datas.php b/includes/datas.php
index 61c8b93..170f74e 100644
--- a/includes/datas.php
+++ b/includes/datas.php
@@ -723,7 +723,62 @@ function getScores($mapid, $pageNumber = 1, $pageDivide = 10) {
}
+/**
+ * Returns true if the given user has completed the tutorial, false otherwise
+ */
+function hasCompletedTutorial($userID) {
+ $sql = "SELECT * FROM `achievements`
+ WHERE `type` = 32 AND `userID` = '$userID'";
+ $result = mysql_query($sql);
+ return (mysql_num_rows($result) >= 1);
+}
+/**
+ * Returns a MySQL resultset for all challenges for the given mapID
+ * @param $mapIdUnsanitized The mapID to load. Assumed to be unsanitized.
+ * @param $userID The userID. Assumed to be unsanitized
+ * @return Returns a MySQL resultset with the columns listed in the code, or NULL if nothing found
+ */
+function loadChallengesForMap($mapIdUnsanitized, $userIdUnsanitized)
+{
+ $mapID = mysql_escape_string($mapIdUnsanitized);
+ $userID = mysql_escape_string($userIdUnsanitized);
+ $sql = "
+ SELECT challenges.ID AS challengeID, challenges.inequality, challenges.goal, challenges.hint,
+ challenges.restrictWallCount, challenges.restrictWallPlacement, challenges.restrictTeleportCount,
+ challenges.restrictTeleportsUsed, challenges.restrictStartPoint, challenges.restrictEndPoint,
+ challengeSolutions.dateSolved
+ FROM challenges
+ LEFT JOIN challengeSolutions ON challenges.ID = challengeSolutions.challengeID AND challengeSolutions.userID = '$userID'
+ WHERE challenges.mapID = '$mapID' AND challenges.enabled = 1
+ ";
+
+ $result = mysql_query($sql);
+ echo mysql_error();
+ if (mysql_num_rows($result) >= 1)
+ return $result;
+ return NULL;
+}
-
+/**
+ * Returns the map "code" for the given mapId
+ */
+function loadMapCode($mapIdUnsanitized)
+{
+ $mapID = mysql_escape_string($mapIdUnsanitized);
+ $sql = "
+ SELECT maps.code as code
+ FROM maps
+ WHERE ID = '$mapID' AND isChallenge = 1
+ LIMIT 1
+ ";
+
+ $result = mysql_query($sql);
+ if (mysql_num_rows($result) >= 1)
+ {
+ $temp = mysql_fetch_row($result);
+ return $temp[0];
+ }
+ return NULL;
+}
?>