<?php
// admin/formular_submit_log_view.php

session_start();
require_once __DIR__ . '/../includes/init.php';
require_once __DIR__ . '/../auth/AuthController.php';
require_once __DIR__ . '/../includes/core/ErrorLogger.php';

$auth = new AuthController();
if (!$auth->isLoggedIn() || ($_SESSION['admin_role'] ?? '') !== 'admin') {
    http_response_code(403);
    echo 'Zugriff verweigert.';
    exit;
}

$logFile = __DIR__ . '/../includes/logs/formular_submit.log';
$logContent = file_exists($logFile) ? file_get_contents($logFile) : 'Keine Formular-EintrÃ¤ge protokolliert.';
$pageHelp = buildDefaultPageHelp('Formular-Log anzeigen', '<pre></pre>', (string) ($_SERVER['SCRIPT_NAME'] ?? ''));

?><!DOCTYPE html>
<html lang="de">
<head>
  <meta charset="UTF-8">
  <title>Formular-Log anzeigen</title>
  <link href="/assets/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
  <style>
    pre {
      background: #f8f9fa;
      padding: 1em;
      border: 1px solid #ccc;
      white-space: pre-wrap;
      font-size: 0.9rem;
    }
  </style>
</head>
<body class="container mt-4">
  <?= $pageHelp ?>
  <h1>Formular-Log anzeigen</h1>
  <p><a href="admin.php" class="btn btn-secondary">ZurÃ¼ck zu Admin</a></p>
  <pre><?= htmlspecialchars($logContent) ?></pre>
</body>
</html>
