ratcatcher/website/hiscores/hiscores.php

64 lines
1.4 KiB
PHP

<script language="php">
if (!isset($havefunctions)) {
include("functions.php");
}
if (isset($_GET['easymode'])) {
$easymode=$_GET['easymode'];
}
sqlite_escape_string($easymode);
/*
echo "<html>";
echo "<title>ratcatcher high scores</title>";
echo "<body bgcolor=\"#ffffff\">";
*/
if ($easymode) {
echo "<center><h2>High Scores - Easy</h2></center>";
} else {
echo "<center><h2>High Scores - Normal</h2></center>";
}
echo "<table width=100%>";
echo "<tr>";
echo "<th align=left>#</th>";
echo "<th align=left>Score</th>";
echo "<th align=left>Level</th>";
echo "<th align=left>Name</th>";
echo "</tr>";
if ($easymode) {
$db = sqlite_open("/var/www/html/ratcatcher.nethack.net/hiscores/hiscores.easy.db", 0666, $errorstr);
} else {
$db = sqlite_open("/var/www/html/ratcatcher.nethack.net/hiscores/hiscores.db", 0666, $errorstr);
}
$q = "select score, level, name from hiscores order by score desc limit 10";
$result = sqlite_query($db, $q);
# loop through results
$pos = 1;
while ($row = sqlite_fetch_array($result)) {
# print this line
printf("<tr>\n");
printf("<td %s>%d</td>", getbgcolor($pos), $pos);
printf("<td %s>%s</td>", getbgcolor($pos), addcommas($row["score"]));
printf("<td %s>%s</td>", getbgcolor($pos), getworld($row["level"]));
printf("<td %s>%s</td>", getbgcolor($pos), $row["name"]);
printf("</tr>\n");
$pos++;
}
sqlite_close($db);
echo "</table>";
/*
echo "</body>";
echo "</html>";
*/
</script>