rpg-westreiche/westreiche_website/app/bootstrap.php

62 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
/**
* Westreiche – Bootstrap.
*
* Lädt Konfiguration, Datenbank, Session und Helfer. Zugangsdaten liegen in
* app/config.local.php (gitignored, wird beim Deployment erzeugt).
*/
define('WS_ROOT', dirname(__DIR__));
define('WS_APP', __DIR__);
$configFile = WS_APP . '/config.local.php';
if (!is_file($configFile)) {
http_response_code(500);
header('Content-Type: text/plain; charset=utf-8');
echo "Die Anwendung ist noch nicht konfiguriert (app/config.local.php fehlt).\n";
exit;
}
$GLOBALS['ws_config'] = require $configFile;
date_default_timezone_set('Europe/Berlin');
ini_set('display_errors', '0');
ini_set('log_errors', '1');
require WS_APP . '/util.php';
require WS_APP . '/rules.php';
require WS_APP . '/db.php';
require WS_APP . '/migrations.php';
require WS_APP . '/auth.php';
require WS_APP . '/character.php';
require WS_APP . '/portrait.php';
require WS_APP . '/invite.php';
require WS_APP . '/mailer.php';
require WS_APP . '/pdf.php';
require WS_APP . '/sheet.php';
require WS_APP . '/pages.php';
$storage = (string) config('app.storage_path', WS_ROOT . '/storage');
if (is_dir($storage . '/logs') && is_writable($storage . '/logs')) {
ini_set('error_log', $storage . '/logs/php.log');
}
set_exception_handler(static function (Throwable $error): void {
error_log('Westreiche: ' . $error::class . ': ' . $error->getMessage() . ' in ' . $error->getFile() . ':' . $error->getLine());
http_response_code(500);
header('Content-Type: text/html; charset=utf-8');
echo '<!doctype html><meta charset="utf-8"><title>Fehler 500</title>'
. '<body style="font-family:Georgia,serif;background:#0a0d16;color:#efe3c8;padding:3rem">'
. '<h1 style="color:#e8c766">Die Sterne stehen ungünstig</h1>'
. '<p>Es ist ein interner Fehler aufgetreten. Bitte später erneut versuchen.</p>'
. '<p><a style="color:#c9a227" href="' . e(url('/')) . '">Zurück</a></p></body>';
});
if (PHP_SAPI !== 'cli') {
security_headers();
if (current_path() !== '/health') {
start_session();
}
}