.
*/
use Carbon\Carbon;
include_once __DIR__.'/core.php';
$pageTitle = tr('Log');
include_once App::filepath('include|custom|', 'top.php');
echo '
'.tr('Username').' |
'.tr('Data').' |
'.tr('Indirizzo IP').' |
'.tr('Dispositivo').' |
'.tr('Stato').' |
';
/*
LEGGO DALLA TABELLA ZZ_LOG
*/
if (Auth::admin()) {
$q = 'SELECT * FROM `zz_logs` ORDER BY `created_at` DESC LIMIT 0, 100';
} else {
$q = 'SELECT * FROM `zz_logs` WHERE `id_utente`='.prepare(Auth::user()['id']).' ORDER BY `created_at` DESC LIMIT 0, 100';
}
$logs = $dbo->fetchArray($q);
foreach ($logs as $log) {
$timestamp = Translator::timestampToLocale($log['created_at']);
$status = Auth::getStatus();
if ($log['stato'] == $status['success']['code']) {
$type = 'success';
$stato = $status['success']['message'];
} elseif ($log['stato'] == $status['disabled']['code']) {
$type = 'warning';
$stato = $status['disabled']['message'];
} elseif ($log['stato'] == $status['unauthorized']['code']) {
$type = 'warning';
$stato = $status['unauthorized']['message'];
} else {
$type = 'danger';
$stato = $status['failed']['message'];
}
$created_at = new Carbon($log['created_at']);
echo '
'.$log['username'].' |
'.$created_at->diffForHumans().' |
'.$log['ip'].' |
'.$log['user_agent'].' |
'.$stato.' |
';
}
echo '
';
?>