$data['main']['temp'], 'min' => $data['main']['temp_min'], 'max' => $data['main']['temp_max'], 'gefuehlt' => $data['main']['feels_like'] ]; } else { return "API Fehler. HTTP Code: " . $httpCode; } } public function getUserAgent(): string { return $_SERVER['HTTP_USER_AGENT'] ?? 'Unbekannt'; } public function getRequestURL(): string { return $_SERVER['REQUEST_URI'] ?? 'Unbekannt'; } public function getCookie(string $name): ?string { return $_COOKIE[$name] ?? 'Unbekannt'; } public function getSessionID(): string { return $session_id ?? 'Unbekannt '; } public function getServerPort(): string { return $_SERVER['SERVER_PORT'] ?? 'Unbekannt'; } public function getClientPort(): string { return $_SERVER['REMOTE_PORT'] ?? 'Unbekannt'; } public function getDocumentRoot(): string { return $_SERVER['DOCUMENT_ROOT'] ?? 'Unbekannt'; } public function getQuery(): string { return $_SERVER['QUERY_STRING'] ?? 'Unbekannt'; } public function getRequestMethod(): string { return $_SERVER['REQUEST_METHOD'] ?? 'Unbekannt'; } public function getCurrentDir(): string { return __DIR__ ; } public function getReferer(): string { return $_SERVER['HTTP_REFERER'] ?? 'Unbekannt'; } public function getWebsite(): string { return $_SERVER['HTTP_HOST'] ?? 'Unbekannt'; } public function getDatabase(): string { $conn = db_connect(); return $conn->host_info; } public function getLoggingStatus($variable) { $status = DatabaseShow( "Variablen", "WERT", "VARIABLENNAME = ?", $variable ); return $status; } public function getServerName(): string { $Servername = $_SERVER['SERVER_NAME'] ?? 'Unbekannt'; if (in_array($Servername, ['Unbekannt', '0.0.0.0', '127.0.0.1'])) { return "Lokal"; } else { return $Servername; } } public function getServerIP(): string { $ServerIP = $_SERVER['SERVER_ADDR'] ?? 'Unbekannt'; if (in_array($ServerIP, ['Unbekannt', '0.0.0.0', '127.0.0.1'])) { return "Lokal"; } else { return $ServerIP; } } public function getClientIP(): string { $xff = $_SERVER['HTTP_X_FORWARDED_FOR'] ?? null; if ($xff) { $ips = array_map('trim', explode(',', $xff)); $clientIp = $ips[0]; return $clientIp; } else { return $_SERVER['REMOTE_ADDR']; } } public function getRequestTime(): string { date_default_timezone_set('Europe/Berlin'); $timestamp = $_SERVER['REQUEST_TIME'] ?? time(); return date('Y-m-d H:i:s', $timestamp); } function getGeoIP($ClientIP) { if (in_array($ClientIP, ['0.0.0.0', '127.0.0.1', '172.30.0.1'])) { return "Lokal"; } elseif (in_array($ClientIP, ['Unbekannt', '0.0.0.0', '127.0.0.1'])) { return "Lokal"; } else { $response = file_get_contents("http://ip-api.com/json/{$ClientIP}?fields=country,countryCode"); $data = json_decode($response); return $data->country; } } function getWhitelistedIPs() { include_once 'DatabaseController.php'; $data = DatabaseShow( "Whitelisted", "`IP-ADDRESSE`" ); $results = []; foreach ($data as $row) { $results[] =$row['IP-ADDRESSE']; } return $results; } function getServerNode($ServerIP) { $nodes = [ 'node1' => '172.30.0.11', 'node1' => '172.30.0.21', 'node2' => '172.30.0.12', 'node2' => '172.30.0.22', 'node3' => '172.30.0.13', 'node3' => '172.30.0.23', 'node4' => '172.30.0.14', 'node4' => '172.30.0.24', 'Lokal' => 'Lokal', ]; foreach ($nodes as $node => $ip) { if ($ServerIP == $ip) { return $node; break; } } } function getClientStatus($ClientIP) { if (in_array($ClientIP, $this->getWhitelistedIPs())) { return "Trusted"; } return "Untrusted"; } function getIsAdmin(){ return $_SESSION['is_admin'] ?? false; } function getIsSuperuser(){ return $_SESSION['is_superuser'] ?? false; } function getUsername(){ return $_SESSION['username'] ?? 'Gast'; } public function getAllData(): array { return [ 'Server - Document Root' => $this->getDocumentRoot(), 'Server - Current Dir' => $this->getCurrentDir(), 'Server - Name' => $this->getServerName(), 'Server - IP' => $this->getServerIP(), 'Server - Port' => $this->getServerPort(), 'Server - Node' => $this->getServerNode($this->getServerIP()), 'Server - Database' => $this->getDatabase(), 'Request - URL' => $this->getRequestURL(), 'Request - Method' => $this->getRequestMethod(), 'Request - Query' => $this->getQuery(), 'Request - Referer' => $this->getReferer(), 'Request - Time' => $this->getRequestTime(), 'Client - IP' => $this->getClientIP(), 'Client - Port' => $this->getClientPort(), 'Client - Country' => $this->getGeoIP($this->getClientIP()), 'Client - User Agent' => $this->getUserAgent(), 'Client - Cookie USER' => $this->getCookie('USER'), 'Client - Cookie SESSSRV' => $this->getCookie('SESSSRV'), 'Client - Session ID' => $this->getSessionID(), 'Access - Whitelisted' => $this->getClientStatus($this->getClientIP()), 'Access - Whitelisted IPs' => $this->getWhitelistedIPs(), 'User - Username' => $this->getUsername(), 'User - Is Admin' => $this->getIsAdmin(), 'User - Is Superuser' => $this->getIsSuperuser(), 'System - Website' => $this->getWebsite(), 'Logging - Public' => $this->getLoggingStatus('GENERAL_PUBLIC_LOGGING')[0]['WERT'], 'Logging - Public DEV' => $this->getLoggingStatus('DEV_PUBLIC_LOGGING')[0]['WERT'], 'Logging - Backend' => $this->getLoggingStatus('GENERAL_BACKEND_LOGGING')[0]['WERT'], 'Logging - Backend DEV' => $this->getLoggingStatus('DEV_BACKEND_LOGGING')[0]['WERT'], ]; } public function ShowAllData(): void { $SpecificData = (new getSpecificData())->getAllData(); echo "
";
        foreach ($SpecificData as $key => $value) {
            if (is_array($value)) {
                $value = implode(', ', $value);
            }
        printf("%-22s : %s\n", $key, $value);
        }
        echo "
"; } }