application.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. $auth = new Auth();
  10. $auth->requireLogin();
  11. $id = trim((string) ($_GET['id'] ?? ''));
  12. $store = new JsonStore();
  13. $submission = $store->getSubmissionByKey($id);
  14. if ($submission === null) {
  15. http_response_code(404);
  16. echo 'Antrag nicht gefunden.';
  17. exit;
  18. }
  19. $csrf = Csrf::token();
  20. ?><!doctype html>
  21. <html lang="de">
  22. <head>
  23. <meta charset="utf-8">
  24. <meta name="viewport" content="width=device-width, initial-scale=1">
  25. <title>Antragsdetails</title>
  26. <link rel="stylesheet" href="/assets/css/tokens.css">
  27. <link rel="stylesheet" href="/assets/css/base.css">
  28. </head>
  29. <body>
  30. <main class="container">
  31. <section class="card">
  32. <p><a href="/admin/index.php">Zur Übersicht</a></p>
  33. <h1>Antragsdetails</h1>
  34. <p><strong>E-Mail:</strong> <?= htmlspecialchars((string) ($submission['email'] ?? '')) ?></p>
  35. <p><strong>Eingereicht:</strong> <?= htmlspecialchars((string) ($submission['submitted_at'] ?? '')) ?></p>
  36. <h2>Formulardaten</h2>
  37. <table>
  38. <tbody>
  39. <?php foreach ((array) ($submission['form_data'] ?? []) as $key => $value): ?>
  40. <tr>
  41. <th><?= htmlspecialchars((string) $key) ?></th>
  42. <td><?= htmlspecialchars(is_scalar($value) ? (string) $value : json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)) ?></td>
  43. </tr>
  44. <?php endforeach; ?>
  45. </tbody>
  46. </table>
  47. <h2>Uploads</h2>
  48. <?php if (empty($submission['uploads'])): ?>
  49. <p>Keine Uploads vorhanden.</p>
  50. <?php else: ?>
  51. <p><a href="/admin/download-zip.php?id=<?= urlencode((string) ($submission['application_key'] ?? '')) ?>">Alle Uploads als ZIP herunterladen</a></p>
  52. <?php foreach ((array) $submission['uploads'] as $field => $files): ?>
  53. <h3><?= htmlspecialchars((string) $field) ?></h3>
  54. <ul>
  55. <?php foreach ((array) $files as $idx => $file): ?>
  56. <li>
  57. <?= htmlspecialchars((string) ($file['original_filename'] ?? 'Datei')) ?>
  58. - <a href="/admin/download.php?id=<?= urlencode((string) ($submission['application_key'] ?? '')) ?>&field=<?= urlencode((string) $field) ?>&index=<?= urlencode((string) $idx) ?>">Download</a>
  59. </li>
  60. <?php endforeach; ?>
  61. </ul>
  62. <?php endforeach; ?>
  63. <?php endif; ?>
  64. <h2>Löschen</h2>
  65. <form method="post" action="/admin/delete.php" onsubmit="return confirm('Antrag wirklich löschen?');">
  66. <input type="hidden" name="csrf" value="<?= htmlspecialchars($csrf) ?>">
  67. <input type="hidden" name="id" value="<?= htmlspecialchars((string) ($submission['application_key'] ?? '')) ?>">
  68. <button type="submit">Antrag löschen</button>
  69. </form>
  70. </section>
  71. </main>
  72. </body>
  73. </html>