Subversion Repositories ALCASAR

Rev

Rev 2818 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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