diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2013-05-01 01:54:08 -0700 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2013-05-01 01:54:08 -0700 |
commit | 51d99728286212717003009dd5706bb74edcb272 (patch) | |
tree | 5aff9d44e5856dd256020811943f9231ccfdb225 /ajax | |
parent | 95d067a02b4a979f0ff3b23291d0b3b9718f615e (diff) | |
download | pathery-51d99728286212717003009dd5706bb74edcb272.tar.xz |
Challengesss Challenges... DB Updates. Challenges
Diffstat (limited to 'ajax')
-rw-r--r-- | ajax/challenges.ajax.php | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/ajax/challenges.ajax.php b/ajax/challenges.ajax.php index f27f3bb..cac9e75 100644 --- a/ajax/challenges.ajax.php +++ b/ajax/challenges.ajax.php @@ -6,7 +6,7 @@ include('../includes/maps.php'); include_once('../includes/sqlEmbedded.php');
if ($_GET['getChallengeIDs'] == 'true') {
- echo getChallengesByTier($_GET['userID']);
+ echo getChallengesByTier($_GET['tier'], $_GET['userID']);
exit;
}
@@ -50,10 +50,11 @@ function getChallengeCode($challengeID) { -function getChallengesByTier($userIdUnsanitized) {
+function getChallengesByTier($tierUnsanitized, $userIdUnsanitized) {
include_once('../includes/sqlEmbedded.php');
$userID = mysql_escape_string($userIdUnsanitized);
+ $tier = mysql_escape_string($tierUnsanitized);
$sql = "SELECT challengeMaps.ID AS challengeMapID, challengeMaps.challengeTier, challengeMaps.name AS name,
challengeSolutions.dateSolved, challengeSolutions.challengeID AS challengeID,
@@ -62,12 +63,17 @@ function getChallengesByTier($userIdUnsanitized) { 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) OR 1
+ AND challengeMaps.challengeTier = '$tier'
ORDER BY challengeMaps.challengeTier, challengeMaps.challengeSuborder, challenges.ordering";
+ //AND challengeMaps.challengeTier <= (SELECT challengeTier FROM users WHERE ID = '$userID' LIMIT 1) OR 1
+
$result = mysql_query($sql) OR die(mysql_error()."SQL: $sql");
if (mysql_num_rows($result) >= 1) {
- while($data = mysql_fetch_array($result)) {
+ $i = 0;
+ //$layer['x'] = '';
+ while($data = mysql_fetch_assoc($result)) {
+ $i++;
//echo $data['challengeMapID'];
$tier = $data['challengeTier'];
$challengeSuborder = $data['challengeSuborder'];
@@ -79,8 +85,10 @@ function getChallengesByTier($userIdUnsanitized) { $mapObj = new map($data['mapCode']);
$mapObj->ID = $challengeMapID;
- $layer[$data['challengeMapID']][$challengeID] = $data;
- $layer[$data['challengeMapID']]['mapObject'] = $mapObj;
+ $layer['CM'.$data['challengeMapID']][$challengeID] = $data;
+ $layer['CM'.$data['challengeMapID']]['mapObject'] = $mapObj;
+ $challenges = getChallenges($data['challengeMapID'], $userID);
+ $layer['CM'.$data['challengeMapID']]['challenges'] = $challenges;
//$layer[] = $data;
}
return json_encode($layer);
@@ -112,7 +120,8 @@ function loadChallengesForMap($mapIdUnsanitized, $userIdUnsanitized) 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
+ challengeSolutions.dateSolved,
+ challenges.dialogStart, challenges.dialogFail, challenges.dialogSuccess
FROM challenges
LEFT JOIN challengeSolutions ON challenges.ID = challengeSolutions.challengeID AND challengeSolutions.userID = '$userID'
WHERE challenges.mapID = '$mapID' AND challenges.enabled = 1
|