Deiteiincludes ($pfad) per whitelist prüfen #53

Merged
niklas.ortmann merged 10 commits from AllowistDateiincludes into dev 2026-07-18 18:31:56 +02:00
Showing only changes of commit d341312192 - Show all commits
+31
View File
@@ -1,3 +1,34 @@
<?php <?php
$pfad = $_GET["pfad"] ?? "home";
// Allowlist für Content
$erlaubte_content_seiten = [
"accessibility", "confirm-password", "confirm-register", "createArticle",
"datenschutz", "home", "impressum", "login", "nutzungsbedingungen",
"password-forgotten", "profile", "register", "search-results",
"show-mail", "showArticle", "showCategory", "updateArticle"
];
// Allowlist für Controller
$erlaubte_controller = [
"confirm-password", "confirm-register", "createArticle", "deleteAccount",
"deleteArticle", "home", "index", "like", "login", "logout",
"password-forgotten", "profile", "profileArticles", "register",
"search-results", "showArticle", "showCategory", "updateArticle"
];
// Validierung der Content-Seite
if (!in_array($pfad, $erlaubte_content_seiten)) {
$pfad = "404";
}
// 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
if ($pfad === "logout" || $pfad === "deleteAccount") {
exit();
}
}
?> ?>