fetchHealth(); $lastPurge = $this->lastPurgeRow(); $badge = static function (bool $ok, string $yes, string $no): string { return $ok ? '' . htmlspecialchars($yes) . '' : '' . htmlspecialchars($no) . ''; }; $rows = []; $rows[] = ['SSR-Auslieferung', $badge($flagOn, 'AN - Seiten kommen vom VPS', 'AUS - SPA wie bisher')]; if ($health === null) { $rows[] = ['SSR-Server', 'NICHT ERREICHBAR']; } else { $rows[] = ['SSR-Server', $badge((bool)($health['ok'] ?? false), 'läuft (' . (int)$health['responseMs'] . ' ms)', 'meldet Fehler')]; $rows[] = ['Release', htmlspecialchars((string)($health['release']['release'] ?? '?')) . ' (Commit ' . htmlspecialchars((string)($health['release']['commit'] ?? '?')) . ', gebaut ' . htmlspecialchars($this->fmtDate((string)($health['release']['builtAt'] ?? ''))) . ')']; $rows[] = ['Seiten-Cache', (int)($health['cachedPages'] ?? 0) . ' Seiten / ' . (int)($health['cacheMB'] ?? 0) . ' MB']; } if ($lastPurge !== null) { $rows[] = ['Letzter Purge', htmlspecialchars(date('d.m. H:i', (int)$lastPurge['crdate'])) . ' (' . htmlspecialchars((string)$lastPurge['trigger_source']) . ', ' . ($lastPurge['success'] ? 'ok' : 'FEHLER') . ', ' . htmlspecialchars(mb_strimwidth((string)$lastPurge['paths'], 0, 60, '…')) . ')']; } if (!$this->purgeService->isConfigured()) { $rows[] = ['Auto-Purge', 'nicht konfiguriert (var/vitec-ssr-purge.env fehlt)']; } $html = ''; foreach ($rows as [$label, $value]) { $html .= ''; } $html .= '
' . htmlspecialchars($label) . '' . $value . '
'; $html .= '

Schalter: Site Management › Settings › VITEC. Modul "VITEC SSR" für Purge & Protokoll.

'; return $html; } public function getOptions(): array { return []; } private function fetchHealth(): ?array { $endpoint = $this->purgeService->getHealthEndpoint(); if ($endpoint === '') { return null; } $start = microtime(true); try { $response = $this->requestFactory->request($endpoint, 'GET', [ 'timeout' => 3, 'connect_timeout' => 2, 'http_errors' => false, ]); if ($response->getStatusCode() !== 200) { return null; } $data = json_decode((string)$response->getBody(), true); if (!is_array($data)) { return null; } $data['responseMs'] = (int)round((microtime(true) - $start) * 1000); return $data; } catch (\Throwable) { return null; } } private function lastPurgeRow(): ?array { try { $qb = $this->connectionPool->getQueryBuilderForTable('tx_vitec_ssrpurgelog'); $row = $qb->select('*')->from('tx_vitec_ssrpurgelog') ->orderBy('uid', 'DESC')->setMaxResults(1) ->executeQuery()->fetchAssociative(); return $row ?: null; } catch (\Throwable) { return null; } } private function fmtDate(string $iso): string { $ts = strtotime($iso); return $ts ? date('d.m.Y H:i', $ts) : '?'; } }