Files
landingpage-haus-schleusingen/public/index.php
Hermes ce21242308 feat(i18n): LocaleController switcher with open-redirect protection (closes #73)
- App\Controllers\LocaleController: GET /locale?set=xx&return=/path
  - Sets 1-year cookie (HttpOnly=false for SSR, SameSite=Lax, Secure on HTTPS)
  - 302 redirect to explicit return URL > Referer > /
  - Pure buildResponse() helper for unit tests (no headers/exit)
  - current() helper: resolves locale from $_GET/$_COOKIE/Accept-Language
- safeRedirect: rejects absolute URLs, protocol-relative (//evil.com),
  backslash tricks (\\evil.com), javascript:/data: schemes
- 28 PHPUnit tests (LocaleControllerTest), all green
- Total project tests now: 92
2026-06-04 08:57:33 +00:00

26 lines
686 B
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
/*
* Front Controller Single Entry Point
* All requests are routed through this file.
*/
// Autoloader (composer PSR-4)
require_once __DIR__ . '/../vendor/autoload.php';
use App\Core\Router;
$router = new Router();
// Define routes
$router->addRoute('/', \App\Controllers\HomeController::class, 'index');
$router->addRoute('/impressum', \App\Controllers\ImpressumController::class, 'index');
$router->addRoute('/datenschutz', \App\Controllers\DatenschutzController::class, 'index');
$router->addRoute('/locale', \App\Controllers\LocaleController::class, 'switch');
// Dispatch
$uri = $_SERVER['REQUEST_URI'] ?? '/';
$router->dispatch($uri);