Subversion Repositories ALCASAR

Rev

Rev 2852 | 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 3254 2025-02-22 17:08:05Z rexy $
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";
2852 rexy 13
	$l_date         = "Date";
3254 rexy 14
	$l_agent        = "Agent web";
2852 rexy 15
} else if ($Language === 'es') {
16
	$l_title	= "Conexiones a ALCASAR, Centro de Control (ACC)";
17
	$l_user		= "Usuario";
18
	$l_ip_address	= "Dirección IP";
19
	$l_date         = "Fecha";
3254 rexy 20
	$l_agent        = "Agente web";
2182 tom.houday 21
} else {
2268 richard 22
	$l_title	= "Connection to ALCASAR Control Center (ACC)";
23
	$l_user		= "User";
24
	$l_ip_address	= "IP address";
2852 rexy 25
	$l_date         = "Date";
3254 rexy 26
	$l_agent        = "Web user agent";
2093 raphael.pi 27
}
2182 tom.houday 28
// Read access log
29
$accessLogs = [];
2267 richard 30
$accessLogFilename = '/var/Save/security/acc_access.log';
2182 tom.houday 31
$filePtn = fopen($accessLogFilename, 'r');
32
if ($filePtn !== false){
33
	while (!feof($filePtn)) {
34
		$ligne = fgets($filePtn);
35
		if (empty($ligne)) {
36
			continue;
37
		}
2267 richard 38
		$infos = explode('|', $ligne);
2182 tom.houday 39
		$accessLogs[] = (object) [
2267 richard 40
			'date'     	=> trim($infos[0]),
41
			'username' 	=> trim($infos[1]),
42
			'ip'       	=> trim($infos[2]),
43
			'user_agent'	=> trim($infos[3])
2182 tom.houday 44
		];
2093 raphael.pi 45
	}
2182 tom.houday 46
	fclose($filePtn);
2093 raphael.pi 47
}
2182 tom.houday 48
$accessLogs = array_reverse($accessLogs);
2093 raphael.pi 49
 
2191 tom.houday 50
// Remove access before startTime
51
if (isset($_GET['startTime'])) {
52
	$startTime = intval($_GET['startTime']);
53
	foreach ($accessLogs as $key => $access) {
54
		$timestamp = date_timestamp_get(date_create_from_format('d/m/Y H:i:s', $access->date));
55
		if ($timestamp < $startTime) {
56
			$accessLogs = array_slice($accessLogs, 0, $key);
57
			break;
58
		}
59
	}
60
}
61
 
2093 raphael.pi 62
?>
2818 rexy 63
<!DOCTYPE html>
2182 tom.houday 64
<html>
65
<head>
2818 rexy 66
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2182 tom.houday 67
	<title>Admin Logs</title>
2818 rexy 68
	<link rel="stylesheet" href="/css/acc.css" type="text/css">
3254 rexy 69
	<link rel="stylesheet" href="/css/jquery.dataTables.css">
70
	<script src="/js/jquery-3.6.min.js"></script>
71
	<script src="/js/jquery.dataTables.js"></script>
72
	<script type="text/javascript">
73
		$(document).ready(function() {
74
		$('#datatable_display').DataTable();
75
		});
76
		$.extend(true, $.fn.dataTable.defaults, {
77
        		language: {
78
			url: '/js/jquery.dataTables.<?= $Language ?>.json'
79
        			},
80
			});
81
	</script>
2182 tom.houday 82
</head>
83
<body>
2818 rexy 84
<div class="panel">
85
	<div class="panel-header"><?= $l_title ?></div>
86
	<div class="panel-row">
87
		<table border=0 width=100% cellpadding=12 cellspacing=0 bgcolor="#ffffd0" valign=top>
88
		<tr><td>
3254 rexy 89
			<TABLE id="datatable_display" class="display" width="100%" border=1 cellspacing=0 cellpadding=0>
90
			<thead><tr bgcolor=”#686464”>
2852 rexy 91
				<th><?=$l_date?></th>
2818 rexy 92
				<th><?=$l_user?></th>
93
				<th><?=$l_ip_address?></th>
2852 rexy 94
				<th><?=$l_agent?></th>
3254 rexy 95
			</tr></thead>
96
			<tbody>
2818 rexy 97
			<?php if (empty($accessLogs)): ?>
98
			<tr>
2268 richard 99
				<td colspan="4"><center>Empty</center></td>
100
			</tr>
2818 rexy 101
			<?php else: ?>
2268 richard 102
			<?php foreach ($accessLogs as $access): ?>
103
			<tr>
2818 rexy 104
				<td><?= $access->date ?></td>
105
				<td><?= $access->username ?></td>
106
				<td><?= $access->ip ?></td>
107
				<td><?= $access->user_agent ?></td>
108
			</tr>
2268 richard 109
			<?php endforeach; ?>
2818 rexy 110
			<?php endif; ?>
3254 rexy 111
			</tbody>
2818 rexy 112
			</table>
113
		</table>
114
	</div>
115
</div>
2093 raphael.pi 116
</body>
2182 tom.houday 117
</html>