<?php  if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } $threats = Database::fetchAll("SELECT severity, COUNT(*) as cnt, MAX(created_at) as latest FROM sec_watchdog_events GROUP BY severity ORDER BY cnt DESC"); $recent = Database::fetchAll("SELECT id, event_id, node_id, severity, description, confidence, created_at FROM sec_watchdog_events ORDER BY created_at DESC LIMIT 25"); echo "<div class=\"threat-intel\"><h3>Threat Classifications</h3><div class=\"threat-summary\">"; foreach ($threats as $t) { $sev = ($t["severity"] === "SECURITY_FAULT" || $t["severity"] === "ANOMALY_ACTIVE") ? "danger" : (($t["severity"] === "ANOMALY_PASSIVE") ? "warning" : "info"); echo "<div class=\"threat-card\">" . UI::badge($t["severity"], $sev) . "<span>{$t["cnt"]} events</span></div>"; } echo "</div><h3>Recent Events</h3>"; $headers = ["ID", "Event", "Node", "Severity", "Description", "Confidence", "Time"]; $rows = []; foreach ($recent as $r) { $rows[] = [ $r["id"], UI::e(substr($r["event_id"] ?? "", 0, 12)), UI::e($r["node_id"] ?? ""), UI::badge($r["severity"] ?? "info"), UI::e(substr($r["description"] ?? "", 0, 60)), ($r["confidence"] ?? 0) * 100 . "%", $r["created_at"] ]; } echo UI::table($headers, $rows, "tbl-threats") . "</div>"; 