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 0000000..6ff94d4 Binary files /dev/null and b/www/res/windows.png differ diff --git a/www/files/stat.php b/www/stat.php similarity index 78% rename from www/files/stat.php rename to www/stat.php index a7d8bbd..af7df78 100644 --- a/www/files/stat.php +++ b/www/stat.php @@ -1,7 +1,7 @@ TimestampIP 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');