application.php 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. declare(strict_types=1);
  3. use App\App\Bootstrap;
  4. use App\Admin\Auth;
  5. use App\Security\Csrf;
  6. use App\Storage\JsonStore;
  7. require dirname(__DIR__) . '/src/autoload.php';
  8. Bootstrap::init();
  9. $app = Bootstrap::config('app');
  10. $auth = new Auth();
  11. $auth->requireLogin();
  12. $id = trim((string) ($_GET['id'] ?? ''));
  13. $store = new JsonStore();
  14. $submission = $store->getSubmissionByKey($id);
  15. if ($submission === null) {
  16. http_response_code(404);
  17. echo 'Antrag nicht gefunden.';
  18. exit;
  19. }
  20. $csrf = Csrf::token();
  21. ?><!doctype html>
  22. <html lang="de">
  23. <head>
  24. <meta charset="utf-8">
  25. <meta name="viewport" content="width=device-width, initial-scale=1">
  26. <title>Antragsdetails</title>
  27. <link rel="stylesheet" href="<?= htmlspecialchars(Bootstrap::url('assets/css/tokens.css')) ?>">
  28. <link rel="stylesheet" href="<?= htmlspecialchars(Bootstrap::url('assets/css/base.css')) ?>">
  29. </head>
  30. <body class="admin-page">
  31. <header class="site-header">
  32. <div class="container header-inner">
  33. <a class="brand" href="<?= htmlspecialchars(Bootstrap::url('admin/index.php')) ?>">
  34. <img class="brand-logo" src="<?= htmlspecialchars(Bootstrap::url('assets/images/feuerwehr-Logo-invers.webp')) ?>" alt="Feuerwehr Logo">
  35. <div class="brand-title"><?= htmlspecialchars((string) ($app['project_name'] ?? 'Admin')) ?></div>
  36. </a>
  37. </div>
  38. </header>
  39. <main class="container">
  40. <section class="card">
  41. <p><a href="<?= htmlspecialchars(Bootstrap::url('admin/index.php')) ?>">Zur Übersicht</a></p>
  42. <h1>Antragsdetails</h1>
  43. <p><strong>E-Mail:</strong> <?= htmlspecialchars((string) ($submission['email'] ?? '')) ?></p>
  44. <p><strong>Eingereicht:</strong> <?= htmlspecialchars((string) ($submission['submitted_at'] ?? '')) ?></p>
  45. <h2>Formulardaten</h2>
  46. <div class="table-responsive">
  47. <table class="table-compact">
  48. <tbody>
  49. <?php foreach ((array) ($submission['form_data'] ?? []) as $key => $value): ?>
  50. <tr>
  51. <th><?= htmlspecialchars((string) $key) ?></th>
  52. <td><?= htmlspecialchars(is_scalar($value) ? (string) $value : json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)) ?></td>
  53. </tr>
  54. <?php endforeach; ?>
  55. </tbody>
  56. </table>
  57. </div>
  58. <h2>Uploads</h2>
  59. <?php if (empty($submission['uploads'])): ?>
  60. <p>Keine Uploads vorhanden.</p>
  61. <?php else: ?>
  62. <p><a href="<?= htmlspecialchars(Bootstrap::url('admin/download-zip.php?id=' . urlencode((string) ($submission['application_key'] ?? '')))) ?>">Alle Uploads als ZIP herunterladen</a></p>
  63. <?php foreach ((array) $submission['uploads'] as $field => $files): ?>
  64. <h3><?= htmlspecialchars((string) $field) ?></h3>
  65. <ul>
  66. <?php foreach ((array) $files as $idx => $file): ?>
  67. <li>
  68. <?= htmlspecialchars((string) ($file['original_filename'] ?? 'Datei')) ?>
  69. - <a href="<?= htmlspecialchars(Bootstrap::url('admin/download.php?id=' . urlencode((string) ($submission['application_key'] ?? '')) . '&field=' . urlencode((string) $field) . '&index=' . urlencode((string) $idx))) ?>">Download</a>
  70. </li>
  71. <?php endforeach; ?>
  72. </ul>
  73. <?php endforeach; ?>
  74. <?php endif; ?>
  75. <h2>Löschen</h2>
  76. <form method="post" action="<?= htmlspecialchars(Bootstrap::url('admin/delete.php')) ?>" onsubmit="return confirm('Antrag wirklich löschen?');">
  77. <input type="hidden" name="csrf" value="<?= htmlspecialchars($csrf) ?>">
  78. <input type="hidden" name="id" value="<?= htmlspecialchars((string) ($submission['application_key'] ?? '')) ?>">
  79. <button type="submit" class="btn">Antrag löschen</button>
  80. </form>
  81. </section>
  82. </main>
  83. </body>
  84. </html>