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) {
session_start();
}
include_once("php/controller/index-controller.php");
include_once "php/controller/index-controller.php";
?>
<!DOCTYPE html>
<html lang="de">
@@ -38,7 +36,7 @@ include_once("php/controller/index-controller.php");
<?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')) {
include_once 'content/' . $pfad . '.php';
} else {
+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";
}