strtoupper($this->label); } public string $value { get => $this->value; } public string $icon { get => $this->icon; } public string $unit { get => $this->unit; } public function __construct( string $label, string $value, string $icon, string $unit = '' ) { $this->label = $label; $this->value = $value; $this->icon = $icon; $this->unit = $unit; } } // Asymmetric Visibility (PHP 8.4) class SystemInfo { public private(set) string $hostname; public private(set) string $phpVersion; public private(set) string $osRelease; public private(set) string $serverSoftware; public private(set) float $loadAvg; public private(set) int $uptimeDays; public private(set) int $uptimeHours; public private(set) string $memTotal; public private(set) string $memFree; public private(set) int $memPercent; public private(set) string $diskTotal; public private(set) string $diskFree; public private(set) int $diskPercent; public private(set) string $cpuModel; public private(set) int $cpuCores; public function __construct() { $this->hostname = gethostname() ?: 'p-7.net Node'; $this->phpVersion = PHP_VERSION; $this->osRelease = php_uname('r'); $this->serverSoftware = $_SERVER['SERVER_SOFTWARE'] ?? 'nginx/OpenLiteSpeed'; // Load Average $load = sys_getloadavg(); $this->loadAvg = round($load[0] ?? 0.0, 2); // Uptime $uptime = 0; if (is_readable('/proc/uptime')) { $uptime = (int) explode(' ', file_get_contents('/proc/uptime'))[0]; } $this->uptimeDays = (int) floor($uptime / 86400); $this->uptimeHours = (int) floor(($uptime % 86400) / 3600); // Memory $memInfo = []; if (is_readable('/proc/meminfo')) { foreach (file('/proc/meminfo') as $line) { [$key, $val] = array_pad(explode(':', $line, 2), 2, '0'); $memInfo[trim($key)] = (int) trim($val); } } $memTotalKb = $memInfo['MemTotal'] ?? 0; $memAvailKb = $memInfo['MemAvailable'] ?? 0; $memUsedKb = $memTotalKb - $memAvailKb; $this->memTotal = $this->formatBytes($memTotalKb * 1024, 'GB'); $this->memFree = $this->formatBytes($memAvailKb * 1024, 'GB'); $this->memPercent = $memTotalKb > 0 ? (int) round($memUsedKb / $memTotalKb * 100) : 0; // Disk $diskTotal = disk_total_space('/') ?: 0; $diskFreeBytes = disk_free_space('/') ?: 0; $this->diskTotal = $this->formatBytes($diskTotal, 'GB'); $this->diskFree = $this->formatBytes($diskFreeBytes, 'GB'); $this->diskPercent = $diskTotal > 0 ? (int) round(($diskTotal - $diskFreeBytes) / $diskTotal * 100) : 0; // CPU $cpuModel = 'High-Performance CPU'; $cpuCores = 1; if (is_readable('/proc/cpuinfo')) { foreach (file('/proc/cpuinfo') as $line) { if (str_starts_with($line, 'model name') && str_contains($line, ':')) { $cpuModel = trim(explode(':', $line, 2)[1]); } if (str_starts_with($line, 'processor')) { $cpuCores++; } } } $this->cpuModel = $cpuModel; $this->cpuCores = $cpuCores; } private function formatBytes(int $bytes, string $unit = 'GB'): string { return match($unit) { 'GB' => round($bytes / 1073741824, 1) . ' GB', 'MB' => round($bytes / 1048576, 1) . ' MB', default => $bytes . ' B', }; } } // First-class callable syntax + array_map (PHP 8.1+, elegant in 8.4) $sys = new SystemInfo(); $domain = $_SERVER['HTTP_HOST'] ?? 'deine-domain.de'; // Named Arguments (PHP 8.0+, used stylishly here) $stats = [ new ServerStat(label: 'PHP Version', value: $sys->phpVersion, icon: '🐘'), new ServerStat(label: 'Hostname', value: $sys->hostname, icon: '🖥️'), new ServerStat(label: 'Load Average', value: (string)$sys->loadAvg, icon: '📊'), new ServerStat(label: 'CPU Kerne', value: (string)$sys->cpuCores, icon: '⚡'), new ServerStat(label: 'Uptime', value: $sys->uptimeDays . 'd ' . $sys->uptimeHours . 'h', icon: '⏱️'), new ServerStat(label: 'RAM gesamt', value: $sys->memTotal, icon: '💾'), ]; $getStatusColor = static fn(int $pct): string => match(true) { $pct < 60 => '#00ff88', $pct < 80 => '#ffd700', default => '#ff4560', }; $memColor = $getStatusColor($sys->memPercent); $diskColor = $getStatusColor($sys->diskPercent); $year = date('Y'); ?>
Diese Domain ist aktiv und wird auf der exklusiven Infrastruktur von p-7.net betrieben – kein Shared-Hosting-Chaos, kein Overselling, keine Kompromisse.