rinkplanner/hub/app/bootstrap.php
torsten 9819311403 feat: Website und Hub zweisprachig (Deutsch/Englisch)
Website (rinkplanner.programmschmiede.de) liegt jetzt im Repo unter web/:
Sprachweiche nach Accept-Language (der User-Agent enthält keine Sprache),
/de/ und /en/ als eigene URLs mit hreflang, Cookie für die manuelle Wahl,
Texte in web/i18n.php, Markup in web/template.php. Deployment über
tools/deploy_web.sh (--sync, --check, --all); /index.html leitet weiter.

Hub: optionale englische Oberfläche über den DE/EN-Umschalter, Cookie
RHUB_LANG, Route /language. Alle Texte (Views, Meldungen, Validierung,
API-messages) stehen in hub/app/i18n_strings.php und laufen über t();
Datum und Zahlen folgen der Sprache. Die API behält ihre code-Felder und
antwortet ohne Cookie weiter deutsch.

deploy_hub.sh --check prüft jetzt Schlüsselparität und fehlende t()-Schlüssel.
Doku: docs/website.md neu, docs/hub.md und AGENTS.md ergänzt.
2026-11-12 22:38:32 +01:00

62 lines
2 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);
/**
* Rinkplanner-Hub – Bootstrap.
*
* Lädt Konfiguration, Datenbank, Session und Helfer. Die Konfiguration mit
* Zugangsdaten liegt in app/config.local.php und wird beim Deployment erzeugt.
*/
define('HUB_ROOT', dirname(__DIR__));
define('HUB_APP', __DIR__);
$configFile = HUB_APP . '/config.local.php';
if (!is_file($configFile)) {
http_response_code(500);
header('Content-Type: text/plain; charset=utf-8');
echo "Der Hub ist noch nicht konfiguriert (app/config.local.php fehlt).\n";
exit;
}
$GLOBALS['hub_config'] = require $configFile;
date_default_timezone_set('UTC');
ini_set('display_errors', '0');
ini_set('log_errors', '1');
require HUB_APP . '/i18n.php';
require HUB_APP . '/util.php';
require HUB_APP . '/db.php';
require HUB_APP . '/auth.php';
require HUB_APP . '/invites.php';
require HUB_APP . '/tokens.php';
require HUB_APP . '/routines.php';
require HUB_APP . '/pages.php';
require HUB_APP . '/api.php';
$storage = (string) config('app.storage_path', HUB_ROOT . '/storage');
if (is_dir($storage) && is_writable($storage)) {
ini_set('error_log', $storage . '/logs/php.log');
}
set_exception_handler(static function (Throwable $error): void {
error_log('Hub: ' . $error::class . ': ' . $error->getMessage() . ' in ' . $error->getFile() . ':' . $error->getLine());
if (function_exists('wants_json') && wants_json()) {
json_response(['error' => ['code' => 'server_error', 'message' => t('api.server_error')]], 500);
return;
}
http_response_code(500);
header('Content-Type: text/html; charset=utf-8');
$title = function_exists('t') ? t('page.title_error', ['status' => 500]) : 'Fehler 500';
$hint = function_exists('t') ? t('api.server_error') : 'Interner Fehler.';
echo '<!doctype html><meta charset="utf-8"><title>' . e($title) . '</title>'
. '<body style="font-family:system-ui;background:#050d19;color:#eefaff;padding:2rem">'
. '<h1>' . e($hint) . '</h1></body>';
});
security_headers();
if (PHP_SAPI !== 'cli') {
start_session();
}