diff --git a/bancount.css b/bancount.css index 6bfe246..5158f21 100644 --- a/bancount.css +++ b/bancount.css @@ -1,80 +1,77 @@ /* -Fail2BanCount - by k6b (kyle@kylefberry.net) + Fail2BanCount - by k6b (kyle@kylefberry.net) -*/ + */ body { - margin:0; - font-size:80%; - font-family: sans-serif; - text-align: center; - } + margin: 0; + font-size: 80%; + font-family: sans-serif; + text-align: center; +} #header { - display: block; - width: 80%; - margin: auto; - } + display: block; + width: 80%; + margin: auto; +} #container { - width: 80%; - margin: auto; - display: block; - } + width: 80%; + margin: auto; + display: block; +} #footer { - width: 80%; - margin: auto; - display: block; - padding: 0.3em; - } + width: 80%; + margin: auto; + display: block; + padding: 0.3em; +} .table { - width: auto; - margin: auto; - display: table; - } + width: auto; + margin: auto; + display: table; +} -.row { - display: table-row; - width: 100% - } +.row { + display: table-row; + width: 100% +} - .row - -.menu { - width:50%; - padding:0.5em; - display: table-cell; - text-align: center; - font-weight: bold; - } +.row .menu { + padding: 0.5em; + display: table-cell; + text-align: center; + font-weight: bold; +} .cell { - width:10em; - padding:0.4em; - display: table-cell; - text-align: center; - } + width: 10em; + padding: 0.4em; + display: table-cell; + text-align: center; +} .cell-header { - padding:0.5em; - display: table-cell; - text-align: center; - text-decoration: underline; - font-weight: bold; - } + padding: 0.5em; + display: table-cell; + text-align: center; + text-decoration: underline; + font-weight: bold; +} h1, h2, h3 { - padding: 0.1em 0.1em 0.2em 0.1em; - } + padding: 0.1em 0.1em 0.2em 0.1em; +} a:link, a:visited, a:active { - text-decoration: none; - color:#000000; - } + text-decoration: none; + color: #000000; +} a:hover { - color:#FF0000; - } + color: #FF0000; +} diff --git a/index.php b/index.php index 11f27de..697be1a 100644 --- a/index.php +++ b/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 '

', $name, '

'; + echo '
'; + echo '', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], ''; + echo '
',   htmlentities(print_r($data, 1)), '
'; + echo '

'; +} + // 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
\n"; echo "\t\t
\n"; echo "\t\t\tHome\n"; echo "\t\t\tAll Bans\n"; +echo "\t\t\tLast 24h ban\n"; echo "\t\t
\n"; echo "\t
\n"; switch ($page) { @@ -245,13 +278,34 @@ switch ($page) { } echo "\t\n"; break; + case 'last' : + //id,service,ip,ban_date,ban_time,country + $getLast24hBan = getLast24hBan($db); + echo "\t
\n"; + echo "\t\t\t
\n\t\t\t\tService\n\t\t\t
\n"; + echo "\t\t\t
\n\t\t\t\tIP\n\t\t\t
\n"; + echo "\t\t\t
\n\t\t\t\tDate\n\t\t\t
\n"; + echo "\t\t\t
\n\t\t\t\tTime\n\t\t\t
\n"; + echo "\t\t\t
\n\t\t\t\tCountry\n\t\t\t
\n"; + foreach ($getLast24hBan as $value) { + echo '
+
', $value['service'], '
+
', $value['ip'], '
+
', $value['ban_date'], '
+
', $value['ban_time'], '
+
', $value['country'], '
+
'; + } + echo '
'; + break; } echo "\n"; +echo '

Go top

'; $stop = microtime(true); $total = round($stop - $start, 4); echo 'Generate in ', $total, ' secondes
'; echo "\n"; echo "\n"; echo "\n";