38539-vm/index.php
2026-02-17 20:36:44 +00:00

221 lines
9.1 KiB
PHP

<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('Europe/Rome');
require_once __DIR__ . '/db/config.php';
$projectName = 'EXTREMELOT';
$view = $_GET['view'] ?? 'mappa';
$errors = [];
$success = false;
$input = [
'name' => '',
'role' => 'Giocatore',
'class' => '',
'level' => 1,
'concept' => '',
];
if ($_SERVER['REQUEST_METHOD'] === 'POST' && $view === 'scheda') {
$input['name'] = trim((string)($_POST['name'] ?? ''));
$input['role'] = trim((string)($_POST['role'] ?? 'Giocatore'));
$input['class'] = trim((string)($_POST['class'] ?? ''));
$input['level'] = (int)($_POST['level'] ?? 1);
$input['concept'] = trim((string)($_POST['concept'] ?? ''));
if (mb_strlen($input['name']) < 2) {
$errors[] = 'Inserisci un nome.';
}
if (!$errors) {
try {
$db = db();
$db->exec("CREATE TABLE IF NOT EXISTS characters (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(120) NOT NULL,
role VARCHAR(60) NOT NULL,
class VARCHAR(120) NOT NULL,
level TINYINT UNSIGNED NOT NULL,
concept TEXT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");
$stmt = $db->prepare('INSERT INTO characters (name, role, class, level, concept) VALUES (:name, :role, :class, :level, :concept)');
$stmt->execute([
':name' => $input['name'],
':role' => $input['role'],
':class' => $input['class'],
':level' => $input['level'],
':concept' => $input['concept']
]);
$success = true;
} catch (Throwable $e) {}
}
}
// Mock Log entries
$mockLog = [
['time' => '21:30', 'text' => '<b>find</b> giunge a Lot'],
['time' => '21:31', 'text' => '<b>Rhael</b> lascia Lot'],
['time' => '21:32', 'text' => '<b>Glykeria</b> lascia Lot'],
['time' => '21:33', 'text' => '<b>Ildiko</b> giunge a Lot'],
['time' => '21:35', 'text' => '<b>Graviel</b> giunge a Lot'],
];
?>
<!doctype html>
<html lang="it">
<head>
<meta charset="utf-8" />
<title><?= $projectName ?></title>
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time() ?>">
<style>
/* Quick inline fixes to match the image precisely */
.gold-text { color: var(--gold); }
.dark-red-bg { background: var(--dark-red); color: var(--gold); }
.parchment-bg { background: var(--parchment); }
</style>
</head>
<body>
<div class="elot-wrapper">
<!-- TOP TABS -->
<header class="elot-header">
<div class="elot-logo" style="width: 230px; color: var(--gold); font-family: serif; font-weight: bold; font-size: 24px; letter-spacing: 2px; text-shadow: 2px 2px #000;">
EXTREMELOT
</div>
<div style="display: flex; gap: 5px; flex-wrap: wrap;">
<a href="?view=posta" class="elot-tab <?= $view === 'posta' ? 'active' : '' ?>">Posta</a>
<a href="?view=mappa" class="elot-tab <?= $view === 'mappa' ? 'active' : '' ?>">LOT</a>
<a href="?view=scheda" class="elot-tab <?= $view === 'scheda' ? 'active' : '' ?>">Scheda</a>
<a href="?view=presenti" class="elot-tab">Presenti</a>
<a href="?view=simboli" class="elot-tab">Simboli</a>
<a href="?view=regole" class="elot-tab">Regole</a>
<a href="?view=azioni" class="elot-tab">Azioni</a>
</div>
</header>
<!-- SIDEBAR -->
<aside class="elot-sidebar">
<div class="sidebar-info">
ANNO XXVIII<br>
11° MESE, 9° GIORNO
</div>
<div class="location-box">
<img src="https://picsum.photos/id/1015/240/120" alt="Mappa" class="location-img">
<div style="color: var(--gold); font-size: 10px; padding: 2px;">Gran Ducato di Lot</div>
</div>
<div class="nav-compass">
<div class="compass-btn empty"></div>
<div class="compass-btn">N</div>
<div class="compass-btn empty"></div>
<div class="compass-btn">O</div>
<div class="compass-btn" style="background: #900;">IN</div>
<div class="compass-btn">E</div>
<div class="compass-btn empty"></div>
<div class="compass-btn">S</div>
<div class="compass-btn empty"></div>
</div>
<div class="section-header">PRESENTE</div>
<div class="presenti-list">
<div style="font-size: 11px; margin-bottom: 5px; color: #5d0000; font-weight: bold;">
388 nel Regno
</div>
<?php foreach ($mockLog as $entry): ?>
<div class="presenti-entry">
<span class="entry-name"><?= explode(' ', strip_tags($entry['text']))[0] ?></span>
</div>
<?php endforeach; ?>
<div class="presenti-entry"><span class="entry-name">Arthemis</span></div>
<div class="presenti-entry"><span class="entry-name">Boromir</span></div>
<div class="presenti-entry"><span class="entry-name">Crysania</span></div>
</div>
<div style="margin-top: 10px;">
<button class="btn-lot" style="width: 100%; font-size: 11px; padding: 4px; margin-bottom: 2px;">Dove vuoi andare?</button>
<button class="btn-lot" style="width: 100%; font-size: 11px; padding: 4px; margin-bottom: 2px; background: #004400;">Chi è online?</button>
<button class="btn-lot" style="width: 100%; font-size: 11px; padding: 4px; background: #990000;">BAZAR</button>
</div>
</aside>
<!-- MAIN CONTENT -->
<main class="elot-main">
<div class="content-frame">
<?php if ($view === 'mappa'): ?>
<h1 class="main-title">Gran Ducato di Lot</h1>
<div style="text-align: center;">
<img src="https://picsum.photos/id/1018/800/500" alt="Mappa del Regno" style="border: 4px double var(--gold); max-width: 100%; height: auto; box-shadow: 0 0 15px rgba(0,0,0,0.5);">
<p style="margin-top: 20px; font-style: italic; color: #5d0000;">
Benvenuto nel Regno di Extremelot, viandante.
</p>
</div>
<!-- Chat Simulation -->
<div style="margin-top: 30px; border-top: 2px solid var(--gold); padding-top: 20px;">
<div style="height: 200px; overflow-y: auto; background: rgba(255,255,255,0.3); border: var(--border-classic); padding: 10px; font-size: 14px; margin-bottom: 10px;">
<p><b>[21:40] find:</b> Ben arrivati a tutti!</p>
<p><b>[21:42] Arthemis:</b> Grazie find, la locanda è aperta stasera?</p>
<p><b>[21:45] find:</b> Certamente, tra poco iniziamo la mescita.</p>
</div>
<div style="display: flex; gap: 5px;">
<input type="text" placeholder="Scrivi il tuo messaggio..." style="flex-grow: 1;">
<button class="compass-btn" style="width: 80px; font-size: 12px;">Invia</button>
<button class="compass-btn" style="width: 80px; font-size: 12px; background: #333;">Azione</button>
</div>
</div>
<?php elseif ($view === 'scheda'): ?>
<h1 class="main-title">Scheda del Personaggio</h1>
<?php if ($success): ?>
<div style="background: #fff8dc; color: #5d0000; padding: 10px; border: 2px solid var(--gold); margin-bottom: 20px; text-align: center; font-weight: bold;">
LA TUA ESSENZA È STATA IMPRESSA NEI REGISTRI DI LOT.
</div>
<?php endif; ?>
<form method="post">
<table class="scheda-table">
<tr>
<td class="label-td">Nome</td>
<td><input type="text" name="name" required></td>
</tr>
<tr>
<td class="label-td">Classe</td>
<td><input type="text" name="class" required placeholder="Es. Cavaliere, Mago..."></td>
</tr>
<tr>
<td class="label-td">Livello</td>
<td><input type="number" name="level" value="1"></td>
</tr>
<tr>
<td class="label-td">Concetto</td>
<td><textarea name="concept" rows="4"></textarea></td>
</tr>
</table>
<div style="text-align: center;">
<button type="submit" class="btn-lot">IMPRIME L'ESSENZA</button>
</div>
</form>
<?php else: ?>
<h1 class="main-title"><?= strtoupper($view) ?></h1>
<div style="text-align: center; padding: 40px;">
<p>Questa pergamena è ancora bianca...</p>
</div>
<?php endif; ?>
</div>
</main>
<!-- FOOTER LINKS -->
<footer class="elot-footer">
<a href="#" class="footer-link">Mappa del Regno</a>
<a href="#" class="footer-link">Mappa delle Isole</a>
<a href="#" class="footer-link">Mappa Testuale</a>
<a href="#" class="footer-link" style="color: #000;">Esci da Lot</a>
</footer>
</div>
</body>
</html>