feat: add Central API clients, bot rate limiting, and admin API UI
- Add ITK_HP_API and ITK_Bot_API static classes with queue/flush/cron - Add WP-Cron (5 min) + shutdown flush for both API queues - Bot Blocker and Honeypot now queue events to their respective APIs - Admin: Bot Blocker tab gains Central Bot API settings panel (enable, URL, token, test connection, flush queue, historical sync) - Admin: Honeypot tab gains Central Honeypot API settings panel - Admin JS: AJAX handlers for Test Connection and Flush Now buttons - Admin CSS: API card styles (status badge, notices, footer controls) - Add .gitignore (excludes bot-api/ which lives in CloudHost/bot-api) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -124,7 +124,7 @@ class ITK_Bot_Blocker {
|
||||
if ($count >= $limit) {
|
||||
// Over the limit – log and send 429.
|
||||
if (!empty($options['log_blocked_attempts'])) {
|
||||
ITK_Database::log_bot([
|
||||
$event = [
|
||||
'ip' => $ip,
|
||||
'ua' => $ua,
|
||||
'referrer' => '',
|
||||
@@ -132,7 +132,9 @@ class ITK_Bot_Blocker {
|
||||
'bot_type' => $name,
|
||||
'reason' => "Rate limited: {$count}/{$limit} req/min",
|
||||
'action' => 'rate_limited',
|
||||
]);
|
||||
];
|
||||
ITK_Database::log_bot($event);
|
||||
ITK_Bot_API::queue($event);
|
||||
}
|
||||
status_header(429);
|
||||
header('Retry-After: 60');
|
||||
@@ -157,7 +159,7 @@ class ITK_Bot_Blocker {
|
||||
array $options
|
||||
): void {
|
||||
if (!empty($options['log_blocked_attempts'])) {
|
||||
ITK_Database::log_bot([
|
||||
$event = [
|
||||
'ip' => $ip,
|
||||
'ua' => $ua,
|
||||
'referrer' => $referrer,
|
||||
@@ -165,7 +167,9 @@ class ITK_Bot_Blocker {
|
||||
'bot_type' => $bot_type,
|
||||
'reason' => $reason,
|
||||
'action' => 'blocked',
|
||||
]);
|
||||
];
|
||||
ITK_Database::log_bot($event);
|
||||
ITK_Bot_API::queue($event);
|
||||
}
|
||||
|
||||
$code = $options['response_code'] ?? '403';
|
||||
|
||||
Reference in New Issue
Block a user