80 lines
3.3 KiB
PHP
80 lines
3.3 KiB
PHP
<?php
|
||
/**
|
||
* Wird von jeder Seite als erstes eingebunden.
|
||
*/
|
||
|
||
require_once __DIR__ . '/../version.php';
|
||
|
||
require_once __DIR__ . '/db.php';
|
||
require_once __DIR__ . '/functions.php';
|
||
require_once __DIR__ . '/themes.php';
|
||
require_once __DIR__ . '/time_tracking.php';
|
||
require_once __DIR__ . '/pseudo_cron.php';
|
||
require_once __DIR__ . '/auth.php';
|
||
require_once __DIR__ . '/smtp_mailer.php';
|
||
require_once __DIR__ . '/mailer.php';
|
||
require_once __DIR__ . '/email_addresses.php';
|
||
require_once __DIR__ . '/health.php';
|
||
require_once __DIR__ . '/admin_models.php';
|
||
require_once __DIR__ . '/queues.php';
|
||
require_once __DIR__ . '/integrations.php';
|
||
require_once __DIR__ . '/reports.php';
|
||
require_once __DIR__ . '/fcm.php';
|
||
require_once __DIR__ . '/staff_activity.php';
|
||
require_once __DIR__ . '/notifications.php';
|
||
require_once __DIR__ . '/plugins.php';
|
||
require_once __DIR__ . '/app_downloads.php';
|
||
require_once __DIR__ . '/theme_catalog.php';
|
||
require_once __DIR__ . '/security_check.php';
|
||
require_once __DIR__ . '/update_security.php';
|
||
|
||
date_default_timezone_set(get_setting('timezone', config()['site']['timezone'] ?? 'UTC'));
|
||
|
||
// Sichere Session-Cookie-Einstellungen (vor session_start)
|
||
if (session_status() === PHP_SESSION_NONE) {
|
||
// Die Sitzungsdaten müssen mindestens so lange liegen bleiben wie die Inaktivitätszeit (PHP-Standard: 24 Minuten, sonst würde man
|
||
// vor Ablauf der eingestellten Zeit abgemeldet)
|
||
@ini_set('session.gc_maxlifetime', (string) max(1440, ((int) (get_setting('staff_session_timeout', '30') ?: 30)) * 60 + 600));
|
||
session_set_cookie_params([
|
||
'lifetime' => 0,
|
||
'path' => '/',
|
||
'secure' => request_is_https(),
|
||
'httponly' => true,
|
||
'samesite' => 'Lax',
|
||
]);
|
||
session_start();
|
||
}
|
||
|
||
// Sicherheits-Header
|
||
header('X-Content-Type-Options: nosniff');
|
||
header('X-Frame-Options: DENY');
|
||
header('Referrer-Policy: strict-origin-when-cross-origin');
|
||
header("Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https://api.qrserver.com; font-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self';");
|
||
header('Permissions-Policy: camera=(), microphone=(), geolocation=(), payment=()');
|
||
// HSTS nur bei echtem HTTPS senden
|
||
if (request_is_https()) {
|
||
header('Strict-Transport-Security: max-age=31536000; includeSubDomains');
|
||
}
|
||
|
||
// PHP-Fehler nie im Browser ausgeben (Produktion)
|
||
@ini_set('display_errors', '0');
|
||
@ini_set('log_errors', '1');
|
||
|
||
// "Eingebauter" Ersatz für echte Server-Cronjobs (siehe includes/pseudo_cron.php).
|
||
// Bewusst auf JEDER Seite (nicht nur im Mitarbeiterbereich): auch Kundenportal-Besuche
|
||
// (Ticket einreichen, Status prüfen, Login, KB) halten die Hintergrund-Jobs am Laufen –
|
||
// genau wie bei WordPress' wp-cron.php reicht dafür jeder Seitenaufruf, nicht nur ein
|
||
// eingeloggter Mitarbeiter. Läuft NACH dem Senden der Antwort, verlangsamt also nichts.
|
||
pseudo_cron_schedule_background();
|
||
|
||
// Aktive Plugins laden (Fehler in Plugins werden isoliert, siehe includes/plugins.php).
|
||
plugins_boot();
|
||
|
||
// DB-kompatibler SQL-Ausdruck für Domain-Teil einer E-Mail
|
||
function sql_email_domain(string $col): string {
|
||
$driver = config()['db']['driver'] ?? 'sqlite';
|
||
return $driver === 'mysql'
|
||
? "SUBSTRING_INDEX($col,'@',-1)"
|
||
: "SUBSTR($col, INSTR($col,'@')+1)";
|
||
}
|