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

75 lines
2.4 KiB
PHP

<?php
// 0) Umgebung / Domains / Error-Level
require_once __DIR__ . "/config.php";
// -----------------------------------------------------------
// Session starten (gemeinsam für Frontend + API)
// -----------------------------------------------------------
if (php_sapi_name() !== 'cli') {
if (session_status() === PHP_SESSION_NONE) {
// Host ermitteln
$host = $_SERVER['HTTP_HOST'] ?? '';
/**
* Ziel:
* STAGING:
* - staging.usbcheck.it
* - api.staging.usbcheck.it
* -> Cookie-Domain: .staging.usbcheck.it
*
* PROD:
* - usbcheck.it
* - www.usbcheck.it
* - api.usbcheck.it
* -> Cookie-Domain: .usbcheck.it
*
* LOKAL/SONSTIG:
* - z.B. localhost, 127.0.0.1
* -> Keine Domain setzen (Browser nimmt Host)
*/
$cookieDomain = '';
if (preg_match('~\.staging\.usbcheck\.it$~', $host)) {
// alles unter *.staging.usbcheck.it
$cookieDomain = '.staging.usbcheck.it';
} elseif (preg_match('~(^|\.)(usbcheck\.it)$~', $host)) {
// usbcheck.it, www.usbcheck.it, api.usbcheck.it, ...
$cookieDomain = '.usbcheck.it';
} else {
// z.B. localhost → leer lassen
$cookieDomain = '';
}
// Einheitlicher Session-Name für alle usbcheck-Hosts
session_name('usbcheck_session');
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
'domain' => $cookieDomain, // wichtig für gemeinsame Session über Subdomains
'secure' => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'),
'httponly' => true,
'samesite' => 'Lax', // reicht für gleiche Site (staging/api.*.usbcheck.it)
]);
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';