From d6d45b1c1cce510b781634deafc970d1cd025ff9 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Sat, 18 Aug 2012 00:15:50 -0700 Subject: Achievements fixes. Fixed bug where userData row didn't exist for the user; Added image for the achievements. --- images/Achievement_MazeCareer.png | Bin 0 -> 368 bytes images/Achievement_PathCareer.png | Bin 0 -> 293 bytes images/MedalGoldCAR.png | Bin 0 -> 1547 bytes images/MedalSilverCAR.png | Bin 0 -> 1605 bytes pages/achievements.php | 59 ++++++++++++++++++++++++-------------- 5 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 images/Achievement_MazeCareer.png create mode 100644 images/Achievement_PathCareer.png create mode 100644 images/MedalGoldCAR.png create mode 100644 images/MedalSilverCAR.png diff --git a/images/Achievement_MazeCareer.png b/images/Achievement_MazeCareer.png new file mode 100644 index 0000000..b04fefa Binary files /dev/null and b/images/Achievement_MazeCareer.png differ diff --git a/images/Achievement_PathCareer.png b/images/Achievement_PathCareer.png new file mode 100644 index 0000000..37559f0 Binary files /dev/null and b/images/Achievement_PathCareer.png differ diff --git a/images/MedalGoldCAR.png b/images/MedalGoldCAR.png new file mode 100644 index 0000000..75e7f26 Binary files /dev/null and b/images/MedalGoldCAR.png differ diff --git a/images/MedalSilverCAR.png b/images/MedalSilverCAR.png new file mode 100644 index 0000000..daf46ff Binary files /dev/null and b/images/MedalSilverCAR.png differ diff --git a/pages/achievements.php b/pages/achievements.php index 76d993d..1d81220 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -224,6 +224,17 @@ if ($result) { //Validate selection and then update. if (isset($_POST['doupdate']) AND !$viewer) { + + // Ensure the user is located in userData. + $sql = "SELECT * FROM `userData` + WHERE `userID` = '$userID'"; + $result = mysql_query($sql); + if (mysql_num_rows($result) == 0) { + $sql = "INSERT INTO `userData` (`userID`, `displayColor`, `wallColor`) + VALUES ('$userID', '#cccccc', '#666666')"; + mysql_query($sql); + } + //print_R($unlocks); $unlockIDC = $_POST['selectColorID']; $unlockColor = $unlocks[1][$unlockIDC]['value']; @@ -246,41 +257,48 @@ if (isset($_POST['doupdate']) AND !$viewer) { SET `wallColor` = '$unlockColor' WHERE `userID` = '$userID'"; $result = mysql_query($sql); - if (!$result) + if (!$result) { echo "Error updating wall color"; + $data = array(); + $data['error'] = "Error when updating wall color"; + $data['session'] = print_r($_SESSION, true); + $data['post'] = print_r($_POST, true); + EmailError($data); + } } if ($unlockEmblem == $_POST['selectEmblem']) { $sql = "UPDATE `userData` SET `wallEmblem` = '$unlockEmblem' WHERE `userID` = '$userID'"; $result = mysql_query($sql); - if (!$result) - echo "Error updating Emblem"; + if (!$result) { + echo "Error updating wall color"; + $data = array(); + $data['error'] = "Error when updating wall color"; + $data['session'] = print_r($_SESSION, true); + $data['post'] = print_r($_POST, true); + EmailError($data); + } + } if ($unlockNameColor == $_POST['selectNameColor']) { $sql = "UPDATE `userData` SET `displayColor` = '$unlockNameColor' WHERE `userID` = '$userID'"; $result = mysql_query($sql); - if (!$result) - echo "Error updating Username Display Color"; + if (!$result) { + echo "Error updating wall color"; + $data = array(); + $data['error'] = "Error when updating wall color"; + $data['session'] = print_r($_SESSION, true); + $data['post'] = print_r($_POST, true); + EmailError($data); + } } - } - $achievements = array(); -//Depreciated -$sql = " -SELECT - type, - MAX(level) as level, - MAX(dateCompleted) -FROM `achievements` -WHERE userID = '$userID' -GROUP BY `type`"; - //Fetch data @@ -478,8 +496,8 @@ foreach($achievements as $aType => $a) { $uCurrent = $uStats[$aType]; $nUCurrent = number_format($uCurrent); - $aTypeNames[1] = "Path Career Level $aLevel!"; - $aTypeNames[2] = "Mazes Career Level $aLevel!"; + $aTypeNames[1] = "Path Career Level $aLevel!"; + $aTypeNames[2] = "Mazes Career Level $aLevel!"; $aTypeNames[3] = "Maze Mastery Level $aLevel!"; $aTypeNames[4] = "Champion Level $aLevel!"; $aTypeNames[32] = 'Tutorial Complete!'; @@ -500,11 +518,10 @@ foreach($achievements as $aType => $a) { $lastlevel = true; foreach ($CPD as $item) { list($required, $unlockType, $unlockValue, $unlockName) = $item; - if ($debug) echo "At $required: ".displayUnlock($unlockType, $unlockValue, $unlockName)."
"; - + $nRequired = number_format($required); if ($required > $uCurrent) { $lastlevel = false; -- cgit v1.2.3