diff --git a/php/controller/deleteComment-controller.php b/php/controller/deleteComment-controller.php index 4eeaeca..a006757 100644 --- a/php/controller/deleteComment-controller.php +++ b/php/controller/deleteComment-controller.php @@ -5,6 +5,7 @@ if (session_status() === PHP_SESSION_NONE) { } require_once __DIR__ . "/../model/CommentManager.php"; +require_once __DIR__ . "/../../includes/csrf.php"; /* * Kommentare dürfen nur über ein POST-Formular gelöscht werden. @@ -44,6 +45,23 @@ if (!isset($_SESSION["user_email"])) { exit(); } +// CSRF-Token prüfen, bevor irgendeine Änderung vorgenommen wird +if (!csrf_verify()) { + $_SESSION["comment_message"] = "Deine Sitzung ist abgelaufen. Bitte lade die Seite neu."; + $_SESSION["comment_message_type"] = "error"; + + if ($articleId !== false && $articleId !== null) { + header( + "Location: index.php?pfad=showArticle&id=" + . urlencode((string) $articleId) + . "#comments" + ); + } else { + header("Location: index.php"); + } + exit(); +} + /* * Kommentar-ID und Beitrags-ID müssen gültige Zahlen sein. */ @@ -102,4 +120,4 @@ header( . "#comments" ); -exit(); +exit(); \ No newline at end of file