153 lines
3.9 KiB
PHP
153 lines
3.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Controllers\PlatformController;
|
|
use App\Controllers\TenantController;
|
|
use App\Core\Response;
|
|
use App\Services\SecurityHeadersService;
|
|
|
|
$app = require dirname(__DIR__) . '/app/bootstrap.php';
|
|
|
|
(new SecurityHeadersService())->send();
|
|
|
|
$platform = new PlatformController(
|
|
$app['rootPath'],
|
|
$app['config'],
|
|
$app['database'],
|
|
$app['view'],
|
|
$app['session'],
|
|
$app['csrf']
|
|
);
|
|
|
|
$tenantController = new TenantController(
|
|
$app['database'],
|
|
$app['view'],
|
|
$app['session'],
|
|
$app['csrf'],
|
|
$app['config']
|
|
);
|
|
|
|
$path = current_path();
|
|
$method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
|
|
|
|
try {
|
|
if ($path === '/' && $method === 'GET') {
|
|
$platform->home();
|
|
return;
|
|
}
|
|
|
|
if ($path === '/install') {
|
|
$method === 'POST' ? $platform->installSubmit() : $platform->installForm();
|
|
return;
|
|
}
|
|
|
|
if ($path === '/register') {
|
|
$method === 'POST' ? $platform->registerSubmit() : $platform->registerForm();
|
|
return;
|
|
}
|
|
|
|
if ($path === '/admin/login') {
|
|
$method === 'POST' ? $platform->adminLoginSubmit() : $platform->adminLoginForm();
|
|
return;
|
|
}
|
|
|
|
if ($path === '/password/forgot') {
|
|
$method === 'POST' ? $platform->passwordResetRequestSubmit() : $platform->passwordResetRequestForm();
|
|
return;
|
|
}
|
|
|
|
if ($path === '/reset-password') {
|
|
$method === 'POST' ? $platform->passwordResetConfirmSubmit() : $platform->passwordResetConfirmForm();
|
|
return;
|
|
}
|
|
|
|
if ($path === '/admin' && $method === 'GET') {
|
|
$platform->adminDashboard();
|
|
return;
|
|
}
|
|
|
|
if ($path === '/admin/logout' && $method === 'POST') {
|
|
$platform->adminLogout();
|
|
return;
|
|
}
|
|
|
|
if ($path === '/api/rfid/intake' && $method === 'POST') {
|
|
if (!($app['config']['rfid_ingest_enabled'] ?? false)) {
|
|
Response::notFound();
|
|
return;
|
|
}
|
|
|
|
$tenantController->rfidIngest();
|
|
return;
|
|
}
|
|
|
|
if (preg_match('#^/t/([^/]+)(?:/(.*))?$#', $path, $matches)) {
|
|
$tenantSlug = rawurldecode($matches[1]);
|
|
$subPath = trim((string) ($matches[2] ?? ''), '/');
|
|
|
|
if ($subPath === '' && $method === 'GET') {
|
|
$tenantController->dashboard($tenantSlug);
|
|
return;
|
|
}
|
|
|
|
if ($subPath === 'login') {
|
|
$method === 'POST' ? $tenantController->loginSubmit($tenantSlug) : $tenantController->loginForm($tenantSlug);
|
|
return;
|
|
}
|
|
|
|
if ($subPath === 'logout' && $method === 'POST') {
|
|
$tenantController->logout($tenantSlug);
|
|
return;
|
|
}
|
|
|
|
if ($subPath === 'members') {
|
|
$tenantController->members($tenantSlug);
|
|
return;
|
|
}
|
|
|
|
if ($subPath === 'products') {
|
|
$tenantController->products($tenantSlug);
|
|
return;
|
|
}
|
|
|
|
if ($subPath === 'bookings') {
|
|
$tenantController->bookings($tenantSlug);
|
|
return;
|
|
}
|
|
|
|
if ($subPath === 'exports/balances.csv' && $method === 'GET') {
|
|
$tenantController->exportBalances($tenantSlug);
|
|
return;
|
|
}
|
|
|
|
if ($subPath === 'exports/bookings.csv' && $method === 'GET') {
|
|
$tenantController->exportBookings($tenantSlug);
|
|
return;
|
|
}
|
|
|
|
if ($subPath === 'payments') {
|
|
$tenantController->payments($tenantSlug);
|
|
return;
|
|
}
|
|
|
|
if ($subPath === 'paper-sheets') {
|
|
$tenantController->paperSheets($tenantSlug);
|
|
return;
|
|
}
|
|
|
|
if ($subPath === 'rfid') {
|
|
$tenantController->rfid($tenantSlug);
|
|
return;
|
|
}
|
|
}
|
|
|
|
Response::notFound();
|
|
} catch (\Throwable $throwable) {
|
|
http_response_code(500);
|
|
error_log($throwable->__toString());
|
|
|
|
echo '<h1>Fehler</h1>';
|
|
echo '<p>' . e($app['config']['debug'] ? $throwable->getMessage() : 'Die Anfrage konnte gerade nicht verarbeitet werden.') . '</p>';
|
|
}
|