<?php if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } $todayThreats = 0; $weekThreats = 0; $ipChanges24h = 0; $highSeverity = 0; try { $todayThreats = (int)Database::scalar("SELECT COUNT(*) FROM sec_watchdog_events WHERE DATE(created_at) = CURDATE()"); $weekThreats = (int)Database::scalar("SELECT COUNT(*) FROM sec_watchdog_events WHERE created_at > DATE_SUB(NOW(), INTERVAL 7 DAY)"); $highSeverity = (int)Database::scalar("SELECT COUNT(*) FROM sec_watchdog_events WHERE severity IN ('high','critical') AND created_at > DATE_SUB(NOW(), INTERVAL 24 HOUR)"); } catch (\Throwable $e) {} try { $ipChanges24h = (int)Database::scalar("SELECT COUNT(*) FROM sec_session_ip_changes WHERE created_at > DATE_SUB(NOW(), INTERVAL 24 HOUR)"); } catch (\Throwable $e) {} $events = []; try { $events = Database::fetchAll("SELECT * FROM sec_watchdog_events ORDER BY created_at DESC LIMIT 50"); } catch (\Throwable $e) {} $ipChanges = []; try { $ipChanges = Database::fetchAll("SELECT * FROM sec_session_ip_changes ORDER BY created_at DESC LIMIT 30"); } catch (\Throwable $e) {} $suspiciousPayments = []; try { $suspiciousPayments = Database::fetchAll("SELECT pl.*, o.order_ref, o.shipping_name FROM payment_logs pl LEFT JOIN orders o ON pl.order_id = o.id WHERE pl.status IN ('failed','suspicious') ORDER BY pl.created_at DESC LIMIT 20"); } catch (\Throwable $e) {} 