1
0
forked from Thunix/www

added terminal interface as default. old website as no-js fallback

This commit is contained in:
root
2026-01-21 09:58:53 -07:00
parent 81d9ddfd03
commit 6f709886ed
14 changed files with 1569 additions and 19 deletions

49
terminal/api/server.php Normal file
View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
require __DIR__ . '/_bootstrap.php';
$candidates = [
$rootDir . '/report',
$rootDir . '/includes/report',
];
$report = null;
foreach ($candidates as $cand) {
if (is_file($cand)) {
$report = $cand;
break;
}
}
if ($report === null) {
json_out(['rows' => [], 'lastUpdated' => null]);
}
$rows = [];
$fh = fopen($report, 'rb');
if ($fh === false) {
json_out(['rows' => [], 'lastUpdated' => null]);
}
while (($line = fgets($fh)) !== false) {
$line = trim($line);
if ($line === '') {
continue;
}
$parts = str_getcsv($line);
if (count($parts) < 3) {
continue;
}
$rows[] = [
'host' => (string)$parts[0],
'check' => (string)$parts[1],
'status' => (string)$parts[2],
];
}
fclose($fh);
$mtime = @filemtime($report);
$last = $mtime ? gmdate('c', (int)$mtime) : null;
json_out(['rows' => $rows, 'lastUpdated' => $last]);