12-28-12. I plan on making considerable changes to this page in the near future.
Thank you for your patience!
Showing scores for the maps played on echo $dateAsStr; ?>
if ($daysAgo > 1) {
echo "
Current Day";
echo "
Next Day";
}
echo "
Previous Day";
$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;
?>
echo $statContent;
function displayPastMaze($mapType, $name, $daysAgo = 1) {
//Ensure no cheating
if ($daysAgo < 1)
return;
$pastMap = pastMap($mapType, $daysAgo);
$mapID = $pastMap;
$mapcode = getMapCode($mapID);
$map = GenerateMapByCode($mapcode);
$sql = "SELECT
maps.ID as mapID,
solution,
users.displayName as Name,
SUM(solutions.moves) as Moves,
timediff(solutions.dateModified, maps.dateCreated) as Timetaken,
userData.wallColor,
userData.wallEmblem,
userData.displayColor,
users.ID as userID
FROM `maps`
JOIN `solutions`
ON maps.ID = solutions.mapID
JOIN `users`
ON solutions.userID = users.ID
JOIN `mapOfTheDay`
ON maps.ID = mapOfTheDay.mapID
LEFT JOIN `userData`
ON users.ID = userData.userID
WHERE
maps.ID = '$mapID'
GROUP BY solutions.userID
ORDER BY Moves DESC, `dateModified` ASC
";
$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);
//Sucky temporary solution:
$GLOBALS['specialMapName'] = $map[0][6];
$sql = "SELECT `moves`, `displayName`, `solution`
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);
}
$r = '';
$r .= '
';
$r .= "
";
$r .= '
';
$r .= $stats;
$r .= '
';
$r .= '
';
$r .= "Best solution for this map: $bestMoves by $byName ";
$r .= DisplayMap($map, $mapID, 'normal', 2);
$r .= '
';
$r .= '
';
return $r;
}
function displaystats($result, $caption = NULL) {
//Get names.
$headers = "
";
$headers .= "Rank | ";
$headers .= "Name | ";
$headers .= "Moves | ";
$headers .= "Time taken | ";
$headers .= "";
//Start table
//$r .= "";
//$r .= "$caption";
//Headers on the top. including Rank.
//$r .= "";
//$r .= $headers;
//$r .= "
";
$i = 1;
while ($row = mysql_fetch_assoc($result)) {
$rowcontent = '';
$mapid = $row['mapID'];
$solution = $row['solution'];
$wallColor = $row['wallColor'];
$wallEmblem = $row['wallEmblem'];
$displayColor = $row['displayColor'];
$displayName = $row['Name'];
$userID = $row['userID'];
//Default
if ($wallColor == '')
$wallColor = '#666666';
$x = "\n";
$x .= "$i | ";
$x .= "$displayName | ";
//$x .= "" . $row['Name'] . ' | ';
$x .= '' . $row['Moves'] . ' | ';
$x .= '' . $row['Timetaken'] . ' | ';
$x .= "
";
if ($userID == $_SESSION['userID']) {
$promotedContent .= $x;
} else {
$content .= $x;
}
$i++;
}
$r = "";
$r .= "$caption";
$r .= $headers;
$r .= $promotedContent;
$r .= $content;
$r .= "
";
return $r;
}
function mysql_field_array( $query ) {
$field = mysql_num_fields( $query );
for ( $i = 0; $i < $field; $i++ ) {
$names[] = mysql_field_name( $query, $i );
}
return $names;
}
?>
echo $tStats;?>
echo $yStats;?>
echo $wStats;?>
echo $mStats;?>