';
echo '';
echo '
' . esc_html__( 'No changes found. Your files match the baseline.', 'ai-cyberguard' ) . '
';
echo '';
return;
}
// Tip box
echo '' . esc_html__( 'Tip: If a change is legitimate (e.g., a plugin update), click Ignore to exclude it from future scans.', 'ai-cyberguard' ) . '
';
// Table wrapper
echo '';
// Table header with filter/copy tools
echo '';
// Table
echo '
';
echo '| ' . esc_html__( 'File Path', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Status', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Actions', 'ai-cyberguard' ) . ' | ';
echo '
';
foreach ( $details as $path => $row ) {
self::render_scan_row( $path, $row, $nonce_action );
}
echo '
';
}
/**
* Render a single scan result row with Security Explainer
*/
private static function render_scan_row( $path, $row, $nonce_action ) {
$status = isset( $row['status'] ) ? sanitize_text_field( $row['status'] ) : '';
$note = isset( $row['note'] ) ? sanitize_text_field( $row['note'] ) : '';
$bh = isset( $row['baseline_hash'] ) ? esc_html( $row['baseline_hash'] ) : '';
$ch = isset( $row['current_hash'] ) ? esc_html( $row['current_hash'] ) : '';
$mt = isset( $row['mtime'] ) ? wp_date( 'Y-m-d H:i', intval( $row['mtime'] ) ) : '';
// Get threat level for this file
$threat = self::get_threat_level( $path, $status );
// Get file extension
$extension = strtolower( pathinfo( $path, PATHINFO_EXTENSION ) );
// M-109-03 (audit 2026-06-17): derive from the scanner's single PHP-family
// source (incl. .inc) plus js, so the diff-table View Code / Analyze button
// and content-pattern escalation cover EVERY variant the scanner scans.
$gp_scannable_exts = class_exists( 'GuardPress_Malware_Scanner' )
? array_merge( GuardPress_Malware_Scanner::php_family_exts(), array( 'js' ) )
: array( 'php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar', 'pht', 'phps', 'inc', 'js' );
$is_scannable = in_array( $extension, $gp_scannable_exts, true );
// Run pattern detection for PHP/JS files that exist
$pattern_scan = null;
if ( $is_scannable && $status !== 'deleted' && class_exists( 'GuardPress_Pattern_Detector' ) ) {
$full_path = ABSPATH . ltrim( $path, '/' );
if ( file_exists( $full_path ) ) {
$pattern_scan = GuardPress_Pattern_Detector::scan_file( $full_path );
}
}
// Upgrade threat level based on pattern scan
if ( $pattern_scan && $pattern_scan['risk_score'] > 0 ) {
$pattern_level = GuardPress_Pattern_Detector::get_risk_level( $pattern_scan['risk_score'] );
$level_priority = array( 'safe' => 0, 'low' => 1, 'medium' => 2, 'high' => 3, 'critical' => 4 );
if ( isset( $level_priority[ $pattern_level ] ) && isset( $level_priority[ $threat['level'] ] ) ) {
if ( $level_priority[ $pattern_level ] > $level_priority[ $threat['level'] ] ) {
$threat['level'] = $pattern_level; // Keep critical level for "AI Required!" badge
/* translators: %s is the pattern scan summary */
$threat['reason'] = sprintf( __( 'Pattern scan: %s', 'ai-cyberguard' ), $pattern_scan['summary'] );
}
}
}
$more = '';
if ( $bh || $ch || $mt ) {
$more = '' . esc_html__( 'File Info', 'ai-cyberguard' ) . '
';
$more .= 'Baseline: ' . ( $bh ?: 'N/A' ) . '
';
$more .= 'Current: ' . ( $ch ?: 'N/A' ) . '
';
$more .= 'Modified: ' . esc_html( $mt ?: 'N/A' ) . '
';
}
echo '';
echo '';
echo '' . esc_html( $path ) . '';
// Show threat badge
echo ' ' . self::get_threat_badge_html( $threat ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML built and escaped inside get_threat_badge_html()
// Show pattern scan results in expandable section
if ( $pattern_scan && ! empty( $pattern_scan['findings'] ) ) {
echo self::render_security_explainer( $pattern_scan ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML built and escaped inside render_security_explainer()
}
if ( $note ) {
echo ' ' . esc_html( $note ) . '';
}
echo ' | ';
echo '' . esc_html( ucfirst( $status ) ) . ' | ';
echo '';
// Action buttons container
echo ' ';
// File info details
echo $more; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $more is HTML built with esc_html() above
// View Code button (for existing files)
if ( $status !== 'deleted' && $is_scannable ) {
echo '';
}
// Analyze with AI button
if ( $is_scannable && $status !== 'deleted' ) {
echo '';
}
// Ignore form
echo '';
echo ' ';
echo ' |
';
}
/**
* Render Security Explainer - shows WHY a file is suspicious
*/
private static function render_security_explainer( $pattern_scan ) {
$html = '';
$html .= '';
$html .= '❓ ' . esc_html__( 'Why is this suspicious?', 'ai-cyberguard' );
$html .= ' Score: ' . esc_html( $pattern_scan['risk_score'] ) . '';
$html .= '
';
$html .= '';
// Show dangerous combinations first (most important)
if ( ! empty( $pattern_scan['combos'] ) ) {
$html .= '
';
$html .= '
⚠️ ' . esc_html__( 'DANGEROUS COMBINATIONS DETECTED:', 'ai-cyberguard' ) . '
';
foreach ( $pattern_scan['combos'] as $combo ) {
$html .= '
';
$html .= '
' . esc_html( $combo['title'] ) . '
';
$html .= '
' . esc_html( $combo['explanation'] ) . '
';
$html .= '
';
$html .= esc_html__( 'Patterns:', 'ai-cyberguard' ) . ' ' . implode( ' + ', array_map( 'esc_html', $combo['patterns'] ) ) . '';
$html .= ' (+' . esc_html( $combo['bonus_score'] ) . ' ' . esc_html__( 'risk points', 'ai-cyberguard' ) . ')';
$html .= '
';
}
$html .= '
';
}
// Group findings by category
$categories = array();
foreach ( $pattern_scan['findings'] as $finding ) {
$cat = $finding['category'];
if ( ! isset( $categories[ $cat ] ) ) {
$categories[ $cat ] = array();
}
$categories[ $cat ][] = $finding;
}
$category_labels = array(
'code_execution' => array( 'icon' => '💀', 'label' => __( 'Code Execution', 'ai-cyberguard' ), 'color' => '#dc2626' ),
'system_access' => array( 'icon' => '🔓', 'label' => __( 'System Access', 'ai-cyberguard' ), 'color' => '#dc2626' ),
'obfuscation' => array( 'icon' => '🎭', 'label' => __( 'Obfuscation/Encoding', 'ai-cyberguard' ), 'color' => '#d97706' ),
'file_operation' => array( 'icon' => '📁', 'label' => __( 'File Operations', 'ai-cyberguard' ), 'color' => '#d97706' ),
'network' => array( 'icon' => '🌐', 'label' => __( 'Network Connections', 'ai-cyberguard' ), 'color' => '#d97706' ),
'user_input' => array( 'icon' => '📥', 'label' => __( 'User Input Handling', 'ai-cyberguard' ), 'color' => '#0891b2' ),
'wordpress' => array( 'icon' => '🔧', 'label' => __( 'WordPress Functions', 'ai-cyberguard' ), 'color' => '#0891b2' ),
'suspicious_name' => array( 'icon' => '📛', 'label' => __( 'Suspicious Naming', 'ai-cyberguard' ), 'color' => '#d97706' ),
'location' => array( 'icon' => '📍', 'label' => __( 'Suspicious Location', 'ai-cyberguard' ), 'color' => '#dc2626' ),
);
foreach ( $categories as $cat => $findings ) {
$cat_info = isset( $category_labels[ $cat ] ) ? $category_labels[ $cat ] : array( 'icon' => '⚡', 'label' => ucfirst( $cat ), 'color' => '#6b7280' );
$html .= '
';
$html .= '
';
$html .= $cat_info['icon'] . ' ' . esc_html( $cat_info['label'] );
$html .= '
';
foreach ( $findings as $finding ) {
$severity_colors = array(
'critical' => '#dc2626',
'high' => '#ea580c',
'medium' => '#d97706',
'low' => '#0891b2',
);
$sev_color = isset( $severity_colors[ $finding['severity'] ] ) ? $severity_colors[ $finding['severity'] ] : '#6b7280';
$html .= '
';
$html .= '
';
$html .= '' . esc_html( $finding['pattern'] ) . '';
$html .= '' . esc_html( strtoupper( $finding['severity'] ) ) . '';
$html .= '
';
$html .= '
' . esc_html( $finding['title'] ) . '
';
$html .= '
' . esc_html( $finding['explanation'] ) . '
';
$html .= '
';
}
$html .= '
';
}
// Recommendation
if ( ! empty( $pattern_scan['recommendation'] ) ) {
$html .= '
';
$html .= '
💡 ' . esc_html__( 'Recommendation:', 'ai-cyberguard' ) . '
';
$html .= '
' . esc_html( $pattern_scan['recommendation'] ) . '
';
$html .= '
';
}
$html .= '
';
return $html;
}
/**
* Get threat level for a file (public static wrapper)
*
* @param string $path File path
* @param string $status File status (changed, new, deleted)
* @return array ['level' => string, 'reason' => string]
*/
public static function get_threat_level_static( $path, $status ) {
return self::get_threat_level( $path, $status );
}
/**
* Get threat level for a file
*
* @param string $path File path
* @param string $status File status (changed, new, deleted)
* @return array ['level' => string, 'reason' => string]
*/
private static function get_threat_level( $path, $status ) {
// Deleted files are not a threat
if ( $status === 'deleted' ) {
return array(
'level' => 'info',
'reason' => __( 'File was deleted', 'ai-cyberguard' ),
);
}
$filename = basename( $path );
$extension = strtolower( pathinfo( $path, PATHINFO_EXTENSION ) );
$path_lower = strtolower( $path );
// Non-executable files are safe
$safe_extensions = array( 'txt', 'md', 'css', 'jpg', 'jpeg', 'png', 'gif', 'svg', 'webp', 'ico', 'woff', 'woff2', 'ttf', 'eot', 'map', 'json', 'xml', 'html', 'htm' );
if ( in_array( $extension, $safe_extensions ) ) {
return array(
'level' => 'safe',
'reason' => __( 'Non-executable file type', 'ai-cyberguard' ),
);
}
// Check for HIGH threat indicators
// Names encoded to prevent false positive detection by other scanners
$high_threat_names = array_merge(
array( 'shell', 'backdoor', 'hack', 'exploit', 'bypass', 'cmd', 'eval', 'webshell', 'mailer', 'spammer', 'proxy', 'tunnel', 'rootkit', 'trojan' ),
array_map( 'base64_decode', array(
'Yzk5', 'cjU3', 'd3Nv', 'YjM3NGs=', 'cGhwc3B5', 'YWxmYQ==', 'bGVhZm1haWxlcg=='
))
);
foreach ( $high_threat_names as $name ) {
if ( stripos( $filename, $name ) !== false ) {
return array(
'level' => 'high',
/* translators: %s is the suspicious substring found in the file name */
'reason' => sprintf( __( 'Suspicious filename contains "%s"', 'ai-cyberguard' ), $name ),
);
}
}
// Hidden PHP files
if ( preg_match( '/^\..*\.php$/i', $filename ) ) {
return array(
'level' => 'high',
'reason' => __( 'Hidden PHP file (starts with dot)', 'ai-cyberguard' ),
);
}
// Random-looking PHP filenames (e.g. "a8f3k9x2.php").
// FIX (false-positive logic, 2026-06-15): the old check flagged ANY 8+ char
// single-token name as "possible malware", which false-positived on extremely
// common legitimate files — functions.php, settings.php, customizer.php,
// dashboard.php, shortcodes.php, template.php, comments.php… Tighten it to
// names that actually look machine-generated: a single alphanumeric token
// that also mixes letters+digits, OR has no vowels at all, OR is long with
// almost no vowels. Pronounceable real-word filenames are no longer flagged
// here; a malicious file hiding behind a word-like name is still caught by the
// content Pattern Detector and the Malware Scan (the content authorities).
$stem = strtolower( preg_replace( '/\.php$/i', '', $filename ) );
if ( preg_match( '/^[a-z0-9]{8,}$/', $stem )
&& ! preg_match( '/^(index|class|admin|ajax|cron|widget)/', $stem ) ) {
$has_digit = (bool) preg_match( '/[0-9]/', $stem );
$has_alpha = (bool) preg_match( '/[a-z]/', $stem );
$vowels = preg_match_all( '/[aeiou]/', $stem );
$looks_random = ( $has_digit && $has_alpha ) // mixed letters + digits
|| ( 0 === $vowels ) // no vowels at all
|| ( strlen( $stem ) >= 10 && $vowels <= 1 ); // long + almost no vowels
if ( $looks_random ) {
return array(
'level' => 'high',
'reason' => __( 'Random filename pattern (possible malware)', 'ai-cyberguard' ),
);
}
}
// PHP executable extensions (M-109-03: single source, incl. .inc)
$php_extensions = class_exists( 'GuardPress_Malware_Scanner' )
? GuardPress_Malware_Scanner::php_family_exts()
: array( 'php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar', 'pht', 'phps', 'inc' );
$is_php = in_array( $extension, $php_extensions, true );
// PHP in genuinely-suspicious directories (uploads / cache / tmp) is HIGH
// regardless of new-vs-changed — there is NO legitimate reason for PHP to live
// there at all, so a hit is suspicious whether the file is new or modified.
if ( $is_php ) {
$suspicious_dirs = array(
'/uploads/' => __( 'PHP in uploads folder (very suspicious)', 'ai-cyberguard' ),
'/cache/' => __( 'PHP in cache folder (suspicious)', 'ai-cyberguard' ),
'/tmp/' => __( 'PHP in temp folder (suspicious)', 'ai-cyberguard' ),
'/temp/' => __( 'PHP in temp folder (suspicious)', 'ai-cyberguard' ),
);
foreach ( $suspicious_dirs as $dir => $reason ) {
if ( strpos( $path_lower, $dir ) !== false ) {
return array(
'level' => 'high',
'reason' => $reason,
);
}
}
}
// NEW PHP in WordPress core directories (wp-admin / wp-includes) is
// overwhelmingly a legitimate core/plugin update (or, on a fresh install,
// simply "not in baseline yet"). FIX (false-positive logic, 2026-06-15): never
// HIGH on location alone — the Malware Scan (signatures + official
// api.wordpress.org core checksums) is the authority for a malicious core file,
// and the per-row content Pattern Detector escalates this when the file's
// CONTENT is malicious. (Random/hidden/malware-named files already returned HIGH
// above; a CHANGED core file is handled as a low "review" further down.)
if ( $status === 'new' && $is_php
&& ( strpos( $path_lower, '/wp-includes/' ) !== false || strpos( $path_lower, '/wp-admin/' ) !== false ) ) {
return array(
'level' => 'low',
'reason' => __( 'New file in WordPress core — likely a WordPress/plugin update. Run a Malware Scan to verify.', 'ai-cyberguard' ),
);
}
// CHANGED files. FIX (false-positive logic, 2026-06-15): a file differing from
// the baseline is the EXPECTED result of a WordPress / plugin / theme update,
// so the integrity scan reports it for transparency but does NOT treat it as a
// high/medium threat on its own — that would alarm users after every legitimate
// update (core updates change dozens of core files). The per-row content
// Pattern Detector (render_scan_row) still escalates to high/critical when a
// changed file's CONTENT is malicious, and the Malware Scan + official wp.org
// core checksums are the authority for tampered core files. wp-config.php is the
// one sensitive exception: it holds the site's secrets and does NOT change during
// normal updates, so a change there earns a deliberate medium "review".
if ( $status === 'changed' && $filename === 'wp-config.php' ) {
return array(
'level' => 'medium',
'reason' => __( 'wp-config.php changed — it holds your site secrets, so review it. Run a Malware Scan to verify.', 'ai-cyberguard' ),
);
}
// NEW PHP files that reach here are NOT in uploads/cache/tmp (already HIGH
// above) and NOT in wp-admin/wp-includes (already a low "review" above) — they
// are in plugins/themes, wp-content, or the site root. A new file is the
// EXPECTED result of installing or updating a plugin/theme, so it is a low
// "review" item — never high/medium on location alone. Malicious CONTENT is
// still caught and escalated by the per-row Pattern Detector and the Malware
// Scan; random/hidden/malware-named files already returned HIGH at the top.
if ( $status === 'new' && $is_php ) {
return array(
'level' => 'low',
'reason' => __( 'New file detected — likely a WordPress/plugin/theme update. Run a Malware Scan to verify.', 'ai-cyberguard' ),
);
}
// Changed PHP files - check location
if ( $status === 'changed' && $is_php ) {
// Changed PHP in plugin/theme - LOW (normal for updates)
if ( strpos( $path_lower, '/wp-content/plugins/' ) !== false || strpos( $path_lower, '/wp-content/themes/' ) !== false ) {
return array(
'level' => 'low',
'reason' => __( 'PHP file modified (likely from update)', 'ai-cyberguard' ),
);
}
// Changed PHP elsewhere - already handled above for core files
return array(
'level' => 'low',
'reason' => __( 'PHP file modified', 'ai-cyberguard' ),
);
}
// JS files - can contain malicious code too
if ( $extension === 'js' ) {
if ( $status === 'new' ) {
return array(
'level' => 'low',
'reason' => __( 'New JavaScript file', 'ai-cyberguard' ),
);
}
if ( $status === 'changed' ) {
return array(
'level' => 'low',
'reason' => __( 'JavaScript file modified', 'ai-cyberguard' ),
);
}
return array(
'level' => 'safe',
'reason' => __( 'JavaScript file', 'ai-cyberguard' ),
);
}
// Default - safe
return array(
'level' => 'safe',
'reason' => __( 'No suspicious indicators', 'ai-cyberguard' ),
);
}
/**
* Get HTML for threat level badge
*
* @param array $threat Threat info array
* @return string HTML
*/
private static function get_threat_badge_html( $threat ) {
$level = $threat['level'];
$reason = $threat['reason'];
$badges = array(
'critical' => array(
'color' => '#991b1b',
'bg' => '#fecaca',
'icon' => '🚨',
'label' => __( 'CRITICAL', 'ai-cyberguard' ),
'ai_badge' => array(
'label' => __( 'AI Required!', 'ai-cyberguard' ),
'bg' => '#dc2626',
'icon' => '🚨',
),
),
'high' => array(
'color' => '#dc2626',
'bg' => '#fee2e2',
'icon' => '🔴',
'label' => __( 'HIGH RISK', 'ai-cyberguard' ),
'ai_badge' => array(
'label' => __( 'AI Recommended', 'ai-cyberguard' ),
'bg' => 'linear-gradient(135deg, #6366f1, #8b5cf6)',
'icon' => '🤖',
),
),
'medium' => array(
'color' => '#d97706',
'bg' => '#fef3c7',
'icon' => '🟠',
'label' => __( 'MEDIUM', 'ai-cyberguard' ),
'ai_badge' => array(
'label' => __( 'AI Suggested', 'ai-cyberguard' ),
'bg' => 'linear-gradient(135deg, #8b5cf6, #a78bfa)',
'icon' => '🤖',
),
),
'low' => array(
'color' => '#0891b2',
'bg' => '#cffafe',
'icon' => '🟡',
'label' => __( 'LOW', 'ai-cyberguard' ),
'ai_badge' => array(
'label' => __( 'AI Optional', 'ai-cyberguard' ),
'bg' => '#6b7280',
'icon' => '💡',
),
),
'safe' => array(
'color' => '#16a34a',
'bg' => '#dcfce7',
'icon' => '🟢',
'label' => __( 'SAFE', 'ai-cyberguard' ),
'ai_badge' => array(
'label' => __( 'Skip AI', 'ai-cyberguard' ),
'bg' => '#d1d5db',
'icon' => '✓',
'text_color' => '#4b5563',
),
),
'info' => array(
'color' => '#6b7280',
'bg' => '#f3f4f6',
'icon' => 'ℹ️',
'label' => __( 'INFO', 'ai-cyberguard' ),
'ai_badge' => null,
),
);
$b = isset( $badges[ $level ] ) ? $badges[ $level ] : $badges['info'];
$html = '';
$html .= '' . $b['icon'] . ' ' . esc_html( $b['label'] );
$html .= '';
// Add AI recommendation badge based on threat level
if ( isset( $b['ai_badge'] ) && $b['ai_badge'] ) {
$ai = $b['ai_badge'];
$text_color = isset( $ai['text_color'] ) ? $ai['text_color'] : '#fff';
$html .= ' ';
$html .= '' . $ai['icon'] . ' ' . esc_html( $ai['label'] );
$html .= '';
}
// Add reason as small text
$html .= '
' . esc_html( $reason ) . '';
return $html;
}
/**
* Render blocked IPs table
*/
public static function render_blocked_ips( $blocked_ips, $nonce_action ) {
echo '';
echo '
' . esc_html__( 'Currently Blocked IPs', 'ai-cyberguard' ) . '
';
if ( empty( $blocked_ips ) ) {
echo '
' . esc_html__( 'No IPs are currently blocked.', 'ai-cyberguard' ) . '
';
echo '
';
return;
}
$total_count = count( $blocked_ips );
// Toolbar with bulk actions and pagination — mirrors Suspicious Activity toolbar
echo '';
echo '';
// Hidden form for bulk actions
echo '';
echo '';
// JavaScript for table functionality — mirrors the Suspicious Activity JS
?>
';
echo '';
echo ' ' . esc_html__( 'Recent Login Activity', 'ai-cyberguard' ) . '';
echo '';
echo '
';
echo '';
echo '| ' . esc_html__( 'Time', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'IP Address', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Username', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Status', 'ai-cyberguard' ) . ' | ';
echo '
';
foreach ( $log as $entry ) {
$status_class = $entry['status'] === 'success' ? 'gp-new' : 'gp-deleted';
echo '';
echo '| ' . esc_html( wp_date( 'M j, H:i:s', $entry['time'] ) ) . ' | ';
echo '' . esc_html( $entry['ip'] ) . ' | ';
echo '' . esc_html( $entry['username'] ) . ' | ';
echo '' . esc_html( ucfirst( $entry['status'] ) ) . ' | ';
echo '
';
}
echo '
';
// Add clear button JS
$nonce = wp_create_nonce( 'guardpress_ajax' );
echo '';
echo '';
}
/**
* Render suspicious IPs table (failed attempts, not yet blocked)
*/
public static function render_suspicious_ips( $suspicious, $nonce_action ) {
echo '';
echo '
' . esc_html__( 'Suspicious Activity', 'ai-cyberguard' ) . '
';
echo '
' . esc_html__( 'IPs with failed login attempts that have not yet triggered automatic lockout.', 'ai-cyberguard' ) . '
';
if ( empty( $suspicious ) ) {
echo '
' . esc_html__( 'No suspicious activity detected.', 'ai-cyberguard' ) . '
';
echo '
';
return;
}
$total_count = count( $suspicious );
// Toolbar with bulk actions and pagination
echo '';
echo '';
echo ' | ';
echo '' . esc_html__( 'IP Address', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Attempts', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Last Try', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Usernames Tried', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Actions', 'ai-cyberguard' ) . ' | ';
echo '
';
$row_index = 0;
foreach ( $suspicious as $ip => $data ) {
$attempts_display = sprintf( '%d/%d', $data['count'], $data['max_attempts'] );
$progress_percent = min( 100, ( $data['count'] / $data['max_attempts'] ) * 100 );
$progress_color = $progress_percent >= 80 ? '#d63638' : ( $progress_percent >= 50 ? '#dba617' : '#72aee6' );
$time_ago = human_time_diff( $data['last_time'], time() ) . ' ' . __( 'ago', 'ai-cyberguard' );
$row_class = $row_index >= 10 ? 'gp-suspicious-row gp-hidden-row' : 'gp-suspicious-row';
echo '';
echo ' | ';
echo '' . esc_html( $ip ) . ' | ';
echo '';
echo '';
echo ' ' . esc_html( $attempts_display ) . '';
echo ' | ';
echo '' . esc_html( $time_ago ) . ' | ';
echo '' . esc_html( implode( ', ', array_slice( $data['usernames'], -3 ) ) ) . ' | ';
echo '';
// Block temporarily button with spinner
echo '';
// Add to blacklist button with spinner
echo '';
// Clear button with spinner
echo '';
echo ' |
';
$row_index++;
}
echo '
';
// Hidden form for bulk actions
echo '';
echo '';
// JavaScript for table functionality
?>
';
echo ' ' . esc_html__( 'Permanent Blacklist', 'ai-cyberguard' ) . '
';
echo '' . esc_html__( 'IPs on this list are permanently blocked from logging in.', 'ai-cyberguard' ) . '
';
// Add form
echo '';
if ( empty( $blacklist ) ) {
echo '' . esc_html__( 'No IPs on blacklist.', 'ai-cyberguard' ) . '
';
echo '';
return;
}
echo '';
echo '| ' . esc_html__( 'IP Address', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Added', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Reason', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Action', 'ai-cyberguard' ) . ' | ';
echo '
';
foreach ( $blacklist as $ip => $data ) {
$is_current = ( $ip === $current_ip );
echo '';
echo '' . esc_html( $ip ) . '';
if ( $is_current ) {
echo ' ' . esc_html__( 'Your IP!', 'ai-cyberguard' ) . '';
}
echo ' | ';
echo '' . esc_html( wp_date( 'M j, Y H:i', $data['added_at'] ) ) . ' | ';
echo '' . esc_html( ucfirst( $data['reason'] ) ) . ' | ';
echo '';
echo ' |
';
}
echo '
';
}
/**
* Render IP Whitelist table (always allowed)
*/
public static function render_whitelist( $whitelist, $nonce_action, $current_ip ) {
echo '';
echo '
' . esc_html__( 'IP Whitelist', 'ai-cyberguard' ) . '
';
echo '
' . esc_html__( 'IPs on this list are never blocked, even after failed attempts.', 'ai-cyberguard' ) . '
';
// Current IP info
$is_whitelisted = isset( $whitelist[ $current_ip ] );
echo '
';
echo '
' . esc_html__( 'Your current IP:', 'ai-cyberguard' ) . ' ' . esc_html( $current_ip ) . '';
if ( $is_whitelisted ) {
echo ' ' . esc_html__( 'Whitelisted', 'ai-cyberguard' ) . '';
}
echo '
';
if ( ! $is_whitelisted ) {
echo '
';
}
echo '
';
// Add form
echo '
';
if ( empty( $whitelist ) ) {
echo '
' . esc_html__( 'No IPs on whitelist.', 'ai-cyberguard' ) . '
';
echo '
';
return;
}
echo '';
echo '| ' . esc_html__( 'IP Address', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Label', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Added', 'ai-cyberguard' ) . ' | ';
echo '' . esc_html__( 'Action', 'ai-cyberguard' ) . ' | ';
echo '
';
foreach ( $whitelist as $ip => $data ) {
$is_current = ( $ip === $current_ip );
echo '';
echo '' . esc_html( $ip ) . '';
if ( $is_current ) {
echo ' ' . esc_html__( 'You', 'ai-cyberguard' ) . '';
}
echo ' | ';
echo '' . esc_html( $data['label'] ?: '—' ) . ' | ';
echo '' . esc_html( wp_date( 'M j, Y H:i', $data['added_at'] ) ) . ' | ';
echo '';
echo ' |
';
}
echo '
';
}
/**
* Render ignored files list
*/
public static function render_ignored_files( $ignored, $nonce_action ) {
echo ' ' . esc_html__( 'Ignored Files', 'ai-cyberguard' ) . '
';
if ( empty( $ignored ) ) {
echo '' . esc_html__( 'No ignored files yet.', 'ai-cyberguard' ) . '
';
return;
}
$ignored_count = count( $ignored );
echo '';
echo '
';
echo '
';
echo '
';
foreach ( $ignored as $path => $hash ) {
// Display the file path (key), not the hash (value)
echo '' . esc_html( $path ) . ' ';
echo ' ';
}
echo '
';
}
}