Subversion Repositories ALCASAR

Rev

Rev 2267 | Go to most recent revision | 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 2268 2017-06-04 10:12:10Z richard $
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";
2182 tom.houday 13
} else {
2268 richard 14
	$l_title	= "Connection to ALCASAR Control Center (ACC)";
15
	$l_user		= "User";
16
	$l_ip_address	= "IP address";
2093 raphael.pi 17
}
2182 tom.houday 18
// Read access log
19
$accessLogs = [];
2267 richard 20
$accessLogFilename = '/var/Save/security/acc_access.log';
2182 tom.houday 21
$filePtn = fopen($accessLogFilename, 'r');
22
if ($filePtn !== false){
23
	while (!feof($filePtn)) {
24
		$ligne = fgets($filePtn);
25
		if (empty($ligne)) {
26
			continue;
27
		}
2267 richard 28
		$infos = explode('|', $ligne);
2182 tom.houday 29
		$accessLogs[] = (object) [
2267 richard 30
			'date'     	=> trim($infos[0]),
31
			'username' 	=> trim($infos[1]),
32
			'ip'       	=> trim($infos[2]),
33
			'user_agent'	=> trim($infos[3])
2182 tom.houday 34
		];
2093 raphael.pi 35
	}
2182 tom.houday 36
	fclose($filePtn);
2093 raphael.pi 37
}
2182 tom.houday 38
$accessLogs = array_reverse($accessLogs);
2093 raphael.pi 39
 
2191 tom.houday 40
// Remove access before startTime
41
if (isset($_GET['startTime'])) {
42
	$startTime = intval($_GET['startTime']);
43
	foreach ($accessLogs as $key => $access) {
44
		$timestamp = date_timestamp_get(date_create_from_format('d/m/Y H:i:s', $access->date));
45
		if ($timestamp < $startTime) {
46
			$accessLogs = array_slice($accessLogs, 0, $key);
47
			break;
48
		}
49
	}
50
}
51
 
2093 raphael.pi 52
?>
2268 richard 53
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2182 tom.houday 54
<html>
55
<head>
56
	<meta charset="utf-8">
57
	<title>Admin Logs</title>
2268 richard 58
	<link rel="stylesheet" href="/css/style.css" type="text/css">
2182 tom.houday 59
	<style>
60
	body {
61
		background-color: #EFEFEF;
62
	}
63
	</style>
64
</head>
65
<body>
2268 richard 66
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
67
<tr><th><? echo "$l_title";?></th></tr>
68
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" 
69
height="2"></td></tr>
70
</TABLE>
71
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
72
	<thead>
73
		<tr>
74
			<th>Date</th>
75
			<th><?=$l_user?></th>
76
			<th><?=$l_ip_address?></th>
77
			<th>Agent</th>
78
		</tr>
79
	</thead>
80
	<tbody>
81
		<?php if (empty($accessLogs)): ?>
82
			<tr>
83
				<td colspan="4"><center>Empty</center></td>
84
			</tr>
85
		<?php else: ?>
86
			<?php foreach ($accessLogs as $access): ?>
87
			<tr>
88
					<td><?= $access->date ?></td>
89
					<td><?= $access->username ?></td>
90
					<td><?= $access->ip ?></td>
91
					<td><?= $access->user_agent ?></td>
2182 tom.houday 92
				</tr>
2268 richard 93
			<?php endforeach; ?>
94
		<?php endif; ?>
95
	</tbody>
96
</table>
2093 raphael.pi 97
</body>
2182 tom.houday 98
</html>