diff --git a/gulpfile.js b/gulpfile.js
index 93040b849..8c7616362 100755
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -122,7 +122,8 @@ const JS = gulp.parallel(() => {
'bootstrap-maxlength/dist/bootstrap-maxlength.js',
'leaflet/dist/leaflet.js',
'leaflet-gesture-handling/dist/leaflet-gesture-handling.min.js',
- 'ismobilejs/dist/isMobile.min.js'
+ 'ismobilejs/dist/isMobile.min.js',
+ 'ua-parser-js/dist/ua-parser.min.js',
];
for (const i in vendor) {
diff --git a/log.php b/log.php
index 5ed3da787..aa74c234c 100755
--- a/log.php
+++ b/log.php
@@ -17,6 +17,8 @@
* along with this program. If not, see .
*/
+use Carbon\Carbon;
+
include_once __DIR__.'/core.php';
$pageTitle = tr('Log');
@@ -34,10 +36,11 @@ echo '
- '.tr('Username').' |
- '.tr('Data').' |
- '.tr('Stato').' |
- '.tr('Indirizzo IP').' |
+ '.tr('Username').' |
+ '.tr('Data').' |
+ '.tr('Indirizzo IP').' |
+ '.tr('Dispositivo').' |
+ '.tr('Stato').' |
';
@@ -50,25 +53,19 @@ if (Auth::admin()) {
} else {
$q = 'SELECT * FROM `zz_logs` WHERE `id_utente`='.prepare(Auth::user()['id']).' ORDER BY `created_at` DESC LIMIT 0, 100';
}
-$rs = $dbo->fetchArray($q);
-$n = sizeof($rs);
+$logs = $dbo->fetchArray($q);
-for ($i = 0; $i < $n; ++$i) {
- $id = $rs[$i]['id'];
- $id_utente = $rs[$i]['id_utente'];
- $username = $rs[$i]['username'];
- $ip = $rs[$i]['ip'];
-
- $timestamp = Translator::timestampToLocale($rs[$i]['created_at']);
+foreach ($logs as $log) {
+ $timestamp = Translator::timestampToLocale($log['created_at']);
$status = Auth::getStatus();
- if ($rs[$i]['stato'] == $status['success']['code']) {
+ if ($log['stato'] == $status['success']['code']) {
$type = 'success';
$stato = $status['success']['message'];
- } elseif ($rs[$i]['stato'] == $status['disabled']['code']) {
+ } elseif ($log['stato'] == $status['disabled']['code']) {
$type = 'warning';
$stato = $status['disabled']['message'];
- } elseif ($rs[$i]['stato'] == $status['unauthorized']['code']) {
+ } elseif ($log['stato'] == $status['unauthorized']['code']) {
$type = 'warning';
$stato = $status['unauthorized']['message'];
} else {
@@ -76,12 +73,15 @@ for ($i = 0; $i < $n; ++$i) {
$stato = $status['failed']['message'];
}
+ $created_at = new Carbon($log['created_at']);
+
echo '
- '.$username.' |
- '.$timestamp.' |
+ '.$log['username'].' |
+ '.$created_at->diffForHumans().' |
+ '.$log['ip'].' |
+ '.$log['user_agent'].' |
'.$stato.' |
- '.$ip.' |
';
}
@@ -93,5 +93,27 @@ echo '
';
+?>
+
+
+purify($_SERVER['HTTP_USER_AGENT']);
$this->current_status = $status;
// Salvataggio del tentativo nel database
diff --git a/update/2_5_1.sql b/update/2_5_1.sql
new file mode 100644
index 000000000..8619e0777
--- /dev/null
+++ b/update/2_5_1.sql
@@ -0,0 +1,2 @@
+-- Aggiunta user-agent nei log
+ALTER TABLE `zz_logs` ADD `user_agent` VARCHAR(255) NULL DEFAULT NULL AFTER `ip`;