rebuild
This commit is contained in:
123
partials/landingpages/retool/debug.php
Normal file
123
partials/landingpages/retool/debug.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
$isList = (isset($_GET['list']) && $_GET['list'] === '1');
|
||||
$isRaw = (isset($_GET['raw']) && $_GET['raw'] === '1');
|
||||
|
||||
if ($isList || $isRaw) {
|
||||
if (!auth_is_admin()) {
|
||||
http_response_code(403);
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'forbidden';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
require_admin();
|
||||
|
||||
if (!defined('APP_DEBUG_TOOL') || !APP_DEBUG_TOOL) {
|
||||
echo '<div class="card">Debug-Tool ist deaktiviert.</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
$debugDir = __DIR__ . '/../../../debug';
|
||||
if (!is_dir($debugDir)) {
|
||||
if ($isList || $isRaw) {
|
||||
http_response_code(404);
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'debug_dir_missing';
|
||||
return;
|
||||
}
|
||||
echo '<div class="card">Debug-Verzeichnis fehlt.</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
$files = array_values(array_filter(scandir($debugDir) ?: [], function ($f) use ($debugDir) {
|
||||
if ($f === '.' || $f === '..') return false;
|
||||
$path = $debugDir . '/' . $f;
|
||||
return is_file($path);
|
||||
}));
|
||||
|
||||
$selected = (string)($_GET['file'] ?? '');
|
||||
$content = null;
|
||||
|
||||
if ($selected !== '' && preg_match('/^[a-zA-Z0-9._-]+$/', $selected)) {
|
||||
$path = $debugDir . '/' . $selected;
|
||||
if (is_file($path)) {
|
||||
$content = file_get_contents($path);
|
||||
}
|
||||
}
|
||||
|
||||
if ($isList) {
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode($files);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($isRaw) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
$tail = isset($_GET['tail']) ? (int)$_GET['tail'] : 0;
|
||||
if ($tail > 0 && $content !== null) {
|
||||
$lines = preg_split('/\\R/', $content) ?: [];
|
||||
$content = implode(PHP_EOL, array_slice($lines, -$tail));
|
||||
}
|
||||
echo $content ?? '';
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="card">
|
||||
<div class="pill">Debug</div>
|
||||
<h1 style="margin-top:.75rem;">Debug Logs</h1>
|
||||
<p class="muted">Hier kannst du temporäre Log-Files aus dem <code>debug/</code>-Ordner ansehen.</p>
|
||||
|
||||
<div style="margin-top:.5rem;">
|
||||
<a class="nav-link" href="/debug?file=oidc_login.log">OIDC Login</a>
|
||||
</div>
|
||||
|
||||
<div style="margin-top:1rem;" class="grid">
|
||||
<div class="card" style="background:var(--panel-2);">
|
||||
<strong>Logs</strong>
|
||||
<ul style="margin-top:.5rem;">
|
||||
<?php if (!$files): ?>
|
||||
<li class="muted">Keine Logs vorhanden.</li>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($files as $f): ?>
|
||||
<li>
|
||||
<a class="nav-link" href="/debug?file=<?= e($f) ?>"><?= e($f) ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card" style="background:var(--panel-2);">
|
||||
<strong>Inhalt</strong>
|
||||
<?php if ($content === null): ?>
|
||||
<p class="muted" style="margin-top:.5rem;">Wähle eine Datei.</p>
|
||||
<?php else: ?>
|
||||
<pre id="debug-content" style="margin-top:.5rem; white-space:pre-wrap; font-family:monospace;"><?= e($content) ?></pre>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($selected !== ''): ?>
|
||||
<script>
|
||||
(() => {
|
||||
const el = document.getElementById('debug-content');
|
||||
if (!el) return;
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.set('raw', '1');
|
||||
let last = '';
|
||||
async function tick() {
|
||||
try {
|
||||
const res = await fetch(url.toString(), { cache: 'no-store' });
|
||||
if (!res.ok) return;
|
||||
const text = await res.text();
|
||||
if (text !== last) {
|
||||
el.textContent = text;
|
||||
last = text;
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
tick();
|
||||
setInterval(tick, 3000);
|
||||
})();
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user