index.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. declare(strict_types=1);
  3. use App\App\Bootstrap;
  4. use App\Admin\Auth;
  5. use App\Storage\JsonStore;
  6. require dirname(__DIR__) . '/src/autoload.php';
  7. Bootstrap::init();
  8. $auth = new Auth();
  9. $auth->requireLogin();
  10. $store = new JsonStore();
  11. $list = $store->listSubmissions();
  12. $query = trim((string) ($_GET['q'] ?? ''));
  13. if ($query !== '') {
  14. $list = array_values(array_filter($list, static function (array $item) use ($query): bool {
  15. return strpos(strtolower((string) ($item['email'] ?? '')), strtolower($query)) !== false;
  16. }));
  17. }
  18. ?><!doctype html>
  19. <html lang="de">
  20. <head>
  21. <meta charset="utf-8">
  22. <meta name="viewport" content="width=device-width, initial-scale=1">
  23. <title>Admin Übersicht</title>
  24. <link rel="stylesheet" href="/assets/css/tokens.css">
  25. <link rel="stylesheet" href="/assets/css/base.css">
  26. </head>
  27. <body>
  28. <main class="container">
  29. <section class="card">
  30. <h1>Abgeschlossene Anträge</h1>
  31. <p><a href="/admin/login.php?logout=1">Abmelden</a></p>
  32. <form method="get" class="field">
  33. <label for="q">Suche E-Mail</label>
  34. <input id="q" name="q" value="<?= htmlspecialchars($query) ?>">
  35. </form>
  36. <?php if (empty($list)): ?>
  37. <p>Keine Anträge vorhanden.</p>
  38. <?php else: ?>
  39. <table>
  40. <thead>
  41. <tr>
  42. <th>E-Mail</th>
  43. <th>Eingereicht</th>
  44. <th>Aktion</th>
  45. </tr>
  46. </thead>
  47. <tbody>
  48. <?php foreach ($list as $item): ?>
  49. <tr>
  50. <td><?= htmlspecialchars((string) ($item['email'] ?? '')) ?></td>
  51. <td><?= htmlspecialchars((string) ($item['submitted_at'] ?? '')) ?></td>
  52. <td><a href="/admin/application.php?id=<?= urlencode((string) ($item['application_key'] ?? '')) ?>">Details</a></td>
  53. </tr>
  54. <?php endforeach; ?>
  55. </tbody>
  56. </table>
  57. <?php endif; ?>
  58. </section>
  59. </main>
  60. </body>
  61. </html>