Subversion Repositories ALCASAR

Rev

Rev 2182 | Rev 2267 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2182 Rev 2191
1
<?php
1
<?php
2
# $Id $
2
# $Id: admin_log.php 2191 2017-04-28 22:00:32Z tom.houdayer $
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
 
9
 
10
if ($Language === 'fr') {
10
if ($Language === 'fr') {
11
	$l_title_amdin_log = "Connexion à l'ALCASAR Control Center (ACC)";
11
	$l_title_amdin_log = "Connexion à l'ALCASAR Control Center (ACC)";
12
} else {
12
} else {
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 = 'admin_log.txt';
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
		];
31
		];
32
	}
32
	}
33
	fclose($filePtn);
33
	fclose($filePtn);
34
}
34
}
35
$accessLogs = array_reverse($accessLogs);
35
$accessLogs = array_reverse($accessLogs);
36
 
36
 
-
 
37
// Remove access before startTime
-
 
38
if (isset($_GET['startTime'])) {
-
 
39
	$startTime = intval($_GET['startTime']);
-
 
40
	foreach ($accessLogs as $key => $access) {
-
 
41
		$timestamp = date_timestamp_get(date_create_from_format('d/m/Y H:i:s', $access->date));
-
 
42
		if ($timestamp < $startTime) {
-
 
43
			$accessLogs = array_slice($accessLogs, 0, $key);
-
 
44
			break;
-
 
45
		}
-
 
46
	}
-
 
47
}
-
 
48
 
37
?>
49
?>
38
<!doctype html>
50
<!doctype html>
39
<html>
51
<html>
40
<head>
52
<head>
41
	<meta charset="utf-8">
53
	<meta charset="utf-8">
42
	<title>Admin Logs</title>
54
	<title>Admin Logs</title>
43
	<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
55
	<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
44
	<style>
56
	<style>
45
	body {
57
	body {
46
		background-color: #EFEFEF;
58
		background-color: #EFEFEF;
47
	}
59
	}
48
	</style>
60
	</style>
49
	<script src="../js/jquery.min.js"></script>
61
	<script src="../js/jquery.min.js"></script>
50
	<script src="../js/bootstrap.min.js"></script>
62
	<script src="../js/bootstrap.min.js"></script>
51
</head>
63
</head>
52
<body>
64
<body>
53
	<div class="container">
65
	<div class="container">
54
		<center>
66
		<center>
55
			<h3><?= $l_title_amdin_log ?></h3>
67
			<h3><?= $l_title_amdin_log ?></h3>
56
		</center>
68
		</center>
57
		<table class="table table-striped">
69
		<table class="table table-striped">
58
			<thead>
70
			<thead>
59
				<tr>
71
				<tr>
60
					<th>Date</th>
72
					<th>Date</th>
61
					<th>User</th>
73
					<th>User</th>
62
					<th>IP address</th>
74
					<th>IP address</th>
63
				</tr>
75
				</tr>
64
			</thead>
76
			</thead>
65
			<tbody>
77
			<tbody>
66
				<?php if (empty($accessLogs)): ?>
78
				<?php if (empty($accessLogs)): ?>
67
					<tr>
79
					<tr>
68
						<td colspan="3"><center>Empty</center></td>
80
						<td colspan="3"><center>Empty</center></td>
69
					</tr>
81
					</tr>
70
				<?php else: ?>
82
				<?php else: ?>
71
					<?php foreach ($accessLogs as $access): ?>
83
					<?php foreach ($accessLogs as $access): ?>
72
						<tr>
84
						<tr>
73
							<td><?= $access->date ?></td>
85
							<td><?= $access->date ?></td>
74
							<td><?= $access->username ?></td>
86
							<td><?= $access->username ?></td>
75
							<td><?= $access->ip ?></td>
87
							<td><?= $access->ip ?></td>
76
						</tr>
88
						</tr>
77
					<?php endforeach; ?>
89
					<?php endforeach; ?>
78
				<?php endif; ?>
90
				<?php endif; ?>
79
			</tbody>
91
			</tbody>
80
		</table>
92
		</table>
81
	</div>
93
	</div>
82
</body>
94
</body>
83
</html>
95
</html>
84
 
96