diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/datas.php | 57 |
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; +} ?> |