From 2c17960a9d945322067a0ab72f75edf95ce11767 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Tue, 21 Apr 2026 22:53:12 +0200 Subject: [PATCH] stat: move from /files/stat to /stat --- www/.php/format.inc | 2 +- www/files/index.php | 9 ++- www/res/stat.css | 118 +++++++++++++++++++++++++++++++++++++++ www/res/windows.png | Bin 0 -> 1775 bytes www/{files => }/stat.php | 63 ++++++++++++++++++--- 5 files changed, 181 insertions(+), 11 deletions(-) create mode 100644 www/res/stat.css create mode 100644 www/res/windows.png rename www/{files => }/stat.php (78%) diff --git a/www/.php/format.inc b/www/.php/format.inc index f808ed0..168af5f 100644 --- a/www/.php/format.inc +++ b/www/.php/format.inc @@ -9,7 +9,7 @@ function get_fmt(): string { header('Location: ?format=text'); header('Content-Length: 14'); exit("303 See Other\n"); - } else if ($fmt !== 'json' && $fmt !== 'html' && $fmt !== 'text') { + } else if ($fmt !== 'json' && $fmt !== 'html' && $fmt !== 'text' && $fmt !== 'table') { header('Status: 300'); header('Content-Type: text/html; charset=UTF-8'); header('Content-Length: 162'); diff --git a/www/files/index.php b/www/files/index.php index f0cfde7..7b5ee20 100644 --- a/www/files/index.php +++ b/www/files/index.php @@ -56,7 +56,12 @@ global $getVers; $getProd = null; $getVers = null; $info = explode('/', $_SERVER['PATH_INFO']); -if (sizeof($info) > 1 && ($info[1] === 'elwig' || $info[1] === 'winziprint')) { +if (sizeof($info) > 0 && $info[1] === 'stat') { + header('Status: 303'); + header('Content-Length: 0'); + header('Location: /stat'); + exit(); +} else if (sizeof($info) > 1 && ($info[1] === 'elwig' || $info[1] === 'winziprint')) { $getProd = $info[1]; if (sizeof($info) > 2) $getVers = $info[2]; if (sizeof($info) > 3) { @@ -180,7 +185,7 @@ if ($format === 'json') { NameGrößeÄnderungsdatum [$prod, $vers, $url, $size, $mtime, $ctime, $mod, $cre]) { - echo " $name" . number_format($size / 1024 / 1024, 1) . " MB" . date('d.m.Y, H:i', $mtime) . "\n"; + echo " $name" . number_format($size / 1024 / 1024, 1) . " MB" . date('d.m.Y, H:i', $mtime) . "\n"; } ?> diff --git a/www/res/stat.css b/www/res/stat.css new file mode 100644 index 0000000..c150e87 --- /dev/null +++ b/www/res/stat.css @@ -0,0 +1,118 @@ + +:root { + font-family: 'Arial', sans-serif; +} + +.client { + background-color: #F8F8F8; + border: 1px solid #C0C0C0; + border-radius: 4px; + padding: 0.5em; + margin: 2em 0; +} + +.client > div { + display: flex; + justify-content: center; + gap: 2em; + flex-wrap: wrap; + margin-top: 1.5em; +} + +.client > span { + font-size: 0.75em; + color: #808080; + position: absolute; +} + +.device { + background-color: #F0F0F0; + border: 1px solid #C0C0C0; + border-radius: 4px; + padding: 1em 1.5em; + flex: 0 1 260px; +} + +.device.online { + background-color: #E0FFE0; + border-color: #80C080; +} + +.device.inactive { + background-color: #E0E0E0; + border-color: #B0B0B0; + color: #808080 !important; +} + +.device .name { + text-align: center; + font-size: 1.5em; + font-weight: bold; +} + +.device.online .name { + color: #008000; +} + +.device .id { + text-align: center; + font-size: 0.75em; + color: #808080; +} + +.device .date { + text-align: center; + font-size: 1em; + font-weight: bold; + margin-top: 1em; +} + +.device.online .date { + color: #008000; +} + +.device .address { + text-align: center; + font-size: 0.75em; + color: #808080; +} + +.device .versions { + display: flex; + justify-content: space-between; +} + +img { + width: 1em; + height: 1em; + transform: translateY(0.125em); +} + +@media (prefers-color-scheme: dark) { + body { + background-color: #000000; + color: #F0F0F0; + } + .client { + background-color: #080808; + border-color: #202020; + } + .device { + background-color: #101010; + border-color: #202020; + } + .device.online { + background-color: #002000; + border-color: #004000; + } + .device.inactive { + background-color: #181818; + border-color: #303030; + } + .device.online .name { + color: #00A000; + } + .device.online .date { + color: #00A000; + } +} diff --git a/www/res/windows.png b/www/res/windows.png new file mode 100644 index 0000000000000000000000000000000000000000..6ff94d4d5a853e62128ea7e6c4d77ccbe6bf730a GIT binary patch literal 1775 zcmb_d>o*(t7X2lW#493189``5sd$7^(y0asiIx=0v-VnhoiFG5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xc9GqH zNgFWHD499jv^n+VJajin969>KRg%fnxLcY1f}JL(R`Jaht>t2D$)T$1*veJFZ<^e5 z+BbaZn;VDs{nV&iT$WlHW#4MAkQHuTxh_0w;PfhHWD2jr#m4j})Kp~nBLi?Gm0%L6 zx@uM_*Qw!q>!xjUqw?zf)T-$-cuthc(vj1;B*W!4G zy?W+WbZ_?d4ZHlNU++7QDfR=SmYyjh)jTqD*m=@`yLK+Yp{RJoH0TWKTimestampIP AddressMethodURIFormatUser Agent\n"; if ($_SERVER['QUERY_STRING'] === 'full') { passthru(<<:g;s:^::g;s:$::g' EOF); } else { passthru(<<:g;s:^::g;s:$::g' EOF); @@ -51,12 +51,12 @@ EOF); } else if ($_SERVER['PATH_INFO'] === '') { $format = get_fmt(); $stat = []; - if (($file = fopen('.log.csv', 'r'))) { + if (($file = fopen('files/.log.csv', 'r'))) { while (($line = fgets($file)) !== false) { $line = explode('|', $line); if (sizeof($line) < 6) continue; if (!str_starts_with($line[5], 'Elwig/')) continue; - if (str_contains($line[5], "PICARD") || str_contains($line[5], "ENTERPRISE") || str_contains($line[5], "GEORGIOU")) continue; + if (str_contains($line[5], "PICARD") || str_contains($line[5], "ENTERPRISE") || str_contains($line[5], "GEORGIOU") || str_contains($line[5], "78A16E85-410A-4")) continue; $timestamp = intval($line[0]); $version = substr(explode(' ', $line[5], 2)[0], 6); $comment = preg_match("/\((.*?), *(.*?), *(.*?), *(.*?)\)/", $line[5], $m); @@ -154,7 +154,7 @@ EOF); echo "\n"; } } - } else { + } else if ($format === 'table') { header('Content-Type: text/html; charset=UTF-8'); echo "\n\n"; echo "Activity Statistics - Elwig\n"; @@ -208,7 +208,54 @@ EOF); echo "\n"; echo "

Log Full Log

\n"; echo "\n\n"; + } else { + header('Content-Type: text/html; charset=UTF-8'); +?> + + + + + Statistiken - Elwig + + + + + + + + + + $devices) { + echo "
$token
\n"; + foreach ($devices as $device => $data) { + $timestamp = array_key_last($data); + $addr = array_reverse(array_unique(array_map(function ($d) { + return $d[3]; + }, array_values($data)))); + $d = $data[$timestamp]; + $name = $DEVICES[$token][$device] ?? $device; + $active = $timestamp + 36 * 60 * 60 > time() ? 'online' : ($timestamp + 28 * 24 * 60 * 60 > time() ? 'offline' : 'inactive'); + echo "
"; + + echo "
$d[0]"; + if (isset($osVersions[$d[2]])) { + echo "" . str_replace('Windows', " ", $osVersions[$d[2]]) . ""; + } else { + echo "$d[2]"; + } + echo "
"; + + echo "
" . date('d.m.Y', $timestamp) . "
"; + echo "
$name
"; + echo "
$device
"; + echo "
" . implode("
", array_slice($addr, 0, 1)) . "
"; + echo "
\n"; + } + echo "
\n"; + } } + echo "\n\n"; } else { header('Status: 404'); header('Content-Length: 0');