1,124 → 1,147 |
<?php |
# $Id$ |
|
//gestion de la langue |
if (is_file("../lib/langues.php")) |
include("../lib/langues.php"); |
require('../lib/langues.php'); |
|
$language = 'en'; |
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
$langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); |
$language = strtolower(substr(chop($langue[0]), 0, 2)); |
} |
if ($language === 'fr') { |
$l_title = 'Sécurité'; |
} else { |
$l_title = 'Security'; |
} |
|
$tab = (isset($_GET['tab'])) ? intval($_GET['tab']) : 1; |
?> |
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//2.0"> |
<HTML> |
<!-- written by Crox --> |
<HEAD> |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
<TITLE>menu</TITLE> |
<link rel="stylesheet" href="../../../css/bootstrap.min.css"> |
<script src="../../../js/jquery.min.js"></script> |
<script src="../../../js/bootstrap.min.js"></script> |
<!DOCTYPE html> |
<html> |
<head> |
<meta charset="UTF-8"> |
<title><?= $l_title ?></title> |
<link rel="stylesheet" href="/css/bootstrap.min.css"> |
<script src="/js/jquery.min.js"></script> |
<script src="/js/bootstrap.min.js"></script> |
<style> |
body { |
background-color: #EFEFEF; |
} |
</style> |
</HEAD> |
</head> |
<body> |
<br> |
<div class="btn-group btn-group-justified" role="group" aria-label="Justified button group"> |
<a href="security.php?tab=1" class="btn btn-default<?= (($tab === 1) ? ' active' : '') ?>" role="button"><?= $l_spoofing ?></a> |
<a href="security.php?tab=2" class="btn btn-default<?= (($tab === 2) ? ' active' : '') ?>" role="button"><?= $l_virus ?></a> |
<a href="security.php?tab=3" class="btn btn-default<?= (($tab === 3) ? ' active' : '') ?>" role="button"><?= $l_fail2ban ?></a> |
</div> |
<br> |
|
|
|
<?php |
$table = 1; |
if(isset($_GET['table'])){ |
$table = $_GET['table']; |
if ($tab === 1) { |
$filePath = '/var/Save/security/watchdog.log'; |
$lines = file($filePath); |
if ($lines === false) { |
exit("Cannot open '$filePath'."); |
} |
|
$lines = array_reverse($lines); |
?> |
|
|
<h3 style="text-align: center;"><?= $l_spoofing ?></h3> |
<div class="container"> |
<table class="table table-striped table-hover"> |
<tbody> |
<?php if (!empty($lines)): ?> |
<?php foreach ($lines as $line): ?> |
<tr><td><?= $line ?></td></tr> |
<?php endforeach; ?> |
<?php else: ?> |
<tr><td style="text-align: center;"><?= $l_empty ?></td></tr> |
<?php endif; ?> |
</tbody> |
</table> |
</div> |
<?php |
} else if ($tab === 2) { |
$filePath = '/var/log/havp/access.log'; |
$lines = file($filePath); |
if ($lines === false) { |
exit("Cannot open '$filePath'."); |
} |
|
echo' |
<br /> |
<div class="btn-group btn-group-justified" role="group" aria-label="Justified button group"> |
<a href="./security.php?table=1" class="btn btn-default" role="button">'.$l_spoofing.'</a> |
<a href="./security.php?table=2" class="btn btn-default" role="button">'.$l_virus.'</a> |
<a href="./security.php?table=3" class="btn btn-default" role="button">'.$l_fail2ban.'</a> |
$lines = array_reverse($lines); |
?> |
<h3 style="text-align: center;"><?= $l_virus ?></h3> |
<div class="container"> |
<table class="table table-striped table-hover"> |
<tbody> |
<?php if (!empty($lines)): ?> |
<?php foreach ($lines as $line): ?> |
<tr><td><?= $line ?></td></tr> |
<?php endforeach; ?> |
<?php else: ?> |
<tr><td style="text-align: center;"><?= $l_empty ?></td></tr> |
<?php endif; ?> |
</tbody> |
</table> |
</div> |
<br />'; |
|
|
?> |
|
|
<?php |
} else if ($tab === 3) { |
$bans = []; |
$regex = '/^(?P<date>[0-9]{4}-[0-9]{2}-[0-9]{2}\ [0-9]{2}:[0-9]{2}:[0-9]{2}),[0-9]{3} fail2ban\.actions\[[0-9]+\]: WARNING \[(?P<rule>[a-zA-Z0-9_-]+)\] (?P<type>Ban|Unban) (?P<ip>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$/'; |
$file = fopen('/var/log/fail2ban.log', 'r'); |
if ($file) { |
while (!feof($file)) { |
$line = fgets($file); |
|
if ( $table == 1){ |
|
echo '<center><h3>'; |
echo "$l_spoofing"; |
echo '</h3></center><div class="container"><table class="table table-striped"><tbody>'; |
|
$fichier='/var/Save/security/watchdog.log'; |
$pointeur=fopen($fichier,"r"); |
if ($pointeur){ |
while (!feof($pointeur)){ |
$ligne=fgets($pointeur); |
echo "<tr><td>$ligne</td></tr>"; |
if (preg_match($regex, $line, $matches)) { |
if ($matches['type'] === 'Ban') { |
$bans[] = (object) [ |
'date_ban' => $matches['date'], |
'date_unban' => null, |
'rule' => $matches['rule'], |
'ip' => $matches['ip'] |
]; |
} else if ($matches['type'] === 'Unban') { |
foreach (array_reverse($bans) as $ban) { |
if (($ban->ip === $matches['ip']) && ($ban->rule === $matches['rule']) && ($ban->date_unban === null)) { |
$ban->date_unban = $matches['date']; |
break; |
} |
} |
else |
{ |
echo '<tr><center>Empty</center></tr>'; |
} |
fclose($pointeur); |
echo '</tbody></table></div>'; |
|
|
} elseif ($table == 2){ |
echo '<center><h3>'; |
echo "$l_virus"; |
echo '</h3></center><div class="container"><table class="table table-striped"><tbody>'; |
|
$fichier='/var/log/havp/access.log'; |
$pointeur=fopen($fichier,"r"); |
if ($pointeur){ |
while (!feof($pointeur)){ |
$ligne=fgets($pointeur); |
echo "<tr><td>$ligne</td></tr>"; |
} |
} |
else |
{ |
echo '<tr><center>Empty</center></tr>'; |
fclose($file); |
} |
fclose($pointeur); |
echo '</tbody></table></div>'; |
|
} elseif ($table == 3){ |
echo '<center><h3>'; |
echo "$l_fail2ban"; |
echo '</h3></center><div class="container"><table class="table table-striped"><tbody>'; |
|
$fichier='/var/log/fail2ban.log'; |
$unban="/Unban/"; |
$ban="/Ban/"; |
$pointeur=fopen($fichier,"r"); |
if ($pointeur){ |
while (!feof($pointeur)){ |
$ligne=fgets($pointeur); |
if(preg_match($ban,$ligne,$r)){ |
echo "<tr><td><font color='red'>$ligne</font></td></tr>"; |
} |
if(preg_match($unban,$ligne,$r)){ |
echo "<tr><td><font color='orange'>$ligne</font></td></tr>"; |
} |
} |
fclose($pointeur); |
} |
else |
{ |
echo '<tr><center>Empty</center></tr>'; |
} |
echo '</tbody></table></div>'; |
$bans = array_reverse($bans); |
?> |
<h3 style="text-align: center;"><?= $l_fail2ban ?></h3> |
<div class="container"> |
<table class="table table-striped table-hover"> |
<thead> |
<tr><th>Date</th><th>Date Unban</th><th><?= $l_rule ?></th><th><?= $l_ipAddress ?></th></tr> |
</thead> |
<tbody> |
<?php if (!empty($bans)): ?> |
<?php foreach ($bans as $ban): ?> |
<tr><td><?= $ban->date_ban ?></td><td><?= $ban->date_unban ?></td><td><?= $ban->rule ?></td><td><?= $ban->ip ?></td></tr> |
<?php endforeach; ?> |
<?php else: ?> |
<tr><td colspan="4" style="text-align: center;"><?= $l_empty ?></td></tr> |
<?php endif; ?> |
</tbody> |
</table> |
</div> |
<?php |
} else { |
echo 'Do not exist'; |
echo 'Unknown tab'; |
} |
|
?> |
</body> |
</HTML> |
</html> |
Property changes: |
Added: svn:keywords |
+Id |
\ No newline at end of property |