diff --git a/cp/app/Controllers/SystemController.php b/cp/app/Controllers/SystemController.php index 71ed603..6b1a3ac 100644 --- a/cp/app/Controllers/SystemController.php +++ b/cp/app/Controllers/SystemController.php @@ -191,7 +191,23 @@ class SystemController extends Controller $this->container->get('flash')->addMessage('error', 'Database failure: ' . $e->getMessage()); return $response->withHeader('Location', '/registry')->withStatus(302); } - + + $currentDateTime = new \DateTime(); + $currentDate = $currentDateTime->format('Y-m-d H:i:s.v'); // Current timestamp + $db->insert( + 'users_audit', + [ + 'user_id' => $_SESSION['auth_user_id'], + 'user_event' => 'settings.update', + 'user_resource' => 'control.panel', + 'user_agent' => $_SERVER['HTTP_USER_AGENT'], + 'user_ip' => get_client_ip(), + 'user_location' => get_client_location(), + 'event_time' => $currentDate, + 'user_data' => null + ] + ); + $this->container->get('flash')->addMessage('success', 'Registry details have been updated successfully'); return $response->withHeader('Location', '/registry')->withStatus(302); @@ -559,7 +575,23 @@ class SystemController extends Controller $this->container->get('flash')->addMessage('error', 'Database failure: ' . $e->getMessage()); return $response->withHeader('Location', '/registry/tld/create')->withStatus(302); } - + + $currentDateTime = new \DateTime(); + $currentDate = $currentDateTime->format('Y-m-d H:i:s.v'); // Current timestamp + $db->insert( + 'users_audit', + [ + 'user_id' => $_SESSION['auth_user_id'], + 'user_event' => 'tld.created', + 'user_resource' => 'control.panel', + 'user_agent' => $_SERVER['HTTP_USER_AGENT'], + 'user_ip' => get_client_ip(), + 'user_location' => get_client_location(), + 'event_time' => $currentDate, + 'user_data' => null + ] + ); + $this->container->get('flash')->addMessage('success', 'TLD ' . $data['extension'] . ' has been created successfully'); return $response->withHeader('Location', '/registry/tlds')->withStatus(302); } @@ -885,6 +917,22 @@ class SystemController extends Controller unset($_SESSION['u_tld_id']); unset($_SESSION['u_tld_extension']); + + $currentDateTime = new \DateTime(); + $currentDate = $currentDateTime->format('Y-m-d H:i:s.v'); // Current timestamp + $db->insert( + 'users_audit', + [ + 'user_id' => $_SESSION['auth_user_id'], + 'user_event' => 'tld.updated', + 'user_resource' => 'control.panel', + 'user_agent' => $_SERVER['HTTP_USER_AGENT'], + 'user_ip' => get_client_ip(), + 'user_location' => get_client_location(), + 'event_time' => $currentDate, + 'user_data' => null + ] + ); $this->container->get('flash')->addMessage('success', 'TLD ' . $tld_extension . ' has been updated successfully'); return $response->withHeader('Location', '/registry/tld/'.$tld_extension)->withStatus(302); @@ -1091,7 +1139,23 @@ class SystemController extends Controller $this->container->get('flash')->addMessage('error', 'Database failure: ' . $e->getMessage()); return $response->withHeader('Location', '/registry/reserved')->withStatus(302); } - + + $currentDateTime = new \DateTime(); + $currentDate = $currentDateTime->format('Y-m-d H:i:s.v'); // Current timestamp + $db->insert( + 'users_audit', + [ + 'user_id' => $_SESSION['auth_user_id'], + 'user_event' => 'reserved.updated', + 'user_resource' => 'control.panel', + 'user_agent' => $_SERVER['HTTP_USER_AGENT'], + 'user_ip' => get_client_ip(), + 'user_location' => get_client_location(), + 'event_time' => $currentDate, + 'user_data' => null + ] + ); + $this->container->get('flash')->addMessage('success', 'Reserved names have been updated successfully'); return $response->withHeader('Location', '/registry/reserved')->withStatus(302); diff --git a/cp/resources/views/partials/js-profile.twig b/cp/resources/views/partials/js-profile.twig index 021c932..4c0e573 100644 --- a/cp/resources/views/partials/js-profile.twig +++ b/cp/resources/views/partials/js-profile.twig @@ -143,11 +143,48 @@ placeholder: "{{ __('No log data for user.') }}", columns: [ {formatter:"responsiveCollapse", width:30, minWidth:30, hozAlign:"center", resizable:false, headerSort:false, responsive:0}, - {title: "{{ __('Event') }}", field: "user_event", minWidth:30, width:120, resizable:false, headerSort:false, responsive:0}, - {title: "{{ __('User Agent') }}", field: "user_agent", minWidth:30, width:500, resizable:false, headerSort:false, responsive:2}, - {title: "{{ __('IP') }}", field: "user_ip", minWidth:30, width:150, resizable:false, headerSort:false, responsive:0}, - {title: "{{ __('Location') }}", field: "user_location", minWidth:30, width:100, resizable:false, headerSort:false, responsive:0}, - {title: "{{ __('Timestamp') }}", field: "event_time", minWidth:30, width:250, resizable:false, headerSort:false, responsive:0}, + { + title: "{{ __('Event') }}", + field: "user_event", + minWidth: 30, + width: 120, + resizable: false, + headerSort: false, + responsive: 0, + formatter: function(cell) { + const value = cell.getValue(); + return `${value}`; + }, + }, + { + title: "{{ __('User Agent') }}", + field: "user_agent", + minWidth: 30, + width: 300, + resizable: false, + headerSort: false, + responsive: 2, + formatter: function(cell) { + const value = cell.getValue(); + return `${value}`; + }, + }, + {title: "{{ __('IP') }}", field: "user_ip", minWidth:30, width:120, resizable:false, headerSort:false, responsive:2}, + { + title: "{{ __('Location') }}", + field: "user_location", + minWidth: 30, + width: 100, + resizable: false, + headerSort: false, + responsive: 0, + formatter: function(cell) { + const countryCode = cell.getValue(); // Get the location code, e.g., "UA" + return ``; + }, + }, + {title: "{{ __('Timestamp') }}", field: "event_time", minWidth:30, width:250, resizable:false, headerSort:false, responsive:2}, + {title: "{{ __('User Log') }}", field: "user_data", minWidth:30, width:300, resizable:false, headerSort:false, responsive:0}, ] }); });