diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..45552cb --- /dev/null +++ b/.htaccess @@ -0,0 +1 @@ +Options -Indexes \ No newline at end of file diff --git a/COPYING b/COPYING index 0b3500c..5de4a67 100644 --- a/COPYING +++ b/COPYING @@ -1,10 +1,17 @@ Files: * License: GNU GPL -Copyright : (c) 2012 - 2015 Kyle F. Berry (k6b) - (c) 2015 Knah Tsaeb +Copyright : (c) 2012 - 2015 Kyle F. Berry (k6b) + (c) 2015 Knah Tsaeb -All knah-tsaeb work are under ZLIB/LIBPNG LICENSE +All knah-tsaeb work's are under ZLIB/LIBPNG LICENSE +Files : jquery.tabbedcontent.min.js +License : MIT +Copyright : (c) 2015 Òscar Casajuana http://elboletaire.github.io/tabbedcontent/index.html + +Files : zepto.min.js +License : MIT +Copyright : (c) 2015 Thomas Fuchs http://zeptojs.com -------------------- GNU GENERAL PUBLIC LICENSE Version 1, February 1989 @@ -275,4 +282,25 @@ freely, subject to the following restrictions: 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. \ No newline at end of file + 3. This notice may not be removed or altered from any source distribution. + +------------------------------------------ + Copyright (c) 2015 Òscar Casajuana + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. \ No newline at end of file diff --git a/bin/bancount.cfg.sample b/bin/bancount.cfg.sample index a99c0ec..298d8fa 100644 --- a/bin/bancount.cfg.sample +++ b/bin/bancount.cfg.sample @@ -1,4 +1,6 @@ +mysqlhost="127.0.0.1" mysqldb="fail2bancount" mysqlpw="" mysqluser="fail2bancount" -title="MyFail2BanInfo" \ No newline at end of file +title="MyFail2BanInfo" +launchDate="DD-MM-YYYY" \ No newline at end of file diff --git a/index.php b/index.php index 697be1a..39b85f2 100644 --- a/index.php +++ b/index.php @@ -17,7 +17,7 @@ echo "\n"; echo "
\n"; -echo "\t

$numbans IPs have been banned.

\n"; +echo "\t

$numbans IPs have been banned since $config[launchDate]

\n"; // Menu 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\tRecidivist\n"; +echo "\t\t\tCurrent ban\n"; +echo "\t\t\tLast 24h\n"; +echo "\t\t\tAll time\n"; +echo "\t\t\tTop 10 countries\n"; echo "\t\t
\n"; echo "\t
\n"; -switch ($page) { - default : - // Begin creating the first table of IPs that have been banned - // more than once. - echo "\t

Recidivist

\n"; - echo "\t
\n"; - echo "\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\tBans\n\t\t\t
\n"; - echo "\t\t\t
\n\t\t\t\tCountry\n\t\t\t
\n"; - echo "\t\t
\n"; - // Print the data obtained from the MySQL database - // Print the first table - while ($row = mysqli_fetch_row($multiplebans)) { - echo "\t\t
\n"; - foreach ($row as $cell) - echo "\t\t\t
\n\t\t\t\t$cell\n\t\t\t
\n"; - echo "\t\t
\n"; - } - echo "\t
\n"; - mysqli_free_result($multiplebans); - // Use correct grammer - if ($currentlybanned != 1) { - $grammer = "IPs are"; - } else { - $grammer = "IP is"; - } - echo "\t

Currently $currentlybanned $grammer banned.

\n"; - // Only print the second table if we have an IP - // currently banned. - if ($numbans > $numunbans) { - // Print the data obtained from the MySQL database - // Table title - echo "\t

Currently Banned

\n"; - // Create the second table, of currently banned IPs - echo "\t
\n"; - echo "\t\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"; - echo "\t\t
\n"; - // Print out the second table - while ($row = mysqli_fetch_row($currentbans)) { - echo "\t\t
\n"; - foreach ($row as $cell) - echo "\t\t\t
\n\t\t\t\t$cell\n\t\t\t
\n"; - echo "\t\t
\n"; - } - echo "\t
\n"; - mysqli_free_result($currentbans); - } - // Print more HTML - echo "\t

Top 10 Countries

\n"; - // Begin creating the second table of counrtys that have been banned - // more than once. - echo "\t
\n"; - echo "\t\t
\n"; - echo "\t\t\t
\n\t\t\t\tCountry\n\t\t\t
\n"; - echo "\t\t\t
\n\t\t\t\tBans\n\t\t\t
\n"; - echo "\t\t
\n"; - // Print the first table - while ($row = mysqli_fetch_row($countrybans)) { - echo "\t\t
\n"; - foreach ($row as $cell) - echo "\t\t\t
\n\t\t\t\t$cell\n\t\t\t
\n"; - echo "\t\t
\n"; - } - echo "\t
\n"; - mysqli_free_result($countrybans); - break; - case "allbans" : - echo "\t
\n"; - echo "\t\t
\n"; - echo "\t\t\t\n\t\t\t\t\n\t\t\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\tBan Date\n\t\t\t\n"; - echo "\t\t\t\n\t\t\t\tBan Time\n\t\t\t\n"; - echo "\t\t\t\n\t\t\t\tCountry\n\t\t\t\n"; - echo "\t\t
\n"; - switch ($orderby) { - default : - case "id" : - while ($row = mysqli_fetch_row($allbans)) { - echo "\t\t
\n"; - foreach ($row as $cell) - echo "\t\t\t
\n\t\t\t\t$cell\n\t\t\t
\n"; - echo "\t\t
\n"; - } - case "ip" : - while ($row = mysqli_fetch_row($allbans_ip)) { - echo "\t\t
\n"; - foreach ($row as $cell) - echo "\t\t\t
\n\t\t\t\t$cell\n\t\t\t
\n"; - echo "\t\t
\n"; - } - break; - case "date" : - while ($row = mysqli_fetch_row($allbans_date)) { - echo "\t\t
\n"; - foreach ($row as $cell) - echo "\t\t\t
\n\t\t\t\t$cell\n\t\t\t
\n"; - echo "\t\t
\n"; - } - break; - case "time" : - while ($row = mysqli_fetch_row($allbans_time)) { - echo "\t\t
\n"; - foreach ($row as $cell) - echo "\t\t\t
\n\t\t\t\t$cell\n\t\t\t
\n"; - echo "\t\t
\n"; - } - break; - case "country" : - while ($row = mysqli_fetch_row($allbans_country)) { - echo "\t\t
\n"; - foreach ($row as $cell) - echo "\t\t\t
\n\t\t\t\t$cell\n\t\t\t
\n"; - echo "\t\t
\n"; - } - break; - case "service" : - while ($row = mysqli_fetch_row($allbans_service)) { - echo "\t\t
\n"; - foreach ($row as $cell) - echo "\t\t\t
\n\t\t\t\t$cell\n\t\t\t
\n"; - echo "\t\t
\n"; - } - break; - } - 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; +if ($page === 'home') { + require 'page/home.php'; +} +if ($page === 'recidivist') { + require 'page/recidivist.php'; +} +if ($page === 'currentBan') { + require 'page/currentBan.php'; +} +if ($page === 'lastBan') { + require 'page/lastBan.php'; +} +if ($page === 'topTen') { + require 'page/topTen.php'; +} +if ($page === 'allBans') { + require 'page/allBans.php'; } echo "
\n"; echo '

Go top

'; @@ -305,7 +124,7 @@ $stop = microtime(true); $total = round($stop - $start, 4); echo 'Generate in ', $total, ' secondes
'; echo "\n"; echo "\n"; echo "\n"; diff --git a/page/.htaccess b/page/.htaccess new file mode 100644 index 0000000..2c73686 --- /dev/null +++ b/page/.htaccess @@ -0,0 +1 @@ +Deny from All \ No newline at end of file diff --git a/page/allBans.php b/page/allBans.php new file mode 100644 index 0000000..46cf242 --- /dev/null +++ b/page/allBans.php @@ -0,0 +1,38 @@ + +
+ + '; + echo '
', $value['service'], '
'; + echo '
', $value['ip'], '
'; + echo '
', $value['ban_date'], '
'; + echo '
', $value['ban_time'], '
'; + echo '
', $value['country'], '
'; + echo '
'; + } +?> + \ No newline at end of file diff --git a/page/currentBan.php b/page/currentBan.php new file mode 100644 index 0000000..831a066 --- /dev/null +++ b/page/currentBan.php @@ -0,0 +1,48 @@ +Currently ',$currentlybanned,' ',$grammer,' banned.'; + +?> +

Currently Banned

+
+
+
+ Service +
+
+ IP +
+
+ Date +
+
+ Time +
+
+ Country +
+
+ +
', $value['service'], '
+
', $value['ip'], '
+
', $value['ban_date'], '
+
', $value['ban_time'], '
+
', $value['country'], '
+
'; + } +?> + \ No newline at end of file diff --git a/page/home.php b/page/home.php new file mode 100644 index 0000000..c8498ef --- /dev/null +++ b/page/home.php @@ -0,0 +1,6 @@ +

Welcome

+
+

+ MyFail2BanInfo is simple webapps for shows some information about your Fail2ban log. +

+
\ No newline at end of file diff --git a/page/lastBan.php b/page/lastBan.php new file mode 100644 index 0000000..8442dc1 --- /dev/null +++ b/page/lastBan.php @@ -0,0 +1,53 @@ += now() - INTERVAL 1 DAY ORDER BY id"); + while ($rows = mysqli_fetch_assoc($getLast24hBan)) { + $lastBan[] = $rows; + } + if (empty($lastBan)) { + $lastBan = array(); + } + return $lastBan; +} +?> +
+
+ Service +
+
+ IP +
+
+ Date +
+
+ Time +
+
+ Country +
+ +
+', $value['service'], ' +
+
+', $value['ip'], ' +
+
+', $value['ban_date'], ' +
+
+', $value['ban_time'], ' +
+
+', $value['country'], ' +
+
'; + } + echo ' + +'; diff --git a/page/recidivist.php b/page/recidivist.php new file mode 100644 index 0000000..2687a19 --- /dev/null +++ b/page/recidivist.php @@ -0,0 +1,42 @@ + 1 ORDER BY count DESC"); + 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; +} + +$multiplebans = getRecidivist($db); +?> +

Recidivist () +

+
+
+
+ IP +
+
+ Bans +
+
+ Country +
+
+ +
', $value['ip'], '
+
', $value['count'], '
+
', $value['country'], '
+
'; + } +?> + \ No newline at end of file diff --git a/page/topTen.php b/page/topTen.php new file mode 100644 index 0000000..048b381 --- /dev/null +++ b/page/topTen.php @@ -0,0 +1,34 @@ + +

Top 10 Countries

+
+
+
+ Country +
+
+ Bans +
+
+ '; + echo '
', $value['country'], '
'; + echo '
', $value['count'], '
'; + echo '
'; + } + ?> + \ No newline at end of file