Files
usbcheck.it/config/fileload.php
2025-12-01 00:42:42 +01:00

61 lines
2.1 KiB
PHP

<?php
// 0) Umgebung / Domains / Error-Level
require_once __DIR__ . "/config.php";
// -----------------------------------------------------------
// Session starten (Frontend + API sollen dieselbe Session nutzen)
// -----------------------------------------------------------
if (php_sapi_name() !== 'cli') {
if (session_status() === PHP_SESSION_NONE) {
session_name('usbcheck_session');
// Cookie-Domain dynamisch bestimmen
$cookieDomain = '';
if (!empty($_SERVER['HTTP_HOST'])) {
$host = $_SERVER['HTTP_HOST'];
// evtl. Port abschneiden
$host = preg_replace('/:\d+$/', '', $host);
// Für alle Subdomains von usbcheck.it dieselbe Session
if (preg_match('/\.?usbcheck\.it$/i', $host)) {
// wirkt für usbcheck.it, staging.usbcheck.it, api.staging.usbcheck.it, ...
$cookieDomain = '.usbcheck.it';
}
// Falls du später andere Projekte auch per Subdomain teilen willst,
// kannst du hier weitere Regeln ergänzen, z.B.:
// elseif (preg_match('/\.?kusche\.berlin$/i', $host)) {
// $cookieDomain = '.kusche.berlin';
// }
}
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
'domain' => $cookieDomain, // WICHTIG: jetzt ggf. .usbcheck.it
'secure' => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'),
'httponly' => true,
'samesite' => 'Lax',
]);
session_start();
}
}
require_once __DIR__ . '/i18n.php'; // <— zentrale Sprachlogik
// ab hier kannst du überall $GLOBALS['lang'] und $GLOBALS['availableLangs'] nutzen
// und für JS:
$usbConfig = [
// ... dein sonstiges Zeug ...
'i18n' => app_i18n_get_frontend_config(),
];
// -----------------------------------------------------------
// 7) Rest des Systems laden
// -----------------------------------------------------------
require_once __DIR__ . "/db.php";
require_once __DIR__ . '/../src/functions.php';