summaryrefslogtreecommitdiffstats
path: root/includes/datas.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/datas.php')
-rw-r--r--includes/datas.php137
1 files changed, 26 insertions, 111 deletions
diff --git a/includes/datas.php b/includes/datas.php
index e99e347..66c816b 100644
--- a/includes/datas.php
+++ b/includes/datas.php
@@ -2,7 +2,7 @@
// For interaction with the SQL database.
//
-include_once('db.inc.php');
+include_once('sqlEmbedded.php');
//FirePHP stuff - TODO: Delete
//require_once('includes/FirePHPCore/FirePHP.class.php');
@@ -114,7 +114,7 @@ function getNotified($userID) {
$aTypeCurrency[1] = "total moves mazed";
$aTypeCurrency[2] = "mazes played";
$aTypeCurrency[3] = "mazes with (tied) top score";
- $aTypeCurrency[4] = "maze wins";
+ $aTypeCurrency[4] = "challenge points";
$aName = $aTypeNames[$aType];
$currency = $aTypeCurrency[$aType];
@@ -506,7 +506,7 @@ function setChallengeCompleted($challenge, $solution, $userID, $moves) {
function isChallengeMap($mapID) {
- include_once('./includes/db.inc.php');
+ include_once('./includes/sqlEmbedded.php');
$sql = "SELECT ID
FROM `maps`
WHERE
@@ -555,7 +555,7 @@ function getAchievementCurrency($userID, $aType) {
// 1, Total Moves "Path Career" //Backdated
// 2, Total Solutions (Total maps played) "Mazes Career" //Backdated
// 3, Tie Top-Score on a map "Maze Mastery" //Tracked (no backdate)
-// 4, Rank#1 Win Top-Score on a map "Wins" //Tracked
+// 4, Champion Points!
$r = 0;
$sql = '';
switch ($aType) {
@@ -572,18 +572,14 @@ function getAchievementCurrency($userID, $aType) {
WHERE userID = '$userID'";
break;
case 3:
- $sql = "SELECT
- SUM(`value`) as t
- FROM `statistics`
- WHERE `userID` = '$userID'
- AND `type` IN (1, 2, 3, 4)";
+ $sql = "SELECT totalTies
+ FROM `users`
+ WHERE `userID` = '$userID'";
break;
case 4:
- $sql = "SELECT
- SUM(`value`) as t
- FROM `statistics`
- WHERE `userID` = '$userID'
- AND `type` IN (32, 33, 34, 35)";
+ $sql = "SELECT championPoints
+ FROM `users`
+ WHERE `ID` = '$userID'";
break;
}
if ($sql == '')
@@ -618,7 +614,7 @@ function getAchievementsArray($type) {
if ($type == 3)
return getMazeMasteryArray();
if ($type == 4)
- return getWinsArray();
+ return getChampionPointsArray();
//Tutorial
if ($type == 32) {
$r[1] = array(1, 1, '#4444ff', 'Blue');
@@ -697,92 +693,22 @@ function getMazeMasteryArray() {
}
//TYPE 4
-function getWinsArray() {
- //$cp[0] = array(requiredmazewins, type, 'value', 'name');
- $r[1] = array(1, 2, 'DiagonalCover_B.png', 'Light Diagnol Cover', 0);
- $r[2] = array(5, 1, '#22aaaa', 'Teal');
- $r[3] = array(15, 2, 'OffsetStripesDiagonal_B.png', 'Dark Diagonal Stripes', 0);
- $r[4] = array(30, 2, 'DiamondLargeDonut_W_I.png', 'Inverted Light Annulated Diamond', 0);
- $r[5] = array(50, 2, 'StarsR_B.png', 'Dark Stars', 0);
- $r[6] = array(75, 2, 'OffsetStripesHorizontal_B_I.png', 'Inverted Dark Horizontal Stripes', 0);
- $r[7] = array(100, 2, 'CrossXLDonut_B_I.png', 'Inverted Dark Large Intersection', 0);
- $r[8] = array(150, 2, 'DiamondLarge_B.png', 'Dark Large Diamond', 0);
- $r[9] = array(225, 1, '#22ff22', 'Neon Lime', 1);
+function getChampionPointsArray() {
+ //$cp[0] = array(requiredpoints, type, 'value', 'name');
+ $r[1] = array(100, 2, 'DiagonalCover_B.png', 'Light Diagnol Cover', 0);
+ $r[2] = array(250, 1, '#22aaaa', 'Teal');
+ $r[3] = array(500, 2, 'OffsetStripesDiagonal_B.png', 'Dark Diagonal Stripes', 0);
+ $r[4] = array(1000, 2, 'DiamondLargeDonut_W_I.png', 'Inverted Light Annulated Diamond', 0);
+ $r[5] = array(2000, 2, 'StarsR_B.png', 'Dark Stars', 0);
+ $r[6] = array(4000, 2, 'OffsetStripesHorizontal_B_I.png', 'Inverted Dark Horizontal Stripes', 0);
+ $r[7] = array(8000, 2, 'CrossXLDonut_B_I.png', 'Inverted Dark Large Intersection', 0);
+ $r[8] = array(16000, 2, 'DiamondLarge_B.png', 'Dark Large Diamond', 0);
+ $r[9] = array(32000, 1, '#22ff22', 'Neon Lime', 1);
//$r[7] = array(75, 2, 'CircleSmall_W_I.png', 'Inverted Bright Small Circle', 0);
return $r;
}
-//Used to track statistics on who wins or ties maps at the end of a day.
-function trackMOTDstats($mapType) {
- // Our rather massive query to get the data we need.
- $sql = "SELECT
- users.ID as userID,
- SUM(solutions.moves) as Moves,
- timediff(MAX(dateModified), maps.dateCreated) as Timetaken
- FROM `maps`
- JOIN `solutions`
- ON maps.ID = solutions.mapID
- JOIN `users`
- ON solutions.userID = users.ID
- JOIN `mapOfTheDay`
- ON maps.ID = mapOfTheDay.mapID
- WHERE
- DATE_ADD(CURDATE(), INTERVAL -1 DAY) =
- DATE_FORMAT(solutions.dateModified,'%Y-%m-%d')
- AND DATE_ADD(CURDATE(), INTERVAL -1 DAY) =
- DATE_FORMAT(maps.dateCreated,'%Y-%m-%d')
- AND `mapType` = '$mapType'
- GROUP BY solutions.userID
- ORDER BY Moves DESC, MAX(dateModified) ASC, solutions.ID DESC
- ";
-
- $mainResult = mysql_query($sql);
- if ($mainResult) {
- $first = true;
- while (list($userID, $uMoves, $uTimeTaken) = mysql_fetch_row($mainResult)) {
- //echo "$first : userID: $userID uMoves: $uMoves uTimeTaken: $uTimeTaken mapType: $mapType<br >";
- do {
- //If it's the rank #1 user, we need to repeat to also award him the tie stat.
- $repeatThis = false;
- $sType = $mapType;
- if ($first) {
- $bestMoves = $uMoves;
- $sType = 31 + $mapType;
- $repeatThis = true;
- }
- if ($uMoves == $bestMoves) {
- $sql = "SELECT `ID` FROM `statistics`
- WHERE `userID` = '$userID' AND `type` = '$sType'";
- $result = mysql_query($sql);
-
- if (mysql_num_rows($result) == 0) {
- $sql = "INSERT INTO `statistics` (`userID`, `type`, `value`)
- VALUES ('$userID', '$sType', 1)";
- $result = mysql_query($sql);
- if (!$result)
- return false;
- } else {
- $sql = "UPDATE `statistics`
- SET `value` = `value` + 1
- WHERE `userID` = '$userID' AND `type` = '$sType'";
- $result = mysql_query($sql);
- if (!$result)
- return false;
- }
-
- } else {
- break 2;
- }
- $first = false;
- } while ($repeatThis);
- }
- }
- return true;
-}
-
-
-
//Select Members
function getMembers($order, $pageNumber = 1, $pageDivide = 50) {
@@ -830,8 +756,8 @@ function getMembers($order, $pageNumber = 1, $pageDivide = 50) {
WHERE solutions.userID = users.ID AND
solutions.dateModified < CURRENT_DATE)
, 0) AS totalMazes,
- SUM(CASE WHEN statistics.type IN (32, 33, 34, 35) THEN statistics.value ELSE 0 END) as totalWins,
- SUM(CASE WHEN statistics.type IN (1, 2, 3, 4) THEN statistics.value ELSE 0 END) as totalTies,
+ users.totalWins,
+ users.totalTies,
IfNull(userData.wallColor, '#666666') as wallColor,
IfNull(userData.displayColor, '#cccccc'),
userData.wallEmblem as wallEmblem,
@@ -839,8 +765,6 @@ function getMembers($order, $pageNumber = 1, $pageDivide = 50) {
users.dateLogin as dateLogin
FROM `users`
LEFT JOIN `userData` ON users.ID = userData.userID
- LEFT JOIN `statistics` ON users.ID = statistics.userID
- GROUP BY users.ID
$order
LIMIT $limitTop, $pageDivide
";
@@ -1134,22 +1058,13 @@ function loadChallengesForMap($mapIdUnsanitized, $userIdUnsanitized)
function loadChallengeListing($userIdUnsanitized)
{
$userID = mysql_escape_string($userIdUnsanitized);
- $sql = "
- SELECT maps.ID AS mapID, maps.challengeTier, maps.name AS name,
- challengeSolutions.dateSolved, challengeSolutions.challengeID AS challengeID
- FROM maps
- INNER JOIN challenges ON maps.ID = challenges.mapID
- LEFT JOIN challengeSolutions ON challenges.ID = challengeSolutions.challengeID
- WHERE maps.isChallenge = 1 AND challenges.enabled = 1
- AND (challengeSolutions.userID IS NULL OR challengeSolutions.userID = '$userID')
- AND maps.challengeTier <= (SELECT challengeTier FROM users WHERE users.ID = '$userID')
- ORDER BY maps.challengeTier, maps.challengeSuborder, challenges.ordering
- ";
+
$sql = " SELECT maps.ID AS mapID, maps.challengeTier, maps.name AS name,
challengeSolutions.dateSolved, challengeSolutions.challengeID AS challengeID
FROM challenges
LEFT JOIN maps ON challenges.mapID = maps.ID
LEFT JOIN challengeSolutions ON challenges.ID = challengeSolutions.challengeID AND challengeSolutions.userID = '$userID'
+ WHERE challenges.enabled = 1
ORDER BY maps.challengeTier, maps.challengeSuborder, challenges.ordering";
$result = mysql_query($sql);