Merge branch 'main' into dev

This commit is contained in:
Tower committed 2026-07-20 09:25:44 +02:00
commit 3e1a79f1f3
3 files changed
+102 -480

No files matched your search

+1 -426
View File
@@ -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',
),
);
);
+61 -30
View File
@@ -8,14 +8,15 @@ session_set_cookie_params([
'httponly' => true,
'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 +24,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 +32,7 @@ $user_id = DatabaseShow(
$_SESSION['username'],
);
// Berechtigte Seiten-IDs des Nutzers (bleibt unverändert)
$rightsArray = DatabaseShowWithFK(
"Benutzer_Berechtigungen",
$Berechtigungen,
@@ -39,9 +40,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,17 +91,11 @@ if (
$selectedService = $_GET['service'];
}
if (
!$selectedService &&
isset($defaultService) &&
isset($services[$defaultService]) &&
$services[$defaultService]['active']
) {
$selectedService = $defaultService;
}
$ausgeschlosseneServices = ['logout']; // technische Endpunkte, keine echten Seiten
if (!$selectedService) {
foreach ($services as $key => $service) {
if (in_array($key, $ausgeschlosseneServices, true)) continue;
if ($service['active']) {
$selectedService = $key;
break;
@@ -74,8 +107,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 +133,7 @@ if ((new getSpecificData())->getWebsite() != "backend.mrhossa.de") {
<div class="main">
<div class="sidebar">
<?php foreach ($serviceGroups as $groupKey => $group): ?>
<?php
<?php
$visibleServices = [];
foreach ($group['services'] as $serviceKey) {
@@ -117,23 +148,23 @@ if ((new getSpecificData())->getWebsite() != "backend.mrhossa.de") {
$isOpen = !empty($group['defaultOpen']) || in_array($selectedService, $visibleServices, true);
?>
<div class="service-group <?= $isOpen ? 'open' : '' ?>" data-group="<?= $groupKey ?>">
<div class="service-group <?= $isOpen ? 'open' : '' ?>" data-group="<?= htmlspecialchars($groupKey) ?>">
<div class="group-title">
<?= htmlspecialchars($group['label']) ?>
<span class="arrow">▸</span>
</div>
<div class="group-services">
<?php foreach ($visibleServices as $serviceKey): ?>
<a href="?service=<?= $serviceKey ?>">
<button class="<?= $selectedService === $serviceKey ? 'active' : '' ?>">
<?= htmlspecialchars($services[$serviceKey]['name']) ?>
</button>
</a>
<?php endforeach; ?>
</div>
<div class="group-title">
<?= htmlspecialchars($group['label']) ?>
<span class="arrow">▸</span>
</div>
<div class="group-services">
<?php foreach ($visibleServices as $serviceKey): ?>
<a href="?service=<?= $serviceKey ?>">
<button class="<?= $selectedService === $serviceKey ? 'active' : '' ?>">
<?= htmlspecialchars($services[$serviceKey]['name']) ?>
</button>
</a>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="content">
+40 -24
View File
@@ -5,6 +5,8 @@ include_once 'controller/LogController.php';
include_once 'modules/Mail.php';
include_once 'config.php';
ob_start();
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
@@ -19,6 +21,22 @@ logging();
$error = null;
function schreibeSessionUndPruefe(): void
{
$sid = session_id();
$writeOk = session_write_close();
$sessionFile = session_save_path() . '/sess_' . $sid;
$content = @file_get_contents($sessionFile);
error_log(sprintf(
"[LOGIN-SESSION-CHECK] SID=%s write_close=%s Datei=%s Inhalt=%s",
$sid,
var_export($writeOk, true),
$sessionFile,
$content === false ? '(Datei nicht lesbar/vorhanden)' : var_export($content, true)
));
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
@@ -30,6 +48,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$_SESSION['is_admin'] = false;
$_SESSION['is_superuser'] = false;
schreibeSessionUndPruefe();
logging();
sendMail(
"Gast Login Successful",
@@ -75,6 +95,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$_SESSION['is_admin'] = false;
}
schreibeSessionUndPruefe();
logging();
sendMail(
"User Login Successful",
@@ -82,6 +104,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
(new getSpecificData())->getRequestURL(),
true,
);
redirectToWebsite("index.php");
exit;
} else {
@@ -119,39 +142,34 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<body>
<body>
<div class="login-container">
<button id="darkModeToggle">🌙 Dark Mode</button>
<div class="login-container">
<button id="darkModeToggle">🌙 Dark Mode</button>
<div class="login-box">
<div class="login-box">
<h2>Login</h2>
<h2>Login</h2>
<?php if ($error): ?>
<p class="login-error"><?= htmlspecialchars($error) ?></p>
<?php endif; ?>
<?php if ($error): ?>
<p class="login-error"><?= htmlspecialchars($error) ?></p>
<?php endif; ?>
<form method="post">
<input type="text" name="username" placeholder="Benutzername" required>
<input type="password" name="password" placeholder="Passwort" required>
<button type="submit">Login</button>
</form>
<form method="post">
<input type="text" name="username" placeholder="Benutzername" required>
<input type="password" name="password" placeholder="Passwort" required>
<button type="submit">Login</button>
</form>
<button style="margin-top: 9px" type="button"
onclick="document.querySelector('input[name=username]').value='gast'; document.querySelector('form').submit();">
Als Gast einloggen
</button>
<button style="margin-top: 9px" type="button"
onclick="document.querySelector('input[name=username]').value='gast'; document.querySelector('form').submit();">
Als Gast einloggen
</button>
</div>
</div>
</body>
</div>
<script>
const toggle = document.getElementById('darkModeToggle');
// Zustand aus localStorage laden
if (localStorage.getItem('darkMode') === 'enabled') {
document.body.classList.add('dark-mode');
}
@@ -167,8 +185,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
});
</script>
</body>
</html>