Files
Backend/WEBROOT/controller/RoutesController.php
T
2026-02-16 09:51:16 +01:00

30 lines
787 B
PHP

<?php
function redirectToWebsite(string $website): void
{
$website = trim($website);
if ($website === '') {
die("Ungültige URL.");
}
$blocked_schemes = ['javascript:', 'data:', 'file:'];
foreach ($blocked_schemes as $scheme) {
if (stripos($website, $scheme) === 0) {
die("Ungültige URL.");
}
}
if (preg_match('/^https?:\/\//i', $website)) {
header("Location: " . $website);
exit;
}
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://";
$domain = $_SERVER['HTTP_HOST'];
$website = ltrim($website, "/");
$redirectUrl = $protocol . $domain . "/" . $website;
header("Location: " . $redirectUrl);
exit;
}