diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/datas.php | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/includes/datas.php b/includes/datas.php index 11a130c..e8e24a3 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -304,12 +304,15 @@ function applyCareerMazesAchievements($userID) { */ function getCompletedChallenges($userID, $mapID, $solution, $moves, $paths) { //mapID 5 is the tutorial, and is treated specially - if($mapID <= 10) { + + //TODO: Fix / depreciate this. Re-adapt tutorial + // Temporary Hack to complete the tutorial... + // if($mapID <= 10) { if ($mapID == 5 && $moves == 75) { onCompletedTutorial($userID); } - return; - } + // return; + // } $challengeResultset = loadChallengesForMap($mapID, $userID); $challengesCompleted = array(); @@ -510,9 +513,9 @@ function setChallengeCompleted($challenge, $solution, $userID, $moves) { function isChallengeMap($mapID) { $sql = "SELECT ID - FROM `maps` + FROM `challengeMaps` WHERE - ID = '$mapID' AND `isChallenge` = true; + ID = '$mapID'; "; $result = mysql_query($sql) or die(mysql_error()); return (mysql_num_rows($result) != 0); @@ -1045,6 +1048,8 @@ function getScores($mapID, $pageNumber = 1, $pageDivide = 10) { * Returns true if the given user has completed the tutorial, false otherwise */ function hasCompletedTutorial($userID) { + $userID = mysql_escape_string($userID); + $sql = "SELECT `level` FROM `achievements` WHERE `type` = 32 AND `userID` = '$userID' LIMIT 1"; @@ -1089,18 +1094,17 @@ function loadChallengeListing($userIdUnsanitized) { $userID = mysql_escape_string($userIdUnsanitized); - $sql = " SELECT maps.ID AS mapID, maps.challengeTier, maps.name AS name, + $sql = "SELECT challengeMaps.ID AS challengeMapID, challengeMaps.challengeTier, challengeMaps.name AS name, challengeSolutions.dateSolved, challengeSolutions.challengeID AS challengeID, - maps.challengeSuborder, challenges.ordering + challengeMaps.challengeSuborder, challenges.ordering, challengeMaps.code as mapCode FROM challenges - INNER JOIN maps ON challenges.mapID = maps.ID + INNER JOIN challengeMaps ON challenges.mapID = challengeMaps.ID LEFT JOIN challengeSolutions ON challenges.ID = challengeSolutions.challengeID AND challengeSolutions.userID = '$userID' WHERE challenges.enabled = 1 - AND maps.challengeTier <= (SELECT challengeTier FROM users WHERE ID = '$userID') - ORDER BY maps.challengeTier, maps.challengeSuborder, challenges.ordering"; + AND challengeMaps.challengeTier <= (SELECT challengeTier FROM users WHERE ID = '$userID' LIMIT 1) + ORDER BY challengeMaps.challengeTier, challengeMaps.challengeSuborder, challenges.ordering"; - $result = mysql_query($sql); - echo mysql_error(); + $result = mysql_query($sql) OR die(mysql_error()."SQL: $sql"); if (mysql_num_rows($result) >= 1) return $result; return NULL; @@ -1109,13 +1113,13 @@ function loadChallengeListing($userIdUnsanitized) /** * Returns the map "code" for the given mapId */ -function loadMapCode($mapIdUnsanitized) +function loadChallengeMapCode($mapIdUnsanitized) { - $mapID = mysql_escape_string($mapIdUnsanitized); + $ID = mysql_escape_string($mapIdUnsanitized); $sql = " - SELECT maps.code as code - FROM maps - WHERE ID = '$mapID' AND isChallenge = 1 + SELECT challengeMaps.code as code + FROM challengeMaps + WHERE ID = '$ID' LIMIT 1 "; |