diff options
Diffstat (limited to 'includes/datas.php')
-rw-r--r-- | includes/datas.php | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/includes/datas.php b/includes/datas.php index a9f3b3c..e8e24a3 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -3,6 +3,7 @@ // include_once('sqlEmbedded.php'); +include_once('constants.php'); //FirePHP stuff - TODO: Delete //require_once('includes/FirePHPCore/FirePHP.class.php'); @@ -114,7 +115,7 @@ function getNotified($userID) { $aTypeCurrency[1] = "total moves mazed"; $aTypeCurrency[2] = "mazes played"; $aTypeCurrency[3] = "mazes with (tied) top score"; - $aTypeCurrency[4] = "challenge points"; + $aTypeCurrency[4] = "champion points"; $aName = $aTypeNames[$aType]; $currency = $aTypeCurrency[$aType]; @@ -303,8 +304,6 @@ function applyCareerMazesAchievements($userID) { */ function getCompletedChallenges($userID, $mapID, $solution, $moves, $paths) { //mapID 5 is the tutorial, and is treated specially - //$firephp = FirePHP::getInstance(true); - //$firephp->log("In challenges"); //TODO: Fix / depreciate this. Re-adapt tutorial // Temporary Hack to complete the tutorial... @@ -315,25 +314,17 @@ function getCompletedChallenges($userID, $mapID, $solution, $moves, $paths) { // return; // } - //$firephp->log($mapID, "mapID"); - //$firephp->log($userID, "userID"); - $challengeResultset = loadChallengesForMap($mapID, $userID); $challengesCompleted = array(); while($challenge = mysql_fetch_array($challengeResultset)) { - //$firephp->log("Checking a challenge"); - //$firephp->log("Checking challenge number" . $challenge['challengeID']); - //$firephp->log($challenge["dateSolved"], "dateCompleted"); //Skip checking challenges which have already been completed if($challenge["dateSolved"] !== NULL) { - //$firephp->log('Challenge was already completed'); $challengesCompleted[] = $challenge["challengeID"]; } else if(hasChallengeBeenCompleted($challenge, $solution, $moves, $paths)) { - //$firephp->log('Challenge was completed!'); setChallengeCompleted($challenge, $solution, $userID, $moves); $challengesCompleted[] = $challenge["challengeID"]; } @@ -520,9 +511,7 @@ function setChallengeCompleted($challenge, $solution, $userID, $moves) { mysql_query($sql); } - function isChallengeMap($mapID) { - include_once('./includes/sqlEmbedded.php'); $sql = "SELECT ID FROM `challengeMaps` WHERE @@ -532,6 +521,31 @@ function isChallengeMap($mapID) { return (mysql_num_rows($result) != 0); } +function getUserChallengeTier($userID) +{ + $userID = mysql_escape_string($userID); + + $sql = "SELECT challengeTier + FROM users + WHERE users.ID = '$userID'"; + + $result = mysql_query($sql); + $row = mysql_fetch_row($result); + return $row[0]; +} + +function setUserChallengeTier($userID, $challengeTier) +{ + $userID = mysql_escape_string($userID); + $challengeTier = mysql_escape_string($challengeTier); + + $sql = "UPDATE users + SET challengeTier = '$challengeTier' + WHERE users.ID = '$userID'"; + + mysql_query($sql); +} + function applyAchievements($userID, $aType) { $amount = getAchievementCurrency($userID, $aType); @@ -1034,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"; @@ -1078,13 +1094,14 @@ function loadChallengeListing($userIdUnsanitized) { $userID = mysql_escape_string($userIdUnsanitized); - $sql = " SELECT challengeMaps.ID AS challengeMapID, challengeMaps.challengeTier, challengeMaps.name AS name, + $sql = "SELECT challengeMaps.ID AS challengeMapID, challengeMaps.challengeTier, challengeMaps.name AS name, challengeSolutions.dateSolved, challengeSolutions.challengeID AS challengeID, challengeMaps.challengeSuborder, challenges.ordering, challengeMaps.code as mapCode FROM challenges - LEFT JOIN challengeMaps ON challenges.mapID = challengeMaps.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 challengeMaps.challengeTier <= (SELECT challengeTier FROM users WHERE ID = '$userID' LIMIT 1) ORDER BY challengeMaps.challengeTier, challengeMaps.challengeSuborder, challenges.ordering"; $result = mysql_query($sql) OR die(mysql_error()."SQL: $sql"); |