Update deleteComment-controller.php

This commit is contained in:
2026-07-19 16:01:42 +02:00
parent 50b29c96d6
commit 3bce65a1a5
+19 -1
View File
@@ -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();