From 5ebed74e126d0eeabc60036bf74802e3e5832374 Mon Sep 17 00:00:00 2001 From: Tower Date: Sun, 19 Jul 2026 22:41:06 +0200 Subject: [PATCH 1/2] update but not functional --- WEBROOT/config.php | 427 +-------------------------------------------- WEBROOT/index.php | 90 ++++++---- WEBROOT/login.php | 46 +++-- 3 files changed, 81 insertions(+), 482 deletions(-) diff --git a/WEBROOT/config.php b/WEBROOT/config.php index 1209fd2..92a34b0 100644 --- a/WEBROOT/config.php +++ b/WEBROOT/config.php @@ -6,429 +6,4 @@ $superuser = array ( 'password' => 'bBHofurUJWKzPE8Z:', 'active' => true, ), -); - -$serviceGroups = array ( - 'Info' => - array ( - 'label' => 'Home', - 'defaultOpen' => true, - 'services' => - array ( - 0 => 'home_info', - 1 => 'vergabe', - 2 => 'links', - 3 => 'einkaufsliste', - 4 => 'termine', - 5 => 'ticket_board', - 6 => 'ajaxTests', - ), - ), - 'Ausbildung' => - array ( - 'label' => 'Ausbildung', - 'defaultOpen' => true, - 'services' => - array ( - 0 => 'print_static', - 1 => 'zeiterfassung', - 2 => 'berichte_arbeit_gen', - 3 => 'berichte', - 4 => 'firmenberichte', - 5 => 'berufsschulberichte', - ), - ), - 'Logs' => - array ( - 'label' => 'Webserver', - 'defaultOpen' => false, - 'services' => - array ( - 0 => 'public_request_logs', - 1 => 'public_request_chart', - 2 => 'backend_request_logs', - 3 => 'backend_request_chart', - 4 => 'personal_request_logs', - ), - ), - 'System' => - array ( - 'label' => 'Verwaltung', - 'defaultOpen' => false, - 'services' => - array ( - 0 => 'data_info', - 1 => 'services_control', - 2 => 'user_control', - 3 => 'variablen_control', - 4 => 'ticket_control', - ), - ), - 'Test' => - array ( - 'label' => 'Dev / Test', - 'defaultOpen' => false, - 'services' => - array ( - 0 => 'api_tester', - 1 => 'weather_chart', - 2 => 'tabellen', - 3 => 'domains', - ), - ), -); - -$services = array ( - 'home_info' => - array ( - 'name' => 'Home', - 'active' => true, - 'adminOnly' => false, - ), - 'vergabe' => - array ( - 'name' => 'Vergabe', - 'active' => true, - 'adminOnly' => false, - ), - 'print_static' => - array ( - 'name' => 'Berichte Drucken', - 'active' => true, - 'adminOnly' => false, - ), - 'api_tester' => - array ( - 'name' => 'API Testing', - 'active' => true, - 'adminOnly' => true, - ), - 'weather_chart' => - array ( - 'name' => 'Wetter Statistik', - 'active' => true, - 'adminOnly' => true, - ), - 'data_info' => - array ( - 'name' => 'Data Info', - 'active' => true, - 'adminOnly' => true, - ), - 'links' => - array ( - 'name' => 'Links', - 'active' => true, - 'adminOnly' => false, - ), - 'public_request_logs' => - array ( - 'name' => 'Public Logs', - 'active' => true, - 'adminOnly' => false, - ), - 'public_request_chart' => - array ( - 'name' => 'Public Statistik', - 'active' => true, - 'adminOnly' => false, - ), - 'backend_request_logs' => - array ( - 'name' => 'Backend Logs', - 'active' => true, - 'adminOnly' => false, - ), - 'backend_request_chart' => - array ( - 'name' => 'Backend Statistik', - 'active' => true, - 'adminOnly' => false, - ), - 'personal_request_logs' => - array ( - 'name' => 'Persönliche Logs', - 'active' => true, - 'adminOnly' => true, - ), - 'services_control' => - array ( - 'name' => 'Seiten', - 'active' => true, - 'adminOnly' => true, - ), - 'zeiterfassung' => - array ( - 'name' => 'Zeit Erfassung', - 'active' => true, - 'adminOnly' => false, - ), - 'berichte_arbeit_gen' => - array ( - 'name' => 'Berichte PDF', - 'active' => true, - 'adminOnly' => false, - ), - 'user_control' => - array ( - 'name' => 'Benutzer', - 'active' => true, - 'adminOnly' => true, - ), - 'variablen_control' => - array ( - 'name' => 'Variablen', - 'active' => true, - 'adminOnly' => true, - ), - 'tabellen' => - array ( - 'name' => 'Tabellen', - 'active' => true, - 'adminOnly' => true, - ), - 'berichte' => - array ( - 'name' => 'Berichte Einsehen', - 'active' => true, - 'adminOnly' => false, - ), - 'domains' => - array ( - 'name' => 'Domains', - 'active' => true, - 'adminOnly' => false, - ), - 'einkaufsliste' => - array ( - 'name' => 'Einkaufsliste', - 'active' => true, - 'adminOnly' => false, - ), - 'termine' => - array ( - 'name' => 'Termine', - 'active' => true, - 'adminOnly' => false, - ), - 'firmenberichte' => - array ( - 'name' => 'Firmenberichte', - 'active' => true, - 'adminOnly' => false, - ), - 'berufsschulberichte' => - array ( - 'name' => 'Berufsschulberichte', - 'active' => true, - 'adminOnly' => false, - ), - 'ticket_board' => - array ( - 'name' => 'Tickets / Ideen', - 'active' => true, - 'adminOnly' => false, - ), - 'ticket_control' => - array ( - 'name' => 'Tickets', - 'active' => true, - 'adminOnly' => false, - ), - 'ajaxTests' => - array ( - 'name' => 'AJAX', - 'active' => true, - 'adminOnly' => false, - ), -); - -$linkGroups = array ( - 'info' => - array ( - 'label' => 'Informationen', - 'color' => '#3498db', - 'defaultOpen' => false, - ), - 'tools' => - array ( - 'label' => 'IoT', - 'color' => '#2ecc71', - 'defaultOpen' => false, - ), - 'admin' => - array ( - 'label' => 'Administration', - 'color' => '#e74c3c', - 'defaultOpen' => false, - ), - 'devices' => - array ( - 'label' => 'Geräte', - 'color' => '#b7db33', - 'defaultOpen' => false, - ), -); - -$linkButtons = array ( - 0 => - array ( - 'label' => 'Gitea', - 'url' => 'http://gitea.mrhossa.de', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'admin', - ), - 1 => - array ( - 'label' => 'HAProxy', - 'url' => 'http://stats.mrhossa.de', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'admin', - ), - 2 => - array ( - 'label' => 'Public', - 'url' => 'https://mrhossa.de', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'info', - ), - 3 => - array ( - 'label' => 'NAS-1', - 'url' => 'http://nas-1.blackpi.ipv64.net', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'devices', - ), - 4 => - array ( - 'label' => 'NAS-2', - 'url' => 'http://nas-2.blackpi.ipv64.net', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'devices', - ), - 5 => - array ( - 'label' => 'FritzBox-1', - 'url' => 'http://fritzbox-1.blackpi.ipv64.net', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'devices', - ), - 6 => - array ( - 'label' => 'FritzBox-2', - 'url' => 'http://fritzbox-2.blackpi.ipv64.net', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'devices', - ), - 7 => - array ( - 'label' => 'GS1910-24', - 'url' => 'http://switch.blackpi.ipv64.net', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'admin', - ), - 8 => - array ( - 'label' => 'NWA5121-NI Innen', - 'url' => 'http://ap-1.blackpi.ipv64.net', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'devices', - ), - 9 => - array ( - 'label' => 'NWA5121-NI Aussen', - 'url' => 'http://ap-2.blackpi.ipv64.net', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'devices', - ), - 10 => - array ( - 'label' => 'ZyWALL 110', - 'url' => 'http://10.233.1248', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'admin', - ), - 11 => - array ( - 'label' => 'Ender 3 V3 KE', - 'url' => 'http://10.233.1.52', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'tools', - ), - 12 => - array ( - 'label' => 'Ubuntu NAS', - 'url' => 'http://10.233.1.32:9000', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'tools', - ), - 13 => - array ( - 'label' => 'Backend', - 'url' => 'https://backend.blackpi.ipv64.net', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'info', - ), - 14 => - array ( - 'label' => 'Dev Backend', - 'url' => 'https://dev-backend.blackpi.ipv64.net', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'info', - ), - 15 => - array ( - 'label' => 'Dev Pubic', - 'url' => 'https://dev-public.blackpi.ipv64.net', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'info', - ), - 16 => - array ( - 'label' => 'Local Backend', - 'url' => 'http://backend.local.ipv64.net', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'info', - ), - 17 => - array ( - 'label' => 'Local Pubic', - 'url' => 'http://public.local.ipv64.net', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'info', - ), - 18 => - array ( - 'label' => 'Proxmox', - 'url' => 'https://100.88.208.86:8006', - 'newTab' => true, - 'adminOnly' => true, - 'group' => 'devices', - ), - 19 => - array ( - 'label' => 'Flatnotes', - 'url' => 'http://10.233.1.130:8080', - 'newTab' => true, - 'adminOnly' => false, - 'group' => 'tools', - ), -); +); \ No newline at end of file diff --git a/WEBROOT/index.php b/WEBROOT/index.php index 5af19e4..9a3bd97 100644 --- a/WEBROOT/index.php +++ b/WEBROOT/index.php @@ -9,13 +9,12 @@ session_set_cookie_params([ 'samesite' => 'Lax' ]); session_start(); - if (empty($_SESSION['user_logged_in'])) { - header('Location: login.php'); + header('Location: login'); exit; } -include_once 'config.php'; +include_once 'config.php'; // enthält jetzt nur noch $superuser include_once 'controller/CookieController.php'; include_once 'controller/DatabaseConnect.php'; include_once 'controller/DatabaseController.php'; @@ -23,7 +22,6 @@ include_once 'controller/DataController.php'; include_once 'controller/LogController.php'; include_once 'controller/UserController.php'; include_once 'modules/ConsoleLog.php'; -// include 'controller/RoutesController.php'; $user_id = DatabaseShow( "Benutzer", @@ -32,6 +30,7 @@ $user_id = DatabaseShow( $_SESSION['username'], ); +// Berechtigte Seiten-IDs des Nutzers (bleibt unverändert) $rightsArray = DatabaseShowWithFK( "Benutzer_Berechtigungen", $Berechtigungen, @@ -39,9 +38,47 @@ $rightsArray = DatabaseShowWithFK( "BENUTZER_ID = ?", $user_id[0]['ID'], ); - $userRights = array_map('trim', array_column($rightsArray['rows'], 'SEITEN_ID')); +$isAdmin = isset($_SESSION['is_admin']) && $_SESSION['is_admin'] === true; +// --- Seiten & Gruppen aus der DB laden --- +$seitenGruppenRows = DatabaseShow( + "Backend_Seiten_Gruppen", + "ID, LABEL, DEFAULT_OPEN, SORTIERUNG" +); +usort($seitenGruppenRows, fn($a, $b) => ($a['SORTIERUNG'] ?? 0) <=> ($b['SORTIERUNG'] ?? 0)); + +$seitenRows = DatabaseShow( + "Backend_Seiten", + "ID, DATEINAME, NAME, AKTIV, ADMIN_ONLY, GRUPPE_ID, SORTIERUNG" +); +usort($seitenRows, fn($a, $b) => ($a['SORTIERUNG'] ?? 0) <=> ($b['SORTIERUNG'] ?? 0)); + +$services = []; +foreach ($seitenRows as $row) { + $services[$row['DATEINAME']] = [ + 'id' => $row['ID'], + 'name' => $row['NAME'], + 'active' => (bool)$row['AKTIV'], + 'adminOnly' => (bool)$row['ADMIN_ONLY'], + 'gruppeId' => $row['GRUPPE_ID'], + ]; +} + +$serviceGroups = []; +foreach ($seitenGruppenRows as $gruppe) { + $servicesInGruppe = array_keys(array_filter( + $services, + fn($s) => $s['gruppeId'] == $gruppe['ID'] + )); + $serviceGroups[$gruppe['LABEL']] = [ + 'label' => $gruppe['LABEL'], + 'defaultOpen' => (bool)$gruppe['DEFAULT_OPEN'], + 'services' => $servicesInGruppe, + ]; +} + +// --- Selected Service Logik bleibt unverändert --- $selectedService = null; if ( @@ -52,15 +89,6 @@ if ( $selectedService = $_GET['service']; } -if ( - !$selectedService && - isset($defaultService) && - isset($services[$defaultService]) && - $services[$defaultService]['active'] -) { - $selectedService = $defaultService; -} - if (!$selectedService) { foreach ($services as $key => $service) { if ($service['active']) { @@ -74,8 +102,6 @@ if ($selectedService && !in_array($selectedService, $userRights, true)) { $selectedService = null; } -$isAdmin = isset($_SESSION['is_admin']) && $_SESSION['is_admin'] === true; - if ((new getSpecificData())->getWebsite() != "backend.mrhossa.de") { $title = "DEV Backend"; } else { @@ -102,7 +128,7 @@ if ((new getSpecificData())->getWebsite() != "backend.mrhossa.de") {