Update index-controller.php
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// Standardpfad
|
||||||
$pfad = $_GET["pfad"] ?? "home";
|
$pfad = $_GET["pfad"] ?? "home";
|
||||||
|
|
||||||
// Allowlist für Content
|
// Allowlists
|
||||||
$erlaubte_content_seiten = [
|
$erlaubte_content_seiten = [
|
||||||
"accessibility", "confirm-password", "confirm-register", "createArticle",
|
"accessibility", "confirm-password", "confirm-register", "createArticle",
|
||||||
"datenschutz", "home", "impressum", "login", "nutzungsbedingungen",
|
"datenschutz", "home", "impressum", "login", "nutzungsbedingungen",
|
||||||
@@ -9,7 +10,6 @@ $erlaubte_content_seiten = [
|
|||||||
"show-mail", "showArticle", "showCategory", "updateArticle"
|
"show-mail", "showArticle", "showCategory", "updateArticle"
|
||||||
];
|
];
|
||||||
|
|
||||||
// Allowlist für Controller
|
|
||||||
$erlaubte_controller = [
|
$erlaubte_controller = [
|
||||||
"confirm-password", "confirm-register", "createArticle", "deleteAccount",
|
"confirm-password", "confirm-register", "createArticle", "deleteAccount",
|
||||||
"deleteArticle", "home", "index", "like", "login", "logout",
|
"deleteArticle", "home", "index", "like", "login", "logout",
|
||||||
@@ -17,18 +17,17 @@ $erlaubte_controller = [
|
|||||||
"search-results", "showArticle", "showCategory", "updateArticle"
|
"search-results", "showArticle", "showCategory", "updateArticle"
|
||||||
];
|
];
|
||||||
|
|
||||||
// Validierung der Content-Seite
|
// Controller laden
|
||||||
if (!in_array($pfad, $erlaubte_content_seiten)) {
|
if (in_array($pfad, $erlaubte_controller)) {
|
||||||
$pfad = "404";
|
include_once "php/controller/" . $pfad . "-controller.php";
|
||||||
}
|
|
||||||
|
|
||||||
// Automatisch den passenden Controller laden, falls erlaubt
|
// Sofortiger Abbruch bei zerstörenden Aktionen
|
||||||
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
|
|
||||||
if ($pfad === "logout" || $pfad === "deleteAccount") {
|
if ($pfad === "logout" || $pfad === "deleteAccount") {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
// Content-Validierung: Wenn der Pfad nicht erlaubt ist, dann 404
|
||||||
|
if (!in_array($pfad, $erlaubte_content_seiten)) {
|
||||||
|
$pfad = "404";
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user