feat: Kür-Hub mit Einladungen, Uploads und API
- PHP-App unter hub/ für rinkplanner-hub.programmschmiede.de - MariaDB-Schema, Argon2id, Sessions, CSRF und Ratenbegrenzung - Einladungscodes, Admin-Bereich und Kür-Pakete mit Audiodatei - JSON-API v1 mit Bearer-Tokens für die Godot-App - Deployment und Erstinstallation über tools/deploy_hub.sh - Doku und Credentials-Vorlage ergänzt
This commit is contained in:
parent
e79b477ee0
commit
055a2919c3
38 changed files with 5111 additions and 0 deletions
59
hub/app/bootstrap.php
Normal file
59
hub/app/bootstrap.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?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 . '/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' => 'Interner Fehler.']], 500);
|
||||
return;
|
||||
}
|
||||
http_response_code(500);
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
echo '<!doctype html><meta charset="utf-8"><title>Fehler</title>'
|
||||
. '<body style="font-family:system-ui;background:#050d19;color:#eefaff;padding:2rem">'
|
||||
. '<h1>Interner Fehler</h1><p>Bitte später erneut versuchen.</p></body>';
|
||||
});
|
||||
|
||||
security_headers();
|
||||
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
start_session();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue