2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2024-04-01 23:09:37 +02:00
|
|
|
use Carbon\Carbon;
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
include_once __DIR__.'/core.php';
|
|
|
|
|
2018-03-02 19:36:42 +01:00
|
|
|
$pageTitle = tr('Log');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-06-26 09:41:43 +02:00
|
|
|
include_once App::filepath('include|custom|', 'top.php');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
<div class="box">
|
|
|
|
<div class="box-header">
|
2017-09-04 12:02:29 +02:00
|
|
|
<h3 class="box-title"><i class="fa fa-book"></i> '.tr('Ultimi 100 accessi').'</h3>
|
2017-08-04 16:28:16 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- /.box-header -->
|
|
|
|
<div class="box-body table-responsive no-padding">
|
|
|
|
<table class="datatables table table-hover">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
2024-04-01 23:09:37 +02:00
|
|
|
<th width="200">'.tr('Username').'</th>
|
|
|
|
<th width="150">'.tr('Data').'</th>
|
|
|
|
<th width="100">'.tr('Indirizzo IP').'</th>
|
|
|
|
<th>'.tr('Dispositivo').'</th>
|
|
|
|
<th width="180">'.tr('Stato').'</th>
|
2017-08-04 16:28:16 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>';
|
|
|
|
|
|
|
|
/*
|
|
|
|
LEGGO DALLA TABELLA ZZ_LOG
|
|
|
|
*/
|
2017-08-07 13:07:18 +02:00
|
|
|
if (Auth::admin()) {
|
2017-08-04 16:28:16 +02:00
|
|
|
$q = 'SELECT * FROM `zz_logs` ORDER BY `created_at` DESC LIMIT 0, 100';
|
|
|
|
} else {
|
2018-08-10 17:14:09 +02:00
|
|
|
$q = 'SELECT * FROM `zz_logs` WHERE `id_utente`='.prepare(Auth::user()['id']).' ORDER BY `created_at` DESC LIMIT 0, 100';
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
2024-04-01 23:09:37 +02:00
|
|
|
$logs = $dbo->fetchArray($q);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2024-04-01 23:09:37 +02:00
|
|
|
foreach ($logs as $log) {
|
|
|
|
$timestamp = Translator::timestampToLocale($log['created_at']);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2017-08-07 13:07:18 +02:00
|
|
|
$status = Auth::getStatus();
|
2024-04-01 23:09:37 +02:00
|
|
|
if ($log['stato'] == $status['success']['code']) {
|
2017-08-04 16:28:16 +02:00
|
|
|
$type = 'success';
|
2017-08-07 13:07:18 +02:00
|
|
|
$stato = $status['success']['message'];
|
2024-04-01 23:09:37 +02:00
|
|
|
} elseif ($log['stato'] == $status['disabled']['code']) {
|
2017-08-04 16:28:16 +02:00
|
|
|
$type = 'warning';
|
2017-08-07 13:07:18 +02:00
|
|
|
$stato = $status['disabled']['message'];
|
2024-04-01 23:09:37 +02:00
|
|
|
} elseif ($log['stato'] == $status['unauthorized']['code']) {
|
2017-08-04 16:28:16 +02:00
|
|
|
$type = 'warning';
|
2017-08-07 13:07:18 +02:00
|
|
|
$stato = $status['unauthorized']['message'];
|
2017-08-04 16:28:16 +02:00
|
|
|
} else {
|
|
|
|
$type = 'danger';
|
2017-08-07 13:07:18 +02:00
|
|
|
$stato = $status['failed']['message'];
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
2024-04-01 23:09:37 +02:00
|
|
|
$created_at = new Carbon($log['created_at']);
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
|
|
|
<tr class="'.$type.'">
|
2024-04-01 23:09:37 +02:00
|
|
|
<td>'.$log['username'].'</td>
|
|
|
|
<td class="tip" title="'.$created_at->format('d/m/Y H:i:s').'">'.$created_at->diffForHumans().'</td>
|
|
|
|
<td>'.$log['ip'].'</td>
|
|
|
|
<td class="user-agent tip" title="'.strip_tags($log['user_agent']).'">'.$log['user_agent'].'</td>
|
2017-08-04 16:28:16 +02:00
|
|
|
<td><span class="label label-'.$type.'">'.$stato.'</span></td>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<!-- /.box-body -->
|
|
|
|
</div>
|
|
|
|
<!-- /.box -->';
|
2024-04-01 23:09:37 +02:00
|
|
|
?>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
|
|
var parser = new UAParser();
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2024-04-01 23:09:37 +02:00
|
|
|
$('tr').each(function(){
|
|
|
|
user_agent_cell = $(this).find('.user-agent');
|
|
|
|
user_agent = user_agent_cell.text();
|
|
|
|
|
|
|
|
if (user_agent !== '') {
|
|
|
|
parser.setUA(user_agent);
|
|
|
|
device = parser.getResult();
|
|
|
|
|
2024-04-02 11:11:59 +02:00
|
|
|
user_agent_cell.html('<strong>' + (device.browser.name || '') + '</strong> ' + (device.browser.version || '') + ' | <strong>' + (device.os.name || '') + '</strong> ' + (device.os.version || ''));
|
2024-04-01 23:09:37 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<?php
|
2018-06-26 09:41:43 +02:00
|
|
|
include_once App::filepath('include|custom|', 'bottom.php');
|