73 lines
1.8 KiB
PHP
73 lines
1.8 KiB
PHP
<?php
|
|
// Einstiegspunkt der Anwendung, Routing zur jeweiligen Modul-Seite
|
|
|
|
|
|
/**
|
|
* 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', 'device_types', 'devices', 'racks', 'floors', 'connections', 'port_types'];
|
|
|
|
// Whitelist der Aktionen
|
|
$validActions = ['list', 'edit', 'save', 'ports', 'delete'];
|
|
|
|
// Prüfen auf gültige Werte
|
|
if (!in_array($module, $validModules)) {
|
|
// TODO: Fehlerseite anzeigen
|
|
die('Ungültiges Modul');
|
|
}
|
|
|
|
if (!in_array($action, $validActions)) {
|
|
// TODO: Fehlerseite anzeigen
|
|
die('Ungültige Aktion');
|
|
}
|
|
|
|
/* =========================
|
|
* 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
|
|
if ($action !== 'save') {
|
|
echo "<p>Die Seite existiert noch nicht.</p>".$modulePath;
|
|
}
|
|
}
|
|
|
|
/* =========================
|
|
* Template-Footer laden (nur für View-Aktionen)
|
|
* ========================= */
|
|
if (!in_array($action, ['save', 'delete'], true)) {
|
|
require_once __DIR__ . '/templates/footer.php';
|
|
}
|