asdasd
This commit is contained in:
134
custom/apps/pihole/partials/dashboard.php
Normal file
134
custom/apps/pihole/partials/dashboard.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
$settings = modules()->settings('pihole');
|
||||
$instances = module_fn('pihole', 'instances');
|
||||
$hasConfig = !empty($instances);
|
||||
$refreshSeconds = (int)($settings['dashboard_refresh_sec'] ?? 1);
|
||||
if ($refreshSeconds < 0) {
|
||||
$refreshSeconds = 1;
|
||||
}
|
||||
?>
|
||||
<div class="pihole-content pihole-page" data-pihole-page="dashboard" data-refresh-seconds="<?= e((string)$refreshSeconds) ?>">
|
||||
|
||||
<section class="window-app-card pihole-card">
|
||||
<div class="pihole-section-header">
|
||||
<strong>Hosts</strong>
|
||||
<a class="window-app-nav-button pihole-link-button" href="/apps/pihole/index.php?view=instances">Instanzen verwalten</a>
|
||||
</div>
|
||||
<?php if (!$instances): ?>
|
||||
<div class="muted" style="margin-top:.75rem;">Keine Pi-hole Instanzen vorhanden. Bitte zuerst hinzufuegen.</div>
|
||||
<div style="margin-top:.75rem;"><a class="window-app-nav-button pihole-primary-action" href="/apps/pihole/index.php?view=instances">+ Neue Instanz</a></div>
|
||||
<?php else: ?>
|
||||
<div class="pihole-list" style="margin-top:1rem;">
|
||||
<?php foreach ($instances as $instance): ?>
|
||||
<div class="pihole-list-row">
|
||||
<div>
|
||||
<strong><?= e((string)($instance['name'] ?? $instance['id'] ?? '')) ?></strong>
|
||||
<div class="muted"><?= e((string)($instance['url'] ?? '')) ?></div>
|
||||
</div>
|
||||
<?php if (!empty($instance['is_primary'])): ?>
|
||||
<span class="pihole-status">Primaer</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
||||
<?php if (!$hasConfig): ?>
|
||||
<?php return; ?>
|
||||
<?php else: ?>
|
||||
<div class="pihole-grid">
|
||||
<div class="window-app-card pihole-stat">
|
||||
<div class="muted">DNS Queries (heute)</div>
|
||||
<div class="pihole-stat-value" data-summary-dns>–</div>
|
||||
</div>
|
||||
<div class="window-app-card pihole-stat">
|
||||
<div class="muted">Ads geblockt</div>
|
||||
<div class="pihole-stat-value" data-summary-blocked>–</div>
|
||||
<div class="pihole-stat-sub" data-summary-percent>–</div>
|
||||
</div>
|
||||
<div class="window-app-card pihole-stat">
|
||||
<div class="muted">Unique Clients</div>
|
||||
<div class="pihole-stat-value" data-summary-clients>–</div>
|
||||
</div>
|
||||
<div class="window-app-card pihole-stat">
|
||||
<div class="muted">Status</div>
|
||||
<div class="pihole-stat-value" data-summary-status>–</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="window-app-card pihole-card">
|
||||
<div class="pihole-section-header">
|
||||
<strong>Blocker steuern (alle Instanzen)</strong>
|
||||
<span class="muted" data-summary-last-refresh>Letztes Update: –</span>
|
||||
</div>
|
||||
<div class="pihole-actions" data-global-actions>
|
||||
<button class="cta-button" data-action="enable" data-instance="all">Aktivieren</button>
|
||||
<button class="nav-link" data-action="disable" data-minutes="5" data-instance="all">5 Min</button>
|
||||
<button class="nav-link" data-action="disable" data-minutes="10" data-instance="all">10 Min</button>
|
||||
<button class="nav-link" data-action="disable" data-minutes="20" data-instance="all">20 Min</button>
|
||||
<button class="nav-link" data-action="disable" data-minutes="30" data-instance="all">30 Min</button>
|
||||
<button class="nav-link" data-action="disable" data-minutes="60" data-instance="all">60 Min</button>
|
||||
<div class="pihole-inline">
|
||||
<input type="number" min="1" max="1440" placeholder="Minuten" data-custom-minutes="all">
|
||||
<button class="nav-link" data-action="disable-custom" data-instance="all">Custom</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="window-app-card pihole-card">
|
||||
<div class="pihole-section-header">
|
||||
<strong>Instanzen</strong>
|
||||
<span class="muted">Einzeln steuerbar & getrennte Updates</span>
|
||||
</div>
|
||||
<div class="pihole-instance-grid" data-instance-cards></div>
|
||||
</section>
|
||||
|
||||
<section class="window-app-card pihole-card">
|
||||
<div class="pihole-section-header">
|
||||
<strong>Usage (Aggregiert)</strong>
|
||||
<span class="muted">Query-Typen und Weiterleitungen</span>
|
||||
</div>
|
||||
<div class="pihole-split" style="margin-top:1rem;">
|
||||
<div>
|
||||
<div class="muted">Query-Typen</div>
|
||||
<div class="pihole-list" data-query-types></div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="muted">Forward Destinations</div>
|
||||
<div class="pihole-list" data-forward-destinations></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<template id="pihole-instance-template">
|
||||
<div class="window-app-card pihole-instance" data-instance="">
|
||||
<div class="pihole-instance-header">
|
||||
<div>
|
||||
<strong data-instance-name></strong>
|
||||
<div class="muted" data-instance-url></div>
|
||||
</div>
|
||||
<div class="pihole-status" data-instance-status>–</div>
|
||||
</div>
|
||||
<div class="pihole-instance-stats">
|
||||
<div><span class="muted">DNS heute</span><div class="pihole-instance-value" data-instance-dns>–</div></div>
|
||||
<div><span class="muted">Ads geblockt</span><div class="pihole-instance-value" data-instance-ads>–</div></div>
|
||||
<div><span class="muted">% Blocked</span><div class="pihole-instance-value" data-instance-percent>–</div></div>
|
||||
</div>
|
||||
<div class="pihole-actions" data-instance-actions>
|
||||
<button class="cta-button" data-action="enable" data-instance="">Aktivieren</button>
|
||||
<button class="nav-link" data-action="disable" data-minutes="5" data-instance="">5 Min</button>
|
||||
<button class="nav-link" data-action="disable" data-minutes="10" data-instance="">10 Min</button>
|
||||
<button class="nav-link" data-action="disable" data-minutes="30" data-instance="">30 Min</button>
|
||||
<div class="pihole-inline">
|
||||
<input type="number" min="1" max="1440" placeholder="Minuten" data-custom-minutes="">
|
||||
<button class="nav-link" data-action="disable-custom" data-instance="">Custom</button>
|
||||
</div>
|
||||
<button class="nav-link" data-action="update" data-instance="">Pi-hole Update</button>
|
||||
</div>
|
||||
<div class="pihole-update" data-instance-update></div>
|
||||
<div class="pihole-error" data-instance-errors></div>
|
||||
</div>
|
||||
</template>
|
||||
408
custom/apps/pihole/partials/instances.php
Normal file
408
custom/apps/pihole/partials/instances.php
Normal file
@@ -0,0 +1,408 @@
|
||||
<?php
|
||||
$moduleName = 'pihole';
|
||||
|
||||
require_admin();
|
||||
|
||||
$settings = modules()->settings($moduleName);
|
||||
$notice = null;
|
||||
$error = null;
|
||||
$testResults = [];
|
||||
|
||||
$httpRequest = static function (string $method, string $url, array $headers, ?string $body, bool $verify, int $timeout): array {
|
||||
$raw = '';
|
||||
$httpCode = 0;
|
||||
$requestError = '';
|
||||
|
||||
if (function_exists('curl_init')) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => $timeout,
|
||||
CURLOPT_CONNECTTIMEOUT => $timeout,
|
||||
CURLOPT_SSL_VERIFYPEER => $verify,
|
||||
CURLOPT_SSL_VERIFYHOST => $verify ? 2 : 0,
|
||||
CURLOPT_CUSTOMREQUEST => $method,
|
||||
CURLOPT_HTTPHEADER => $headers,
|
||||
]);
|
||||
if ($body !== null) {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
|
||||
}
|
||||
$raw = (string)curl_exec($ch);
|
||||
if ($raw === '' && curl_errno($ch)) {
|
||||
$requestError = curl_error($ch);
|
||||
}
|
||||
$httpCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
} else {
|
||||
$ctx = stream_context_create([
|
||||
'http' => [
|
||||
'method' => $method,
|
||||
'timeout' => $timeout,
|
||||
'header' => implode("\r\n", $headers),
|
||||
'content' => $body ?? '',
|
||||
],
|
||||
'ssl' => [
|
||||
'verify_peer' => $verify,
|
||||
'verify_peer_name' => $verify,
|
||||
],
|
||||
]);
|
||||
$raw = (string)@file_get_contents($url, false, $ctx);
|
||||
if ($raw === '') {
|
||||
$requestError = 'HTTP request failed';
|
||||
} else {
|
||||
$httpCode = 200;
|
||||
}
|
||||
}
|
||||
|
||||
if ($requestError !== '') {
|
||||
return ['ok' => false, 'http_code' => $httpCode, 'error' => $requestError, 'raw' => $raw, 'url' => $url];
|
||||
}
|
||||
|
||||
$decoded = json_decode($raw, true);
|
||||
if (!is_array($decoded)) {
|
||||
return ['ok' => false, 'http_code' => $httpCode, 'error' => 'invalid_json', 'raw' => $raw, 'url' => $url];
|
||||
}
|
||||
|
||||
return ['ok' => true, 'http_code' => $httpCode, 'data' => $decoded, 'url' => $url];
|
||||
};
|
||||
|
||||
$runConnectionTest = static function (array $instance, array $settings) use ($httpRequest): array {
|
||||
$verifyTls = !isset($settings['verify_tls']) || $settings['verify_tls'] === '1' || $settings['verify_tls'] === 1 || $settings['verify_tls'] === true;
|
||||
$timeout = (int)($settings['api_timeout_sec'] ?? 8);
|
||||
if ($timeout <= 0) {
|
||||
$timeout = 8;
|
||||
}
|
||||
|
||||
$url = rtrim((string)($instance['url'] ?? ''), '/');
|
||||
$password = trim((string)($instance['password'] ?? ''));
|
||||
$v6AuthUrl = $url . '/api/auth';
|
||||
$v6Payload = json_encode(['password' => $password], JSON_UNESCAPED_UNICODE);
|
||||
$v6Auth = $httpRequest('POST', $v6AuthUrl, ['Accept: application/json', 'Content-Type: application/json'], $v6Payload, $verifyTls, $timeout);
|
||||
|
||||
if ($v6Auth['ok']) {
|
||||
$session = (array)(($v6Auth['data']['session'] ?? []) ?: []);
|
||||
$sid = trim((string)($session['sid'] ?? ''));
|
||||
if ($sid !== '') {
|
||||
$probe = $httpRequest('GET', $url . '/api/stats/summary', ['Accept: application/json', 'X-FTL-SID: ' . $sid], null, $verifyTls, $timeout);
|
||||
if ($probe['ok']) {
|
||||
return [
|
||||
'ok' => true,
|
||||
'status' => 'ok',
|
||||
'message' => 'Verbindung OK. API v6 antwortet.',
|
||||
'version' => 6,
|
||||
'details' => ['auth' => $v6Auth, 'probe' => $probe],
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'ok' => false,
|
||||
'status' => 'error',
|
||||
'message' => 'v6 Auth OK, aber Stats-Endpoint antwortet nicht sauber.',
|
||||
'version' => 6,
|
||||
'details' => ['auth' => $v6Auth, 'probe' => $probe],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$legacyUrl = $url . '/admin/api.php?summaryRaw';
|
||||
if ($password !== '') {
|
||||
$legacyUrl .= '&auth=' . rawurlencode($password);
|
||||
}
|
||||
$v5Probe = $httpRequest('GET', $legacyUrl, ['Accept: application/json'], null, $verifyTls, $timeout);
|
||||
if ($v5Probe['ok']) {
|
||||
return [
|
||||
'ok' => true,
|
||||
'status' => 'ok',
|
||||
'message' => 'Verbindung OK. API v5 antwortet.',
|
||||
'version' => 5,
|
||||
'details' => ['auth' => $v6Auth, 'probe' => $v5Probe],
|
||||
];
|
||||
}
|
||||
|
||||
$status = 'error';
|
||||
$message = 'Unbekannter Fehler.';
|
||||
$httpCode = (int)($v6Auth['http_code'] ?? $v5Probe['http_code'] ?? 0);
|
||||
$requestError = (string)($v6Auth['error'] ?? $v5Probe['error'] ?? 'error');
|
||||
if ($httpCode === 0) {
|
||||
$status = 'unreachable';
|
||||
$message = 'Host nicht erreichbar oder kein HTTP-Response.';
|
||||
} elseif ($httpCode === 401 || $httpCode === 403) {
|
||||
$status = 'auth';
|
||||
$message = 'Passwort oder App-Passwort falsch oder nicht berechtigt.';
|
||||
} elseif ($requestError === 'invalid_json') {
|
||||
$status = 'invalid';
|
||||
$message = 'API antwortet nicht mit JSON. URL pruefen.';
|
||||
} else {
|
||||
$message = 'API Fehler: ' . $requestError . ' (HTTP ' . $httpCode . ')';
|
||||
}
|
||||
|
||||
return [
|
||||
'ok' => false,
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
'details' => ['auth' => $v6Auth, 'probe' => $v5Probe],
|
||||
];
|
||||
};
|
||||
|
||||
$loadInstances = function (array $settings): array {
|
||||
$normalizeSecret = static function (array $row): string {
|
||||
$password = trim((string)($row['password'] ?? ''));
|
||||
if ($password !== '') {
|
||||
return $password;
|
||||
}
|
||||
|
||||
return trim((string)($row['token'] ?? ''));
|
||||
};
|
||||
|
||||
$instances = [];
|
||||
$rawJson = trim((string)($settings['instances_json'] ?? ''));
|
||||
if ($rawJson !== '') {
|
||||
$decoded = json_decode($rawJson, true);
|
||||
if (is_array($decoded)) {
|
||||
foreach ($decoded as $row) {
|
||||
if (!is_array($row)) {
|
||||
continue;
|
||||
}
|
||||
$id = trim((string)($row['id'] ?? ''));
|
||||
$url = trim((string)($row['url'] ?? ''));
|
||||
if ($id === '' || $url === '') {
|
||||
continue;
|
||||
}
|
||||
$instances[$id] = [
|
||||
'id' => $id,
|
||||
'name' => trim((string)($row['name'] ?? '')) ?: $id,
|
||||
'url' => $url,
|
||||
'password' => $normalizeSecret($row),
|
||||
'is_primary' => !empty($row['is_primary']),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$instances) {
|
||||
foreach (['primary', 'secondary'] as $key) {
|
||||
$url = trim((string)($settings[$key . '_url'] ?? ''));
|
||||
if ($url === '') {
|
||||
continue;
|
||||
}
|
||||
$instances[$key] = [
|
||||
'id' => $key,
|
||||
'name' => trim((string)($settings[$key . '_name'] ?? '')) ?: ($key === 'primary' ? 'Primaer' : 'Sekundaer'),
|
||||
'url' => $url,
|
||||
'password' => trim((string)($settings[$key . '_token'] ?? '')),
|
||||
'is_primary' => $key === 'primary',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $instances;
|
||||
};
|
||||
|
||||
$instances = $loadInstances($settings);
|
||||
|
||||
$sanitizeId = function (string $id): string {
|
||||
$id = preg_replace('/[^a-zA-Z0-9_-]/', '', $id);
|
||||
return trim((string)$id);
|
||||
};
|
||||
|
||||
$saveInstances = function (array $settings, array $instances): void {
|
||||
$payload = $settings;
|
||||
$payload['instances_json'] = json_encode(array_values($instances), JSON_UNESCAPED_UNICODE);
|
||||
modules()->saveSettings('pihole', $payload);
|
||||
};
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$deleteId = trim((string)($_POST['delete_id'] ?? ''));
|
||||
$testId = trim((string)($_POST['test_id'] ?? ''));
|
||||
$currentId = trim((string)($_POST['current_id'] ?? ''));
|
||||
$instanceId = trim((string)($_POST['instance_id'] ?? ''));
|
||||
$name = trim((string)($_POST['name'] ?? ''));
|
||||
$url = trim((string)($_POST['url'] ?? ''));
|
||||
$password = trim((string)($_POST['password'] ?? ''));
|
||||
$isPrimary = isset($_POST['is_primary']);
|
||||
|
||||
if ($testId !== '') {
|
||||
if (isset($instances[$testId])) {
|
||||
module_debug_push('pihole', [
|
||||
'label' => 'connection.test.start',
|
||||
'instance_id' => $testId,
|
||||
'instance_name' => (string)($instances[$testId]['name'] ?? $testId),
|
||||
'url' => (string)($instances[$testId]['url'] ?? ''),
|
||||
]);
|
||||
|
||||
$result = $runConnectionTest($instances[$testId], $settings);
|
||||
$testResults[$testId] = $result;
|
||||
|
||||
module_debug_push('pihole', [
|
||||
'label' => 'connection.test.result',
|
||||
'instance_id' => $testId,
|
||||
'instance_name' => (string)($instances[$testId]['name'] ?? $testId),
|
||||
'result' => $result,
|
||||
]);
|
||||
|
||||
$notice = $result['message'] ?? null;
|
||||
} else {
|
||||
$error = 'Test-Instanz nicht gefunden.';
|
||||
}
|
||||
} elseif ($deleteId !== '') {
|
||||
if (isset($instances[$deleteId])) {
|
||||
unset($instances[$deleteId]);
|
||||
$notice = 'Instanz geloescht.';
|
||||
}
|
||||
} else {
|
||||
$instanceId = $sanitizeId($instanceId);
|
||||
if ($instanceId === '' || $url === '') {
|
||||
$error = 'Bitte ID und URL angeben.';
|
||||
} elseif ($currentId === '' && isset($instances[$instanceId])) {
|
||||
$error = 'Die Instanz-ID ist bereits vergeben. Bitte eine eindeutige ID verwenden.';
|
||||
} elseif ($currentId !== '' && $currentId !== $instanceId && isset($instances[$instanceId])) {
|
||||
$error = 'Die neue Instanz-ID ist bereits vergeben. Bitte eine eindeutige ID verwenden.';
|
||||
} else {
|
||||
$existingPassword = '';
|
||||
if ($currentId !== '' && isset($instances[$currentId])) {
|
||||
$existingPassword = (string)($instances[$currentId]['password'] ?? '');
|
||||
}
|
||||
$passwordToStore = $password !== '' ? $password : $existingPassword;
|
||||
if ($currentId !== '' && $currentId !== $instanceId) {
|
||||
unset($instances[$currentId]);
|
||||
}
|
||||
$instances[$instanceId] = [
|
||||
'id' => $instanceId,
|
||||
'name' => $name !== '' ? $name : $instanceId,
|
||||
'url' => $url,
|
||||
'password' => $passwordToStore,
|
||||
'is_primary' => $isPrimary,
|
||||
];
|
||||
|
||||
if ($isPrimary) {
|
||||
foreach ($instances as $id => &$row) {
|
||||
$row['is_primary'] = ($id === $instanceId);
|
||||
}
|
||||
unset($row);
|
||||
$settings['primary_id'] = $instanceId;
|
||||
}
|
||||
|
||||
$notice = $currentId !== '' ? 'Instanz aktualisiert.' : 'Instanz gespeichert.';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$saveInstances($settings, $instances);
|
||||
$settings = modules()->settings($moduleName);
|
||||
$instances = $loadInstances($settings);
|
||||
}
|
||||
}
|
||||
|
||||
$primaryId = trim((string)($settings['primary_id'] ?? ''));
|
||||
if ($primaryId === '') {
|
||||
foreach ($instances as $id => $row) {
|
||||
if (!empty($row['is_primary'])) {
|
||||
$primaryId = $id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="pihole-content">
|
||||
<section class="window-app-card pihole-card">
|
||||
<div class="pihole-section-header">
|
||||
<div>
|
||||
<h3 class="pihole-section-title">Instanzen</h3>
|
||||
<p class="window-app-copy">Pi-hole Instanzen hinzufuegen, bearbeiten und loeschen.</p>
|
||||
</div>
|
||||
<div style="display:flex; gap:10px; flex-wrap:wrap;">
|
||||
<button class="window-app-nav-button pihole-primary-action" type="button" data-instance-new>+ Neue Instanz</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="pihole-message pihole-message--error" style="margin-top:16px;">
|
||||
<?= e($error) ?>
|
||||
</div>
|
||||
<?php elseif ($notice): ?>
|
||||
<div class="pihole-message pihole-message--success" style="margin-top:16px;">
|
||||
<?= e($notice) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="pihole-instance-grid" style="margin-top:16px;">
|
||||
<?php if (!$instances): ?>
|
||||
<div class="window-app-card pihole-card">Keine Instanzen vorhanden.</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($instances as $instance): ?>
|
||||
<div class="window-app-card pihole-instance-card"
|
||||
data-instance-id="<?= e((string)$instance['id']) ?>"
|
||||
data-name="<?= e((string)($instance['name'] ?? '')) ?>"
|
||||
data-url="<?= e((string)($instance['url'] ?? '')) ?>"
|
||||
data-primary="<?= !empty($instance['is_primary']) ? '1' : '0' ?>">
|
||||
<div class="pihole-instance-header">
|
||||
<div>
|
||||
<strong><?= e((string)($instance['name'] ?? '')) ?></strong>
|
||||
<div class="muted">ID: <?= e((string)($instance['id'] ?? '')) ?></div>
|
||||
<div class="muted">URL: <?= e((string)($instance['url'] ?? '')) ?></div>
|
||||
</div>
|
||||
<?php if (!empty($instance['is_primary']) || $instance['id'] === $primaryId): ?>
|
||||
<span class="pihole-status">Primaer</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="pihole-card-actions">
|
||||
<button class="window-app-nav-button pihole-link-button" type="button" data-instance-edit>Bearbeiten</button>
|
||||
<form method="post">
|
||||
<input type="hidden" name="test_id" value="<?= e((string)($instance['id'] ?? '')) ?>">
|
||||
<button class="window-app-nav-button pihole-link-button" type="submit" data-instance-test>Test Verbindung</button>
|
||||
</form>
|
||||
<form method="post" onsubmit="return confirm('Instanz wirklich loeschen?')">
|
||||
<input type="hidden" name="delete_id" value="<?= e((string)($instance['id'] ?? '')) ?>">
|
||||
<button class="window-app-nav-button pihole-link-button" type="submit">Loeschen</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="pihole-test-result<?= !empty($testResults[$instance['id']]['status']) ? ' is-' . e((string)$testResults[$instance['id']]['status']) : '' ?>" data-instance-result><?= e((string)($testResults[$instance['id']]['message'] ?? '')) ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="modal" data-instance-modal aria-hidden="true">
|
||||
<div class="modal-card pihole-modal-card" role="dialog" aria-modal="true" aria-labelledby="pihole-instance-modal-title">
|
||||
<div class="modal-header">
|
||||
<div>
|
||||
<strong id="pihole-instance-modal-title" data-instance-modal-title>Neue Instanz</strong>
|
||||
<div class="muted">Pi-hole Host anlegen oder bestehende Instanz bearbeiten.</div>
|
||||
</div>
|
||||
<button class="icon-button" type="button" data-instance-close aria-label="Modal schliessen">×</button>
|
||||
</div>
|
||||
<form method="post" class="pihole-instance-form" data-instance-form>
|
||||
<input type="hidden" name="current_id" value="">
|
||||
<div class="form-grid pihole-instance-form-grid">
|
||||
<label class="form-field pihole-form-field-wide">
|
||||
<span class="muted">ID</span>
|
||||
<input type="text" name="instance_id" placeholder="z.B. pihole-main" required>
|
||||
<small class="muted">Die ID muss eindeutig sein und wird nur intern verwendet.</small>
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="muted">Name</span>
|
||||
<input type="text" name="name" placeholder="z.B. Pi-hole Main" required>
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="muted">URL</span>
|
||||
<input type="text" name="url" placeholder="http://pi-hole.local" required>
|
||||
</label>
|
||||
<label class="form-field pihole-form-field-wide">
|
||||
<span class="muted">Passwort / App-Passwort</span>
|
||||
<input type="password" name="password" placeholder="Pi-hole Passwort oder App-Passwort" autocomplete="new-password">
|
||||
<small class="muted">Beim Bearbeiten leer lassen, um das gespeicherte Passwort unveraendert zu lassen.</small>
|
||||
</label>
|
||||
<label class="pihole-checkbox-field">
|
||||
<input type="checkbox" name="is_primary" value="1">
|
||||
<span>Als Primaer verwenden</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="pihole-modal-actions">
|
||||
<button class="window-app-nav-button pihole-primary-action" type="submit" data-instance-submit>Speichern</button>
|
||||
<button class="window-app-nav-button pihole-link-button" type="button" data-instance-cancel>Abbrechen</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
88
custom/apps/pihole/partials/lists.php
Normal file
88
custom/apps/pihole/partials/lists.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
$settings = modules()->settings('pihole');
|
||||
$instances = module_fn('pihole', 'instances');
|
||||
$hasConfig = !empty($instances);
|
||||
$refreshSeconds = (int)($settings['lists_refresh_sec'] ?? 5);
|
||||
if ($refreshSeconds < 0) {
|
||||
$refreshSeconds = 5;
|
||||
}
|
||||
?>
|
||||
<div class="pihole-content pihole-page" data-pihole-page="lists" data-refresh-seconds="<?= e((string)$refreshSeconds) ?>">
|
||||
<?php if (!$hasConfig): ?>
|
||||
<div class="window-app-card pihole-card">
|
||||
<strong>Keine Instanzen konfiguriert</strong>
|
||||
<div class="muted" style="margin-top:.35rem;">Bitte zuerst eine Pi-hole Instanz hinzufuegen.</div>
|
||||
<div style="margin-top:.75rem;"><a class="window-app-nav-button pihole-link-button" href="/apps/pihole/index.php?view=instances">Instanzen verwalten</a></div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<section class="window-app-card pihole-card">
|
||||
<div class="pihole-section-header">
|
||||
<strong>Listen-Updates</strong>
|
||||
<span class="muted">Gravity / Blocklisten fuer alle oder einzelne Instanzen neu laden</span>
|
||||
</div>
|
||||
<div class="pihole-actions" data-list-actions>
|
||||
<button class="cta-button" data-action="gravity" data-instance="all">Alle Instanzen aktualisieren</button>
|
||||
<?php foreach ($instances as $instance): ?>
|
||||
<button class="nav-link" data-action="gravity" data-instance="<?= e((string)($instance['id'] ?? '')) ?>">
|
||||
<?= e((string)($instance['name'] ?? $instance['id'] ?? 'Instanz')) ?>
|
||||
</button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="pihole-update" data-list-update-status></div>
|
||||
</section>
|
||||
|
||||
<div class="pihole-split">
|
||||
<div class="window-app-card pihole-card">
|
||||
<div class="pihole-section-header">
|
||||
<strong>Top geblockte Domains (Aggregiert)</strong>
|
||||
<span class="muted">Letzte Statistiken</span>
|
||||
</div>
|
||||
<div class="pihole-list" data-top-ads></div>
|
||||
</div>
|
||||
<div class="window-app-card pihole-card">
|
||||
<div class="pihole-section-header">
|
||||
<strong>Top erlaubte Domains (Aggregiert)</strong>
|
||||
<span class="muted">Letzte Statistiken</span>
|
||||
</div>
|
||||
<div class="pihole-list" data-top-queries></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="window-app-card pihole-card">
|
||||
<div class="pihole-section-header">
|
||||
<strong>Domainlisten erweitern</strong>
|
||||
<span class="muted">Eintraege werden auf der Primaer-Instanz gesetzt</span>
|
||||
</div>
|
||||
<form class="pihole-form" data-domain-form>
|
||||
<label>
|
||||
<span class="muted">Typ</span>
|
||||
<select name="type">
|
||||
<option value="block">Blacklist (Blocken)</option>
|
||||
<option value="allow">Whitelist (Erlauben)</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
<span class="muted">Domain</span>
|
||||
<input type="text" name="domain" placeholder="example.com" required>
|
||||
</label>
|
||||
<button class="cta-button" type="submit">Hinzufuegen</button>
|
||||
</form>
|
||||
<div class="pihole-update" data-domain-status></div>
|
||||
</section>
|
||||
|
||||
<section class="window-app-card pihole-card">
|
||||
<div class="pihole-section-header">
|
||||
<strong>Adlist-URL hinzufuegen</strong>
|
||||
<span class="muted">Optional: unterstuetzt nur wenn die API den Endpunkt anbietet.</span>
|
||||
</div>
|
||||
<form class="pihole-form" data-adlist-form>
|
||||
<label>
|
||||
<span class="muted">Adlist URL</span>
|
||||
<input type="text" name="url" placeholder="https://example.com/list.txt" required>
|
||||
</label>
|
||||
<button class="nav-link" type="submit">Adlist hinzufuegen</button>
|
||||
</form>
|
||||
<div class="pihole-update" data-adlist-status></div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
35
custom/apps/pihole/partials/queries.php
Normal file
35
custom/apps/pihole/partials/queries.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
$settings = modules()->settings('pihole');
|
||||
$instances = module_fn('pihole', 'instances');
|
||||
$hasConfig = !empty($instances);
|
||||
$refreshSeconds = (int)($settings['queries_refresh_sec'] ?? 5);
|
||||
if ($refreshSeconds < 0) {
|
||||
$refreshSeconds = 5;
|
||||
}
|
||||
?>
|
||||
<div class="pihole-content pihole-page" data-pihole-page="queries" data-refresh-seconds="<?= e((string)$refreshSeconds) ?>">
|
||||
<?php if (!$hasConfig): ?>
|
||||
<div class="window-app-card pihole-card">
|
||||
<strong>Keine Instanzen konfiguriert</strong>
|
||||
<div class="muted" style="margin-top:.35rem;">Bitte zuerst eine Pi-hole Instanz hinzufuegen.</div>
|
||||
<div style="margin-top:.75rem;"><a class="window-app-nav-button pihole-link-button" href="/apps/pihole/index.php?view=instances">Instanzen verwalten</a></div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="pihole-split">
|
||||
<div class="window-app-card pihole-card">
|
||||
<div class="pihole-section-header">
|
||||
<strong>Aktuelle Blockings</strong>
|
||||
<span class="muted">Letzte geblockte Domains</span>
|
||||
</div>
|
||||
<div class="pihole-blocked" data-recent-blocked></div>
|
||||
</div>
|
||||
<div class="window-app-card pihole-card">
|
||||
<div class="pihole-section-header">
|
||||
<strong>Top Clients (Aggregiert)</strong>
|
||||
<span class="muted">Anfragen nach Client</span>
|
||||
</div>
|
||||
<div class="pihole-list" data-top-clients></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
Reference in New Issue
Block a user