From fbfa53d3120bdb8c2780d74b6d1b756c363b75ff Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Mon, 19 Mar 2012 19:29:00 -0700 Subject: Improvements to do.php --- do.php | 88 +++++++++++++++++++++++++++--------------------------------------- 1 file changed, 36 insertions(+), 52 deletions(-) (limited to 'do.php') diff --git a/do.php b/do.php index d887be6..1852e9c 100644 --- a/do.php +++ b/do.php @@ -28,21 +28,11 @@ if ($_GET['checkachieve'] == 'true' AND $_SESSION['accepted'] == 1) { $userID = $_SESSION['userID']; - $sql = "UPDATE `achievements` - SET `level` = '0' - WHERE `userID` = '$userID'"; - //mysql_query($sql); //Located in includes/datas.php $note = getNotified($userID); if ($note !== false) $json['notificationtext'] = $note; - - // $achieved = checkAchievements($userID); - - // if ($achieved['result']) { - // $json['notificationtext'] = $achieved['text']; - // } } if ($_GET['r'] == 'getscores') { @@ -55,51 +45,48 @@ if ($_GET['r'] == 'getscores') { die($encoded); } - if ($_GET['r'] == 'getsol') { - $solid = $_GET['solutionid'] + 0; + $mapID = $_GET['mapID'] + 0; //echo "working..."; - if (!is_int($solid)) return; - - $sql = "SELECT `solution`, `mapID` - FROM `solutions` - WHERE - `ID` = '$solid' - LIMIT 1"; + if (!is_int($mapID)) return; + + $userID = $_SESSION['userID']; - $result = mysql_query($sql); - if (mysql_num_rows($result) > 0) { - list($json['solution'], $json['mapid']) = mysql_fetch_row($result); - $encoded = json_encode($json); - die($encoded); + if ($_SESSION['accepted'] == 1) + $json = getSolution($userID, $mapID); + if (isset($_SESSION[$mapID.'sol']) AND $mysolution == '') { + $json['solution'] = $_SESSION[$mapID.'sol']; + $json['moves'] = $_SESSION[$mapID.'moves']; } + $json['mapid'] = $mapID; + + $encoded = json_encode($json); + die($encoded); } - +// ------------ MAIN; getpath. if ($_GET['r'] == 'getpath') { - //Stage 1; Get the path. - - //Generate the map based on the code. - $mapcode = $_GET['mapcode']; + //Join the partial-solution from the map, and the solution sent. + //Could be used to validate maps in for challenges where + // getting the map code from the database is not an option //$tmp = GenerateMapByCode($_GET['mapcode']); - //Seperate any existing solution from map (?depreciated?) //$tmp = seperateMapSolution($tmp); - - //!!!! - //Join the partial-solution from the map, and the solution sent (?Again, depreciated?) //$solution = formSolution($_GET['solution'].$tmp); - $solution = $_GET['solution']; + // Enables the ability to discover an exact duplicate solution. + $solution = formSolution($_GET['solution']); //valid mapID? $mapID = $_GET[mapid] + 0; if (!is_int($mapID)) return; - if ($mapID > 10) { + //the first 10 ID's reserved for challenges & tutorial. + if ($mapID > 10) $mapcode = getMapCode($mapID); - } + else + $mapcode = $_GET['mapcode']; //mygrid will be the map, with the solution applied. $map = GenerateMapByCode($mapcode); @@ -168,7 +155,7 @@ if ($_GET['r'] == 'getpath') { // --------- CONTINUE EXECUTION - // --------- USER NOT LOGGED IN + // --------- USER NOT LOGGED IN? if ($_SESSION['accepted'] !== 1) { if ($moves >= ($_SESSION[$mapID.'moves'] + 0)) { $_SESSION[$mapID.'moves'] = $moves; @@ -178,9 +165,7 @@ if ($_GET['r'] == 'getpath') { } // --------- USER LOGGED IN - //Challenge/Tutorial? - //echo "pre"; if ($mapID <= 10 AND $_GET['isChallenge'] = 'true') { //echo "running function".$_GET['challengeID']; applyChallengeAchievements($userID, $_GET['challengeID'], $mapID, $solution, $moves); @@ -226,19 +211,18 @@ if ($_GET['r'] == 'getpath') { } // --------- APPLY ACHIEVEMENTS - - //while(applyCareerAchievement($userID)) { - // usleep(200); - //} - - //if ($checkcm) - applyCareerMazesAchievements($userID); - //if ($checkcp) - applyCareerPathAchievements($userID); - - //!! no need w/ rush-sending. - $encoded = json_encode($json); - echo $encoded; + + if ($checkcp) + applyAchievements($userID, 1); + if ($checkcm) { + applyAchievements($userID, 2); + applyAchievements($userID, 3); + applyAchievements($userID, 4); + } + + // no need w/ rush-sending. + //$encoded = json_encode($json); + //echo $encoded; // --------- END } -- cgit v1.2.3