Compare commits

...

2 Commits

Author SHA1 Message Date
niklas.ortmann a8e76c782d Update index-controller.php 2026-07-18 15:53:33 +02:00
niklas.ortmann 3f9c048493 Update index.php 2026-07-18 15:53:31 +02:00
2 changed files with 13 additions and 16 deletions
+2 -4
View File
@@ -2,9 +2,7 @@
if (session_status() === PHP_SESSION_NONE) { if (session_status() === PHP_SESSION_NONE) {
session_start(); session_start();
} }
include_once "php/controller/index-controller.php";
include_once("php/controller/index-controller.php");
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="de"> <html lang="de">
@@ -38,7 +36,7 @@ include_once("php/controller/index-controller.php");
<?php <?php
include_once 'includes/navbar.php'; include_once 'includes/navbar.php';
// Dynamischer Inhalt (Absolut sicher durch die obige Prüfung) // Dynamischer Inhalt (Nutzt das geprüfte $pfad aus dem Index-Controller)
if (isset($pfad) && $pfad !== "404" && file_exists('content/' . $pfad . '.php')) { if (isset($pfad) && $pfad !== "404" && file_exists('content/' . $pfad . '.php')) {
include_once 'content/' . $pfad . '.php'; include_once 'content/' . $pfad . '.php';
} else { } else {
+11 -12
View File
@@ -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";
}