Add hostname to the user logs

This commit is contained in:
FusionPBX
2024-09-03 17:33:29 -06:00
committed by GitHub
parent cbb01cea1e
commit ad1b8fbabb
3 changed files with 12 additions and 1 deletions

View File

@@ -40,6 +40,10 @@
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains';
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'hostname';
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
$apps[$x]['db'][$y]['fields'][$z]['search_by'] = 'true';
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = 'timestamp';
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamptz';
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'date';

View File

@@ -70,6 +70,7 @@ if (!class_exists('user_logs')) {
$array['user_logs'][0]["domain_uuid"] = $result['domain_uuid'];
$array['user_logs'][0]["user_uuid"] = $result['user_uuid'];
$array['user_logs'][0]["username"] = $result['username'];
$array['user_logs'][0]["hostname"] = gethostname();
$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'];

View File

@@ -84,6 +84,9 @@
//get the session path
$session_path = session_save_path();
//get the server hostname
$hostname = gethostname();
//get order and order by
$order_by = $_GET["order_by"] ?? null;
$order = $_GET["order"] ?? null;
@@ -146,7 +149,8 @@
//get the list
$sql = "select ";
$sql .= "user_log_uuid, ";
$sql .= "u.user_log_uuid, ";
$sql .= "u.hostname, ";
$sql .= "u.domain_uuid, ";
$sql .= "d.domain_name, ";
$sql .= "to_char(timezone(:time_zone, timestamp), 'DD Mon YYYY') as date_formatted, ";
@@ -240,6 +244,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='shrink hide-md-dn'>".$text['label-hostname']."</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);
@@ -267,6 +272,7 @@
}
echo " <td>".escape($row['date_formatted'])."</td>\n";
echo " <td class='left hide-md-dn'>".escape($row['time_formatted'])."</td>\n";
echo " <td class='hide-md-dn'>".escape($row['hostname'])."</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";