From a81858ef82af7469e843e2e6a84ca220330003e3 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 21 May 2013 16:03:08 -0700 Subject: Some code cleanup; fixed a $mydomain missing. --- do.php | 43 ++++++------------------------------------- globe.php | 12 +++++++----- includes/datas.php | 7 +++++-- 3 files changed, 18 insertions(+), 44 deletions(-) diff --git a/do.php b/do.php index 25a663d..41b1133 100644 --- a/do.php +++ b/do.php @@ -123,7 +123,8 @@ if ($_GET['r'] == 'getpath') { // Enables the ability to discover an exact duplicate solution. $solution = formSolution($_GET['solution']); - $userID = $_SESSION['userID'] + 0; + $userID = 0; + if ($accepted) $userID = $_SESSION['userID'] + 0; //valid mapID? $mapID = $_GET['mapid'] + 0; @@ -252,50 +253,20 @@ if ($_GET['r'] == 'getpath') { // return; //} //x - //TODO: Delete the below? - //TODO: I changed this; note these changes before re-applying the above. - //Challenge/Tutorial? -/* if ($mapID <= 10 AND $_GET['isChallenge'] = 'true') { - $json['error'][] = 'executed as a challenge'; - - //This will allow me to give insentive to logging in. - // So that they don't have to do the tutorial twice. - if ($mapID == 5 && $moves == 75 && $accepted == false) { - $_SESSION['preCompletedTutorial'] = true; - $_SESSION['preCompletedTutorialNotified'] = false; - } - if ($accepted == false) { - if ($debug == true) { - echo json_encode($json); - } - exit; - } - //if ($accepted == false) die(json_encode($json)); - //TODO: Where's $paths coming from? - getCompletedChallenges($userID, $mapID, $solution, $moves, $paths); - //die(json_encode($json)); - } - */ // --------- USER NOT LOGGED IN? - if ($_SESSION['accepted'] !== 1) { + if (!$accepted) { if ($moves >= ($_SESSION[$mapID.'moves'] + 0)) { $_SESSION[$mapID.'moves'] = $moves; $_SESSION[$mapID.'sol'] = $solution; } - return; + exit; } + // ---------- NO GUESTS BEYOND THIS POINT // ---------- CLOSING THE SESSION $_SESSION WILL NO LONGER WORK FOR WRITING session_write_close(); - //Now that is done, we can easily do whatever we want - Like, send any emails that there might be. - //TODO: Move to process.php! - //include_once('./includes/emails.php'); - //SendQueuedEmail(); - $json['error'][] = 'user is logged in'; - // --------- USER LOGGED IN - //Is the map still valid to score on? if (!isCurrentMap($mapID)) return; @@ -340,9 +311,7 @@ if ($_GET['r'] == 'getpath') { $json['error'][] = "Involved data: ('$userID', '$mapID', '$solution', '$moves')"; // --------- APPLY ACHIEVEMENTS - - if ($checkcp) - applyAchievements($userID, 1); + if ($checkcp) applyAchievements($userID, 1); if ($checkcm) { applyAchievements($userID, 2); applyAchievements($userID, 3); diff --git a/globe.php b/globe.php index d8cc78d..cd3425c 100644 --- a/globe.php +++ b/globe.php @@ -10,7 +10,9 @@ if (!session_id()) //!! CONFIRM THIS DOMAIN BEFORE TRANSFER //$mydomain = "http://www.mazetd.4xg.net/"; //$mydomain = "http://www.blue.4xg.net/ -$mydomain = "http://www.pathery.com/"; +//$mydomain = "http://www.pathery.com/"; +$mydomain = "http://beta.snapems.com/"; +//include_once('includes/db.inc.php'); function LogError($error) { @@ -74,7 +76,7 @@ function sql_clean($string) { } function CookieLogin() { - global $accepted; + global $accepted, $mydomain; include_once "includes/sqlEmbedded.php"; $userID = $_COOKIE['userID']; $auth = $_COOKIE['auth']; @@ -112,9 +114,9 @@ function CookieLogin() { if ($isAdmin == 1) $_SESSION['isAdmin'] = true; header("Location: $mydomain"); } else { - setcookie("doLogin", "lastAttemptFailed"); - setcookie("userID", ""); - setcookie("auth", ""); + setcookie("doLogin", "lastAttemptFailed"); + setcookie("userID", ""); + setcookie("auth", ""); return false; } } diff --git a/includes/datas.php b/includes/datas.php index 2985853..8a50cbb 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -248,6 +248,8 @@ function applyCareerMazesAchievements($userID) { function getCompletedChallenges($userID, $mapID, $solution, $moves, $paths) { //mapID 5 is the tutorial, and is treated specially + //TODO: What if they're not logged in? + //TODO: Fix / depreciate this. Re-adapt tutorial // Temporary Hack to complete the tutorial... // if($mapID <= 10) { @@ -281,8 +283,7 @@ function getCompletedChallenges($userID, $mapID, $solution, $moves, $paths) { */ function onCompletedTutorial($userID) { //have they previously completed the tutorial? - if(hasCompletedTutorial($userID)) - return false; + if (hasCompletedTutorial($userID)) return false; // -------- This is the first time they've completed the tutorial! $sql = "INSERT INTO `achievements` @@ -510,6 +511,8 @@ function applyAchievements($userID, $aType) { //Is there a next level for this? $aNextLevel = $aLevel + 1; if (!isset($aArray[$aNextLevel])) return false; + //Returns an error notice? + //TODO: !! list($required, $unlockType, $unlockValue, $unlockName, $unlockSubtype) = $aArray[$aNextLevel]; if ($amount < $required) return false; -- cgit v1.2.3