Add the session status to user logs

This commit is contained in:
FusionPBX 2024-09-02 23:42:52 -06:00 committed by GitHub
parent ffd0545a22
commit 452ddc9539
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 5 deletions

View File

@ -19,7 +19,6 @@
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'user_log_delete';
//$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
//User Logs
@ -80,6 +79,11 @@
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter the user agent.';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'session_id';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "insert_date";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2019-2021
Portions created by the Initial Developer are Copyright (C) 2019-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -63,8 +63,9 @@ if (!class_exists('user_logs')) {
* add user_logs
*/
public static function add($result) {
$array = [];
//prepare the array
$array = [];
$array['user_logs'][0]["timestamp"] = 'now()';
$array['user_logs'][0]["domain_uuid"] = $result['domain_uuid'];
$array['user_logs'][0]["user_uuid"] = $result['user_uuid'];
@ -72,6 +73,7 @@ if (!class_exists('user_logs')) {
$array['user_logs'][0]["type"] = 'login';
$array['user_logs'][0]["remote_address"] = $_SERVER['REMOTE_ADDR'];
$array['user_logs'][0]["user_agent"] = $_SERVER['HTTP_USER_AGENT'];
$array['user_logs'][0]["session_id"] = session_id();
$array['user_logs'][0]["type"] = 'login';
if ($result["authorized"] == "true") {
$array['user_logs'][0]["result"] = 'success';

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018 - 2023
Portions created by the Initial Developer are Copyright (C) 2018 - 2024
the Initial Developer. All Rights Reserved.
*/
@ -81,6 +81,9 @@
exit;
}
//get the session path
$session_path = session_save_path();
//get order and order by
$order_by = $_GET["order_by"] ?? null;
$order = $_GET["order"] ?? null;
@ -153,7 +156,8 @@
$sql .= "type, ";
$sql .= "result, ";
$sql .= "remote_address, ";
$sql .= "user_agent ";
$sql .= "user_agent, ";
$sql .= "session_id ";
$sql .= "from v_user_logs as u, v_domains as d ";
if (permission_exists('user_log_all') && $show == 'all') {
$sql .= "where true ";
@ -236,6 +240,7 @@
}
echo "<th class='left'>".$text['label-date']."</th>\n";
echo "<th class='left hide-md-dn'>".$text['label-time']."</th>\n";
echo "<th class='right'>".$text['label-status']."</th>\n";
echo th_order_by('username', $text['label-username'], $order_by, $order);
echo th_order_by('type', $text['label-type'], $order_by, $order);
echo th_order_by('result', $text['label-result'], $order_by, $order);
@ -246,6 +251,10 @@
if (!empty($user_logs) && is_array($user_logs) && @sizeof($user_logs) != 0) {
$x = 0;
foreach ($user_logs as $row) {
//check the session status
$session_file = 'sess_'.$row['session_id'];
$session_status = (!empty($row['session_id']) && file_exists($session_path.'/'.$session_file)) ? 'active' : 'inactive';
echo "<tr class='list-row'>\n";
if (permission_exists('user_log_delete')) {
echo " <td class='checkbox'>\n";
@ -258,6 +267,7 @@
}
echo " <td>".escape($row['date_formatted'])."</td>\n";
echo " <td class='left hide-md-dn'>".escape($row['time_formatted'])."</td>\n";
echo " <td><div class='list-status-".$session_status."'></div></td>\n";
echo " <td>".escape($row['username'])."</td>\n";
echo " <td>".escape($row['type'])."</td>\n";
echo " <td>".escape($row['result'])."</td>\n";

View File

@ -3230,6 +3230,22 @@ else { //default: white
white-space: nowrap;
}
.list-status-active {
width: 10px;
height: 10px;
background-color: green;
border-radius: 50%;
display: inline-block;
}
.list-status-inactive {
width: 10px;
height: 10px;
background-color: #ccc;
border-radius: 50%;
display: inline-block;
}
/* EDIT ********************************************************************************/
td.edit_delete_checkbox_all {