nonce_action = $nonce_action; } /** * Render a toggle switch * * @param string $name Input name * @param bool $checked Whether checked * @param string $label Label text (optional) * @param array $args Additional args (id, class, disabled, description) */ private function render_toggle( $name, $checked, $label = '', $args = array() ) { $id = isset( $args['id'] ) ? $args['id'] : $name; $class = isset( $args['class'] ) ? ' ' . $args['class'] : ''; $disabled = ! empty( $args['disabled'] ) ? ' disabled' : ''; $data_attr = isset( $args['data'] ) ? ' data-feature="' . esc_attr( $args['data'] ) . '"' : ''; echo '
'; echo ''; if ( $label ) { echo '' . esc_html( $label ) . ''; } echo '
'; if ( ! empty( $args['description'] ) ) { echo '

' . esc_html( $args['description'] ) . '

'; } } /** * Render the settings & security page */ public function render() { if ( ! current_user_can( 'manage_options' ) ) { return; } $notice = isset( $_GET['gp_notice'] ) ? sanitize_text_field( wp_unslash( $_GET['gp_notice'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- capability-gated read (current_user_can manage_options above); read-only notice key for display // Get settings $gp_settings = class_exists( 'GuardPress_Settings' ) ? GuardPress_Settings::get() : array(); // Get login security data $login_settings = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_settings() : array(); $login_stats = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_stats() : array(); $blocked_ips = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_blocked_ips() : array(); $suspicious = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_suspicious_ips() : array(); $blacklist = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_blacklist() : array(); $whitelist = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_whitelist() : array(); $login_log = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_log( 20 ) : array(); $current_ip = class_exists( 'GuardPress_Login_Security' ) ? GuardPress_Login_Security::get_admin_ip() : ''; echo '
'; // CSS to hide other plugin notices inside our page ?> render_notices( $notice ); // Save Settings Reminder Notice echo '
'; echo '

๐Ÿ’ก ' . esc_html__( 'Don\'t forget to click "Save Settings" after making changes!', 'ai-cyberguard' ) . '

'; echo '
'; // ===================================================================== // PART 1: Privacy & External Requests // These external-service consents (Threat Feed + AI) are needed early to // get full protection, so the single unified section leads the page. // (The former standalone "AI Analysis" and "Threat Intelligence Feed" // sections were folded in here to remove the duplicate controls.) // ===================================================================== $this->render_privacy_section(); echo '
'; // ===================================================================== // PART 2: Scanner Settings // ===================================================================== echo '

' . esc_html__( 'Scanner Settings', 'ai-cyberguard' ) . '

'; // Main settings form $this->render_settings_form( $gp_settings ); echo '
'; // Test email form $this->render_test_email_form(); echo '
'; // ===================================================================== // PART 2: Login Security // ===================================================================== echo '

' . esc_html__( 'Login Security', 'ai-cyberguard' ) . '

'; // Login stats cards $this->render_login_stats_cards( $login_stats ); // Login settings form $this->render_login_settings_form( $login_settings ); // Suspicious IPs GuardPress_Partial_Tables::render_suspicious_ips( $suspicious, $this->nonce_action ); // Temporarily blocked IPs GuardPress_Partial_Tables::render_blocked_ips( $blocked_ips, $this->nonce_action ); // Permanent Blacklist GuardPress_Partial_Tables::render_blacklist( $blacklist, $this->nonce_action, $current_ip ); // Whitelist GuardPress_Partial_Tables::render_whitelist( $whitelist, $this->nonce_action, $current_ip ); // Login activity log GuardPress_Partial_Tables::render_login_log( $login_log ); // ===================================================================== // PART 3: PRO Settings (Locked for FREE users) // ===================================================================== $this->render_pro_settings_section(); // Footer echo ''; echo '
'; // wrap } /** * Render notices (combined for settings and login security) */ private function render_notices( $notice ) { $notice_map = array( // Settings notices 'settings_saved' => array( 'type' => 'success', 'message' => __( 'Settings saved successfully.', 'ai-cyberguard' ) ), 'privacy_saved' => array( 'type' => 'success', 'message' => __( 'Privacy settings saved successfully.', 'ai-cyberguard' ) ), 'test_email_ok' => array( 'type' => 'success', 'message' => __( 'โœ… Test email sent successfully! Check your inbox (and spam folder).', 'ai-cyberguard' ) ), 'test_email_fail' => array( 'type' => 'error', 'message' => __( 'โŒ Test email failed to send. Please check: 1) Your SMTP configuration 2) wp_mail function is working 3) Email recipient is valid 4) Server allows outgoing mail', 'ai-cyberguard' ) ), // Login security notices 'ip_unblocked' => array( 'type' => 'success', 'message' => __( 'IP address unblocked.', 'ai-cyberguard' ) ), 'ip_blocked' => array( 'type' => 'success', 'message' => __( 'IP address blocked temporarily.', 'ai-cyberguard' ) ), 'added_blacklist' => array( 'type' => 'success', 'message' => __( 'IP added to permanent blacklist.', 'ai-cyberguard' ) ), 'removed_blacklist' => array( 'type' => 'success', 'message' => __( 'IP removed from blacklist.', 'ai-cyberguard' ) ), 'added_whitelist' => array( 'type' => 'success', 'message' => __( 'IP added to whitelist.', 'ai-cyberguard' ) ), 'removed_whitelist' => array( 'type' => 'success', 'message' => __( 'IP removed from whitelist.', 'ai-cyberguard' ) ), 'cleared_suspicious'=> array( 'type' => 'info', 'message' => __( 'Failed attempts cleared for IP.', 'ai-cyberguard' ) ), 'cleared_all_suspicious' => array( 'type' => 'success', 'message' => __( 'All suspicious activity cleared.', 'ai-cyberguard' ) ), 'bulk_blocked' => array( 'type' => 'success', 'message' => __( 'Selected IPs blocked temporarily.', 'ai-cyberguard' ) ), 'bulk_blacklisted' => array( 'type' => 'success', 'message' => __( 'Selected IPs added to permanent blacklist.', 'ai-cyberguard' ) ), 'bulk_cleared' => array( 'type' => 'success', 'message' => __( 'Selected IPs cleared from suspicious list.', 'ai-cyberguard' ) ), 'bulk_unblocked' => array( 'type' => 'success', 'message' => __( 'Selected IPs unblocked.', 'ai-cyberguard' ) ), 'all_unblocked' => array( 'type' => 'success', 'message' => __( 'All blocked IPs have been unblocked.', 'ai-cyberguard' ) ), 'invalid_ip' => array( 'type' => 'error', 'message' => __( 'Invalid IP address format.', 'ai-cyberguard' ) ), 'file_unignored' => array( 'type' => 'success', 'message' => __( 'File removed from ignored list.', 'ai-cyberguard' ) ), // FIX R-3 (audit 2026-05-25 round 2): unknown_cmd notice from // handle_actions default branch โ€” Settings page mirror of the // scanner-page mapping. 'unknown_cmd' => array( 'type' => 'warning', 'message' => __( 'Unknown command. The action was not executed.', 'ai-cyberguard' ) ), ); GuardPress_Partial_Notices::render_from_url( $notice_map ); } // ========================================================================= // Scanner Settings // ========================================================================= /** * Render main settings form */ private function render_settings_form( $settings ) { // Extract settings with defaults $scheduled_enabled = ! empty( $settings['scheduled_enabled'] ); $schedule_frequency = isset( $settings['schedule_frequency'] ) ? (string) $settings['schedule_frequency'] : 'twicedaily'; $schedule_mode = isset( $settings['schedule_mode'] ) ? (string) $settings['schedule_mode'] : 'regular'; $schedule_time = isset( $settings['schedule_time'] ) ? (string) $settings['schedule_time'] : '03:00'; $email_enabled = ! empty( $settings['email_enabled'] ); $email_recipients = isset( $settings['email_recipients'] ) ? (string) $settings['email_recipients'] : ''; $include_plugin_updates = ! empty( $settings['include_plugin_updates'] ); $alert_only_risky = ! empty( $settings['alert_only_risky'] ); $email_subject_prefix = isset( $settings['email_subject_prefix'] ) ? (string) $settings['email_subject_prefix'] : ''; $email_rate_limit = isset( $settings['email_rate_limit'] ) ? (string) $settings['email_rate_limit'] : 'none'; $allowed_patterns = isset( $settings['allowed_patterns'] ) && is_array( $settings['allowed_patterns'] ) ? implode( "\n", $settings['allowed_patterns'] ) : ''; $excluded_dirs = isset( $settings['excluded_dirs'] ) && is_array( $settings['excluded_dirs'] ) ? implode( "\n", $settings['excluded_dirs'] ) : ''; echo '
'; wp_nonce_field( $this->nonce_action, 'guardpress_nonce' ); echo ''; echo ''; // Scheduled Scans Section $this->render_scheduled_scans_section( $scheduled_enabled, $schedule_frequency, $schedule_mode, $schedule_time ); // Email Alerts Section $this->render_email_alerts_section( $email_enabled, $email_recipients, $email_subject_prefix, $email_rate_limit, $alert_only_risky, $include_plugin_updates ); // Exclusions Section $this->render_exclusions_section( $allowed_patterns, $excluded_dirs ); submit_button( __( 'Save Scanner Settings', 'ai-cyberguard' ), 'primary', 'submit', true ); echo '
'; } /** * Render scheduled scans section */ private function render_scheduled_scans_section( $enabled, $frequency, $mode, $time = '03:00' ) { echo '
'; echo '

' . esc_html__( 'Scheduled Scans', 'ai-cyberguard' ) . '

'; // ACG-149-138: the scheduled run now also malware-scans every file it finds changed or new // (class-cron.php), so this description states that. It says "changed" deliberately โ€” a full sweep // of every file on the site is still the manual Malware Scan. echo '

' . esc_html__( 'Automatic scans run in the background, alert you when files change, and check every changed file for malware. Recommended: Enable with "Twice daily" for most sites.', 'ai-cyberguard' ) . '

'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '

'; echo ''; echo esc_html__( 'Scan results are displayed on the main Dashboard page. After each scheduled scan, you can view the results and receive email alerts (if enabled).', 'ai-cyberguard' ); echo '

'; echo '
'; echo '
'; } /** * Render email alerts section */ private function render_email_alerts_section( $enabled, $recipients, $subject_prefix, $rate_limit, $alert_only_risky, $include_plugin_updates ) { echo '
'; echo '

' . esc_html__( 'Email Alerts', 'ai-cyberguard' ) . '

'; // ACG-149-138: a confirmed malware finding from a scheduled scan now sends its own alert, which // bypasses the rate limit below. Before this it could not: the notifier had no malware path at all. echo '

' . esc_html__( 'Get notified by email when files change โ€” and immediately if a scheduled scan finds malware.', 'ai-cyberguard' ) . '

'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; } /** * Render exclusions section */ private function render_exclusions_section( $allowed_patterns, $excluded_dirs ) { echo '
'; echo '

' . esc_html__( 'Scan Exclusions', 'ai-cyberguard' ) . '

'; echo '

' . esc_html__( 'Reduce false positives by excluding known-changing files like cache folders and logs.', 'ai-cyberguard' ) . '

'; // Warning echo '
'; echo '

โš ๏ธ ' . esc_html__( 'Security Trade-off:', 'ai-cyberguard' ) . ' ' . esc_html__( 'Excluded folders are not scanned at all. Only exclude folders you trust completely.', 'ai-cyberguard' ) . '

'; echo '
'; echo ''; echo ''; echo ''; echo '
'; } /** * Render test email form */ private function render_test_email_form() { echo '
'; echo '

' . esc_html__( 'Test Email', 'ai-cyberguard' ) . '

'; echo '

' . esc_html__( 'Send a test message to verify your email configuration.', 'ai-cyberguard' ) . '

'; GuardPress_Partial_Buttons::render_form_button( array( 'cmd' => 'send_test_email', 'label' => __( 'Send Test Email', 'ai-cyberguard' ), 'icon' => 'email', 'class' => 'secondary', 'size' => '', 'nonce' => $this->nonce_action, ) ); echo '
'; } /** * Render AI Settings section * @since 1.0.0 */ private function render_ai_settings_section() { // FIX F-104-01 (v1.0.5): render-safe, network-free readers โ€” this is a // page-render path, so it must not reach check_remote_service()/get_remaining(true). $stats = class_exists( 'GuardPress_AI_Analyzer' ) ? GuardPress_AI_Analyzer::get_usage_stats_cached_only() : array( 'used' => 0, 'limit' => 20, 'remaining' => 20 ); $is_enabled = class_exists( 'GuardPress_AI_Analyzer' ) && GuardPress_AI_Analyzer::is_enabled(); $is_available = class_exists( 'GuardPress_AI_Analyzer' ) && GuardPress_AI_Analyzer::is_available_cached_only(); $is_pro_user = class_exists( 'GuardPress_License' ) && GuardPress_License::is_pro(); echo '
'; echo '

' . esc_html__( 'AI Analysis', 'ai-cyberguard' ) . ' POWERED BY CLAUDE

'; // Privacy disclosure box (always visible) echo '
'; echo '

โš ๏ธ ' . esc_html__( 'Privacy Notice', 'ai-cyberguard' ) . '

'; echo '

'; echo esc_html__( 'When enabled, AI Analysis sends code excerpts from detected file changes to an external AI service (Claude by Anthropic) for security analysis. Alongside each excerpt it also sends the file name, its path relative to your site root, the file type, and your WordPress version (never the absolute server path or a username). Sensitive data like passwords, API keys, and database credentials are automatically redacted before sending.', 'ai-cyberguard' ); echo '

'; echo '
'; // Opt-in form if ( ! $is_enabled ) { // Show opt-in button echo '
'; echo '

'; echo esc_html__( 'AI Analysis is currently disabled. Enable it to get intelligent security insights.', 'ai-cyberguard' ); echo '

'; echo ''; echo '

'; echo esc_html__( 'By enabling, you consent to sending code excerpts to an external AI service for analysis.', 'ai-cyberguard' ); echo '

'; echo '
'; // JavaScript for enabling AI ?> '; echo ' '; echo esc_html__( 'AI Analysis is enabled and ready to use!', 'ai-cyberguard' ); echo '
'; } else { echo '
'; echo ' '; echo esc_html__( 'AI Analysis is enabled but the service is temporarily unavailable.', 'ai-cyberguard' ); echo '
'; } // Usage stats echo '
'; echo '

' . esc_html__( 'Usage Statistics', 'ai-cyberguard' ) . '

'; echo '
'; echo '' . esc_html__( 'Credits Used', 'ai-cyberguard' ) . ''; echo '' . esc_html( sprintf( '%d / %d', $stats['used'], $stats['limit'] ) ) . ''; echo '
'; // Progress bar echo '
'; $bar_color = $stats['remaining'] > 10 ? '#10b981' : ( $stats['remaining'] > 0 ? '#f59e0b' : '#ef4444' ); echo '
'; echo '
'; echo '

'; if ( $is_pro_user ) { /* translators: %d is the number of PRO AI analyses remaining this year */ echo sprintf( esc_html__( '%d PRO analyses remaining this year', 'ai-cyberguard' ), esc_html( $stats['remaining'] ) ); } else { /* translators: %d is the number of free AI analyses remaining */ echo sprintf( esc_html__( '%d free analyses remaining', 'ai-cyberguard' ), esc_html( $stats['remaining'] ) ); } echo '

'; echo '
'; } // Info box echo '
'; echo '

๐Ÿค– ' . esc_html__( 'How AI Analysis Works', 'ai-cyberguard' ) . '

'; echo ''; echo '
'; echo ''; // end section } /** * Render Threat Intelligence Feed section */ private function render_threat_feed_section() { $status = class_exists( 'GuardPress_Threat_Feed' ) ? GuardPress_Threat_Feed::get_status() : array(); $is_pro = class_exists( 'GuardPress_License' ) && GuardPress_License::is_pro(); echo '
'; echo '

' . esc_html__( 'Threat Intelligence Feed', 'ai-cyberguard' ) . '

'; // Info box echo '
'; echo '

๐Ÿ›ก๏ธ ' . esc_html__( 'What is Threat Intelligence?', 'ai-cyberguard' ) . '

'; echo '

'; echo esc_html__( 'AI CyberGuard automatically downloads the latest malware signatures and threat patterns from our security database. This keeps your scanner updated with new threats as they are discovered.', 'ai-cyberguard' ); echo '

'; echo ''; echo '
'; // Status cards echo '
'; // Signatures count echo '
'; echo '
' . intval( $status['signature_count'] ?? 0 ) . '
'; echo '
' . esc_html__( 'Threat Signatures', 'ai-cyberguard' ) . '
'; echo '
'; // Malware hashes count echo '
'; echo '
' . intval( $status['hash_count'] ?? 0 ) . '
'; echo '
' . esc_html__( 'Malware Hashes', 'ai-cyberguard' ) . '
'; echo '
'; // Last update echo '
'; $last_update = $status['last_update_ago'] ?? __( 'Never', 'ai-cyberguard' ); echo '
' . esc_html( $last_update ) . '
'; echo '
' . esc_html__( 'Last Updated', 'ai-cyberguard' ) . '
'; echo '
'; // Update interval echo '
'; $interval = $status['update_interval'] ?? __( 'Weekly', 'ai-cyberguard' ); $interval_color = $is_pro ? '#10b981' : '#f59e0b'; echo '
' . esc_html( $interval ) . '
'; echo '
' . esc_html__( 'Update Frequency', 'ai-cyberguard' ) . '
'; echo '
'; echo '
'; // Update button echo '
'; echo ''; echo ''; echo '
'; // JavaScript for update button ?> '; // end section } // ========================================================================= // Privacy & External Requests // ========================================================================= /** * Render privacy and external requests section * WP.org compliance: Clear disclosure of all external communications */ private function render_privacy_section() { $threat_feed_enabled = get_option( 'guardpress_threat_feed_enabled', false ); $threat_feed_auto = get_option( 'guardpress_threat_feed_auto_update', false ); $ai_enabled = get_option( 'guardpress_ai_enabled', false ); // Status used by the folded-in Threat Feed + AI details (shown when enabled). $tf_status = class_exists( 'GuardPress_Threat_Feed' ) ? GuardPress_Threat_Feed::get_status() : array(); // FIX F-104-01 (v1.0.5): render-safe stats (no network call on page render). $ai_stats = class_exists( 'GuardPress_AI_Analyzer' ) ? GuardPress_AI_Analyzer::get_usage_stats_cached_only() : array( 'used' => 0, 'limit' => 20, 'remaining' => 20 ); echo '
'; echo '

' . esc_html__( 'Privacy & External Requests', 'ai-cyberguard' ) . '

'; // Info box - Enhanced with recommendations echo '
'; echo '

'; echo '๐Ÿ”’ ' . esc_html__( 'Your Privacy Matters', 'ai-cyberguard' ); echo '

'; echo '

'; echo esc_html__( 'AI CyberGuard respects your privacy. All external connections to GuardPress servers are disabled by default. You have full control over what data is shared. Enable the features below to get the most out of the plugin.', 'ai-cyberguard' ); echo '

'; // Recommendations box echo '
'; echo '
'; echo ' '; echo esc_html__( 'Recommended for Full Protection:', 'ai-cyberguard' ); echo '
'; echo '
    '; echo '
  • ' . esc_html__( 'Threat Intelligence Feed', 'ai-cyberguard' ) . ' - ' . esc_html__( 'Enable for latest malware signatures (weekly updates)', 'ai-cyberguard' ) . '
  • '; echo '
  • ' . esc_html__( 'AI Analysis', 'ai-cyberguard' ) . ' - ' . esc_html__( 'Enable for deep code analysis (20 free credits)', 'ai-cyberguard' ) . '
  • '; echo '
'; echo '
'; echo '
'; echo '
'; wp_nonce_field( 'guardpress_save_privacy_settings', 'gp_privacy_nonce' ); // Modern card-based layout echo '
'; // 1. Threat Intelligence Feed echo '
'; echo '
'; echo '
'; echo '

'; echo ' '; echo esc_html__( 'Threat Intelligence Feed', 'ai-cyberguard' ); echo '

'; echo '

'; echo esc_html__( 'Registers your site with guardpress.ai (random installation ID + plugin version) and downloads the latest malware signatures, updated weekly. While this is on, scans may also check suspicious file hashes and URLs against the public abuse.ch database.', 'ai-cyberguard' ); echo '

'; echo '

'; echo '' . esc_html__( 'Data sent:', 'ai-cyberguard' ) . ' ' . esc_html__( 'random installation ID + plugin version; suspicious file hashes/URLs during scans', 'ai-cyberguard' ); echo ' โ€ข ' . esc_html__( 'To:', 'ai-cyberguard' ) . ' guardpress.ai, abuse.ch'; echo '

'; echo '
'; echo '
'; $this->render_toggle( 'gp_threat_feed_enabled', $threat_feed_enabled, '', array( 'class' => 'large' ) ); echo '
'; echo ''; echo $threat_feed_enabled ? esc_html__( 'ON', 'ai-cyberguard' ) : esc_html__( 'OFF', 'ai-cyberguard' ); echo ''; echo '
'; echo '
'; echo '
'; if ( $threat_feed_enabled ) { echo '
'; echo '
' . intval( $tf_status['signature_count'] ?? 0 ) . ' ' . esc_html__( 'signatures', 'ai-cyberguard' ) . ' • ' . intval( $tf_status['hash_count'] ?? 0 ) . ' ' . esc_html__( 'malware hashes', 'ai-cyberguard' ) . ' • ' . esc_html__( 'Updated', 'ai-cyberguard' ) . ': ' . esc_html( $tf_status['last_update_ago'] ?? __( 'Never', 'ai-cyberguard' ) ) . '
'; echo ''; echo ''; echo '
'; } echo '
'; // 1b. Auto-update sub-option (indented) echo '
'; echo '
'; echo '
'; echo '

'; echo 'โ†ณ ' . esc_html__( 'Auto-update Schedule', 'ai-cyberguard' ); echo '

'; echo '

'; echo esc_html__( 'Automatically check for new signatures via WordPress cron', 'ai-cyberguard' ); echo '

'; echo '
'; echo '
'; $this->render_toggle( 'gp_threat_feed_auto', $threat_feed_auto, '', array( 'class' => 'large', 'disabled' => ! $threat_feed_enabled ) ); echo '
'; echo ''; echo $threat_feed_auto ? esc_html__( 'AUTO', 'ai-cyberguard' ) : esc_html__( 'MANUAL', 'ai-cyberguard' ); echo ''; echo '
'; echo '
'; echo '
'; echo '
'; // 2. AI Code Analysis echo '
'; echo '
'; echo '
'; echo '

'; echo ' '; echo esc_html__( 'AI Code Analysis', 'ai-cyberguard' ); echo ' 20 ' . esc_html__( 'FREE CREDITS', 'ai-cyberguard' ) . ''; echo '

'; echo '

'; echo esc_html__( 'Analyzes suspicious files using AI to detect hidden malware and backdoors.', 'ai-cyberguard' ); echo '

'; echo '

'; echo '' . esc_html__( 'Data sent:', 'ai-cyberguard' ) . ' ' . esc_html__( 'File content + the file name, its path relative to your site root, the file type, and your WordPress version (only when you click Analyze; secrets are redacted; no absolute path or username is sent)', 'ai-cyberguard' ); echo ' โ€ข ' . esc_html__( 'To:', 'ai-cyberguard' ) . ' guardpress.ai'; echo '

'; echo '
'; echo '
'; $this->render_toggle( 'gp_ai_enabled', $ai_enabled, '', array( 'class' => 'large' ) ); echo '
'; echo ''; echo $ai_enabled ? esc_html__( 'ON', 'ai-cyberguard' ) : esc_html__( 'OFF', 'ai-cyberguard' ); echo ''; echo '
'; echo '
'; echo '
'; if ( $ai_enabled ) { /* translators: 1: number of AI credits used, 2: total AI credit limit */ echo '
' . esc_html( sprintf( __( '%1$d of %2$d AI credits used.', 'ai-cyberguard' ), (int) ( $ai_stats['used'] ?? 0 ), (int) ( $ai_stats['limit'] ?? 20 ) ) ) . '
'; } echo '
'; // 3. GeoIP enrichment (audit M-05) โ€” external IPโ†’country lookup for the Live // Attack Map. Opt-in, default OFF, so no IP leaves the site out of the box. $geoip_on = (bool) get_option( 'guardpress_geoip_enrichment_enabled', false ); echo '
'; echo '
'; echo '
'; echo '

'; echo ' '; echo esc_html__( 'Attack-map location lookup (GeoIP)', 'ai-cyberguard' ); echo '

'; echo '

'; echo esc_html__( 'Looks up the country of attacking IP addresses so the Live Attack Map can plot them. Off by default โ€” while off, the map only shows countries already known from cache.', 'ai-cyberguard' ); echo '

'; echo '

'; echo '' . esc_html__( 'Data sent:', 'ai-cyberguard' ) . ' ' . esc_html__( 'Attacking IP address (only when you open the dashboard, rate-limited)', 'ai-cyberguard' ); echo ' โ€ข ' . esc_html__( 'To:', 'ai-cyberguard' ) . ' ipinfo.io'; echo '

'; echo '
'; echo '
'; $this->render_toggle( 'gp_geoip_enrichment', $geoip_on, '', array( 'class' => 'large' ) ); echo '
'; echo ''; echo $geoip_on ? esc_html__( 'ON', 'ai-cyberguard' ) : esc_html__( 'OFF', 'ai-cyberguard' ); echo ''; echo '
'; echo '
'; echo '
'; echo '
'; echo '
'; // end grid // Note echo '

'; echo ' '; echo esc_html__( 'Note: AI Analysis only sends data when YOU click the "Analyze" button. It never runs automatically. All connections use HTTPS encryption.', 'ai-cyberguard' ); echo '

'; echo ''; echo '
'; // Threat Feed "Update Now" โ€” AJAX refresh of the signatures (folded in from // the former Threat Intelligence section). Bound by ID; harmless if the // button isn't rendered (Threat Feed off). ?> '; } // ========================================================================= // Login Security // ========================================================================= /** * Render login stats cards */ private function render_login_stats_cards( $stats ) { echo '
'; GuardPress_Partial_Cards::render_card( array( 'title' => __( 'Suspicious IPs', 'ai-cyberguard' ), 'value' => isset( $stats['suspicious_ips'] ) ? $stats['suspicious_ips'] : 0, 'icon' => 'warning', 'variant' => 'warn', ) ); GuardPress_Partial_Cards::render_card( array( 'title' => __( 'Temp. Blocked', 'ai-cyberguard' ), 'value' => isset( $stats['blocked_ips'] ) ? $stats['blocked_ips'] : 0, 'icon' => 'clock', 'variant' => 'danger', ) ); GuardPress_Partial_Cards::render_card( array( 'title' => __( 'Blacklisted', 'ai-cyberguard' ), 'value' => isset( $stats['blacklisted_ips'] ) ? $stats['blacklisted_ips'] : 0, 'icon' => 'dismiss', 'variant' => 'danger', ) ); GuardPress_Partial_Cards::render_card( array( 'title' => __( 'Failed Today', 'ai-cyberguard' ), 'value' => isset( $stats['failed_today'] ) ? $stats['failed_today'] : 0, 'icon' => 'chart-bar', /* translators: %d is the number of failed login attempts this week */ 'subtitle' => sprintf( __( 'This week: %d', 'ai-cyberguard' ), isset( $stats['failed_week'] ) ? $stats['failed_week'] : 0 ), ) ); echo '
'; } /** * Render login settings form */ private function render_login_settings_form( $settings ) { echo '
'; wp_nonce_field( $this->nonce_action, 'guardpress_nonce' ); echo ''; echo ''; echo '
'; echo '

' . esc_html__( 'Brute Force Protection', 'ai-cyberguard' ) . '

'; // Info box echo '
'; echo '

'; echo '๐Ÿ’ก ' . esc_html__( 'What this does:', 'ai-cyberguard' ) . ' '; echo esc_html__( 'Automatically blocks IP addresses that repeatedly fail to log in. This stops password-guessing attacks.', 'ai-cyberguard' ); echo '

'; echo '
'; // Anti-lockout safety note โ€” addresses non-technical users' biggest fear // (locking themselves out) and points to the in-page Whitelist + Rescue. echo '
'; echo '

'; echo '๐Ÿ›Ÿ ' . esc_html__( 'You can\'t lock yourself out:', 'ai-cyberguard' ) . ' '; echo esc_html__( 'Add your own IP to the Whitelist lower on this page (or use the Login Rescue page) โ€” whitelisted addresses are never blocked, no matter how many logins fail.', 'ai-cyberguard' ); echo '

'; echo '
'; echo ''; // Enable protection echo ''; // Max attempts echo ''; // Lockout duration echo ''; // Options echo ''; echo '
'; submit_button( __( 'Save Login Security Settings', 'ai-cyberguard' ), 'primary', 'submit', true ); echo '
'; } /** * Render PRO settings section * Shows all PRO features with locks for FREE users */ private function render_pro_settings_section() { // Create alias so existing code works in FREE version if ( ! class_exists( 'GuardPress_Pro_UI_Helper' ) && class_exists( 'GuardPress_Upsell' ) ) { class_alias( 'GuardPress_Upsell', 'GuardPress_Pro_UI_Helper' ); } // Check helper is available if ( ! class_exists( 'GuardPress_Pro_UI_Helper' ) ) { return; } $is_pro = GuardPress_Pro_UI_Helper::is_pro(); $pro_settings = array(); // Get PRO settings if available if ( class_exists( 'GuardPress_Pro_Settings' ) ) { $pro_settings = GuardPress_Pro_Settings::get(); } // Render styles GuardPress_Pro_UI_Helper::render_styles(); echo '
'; // Section header echo '

'; echo ' '; echo esc_html__( 'PRO Security Features', 'ai-cyberguard' ); if ( ! $is_pro ) { echo ' ๐Ÿ”’ PRO'; } echo '

'; if ( ! $is_pro ) { echo '

'; echo esc_html__( 'These advanced security features are available in the PRO version.', 'ai-cyberguard' ); echo '

'; } else { echo '

'; echo esc_html__( 'Configure each feature from its dedicated settings page. Click on any feature below to manage its settings.', 'ai-cyberguard' ); echo '

'; } // Define PRO features with their pages $pro_features = array( // === Core Security === array( 'id' => 'waf', 'title' => __( 'Advanced WAF (Real-Time)', 'ai-cyberguard' ), 'icon' => 'shield-alt', 'description' => __( 'Always-on real-time firewall โ€” upgrades the basic firewall already in FREE', 'ai-cyberguard' ), 'setting_key' => 'waf_enabled', 'page' => 'guardpress-waf', ), array( 'id' => 'country_blocking', 'title' => __( 'Country Blocking', 'ai-cyberguard' ), 'icon' => 'admin-site-alt3', 'description' => __( 'Block or allow traffic from specific countries', 'ai-cyberguard' ), 'setting_key' => 'country_block_enabled', 'page' => 'guardpress-waf', ), array( 'id' => 'two_factor', 'title' => __( 'Full 2FA (Org-Wide)', 'ai-cyberguard' ), 'icon' => 'lock', 'description' => __( 'Org-wide enforcement, per-role rules & trusted devices โ€” beyond the per-user 2FA in FREE', 'ai-cyberguard' ), 'setting_key' => 'two_factor_enabled', 'page' => 'guardpress-login-protection', ), array( 'id' => 'realtime_protection', 'title' => __( 'Real-Time File Protection', 'ai-cyberguard' ), 'icon' => 'visibility', 'description' => __( 'Monitor file changes instantly as they happen', 'ai-cyberguard' ), 'setting_key' => 'realtime_enabled', 'page' => 'guardpress-realtime', ), // === Backup & Recovery === array( 'id' => 'cloud_backup', 'title' => __( 'Cloud Backup', 'ai-cyberguard' ), 'icon' => 'cloud-upload', 'description' => __( 'Automatic backups to Google Drive, Dropbox, or S3', 'ai-cyberguard' ), 'setting_key' => 'backup_enabled', 'page' => 'guardpress-backup', ), array( 'id' => 'quarantine', 'title' => __( 'Quarantine & Auto-Restore', 'ai-cyberguard' ), 'icon' => 'trash', 'description' => __( 'Isolate suspicious files, auto-restore from baseline', 'ai-cyberguard' ), 'setting_key' => 'quarantine_enabled', 'page' => 'guardpress-quarantine', ), array( 'id' => 'time_machine', 'title' => __( 'Security Time Machine', 'ai-cyberguard' ), 'icon' => 'backup', 'description' => __( 'Browse and restore any file version from history', 'ai-cyberguard' ), 'setting_key' => 'time_machine_enabled', 'page' => 'guardpress-time-machine', ), // === Notifications === array( 'id' => 'notifications', 'title' => __( 'Instant Notifications', 'ai-cyberguard' ), 'icon' => 'smartphone', 'description' => __( 'SMS, WhatsApp, Telegram, Slack alerts', 'ai-cyberguard' ), 'setting_key' => 'notify_sms', 'page' => 'guardpress-notifications', ), array( 'id' => 'voice_alerts', 'title' => __( 'Voice Call Alerts', 'ai-cyberguard' ), 'icon' => 'phone', 'description' => __( 'Receive phone calls for critical security events', 'ai-cyberguard' ), 'setting_key' => 'voice_alerts_enabled', 'page' => 'guardpress-notifications', ), // === AI Intelligence === array( 'id' => 'ai_assistant', 'title' => __( 'AI Security Assistant', 'ai-cyberguard' ), 'icon' => 'format-chat', 'description' => __( 'Chat with AI about your security status and threats', 'ai-cyberguard' ), 'setting_key' => 'ai_assistant_enabled', 'page' => 'guardpress-ai-assistant', ), array( 'id' => 'predictive_threat', 'title' => __( 'Predictive Threat Score', 'ai-cyberguard' ), 'icon' => 'chart-area', 'description' => __( 'AI predicts potential vulnerabilities before attacks', 'ai-cyberguard' ), 'setting_key' => 'predictive_enabled', 'page' => 'guardpress-ai-intelligence', ), array( 'id' => 'login_anomaly', 'title' => __( 'Login Anomaly Intelligence', 'ai-cyberguard' ), 'icon' => 'admin-users', 'description' => __( 'Detect unusual login patterns and suspicious behavior', 'ai-cyberguard' ), 'setting_key' => 'login_anomaly_enabled', 'page' => 'guardpress-login-protection', ), array( 'id' => 'attack_replay', 'title' => __( 'Attack Replay Analysis', 'ai-cyberguard' ), 'icon' => 'controls-play', 'description' => __( 'Visualize attack timeline and understand threat vectors', 'ai-cyberguard' ), 'setting_key' => 'attack_replay_enabled', 'page' => 'guardpress-attack-replay', ), // === Unique Features === array( 'id' => 'honeypot', 'title' => __( 'Hacker Trap (Honeypots)', 'ai-cyberguard' ), 'icon' => 'warning', 'description' => __( 'Deploy decoy files to detect and trap attackers', 'ai-cyberguard' ), 'setting_key' => 'honeypot_enabled', 'page' => 'guardpress-hardening', ), array( 'id' => 'code_dna', 'title' => __( 'Code DNA Fingerprinting', 'ai-cyberguard' ), 'icon' => 'screenoptions', 'description' => __( 'Advanced code analysis beyond simple hash matching', 'ai-cyberguard' ), 'setting_key' => 'code_dna_enabled', 'page' => 'guardpress-advanced', ), array( 'id' => 'git_integration', 'title' => __( 'Git Integration', 'ai-cyberguard' ), 'icon' => 'media-code', 'description' => __( 'Compare files with Git repositories for integrity', 'ai-cyberguard' ), 'setting_key' => 'git_enabled', 'page' => 'guardpress-git', ), // === Compliance & Reports === array( 'id' => 'compliance', 'title' => __( 'Compliance Dashboard', 'ai-cyberguard' ), 'icon' => 'clipboard', 'description' => __( 'GDPR, PCI-DSS compliance reports and audit logs', 'ai-cyberguard' ), 'setting_key' => 'compliance_enabled', 'page' => 'guardpress-compliance', ), array( 'id' => 'gamification', 'title' => __( 'Security Gamification', 'ai-cyberguard' ), 'icon' => 'awards', 'description' => __( 'Achievements, streaks, leaderboard & score history', 'ai-cyberguard' ), 'setting_key' => 'gamification_pro_enabled', 'page' => 'guardpress-gamification', ), // === Monitoring === array( 'id' => 'uptime', 'title' => __( 'Uptime Monitoring', 'ai-cyberguard' ), 'icon' => 'chart-line', 'description' => __( 'Get alerted when your site goes down', 'ai-cyberguard' ), 'setting_key' => 'uptime_enabled', 'page' => 'guardpress-monitoring', ), ); // Render feature cards echo '
'; foreach ( $pro_features as $feature ) { $is_enabled = ! empty( $pro_settings[ $feature['setting_key'] ] ); $is_locked = ! $is_pro; $border_color = $is_locked ? '#e0e0e0' : ( $is_enabled ? '#22c55e' : '#f59e0b' ); $status_text = $is_locked ? __( 'Locked', 'ai-cyberguard' ) : ( $is_enabled ? __( 'Active', 'ai-cyberguard' ) : __( 'Inactive', 'ai-cyberguard' ) ); $status_color = $is_locked ? '#9ca3af' : ( $is_enabled ? '#22c55e' : '#f59e0b' ); $status_bg = $is_locked ? '#f3f4f6' : ( $is_enabled ? '#f0fdf4' : '#fffbeb' ); echo '
'; // Header row echo '
'; echo ''; echo '
'; echo '

' . esc_html( $feature['title'] ) . '

'; echo '
'; // Status badge echo '' . esc_html( $status_text ) . ''; echo '
'; // Description echo '

' . esc_html( $feature['description'] ) . '

'; // Action button if ( $is_locked ) { echo ''; echo ''; echo esc_html__( 'Unlock with PRO', 'ai-cyberguard' ); echo ''; } else { echo ''; echo ''; echo esc_html__( 'Configure', 'ai-cyberguard' ); echo ''; } echo '
'; } echo '
'; // Render upgrade modal GuardPress_Pro_UI_Helper::render_upgrade_modal(); } /** * Render a PRO settings group (kept for backward compatibility) */ private function render_pro_setting_group( $id, $title, $icon, $is_pro, $fields ) { // This function is no longer used but kept for backward compatibility return; } }