sadas
This commit is contained in:
@@ -36,13 +36,18 @@ if (php_sapi_name() !== 'cli') {
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
$clientId = $_COOKIE['usbcheck_client'] ?? null;
|
||||
|
||||
if (!is_string($clientId) || $clientId === '' || !preg_match('/^[a-f0-9]{32}$/', $clientId)) {
|
||||
// jetzt 64 Hex-Zeichen (32 Bytes → 64 Hex)
|
||||
if (
|
||||
!is_string($clientId)
|
||||
|| $clientId === ''
|
||||
|| !preg_match('/^[a-f0-9]{64}$/', $clientId)
|
||||
) {
|
||||
// neue ID erzeugen
|
||||
try {
|
||||
$clientId = bin2hex(random_bytes(16));
|
||||
$clientId = bin2hex(random_bytes(32)); // 32 Bytes → 64 Hex
|
||||
} catch (Throwable $e) {
|
||||
// Fallback – sollte praktisch nie passieren
|
||||
$clientId = bin2hex(openssl_random_pseudo_bytes(16));
|
||||
$clientId = bin2hex(openssl_random_pseudo_bytes(32));
|
||||
}
|
||||
|
||||
$host = $_SERVER['HTTP_HOST'] ?? '';
|
||||
@@ -55,7 +60,7 @@ if (php_sapi_name() !== 'cli') {
|
||||
}
|
||||
|
||||
$cookieOpts = [
|
||||
'expires' => time() + 365 * 24 * 60 * 60,
|
||||
'expires' => time() + 365 * 24 * 60 * 60, // ~1 Jahr
|
||||
'path' => '/',
|
||||
'secure' => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'),
|
||||
'httponly' => false, // darf JS lesen, falls du es mal brauchst
|
||||
@@ -74,7 +79,7 @@ if (php_sapi_name() !== 'cli') {
|
||||
$GLOBALS['usb_client_id'] = $clientId;
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/i18n.php'; // <— NEU: zentrale Sprachlogik
|
||||
require_once __DIR__ . '/i18n.php'; // <— zentrale Sprachlogik
|
||||
|
||||
// ab hier kannst du überall $GLOBALS['lang'] und $GLOBALS['availableLangs'] nutzen
|
||||
// und für JS:
|
||||
@@ -82,8 +87,9 @@ $usbConfig = [
|
||||
// ... dein sonstiges Zeug ...
|
||||
'i18n' => app_i18n_get_frontend_config(),
|
||||
];
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// 7) Rest des Systems laden
|
||||
// Rest des Systems laden
|
||||
// -----------------------------------------------------------
|
||||
require_once __DIR__ . "/db.php";
|
||||
require_once __DIR__ . '/../src/functions.php';
|
||||
require_once __DIR__ . '/../src/functions.php";
|
||||
|
||||
Reference in New Issue
Block a user