Update index-controller.php

This commit is contained in:
2026-07-18 15:53:33 +02:00
parent 3f9c048493
commit a8e76c782d
+11 -12
View File
@@ -1,7 +1,8 @@
<?php
// Standardpfad
$pfad = $_GET["pfad"] ?? "home";
// Allowlist für Content
// Allowlists
$erlaubte_content_seiten = [
"accessibility", "confirm-password", "confirm-register", "createArticle",
"datenschutz", "home", "impressum", "login", "nutzungsbedingungen",
@@ -9,7 +10,6 @@ $erlaubte_content_seiten = [
"show-mail", "showArticle", "showCategory", "updateArticle"
];
// Allowlist für Controller
$erlaubte_controller = [
"confirm-password", "confirm-register", "createArticle", "deleteAccount",
"deleteArticle", "home", "index", "like", "login", "logout",
@@ -17,18 +17,17 @@ $erlaubte_controller = [
"search-results", "showArticle", "showCategory", "updateArticle"
];
// Validierung der Content-Seite
if (!in_array($pfad, $erlaubte_content_seiten)) {
$pfad = "404";
}
// Controller laden
if (in_array($pfad, $erlaubte_controller)) {
include_once "php/controller/" . $pfad . "-controller.php";
// Automatisch den passenden Controller laden, falls erlaubt
if ($pfad !== "404" && in_array($pfad, $erlaubte_controller)) {
include_once "../php/controller/" . $pfad . "-controller.php";
// Nach Logout oder Account-Löschung das Skript sofort beenden
// Sofortiger Abbruch bei zerstörenden Aktionen
if ($pfad === "logout" || $pfad === "deleteAccount") {
exit();
}
}
?>
// Content-Validierung: Wenn der Pfad nicht erlaubt ist, dann 404
if (!in_array($pfad, $erlaubte_content_seiten)) {
$pfad = "404";
}