Subversion Repositories ALCASAR

Rev

Rev 2268 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log

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