Migrations).')); acp_redirect('migrations'); } if ($_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['do'] ?? '') === 'clear_ip') { $ip = substr(trim((string)($_POST['ip'] ?? '')), 0, 45); if ($ip !== '') { db()->execute("DELETE FROM `znote_login_attempts` WHERE `ip` = ? AND `success` = 0;", [$ip]); acp_log('login_guard.clear_ip', $ip); acp_flash_success(t_default('acp.lattempt.cleared', 'Cleared - that IP can log in again immediately.')); } acp_redirect('login_attempts'); } $cfg = znote_login_guard_config(); $lockedRows = db()->fetchAll(" SELECT `ip`, COUNT(*) AS `failures`, MAX(`created_at`) AS `last_failure` FROM `znote_login_attempts` WHERE `success` = 0 AND `created_at` >= ? GROUP BY `ip` HAVING `failures` >= ? ORDER BY `last_failure` DESC; ", [time() - $cfg['window_seconds'], $cfg['threshold']]); $lockedRows = is_array($lockedRows) ? $lockedRows : array(); $recent = db()->fetchAll(" SELECT `ip`, `username`, `success`, `created_at` FROM `znote_login_attempts` ORDER BY `id` DESC LIMIT 100; "); $recent = is_array($recent) ? $recent : array(); ?>
0 ? 'red' : 'green'); acp_stat(t_default('acp.lattempt.stat_guard', 'Protection'), $cfg['enabled'] ? t_default('acp.lattempt.on', 'On') : t_default('acp.lattempt.off', 'Off'), 'fa-shield', acp_url('settings'), $cfg['enabled'] ? 'green' : 'grey'); ?>