parent
81860d1851
commit
c4b906223c
|
|
@ -191,7 +191,10 @@ class Fail2BanJailModal extends ModalComponent
|
||||||
$db = $this->getDbFile();
|
$db = $this->getDbFile();
|
||||||
|
|
||||||
$q = sprintf(
|
$q = sprintf(
|
||||||
"SELECT timeofban, expiretime FROM bans WHERE jail=%s AND ip=%s ORDER BY timeofban DESC LIMIT 1",
|
"SELECT timeofban, expiretime
|
||||||
|
FROM bans
|
||||||
|
WHERE jail=%s AND ip=%s AND (expiretime=-1 OR expiretime>STRFTIME('%%s','now'))
|
||||||
|
ORDER BY timeofban DESC LIMIT 1",
|
||||||
$this->sql($jail),
|
$this->sql($jail),
|
||||||
$this->sql($ip)
|
$this->sql($ip)
|
||||||
);
|
);
|
||||||
|
|
@ -206,9 +209,21 @@ class Fail2BanJailModal extends ModalComponent
|
||||||
|
|
||||||
private function isStillBanned(string $jail, string $ip): bool
|
private function isStillBanned(string $jail, string $ip): bool
|
||||||
{
|
{
|
||||||
[, $out] = $this->f2b('get '.escapeshellarg($jail).' banip '.escapeshellarg($ip));
|
// 1) Direkt: banip
|
||||||
// gibt in der Regel "1" (banned) oder nichts/0 zurück
|
[, $out1] = $this->f2b('get '.escapeshellarg($jail).' banip '.escapeshellarg($ip));
|
||||||
return (bool)preg_match('/\b1\b/', $out);
|
if (preg_match('/\b1\b/', $out1)) return true;
|
||||||
|
|
||||||
|
// 2) Liste: banlist (Rohliste, whitespace-separiert)
|
||||||
|
[, $out2] = $this->f2b('get '.escapeshellarg($jail).' banlist');
|
||||||
|
if ($out2 !== '') {
|
||||||
|
$list = array_filter(array_map('trim', preg_split('/\s+/', trim($out2))));
|
||||||
|
if (in_array($ip, $list, true)) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3) Notfall: status-Parsing
|
||||||
|
[, $out3] = $this->f2b('status '.escapeshellarg($jail));
|
||||||
|
$ipList = $this->firstMatch('/Banned IP list:\s*(.+)$/mi', $out3) ?: '';
|
||||||
|
return $ipList !== '' && preg_match('/(^|\s)'.preg_quote($ip,'/').'(\s|$)/', $ipList) === 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getBantime(string $jail): int
|
private function getBantime(string $jail): int
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue