$matches[1],
'message' => $matches[2]
];
}
}
return array_reverse($entries); // Most recent first
}
// Get log data
$contactSubmissions = parseLogFile('../logs/contact-submissions.log');
$contactErrors = parseLogFile('../logs/contact-errors.log');
$blockedIPs = file_exists('../logs/blocked-ips.txt') ? file('../logs/blocked-ips.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) : [];
// Analyze spam patterns
$spamPatterns = [
'recaptcha_failures' => 0,
'direct_post_attempts' => 0,
'rate_limit_hits' => 0,
'low_interaction_scores' => 0,
'blocked_ips_count' => count($blockedIPs),
'hourly_distribution' => array_fill(0, 24, 0),
'top_ips' => []
];
$ipCounts = [];
foreach ($contactErrors as $error) {
if (strpos($error['message'], 'RECAPTCHA FAILED') !== false) {
$spamPatterns['recaptcha_failures']++;
}
if (strpos($error['message'], 'DIRECT POST') !== false) {
$spamPatterns['direct_post_attempts']++;
}
if (strpos($error['message'], 'Too many requests') !== false) {
$spamPatterns['rate_limit_hits']++;
}
if (strpos($error['message'], 'LOW INTERACTION SCORE') !== false) {
$spamPatterns['low_interaction_scores']++;
}
// Extract IP addresses
if (preg_match('/from ([0-9.]+)/', $error['message'], $matches)) {
$ip = $matches[1];
$ipCounts[$ip] = ($ipCounts[$ip] ?? 0) + 1;
}
// Track hourly distribution
$hour = (int)date('G', strtotime($error['timestamp']));
$spamPatterns['hourly_distribution'][$hour]++;
}
// Get top spam IPs
arsort($ipCounts);
$spamPatterns['top_ips'] = array_slice($ipCounts, 0, 10, true);
?>
Spam Analysis Dashboard - UK Data Services
Spam Analysis Dashboard
Hourly Spam Distribution
0 ? ($count / $maxHourly * 100) : 0;
?>
Top Spam Source IPs
| IP Address |
Attempts |
Status |
$count): ?>
|
|
Blocked' : 'Active';
?>
|
Recent Error Log (Last 20)
Recent Successful Submissions (Last 10)