summaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/leaderboard.php103
1 files changed, 66 insertions, 37 deletions
diff --git a/pages/leaderboard.php b/pages/leaderboard.php
index a457a8d..9f40d8b 100644
--- a/pages/leaderboard.php
+++ b/pages/leaderboard.php
@@ -47,12 +47,20 @@ $datePrevDay = date('Y-m-d', strtotime("-1 day", $dateAgo));
if ($daysAgo < 1)
die("You must specify a date previous to today.");
+
+
+$time_start = microtime(true);
+
$tStats = getStat(1, $daysAgo);
$yStats = getStat(2, $daysAgo);
-
$wStats = getStat(3, $daysAgo);
$mStats = getStat(4, $daysAgo);
+$time_end = microtime(true);
+$time = $time_end - $time_start;
+
+if ($_GET['debug'] == true) echo "XX StatContent getStat Rechieve: $time seconds XX\n";
+
function getStat ($type, $daysAgo = 1) {
switch ($type) {
@@ -122,7 +130,10 @@ function getStat ($type, $daysAgo = 1) {
<div class="wrapper">
<div style='text-align:center;padding-bottom:7px;'>
-Showing scores for the maps played on <? echo $dateAsStr; ?>
+<strong>12-28-12. I plan on making considerable changes to this page in the near future.
+<br />Thank you for your patience!</strong>
+<br />
+<br />Showing scores for the maps played on <? echo $dateAsStr; ?>
</div>
<div id="daynav">
@@ -133,11 +144,21 @@ if ($daysAgo > 1) {
}
echo "<a href='leaderboard?date=$datePrevDay' title='Older'>Previous Day</a>";
+
+
+$time_start = microtime(true);
+
$statContent .= displayPastMaze(1, 'Simple', $daysAgo);
$statContent .= displayPastMaze(2, 'Normal', $daysAgo);
$statContent .= displayPastMaze(3, 'Complex', $daysAgo);
$statContent .= displayPastMaze(4, 'Special', $daysAgo);
+$time_end = microtime(true);
+$time = $time_end - $time_start;
+
+if ($_GET['debug'] == true) echo "StatContent Rechieve: $time seconds\n";
+
+
$special = 'Special';
if ($specialMapName != '')
$special = $specialMapName;
@@ -163,6 +184,11 @@ function displayPastMaze($mapType, $name, $daysAgo = 1) {
if ($daysAgo < 1)
return;
+ $pastMap = pastMap($mapType, $daysAgo);
+ $mapID = $pastMap;
+ $mapcode = getMapCode($mapID);
+ $map = GenerateMapByCode($mapcode);
+
$sql = "SELECT
maps.ID as mapID,
solution,
@@ -182,42 +208,33 @@ function displayPastMaze($mapType, $name, $daysAgo = 1) {
ON maps.ID = mapOfTheDay.mapID
LEFT JOIN `userData`
ON users.ID = userData.userID
- WHERE DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
- DATE_FORMAT(solutions.dateModified,'%Y-%m-%d')
- AND DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
- DATE_FORMAT(maps.dateCreated,'%Y-%m-%d')
- AND `mapType` = '$mapType'
+ WHERE
+ maps.ID = '$mapID'
GROUP BY solutions.userID
ORDER BY Moves DESC, `dateModified` ASC
";
- $result = mysql_query($sql);
-
+
+ $result = mysql_query($sql) or die(mysql_error());
+
$statname = "Yesterday's Best $name:";
if ($daysAgo > 1) {
$statname = "$daysAgo days ago's Best $name:";
}
$stats = displayStats($result, $statname);
- $pastMap = pastMap($mapType, $daysAgo);
- $mapID = $pastMap;
- $mapcode = getMapCode($mapID);
- $map = GenerateMapByCode($mapcode);
-
//Sucky temporary solution:
$GLOBALS['specialMapName'] = $map[0][6];
$sql = "SELECT `moves`, `displayName`, `solution`
- FROM `solutions`, `users`
- WHERE `mapID` = '$mapID' AND
- `userID` = users.ID
+ FROM `solutions`
+ LEFT JOIN `users`
+ ON solutions.userID = users.ID
+ WHERE `mapID` = '$mapID'
ORDER BY `moves` DESC, `dateModified` ASC
LIMIT 1";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
list($bestMoves, $byName, $solution) = mysql_fetch_row($result);
- //echo "Best solution for this map: $bestMoves by $byName";
- //$map = MergeMapSolution($map, $solution);
- //echo DisplayMap($map, $mapID);
}
$r = '';
@@ -229,7 +246,7 @@ function displayPastMaze($mapType, $name, $daysAgo = 1) {
$r .= '<div class="col2">';
$r .= "Best solution for this map: <b>$bestMoves by $byName </b>";
- $r .= DisplayMap($map, $mapID, 'example', 2);
+ $r .= DisplayMap($map, $mapID, 'normal', 2);
$r .= '</div>';
$r .= '</div>';
return $r;
@@ -237,17 +254,19 @@ 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 .= "</th>";
//Start table
- $r .= "<table style='border:1px solid #FFF'>";
- $r .= "<caption>$caption</caption>";
+ //$r .= "<table style='border:1px solid #FFF'>";
+ //$r .= "<caption>$caption</caption>";
//Headers on the top. including Rank.
- $r .= "<tr>";
- $r .= $headers;
- $r .= "</tr>";
+ //$r .= "<tr>";
+ //$r .= $headers;
+ //$r .= "</tr>";
$i = 1;
while ($row = mysql_fetch_assoc($result)) {
@@ -263,16 +282,30 @@ function displaystats($result, $caption = NULL) {
//Default
if ($wallColor == '')
$wallColor = '#666666';
+
+ $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 style='color:$displayColor';>" . $row['Name'] . '</td>';
+ $x .= '<td><a href="javascript:void(0)">' . $row['Moves'] . '</a></td>';
+ $x .= '<td>' . $row['Timetaken'] . '</td>';
+ $x .= "</tr>";
+
+ if ($userID == $_SESSION['userID']) {
+ $promotedContent .= $x;
+ } else {
+ $content .= $x;
+ }
- $r .= "<tr class='lbrow' onmouseover='changeWallEmblem(\"$wallEmblem\"); changeWallColor(\"$wallColor\"); loadSol(\"$mapid:$solution\");'>\n";
- $r .= "<td>$i</td>";
- $r .= "<td><span title='UserID: $userID'><a href='achievements?id=$userID' style='color:$displayColor'>$displayName</a></span></td>";
- //$r .= "<td style='color:$displayColor';>" . $row['Name'] . '</td>';
- $r .= '<td><a href="javascript:void(0)">' . $row['Moves'] . '</a></td>';
- $r .= '<td>' . $row['Timetaken'] . '</td>';
- $r .= "</tr>";
$i++;
}
+
+ $r = "<table style='border:1px solid #FFF'>";
+ $r .= "<caption>$caption</caption>";
+ $r .= $headers;
+ $r .= $promotedContent;
+ $r .= $content;
+
$r .= "</table>";
return $r;
}
@@ -329,10 +362,6 @@ function showStats(type) {
showStats(1);
</script>
-<div id="copy">
- Copyright &copy; 2011-2012 pathery.com
-</div>
-
<script src="sounds/script/soundmanager.js"></script>
<script type="text/javascript">soundManagerInit();</script>