index.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?php
  2. include 'db_config.php'; // Falls du die Connection auslagerst, sonst Code von oben kopieren
  3. // --- LOGIK: NEUEN SPIELER HINZUFÜGEN ---
  4. if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_player'])) {
  5. $sql = "INSERT IGNORE INTO spieler (name) VALUES (?)";
  6. $stmt = $pdo->prepare($sql);
  7. $stmt->execute([$_POST['neuer_spieler_name']]);
  8. header("Location: " . $_SERVER['PHP_SELF']);
  9. exit;
  10. }
  11. // --- LOGIK: SCORE HINZUFÜGEN ---
  12. if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_score'])) {
  13. $sql = "INSERT INTO scores (spieler_id, spiel_id, zeit, hilfe, sterne) VALUES (?, ?, ?, ?, ?)";
  14. $stmt = $pdo->prepare($sql);
  15. $stmt->execute([
  16. $_POST['spieler_id'],
  17. $_POST['spiel_id'],
  18. (int)$_POST['zeit'],
  19. (int)$_POST['hilfe'],
  20. (int)$_POST['sterne']
  21. ]);
  22. header("Location: " . $_SERVER['PHP_SELF']);
  23. exit;
  24. }
  25. // --- DATEN ABFRAGEN ---
  26. $stmtGames = $pdo->query("SELECT * FROM spiele ORDER BY id DESC");
  27. $exitGames = $stmtGames->fetchAll(PDO::FETCH_ASSOC);
  28. $stmtAllPlayers = $pdo->query("SELECT * FROM spieler ORDER BY name ASC");
  29. $playersList = $stmtAllPlayers->fetchAll();
  30. $sqlScores = "SELECT s.*, p.name as spieler_name
  31. FROM scores s
  32. JOIN spieler p ON s.spieler_id = p.id
  33. ORDER BY s.sterne DESC, s.zeit ASC";
  34. $allScores = $pdo->query($sqlScores)->fetchAll();
  35. ?>
  36. <!DOCTYPE html>
  37. <html lang="de">
  38. <head>
  39. <meta charset="UTF-8">
  40. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  41. <title>EXIT - Dashboard</title>
  42. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" />
  43. <style>
  44. body { font-family: 'Segoe UI', sans-serif; background: #121212; color: #e0e0e0; margin: 0; padding-bottom: 100px; }
  45. .container { max-width: 1200px; margin: auto; padding: 20px; }
  46. .swiper { width: 100%; padding-bottom: 40px; }
  47. .swiper-slide { width: 320px; height: auto; }
  48. .card { background: #1e1e1e; border-radius: 12px; border: 1px solid #333; overflow: hidden; height: 100%; }
  49. .card img { width: 100%; height: 180px; object-fit: cover; opacity: 0.7; }
  50. .content { padding: 15px; }
  51. h2 { color: #e67e22; margin-top: 0; font-size: 1.2em; }
  52. .stats { width: 100%; border-collapse: collapse; font-size: 0.85em; }
  53. .stats td { padding: 6px 0; border-bottom: 1px solid #2a2a2a; }
  54. .badge { padding: 4px 8px; border-radius: 4px; font-size: 0.7em; font-weight: bold; text-transform: uppercase; }
  55. .level-Einsteiger { background: #27ae60; }
  56. .level-Profi { background: #c0392b; }
  57. .level-Fortgeschrittene { background: #2980b9; }
  58. .bottom-section { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; margin-top: 20px; }
  59. @media (max-width: 768px) { .bottom-section { grid-template-columns: 1fr; } }
  60. .form-section, .info-section { background: #1e1e1e; padding: 20px; border-radius: 12px; border: 1px solid #444; }
  61. .highlight-border { border-color: #e67e22; }
  62. input, select { width: 100%; padding: 10px; background: #2a2a2a; border: 1px solid #444; color: white; border-radius: 5px; box-sizing: border-box; margin-bottom: 10px; }
  63. button { background: #e67e22; color: white; border: none; padding: 12px; border-radius: 5px; cursor: pointer; font-weight: bold; width: 100%; }
  64. /* Footer Navigation */
  65. .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; }
  66. .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; }
  67. .footer-nav a:hover { border-color: #e67e22; border-radius: 5px; }
  68. .info-section a { color: #e67e22; text-decoration: none; display: block; padding: 10px; border: 1px dashed #444; border-radius: 8px; text-align: center; }
  69. .info-section a:hover { background: #252525; }
  70. #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); }
  71. .overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 1500; }
  72. </style>
  73. </head>
  74. <body>
  75. <div class="container">
  76. <h1>🏆 EXIT Highscores</h1>
  77. <div class="swiper mySwiper">
  78. <div class="swiper-wrapper">
  79. <?php foreach ($exitGames as $game): ?>
  80. <div class="swiper-slide">
  81. <div class="card">
  82. <img src="<?= htmlspecialchars($game['bild_url']) ?>" alt="Cover">
  83. <div class="content">
  84. <span class="badge level-<?= $game['level'] ?>"><?= $game['level'] ?></span>
  85. <h2><?= htmlspecialchars($game['titel']) ?></h2>
  86. <table class="stats">
  87. <?php
  88. $found = false;
  89. foreach ($allScores as $entry):
  90. if ($entry['spiel_id'] == $game['id']): $found = true; ?>
  91. <tr>
  92. <td><strong><?= htmlspecialchars($entry['spieler_name']) ?></strong></td>
  93. <td><?= $entry['zeit'] ?>'</td>
  94. <td style="color:#f1c40f"><?= $entry['sterne'] ?>★</td>
  95. </tr>
  96. <?php endif; endforeach;
  97. if (!$found) echo "<tr><td colspan='3' style='color:#666'>Noch keine Scores.</td></tr>";
  98. ?>
  99. </table>
  100. </div>
  101. </div>
  102. </div>
  103. <?php endforeach; ?>
  104. </div>
  105. <div class="swiper-pagination"></div>
  106. </div>
  107. <div class="bottom-section">
  108. <div class="info-section">
  109. <h2>📜 Archiv</h2>
  110. <p style="font-size: 0.8em; color: #888;">Hier findest du alle Details zu den bereits gelösten Abenteuern.</p>
  111. <a href="gespielte_spiele.php">📂 Übersicht gespielte Spiele</a>
  112. </div>
  113. <div class="form-section highlight-border">
  114. <h2>🎯 Ergebnis eintragen</h2>
  115. <form method="POST">
  116. <select name="spiel_id" required>
  117. <?php foreach ($exitGames as $game): ?>
  118. <option value="<?= $game['id'] ?>"><?= htmlspecialchars($game['titel']) ?></option>
  119. <?php endforeach; ?>
  120. </select>
  121. <select name="spieler_id" required>
  122. <option value="">-- Wer hat gespielt? --</option>
  123. <?php foreach ($playersList as $p): ?>
  124. <option value="<?= $p['id'] ?>"><?= htmlspecialchars($p['name']) ?></option>
  125. <?php endforeach; ?>
  126. </select>
  127. <div style="display: flex; gap: 10px;">
  128. <input type="number" name="zeit" placeholder="Min" required>
  129. <input type="number" name="sterne" min="1" max="10" placeholder="Sterne">
  130. <input type="number" name="hilfe" placeholder="Hilfe">
  131. </div>
  132. <button type="submit" name="add_score">Score speichern</button>
  133. </form>
  134. </div>
  135. </div>
  136. </div>
  137. <div class="footer-nav">
  138. <a href="javascript:void(0)" onclick="toggleModal()">👤 NEUER SPIELER</a>
  139. <a href="besitz.php">📦 BESTAND PFLEGEN</a> <a href="gesamtliste.php">📝 GESAMTÜBERSICHT</a>
  140. <a href="admin.php">🛠 ADMIN</a>
  141. </div>
  142. <div class="overlay" id="overlay" onclick="toggleModal()"></div>
  143. <div id="playerModal">
  144. <h2>👤 Team/Spieler anlegen</h2>
  145. <form method="POST">
  146. <input type="text" name="neuer_spieler_name" placeholder="Name (z.B. Die Füchse)" required>
  147. <button type="submit" name="add_player">Anlegen</button>
  148. <button type="button" onclick="toggleModal()" style="background: #444; margin-top: 10px;">Abbrechen</button>
  149. </form>
  150. </div>
  151. <script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
  152. <script>
  153. const swiper = new Swiper(".mySwiper", {
  154. slidesPerView: "auto",
  155. spaceBetween: 20,
  156. centeredSlides: false,
  157. grabCursor: true,
  158. pagination: {
  159. el: ".swiper-pagination",
  160. clickable: true,
  161. },
  162. });
  163. function toggleModal() {
  164. const modal = document.getElementById('playerModal');
  165. const overlay = document.getElementById('overlay');
  166. const display = modal.style.display === 'block' ? 'none' : 'block';
  167. modal.style.display = display;
  168. overlay.style.display = display;
  169. }
  170. </script>
  171. </body>
  172. </html>