Rev 2267 | Rev 2818 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log
<?php
# $Id: admin_log.php 2268 2017-06-04 10:12:10Z richard $
$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 = "Connexion à l'ALCASAR Control Center (ACC)";
$l_user = "Utilisateur";
$l_ip_address = "Adresse IP";
} else {
$l_title = "Connection to ALCASAR Control Center (ACC)";
$l_user = "User";
$l_ip_address = "IP address";
}
// Read access log
$accessLogs = [];
$accessLogFilename = '/var/Save/security/acc_access.log';
$filePtn = fopen($accessLogFilename, 'r');
if ($filePtn !== false){
while (!feof($filePtn)) {
$ligne = fgets($filePtn);
if (empty($ligne)) {
continue;
}
$infos = explode('|', $ligne);
$accessLogs[] = (object) [
'date' => trim($infos[0]),
'username' => trim($infos[1]),
'ip' => trim($infos[2]),
'user_agent' => trim($infos[3])
];
}
fclose($filePtn);
}
$accessLogs = array_reverse($accessLogs);
// Remove access before startTime
if (isset($_GET['startTime'])) {
$startTime = intval($_GET['startTime']);
foreach ($accessLogs as $key => $access) {
$timestamp = date_timestamp_get(date_create_from_format('d/m/Y H:i:s', $access->date));
if ($timestamp < $startTime) {
$accessLogs = array_slice($accessLogs, 0, $key);
break;
}
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta charset="utf-8">
<title>Admin Logs</title>
<link rel="stylesheet" href="/css/style.css" type="text/css">
<style>
body {
background-color: #EFEFEF;
}
</style>
</head>
<body>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><th><? echo "$l_title";?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1"
height="2"></td></tr>
</TABLE>
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
<thead>
<tr>
<th>Date</th>
<th><?=$l_user?></th>
<th><?=$l_ip_address?></th>
<th>Agent</th>
</tr>
</thead>
<tbody>
<?php if (empty($accessLogs)): ?>
<tr>
<td colspan="4"><center>Empty</center></td>
</tr>
<?php else: ?>
<?php foreach ($accessLogs as $access): ?>
<tr>
<td><?= $access->date ?></td>
<td><?= $access->username ?></td>
<td><?= $access->ip ?></td>
<td><?= $access->user_agent ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</body>
</html>