Dragon-Knight/templates/left_nav.php
Valithor Obsidion 4d5c345528 functions.php
2025-08-14 15:47:25 -04:00

69 lines
2.2 KiB
PHP

<section>
<div class="title"><img src="/img/button_location.gif" alt="Location" title="Location"></div>
Currently: <?php echo DragonKnight\user()->currentaction ?><br>
<?php
$lat = DragonKnight\user()->latitude;
$lon = DragonKnight\user()->longitude;
if ($lat < 0) {
$lat = ($lat * -1).'S';
} else {
$lat .= 'N';
}
if ($lon < 0) {
$lon = ($lon * -1).'W';
} else {
$lon .= 'E';
}
?>
Latitude: <?php echo $lat ?><br>
Longitude: <?php echo $lon ?><br>
<a href="javascript:openmappopup()">View Map</a><br>
<form action="/move" method="post" hx-post="/move" hx-target="#middle" class="move-compass">
<button name="direction" value="north" class="north">North</button>
<div class="mid">
<button name="direction" value="west" class="west">West</button>
<button name="direction" value="east" class="east">East</button>
</div>
<button name="direction" value="south" class="south">South</button>
</form>
</section>
<section>
<div class="title"><img src="/img/button_towns.gif" alt="Towns" title="Towns"></div>
<?php
if (DragonKnight\user()->currentaction == 'In Town') {
$town = DragonKnight\get_town_by_xy((int) DragonKnight\user()->latitude, (int) DragonKnight\user()->longitude);
echo "Welcome to <b>{$town['name']}</b>.<br><br>";
}
?>
Travel To:<br>
<?php
$town_list = explode(',', DragonKnight\user()->towns);
$towns = DragonKnight\db()->query('SELECT * FROM towns ORDER BY id;');
$mapped = false;
while ($row = $towns->fetchArray(SQLITE3_ASSOC)) {
$mapped = true;
if (in_array($row['id'], $town_list)) {
echo <<<HTML
<a href="/gotown/{$row['id']}" hx-get="/gotown/{$row['id']}" hx-target="#middle">{$row['name']}</a><br>
HTML;
}
}
if (! $mapped) {
echo 'You have no towns mapped.';
}
?>
</section>
<section>
<div class="title"><img src="/img/button_functions.gif" alt="Functions" title="Functions"></div>
<a href="/" hx-get="/" hx-target="#middle">Home</a><br>
<a href="/forum" hx-get="/forum" hx-target="#middle">Forum</a><br>
<a href="/settings">Settings</a><br>
<?php if (DragonKnight\user()->authlevel === 1): ?>
<a href="/admin">Admin</a><br>
<?php endif; ?>
<a href="/help">Help</a><br>
<a href="/logout">Log Out</a>
</section>