update: admin user with permissions for others
This commit is contained in:
1 parent
73ffffb86d
commit
eebfb9f513
4 files changed
+21
-1
No files matched your search
+2
-1
@@ -41,7 +41,8 @@ $services = [
|
||||
],
|
||||
'services_control' => [
|
||||
'name' => 'Site Control',
|
||||
'active' => true
|
||||
'active' => true,
|
||||
'adminOnly' => true
|
||||
],
|
||||
'logout' => [
|
||||
'name' => 'Logout',
|
||||
|
||||
@@ -99,6 +99,10 @@ if (!$selectedService) {
|
||||
<?php
|
||||
if (!isset($services[$serviceKey])) continue;
|
||||
if (!$services[$serviceKey]['active']) continue;
|
||||
|
||||
if (!empty($services[$serviceKey]['adminOnly']) && !$isAdmin) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<a href="?service=<?= $serviceKey ?>">
|
||||
<button class="<?= $selectedService === $serviceKey ? 'active' : '' ?>">
|
||||
|
||||
@@ -25,6 +25,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$username
|
||||
);
|
||||
|
||||
$isAdmin = DatabaseShow(
|
||||
"Benutzer",
|
||||
"ADMIN",
|
||||
"NAME = ?",
|
||||
$username
|
||||
);
|
||||
|
||||
if (!empty($results)) {
|
||||
$user = $results[0];
|
||||
|
||||
@@ -37,6 +44,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$_SESSION['is_superuser'] = true;
|
||||
}
|
||||
|
||||
if (isset($isAdmin[0]['ADMIN']) && $isAdmin[0]['ADMIN'] == 1) {
|
||||
$_SESSION['is_admin'] = true;
|
||||
} else {
|
||||
$_SESSION['is_admin'] = false;
|
||||
}
|
||||
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
} else {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// ansonsten nutzen wir 'Gast' als Fallback.
|
||||
$username = $_SESSION['username'] ?? 'Gast';
|
||||
$is_superuser = $_SESSION['is_superuser'] ?? false;
|
||||
$is_admin = $_SESSION['is_admin'] ?? false;
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -18,6 +19,7 @@ $is_superuser = $_SESSION['is_superuser'] ?? false;
|
||||
// htmlspecialchars schützt vor XSS (Cross-Site Scripting)
|
||||
echo '<h3><strong>Hallo ' . htmlspecialchars($username) . '</strong></h3>';
|
||||
echo '<h4>' . ($is_superuser ? 'Sie sind eingeloggt als Superuser' : '') . '</h4>';
|
||||
echo '<h4>' . ($is_admin ? 'Sie sind eingeloggt als Admin' : '') . '</h4>';
|
||||
?>
|
||||
</body>
|
||||
|
||||
|
||||
Reference in new issue
Block a user