Update ActividadAdmin.php

This commit is contained in:
Lizandro Guarnizo
2026-04-08 09:16:53 -05:00
parent d38b5936ca
commit 485404814b
+10 -1
View File
@@ -48,6 +48,15 @@ class ActividadAdmin {
? json_encode($detalle, JSON_UNESCAPED_UNICODE)
: (string)($detalle ?? '');
// Resolver IP real del cliente (detrás de proxy/Coolify/Nginx)
$ip = null;
foreach (['HTTP_X_FORWARDED_FOR','HTTP_X_REAL_IP','HTTP_CF_CONNECTING_IP','REMOTE_ADDR'] as $h) {
if (!empty($_SERVER[$h])) {
$ip = trim(explode(',', $_SERVER[$h])[0]);
break;
}
}
return $this->db->insert('lab_actividad_admin', [
'admin_id' => $adminId,
'admin_nombre'=> $adminNombre,
@@ -55,7 +64,7 @@ class ActividadAdmin {
'accion' => $accion,
'entidad_id' => $entidadId,
'detalle' => $detalleStr,
'ip_address' => $_SERVER['REMOTE_ADDR'] ?? null,
'ip_address' => $ip,
'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? null,
]);
}