| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <?php
- include 'db_config.php'; // Falls du die Connection auslagerst, sonst Code von oben kopieren
- // --- LOGIK: NEUEN SPIELER HINZUFÜGEN ---
- if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_player'])) {
- $sql = "INSERT IGNORE INTO spieler (name) VALUES (?)";
- $stmt = $pdo->prepare($sql);
- $stmt->execute([$_POST['neuer_spieler_name']]);
- header("Location: " . $_SERVER['PHP_SELF']);
- exit;
- }
- // --- LOGIK: SCORE HINZUFÜGEN ---
- if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_score'])) {
- $sql = "INSERT INTO scores (spieler_id, spiel_id, zeit, hilfe, sterne) VALUES (?, ?, ?, ?, ?)";
- $stmt = $pdo->prepare($sql);
- $stmt->execute([
- $_POST['spieler_id'],
- $_POST['spiel_id'],
- (int)$_POST['zeit'],
- (int)$_POST['hilfe'],
- (int)$_POST['sterne']
- ]);
- header("Location: " . $_SERVER['PHP_SELF']);
- exit;
- }
- // --- DATEN ABFRAGEN ---
- $stmtGames = $pdo->query("SELECT * FROM spiele ORDER BY id DESC");
- $exitGames = $stmtGames->fetchAll(PDO::FETCH_ASSOC);
- $stmtAllPlayers = $pdo->query("SELECT * FROM spieler ORDER BY name ASC");
- $playersList = $stmtAllPlayers->fetchAll();
- $sqlScores = "SELECT s.*, p.name as spieler_name
- FROM scores s
- JOIN spieler p ON s.spieler_id = p.id
- ORDER BY s.sterne DESC, s.zeit ASC";
- $allScores = $pdo->query($sqlScores)->fetchAll();
- ?>
- <!DOCTYPE html>
- <html lang="de">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>EXIT - Dashboard</title>
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" />
- <style>
- body { font-family: 'Segoe UI', sans-serif; background: #121212; color: #e0e0e0; margin: 0; padding-bottom: 100px; }
- .container { max-width: 1200px; margin: auto; padding: 20px; }
-
- .swiper { width: 100%; padding-bottom: 40px; }
- .swiper-slide { width: 320px; height: auto; }
-
- .card { background: #1e1e1e; border-radius: 12px; border: 1px solid #333; overflow: hidden; height: 100%; }
- .card img { width: 100%; height: 180px; object-fit: cover; opacity: 0.7; }
- .content { padding: 15px; }
-
- h2 { color: #e67e22; margin-top: 0; font-size: 1.2em; }
- .stats { width: 100%; border-collapse: collapse; font-size: 0.85em; }
- .stats td { padding: 6px 0; border-bottom: 1px solid #2a2a2a; }
-
- .badge { padding: 4px 8px; border-radius: 4px; font-size: 0.7em; font-weight: bold; text-transform: uppercase; }
- .level-Einsteiger { background: #27ae60; }
- .level-Profi { background: #c0392b; }
- .level-Fortgeschrittene { background: #2980b9; }
- .bottom-section { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; margin-top: 20px; }
- @media (max-width: 768px) { .bottom-section { grid-template-columns: 1fr; } }
- .form-section, .info-section { background: #1e1e1e; padding: 20px; border-radius: 12px; border: 1px solid #444; }
- .highlight-border { border-color: #e67e22; }
-
- input, select { width: 100%; padding: 10px; background: #2a2a2a; border: 1px solid #444; color: white; border-radius: 5px; box-sizing: border-box; margin-bottom: 10px; }
- button { background: #e67e22; color: white; border: none; padding: 12px; border-radius: 5px; cursor: pointer; font-weight: bold; width: 100%; }
- /* Footer Navigation */
- .footer-nav { position: fixed; bottom: 0; left: 0; width: 100%; background: #1a1a1a; border-top: 2px solid #e67e22; padding: 15px 0; display: flex; justify-content: center; gap: 20px; z-index: 1000; flex-wrap: wrap; }
- .footer-nav a { color: #e67e22; text-decoration: none; font-weight: bold; font-size: 0.85em; padding: 5px 10px; border: 1px solid transparent; transition: 0.3s; }
- .footer-nav a:hover { border-color: #e67e22; border-radius: 5px; }
-
- .info-section a { color: #e67e22; text-decoration: none; display: block; padding: 10px; border: 1px dashed #444; border-radius: 8px; text-align: center; }
- .info-section a:hover { background: #252525; }
- #playerModal { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #1e1e1e; padding: 30px; border-radius: 12px; border: 1px solid #e67e22; z-index: 2000; box-shadow: 0 0 50px rgba(0,0,0,0.8); }
- .overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 1500; }
- </style>
- </head>
- <body>
- <div class="container">
- <h1>🏆 EXIT Highscores</h1>
- <div class="swiper mySwiper">
- <div class="swiper-wrapper">
- <?php foreach ($exitGames as $game): ?>
- <div class="swiper-slide">
- <div class="card">
- <img src="<?= htmlspecialchars($game['bild_url']) ?>" alt="Cover">
- <div class="content">
- <span class="badge level-<?= $game['level'] ?>"><?= $game['level'] ?></span>
- <h2><?= htmlspecialchars($game['titel']) ?></h2>
- <table class="stats">
- <?php
- $found = false;
- foreach ($allScores as $entry):
- if ($entry['spiel_id'] == $game['id']): $found = true; ?>
- <tr>
- <td><strong><?= htmlspecialchars($entry['spieler_name']) ?></strong></td>
- <td><?= $entry['zeit'] ?>'</td>
- <td style="color:#f1c40f"><?= $entry['sterne'] ?>★</td>
- </tr>
- <?php endif; endforeach;
- if (!$found) echo "<tr><td colspan='3' style='color:#666'>Noch keine Scores.</td></tr>";
- ?>
- </table>
- </div>
- </div>
- </div>
- <?php endforeach; ?>
- </div>
- <div class="swiper-pagination"></div>
- </div>
- <div class="bottom-section">
- <div class="info-section">
- <h2>📜 Archiv</h2>
- <p style="font-size: 0.8em; color: #888;">Hier findest du alle Details zu den bereits gelösten Abenteuern.</p>
- <a href="gespielte_spiele.php">📂 Übersicht gespielte Spiele</a>
- </div>
- <div class="form-section highlight-border">
- <h2>🎯 Ergebnis eintragen</h2>
- <form method="POST">
- <select name="spiel_id" required>
- <?php foreach ($exitGames as $game): ?>
- <option value="<?= $game['id'] ?>"><?= htmlspecialchars($game['titel']) ?></option>
- <?php endforeach; ?>
- </select>
- <select name="spieler_id" required>
- <option value="">-- Wer hat gespielt? --</option>
- <?php foreach ($playersList as $p): ?>
- <option value="<?= $p['id'] ?>"><?= htmlspecialchars($p['name']) ?></option>
- <?php endforeach; ?>
- </select>
- <div style="display: flex; gap: 10px;">
- <input type="number" name="zeit" placeholder="Min" required>
- <input type="number" name="sterne" min="1" max="10" placeholder="Sterne">
- <input type="number" name="hilfe" placeholder="Hilfe">
- </div>
- <button type="submit" name="add_score">Score speichern</button>
- </form>
- </div>
- </div>
- </div>
- <div class="footer-nav">
- <a href="javascript:void(0)" onclick="toggleModal()">👤 NEUER SPIELER</a>
- <a href="besitz.php">📦 BESTAND PFLEGEN</a> <a href="gesamtliste.php">📝 GESAMTÜBERSICHT</a>
- <a href="admin.php">🛠 ADMIN</a>
- </div>
- <div class="overlay" id="overlay" onclick="toggleModal()"></div>
- <div id="playerModal">
- <h2>👤 Team/Spieler anlegen</h2>
- <form method="POST">
- <input type="text" name="neuer_spieler_name" placeholder="Name (z.B. Die Füchse)" required>
- <button type="submit" name="add_player">Anlegen</button>
- <button type="button" onclick="toggleModal()" style="background: #444; margin-top: 10px;">Abbrechen</button>
- </form>
- </div>
- <script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
- <script>
- const swiper = new Swiper(".mySwiper", {
- slidesPerView: "auto",
- spaceBetween: 20,
- centeredSlides: false,
- grabCursor: true,
- pagination: {
- el: ".swiper-pagination",
- clickable: true,
- },
- });
- function toggleModal() {
- const modal = document.getElementById('playerModal');
- const overlay = document.getElementById('overlay');
- const display = modal.style.display === 'block' ? 'none' : 'block';
- modal.style.display = display;
- overlay.style.display = display;
- }
- </script>
- </body>
- </html>
|