[add] possibility to sort all columns
This commit is contained in:
parent
860344923c
commit
59fab70b75
24
index.php
24
index.php
|
@ -23,13 +23,28 @@ $db_pwd = $config['mysqlpw'];
|
|||
$database = $config['mysqldb'];
|
||||
// Page variable
|
||||
$page = htmlspecialchars($_GET["page"]);
|
||||
$orderby = htmlspecialchars($_GET["orderby"]);
|
||||
$sortBy = htmlspecialchars($_GET["sortBy"]);
|
||||
$order = htmlspecialchars($_GET["order"]);
|
||||
$newOrder = testOrder($order);
|
||||
if ($order == 'a') {
|
||||
$order = 'asc';
|
||||
} else {
|
||||
$order = 'desc';
|
||||
}
|
||||
function testOrder($order) {
|
||||
if ($order == 'd') {
|
||||
return 'a';
|
||||
} else {
|
||||
return 'd';
|
||||
}
|
||||
}
|
||||
|
||||
function n_print($data, $name = '') {
|
||||
$aBackTrace = debug_backtrace();
|
||||
echo '<h2>', $name, '</h2>';
|
||||
echo '<fieldset style="border: 1px solid orange; padding: 5px;color: #333; background-color: #fff;">';
|
||||
echo '<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '</legend>';
|
||||
echo '<pre>', htmlentities(print_r($data, 1)), '</pre>';
|
||||
echo '<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '</legend>';
|
||||
echo '<pre>', htmlentities(print_r($data, 1)), '</pre>';
|
||||
echo '</fieldset><br />';
|
||||
}
|
||||
|
||||
|
@ -61,6 +76,7 @@ if (!$totalunbans) {
|
|||
while ($row = mysqli_fetch_array($totalunbans)) {
|
||||
$numunbans = $row['MAX(id)'];
|
||||
}
|
||||
$currentlybanned = $numbans - $numunbans;
|
||||
if ($currentlybanned != 1) {
|
||||
$grammer = "IPs are";
|
||||
} else {
|
||||
|
@ -132,7 +148,7 @@ $stop = microtime(true);
|
|||
$total = round($stop - $start, 4);
|
||||
echo 'Generate in ', $total, ' secondes</br>';
|
||||
echo "<div id='footer'>\n";
|
||||
echo "\t©", date("Y"), " released under GNU GPL base on <a href='http://kylefberry.net'>k6b</a> work this version are made by Knah Tsaeb\n";
|
||||
echo "\t©", date("Y"), " released under GNU GPL base on <a href='http://kylefberry.net'>k6b</a> work this version are made by Knah Tsaeb\n";
|
||||
echo "</div>\n";
|
||||
echo "</body>\n";
|
||||
echo "</html>\n";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
// Order by ID
|
||||
function getAllBan($db, $order = 'id') {
|
||||
$sql = "SELECT id,service,ip,ban_date,ban_time,country,countryCode FROM bans ORDER BY $order";
|
||||
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;
|
||||
|
@ -14,24 +14,24 @@ function getAllBan($db, $order = 'id') {
|
|||
?>
|
||||
<div class='table'>
|
||||
<div class='row'>
|
||||
<a href='?page=allBans&orderby=service' class='cell-header'><u>Service</u></a>
|
||||
<a href='?page=allBans&orderby=ip' class='cell-header'><u>IP</u></a>
|
||||
<a href='?page=allBans&orderby=ban_date' class='cell-header'><u>Ban Date</u></a>
|
||||
<a href='?page=allBans&orderby=ban_time' class='cell-header'><u>Ban Time</u></a>
|
||||
<a href='?page=allBans&orderby=country' class='cell-header'><u>Country</u></a>
|
||||
<a href="?page=allBans&sortBy=service&order=<?php echo $newOrder?>" class='cell-header'>Service</a>
|
||||
<a href="?page=allBans&sortBy=ip&order=<?php echo $newOrder?>" class='cell-header'>IP</a>
|
||||
<a href="?page=allBans&sortBy=ban_date&order=<?php echo $newOrder?>" class='cell-header'>Ban Date</a>
|
||||
<a href="?page=allBans&sortBy=ban_time&order=<?php echo $newOrder?>" class='cell-header'>Ban Time</a>
|
||||
<a href="?page=allBans&sortBy=country&order=<?php echo $newOrder?>" class='cell-header'>Country</a>
|
||||
</div>
|
||||
<?php
|
||||
if (empty($orderby)) {
|
||||
$orderby = 'id';
|
||||
if (empty($sortBy)) {
|
||||
$sortBy = 'ban_date';
|
||||
}
|
||||
$allBan = getAllBan($db, $orderby);
|
||||
$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 class="cell">', $value['country'].printFlag($value['countryCode']), '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
function getCurrentBan($db) {
|
||||
$sql = mysqli_query($db, "SELECT service,ip,ban_date,ban_time,country,countryCode FROM bans WHERE bans.id NOT IN ( SELECT unbans.id FROM unbans WHERE bans.id=unbans.id)");
|
||||
function getCurrentBan($db, $sortBy = 'ban_date, ban_time', $order = 'DESC') {
|
||||
$sql = mysqli_query($db, "SELECT id,service,ip,ban_date,ban_time,country,countryCode FROM bans WHERE bans.ip NOT IN ( SELECT unbans.ip FROM unbans WHERE bans.ip=unbans.ip) ORDER BY $sortBy $order");
|
||||
while ($rows = mysqli_fetch_assoc($sql)) {
|
||||
$currentBan[] = $rows;
|
||||
}
|
||||
|
@ -11,30 +11,32 @@ function getCurrentBan($db) {
|
|||
return $currentBan;
|
||||
}
|
||||
|
||||
echo '<h3>Currently ',$currentlybanned,' ',$grammer,' banned.</h3>';
|
||||
|
||||
//echo '<h3>Currently ',abs($currentlybanned),' ',$grammer,' banned.</h3>';
|
||||
?>
|
||||
<h2>Currently Banned</h2>
|
||||
<div class='table'>
|
||||
<div class='row'>
|
||||
<div class='cell-header'>
|
||||
Service
|
||||
<a href="?page=currentBan&sortBy=service&order=<?php echo $newOrder?>">Service</a>
|
||||
</div>
|
||||
<div class='cell-header'>
|
||||
IP
|
||||
<a href="?page=currentBan&sortBy=ip&order=<?php echo $newOrder?>">IP</a>
|
||||
</div>
|
||||
<div class='cell-header'>
|
||||
Date
|
||||
<a href="?page=currentBan&sortBy=ban_date&order=<?php echo $newOrder?>">Date</a>
|
||||
</div>
|
||||
<div class='cell-header'>
|
||||
Time
|
||||
<a href="?page=currentBan&sortBy=ban_time&order=<?php echo $newOrder?>">Time</a>
|
||||
</div>
|
||||
<div class='cell-header'>
|
||||
Country
|
||||
<a href="?page=currentBan&sortBy=country&order=<?php echo $newOrder?>">Country</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$currentBan = getCurrentBan($db);
|
||||
if (empty($sortBy)) {
|
||||
$sortBy = 'ban_date';
|
||||
}
|
||||
$currentBan = getCurrentBan($db, $sortBy, $order);
|
||||
foreach ($currentBan as $value) {
|
||||
echo '<div class="row">
|
||||
<div class="cell">', $value['service'], '</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
function getLast24hBan($db) {
|
||||
$getLast24hBan = mysqli_query($db, "SELECT service,ip,ban_date,ban_time,country, countryCode FROM bans WHERE concat_ws(' ',ban_date, ban_time) >= now() - INTERVAL 1 DAY ORDER BY id");
|
||||
function getLast24hBan($db, $sortBy = 'ban_date, ban_time', $order = 'DESC') {
|
||||
$getLast24hBan = mysqli_query($db, "SELECT service,ip,ban_date,ban_time,country, countryCode FROM bans WHERE concat_ws(' ',ban_date, ban_time) >= now() - INTERVAL 1 DAY ORDER BY $sortBy $order");
|
||||
while ($rows = mysqli_fetch_assoc($getLast24hBan)) {
|
||||
$lastBan[] = $rows;
|
||||
}
|
||||
|
@ -12,22 +12,25 @@ function getLast24hBan($db) {
|
|||
?>
|
||||
<div class='table'>
|
||||
<div class='cell-header'>
|
||||
Service
|
||||
<a href="?page=lastBan&sortBy=service&order=<?php echo $newOrder?>">Service</a>
|
||||
</div>
|
||||
<div class='cell-header'>
|
||||
IP
|
||||
<a href="?page=lastBan&sortBy=ip&order=<?php echo $newOrder?>">IP</a>
|
||||
</div>
|
||||
<div class='cell-header'>
|
||||
Date
|
||||
<a href="?page=lastBan&sortBy=ban_date&order=<?php echo $newOrder?>">Date</a>
|
||||
</div>
|
||||
<div class='cell-header'>
|
||||
Time
|
||||
<a href="?page=lastBan&sortBy=ban_time&order=<?php echo $newOrder?>">Time</a>
|
||||
</div>
|
||||
<div class='cell-header'>
|
||||
Country
|
||||
<a href="?page=lastBan&sortBy=country&order=<?php echo $newOrder?>">Country</a>
|
||||
</div>
|
||||
<?php
|
||||
$getLast24hBan = getLast24hBan($db);
|
||||
if (empty($sortBy)) {
|
||||
$sortBy = 'ban_date';
|
||||
}
|
||||
$getLast24hBan = getLast24hBan($db, $sortBy, $order);
|
||||
foreach ($getLast24hBan as $value) {
|
||||
echo '
|
||||
<div class="row">
|
||||
|
@ -44,7 +47,7 @@ function getLast24hBan($db) {
|
|||
', $value['ban_time'], '
|
||||
</div>
|
||||
<div class="cell">
|
||||
', $value['country'], printFlag($value['countryCode']), '
|
||||
', $value['country'], printFlag($value['countryCode']), '
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
function getRecidivist($db) {
|
||||
$sql = mysqli_query($db, "SELECT ip, COUNT(*) count,country, countryCode FROM bans GROUP BY ip HAVING count > 1 ORDER BY count DESC");
|
||||
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");
|
||||
if (!$sql) {
|
||||
die("Query failed. 1");
|
||||
}
|
||||
|
@ -13,21 +13,23 @@ function getRecidivist($db) {
|
|||
}
|
||||
return $multiplebans;
|
||||
}
|
||||
|
||||
$multiplebans = getRecidivist($db);
|
||||
if (empty($sortBy)) {
|
||||
$sortBy = 'count';
|
||||
}
|
||||
$multiplebans = getRecidivist($db, $sortBy, $order);
|
||||
?>
|
||||
<h2>Recidivist (<?php echo count($multiplebans); ?>)
|
||||
</h2>
|
||||
<div class='table'>
|
||||
<div class='row'>
|
||||
<div class='cell-header'>
|
||||
IP
|
||||
<a href="?page=recidivist&sortBy=count&order=<?php echo $newOrder?>">IP</a>
|
||||
</div>
|
||||
<div class='cell-header'>
|
||||
Bans
|
||||
<a href="?page=recidivist&sortBy=count&order=<?php echo $newOrder?>">Bans</a>
|
||||
</div>
|
||||
<div class='cell-header'>
|
||||
Country
|
||||
<a href="?page=recidivist&sortBy=country&order=<?php echo $newOrder?>">Country</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
|
|
@ -16,19 +16,19 @@ function topTen($db) {
|
|||
<div class='table'>
|
||||
<div class='row'>
|
||||
<div class='cell-header'>
|
||||
Country
|
||||
Bans
|
||||
</div>
|
||||
<div class='cell-header'>
|
||||
Bans
|
||||
Country
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$topTen = topTen($db);
|
||||
foreach ($topTen as $value) {
|
||||
echo '<div class="row">';
|
||||
echo '<div class="cell">', $value['country'].printFlag($value['countryCode']),'</div>';
|
||||
echo '<div class="cell">', $value['count'], '</div>';
|
||||
echo '<div class="cell">', $value['country'].printFlag($value['countryCode']), '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
?>
|
||||
</div>
|
Loading…
Reference in New Issue