Town page no longer uses tables

This commit is contained in:
Sky Johnson 2024-12-13 13:15:04 -06:00
parent 82a2e42cb9
commit 5ea0de2ae1
4 changed files with 83 additions and 99 deletions

View File

@ -170,3 +170,12 @@ a:hover {
height: 38px; height: 38px;
} }
div.town-content {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
div.town-content div.options, div.town-content div.news {
grid-column: span 2;
}

View File

@ -101,34 +101,6 @@ if ($l['code'] !== 200) exit($l['code']);
if (!empty($l['middleware'])) foreach ($l['middleware'] as $middleware) $middleware(); if (!empty($l['middleware'])) foreach ($l['middleware'] as $middleware) $middleware();
$l['handler'](...$l['params'] ?? []); $l['handler'](...$l['params'] ?? []);
/*
$do = explode(':', $_GET['do'] ?? '');
match ($do[0]) {
'inn' => inn(),
'buy' => buy(),
'buy2' => buy2($do[1]),
'buy3' => buy3($do[1]),
// 'sell' => sell(),
'maps' => maps(),
'maps2' => maps2($do[1]),
'maps3' => maps3($do[1]),
'gotown' => travelto($do[1]),
'move' => move(),
'fight' => fight(),
'victory' => victory(),
'drop' => drop(),
'dead' => dead(),
'verify' => header("Location: users.php?do=verify"),
'spell' => healspells($do[1]),
'showchar' => showchar(),
'onlinechar' => onlinechar($do[1]),
'showmap' => showmap(),
'babblebox' => babblebox(),
'ninja' => ninja(),
default => donothing()
};
*/
function donothing() function donothing()
{ {
global $userrow; global $userrow;
@ -163,9 +135,8 @@ function dotown()
// News box. Grab latest news entry and display it. Something a little more graceful coming soon maybe. // News box. Grab latest news entry and display it. Something a little more graceful coming soon maybe.
if ($controlrow["shownews"] == 1) { if ($controlrow["shownews"] == 1) {
$newsrow = db()->query('SELECT * FROM news ORDER BY id DESC LIMIT 1;')->fetchArray(SQLITE3_ASSOC); $newsrow = db()->query('SELECT * FROM news ORDER BY id DESC LIMIT 1;')->fetchArray(SQLITE3_ASSOC);
$townrow["news"] = "<table width=\"95%\"><tr><td class=\"title\">Latest News</td></tr><tr><td>\n"; $townrow["news"] = '<div class="title">Latest News</div>';
$townrow["news"] .= "<span class=\"light\">[".prettydate($newsrow["postdate"])."]</span><br>".nl2br($newsrow["content"]); $townrow["news"] .= "<span class=\"light\">[".prettydate($newsrow["postdate"])."]</span><br>".nl2br($newsrow["content"]);
$townrow["news"] .= "</td></tr></table>\n";
} }
// Who's Online. Currently just members. Guests maybe later. // Who's Online. Currently just members. Guests maybe later.
@ -180,22 +151,18 @@ function dotown()
$online_rows[] = "<a href=\"/onlinechar/{$onlinerow["id"]}\">".$onlinerow["username"]."</a>"; $online_rows[] = "<a href=\"/onlinechar/{$onlinerow["id"]}\">".$onlinerow["username"]."</a>";
} }
$townrow["whosonline"] = "<table width=\"95%\"><tr><td class=\"title\">Who's Online</td></tr><tr><td>\n"; $townrow["whosonline"] = '<div class="title">Who\'s Online</div>';
$townrow["whosonline"] .= "There are <b>$online_count</b> user(s) online within the last 10 minutes: "; $townrow["whosonline"] .= "There are <b>$online_count</b> user(s) online within the last 10 minutes: ";
$townrow["whosonline"] .= rtrim(implode(', ', $online_rows), ', '); $townrow["whosonline"] .= rtrim(implode(', ', $online_rows), ', ');
$townrow["whosonline"] .= "</td></tr></table>\n";
} }
if ($controlrow["showbabble"] == 1) { if ($controlrow["showbabble"] == 1) {
$townrow["babblebox"] = <<<HTML $townrow["babblebox"] = <<<HTML
<table width="95%"> <div class="title">Babble Box</div>
<tr><td class="title">Babble Box</td></tr> <iframe src="/babblebox" name="sbox" width="100%" height="250" frameborder="0" id="bbox">
<tr><td> Your browser does not support inline frames! The Babble Box will not be available until you upgrade to
<iframe src="/babblebox" name="sbox" width="100%" height="250" frameborder="0" id="bbox"> a newer <a href="http://www.mozilla.org" target="_new">browser</a>.
Your browser does not support inline frames! The Babble Box will not be available until you upgrade to a newer <a href="http://www.mozilla.org" target="_new">browser</a>. </iframe>
</iframe>
</td></tr>
</table>
HTML; HTML;
} }
@ -305,15 +272,13 @@ function babblebox()
redirect('/babblebox'); redirect('/babblebox');
} }
$babblebox = ["content" => ""]; $babblebox['content'] = '';
$bg = 1; $query = db()->query('SELECT * FROM babble ORDER BY id DESC LIMIT 40;');
$query = db()->query('SELECT * FROM babble ORDER BY id DESC LIMIT 20;');
while ($babblerow = $query->fetchArray(SQLITE3_ASSOC)) { while ($babblerow = $query->fetchArray(SQLITE3_ASSOC)) {
if ($bg == 1) { $new = "<div style=\"width:98%; background-color:#eeeeee;\">[<b>".$babblerow["author"]."</b>] ".$babblerow["babble"]."</div>\n"; $bg = 2; } $new = "<div class=\"message\">[<b>{$babblerow["author"]}</b>] {$babblerow["babble"]}</div>\n";
else { $new = "<div style=\"width:98%; background-color:#ffffff;\">[<b>".$babblerow["author"]."</b>] ".stripslashes($babblerow["babble"])."</div>\n"; $bg = 1; }
$babblebox["content"] = $new . $babblebox["content"]; $babblebox["content"] = $new . $babblebox["content"];
} }
$babblebox["content"] .= "<center><form action=\"/babblebox\" method=\"post\"><input type=\"text\" name=\"babble\" size=\"15\" maxlength=\"120\" /><br><input type=\"submit\" name=\"submit\" value=\"Babble\" /> <input type=\"reset\" name=\"reset\" value=\"Clear\" /></form></center>"; $babblebox["content"] .= '<form action="/babblebox" method="post" style="margin-top: 1rem;"><input type="text" name="babble" maxlength="255" style="width: 100%;"><br><input type="submit" name="submit" value="Babble"><input type="reset" name="reset" value="Clear"></form>';
echo parsetemplate("<html>\n" . gettemplate("babblebox"), $babblebox); echo parsetemplate("<html>\n" . gettemplate("babblebox"), $babblebox);
} }

View File

@ -1,34 +1,44 @@
<?php <?php
$template = <<<THEVERYENDOFYOU $template = <<<HTML
<head> <head>
<title>shoutbox</title> <title>Babblebox</title>
<style type="text/css"> <style type="text/css">
body { body {
background-image: url(/img/background.jpg); background-image: url(/img/background.jpg);
color: black; color: black;
font: 11px verdana; font: 11px verdana;
margins: 0px; margin: 0px;
padding: 0px; padding: 0px;
} }
div {
padding: 2px; div {
border: solid 1px black; padding: 2px;
margin: 2px; border: solid 1px black;
text-align: left; margin: 2px;
} text-align: left;
a { }
color: #663300;
text-decoration: none; a {
font-weight: bold; color: #663300;
} text-decoration: none;
a:hover { font-weight: bold;
color: #330000; }
}
</style> a:hover {
color: #330000;
}
div.message {
background-color: white;
}
div.message:nth-child(even) {
background-color: #eeeeee;
}
</style>
</head> </head>
<body onload="window.scrollTo(0,99999)"> <body onload="window.scrollTo(0,99999)">
{{content}} {{content}}
</body> </body>
</html> </html>
THEVERYENDOFYOU; HTML;
?>

View File

@ -1,26 +1,26 @@
<?php <?php
$template = <<<THEVERYENDOFYOU $template = <<<HTML
<table width="100%"> <div class="town-content">
<tr><td class="title"><img src="/img/town_{{id}}.gif" alt="Welcome to {{name}}" title="Welcome to {{name}}" /></td></tr> <div class="options">
<tr><td> <div class="title"><img src="/img/town_{{id}}.gif" alt="Welcome to {{name}}" title="Welcome to {{name}}"></div>
<b>Town Options:</b><br> <b>Town Options:</b><br>
<ul> <ul>
<li /><a href="/inn">Rest at the Inn</a> <li><a href="/inn">Rest at the Inn</a></li>
<li /><a href="/buy">Buy Weapons/Armor</a> <li><a href="/buy">Buy Weapons/Armor</a></li>
<li /><a href="/maps">Buy Maps</a> <li><a href="/maps">Buy Maps</a></li>
</ul> </ul>
</td></tr> </div>
<tr><td><center>
{{news}} <div class="news">
<br> {{news}}
<table width="95%"> </div>
<tr><td width="50%">
{{whosonline}} <div class="whos-online">
</td><td> {{whosonline}}
{{babblebox}} </div>
</td></tr>
</table> <div class="babblebox">
</td></tr> {{babblebox}}
</table> </div>
THEVERYENDOFYOU; </div>
?> HTML;