diff options
-rw-r--r-- | app.php | 2 | ||||
-rw-r--r-- | css/challenge.css | 41 | ||||
-rw-r--r-- | css/page.css | 31 | ||||
-rw-r--r-- | css/stats.css | 32 | ||||
-rw-r--r-- | do.php | 4 | ||||
-rw-r--r-- | globe.php | 4 | ||||
-rw-r--r-- | images/championpoints.png | bin | 0 -> 1484 bytes | |||
-rw-r--r-- | includes/datas.php | 137 | ||||
-rw-r--r-- | includes/header.php | 24 | ||||
-rw-r--r-- | includes/mapoftheday.php | 2 | ||||
-rw-r--r-- | includes/maps.php | 6 | ||||
-rw-r--r-- | includes/playerStats.php | 271 | ||||
-rw-r--r-- | includes/sqlEmbedded.php | 7 | ||||
-rw-r--r-- | includes/sqli.php | 10 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | pages/achievements.php | 6 | ||||
-rw-r--r-- | pages/admin.php | 26 | ||||
-rw-r--r-- | pages/challenge.php | 10 | ||||
-rw-r--r-- | pages/challengelist.php | 2 | ||||
-rw-r--r-- | pages/cp.php | 2 | ||||
-rw-r--r-- | pages/faq.php | 24 | ||||
-rw-r--r-- | pages/feedback.php | 2 | ||||
-rw-r--r-- | pages/gallery.php | 2 | ||||
-rw-r--r-- | pages/home.php | 2 | ||||
-rw-r--r-- | pages/leaderboard.php | 31 | ||||
-rw-r--r-- | pages/login.php | 2 | ||||
-rw-r--r-- | pages/massemail.php | 4 | ||||
-rw-r--r-- | pages/memberlist.php | 7 | ||||
-rw-r--r-- | pages/tutorial.php | 2 | ||||
-rw-r--r-- | update notes.txt | 12 |
30 files changed, 510 insertions, 197 deletions
@@ -1,7 +1,7 @@ <?PHP
include "includes/maps.php";
-include "includes/db.inc.php";
+include "includes/sqlEmbedded.php";
include "includes/mapoftheday.php";
include "includes/datas.php";
diff --git a/css/challenge.css b/css/challenge.css index ffcfe83..a7f7465 100644 --- a/css/challenge.css +++ b/css/challenge.css @@ -5,13 +5,32 @@ font-weight: bold; } #challenge_wrapper #challenges_listing { } -.challenge_complete { - color:green; +.challenge_ulist +{ + list-style-type:none; + padding-left:0px; + margin-left:0px; +} +.challenge_ulist li +{ + /* Replace the bullet-points with challenge complete/incomplete images */ + background-position: 0 5px; + background-repeat: no-repeat; + background-size: 28px 28px; + padding-left: 30px; + padding-top: 6px; +} +.challenge_ulist .challenge_complete +{ + background-image:url('../images/challenge_complete.png'); font-weight: normal; + color:#008000; } -.challenge_incomplete { +.challenge_ulist .challenge_incomplete +{ + background-image:url('../images/challenge_incomplete.png'); font-weight: bold; - color:red; + color:#DD1111; } .challenge_complete a { @@ -21,6 +40,7 @@ display: none; } +<<<<<<< HEAD .challengelist_map { float:left; padding: 15px; @@ -36,6 +56,8 @@ border-width: 0px 0px 1px 1px; } +======= +>>>>>>> origin/HEAD /** Challenge listing page **/ #challengelist_wrapper #challengelist {} #challengelist_wrapper #challengelist .challengelist_tier { @@ -57,4 +79,15 @@ height: 32px; background-image: url("../images/challenge_incomplete.png"); float: right; +} +.challengelist_map { + float:left; + padding: 15px; + background-color:#333; + margin: 20px; + border-radius:10px; + cursor:pointer; +} +.challengelist_map:hover { + background-color:#444; }
\ No newline at end of file diff --git a/css/page.css b/css/page.css index 40027ca..db32892 100644 --- a/css/page.css +++ b/css/page.css @@ -51,10 +51,9 @@ form { float:left;
display:inline;
}
+
.divide {
- font-weight:bold;
- padding: 15px 15px;
- margin: 12px auto;
+ padding: 15px 0px;
text-align: center;
position: relative;
min-width: 900px;
@@ -70,6 +69,25 @@ form { }
+.copyAndButtons
+{
+ margin: 0 auto;
+ width: 900px;
+}
+
+.copyAndButtons #copy
+{
+ clear: both;
+ float: left;
+ margin-left: 240px;
+}
+
+.copyAndButtons #socialButtons
+{
+ float: left;
+ margin: 0 auto;
+}
+
#countdown {
text-align: center;
margin-top: 5px;
@@ -106,12 +124,7 @@ a:hover { -o-transition:color 0s ease-out;
-moz-transition:color 0s ease-out;
}
-
-.socialButtons {
- text-align:right;
- margin: 0px auto;
- width:890px;
-}
+a img {border: none;} /* IE specific: remove outline around image links */
.buttons a {
margin: 1px;
diff --git a/css/stats.css b/css/stats.css index ab4cb96..28d6842 100644 --- a/css/stats.css +++ b/css/stats.css @@ -9,7 +9,7 @@ margin-right: 0px; margin-left: 12px; float: left; - width: 300px; + max-width: 340px; height: auto; } .col { @@ -37,6 +37,26 @@ table { td, th { padding: 3px; } + +.leaderboardHeaders .leaderboardHeadersRank, +.leaderboardHeaders .leaderboardHeadersName, +.leaderboardHeaders .leaderboardHeadersMoves, +.leaderboardHeaders .leaderboardHeadersTime +{ + border:1px solid #ccc; +} + +.leaderboardHeaders .leaderboardHeadersRank { width: 40px; } +.leaderboardHeaders .leaderboardHeadersName, +.leaderboardName +{ + max-width: 140px; + text-overflow: ellipsis; + overflow: hidden; +} +.leaderboardHeaders .leaderboardHeadersMoves { width: 45px; } +.leaderboardHeaders .leaderboardHeadersTime { width: 85px; } + .lbrow { /* Temporary adjust for font changes */ font-size:105%; @@ -112,3 +132,13 @@ td, th { white-space:nowrap; } +.myPoints +{ + text-align: center; + color: #00DDFF; +} + +.myPoints .myPointsValue +{ + font-weight: bold; +}
\ No newline at end of file @@ -2,7 +2,7 @@ session_start();
include "includes/maps.php";
-include "includes/db.inc.php";
+include "includes/sqlEmbedded.php";
include "includes/datas.php";
//FirePHP stuff - TODO: Delete
@@ -373,7 +373,7 @@ die(json_encode($json)); function isCurrentMap($mapID) {
// TODO: change methodology
- include_once('./includes/db.inc.php');
+ include_once('./includes/sqlEmbedded.php');
$sql = "SELECT maps.ID
FROM `mapOfTheDay`
LEFT JOIN `maps` ON maps.ID = `mapID`
@@ -5,7 +5,7 @@ if (!session_id()) //session_regenerate_id();
//Database login:
-//include_once 'db.inc.php';
+//include_once 'sqlEmbedded.php';
//TODO: CONFIRM THIS DOMAIN BEFORE TRANSFER
//$mydomain = "http://www.mazetd.4xg.net/";
@@ -62,7 +62,7 @@ function sql_clean($string) { function CookieLogin() {
global $accepted;
- include_once "includes/db.inc.php";
+ include_once "includes/sqlEmbedded.php";
$userID = $_COOKIE['userID'];
$auth = $_COOKIE['auth'];
diff --git a/images/championpoints.png b/images/championpoints.png Binary files differnew file mode 100644 index 0000000..f6625fe --- /dev/null +++ b/images/championpoints.png 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); diff --git a/includes/header.php b/includes/header.php index 2a6e940..52a86f8 100644 --- a/includes/header.php +++ b/includes/header.php @@ -62,16 +62,7 @@ function htmlFooter() { global $footerLinks;
- echo "<div class='divide'>
-
- <div class='socialButtons buttons'>
- <a href='http://www.facebook.com/Pathery' target='top' title='Facebook'><img alt='Facebook' src='images/btns/facebook.png' /></a>
- <a href='http://www.reddit.com/r/Pathery' target='top' title='Reddit'><img alt='Reddit' src='images/btns/reddit.png' /></a>
- <a href='https://twitter.com/Pathery' target='top' title='Twitter'><img alt='Twitter' src='images/btns/twitter.png' /></a>
- <a href='https://plus.google.com/105148482605711831543' target='top' title='Google Plus'><img alt='Google Plus' src='images/btns/googleplus.png' /></a>
- </div>
-
- </div>";
+ echo "<div class='divide'></div>";
echo " <div class='footerArea' style='width:100%;clear: both'><ul id='triple'>";
foreach ($footerLinks as $key => $value) {
echo "<li><a href='$key'>$value</a></li>";
@@ -79,9 +70,16 @@ function htmlFooter() { echo " </ul></div>";
?>
-
- <div id="copy" style='width:100%;clear: both'>
- Copyright © 2011-2012 pathery.com
+ <div class="copyAndButtons">
+ <div id="copy">
+ Copyright © 2011-2013 pathery.com
+ </div>
+ <div id="socialButtons" class='buttons'>
+ <a href='http://www.facebook.com/Pathery' target='top' title='Facebook'><img alt='Facebook' src='images/btns/facebook.png' /></a>
+ <a href='http://www.reddit.com/r/Pathery' target='top' title='Reddit'><img alt='Reddit' src='images/btns/reddit.png' /></a>
+ <a href='https://twitter.com/Pathery' target='top' title='Twitter'><img alt='Twitter' src='images/btns/twitter.png' /></a>
+ <a href='https://plus.google.com/105148482605711831543' target='top' title='Google Plus'><img alt='Google Plus' src='images/btns/googleplus.png' /></a>
+ </div>
</div>
<br />
diff --git a/includes/mapoftheday.php b/includes/mapoftheday.php index d244635..178dc64 100644 --- a/includes/mapoftheday.php +++ b/includes/mapoftheday.php @@ -1 +1 @@ -<?php
include_once('maps.php');
include_once('db.inc.php');
/**
* Returns the Map Of The Day with the given type (index)
*/
function mapOfTheDay($type = 1) {
ignore_user_abort(true);
if ($type <= 8)
$expire = 2;
if ($type <= 4)
$expire = 1;
$sql = "
SELECT
maps.ID,
maps.code
FROM `mapOfTheDay`, `maps`
WHERE `mapType` = $type AND
DATEDIFF(CURDATE(), mapOfTheDay.mapDate) < $expire AND
mapID = maps.ID
";
$result = mysql_query($sql);
//No map for today?
if (mysql_num_rows($result) != 0) {
$r['code'] = mysql_result($result, 0, 'code');
$r['map'] = GenerateMapByCode($r['code']);
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
return generateNewMapOfTheDay($type, $sql);
}
/**
* Generates a new map of the day. DO NOT CALL OUTSIDE OF mapoftheday.php
*/
function generateNewMapOfTheDay($type, $sql)
{
// If you want to modify the maps created! This is the line
//GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1) {
switch ($type) {
case 1: //Easy
$map = GenerateMap(13, 7, 12, rand(7, 10), rand(0, 1), 0);
break;
case 2: //Normal
$map = GenerateMap(15, 9, 7, rand(11, 13), rand(1, 3) + rand(0, 1), 0);
break;
case 3: //Hard
$map = getRandomComplexMap();
break;
case 4: //Full random map
$map = getRandomSpecialMap();
break;
case 5:
$map = getRandomWeeklyMap();
break;
default:
$map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9));
break;
}
$lock = acquireMotdLock();
try
{
//Double check... $sql is already set
$result = mysql_query($sql);
//Are you SURE there's no map?
if (mysql_num_rows($result) != 0)
{
releaseMotdLock($lock);
return mapOfTheDay($type);
}
$code = GenerateMapCode($map);
$sql = "INSERT INTO `maps` (`code`)
VALUES ('$code')";
$result = mysql_query($sql);
if (!$result)
{
releaseMotdLock($lock);
die("Error on inserting map");
}
$mapID = mysql_insert_id();
$r['code'] = $code;
$r['map'] = $map;
$r['id'] = $mapID;
$sql = "INSERT INTO `mapOfTheDay` (`mapID`, `mapType`, `mapDate`)
VALUES ('$mapID', '$type', CURDATE()) ";
$result = mysql_query($sql);
if (!$result)
{
releaseMotdLock($lock);
die("Error on insert into mapOfTheDay");
}
} catch (Exception $exc) { /* Ignore... :| */ }
releaseMotdLock($lock);
// ---------- Track statistics for 'yesterdays' map.
trackMOTDstats($type);
return $r;
}
/**
* The file locked in order to create serialize map-creations, since our DB doesn't support transactions...
*/
define('FILE_MOTD_LOCK', './motdLockFile');
/**
* Obtains the mutex used for creating the Map Of The Day, so that race-conditions cannot occur (like two threads
* creating and inserting the maps into the database at the same time, which has happened
*/
function acquireMotdLock()
{
$fileHandle = fopen(FILE_MOTD_LOCK, 'a+');
flock($fileHandle, LOCK_EX);
return $fileHandle;
}
/**
* Releases the lock acquired from acquireMotdLock
*/
function releaseMotdLock($fileHandle)
{
if($fileHandle)
flock($fileHandle, LOCK_UN);
}
//Select from yesterday
function getYesterdaysMap() {
$sql = "
select `ID`, `code` from `maps`
WHERE (
DAY(dateCreated) = DAY(NOW()) - 1
AND
MONTH(dateCreated) = MONTH(NOW())
AND
YEAR(dateCreated) = YEAR(NOW())
)
";
$result = mysql_query($sql);
//No map for today?
if (mysql_num_rows($result) == 0) {
return -1;
}
$r['code'] = mysql_result($result, 0, 'code');
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
function getRandomComplexMap() {
$random = weight(0, 0, 0, 0, 0, 0, 0, 1);
switch ($random) {
case 0:
$map = GenerateMap(19, 9, rand(7, 9), rand(14, 16), rand(2, 5), rand(1, 2));
break;
case 1:
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath = insertPoint($reversePath, 'abc');
$reversePath = insertPoint($reversePath, 'tu');
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 0;
$myparams['rockchance'] = 7;
$myparams['walls'] = 12;
$myparams['name'] = 'Reverse Order';
$map = GenerateShapedMap($reversePath, $myparams);
break;
}
return $map;
}
function getRandomSpecialMap() {
//This can be used to add additional weight to certain maps that we like.
$random = weight(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$shape = array();
$params = array();
switch ($random) {
//=====================================
case 0:
//Thirty
$map = GenerateMap(
18, 14, 20, //width, height, rocks
weight(30), //Walls
weight(1), //Checkpoints
weight(1), //Teleports
'Thirty'
);
break;
//=====================================
case 1:
//Simple
$map = GenerateMap(
18, 9, 7, //width, height, rocks
weight(15, 16, 17), //Walls
weight(0), //Checkpoints
weight(0), //Teleports
'Finite'
);
break;
//=====================================
case 2:
//ABC's
$map = GenerateMap(
19, 11, 12, //width, height, rocks
weight(20, 21, 22, 22, 23), //Walls
weight(3), //Checkpoints
weight(0), //Teleports
"ABC's "
);
break;
//=====================================
case 3:
//Tele Madness
$map = GenerateMap(
17, 12, 10, //width, height, rocks
weight(17, 18), //Walls
weight(1), //Checkpoints
weight(5), //Teleports
'Teleport Madness'
);
break;
//=====================================
case 4: //Thursday
//Rocky Maze
$map = GenerateMap(
19, 15, 5, //width, height, rocks
weight(16, 17, 18), //Walls
weight(1, 2, 2, 2, 3, 3), //Checkpoints
weight(0), //Teleports
'Rocky Maze'
);
break;
//=====================================
case 5: //Friday
//Side to Side
$map = GenerateMap(
26, 6, 12, //width, height, rocks
weight(17, 18, 19), //Walls
weight(2, 2, 2, 3, 3), //Checkpoints
weight(3, 3, 3, 4), //Teleports
'Side to Side'
);
break;
//=====================================
case 6:
//Ultimate's Random map:
//Create shape
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
//Insert points
$shape = insertPoint($shape, "sfabcr", $target = '?');
$shape = insertPoint($shape, weight("tu", "d", "tu", "", ""), $target = '?');
//Set params
$params['rockchance'] = 10;
$params['walls'] = weight(21, 20, 22, 20, 21);
$params['name'] = 'Ultimate Random';
//Put it all together.
$map = GenerateShapedMap($shape, $params);
break;
//=====================================
//=====================================
case 7:
//Dual map
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "oqqqqqqqqqqqqqqqqqqqo";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapa = insertPoint($dualmapa, 'abc');
$dualmapb = insertPoint($dualmapb, 'abc');
$dualmap = array_merge($dualmapa, $dualmapb);
$dualmap = insertPoint($dualmap, 'tu');
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 1;
$myparams['rockchance'] = 9;
$myparams['walls'] = weight(20, 20, 21, 21, 22, 23);
$myparams['name'] = 'Seeing Double';
$map = GenerateShapedMap($dualmap, $myparams);
break;
//=====================================
//=====================================
case 8:
//Centralized
$myshape[] = "ooooooooooooooooooo";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o???????fos???????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "ooooooooooooooooooo";
$myshape = insertPoint($myshape, "abc", $target = '?');
$myshape = insertPoint($myshape, weight("tu", "d", "tud", ""), $target = '?');
$myparams['rockchance'] = 7;
$myparams['walls'] = weight(17, 18, 19, 18, 17);
$myparams['name'] = 'Centralized';
$map = GenerateShapedMap($myshape, $myparams);
break;
//=====================================
//=====================================
case 9:
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'Xo??????????????ox';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths = insertPoint($dualingPaths, 'abc');
$dualingPaths = insertPoint($dualingPaths, weight('xx', 'xxx', 'xxxx').weight('XX', 'XXX', 'XXXX'));
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 0;
$myparams['rockchance'] = 9;
$myparams['walls'] = 13;
$myparams['name'] = 'Dualing paths';
$map = GenerateShapedMap($dualingPaths, $myparams);
break;
//=====================================
//=====================================
case 10:
$unlimited[] = 'so?o?o?o?o?o?o?of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?????????????of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?????????????of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?????????????of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?o?o?o?o?o?o?of';
$unlimited = insertPoint($unlimited, 'abc');
$unlimited = insertPoint($unlimited, weight('tu', 'dtu'));
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 1;
$myparams['rockchance'] = 9;
$myparams['walls'] = 999;
$myparams['name'] = 'Unlimited';
$map = GenerateShapedMap($unlimited, $myparams);
break;
//=====================================
}
return $map;
}
function getRandomWeeklyMap() {
// TEST MAP...
$ultraComplex[] = "sooooooooooooooooooooooor";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "sooooooooooooooooooooooor";
$ultraComplex = insertPoint($ultraComplex, 'abcde');
$ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e'));
$ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e', 'u', 'n', 'j', 'h', 'n'));
$ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e', 'u', 'n', 'j', 'h', 'n'));
$ultraComplex = insertPoint($ultraComplex, 'tumnghij');
$myparams['checkpoints'] = 5;
$myparams['teleports'] = 3;
$myparams['rockchance'] = 12;
$myparams['walls'] = 50;
$myparams['name'] = 'Ultra Complex';
$map = GenerateShapedMap($ultraComplex, $myparams);
return $map;
}
?>
\ No newline at end of file +<?php
include_once('maps.php');
include_once('sqlEmbedded.php');
include_once('playerStats.php');
define('MAP_EXPIRE_TIME_NORMAL', 1); //Days that non-weekly maps should last. Changing this won't
//really work without changes to generateNewMapsOfTheDay()..
define('MAP_EXPIRE_TIME_WEEKLY', 2); //Days that a weekly map should last
/**
* Returns the Map Of The Day with the given type (index). Generates new maps if necessary.
*/
function mapOfTheDay($type = 1)
{
$map = getMapOfTheDayInternal($type);
if($map == null)
{
//Map doesn't exist, so we generate the maps and try again
generateNewMapsOfTheDay();
$map = getMapOfTheDayInternal($type);
}
return $map;
}
/**
* Returns the map of the day of the given type, or null if not found.
* Do not call outside of mapoftheday.php
*/
function getMapOfTheDayInternal($type)
{
if ($type <= 4)
$expire = MAP_EXPIRE_TIME_NORMAL;
else if ($type <= 8)
$expire = MAP_EXPIRE_TIME_WEEKLY;
$sql = "
SELECT maps.ID, maps.code
FROM `mapOfTheDay`, `maps`
WHERE `mapType` = $type
AND DATEDIFF(CURDATE(), mapOfTheDay.mapDate) < $expire
AND mapID = maps.ID
";
$result = mysql_query($sql);
if (mysql_num_rows($result) == 0)
{
return null;
}
//A map was found, so return it
$r['code'] = mysql_result($result, 0, 'code');
$r['map'] = GenerateMapByCode($r['code']);
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
/**
* Generates all the new maps for the day. Includes a critical section so maps aren't generated more
* than once per day.
*/
function generateNewMapsOfTheDay()
{
ignore_user_abort(true);
$lock = acquireMotdLock();
try
{
//Double check that there is no simple map for today. Since that was done outside of the lock, it's possible
//two threads could reach this point at the same time.
$map = getMapOfTheDayInternal(1);
if($map != null)
{
releaseMotdLock($lock);
return;
}
//The rest of the code in the try{} can be assumed to only be run once a day
//Generate the maps
generateMapAndAddToDB(1);
generateMapAndAddToDB(2);
generateMapAndAddToDB(3);
generateMapAndAddToDB(4);
//The weekly maps might not need to be generated tonight. Check if it does first
$weeklyMap = getMapOfTheDayInternal(5);
if($weeklyMap == null)
{
generateMapAndAddToDB(5);
}
//Update the player-statistics
addStatsForYesterdaysMaps();
} catch (Exception $exc) { /* Ignore... :| */ }
//try/catch above is necessary to make sure an exception doesn't prevent us from releasing the lock!
releaseMotdLock($lock);
}
/**
* Generates a single map of the given type, and adds its info to the DB
*/
function generateMapAndAddToDB($type)
{
// If you want to modify the maps created! This is the line
//GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1)
switch ($type) {
case 1: //Easy
$map = GenerateMap(13, 7, 12, rand(7, 10), rand(0, 1), 0);
break;
case 2: //Normal
$map = GenerateMap(15, 9, 7, rand(11, 13), rand(1, 3) + rand(0, 1), 0);
break;
case 3: //Hard
$map = getRandomComplexMap();
break;
case 4: //Full random map
$map = getRandomSpecialMap();
break;
case 5:
$map = getRandomWeeklyMap();
break;
default:
$map = GenerateMap(rand(13, 18), rand(10, 14), rand(6, 9));
break;
}
$code = GenerateMapCode($map);
$sql = "INSERT INTO `maps` (`code`)
VALUES ('$code')";
$result = mysql_query($sql);
if (!$result)
{
releaseMotdLock($lock);
die("Error on inserting map");
}
$mapID = mysql_insert_id();
$r['code'] = $code;
$r['map'] = $map;
$r['id'] = $mapID;
$sql = "INSERT INTO `mapOfTheDay` (`mapID`, `mapType`, `mapDate`)
VALUES ('$mapID', '$type', CURDATE()) ";
$result = mysql_query($sql);
if (!$result)
{
releaseMotdLock($lock);
die("Error on insert into mapOfTheDay");
}
}
/**
* The file locked in order to create serialize map-creations, since our DB doesn't support transactions...
*/
define('FILE_MOTD_LOCK', './motdLockFile');
/**
* Obtains the mutex used for creating the Map Of The Day, so that race-conditions cannot occur (like two threads
* creating and inserting the maps into the database at the same time, which has happened
*/
function acquireMotdLock()
{
$fileHandle = fopen(FILE_MOTD_LOCK, 'a+');
flock($fileHandle, LOCK_EX);
return $fileHandle;
}
/**
* Releases the lock acquired from acquireMotdLock
*/
function releaseMotdLock($fileHandle)
{
if($fileHandle)
flock($fileHandle, LOCK_UN);
}
//Select from yesterday
function getYesterdaysMap() {
$sql = "
select `ID`, `code` from `maps`
WHERE (
DAY(dateCreated) = DAY(NOW()) - 1
AND
MONTH(dateCreated) = MONTH(NOW())
AND
YEAR(dateCreated) = YEAR(NOW())
)
";
$result = mysql_query($sql);
//No map for today?
if (mysql_num_rows($result) == 0) {
return -1;
}
$r['code'] = mysql_result($result, 0, 'code');
$r['id'] = mysql_result($result, 0, 'ID');
return $r;
}
function getRandomComplexMap() {
$random = weight(0, 0, 0, 0, 0, 0, 0, 1);
switch ($random) {
case 0:
$map = GenerateMap(19, 9, rand(7, 9), rand(14, 16), rand(2, 5), rand(1, 2));
break;
case 1:
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath[] = 'fo?????????????oS';
$reversePath = insertPoint($reversePath, 'abc');
$reversePath = insertPoint($reversePath, 'tu');
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 0;
$myparams['rockchance'] = 7;
$myparams['walls'] = 12;
$myparams['name'] = 'Reverse Order';
$map = GenerateShapedMap($reversePath, $myparams);
break;
}
return $map;
}
function getRandomSpecialMap() {
//This can be used to add additional weight to certain maps that we like.
$random = weight(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$shape = array();
$params = array();
switch ($random) {
//=====================================
case 0:
//Thirty
$map = GenerateMap(
18, 14, 20, //width, height, rocks
weight(30), //Walls
weight(1), //Checkpoints
weight(1), //Teleports
'Thirty'
);
break;
//=====================================
case 1:
//Simple
$map = GenerateMap(
18, 9, 7, //width, height, rocks
weight(15, 16, 17), //Walls
weight(0), //Checkpoints
weight(0), //Teleports
'Finite'
);
break;
//=====================================
case 2:
//ABC's
$map = GenerateMap(
19, 11, 12, //width, height, rocks
weight(20, 21, 22, 22, 23), //Walls
weight(3), //Checkpoints
weight(0), //Teleports
"ABC's "
);
break;
//=====================================
case 3:
//Tele Madness
$map = GenerateMap(
17, 12, 10, //width, height, rocks
weight(17, 18), //Walls
weight(1), //Checkpoints
weight(5), //Teleports
'Teleport Madness'
);
break;
//=====================================
case 4: //Thursday
//Rocky Maze
$map = GenerateMap(
19, 15, 5, //width, height, rocks
weight(16, 17, 18), //Walls
weight(1, 2, 2, 2, 3, 3), //Checkpoints
weight(0), //Teleports
'Rocky Maze'
);
break;
//=====================================
case 5: //Friday
//Side to Side
$map = GenerateMap(
26, 6, 12, //width, height, rocks
weight(17, 18, 19), //Walls
weight(2, 2, 2, 3, 3), //Checkpoints
weight(3, 3, 3, 4), //Teleports
'Side to Side'
);
break;
//=====================================
case 6:
//Ultimate's Random map:
//Create shape
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
$shape[] = "??????????????????";
//Insert points
$shape = insertPoint($shape, "sfabcr", $target = '?');
$shape = insertPoint($shape, weight("tu", "d", "tu", "", ""), $target = '?');
//Set params
$params['rockchance'] = 10;
$params['walls'] = weight(21, 20, 22, 20, 21);
$params['name'] = 'Ultimate Random';
//Put it all together.
$map = GenerateShapedMap($shape, $params);
break;
//=====================================
//=====================================
case 7:
//Dual map
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "s???????????????????f";
$dualmapa[] = "oqqqqqqqqqqqqqqqqqqqo";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapb[] = "s???????????????????f";
$dualmapa = insertPoint($dualmapa, 'abc');
$dualmapb = insertPoint($dualmapb, 'abc');
$dualmap = array_merge($dualmapa, $dualmapb);
$dualmap = insertPoint($dualmap, 'tu');
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 1;
$myparams['rockchance'] = 9;
$myparams['walls'] = weight(20, 20, 21, 21, 22, 23);
$myparams['name'] = 'Seeing Double';
$map = GenerateShapedMap($dualmap, $myparams);
break;
//=====================================
//=====================================
case 8:
//Centralized
$myshape[] = "ooooooooooooooooooo";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o???????fos???????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "o?????????????????o";
$myshape[] = "ooooooooooooooooooo";
$myshape = insertPoint($myshape, "abc", $target = '?');
$myshape = insertPoint($myshape, weight("tu", "d", "tud", ""), $target = '?');
$myparams['rockchance'] = 7;
$myparams['walls'] = weight(17, 18, 19, 18, 17);
$myparams['name'] = 'Centralized';
$map = GenerateShapedMap($myshape, $myparams);
break;
//=====================================
//=====================================
case 9:
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'so??????????????xf';
$dualingPaths[] = 'Xo??????????????ox';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths[] = 'fX??????????????oS';
$dualingPaths = insertPoint($dualingPaths, 'abc');
$dualingPaths = insertPoint($dualingPaths, weight('xx', 'xxx', 'xxxx').weight('XX', 'XXX', 'XXXX'));
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 0;
$myparams['rockchance'] = 9;
$myparams['walls'] = 13;
$myparams['name'] = 'Dualing paths';
$map = GenerateShapedMap($dualingPaths, $myparams);
break;
//=====================================
//=====================================
case 10:
$unlimited[] = 'so?o?o?o?o?o?o?of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?????????????of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?????????????of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?????????????of';
$unlimited[] = 's???????????????f';
$unlimited[] = 'so?o?o?o?o?o?o?of';
$unlimited = insertPoint($unlimited, 'abc');
$unlimited = insertPoint($unlimited, weight('tu', 'dtu'));
$myparams['checkpoints'] = 3;
$myparams['teleports'] = 1;
$myparams['rockchance'] = 9;
$myparams['walls'] = 999;
$myparams['name'] = 'Unlimited';
$map = GenerateShapedMap($unlimited, $myparams);
break;
//=====================================
}
return $map;
}
function getRandomWeeklyMap() {
// TEST MAP...
$ultraComplex[] = "sooooooooooooooooooooooor";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "so?????????????????????or";
$ultraComplex[] = "ro?????????????????????of";
$ultraComplex[] = "sooooooooooooooooooooooor";
$ultraComplex = insertPoint($ultraComplex, 'abcde');
$ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e'));
$ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e', 'u', 'n', 'j', 'h', 'n'));
$ultraComplex = insertPoint($ultraComplex, weight('a', 'b', 'c', 'd', 'e', 'u', 'n', 'j', 'h', 'n'));
$ultraComplex = insertPoint($ultraComplex, 'tumnghij');
$myparams['checkpoints'] = 5;
$myparams['teleports'] = 3;
$myparams['rockchance'] = 12;
$myparams['walls'] = 50;
$myparams['name'] = 'Ultra Complex';
$map = GenerateShapedMap($ultraComplex, $myparams);
return $map;
}
?>
\ No newline at end of file diff --git a/includes/maps.php b/includes/maps.php index 6a831c8..03bcd81 100644 --- a/includes/maps.php +++ b/includes/maps.php @@ -769,7 +769,7 @@ function formSolution($solution) { //Returns the best solution.
function getSolution($userID, $mapID) {
- include_once('db.inc.php');
+ include_once('sqlEmbedded.php');
$sql = "SELECT `solution`, `moves`
FROM `solutions`
WHERE `userID` = '$userID' AND
@@ -782,7 +782,7 @@ function getSolution($userID, $mapID) { }
function getChallengeSolution($userID, $challengeID) {
- include_once('db.inc.php');
+ include_once('sqlEmbedded.php');
$sql = "SELECT `solution`, `moves`
FROM `challengeSolutions`
WHERE `userID` = '$userID' AND
@@ -795,7 +795,7 @@ function getChallengeSolution($userID, $challengeID) { }
function getMapCode($mapID) {
- include_once('db.inc.php');
+ include_once('sqlEmbedded.php');
$sql = "SELECT `code`
FROM `maps`
WHERE `ID` = '$mapID'
diff --git a/includes/playerStats.php b/includes/playerStats.php new file mode 100644 index 0000000..b302812 --- /dev/null +++ b/includes/playerStats.php @@ -0,0 +1,271 @@ +<?php +define('CP_EARLIEST_DATE', '2012-01-01'); +define('CP_MIN_WORTH', 10); +define('CP_MAX_WORTH_SIMPLE', 100); +define('CP_MAX_WORTH_NORMAL', 150); +define('CP_MAX_WORTH_COMPLEX', 200); +define('CP_MAX_WORTH_SPECIAL', 200); +define('CP_MAX_WORTH_WEEKLY', 350); +define('CP_MIN_WORTH_WEEKLY', 50); +define('CP_POINTS_FOR_ATTEMPTING', 5); +define('CP_EXTRA_PERCENT_FOR_FIRST', 0.05); + +/** + * Sets a flag on all solutions which are the high score (first to tie the best length) + */ +function setIsHighScoreFlag($fromDate) +{ + $fromDate = mysql_escape_string($fromDate); + + $sql = " + UPDATE solutions + SET solutions.isHighScore = 1 + WHERE solutions.ID IN + ( + SELECT s2.ID + FROM (SELECT * FROM solutions) AS s2 + INNER JOIN mapOfTheDay ON s2.mapID = mapOfTheDay.mapID + WHERE s2.ID = + ( + SELECT s3.ID + FROM (SELECT * FROM solutions) AS s3 + WHERE s3.mapID = s2.mapID + ORDER BY moves DESC, dateModified ASC + LIMIT 1 + ) + AND mapOfTheDay.mapDate >= '$fromDate' + ) + "; + + mysql_query($sql); +} + +/** + * Calculates the worth of all maps' champion points from after the given date + * @param $fromDate The earliest date to count from. Use SQL date-string format. + * Pass in yesterday's date, for example, to add champion points from yesterday's maps + */ +function calculateMapsChampionPointWorth($fromDate) +{ + $fromDate = mysql_escape_string($fromDate); + + //We take the worth of the map, multiply by the number of people who tied the high score, then divide by the + //total number of people who attempted the map (minus 1) + $sql = " + UPDATE mapOfTheDay + SET championPointsWorth = GREATEST(".CP_MIN_WORTH.", + ( + CASE mapType + WHEN 1 THEN ".CP_MAX_WORTH_SIMPLE." + WHEN 2 THEN ".CP_MAX_WORTH_NORMAL." + WHEN 3 THEN ".CP_MAX_WORTH_COMPLEX." + WHEN 4 THEN ".CP_MAX_WORTH_SPECIAL." + WHEN 5 THEN ".CP_MAX_WORTH_WEEKLY." + ELSE 0 + END + ) * ( + SELECT COUNT(*) + FROM solutions + WHERE solutions.mapID = mapOfTheDay.mapID + AND solutions.moves < + ( + SELECT MAX(moves) + FROM solutions AS s2 + WHERE s2.mapId = mapOfTheDay.mapID + ) + ) / ( + SELECT GREATEST(COUNT(*)-1, 1) + FROM solutions + WHERE solutions.mapID = mapOfTheDay.mapID + )) + WHERE mapDate >= '$fromDate' + "; + + mysql_query($sql); +} + +/** + * Adds the champion points for each player for every day after the given date, but before today. + * Thus, if you're using this to add points from yesterday's maps, this should be done + * after the date has changed. + * @param $fromDate The earliest date to count from. SQL date-string format. + * Pass in yesterday's date, for example, to add champion points from yesterday's maps + */ +function addPlayerChampionPointsForMapsOfTheDay($fromDate) +{ + $fromDate = mysql_escape_string($fromDate); + + //TODO: How do you know when an ultra-complex map has completed? + + //Weird syntax of these queries is necessary due to a bug in MySQL with updating a table and selecting a table + //in the same query. See http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/ + $sql1 = " + -- Add the points for tying the map + UPDATE solutions + INNER JOIN + ( + SELECT mapID, moves + FROM solutions AS s2 + WHERE isHighScore = 1 + ) AS maxMoves ON maxMoves.mapID = solutions.mapID + INNER JOIN mapOfTheDay ON mapOfTheDay.mapID = solutions.mapID + SET solutions.championPointsWorth = mapOfTheDay.championPointsWorth + WHERE mapOfTheDay.mapDate >= '$fromDate' + AND mapOfTheDay.mapDate < CURDATE() + AND mapOfTheDay.mapType <> 5 + AND solutions.moves = maxMoves.moves + "; + + $sql2 = " + -- Add the extra for being the first to tie the map + UPDATE solutions + SET solutions.championPointsWorth = solutions.championPointsWorth * (1 + ".CP_EXTRA_PERCENT_FOR_FIRST.") + WHERE solutions.isHighScore = 1 + AND solutions.dateModified >= $fromDate + AND solutions.dateModified < CURDATE() + "; + + //TODO: This doesn't work right, weekly maps last more than a day... + $sql3 = " + -- Add the points for doing the weekly maps + UPDATE solutions + SET championPointsWorth = championPointsWorth + + ( + SELECT IFNULL(SUM(".CP_MAX_WORTH_WEEKLY." * + ( + SELECT COUNT(*) + FROM (SELECT * FROM solutions) AS s2 + WHERE s2.mapID = mapOfTheDay.mapID + AND s2.moves < usersSolutions.moves + ) / ( + SELECT GREATEST(COUNT(*)-1, 1) + FROM (SELECT * FROM solutions) AS s2 + WHERE s2.mapID = mapOfTheDay.mapID + ) + ".CP_MIN_WORTH_WEEKLY."), 0) + FROM mapOfTheDay + INNER JOIN (SELECT * FROM solutions) AS usersSolutions ON usersSolutions.mapID = mapOfTheDay.mapID + WHERE usersSolutions.ID = solutions.ID + AND mapOfTheDay.mapType = 5 + AND mapOfTheDay.mapDate >= '$fromDate' + AND mapOfTheDay.mapDate < CURDATE() + ) + WHERE solutions.dateModified >= $fromDate; + AND mapOfTheDay.mapDate < CURDATE() + "; + + $sql4 = " + -- Add the points for attempting the map + UPDATE solutions + SET championPointsWorth = ".CP_POINTS_FOR_ATTEMPTING." + WHERE championPointsWorth = 0 + AND dateModified >= $fromDate + AND dateModified < CURDATE() + "; + + //TODO: Points for doing challenges too + //TODO: Is summing the entire table every time slow? If so, we should just add the points instead + $sql5 = " + -- Simply re-sum all the points + UPDATE users + SET championPoints = + ( + SELECT SUM(championPointsWorth) + FROM solutions + WHERE solutions.userID = users.ID + ) + "; + + mysql_query($sql1); + mysql_query($sql2); + mysql_query($sql3); + mysql_query($sql4); + mysql_query($sql5); +} + +/** + * Sets all players wins and draws to 0. Should be done before a total recalculation + */ +function clearWinsAndTies() +{ + $sql = " + UPDATE users + SET totalWins = 0, totalTies = 0; + "; + + mysql_query($sql); +} + +/** + * Calculates players' total wins and draws, adding from the given date + */ +function addWinsAndTies($fromDate) +{ + $sql1 = " + -- Add the players' latest wins + UPDATE users + SET totalWins = totalWins + + ( + SELECT COUNT(*) + FROM solutions + INNER JOIN mapOfTheDay ON solutions.mapID = mapOfTheDay.mapID + WHERE solutions.isHighScore = 1 + AND mapOfTheDay.mapDate >= '$fromDate' + AND mapOfTheDay.mapDate < CURDATE() + AND solutions.userID = users.ID + ); + "; + + $sql2 = " + -- Add the players' latest ties + UPDATE users + SET totalTies = totalTies + + ( + SELECT COUNT(*) + FROM solutions + INNER JOIN mapOfTheDay ON solutions.mapID = mapOfTheDay.mapID + WHERE mapOfTheDay.mapDate >= '$fromDate' + AND mapOfTheDay.mapDate < CURDATE() + AND solutions.userID = users.ID + AND solutions.moves = + ( + SELECT moves + FROM solutions AS s2 + WHERE s2.mapID = mapOfTheDay.mapID + AND s2.isHighScore = 1 + LIMIT 1 + ) + ); + "; + + mysql_query($sql1); + mysql_query($sql2); +} + +/** + * Calculates the worth of the maps for yesterday, and distributes points for them. Also adds wins and ties to + * the correct players + */ +function addStatsForYesterdaysMaps() +{ + $yesterday = strtotime('-1 day', time()); + $yesterdayStr = date('Y-m-d', $yesterday); + setIsHighScoreFlag($yesterday); + calculateMapsChampionPointWorth($yesterdayStr); + addPlayerChampionPointsForMapsOfTheDay($yesterdayStr); + addWinsAndTies($yesterdayStr); +} + +/** + * Recalculates all player's total champion points, wins, and ties. + * Will probably be extremely slow, so should not be called often! + */ +function recalculateStatsForAllPlayers() +{ + setIsHighScoreFlag(CP_EARLIEST_DATE); + calculateMapsChampionPointWorth(CP_EARLIEST_DATE); + addPlayerChampionPointsForMapsOfTheDay(CP_EARLIEST_DATE); + //TODO: Champion points for challenges! + clearWinsAndTies(); + addWinsAndTies(CP_EARLIEST_DATE); +} +?> diff --git a/includes/sqlEmbedded.php b/includes/sqlEmbedded.php new file mode 100644 index 0000000..b7a32b5 --- /dev/null +++ b/includes/sqlEmbedded.php @@ -0,0 +1,7 @@ +<?php +include_once('db.inc.php'); + +global $mysqlid; +$mysqlid = @mysql_connect($db_host,$db_user, $db_pass) or die("Cannot connect to database."); +@mysql_select_db($db_name, $mysqlid) or die("Invalid database."); +?> diff --git a/includes/sqli.php b/includes/sqli.php index 0974380..d19069b 100644 --- a/includes/sqli.php +++ b/includes/sqli.php @@ -1,12 +1,4 @@ <?php
-
-//global $mysqlid;
-$db_host = "db2894.perfora.net";
-$db_user = "dbo362854667";
-$db_name = "db362854667";
-$db_pass = "mazes4me";
-// $mysqlid = @mysql_connect($db_host,$db_user, $db_pass) or die("Cannot connect to database.");
-// @mysql_select_db($db_name, $mysqlid) or die("Invalid database.");
-
+include_once('db.inc.php');
$mysqli = mysqli_connect($db_host, $db_user, $db_pass, $db_name) or die("Failed to connect to database");
?>
\ No newline at end of file @@ -27,7 +27,7 @@ if (isset($_SESSION['accepted']) AND $_SESSION['accepted'] == 1) //TODO: We could store this data in the session
if ($accepted) {
$userID = $_SESSION['userID'];
- include_once ('./includes/db.inc.php');
+ include_once ('./includes/sqlEmbedded.php');
$sql = "
SELECT
userData.wallColor,
diff --git a/pages/achievements.php b/pages/achievements.php index ac7aded..6dbabe7 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -7,7 +7,7 @@ htmlHeader(array('profile'), 'Pathery Achievements'); <?php
topbar($Links);
-include_once('./includes/db.inc.php');
+include_once('./includes/sqlEmbedded.php');
include_once('./includes/datas.php');
//Get UserID
@@ -499,13 +499,13 @@ foreach($achievements as $aType => $a) { $aTypeNames[1] = "<img src='../images/Achievement_PathCareer.png' style='width:36px;height:36px;vertical-align:middle'>Path Career Level $aLevel!";
$aTypeNames[2] = "<img src='../images/Achievement_MazeCareer.png' style='width:36px;height:36px;vertical-align:middle'>Mazes Career Level $aLevel!";
$aTypeNames[3] = "<img src='../images/MedalSilverCAR.png' style='width:36px;height:36px;vertical-align:middle'>Maze Mastery Level $aLevel!";
- $aTypeNames[4] = "<img src='../images/MedalGoldCAR.png' style='width:36px;height:36px;vertical-align:middle'>Champion Level $aLevel!";
+ $aTypeNames[4] = "<img src='../images/championpoints.png' style='width:36px;height:36px;vertical-align:middle'>Champion Level $aLevel!";
$aTypeNames[32] = 'Tutorial Complete!';
$aTypeCurrency[1] = "total moves mazed";
$aTypeCurrency[2] = "mazes played";
$aTypeCurrency[3] = "mazes with (tied) top score";
- $aTypeCurrency[4] = "maze wins";
+ $aTypeCurrency[4] = "champion points";
$name = $aTypeNames[$aType];
$currency = $aTypeCurrency[$aType];
diff --git a/pages/admin.php b/pages/admin.php index 983c4bc..0f54285 100644 --- a/pages/admin.php +++ b/pages/admin.php @@ -6,10 +6,11 @@ htmlHeader(); <?php
topbar($Links);
-include('./includes/datas.php');
-include('./includes/maps.php');
-include('./includes/mapoftheday.php');
-include('./includes/db.inc.php');
+include_once('./includes/datas.php');
+include_once('./includes/maps.php');
+include_once('./includes/mapoftheday.php');
+include_once('./includes/sqlEmbedded.php');
+include_once('./includes/playerStats.php');
if ($_GET['applyall'] == 'true') {
echo "Apply-All command heard. Executing...";
@@ -26,22 +27,33 @@ if ($_GET['applyall'] == 'true') { echo "Execution complete!";
}
+else if ($_GET['recalcStats'] == 'true') {
+ echo "Recalculating all player stats...";
+
+ recalculateStatsForAllPlayers();
+
+ echo "Complete!";
+}
$sql = "SELECT `ID`, `displayName`, `dateJoined`, `dateLogin`, `email`, `isAdmin` FROM `users`";
$result = mysql_query($sql);
-echo "
+echo '
<center>
<h3>Administrators Page</h3>
<p>News:</p>
+<p>Buttons:<br />
+ <input type="button" value="Apply all achievements" onClick="parent.location=\'admin?applyall=true\'">
+ <input type="button" value="Recalculate all player stats" onClick="parent.location=\'admin?recalcStats=true\'">
+</p>
<p>Hello admins, this is our current userlist.</p>
</center>
-<table style='padding-left:20px;'>
+<table style="padding-left:20px;">
<tr>
<th>ID</th><th>Display name:</th><th>Joined On:</th><th>Last Logon</th><th>Email</th><th>Administrator</th>
</tr>
-";
+';
while (list($CUID, $CUsername, $Joined, $LastLogon, $email, $isAdmin) = mysql_fetch_row($result)) {
diff --git a/pages/challenge.php b/pages/challenge.php index 8d312d1..ceefebe 100644 --- a/pages/challenge.php +++ b/pages/challenge.php @@ -6,7 +6,7 @@ htmlHeader( include_once ('./includes/maps.php');
include_once ('./includes/mapoftheday.php');
-include_once ('./includes/db.inc.php');
+include_once ('./includes/sqlEmbedded.php');
include_once ('./includes/datas.php');
//Get custom wall colors;
@@ -131,21 +131,19 @@ function displayChallenges($challengeResultset) {
echo '<div id="challenges">';
echo '<div id="challenges_title">Challenges</div>';
- echo '<div id="challenges_listing"><ol>';
+ echo '<div id="challenges_listing"><ul class="challenge_ulist">';
while($challenge = mysql_fetch_array($challengeResultset))
{
$mapID = $_GET["mapID"];
$challengeId = $challenge["challengeID"];
- echo "<li>";
if($challenge["dateSolved"] !== NULL)
$cssClass = "challenge_complete";
else
$cssClass = "challenge_incomplete";
$loadSolutionString = "<a href='javascript:requestChallengeSolution(\"$mapID\", \"$challengeId\");'> Load this solution</a>";
- echo "<span class='$cssClass' id='challenge_id_$challengeId'>" . getChallengeDisplayString($challenge) . " $loadSolutionString </span>";
- echo "</li>";
+ echo "<li class='$cssClass' id='challenge_id_$challengeId'>" . getChallengeDisplayString($challenge) . " $loadSolutionString </li>";
}
- echo "</ol></div></div>";
+ echo "</ul></div></div>";
}
/**
diff --git a/pages/challengelist.php b/pages/challengelist.php index a6a4ade..ca9fe46 100644 --- a/pages/challengelist.php +++ b/pages/challengelist.php @@ -6,7 +6,7 @@ htmlHeader( include_once ('./includes/maps.php'); include_once ('./includes/mapoftheday.php'); -include_once ('./includes/db.inc.php'); +include_once ('./includes/sqlEmbedded.php'); include_once ('./includes/datas.php'); include_once ('./includes/mapclass.php'); diff --git a/pages/cp.php b/pages/cp.php index 06ec0e8..a807200 100644 --- a/pages/cp.php +++ b/pages/cp.php @@ -9,7 +9,7 @@ htmlHeader(); topbar($Links);
include('./includes/maps.php');
-include_once('./includes/db.inc.php');
+include_once('./includes/sqlEmbedded.php');
function validatename($name) {
if (strlen($name) < 1)
diff --git a/pages/faq.php b/pages/faq.php index 3df08eb..95b0b87 100644 --- a/pages/faq.php +++ b/pages/faq.php @@ -7,7 +7,8 @@ htmlHeader(array(), 'FAQ', 'How does the pathing work?'); echo soundManager2();
topbar($Links);
-include('./includes/maps.php');
+include_once('./includes/maps.php');
+include_once('./includes/playerStats.php');
// Demo maps:
@@ -72,6 +73,7 @@ Your question not here? Ask me via the <a href='feedback'>Feedback Page</a>. <li><a href='#pathing'>How does the pathing work? / How does it choose which way to go?</a></li>
<li><a href='#multipath'>How does Multi-path work? (Two paths at once)</a></li>
<li><a href='#greed'>More than one of the same checkpoint?</a></li>
+ <li><a href='#championPoints'>What are 'Champion Points?'</a></li>
</ul>
<a name='pathing'> </a>
@@ -131,6 +133,26 @@ When there's more than one checkpoint, you can completely wall one off. <? echo $demo3; ?>
<div style='clear:both'></div>
+<hr width='60%' />
+
+<a name='championPoints'> </a>
+<h3>What are 'Champion Points?'</h3>
+<img src="../images/championpoints.png"></img>
+<p>Champion Points are a way to give you recognition for your skills and dedication. They work like this:
+<ul><li>Just for attempting a map, you get <?echo CP_POINTS_FOR_ATTEMPTING;?> points. That's <?echo CP_POINTS_FOR_ATTEMPTING*4;?> points a day just for clicking go!</li>
+ <li>If you tie the high score, you get anywhere between <?echo CP_MIN_WORTH;?> and <?echo CP_MAX_WORTH_SPECIAL;?> points,
+ depending on how many people tied or didn't tie the high score.</li>
+ <li>The winner of each map receives an additional small bonus.</li>
+ <? /*TODO: REVIEW AFTER PUSHING THE WEEKLY MAP UPDATE*/ //<li>On the weekly maps, <i>everyone</i> gets points! The more people you beat, the more points you'll get!</li> ?>
+ <? //<li>You also receive points for completing additional tasks, like <a href="challengelist">completing challenges</a>,
+ //<a href="achievements">getting achievements</a>!</li>, or even <a href="ADD LINK HERE">liking us on facebook</a> ?>
+</ul>
+ Make sure to play every day to receive as many points as possible!
+</p>
+
+<br />
+<div style='clear:both'></div>
+
</div>
diff --git a/pages/feedback.php b/pages/feedback.php index 33c3e1d..e971f12 100644 --- a/pages/feedback.php +++ b/pages/feedback.php @@ -10,7 +10,7 @@ if (isset($_POST['regarding']) AND isset($_SESSION['accepted'])) { if (!is_int($userID))
return;
- include_once "includes/db.inc.php";
+ include_once "includes/sqlEmbedded.php";
$sql = "SELECT `email` FROM `users`
WHERE `ID` = '$userID'";
$result = mysql_query($sql);
diff --git a/pages/gallery.php b/pages/gallery.php index f8e1b9d..525c73a 100644 --- a/pages/gallery.php +++ b/pages/gallery.php @@ -1,7 +1,7 @@ <?PHP htmlHeader(array(), '', '', array('scores')); -include_once ('./includes/db.inc.php'); +include_once ('./includes/sqlEmbedded.php'); if ($accepted) { $userID = $_SESSION['userID']; diff --git a/pages/home.php b/pages/home.php index 37a94c3..d5ba45f 100644 --- a/pages/home.php +++ b/pages/home.php @@ -2,7 +2,7 @@ include_once ('./includes/maps.php');
include_once ('./includes/mapoftheday.php');
-include_once ('./includes/db.inc.php');
+include_once ('./includes/sqlEmbedded.php');
include_once ('./includes/datas.php');
htmlHeader(
diff --git a/pages/leaderboard.php b/pages/leaderboard.php index 9f40d8b..b5e3a76 100644 --- a/pages/leaderboard.php +++ b/pages/leaderboard.php @@ -11,7 +11,7 @@ include('./includes/maps.php'); //include('./includes/mapoftheday.php');
include('./includes/datas.php');
-include_once ('./includes/db.inc.php');
+include_once ('./includes/sqlEmbedded.php');
function day_diff($date1, $date2) {
$current = $date1;
@@ -109,7 +109,10 @@ function getStat ($type, $daysAgo = 1) { userData.wallColor,
userData.wallEmblem,
userData.displayColor,
- users.ID as userID
+ users.ID as userID,
+ SUM(CASE WHEN solutions.dateModified < CURDATE()
+ THEN solutions.championPointsWorth
+ ELSE 0 END) AS championPointsWorth
FROM `maps`
JOIN `solutions`
ON maps.ID = solutions.mapID
@@ -198,7 +201,8 @@ function displayPastMaze($mapType, $name, $daysAgo = 1) { userData.wallColor,
userData.wallEmblem,
userData.displayColor,
- users.ID as userID
+ users.ID as userID,
+ solutions.championPointsWorth
FROM `maps`
JOIN `solutions`
ON maps.ID = solutions.mapID
@@ -254,11 +258,11 @@ function displayPastMaze($mapType, $name, $daysAgo = 1) { function displaystats($result, $caption = NULL) {
//Get names.
- $headers = "<tr>";
- $headers .= "<th style='border:1px solid #ccc'>Rank</th>";
- $headers .= "<th style='border:1px solid #ccc'>Name</th>";
- $headers .= "<th style='border:1px solid #ccc'>Moves</th>";
- $headers .= "<th style='border:1px solid #ccc'>Time taken</th>";
+ $headers = "<tr class='leaderboardHeaders'>";
+ $headers .= "<th class='leaderboardHeadersRank'>Rank</th>";
+ $headers .= "<th class='leaderboardHeadersName'>Name</th>";
+ $headers .= "<th class='leaderboardHeadersMoves'>Moves</th>";
+ $headers .= "<th class='leaderboardHeadersTime'>Time taken</th>";
$headers .= "</th>";
//Start table
//$r .= "<table style='border:1px solid #FFF'>";
@@ -269,6 +273,7 @@ function displaystats($result, $caption = NULL) { //$r .= "</tr>";
$i = 1;
+ $championPoints = null;
while ($row = mysql_fetch_assoc($result)) {
$rowcontent = '';
$mapid = $row['mapID'];
@@ -285,7 +290,7 @@ function displaystats($result, $caption = NULL) { $x = "<tr class='lbrow' onmouseover='changeWallEmblem(\"$wallEmblem\"); changeWallColor(\"$wallColor\"); loadSol(\"$mapid:$solution\");'>\n";
$x .= "<td>$i</td>";
- $x .= "<td><span title='UserID: $userID'><a href='achievements?id=$userID' style='color:$displayColor'>$displayName</a></span></td>";
+ $x .= "<td class='leaderboardName'><span title='UserID: $userID'><a href='achievements?id=$userID' style='color:$displayColor'>$displayName</a></span></td>";
//$x .= "<td style='color:$displayColor';>" . $row['Name'] . '</td>';
$x .= '<td><a href="javascript:void(0)">' . $row['Moves'] . '</a></td>';
$x .= '<td>' . $row['Timetaken'] . '</td>';
@@ -293,6 +298,7 @@ function displaystats($result, $caption = NULL) { if ($userID == $_SESSION['userID']) {
$promotedContent .= $x;
+ $championPoints = $row['championPointsWorth'];
} else {
$content .= $x;
}
@@ -300,7 +306,12 @@ function displaystats($result, $caption = NULL) { $i++;
}
- $r = "<table style='border:1px solid #FFF'>";
+ $r = '';
+ if($championPoints != null && $championPoints > 0)
+ {
+ $r .= "<div class='myPoints'>Points earned: <span class='myPointsValue'>$championPoints</span> <img src='../images/championpoints.png' width='16px' height='16px'></img></div>";
+ }
+ $r .= "<table style='border:1px solid #FFF'>";
$r .= "<caption>$caption</caption>";
$r .= $headers;
$r .= $promotedContent;
diff --git a/pages/login.php b/pages/login.php index 92b71fd..9358d89 100644 --- a/pages/login.php +++ b/pages/login.php @@ -48,7 +48,7 @@ try { $claimedid = $openid->__get('identity');
//I know just where to put this stuff!
- require './includes/db.inc.php';
+ require './includes/sqlEmbedded.php';
//Unless I already have this information...
//* Modify this to WHERE `email`
//$sql = "SELECT `ID`, `isAdmin`, `openID`, `displayName` FROM `users` WHERE `email` = '$email'";
diff --git a/pages/massemail.php b/pages/massemail.php index a861500..d45588b 100644 --- a/pages/massemail.php +++ b/pages/massemail.php @@ -6,7 +6,7 @@ htmlHeader(); topbar($Links);
include('./includes/datas.php');
-include('./includes/db.inc.php');
+include('./includes/sqlEmbedded.php');
if (isset($_POST['massemail']) AND isset($_SESSION['accepted'])) {
@@ -22,7 +22,7 @@ if (isset($_POST['massemail']) AND isset($_SESSION['accepted'])) { if (!is_int($userID))
return;
- include_once "includes/db.inc.php";
+ include_once "includes/sqlEmbedded.php";
$sql = "SELECT `email` FROM `users`
WHERE `ID` = '$userID'";
$result = mysql_query($sql);
diff --git a/pages/memberlist.php b/pages/memberlist.php index 22d88b4..2fa2cdc 100644 --- a/pages/memberlist.php +++ b/pages/memberlist.php @@ -13,7 +13,7 @@ htmlHeader( topbar($Links);
-include_once ('./includes/db.inc.php');
+include_once ('./includes/sqlEmbedded.php');
include_once ('./includes/datas.php');
@@ -115,8 +115,8 @@ $sql = "SELECT WHERE solutions.userID = users.ID AND
solutions.dateModified BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY) AND CURRENT_DATE) AS totalMovesThisWeek,
(SELECT COUNT(*) FROM solutions WHERE solutions.userID = users.ID AND solutions.dateModified < CURRENT_DATE) 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,
@@ -124,7 +124,6 @@ $sql = "SELECT 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
";
diff --git a/pages/tutorial.php b/pages/tutorial.php index 4d2446f..5208a57 100644 --- a/pages/tutorial.php +++ b/pages/tutorial.php @@ -13,7 +13,7 @@ topbar($Links); //TODO: Turn this into a function?
if ($accepted) {
- include_once ('./includes/db.inc.php');
+ include_once ('./includes/sqlEmbedded.php');
$userID = $_SESSION['userID'];
$sql = "
diff --git a/update notes.txt b/update notes.txt new file mode 100644 index 0000000..7c57a30 --- /dev/null +++ b/update notes.txt @@ -0,0 +1,12 @@ +For next update: +- Move the new columns from BlueRaja's database over to your other databases. Make sure to get not only the type, but nullable/default as well. + (We need to do this in a more sensible way in the future... sorry) +- Drop the 'statistics' table. It's not needed anymore. +- Delete the lines relating to '$mysqlid' from db.inc.php (which I can't do, since that file is not versioned). + Those lines have been moved to sqlEmbedded.php. The only thing that should be left are the four lines defining the servername/username/etc. +- Open includes\playerStats.php, and set CP_EARLIEST_DATE to the date we want to start counting ties/wins/champion points from. + We could also pretty easily recalculate the other stats (mazes and total moves) from that date, if you want; then that date would be like the 'start' of pathery. +- Go to the admin page in the browser, and click on the button that says "recalculate player statistics." All the above steps must be done before this. + + +Notes from previous updates:
\ No newline at end of file |