[add] last 24h ban
This commit is contained in:
parent
bf3e9aabef
commit
78aba94cde
|
@ -41,10 +41,7 @@ body {
|
|||
width: 100%
|
||||
}
|
||||
|
||||
.row
|
||||
|
||||
.menu {
|
||||
width:50%;
|
||||
.row .menu {
|
||||
padding: 0.5em;
|
||||
display: table-cell;
|
||||
text-align: center;
|
||||
|
|
54
index.php
54
index.php
|
@ -24,6 +24,15 @@ $database = $config['mysqldb'];
|
|||
// Page variable
|
||||
$page = htmlspecialchars($_GET["page"]);
|
||||
$orderby = htmlspecialchars($_GET["orderby"]);
|
||||
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 '</fieldset><br />';
|
||||
}
|
||||
|
||||
// Connect to MySQL
|
||||
if (!$db = mysqli_connect($db_host, $db_user, $db_pwd)) {
|
||||
die("Can't connect to database");
|
||||
|
@ -95,6 +104,29 @@ $allbans_service = mysqli_query($db, "SELECT id,service,ip,ban_date,ban_time,cou
|
|||
if (!$multiplebans) {
|
||||
die("Query failed.");
|
||||
}
|
||||
function getLast24hBan($db) {
|
||||
$getLast24hBan = mysqli_query($db, "SELECT service,ip,ban_date,ban_time,country FROM bans WHERE concat_ws(' ',ban_date, ban_time) >= now() - INTERVAL 1 DAY ORDER BY id");
|
||||
while ($rows = mysqli_fetch_assoc($getLast24hBan)) {
|
||||
$lastBan[] = $rows;
|
||||
}
|
||||
if (empty($lastBan)) {
|
||||
$lastBan = array();
|
||||
}
|
||||
return $lastBan;
|
||||
}
|
||||
|
||||
// Get day with ban
|
||||
function getDayWithBan($db) {
|
||||
$getDayWithBan = mysqli_query($db, "SELECT DISTINCT ban_date FROM bans ORDER BY ban_date");
|
||||
while ($rows = mysqli_fetch_assoc($getDayWithBan)) {
|
||||
$allDate[] = $rows['ban_date'];
|
||||
}
|
||||
if (empty($allDate)) {
|
||||
$allDate = array();
|
||||
}
|
||||
return $allDate;
|
||||
}
|
||||
|
||||
// Find the number of currently banned IP's using subtraction.
|
||||
// I'm sure I can do this with a single MySQL query and get
|
||||
// rid of the above 2 queries all together.
|
||||
|
@ -109,6 +141,7 @@ echo "\t<div class='table'>\n";
|
|||
echo "\t\t<div class='row'>\n";
|
||||
echo "\t\t\t<a href='?page=home' class='menu'>Home</a>\n";
|
||||
echo "\t\t\t<a href='?page=allbans' class='menu'>All Bans</a>\n";
|
||||
echo "\t\t\t<a href='?page=last' class='menu'>Last 24h ban</a>\n";
|
||||
echo "\t\t</div>\n";
|
||||
echo "\t</div>\n";
|
||||
switch ($page) {
|
||||
|
@ -245,8 +278,29 @@ switch ($page) {
|
|||
}
|
||||
echo "\t</div>\n";
|
||||
break;
|
||||
case 'last' :
|
||||
//id,service,ip,ban_date,ban_time,country
|
||||
$getLast24hBan = getLast24hBan($db);
|
||||
echo "\t<div class='table'>\n";
|
||||
echo "\t\t\t<div class='cell-header'>\n\t\t\t\tService\n\t\t\t</div>\n";
|
||||
echo "\t\t\t<div class='cell-header'>\n\t\t\t\tIP\n\t\t\t</div>\n";
|
||||
echo "\t\t\t<div class='cell-header'>\n\t\t\t\tDate\n\t\t\t</div>\n";
|
||||
echo "\t\t\t<div class='cell-header'>\n\t\t\t\tTime\n\t\t\t</div>\n";
|
||||
echo "\t\t\t<div class='cell-header'>\n\t\t\t\tCountry\n\t\t\t</div>\n";
|
||||
foreach ($getLast24hBan as $value) {
|
||||
echo '<div class="row">
|
||||
<div class="cell">', $value['service'], '</div>
|
||||
<div class="cell">', $value['ip'], '</div>
|
||||
<div class="cell">', $value['ban_date'], '</div>
|
||||
<div class="cell">', $value['ban_time'], '</div>
|
||||
<div class="cell">', $value['country'], '</div>
|
||||
</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
break;
|
||||
}
|
||||
echo "</div>\n";
|
||||
echo '<p><a href="#header">Go top</a></p>';
|
||||
$stop = microtime(true);
|
||||
$total = round($stop - $start, 4);
|
||||
echo 'Generate in ', $total, ' secondes</br>';
|
||||
|
|
Loading…
Reference in New Issue