403)); } global $wpdb; $dwarpal_logs_table = $wpdb->prefix . 'dwarpal_logs'; $dwarpal_traffic_table = $wpdb->prefix . 'dwarpal_traffic'; $dwarpal_http_errors_table = $wpdb->prefix . 'dwarpal_http_errors'; // Row estimates come from table statistics. COUNT(*) on these logs locks a busy site. $dwarpal_total_logs = Dwarpal_Install::estimated_rows($dwarpal_logs_table); $dwarpal_total_traffic = Dwarpal_Install::estimated_rows($dwarpal_traffic_table); $dwarpal_http_errors = Dwarpal_Install::estimated_rows($dwarpal_http_errors_table); $dwarpal_failed_logins = 0; $dwarpal_firewall_blocks = 0; $dwarpal_seo_hacks = 0; $dwarpal_security_score = 40; if (get_option('dwarpal_firewall_enabled', true)) { $dwarpal_security_score += 20; } if (get_option('dwarpal_login_security_enabled', true)) { $dwarpal_security_score += 20; } if (get_option('dwarpal_security_headers_enabled', true)) { $dwarpal_security_score += 10; } if (get_option('dwarpal_audit_log_enabled', true)) { $dwarpal_security_score += 10; } // Scan steps order (no SEO Protection) - must match backend $dwarpal_scan_steps = array( 'firewall' => __('Firewall', 'dwarpal'), 'login_security' => __('Login Security', 'dwarpal'), 'security_logs' => __('Security Logs', 'dwarpal'), 'seo_protection' => __('SEO Protection', 'dwarpal'), 'malware' => __('Malware Scanner', 'dwarpal'), 'vulnerability' => __('Vulnerability Scanner', 'dwarpal'), 'file_integrity' => __('File Integrity', 'dwarpal'), 'permissions' => __('File Permissions', 'dwarpal'), 'hardening' => __('Hardening', 'dwarpal'), 'two_factor' => __('Two-Factor Auth', 'dwarpal'), 'spam_prevention' => __('Spam Prevention', 'dwarpal'), 'ip_blocking' => __('IP Blocking', 'dwarpal'), 'security_headers' => __('Security Headers', 'dwarpal'), 'post_hack' => __('Post-Hack Recovery', 'dwarpal'), 'database' => __('Database Security', 'dwarpal'), 'blocklist' => __('Blocklist Monitor', 'dwarpal'), 'live_traffic' => __('Live Traffic', 'dwarpal'), 'http_errors' => __('HTTP Errors', 'dwarpal'), 'maintenance' => __('Maintenance Mode', 'dwarpal'), 'system_info' => __('System Info', 'dwarpal'), 'plugin_scanner' => __('Plugin Scanner', 'dwarpal'), ); // System info for dashboard (4 sections: WordPress, Server, Plugins & Themes, Security) $dwarpal_system_info = null; $dwarpal_sys = array(); if (class_exists('Dwarpal_System_Info')) { $dwarpal_system_info = new Dwarpal_System_Info(); $dwarpal_sys = $dwarpal_system_info->get_system_info(); } // Features overview (enabled/disabled) $dwarpal_features = array( 'firewall' => array('name' => __('Firewall', 'dwarpal'), 'opt' => 'dwarpal_firewall_enabled'), 'login_security' => array('name' => __('Login Security', 'dwarpal'), 'opt' => 'dwarpal_login_security_enabled'), 'audit_log' => array('name' => __('Security Logs', 'dwarpal'), 'opt' => 'dwarpal_audit_log_enabled'), 'spam_prevention' => array('name' => __('Spam Prevention', 'dwarpal'), 'opt' => 'dwarpal_spam_prevention_enabled'), 'ip_blocking' => array('name' => __('IP Blocking', 'dwarpal'), 'opt' => 'dwarpal_ip_blocking_enabled'), 'security_headers' => array('name' => __('Security Headers', 'dwarpal'), 'opt' => 'dwarpal_security_headers_enabled'), 'post_hack' => array('name' => __('Post-Hack Recovery', 'dwarpal'), 'opt' => 'dwarpal_post_hack_enabled'), 'live_traffic' => array('name' => __('Live Traffic', 'dwarpal'), 'opt' => 'dwarpal_live_traffic_enabled'), 'http_errors' => array('name' => __('HTTP Error Logging', 'dwarpal'), 'opt' => 'dwarpal_http_error_logging_enabled'), 'maintenance' => array('name' => __('Maintenance Mode', 'dwarpal'), 'opt' => 'dwarpal_maintenance_mode_enabled'), 'blocklist' => array('name' => __('Blocklist Monitor', 'dwarpal'), 'opt' => 'dwarpal_blocklist_monitoring_enabled'), ); // Latest 5 security logs and 5 traffic entries for dashboard $dwarpal_recent_logs = array(); $dwarpal_recent_traffic = array(); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Custom security plugin tables. if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $dwarpal_logs_table)) === $dwarpal_logs_table) { $dwarpal_recent_logs = $wpdb->get_results( $wpdb->prepare( "SELECT id, event_type, ip_address, message, created_at FROM " . esc_sql($dwarpal_logs_table) . " ORDER BY id DESC LIMIT %d", 5 ), ARRAY_A ); } // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Custom security plugin tables. if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $dwarpal_traffic_table)) === $dwarpal_traffic_table) { $dwarpal_recent_traffic = $wpdb->get_results( $wpdb->prepare( "SELECT id, ip_address, request_uri, method, status_code, is_human, is_bot, user_id, created_at FROM " . esc_sql($dwarpal_traffic_table) . " ORDER BY id DESC LIMIT %d", 5 ), ARRAY_A ); } $dwarpal_page_title = __('Dwarpal', 'dwarpal'); $dwarpal_page_subtitle = __('Dwarpal WP Security Plugin', 'dwarpal'); ?>