wip: Mobile-Theme-Testphase und PHP-8.2-Guards (Stand Juni 2026)

This commit is contained in:
Thomas Bartelt
2026-09-13 19:10:56 +02:00
parent 08beac8d67
commit 20d55f77b8
1448 changed files with 16015 additions and 583 deletions
+32
View File
@@ -95,6 +95,38 @@ class Config extends Main {
}
}
// === Mobile-Theme-Switch (Test-Phase) ===
// Priorität:
// 1. URL-Parameter ?theme=X (setzt Cookie für 30 Tage)
// 2. Cookie THEME_OVERRIDE
// 3. User-Agent: iOS/Android Mobile → automatisch Mobile-Theme
// Whitelist verhindert beliebige Theme-Werte (Sicherheit).
$theme_whitelist = ['theme2', 'mobile'];
$is_https = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https');
if (isset($_GET['theme']) && in_array($_GET['theme'], $theme_whitelist, true)) {
// iOS Safari/Chrome braucht modernes Cookie-Format mit SameSite + Secure
setcookie('THEME_OVERRIDE', $_GET['theme'], [
'expires' => time() + 30 * 86400,
'path' => '/',
'secure' => $is_https,
'httponly' => false,
'samesite' => 'Lax',
]);
$this->shopConfiguration['THEME'] = $_GET['theme'];
} elseif (isset($_COOKIE['THEME_OVERRIDE']) && in_array($_COOKIE['THEME_OVERRIDE'], $theme_whitelist, true)) {
$this->shopConfiguration['THEME'] = $_COOKIE['THEME_OVERRIDE'];
} else {
// Automatik: iOS oder Android-Mobile? → Mobile-Theme
$ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if (preg_match('/iPhone|iPod|iPad|Android.*Mobile|webOS|BlackBerry|IEMobile|Opera Mini/i', $ua)) {
$this->shopConfiguration['THEME'] = 'mobile';
}
}
// === Ende Theme-Switch ===
foreach ($text_values as $obj) {
$this->shopConfiguration[$obj->name] = str_replace('{$THEME_DIR}', STANDARD_DIR.'web/'.SHOP_SYSTEM.'/themes/'.$this->shopConfiguration['THEME'], $obj->setting);
}