Subversion Repositories ALCASAR

Rev

Rev 2191 | Rev 2268 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2191 Rev 2267
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: admin_log.php 2191 2017-04-28 22:00:32Z tom.houdayer $
2
# $Id: admin_log.php 2267 2017-06-04 09:28:36Z richard $
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)); 
Line 13... Line 13...
13
	$l_title_amdin_log = "Connection to ALCASAR Control Center (ACC)";
13
	$l_title_amdin_log = "Connection to ALCASAR Control Center (ACC)";
14
}
14
}
15
 
15
 
16
// Read access log
16
// Read access log
17
$accessLogs = [];
17
$accessLogs = [];
18
$accessLogFilename = 'admin_log.txt';
18
$accessLogFilename = '/var/Save/security/acc_access.log';
19
$filePtn = fopen($accessLogFilename, 'r');
19
$filePtn = fopen($accessLogFilename, 'r');
20
if ($filePtn !== false){
20
if ($filePtn !== false){
21
	while (!feof($filePtn)) {
21
	while (!feof($filePtn)) {
22
		$ligne = fgets($filePtn);
22
		$ligne = fgets($filePtn);
23
		if (empty($ligne)) {
23
		if (empty($ligne)) {
24
			continue;
24
			continue;
25
		}
25
		}
26
		$infos = explode('|||', $ligne);
26
		$infos = explode('|', $ligne);
27
		$accessLogs[] = (object) [
27
		$accessLogs[] = (object) [
28
			'date'     => trim($infos[0]),
28
			'date'     	=> trim($infos[0]),
29
			'username' => trim($infos[1]),
29
			'username' 	=> trim($infos[1]),
30
			'ip'       => trim($infos[2])
30
			'ip'       	=> trim($infos[2]),
-
 
31
			'user_agent'	=> trim($infos[3])
31
		];
32
		];
32
	}
33
	}
33
	fclose($filePtn);
34
	fclose($filePtn);
34
}
35
}
35
$accessLogs = array_reverse($accessLogs);
36
$accessLogs = array_reverse($accessLogs);
Line 70... Line 71...
70
			<thead>
71
			<thead>
71
				<tr>
72
				<tr>
72
					<th>Date</th>
73
					<th>Date</th>
73
					<th>User</th>
74
					<th>User</th>
74
					<th>IP address</th>
75
					<th>IP address</th>
-
 
76
					<th>Agent</th>
75
				</tr>
77
				</tr>
76
			</thead>
78
			</thead>
77
			<tbody>
79
			<tbody>
78
				<?php if (empty($accessLogs)): ?>
80
				<?php if (empty($accessLogs)): ?>
79
					<tr>
81
					<tr>
Line 83... Line 85...
83
					<?php foreach ($accessLogs as $access): ?>
85
					<?php foreach ($accessLogs as $access): ?>
84
						<tr>
86
						<tr>
85
							<td><?= $access->date ?></td>
87
							<td><?= $access->date ?></td>
86
							<td><?= $access->username ?></td>
88
							<td><?= $access->username ?></td>
87
							<td><?= $access->ip ?></td>
89
							<td><?= $access->ip ?></td>
-
 
90
							<td><?= $access->user_agent ?></td>
88
						</tr>
91
						</tr>
89
					<?php endforeach; ?>
92
					<?php endforeach; ?>
90
				<?php endif; ?>
93
				<?php endif; ?>
91
			</tbody>
94
			</tbody>
92
		</table>
95
		</table>