Fix: Mailbox Stats über Dovecot mit config/mailpool.php

main v1.0.115
boban 2025-10-31 03:18:53 +01:00
parent 81860d1851
commit c4b906223c
1 changed files with 21 additions and 6 deletions

View File

@ -74,7 +74,7 @@ class Fail2BanJailModal extends ModalComponent
$this->rows = $rows;
}
/** ROBUST: findet Binaries automatisch */
private function bin(string $name): string
{
@ -191,7 +191,10 @@ class Fail2BanJailModal extends ModalComponent
$db = $this->getDbFile();
$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($ip)
);
@ -203,12 +206,24 @@ class Fail2BanJailModal extends ModalComponent
[$timeofban, $expire] = array_map('intval', explode('|', $out)) + [null, null];
return ['banned_at' => $timeofban ?: null, 'expire' => $expire ?? null];
}
private function isStillBanned(string $jail, string $ip): bool
{
[, $out] = $this->f2b('get '.escapeshellarg($jail).' banip '.escapeshellarg($ip));
// gibt in der Regel "1" (banned) oder nichts/0 zurück
return (bool)preg_match('/\b1\b/', $out);
// 1) Direkt: banip
[, $out1] = $this->f2b('get '.escapeshellarg($jail).' banip '.escapeshellarg($ip));
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