From 1da4842847cd1da097a1273bcc23c4a702f609a6 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Sun, 19 Jul 2026 14:56:25 +0200 Subject: [PATCH 01/37] Update dataSources.local.xml --- .idea/dataSources.local.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml index cdc31de..b341a8a 100644 --- a/.idea/dataSources.local.xml +++ b/.idea/dataSources.local.xml @@ -1,6 +1,6 @@ - + " From 42faab17e8874414354860a05ba40bf5a019f59c Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Sun, 19 Jul 2026 14:56:26 +0200 Subject: [PATCH 02/37] Create csrf.php --- includes/csrf.php | 88 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 includes/csrf.php diff --git a/includes/csrf.php b/includes/csrf.php new file mode 100644 index 0000000..db0575e --- /dev/null +++ b/includes/csrf.php @@ -0,0 +1,88 @@ +'; +} + +/** + * Prüft, ob das per POST gesendete CSRF-Token zum Session-Token passt. + * + * Der Vergleich erfolgt zeitkonstant über hash_equals(), um + * Timing-Angriffe auf den Vergleich selbst auszuschließen. + * + * @return bool true, wenn das Token gültig ist + */ +function csrf_verify(): bool +{ + $sentToken = $_POST["csrf_token"] ?? ""; + $sessionToken = $_SESSION["csrf_token"] ?? ""; + + if (!is_string($sentToken) || $sentToken === "" || $sessionToken === "") { + return false; + } + + return hash_equals($sessionToken, $sentToken); +} + +/** + * Bricht die Anfrage ab und leitet mit einer Fehlermeldung um, + * wenn das mitgesendete CSRF-Token ungültig oder nicht vorhanden ist. + * + * Muss am Anfang jeder zustandsändernden POST-Aktion aufgerufen werden, + * bevor irgendeine Änderung an Daten vorgenommen wird. + * + * @param string $redirectTo Ziel-URL, zu der bei ungültigem Token + * weitergeleitet wird + * @return void + */ +function csrf_require_valid(string $redirectTo = "index.php"): void +{ + if (!csrf_verify()) { + http_response_code(403); + $_SESSION["message"] = "invalid_csrf_token"; + header("Location: " . $redirectTo); + exit(); + } +} \ No newline at end of file From ad9a00fd49f487d3b756e0f8776872f6a496cef7 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Sun, 19 Jul 2026 14:57:52 +0200 Subject: [PATCH 03/37] csrf.php --- includes/alertMessages.php | 8 +++++++- index.php | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/includes/alertMessages.php b/includes/alertMessages.php index 645f532..2c42d14 100644 --- a/includes/alertMessages.php +++ b/includes/alertMessages.php @@ -89,6 +89,12 @@ Es ist ein Datenbankfehler aufgetreten. Bitte versuche es erneut.

+ +

+ Deine Sitzung ist abgelaufen oder die Anfrage konnte nicht überprüft werden. + Bitte lade die Seite neu und versuche es erneut. +

+ +?> \ No newline at end of file diff --git a/index.php b/index.php index 42d054c..b70d61c 100644 --- a/index.php +++ b/index.php @@ -2,6 +2,7 @@ if (session_status() === PHP_SESSION_NONE) { session_start(); } +include_once "includes/csrf.php"; include_once "php/controller/index-controller.php"; ?> From bfb2d2b0d8e1cfee6e645e846d0fe5022f74f59e Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Sun, 19 Jul 2026 14:59:45 +0200 Subject: [PATCH 04/37] navbar logout mit post --- css/navbar.css | 22 +++++++++++++++++++++- includes/navbar.php | 16 ++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/css/navbar.css b/css/navbar.css index d7d3d4a..f7e82c9 100644 --- a/css/navbar.css +++ b/css/navbar.css @@ -250,7 +250,7 @@ CSS für die navbar padding: 2rem 1rem; box-shadow: 2px 0 10px rgba(0,0,0,0.5); overflow-y: auto; - + /* Genug Abstand oben rechts, damit Links nicht hinter dem X liegen */ padding: 4rem 1.5rem 2rem 1.5rem; } @@ -285,6 +285,26 @@ CSS für die navbar border-bottom: 1px solid #333d43; } + .nav__logout-form { + margin: 0; + } + + .nav__mobile-logout-button { + color: #fff; + text-decoration: none; + font-size: 1.2rem; + font-weight: 600; + display: block; + width: 100%; + text-align: left; + padding: 0.5rem 1rem; + border: none; + border-bottom: 1px solid #333d43; + background: none; + cursor: pointer; + font-family: inherit; + } + .nav__mobile-submenu { display: block; list-style: none; diff --git a/includes/navbar.php b/includes/navbar.php index c62204e..78d7a3c 100644 --- a/includes/navbar.php +++ b/includes/navbar.php @@ -28,7 +28,12 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden
  • Profil
  • -
  • Abmelden
  • +
  • + +
  • Beitrag erstellen
  • @@ -158,9 +163,12 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden Beitrag erstellen - - Abmelden - + From bac296b58acbefed1cda430e57f0aabf8efc10ee Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Sun, 19 Jul 2026 15:07:09 +0200 Subject: [PATCH 05/37] Update logout-controller.php --- php/controller/logout-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/controller/logout-controller.php b/php/controller/logout-controller.php index 49386ab..d88a634 100644 --- a/php/controller/logout-controller.php +++ b/php/controller/logout-controller.php @@ -2,5 +2,5 @@ $_SESSION = []; session_destroy(); -header("Location: index.php"); +header("Location: ../../index.php"); exit(); \ No newline at end of file From f1703a476e67ebbdc8be07b5656e50256b907c1a Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Sun, 19 Jul 2026 15:09:22 +0200 Subject: [PATCH 06/37] Update index.php --- index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/index.php b/index.php index b70d61c..e8c35db 100644 --- a/index.php +++ b/index.php @@ -36,6 +36,7 @@ include_once "php/controller/index-controller.php"; Date: Sun, 19 Jul 2026 15:13:44 +0200 Subject: [PATCH 07/37] debugging --- includes/navbar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/navbar.php b/includes/navbar.php index 78d7a3c..28fae66 100644 --- a/includes/navbar.php +++ b/includes/navbar.php @@ -164,7 +164,7 @@ Globales Menü, wird via PHP später in alle Seiten eingebunden