Aggiunta visualizzazione sessioni attive in stato dei servizi.

This commit is contained in:
Luca 2024-02-22 15:58:03 +01:00
parent 6da04b302e
commit 5334747609
7 changed files with 216 additions and 63 deletions

View File

@ -95,10 +95,10 @@ if (empty($record) || !$has_access) {
<h3 class="box-title"><i class="fa fa-warning"></i> '.tr('Attenzione!').'</h3> <h3 class="box-title"><i class="fa fa-warning"></i> '.tr('Attenzione!').'</h3>
</div> </div>
<div class="box-body"> <div class="box-body">
<p>'.tr('I seguenti utenti stanno visualizzando questa pagina').':</p> <p>'.tr('I seguenti utenti stanno consultando questa scheda').':</p>
<ul class="list"> <ul class="list">
</ul> </ul>
<p>'.tr('Prestare attenzione prima di effettuare modifiche, poichè queste potrebbero essere perse a causa di multipli salvataggi contemporanei').'.</p> <p>'.tr('Prestare attenzione prima di effettuare modifiche, poiché queste potrebbero essere perse a causa di una sovrascrittura delle informazioni').'.</p>
</div> </div>
</div>'; </div>';
} }

View File

@ -30,12 +30,46 @@ $modules = [
]; ];
$sapi_name = php_sapi_name(); $sapi_name = php_sapi_name();
if (strpos($sapi_name, 'apache') !== false) { if (strpos($sapi_name, 'apache') !== false) {
$apache_version = 'apache'; //PHP è in esecuzione come modulo Apache (4)
}elseif (strpos($sapi_name, 'fpm') !== false) { $php_interface = 'apache';
$apache_version = 'fpm'; }
}else { elseif (strpos($sapi, 'fpm-fcgi') !== false) {
//echo "Non è possibile determinare il tipo di interfaccia di PHP."; //PHP è in esecuzione come PHP-FPM FastCGI (3)
$php_interface = 'fpm-fcgi';
}
elseif (strpos($sapi_name, 'fpm') !== false) {
//PHP è in esecuzione come PHP-FPM (9)
$php_interface = 'fpm';
}
elseif (strpos($sapi, 'cgi-fcgi') !== false) {
//PHP è in esecuzione come FastCGI (8)
$php_interface = 'cgi-fcgi';
}
elseif (strpos($sapi, 'cgi') !== false) {
//PHP è in esecuzione come modulo CGI (2)
$php_interface = 'cgi';
}
elseif (strpos($sapi, 'cli') !== false) {
//PHP è in esecuzione dalla riga di comando (command line interface) (1)
$php_interface = 'cli';
}
elseif (strpos($sapi, 'embed') !== false) {
//PHP è incorporato in un'applicazione (5)
$php_interface = 'embed';
}
elseif (strpos($sapi, 'litespeed') !== false) {
//PHP è in esecuzione come modulo LiteSpeed (6)
$php_interface = 'litespeed';
}
elseif (strpos($sapi, 'isapi') !== false) {
//PHP è in esecuzione come modulo ISAPI in IIS (7)
$php_interface = 'isapi';
}
else {
//Non è possibile determinare il tipo di interfaccia di PHP (0)
$php_interface = 'n.d.';
} }
if (function_exists('apache_get_modules')) { if (function_exists('apache_get_modules')) {
@ -48,7 +82,7 @@ foreach ($modules as $name => $values) {
$status = isset($available_modules) ? in_array($name, $available_modules) : $_SERVER[$values['server']] == 'On'; $status = isset($available_modules) ? in_array($name, $available_modules) : $_SERVER[$values['server']] == 'On';
if ($name == 'mod_mime' && $apache_version == 'fpm' ){ if ($name == 'mod_mime' && $php_interface != 'apache' ){
$headers = get_headers( (!empty($config['redirectHTTPS']) && !isHTTPS(true))? 'https://' : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 1); $headers = get_headers( (!empty($config['redirectHTTPS']) && !isHTTPS(true))? 'https://' : 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 1);
if (isset($headers['Content-Type'])) { if (isset($headers['Content-Type'])) {
$status = 1; $status = 1;
@ -393,8 +427,8 @@ foreach ($config_to_check as $name => $values) {
} }
$requirements = [ $requirements = [
tr('Apache (_VERSION_)', [ tr('Apache (_INTERFACE_)', [
'_VERSION_' => $apache_version, '_INTERFACE_' => $php_interface,
]) => $apache, ]) => $apache,
tr('PHP (_VERSION_ _SUPPORTED_)', [ tr('PHP (_VERSION_ _SUPPORTED_)', [
'_VERSION_' => phpversion(), '_VERSION_' => phpversion(),

View File

@ -185,9 +185,61 @@ function search(button) {
<div class="row">'; <div class="row">';
//Verifiche di integrità
echo ' echo '
<div class="col-md-4"> <div class="col-md-4">
<div class="box box-success"> <div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">
'.tr("Verifica l'integrità dell'installazione").' <span class="tip" title="'.tr("Verifica l'integrità della tua installazione attraverso un controllo sui checksum dei file e sulla struttura del database").'."><i class="fa fa-question-circle-o"></i></span>
</h3>
</div>
<div class="box-body">
<button type="button" class="btn btn-primary btn-block" onclick="checksum(this)">
<i class="fa fa-list-alt"></i> '.tr('Controlla file').'
</button>
<button type="button" class="btn btn-info btn-block" onclick="database(this)">
<i class="fa fa-database"></i> '.tr('Controlla database').'
</button>
<button type="button" class="btn btn-block" onclick="controlli(this)">
<i class="fa fa-stethoscope"></i> '.tr('Controlla gestionale').'
</button>
</div>
</div>
</div>';
//Controllo automatico della presenza di aggiornamenti per il gestionale
echo '
<div class="col-md-4">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">
'.tr('Ricerca aggiornamenti').' <span class="tip" title="'.tr('Controllo automatico della presenza di aggiornamenti per il gestionale').'."><i class="fa fa-question-circle-o"></i></span>
</h3>
</div>
<div class="box-body" id="update-search">';
if (extension_loaded('curl')) {
echo ' <button type="button" class="btn btn-info btn-block" onclick="search(this)">
<i class="fa fa-search"></i> '.tr('Ricerca').'
</button>';
} else {
echo ' <button type="button" class="btn btn-warning btn-block disabled" >
<i class="fa fa-warning"></i> '.tr('Estensione curl non supportata').'.
</button>';
}
echo ' </div>
</div>
</div>';
//Form di caricamento aggiornamenti gestionale o moduli
echo '
<div class="col-md-4">
<div class="box box-primary">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title"> <h3 class="box-title">
'.tr('Carica aggiornamenti o nuovi moduli').' <span class="tip" title="'.tr('Form di caricamento aggiornamenti del gestionale e innesti di moduli e plugin').'."><i class="fa fa-question-circle-o"></i></span> '.tr('Carica aggiornamenti o nuovi moduli').' <span class="tip" title="'.tr('Form di caricamento aggiornamenti del gestionale e innesti di moduli e plugin').'."><i class="fa fa-question-circle-o"></i></span>
@ -227,54 +279,6 @@ echo '
</div> </div>
</div>'; </div>';
echo '
<div class="col-md-4">
<div class="box box-warning">
<div class="box-header with-border">
<h3 class="box-title">
'.tr("Verifica l'integrità dell'installazione").' <span class="tip" title="'.tr("Verifica l'integrità della tua installazione attraverso un controllo sui checksum dei file e sulla struttura del database").'."><i class="fa fa-question-circle-o"></i></span>
</h3>
</div>
<div class="box-body">
<button type="button" class="btn btn-primary btn-block" onclick="checksum(this)">
<i class="fa fa-list-alt"></i> '.tr('Controlla file').'
</button>
<button type="button" class="btn btn-info btn-block" onclick="database(this)">
<i class="fa fa-database"></i> '.tr('Controlla database').'
</button>
<button type="button" class="btn btn-block" onclick="controlli(this)">
<i class="fa fa-stethoscope"></i> '.tr('Controlla gestionale').'
</button>
</div>
</div>
</div>';
echo '
<div class="col-md-4">
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title">
'.tr('Ricerca aggiornamenti').' <span class="tip" title="'.tr('Controllo automatico della presenza di aggiornamenti per il gestionale').'."><i class="fa fa-question-circle-o"></i></span>
</h3>
</div>
<div class="box-body" id="update-search">';
if (extension_loaded('curl')) {
echo ' <button type="button" class="btn btn-info btn-block" onclick="search(this)">
<i class="fa fa-search"></i> '.tr('Ricerca').'
</button>';
} else {
echo ' <button type="button" class="btn btn-warning btn-block disabled" >
<i class="fa fa-warning"></i> '.tr('Estensione curl non supportata').'.
</button>';
}
echo ' </div>
</div>
</div>';
echo ' echo '
</div>'; </div>';

View File

@ -260,7 +260,7 @@ echo '
</div> </div>
</div>'; </div>';
// Widgets + Hooks // Widgets + Hooks + Sessioni
echo ' echo '
<div class="col-md-12 col-lg-6"> <div class="col-md-12 col-lg-6">
<div class="box box-info"> <div class="box box-info">
@ -285,8 +285,21 @@ echo '
</div> </div>
</div> </div>
<div class="box box-info">
<div class="box-header">
<h3 class="box-title">
'.tr('Sessioni attive negli ultimi _MINUTI_ minuti', ['_MINUTI_' => setting('Timeout notifica di presenza (minuti)')]).'
</h3>
</div>
<div class="box-body" id="sessioni">
</div>
</div>
</div> </div>
</div> </div>';
echo '
<script> <script>
@ -442,11 +455,23 @@ function caricaElencoHooks() {
}); });
} }
function caricaElencoSessioni() {
let container = $("#sessioni");
localLoading(container, true);
return $.get("'.$structure->fileurl('elenco-sessioni.php').'?id_module='.$id_module.'", function(data) {
container.html(data);
localLoading(container, false);
init();
});
}
$(document).ready(function() { $(document).ready(function() {
caricaElencoModuli(); caricaElencoModuli();
caricaElencoWidget(); caricaElencoWidget();
caricaElencoHooks(); caricaElencoHooks();
caricaElencoSessioni();
init(); init();
}); });

View File

@ -39,7 +39,7 @@ foreach ($gruppi as $modulo => $hooks) {
echo ' echo '
<thead> <thead>
<tr> <tr>
<th colspan="4">'.$modulo.'</th> <th colspan="4" class="text-center text-muted" >'.$modulo.'</th>
</tr> </tr>
</thead> </thead>

View File

@ -0,0 +1,90 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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/>.
*/
include_once __DIR__.'/../../core.php';
if (setting('Attiva notifica di presenza utenti sul record')){
echo '
<table class="table table-hover table-condensed">
<thead>
<tr>
<th>'.tr('Utente').'</th>
<th class="text-center">'.tr('Record').'</th>
<th class="text-center">'.tr('Data e ora accesso').'</th>
<th class="text-center">'.tr('Tempo trascorso').'</th>
<th class="text-center">'.tr('Permanenza').'</th>
</tr>
</thead>';
$sessioni = $dbo->fetchArray('SELECT zz_semaphores.*, SUBSTRING_INDEX(posizione, ",", -1) AS id_record, zz_modules.name AS modulo, TIMESTAMPDIFF(SECOND, zz_semaphores.created_at, zz_semaphores.updated_at) AS permanenza
FROM zz_semaphores
INNER JOIN zz_modules ON SUBSTRING_INDEX(posizione, ",", 1) = zz_modules.id
INNER JOIN zz_users ON zz_semaphores.id_utente = zz_users.id
ORDER BY `modulo` ASC, SUBSTRING_INDEX(posizione, ",", -1) ASC');
$gruppi = collect($sessioni)->groupBy('modulo');
foreach ($gruppi as $modulo => $sessioni) {
echo '
<thead>
<tr>
<th colspan="6" class="text-center text-muted" >'.$modulo.'</th>
</tr>
</thead>
<tbody>';
foreach ($sessioni as $sessione) {
$class ='info';
$utente = Models\User::find($sessione['id_utente']);
echo '
<tr class="'.$class.'" data-id="'.$sessione['id'].'" data-nome='.json_encode($sessione['name']).'>
<td>
'.(($utente->photo) ? "<img class='attachment-img tip' title=".$utente->nome_completo." src=".$utente->photo.">" : "<i class='fa fa-user-circle-o attachment-img tip' title=".$utente->nome_completo."></i>").'<span class="direct-chat-name"> '.$utente->nome_completo.'</span>
</td>
<td class="text-center">
'.$sessione['id_record'].'
</td>
<td class="text-center">
'.Translator::timestampToLocale($sessione['created_at']).'
</td>
<td class="text-center">
<span class="tip" title="'.Translator::timestampToLocale($sessione['updated_at']).'" >'.Carbon\Carbon::parse($sessione['updated_at'])->diffForHumans().'</span>
</td>
<td class="text-center">
<span class="tip" title="'.Translator::timestampToLocale($sessione['updated_at']).'" >'.gmdate('H:i:s', $sessione['permanenza']).'</span>
</td>
</tr>';
}
}
echo '
</tbody>
</table>';
}else{
echo '<span>Non è possibile monitorare la presenta degli utenti.</span>';
}

View File

@ -41,7 +41,7 @@ foreach ($gruppi as $modulo => $widgets) {
echo ' echo '
<thead> <thead>
<tr> <tr>
<th colspan="4">'.$modulo.'</th> <th colspan="4" class="text-center text-muted" >'.$modulo.'</th>
</tr> </tr>
</thead> </thead>