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');
?>
= t_default('acp.lattempt.locked_title', 'Currently locked out') ?>
| = t_default('acp.lattempt.col_ip', 'IP') ?> |
= t_default('acp.lattempt.col_failures', 'Failures') ?> |
= t_default('acp.lattempt.col_last', 'Last attempt') ?> |
|
= h((string)$row['ip']) ?> |
= (int)$row['failures'] ?> |
= h(getClock((int)$row['last_failure'], true)) ?> |
|
= t_default('acp.lattempt.recent_title', 'Last 100 attempts') ?>
| = t_default('acp.lattempt.col_when', 'When') ?> |
= t_default('acp.lattempt.col_ip', 'IP') ?> |
= t_default('acp.lattempt.col_username', 'Username tried') ?> |
= t_default('acp.lattempt.col_result', 'Result') ?> |
| = h(getClock((int)$row['created_at'], true)) ?> |
= h((string)$row['ip']) ?> |
= h((string)$row['username']) ?> |
= $row['success'] ? t_default('acp.lattempt.success', 'Success') : t_default('acp.lattempt.failed', 'Failed') ?>
|