my $currentbans = $db->prepare("SELECT ip,ban_date,ban_time,country FROM bans WHERE bans.id NOT IN ( SELECT unbans.id FROM unbans WHERE bans.id=unbans.id)");
my $bans = $db->prepare("SELECT MAX(id) FROM bans");
my $unbans = $db->prepare("SELECT MAX(id) From unbans");
my $multiplebans = $db->prepare("SELECT ip,COUNT(*) count,country FROM bans GROUP BY ip HAVING count > 1 ORDER BY count DESC");
$currentbans->execute();
$bans->execute();
$unbans->execute();
$multiplebans->execute();
# find total bans
while (my $ref = $bans->fetchrow_arrayref) {
our $totalban = $ref->[0];
}
while (my $ref = $unbans->fetchrow_arrayref) {
our $totalunban = $ref->[0];
}
our ($totalban,$totalunban);
our $currentlybanned = $totalban - $totalunban;
print color 'bold';
print color 'underline';
print "\nFail2BanCount - by k6b\n\n";
print color 'reset';
print "$totalban IPs have been banned.\n\n";
# find IPs banned more than once
print color 'underline';
print "IP\t\tBans\tCountry\n";
print color 'reset';
while (my $ref = $multiplebans->fetchrow_arrayref) {