div TODOs
This commit is contained in:
@@ -1,72 +1,37 @@
|
||||
<?php
|
||||
// Einstiegspunkt der Anwendung, Routing zur jeweiligen Modul-Seite
|
||||
|
||||
require_once __DIR__ . '/bootstrap.php';
|
||||
requireAuth();
|
||||
|
||||
/**
|
||||
* index.php
|
||||
*
|
||||
* Einstiegspunkt der Anwendung
|
||||
* - Single-User
|
||||
* - Modulbasiertes Routing
|
||||
* - Basierend auf _sql.php
|
||||
* - HTML-Layout via templates/layout.php
|
||||
*/
|
||||
|
||||
/* =========================
|
||||
* Bootstrap
|
||||
* ========================= */
|
||||
require_once __DIR__ . '/bootstrap.php'; // lädt config, DB, helper
|
||||
// TODO: Session starten / Single-User-Auth prüfen
|
||||
|
||||
/* =========================
|
||||
* Routing
|
||||
* ========================= */
|
||||
|
||||
// Standard-Modul / Aktion
|
||||
$module = $_GET['module'] ?? 'dashboard';
|
||||
$action = $_GET['action'] ?? 'list';
|
||||
|
||||
// Whitelist der Module
|
||||
$validModules = ['dashboard', 'locations', 'buildings', 'rooms', 'device_types', 'devices', 'racks', 'floors', 'floor_infrastructure', 'connections', 'port_types'];
|
||||
|
||||
// Whitelist der Aktionen
|
||||
$validActions = ['list', 'edit', 'save', 'ports', 'delete'];
|
||||
|
||||
// Prüfen auf gültige Werte
|
||||
if (!in_array($module, $validModules)) {
|
||||
renderClientError(400, 'Ungültiges Modul');
|
||||
if (!in_array($module, $validModules, true)) {
|
||||
renderClientError(400, 'Ungueltiges Modul');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!in_array($action, $validActions)) {
|
||||
// TODO: Fehlerseite anzeigen, nutze renderClientError(...)
|
||||
die('Ungültige Aktion');
|
||||
if (!in_array($action, $validActions, true)) {
|
||||
renderClientError(400, 'Ungueltige Aktion');
|
||||
exit;
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* Template-Header laden (nur für View-Aktionen)
|
||||
* ========================= */
|
||||
if (!in_array($action, ['save', 'delete'], true)) {
|
||||
require_once __DIR__ . '/templates/header.php';
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* Modul laden
|
||||
* ========================= */
|
||||
$modulePath = __DIR__ . "/modules/$module/$action.php";
|
||||
|
||||
if (file_exists($modulePath)) {
|
||||
require_once $modulePath;
|
||||
} else {
|
||||
// TODO: Fehlerseite oder 404, nutze renderClientError(...)
|
||||
if ($action !== 'save') {
|
||||
echo "<p>Die Seite existiert noch nicht.</p>".$modulePath;
|
||||
}
|
||||
renderClientError(404, 'Die angeforderte Seite existiert nicht.');
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* Template-Footer laden (nur für View-Aktionen)
|
||||
* ========================= */
|
||||
if (!in_array($action, ['save', 'delete'], true)) {
|
||||
require_once __DIR__ . '/templates/footer.php';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user