Subversion Repositories ALCASAR

Rev

Rev 2818 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
2182 tom.houday 1
<?php
2191 tom.houday 2
# $Id: admin_log.php 2852 2020-07-18 10:08:26Z rexy $
2093 raphael.pi 3
 
2182 tom.houday 4
$Language = 'en';
5
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
6
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
7
	$Language = strtolower(substr(chop($Langue[0]), 0, 2)); 
2093 raphael.pi 8
}
2182 tom.houday 9
if ($Language === 'fr') {
2268 richard 10
	$l_title	= "Connexion à l'ALCASAR Control Center (ACC)";
11
	$l_user		= "Utilisateur";
12
	$l_ip_address	= "Adresse IP";
2852 rexy 13
	$l_date         = "Date";
14
    $l_agent        = "Agent web";
15
 
16
} else if ($Language === 'es') {
17
	$l_title	= "Conexiones a ALCASAR, Centro de Control (ACC)";
18
	$l_user		= "Usuario";
19
	$l_ip_address	= "Dirección IP";
20
	$l_date         = "Fecha";
21
    $l_agent        = "Agente web";
2182 tom.houday 22
} else {
2268 richard 23
	$l_title	= "Connection to ALCASAR Control Center (ACC)";
24
	$l_user		= "User";
25
	$l_ip_address	= "IP address";
2852 rexy 26
	$l_date         = "Date";
27
    $l_agent        = "Web user agent";
2093 raphael.pi 28
}
2182 tom.houday 29
// Read access log
30
$accessLogs = [];
2267 richard 31
$accessLogFilename = '/var/Save/security/acc_access.log';
2182 tom.houday 32
$filePtn = fopen($accessLogFilename, 'r');
33
if ($filePtn !== false){
34
	while (!feof($filePtn)) {
35
		$ligne = fgets($filePtn);
36
		if (empty($ligne)) {
37
			continue;
38
		}
2267 richard 39
		$infos = explode('|', $ligne);
2182 tom.houday 40
		$accessLogs[] = (object) [
2267 richard 41
			'date'     	=> trim($infos[0]),
42
			'username' 	=> trim($infos[1]),
43
			'ip'       	=> trim($infos[2]),
44
			'user_agent'	=> trim($infos[3])
2182 tom.houday 45
		];
2093 raphael.pi 46
	}
2182 tom.houday 47
	fclose($filePtn);
2093 raphael.pi 48
}
2182 tom.houday 49
$accessLogs = array_reverse($accessLogs);
2093 raphael.pi 50
 
2191 tom.houday 51
// Remove access before startTime
52
if (isset($_GET['startTime'])) {
53
	$startTime = intval($_GET['startTime']);
54
	foreach ($accessLogs as $key => $access) {
55
		$timestamp = date_timestamp_get(date_create_from_format('d/m/Y H:i:s', $access->date));
56
		if ($timestamp < $startTime) {
57
			$accessLogs = array_slice($accessLogs, 0, $key);
58
			break;
59
		}
60
	}
61
}
62
 
2093 raphael.pi 63
?>
2818 rexy 64
<!DOCTYPE html>
2182 tom.houday 65
<html>
66
<head>
2818 rexy 67
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2182 tom.houday 68
	<title>Admin Logs</title>
2818 rexy 69
	<link rel="stylesheet" href="/css/acc.css" type="text/css">
2182 tom.houday 70
</head>
71
<body>
2818 rexy 72
<div class="panel">
73
	<div class="panel-header"><?= $l_title ?></div>
74
	<div class="panel-row">
75
		<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
76
		<tr><td>
77
			<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
2268 richard 78
			<tr>
2852 rexy 79
				<th><?=$l_date?></th>
2818 rexy 80
				<th><?=$l_user?></th>
81
				<th><?=$l_ip_address?></th>
2852 rexy 82
				<th><?=$l_agent?></th>
2818 rexy 83
			</tr>
84
			<?php if (empty($accessLogs)): ?>
85
			<tr>
2268 richard 86
				<td colspan="4"><center>Empty</center></td>
87
			</tr>
2818 rexy 88
			<?php else: ?>
2268 richard 89
			<?php foreach ($accessLogs as $access): ?>
90
			<tr>
2818 rexy 91
				<td><?= $access->date ?></td>
92
				<td><?= $access->username ?></td>
93
				<td><?= $access->ip ?></td>
94
				<td><?= $access->user_agent ?></td>
95
			</tr>
2268 richard 96
			<?php endforeach; ?>
2818 rexy 97
			<?php endif; ?>
98
			</table>
99
		</table>
100
	</div>
101
</div>
2093 raphael.pi 102
</body>
2182 tom.houday 103
</html>