153 lines
4.3 KiB
PHP
153 lines
4.3 KiB
PHP
<?php
|
|
ob_start();
|
|
session_set_cookie_params([
|
|
'lifetime' => 0,
|
|
'path' => '/',
|
|
'domain' => '',
|
|
'secure' => false,
|
|
'httponly' => true,
|
|
'samesite' => 'Lax'
|
|
]);
|
|
session_start();
|
|
|
|
if (empty($_SESSION['user_logged_in'])) {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
include_once 'config.php';
|
|
include_once 'controller/CookieController.php';
|
|
include_once 'controller/DatabaseConnect.php';
|
|
include_once 'controller/DatabaseController.php';
|
|
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",
|
|
"ID",
|
|
"NAME = ?",
|
|
$_SESSION['username'],
|
|
);
|
|
|
|
$rightsArray = DatabaseShowWithFK(
|
|
"Benutzer_Berechtigungen",
|
|
$Berechtigungen,
|
|
"SEITEN_ID",
|
|
"BENUTZER_ID = ?",
|
|
$user_id[0]['ID'],
|
|
);
|
|
|
|
$userRights = array_map('trim', array_column($rightsArray['rows'], 'SEITEN_ID'));
|
|
|
|
$selectedService = null;
|
|
|
|
if (
|
|
isset($_GET['service']) &&
|
|
isset($services[$_GET['service']]) &&
|
|
$services[$_GET['service']]['active']
|
|
) {
|
|
$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']) {
|
|
$selectedService = $key;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
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 {
|
|
$title = "Backend";
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="de">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?= $title ?></title>
|
|
<link rel="stylesheet" href="style.css">
|
|
</head>
|
|
|
|
<body>
|
|
<header class="main-header">
|
|
Backend
|
|
<button id="darkModeToggle">Dark Mode</button>
|
|
<button id="logoutButton">Logout</button>
|
|
</header>
|
|
<div class="main">
|
|
<div class="sidebar">
|
|
<?php foreach ($serviceGroups as $groupKey => $group): ?>
|
|
<?php
|
|
$visibleServices = [];
|
|
|
|
foreach ($group['services'] as $serviceKey) {
|
|
if (!isset($services[$serviceKey])) continue;
|
|
if (!$services[$serviceKey]['active']) continue;
|
|
if (!empty($services[$serviceKey]['adminOnly']) && !$isAdmin) continue;
|
|
if (!in_array($serviceKey, $userRights, true)) continue;
|
|
$visibleServices[] = $serviceKey;
|
|
}
|
|
|
|
if (empty($visibleServices)) continue;
|
|
|
|
$isOpen = !empty($group['defaultOpen']) || in_array($selectedService, $visibleServices, true);
|
|
?>
|
|
<div class="service-group <?= $isOpen ? 'open' : '' ?>" data-group="<?= $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>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<div class="content">
|
|
<?php
|
|
if ($selectedService) {
|
|
include "services/$selectedService.php";
|
|
logging();
|
|
} else {
|
|
echo "<p>Kein aktiver Service verfügbar.</p>";
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
<script src="main.js"></script>
|
|
</body>
|
|
|
|
</html>
|