MyFail2BanInfo/page/allBans.php

39 lines
1.5 KiB
PHP

<?php
// Order by ID
function getAllBan($db, $sortBy = 'ban_date, ban_time', $order = 'DESC') {
$sql = "SELECT id,service,ip,ban_date,ban_time,country,countryCode FROM bans ORDER BY $sortBy $order";
$res = mysqli_query($db, $sql);
while ($rows = mysqli_fetch_assoc($res)) {
$allBan[] = $rows;
}
if (empty($allBan)) {
$allBan = array();
}
return $allBan;
}
?>
<h2>All time banned</h2>
<div class='table'>
<div class='row'>
<a href="?page=allBans&amp;sortBy=service&amp;order=<?php echo $newOrder?>" class='cell-header'>Service</a>
<a href="?page=allBans&amp;sortBy=ip&amp;order=<?php echo $newOrder?>" class='cell-header'>IP</a>
<a href="?page=allBans&amp;sortBy=ban_date&amp;order=<?php echo $newOrder?>" class='cell-header'>Ban Date</a>
<a href="?page=allBans&amp;sortBy=ban_time&amp;order=<?php echo $newOrder?>" class='cell-header'>Ban Time</a>
<a href="?page=allBans&amp;sortBy=country&amp;order=<?php echo $newOrder?>" class='cell-header'>Country</a>
</div>
<?php
if (empty($sortBy)) {
$sortBy = 'ban_date';
}
$allBan = getAllBan($db, $sortBy, $order);
foreach ($allBan as $value) {
echo '<div class="row">';
echo '<div class="cell">', $value['service'], '</div>';
echo '<div class="cell">', $value['ip'], '</div>';
echo '<div class="cell">', $value['ban_date'], '</div>';
echo '<div class="cell">', $value['ban_time'], '</div>';
echo '<div class="cell">', $value['country'].printFlag($value['countryCode']), '</div>';
echo '</div>';
}
?>
</div>