This commit is contained in:
Bruno Notebook committed 2026-02-12 21:21:36 +01:00
1 parent 1b5e1a7a0b
commit 74b3639bf2
2 files changed
+109 -83

No files matched your search

+9 -1
View File
@@ -22,7 +22,7 @@ $serviceGroups = array (
),
'Logs' =>
array (
'label' => 'Webserver Logs',
'label' => 'Webserver',
'defaultOpen' => true,
'services' =>
array (
@@ -125,4 +125,12 @@ $linkButtons = array (
'adminOnly' => false,
'group' => 'admin',
),
2 =>
array (
'label' => 'Public',
'url' => 'https://blackpi.ipv64.net',
'newTab' => true,
'adminOnly' => false,
'group' => 'info',
),
);
+100 -82
View File
@@ -31,7 +31,7 @@ if (isset($_GET['logout'])) {
/*
|--------------------------------------------------------------------------
| SPEICHER LOGIK (mit automatischem Refresh)
| SPEICHER LOGIK
|--------------------------------------------------------------------------
*/
if (isset($_POST['save']) && ($_SESSION['logged_in'] ?? false)) {
@@ -39,38 +39,44 @@ if (isset($_POST['save']) && ($_SESSION['logged_in'] ?? false)) {
// 1. Service Groups
$newServiceGroups = [];
foreach ($_POST['serviceGroups'] as $id => $groupData) {
if (empty($id)) continue;
$newServiceGroups[$id] = [
'label' => $groupData['label'],
'defaultOpen' => isset($groupData['defaultOpen']),
'services' => $serviceGroups[$id]['services'] ?? []
];
if(isset($_POST['serviceGroups'])){
foreach ($_POST['serviceGroups'] as $id => $groupData) {
if (empty($id)) continue;
$newServiceGroups[$id] = [
'label' => $groupData['label'],
'defaultOpen' => isset($groupData['defaultOpen']),
'services' => $serviceGroups[$id]['services'] ?? []
];
}
}
// 2. Services
$newServices = [];
foreach ($_POST['services'] as $id => $s) {
if (empty($id)) continue;
$newServices[$id] = [
'name' => $s['name'],
'active' => isset($s['active']),
'adminOnly' => isset($s['adminOnly'])
];
if(isset($_POST['services'])){
foreach ($_POST['services'] as $id => $s) {
if (empty($id)) continue;
$newServices[$id] = [
'name' => $s['name'],
'active' => isset($s['active']),
'adminOnly' => isset($s['adminOnly'])
];
}
}
// 3. Link Groups
$newLinkGroups = [];
foreach ($_POST['linkGroups'] as $id => $lg) {
if (empty($id)) continue;
$newLinkGroups[$id] = [
'label' => $lg['label'],
'color' => $lg['color'],
'defaultOpen' => isset($lg['defaultOpen'])
];
if(isset($_POST['linkGroups'])){
foreach ($_POST['linkGroups'] as $id => $lg) {
if (empty($id)) continue;
$newLinkGroups[$id] = [
'label' => $lg['label'],
'color' => $lg['color'],
'defaultOpen' => isset($lg['defaultOpen'])
];
}
}
// 4. Link Buttons (Hinzugefügt)
// 4. Link Buttons
$newLinkButtons = [];
if(isset($_POST['linkButtons'])){
foreach ($_POST['linkButtons'] as $btn) {
@@ -84,7 +90,6 @@ if (isset($_POST['save']) && ($_SESSION['logged_in'] ?? false)) {
}
}
// Inhalt für config.php generieren
$content = "<?php\n\n";
$content .= '$superuser = ' . var_export($superuser, true) . ";\n\n";
$content .= '$serviceGroups = ' . var_export($newServiceGroups, true) . ";\n\n";
@@ -93,13 +98,9 @@ if (isset($_POST['save']) && ($_SESSION['logged_in'] ?? false)) {
$content .= '$linkButtons = ' . var_export($newLinkButtons, true) . ";\n";
if (file_put_contents($configFile, $content)) {
// Zwingt PHP, die Datei sofort neu zu lesen (behebt Refresh-Problem)
if (function_exists('opcache_invalidate')) {
@opcache_invalidate($configFile, true);
}
if (function_exists('opcache_invalidate')) { @opcache_invalidate($configFile, true); }
$_SESSION['status_message'] = "✅ Konfiguration erfolgreich gespeichert!";
header("Location: " . $_SERVER['PHP_SELF']);
header("Location: " . $_SERVER['PHP_SELF'] . "?success=1");
exit;
}
}
@@ -111,65 +112,58 @@ unset($_SESSION['status_message']);
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Site Control</title>
<link rel="stylesheet" href="style.css">
<style>
body { display: flex; flex-direction: column; height: 100vh; margin: 0; }
header { display: flex; justify-content: flex-end; align-items: center; padding: 10px 40px; background: #1a1a1a; }
.main { display: flex; flex: 1; overflow: hidden; width: 100%; }
.content { flex: 1; padding: 20px; overflow-y: auto; max-width: none !important; width: 100%; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 20px; margin-bottom: 40px; width: 100%; }
.admin-card { background: rgba(255, 255, 255, 0.05); border: 1px solid #333; border-radius: 8px; padding: 20px; }
input[type="text"], select { width: 100%; margin: 8px 0; padding: 10px; background: #222; border: 1px solid #444; color: #fff; border-radius: 4px; }
.status-msg { background: #28a745; color: white; padding: 15px; border-radius: 5px; margin-bottom: 20px; text-align: center; }
.save-bar { position: sticky; bottom: -20px; background: #121212; padding: 20px 0; border-top: 1px solid #333; margin-top: 20px; text-align: center; }
.btn-save { background: #007bff; color: white; padding: 12px 60px; border: none; border-radius: 5px; font-weight: bold; cursor: pointer; }
.logout-link { color: white; text-decoration: none; border: 1px solid white; padding: 5px 15px; border-radius: 4px; font-size: 0.9rem; }
.logout-link:hover { background: white; color: #007bff; }
h3 { border-bottom: 1px solid #444; padding-bottom: 10px; color: #007bff; }
body { display: flex; flex-direction: column; height: 100vh; margin: 0; background: #000; color: #fff; }
.main { display: flex; flex: 1; overflow: hidden; }
.content { flex: 1; padding: 10px; overflow-y: auto; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 20px; margin-bottom: 30px; }
.admin-card { background: #1a1a1a; border: 1px solid #333; border-radius: 8px; padding: 15px; position: relative; }
input[type="text"], select { width: 100%; margin: 5px 0; padding: 8px; background: #222; border: 1px solid #444; color: #fff; }
.status-msg { background: #28a745; padding: 15px; border-radius: 5px; margin-bottom: 20px; text-align: center; }
.save-bar { position: sticky; bottom: -20px ; padding: 20px; border-top: 1px solid #333; text-align: center; }
.btn-save { background: #007bff; color: white; padding: 12px 60px; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; }
.btn-add { background: #28a745; color: white; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; margin-bottom: 15px; }
.logout-link { color: #888; text-decoration: none; border: 1px solid #444; padding: 5px 10px; border-radius: 4px; }
h2 { border-bottom: 1px solid #333; padding-bottom: 10px; margin-top: 40px; display: flex; justify-content: space-between; align-items: center; }
</style>
</head>
<body class="dark-mode">
<div class="main">
<?php if (!($_SESSION['logged_in'] ?? false)): ?>
<div class="login-container" style="width: 100%;">
<div class="login-box">
<h2>Admin Login</h2>
<?php if(isset($error)): ?><p class="login-error"><?= $error ?></p><?php endif; ?>
<form method="post">
<input type="password" name="password" placeholder="Passwort" required>
<button type="submit">Einloggen</button>
</form>
</div>
<div style="margin: auto; width: 300px; padding: 50px; background: #111; border-radius: 10px;">
<form method="post">
<h2>Login</h2>
<input type="password" name="password" placeholder="Passwort" required style="margin-bottom:10px;">
<button type="submit" style="width:100%; padding:10px;">Login</button>
</form>
</div>
<?php else: ?>
<div class="content">
<h1>🛠 Site Control Panel</h1>
<?php if($message): ?>
<div class="status-msg"><?= $message ?></div>
<?php endif; ?>
<?php if($message): ?><div class="status-msg"><?= $message ?></div><?php endif; ?>
<form method="post">
<h3>📦 Service Gruppen (Sidebar)</h3>
<div class="admin-grid">
<form method="post" id="adminForm">
<h2>📦 Service Gruppen <button type="button" class="btn-add" onclick="addNew('serviceGroup')">+ Neu</button></h2>
<div class="admin-grid" id="container-serviceGroup">
<?php foreach ($serviceGroups as $id => $group): ?>
<div class="admin-card">
<strong style="color: #007bff;">Gruppe: <?= htmlspecialchars($id) ?></strong>
<input type="text" name="serviceGroups[<?= $id ?>][label]" value="<?= htmlspecialchars($group['label']) ?>">
<strong>ID: <?= htmlspecialchars($id) ?></strong>
<input type="text" name="serviceGroups[<?= $id ?>][label]" value="<?= htmlspecialchars($group['label']) ?>" placeholder="Label">
<label><input type="checkbox" name="serviceGroups[<?= $id ?>][defaultOpen]" <?= ($group['defaultOpen'] ?? false) ? 'checked' : '' ?>> Offen</label>
</div>
<?php endforeach; ?>
</div>
<h3>🖥 Services (Module)</h3>
<div class="admin-grid">
<h2>🖥 Services (Module) <button type="button" class="btn-add" onclick="addNew('service')">+ Neu</button></h2>
<div class="admin-grid" id="container-service">
<?php foreach ($services as $id => $s): ?>
<div class="admin-card">
<strong style="color: #007bff;">Key: <?= htmlspecialchars($id) ?></strong>
<strong>Key: <?= htmlspecialchars($id) ?></strong>
<input type="text" name="services[<?= $id ?>][name]" value="<?= htmlspecialchars($s['name']) ?>">
<label><input type="checkbox" name="services[<?= $id ?>][active]" <?= ($s['active'] ?? false) ? 'checked' : '' ?>> Aktiv</label> |
<label><input type="checkbox" name="services[<?= $id ?>][adminOnly]" <?= ($s['adminOnly'] ?? false) ? 'checked' : '' ?>> Admin-Only</label>
@@ -177,45 +171,69 @@ unset($_SESSION['status_message']);
<?php endforeach; ?>
</div>
<h3>🔘 Link Kacheln (Dashboard Buttons)</h3>
<div class="admin-grid">
<h2>🔘 Link Kacheln <button type="button" class="btn-add" onclick="addNew('linkButton')">+ Neu</button></h2>
<div class="admin-grid" id="container-linkButton">
<?php foreach ($linkButtons as $key => $btn): ?>
<div class="admin-card">
<input type="text" name="linkButtons[<?= $key ?>][label]" value="<?= htmlspecialchars($btn['label']) ?>" placeholder="Label">
<input type="text" name="linkButtons[<?= $key ?>][label]" value="<?= htmlspecialchars($btn['label']) ?>" placeholder="Name">
<input type="text" name="linkButtons[<?= $key ?>][url]" value="<?= htmlspecialchars($btn['url']) ?>" placeholder="URL">
<label>Zugehörige Gruppe:</label>
<select name="linkButtons[<?= $key ?>][group]">
<?php foreach ($linkGroups as $id => $lg): ?>
<option value="<?= $id ?>" <?= ($btn['group'] == $id) ? 'selected' : '' ?>><?= htmlspecialchars($lg['label']) ?></option>
<?php endforeach; ?>
</select>
<div style="margin-top: 10px;">
<label><input type="checkbox" name="linkButtons[<?= $key ?>][newTab]" <?= ($btn['newTab'] ?? false) ? 'checked' : '' ?>> Neuer Tab</label> |
<label><input type="checkbox" name="linkButtons[<?= $key ?>][adminOnly]" <?= ($btn['adminOnly'] ?? false) ? 'checked' : '' ?>> Admin-Only</label>
</div>
<label><input type="checkbox" name="linkButtons[<?= $key ?>][newTab]" <?= ($btn['newTab'] ?? false) ? 'checked' : '' ?>> Tab</label> |
<label><input type="checkbox" name="linkButtons[<?= $key ?>][adminOnly]" <?= ($btn['adminOnly'] ?? false) ? 'checked' : '' ?>> Admin</label>
</div>
<?php endforeach; ?>
</div>
<h3>🎨 Link Gruppen (Farben & Design)</h3>
<div class="admin-grid">
<h2>🎨 Link Gruppen <button type="button" class="btn-add" onclick="addNew('linkGroup')">+ Neu</button></h2>
<div class="admin-grid" id="container-linkGroup">
<?php foreach ($linkGroups as $id => $lg): ?>
<div class="admin-card">
<strong style="color: #007bff;">ID: <?= htmlspecialchars($id) ?></strong>
<strong>ID: <?= htmlspecialchars($id) ?></strong>
<input type="text" name="linkGroups[<?= $id ?>][label]" value="<?= htmlspecialchars($lg['label']) ?>">
<input type="color" name="linkGroups[<?= $id ?>][color]" value="<?= $lg['color'] ?? '#3498db' ?>" style="height:40px; cursor:pointer;">
<input type="color" name="linkGroups[<?= $id ?>][color]" value="<?= $lg['color'] ?? '#3498db' ?>" style="height:35px;">
</div>
<?php endforeach; ?>
</div>
<div class="save-bar">
<button type="submit" name="save" class="btn-save">💾 Änderungen speichern</button>
</div>
<div class="save-bar"><button type="submit" name="save" class="btn-save">💾 Konfiguration Speichern</button></div>
</form>
</div>
<?php endif; ?>
</div>
<script>
function addNew(type) {
const container = document.getElementById('container-' + type);
let id = "";
if (type !== 'linkButton') {
id = prompt("Bitte eine eindeutige ID eingeben (z.B. 'plex' oder 'tools_neu'):");
if (!id) return;
} else {
id = Date.now(); // Buttons nutzen numerischen Index
}
const card = document.createElement('div');
card.className = 'admin-card';
card.style.border = '1px dashed #28a745';
if (type === 'serviceGroup') {
card.innerHTML = `<strong>Neu: ${id}</strong><input type="text" name="serviceGroups[${id}][label]" placeholder="Label"><label><input type="checkbox" name="serviceGroups[${id}][defaultOpen]" checked> Offen</label>`;
} else if (type === 'service') {
card.innerHTML = `<strong>Neu: ${id}</strong><input type="text" name="services[${id}][name]" placeholder="Service Name"><label><input type="checkbox" name="services[${id}][active]" checked> Aktiv</label>`;
} else if (type === 'linkGroup') {
card.innerHTML = `<strong>Neu: ${id}</strong><input type="text" name="linkGroups[${id}][label]" placeholder="Gruppen Name"><input type="color" name="linkGroups[${id}][color]" value="#3498db" style="height:35px;">`;
} else if (type === 'linkButton') {
card.innerHTML = `<input type="text" name="linkButtons[${id}][label]" placeholder="Name"><input type="text" name="linkButtons[${id}][url]" placeholder="URL"><select name="linkButtons[${id}][group]"><?php foreach ($linkGroups as $gid => $gl): ?><option value="<?= $gid ?>"><?= $gl['label'] ?></option><?php endforeach; ?></select><label><input type="checkbox" name="linkButtons[${id}][newTab]" checked> Tab</label>`;
}
container.appendChild(card);
card.scrollIntoView({ behavior: 'smooth' });
}
</script>
</body>
</html>