MyFail2BanInfo/page/recidivist.php

44 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2015-06-18 10:11:20 +02:00
<?php
2015-07-07 17:13:49 +02:00
function getRecidivist($db, $sortBy = 'count', $order = 'ASC') {
$sql = mysqli_query($db, "SELECT ip, COUNT(*) count,country, countryCode FROM bans GROUP BY ip HAVING count > 1 ORDER BY $sortBy $order");
2015-06-18 10:11:20 +02:00
if (!$sql) {
die("Query failed. 1");
}
while ($rows = mysqli_fetch_assoc($sql)) {
$multiplebans[] = $rows;
}
mysqli_free_result($sql);
if (empty($multiplebans)) {
$multiplebans = array();
}
return $multiplebans;
}
2015-07-07 17:13:49 +02:00
if (empty($sortBy)) {
$sortBy = 'count';
}
$multiplebans = getRecidivist($db, $sortBy, $order);
2015-06-18 10:11:20 +02:00
?>
<h2>Recidivist (<?php echo count($multiplebans); ?>)
</h2>
<div class='table'>
<div class='row'>
<div class='cell-header'>
2015-07-07 17:13:49 +02:00
<a href="?page=recidivist&amp;sortBy=count&amp;order=<?php echo $newOrder?>">IP</a>
2015-06-18 10:11:20 +02:00
</div>
<div class='cell-header'>
2015-07-07 17:13:49 +02:00
<a href="?page=recidivist&amp;sortBy=count&amp;order=<?php echo $newOrder?>">Bans</a>
2015-06-18 10:11:20 +02:00
</div>
<div class='cell-header'>
2015-07-07 17:13:49 +02:00
<a href="?page=recidivist&amp;sortBy=country&amp;order=<?php echo $newOrder?>">Country</a>
2015-06-18 10:11:20 +02:00
</div>
</div>
<?php
foreach ($multiplebans as $value) {
echo '<div class="row">
<div class="cell">', $value['ip'], '</div>
<div class="cell">', $value['count'], '</div>
2015-07-03 16:04:10 +02:00
<div class="cell">', $value['country'],printFlag($value['countryCode']),'</div>
2015-06-18 10:11:20 +02:00
</div>';
}
?>
</div>