Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2404 → Rev 2405

/web/acc/manager/htdocs/security.php
43,24 → 43,40
 
<?php
if ($tab === 1) {
$filePath = '/var/Save/security/watchdog.log';
$lines = file($filePath);
if ($lines === false) {
exit("Cannot open '$filePath'.");
$spoofs = [];
$regex = '/^\[(?P<date>[0-9]{2}\/[0-9]{2}\/[0-9]{4}-[0-9]{2}:[0-9]{2}:[0-9]{2})\] : alcasar-watchdog : (?P<ip>(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])) is usurped \((?P<mac>(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2})\)\. Alcasar disconnect the user \((?P<user>.+)\)\.$/';
$file = fopen('/var/Save/security/watchdog.log', 'r');
if ($file) {
while (!feof($file)) {
$line = fgets($file);
 
if (preg_match($regex, $line, $matches)) {
$spoofs[] = (object) [
'date' => DateTime::createFromFormat('d/m/Y-H:i:s', $matches['date'])->format('Y-m-d H:i:s'),
'ip' => $matches['ip'],
'mac' => $matches['mac'],
'user' => $matches['user']
];
}
}
fclose($file);
}
 
$lines = array_reverse($lines);
$spoofs = array_reverse($spoofs);
?>
<h3 style="text-align: center;"><?= $l_spoofing ?></h3>
<div class="container">
<table class="table table-striped table-hover">
<thead>
<tr><th>Date</th><th><?= $l_ipAddress ?></th><th>MAC</th><th><?= $l_user ?></th></tr>
</thead>
<tbody>
<?php if (!empty($lines)): ?>
<?php foreach ($lines as $line): ?>
<tr><td><?= $line ?></td></tr>
<?php if (!empty($spoofs)): ?>
<?php foreach ($spoofs as $spoof): ?>
<tr><td><?= $spoof->date ?></td><td><?= $spoof->ip ?></td><td><?= $spoof->mac ?></td><td><?= $spoof->user ?></td></tr>
<?php endforeach; ?>
<?php else: ?>
<tr><td style="text-align: center;"><?= $l_empty ?></td></tr>
<tr><td colspan="4" style="text-align: center;"><?= $l_empty ?></td></tr>
<?php endif; ?>
</tbody>
</table>