59 lines
2.0 KiB
PHP
59 lines
2.0 KiB
PHP
<?php
|
|
|
|
// 0) Umgebung / Domains / Error-Level
|
|
require_once __DIR__ . "/config.php";
|
|
|
|
// ----------------------------------------------------------
|
|
// Session starten (gemeinsam für Frontend + API Subdomains)
|
|
// -----------------------------------------------------------
|
|
if (php_sapi_name() !== 'cli') {
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
|
|
// Einheitlicher Name für alle Teilbereiche
|
|
session_name('usbcheck_session');
|
|
|
|
$isHttps = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
|
|
|
|
// Cookie-Domain so wählen, dass ALLE Subdomains von usbcheck.it
|
|
// dieselbe Session sehen (staging., api.staging., www., …)
|
|
$cookieDomain = '';
|
|
if (!empty($_SERVER['HTTP_HOST'])) {
|
|
$host = $_SERVER['HTTP_HOST'];
|
|
|
|
// alles was auf "usbcheck.it" endet, bekommt die gemeinsame Domain
|
|
if (substr($host, -strlen('usbcheck.it')) === 'usbcheck.it') {
|
|
// wirkt für usbcheck.it, staging.usbcheck.it, api.staging.usbcheck.it, ...
|
|
$cookieDomain = '.usbcheck.it';
|
|
}
|
|
}
|
|
|
|
session_set_cookie_params([
|
|
'lifetime' => 0,
|
|
'path' => '/',
|
|
// WICHTIG: hier die Domain, damit API + Frontend teilen
|
|
'domain' => $cookieDomain ?: '',
|
|
'secure' => $isHttps,
|
|
'httponly' => true,
|
|
// eTLD+1 ist gleich (usbcheck.it), daher reicht Lax für Same-Site
|
|
'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';
|