diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index fa889f3071..4060fe8847 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -276,7 +276,7 @@ foreach ($timezones as $timezone) { } } -$table->data[$i][0] = __('Timezone setup'); +$table->data[$i][0] = __('Server Timezone setup'); $table->data[$i][1] = html_print_input_text_extended( 'timezone_text', $config['timezone'], diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index be845f3fc0..1df8fae13c 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -393,6 +393,10 @@ function process_user_login_remote($login, $pass, $api=false) $user_info['metaconsole_access_node'] = $config['ldap_adv_user_node']; } + if (isset($config['timezonevisual']) === true) { + $user_info['timezone'] = $config['timezonevisual']; + } + $permissions = fill_permissions_ldap($sr); if (empty($permissions) === true) { $config['auth_error'] = __('User not found in database or incorrect password'); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index b0d15d5cef..382e4354a4 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -561,6 +561,10 @@ function config_update_config() $error_update[] = __('Automatically assigned no hierarchy'); } + if (config_update_value('timezonevisual', (string) get_parameter('timezonevisual'), true) === false) { + $error_update[] = __('Automatically timezone visual'); + } + if (config_update_value('autocreate_blacklist', get_parameter('autocreate_blacklist'), true) === false) { $error_update[] = __('Autocreate blacklist'); } diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 3740257717..2e6e836286 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -4235,12 +4235,53 @@ function events_page_details($event, $server_id=0) $data = []; $data[0] = '
'.__('Last contact').'
'; - $data[1] = ($agent['ultimo_contacto'] == '1970-01-01 00:00:00') ? ''.__('N/A').'' : ui_print_timestamp($agent['ultimo_contacto'], true); + + $user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone']; + if (!$user_timezone) { + $timezone = timezone_open(date_default_timezone_get()); + $datetime_eur = date_create('now', timezone_open($config['timezone'])); + $dif = timezone_offset_get($timezone, $datetime_eur); + date($config['date_format'], $dif); + if (!date('I')) { + // For summer -3600sec. + $dif -= 3600; + } + + $total_sec = strtotime($agent['ultimo_contacto']); + $total_sec += $dif; + $last_contact = date($config['date_format'], $total_sec); + $last_contact_value = ui_print_timestamp($last_contact, true); + } else { + $user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone']; + date_default_timezone_set($user_timezone); + + $last_contact_value = human_time_comparation(strtotime($agent['ultimo_contacto']), 'large'); + } + + $data[1] = ($agent['ultimo_contacto'] == '1970-01-01 00:00:00') ? ''.__('N/A').'' : $last_contact_value; $table_details->data[] = $data; + $user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone']; + if (!$user_timezone) { + $timezone = timezone_open(date_default_timezone_get()); + $datetime_eur = date_create('now', timezone_open($config['timezone'])); + $dif = timezone_offset_get($timezone, $datetime_eur); + date($config['date_format'], $dif); + if (!date('I')) { + // For summer -3600sec. + $dif -= 3600; + } + + $total_sec = strtotime($agent['ultimo_contacto_remoto']); + $total_sec += $dif; + $lr_contact = date($config['date_format'], $total_sec); + } else { + $lr_contact = date($config['date_format'], strtotime($agent['ultimo_contacto_remoto'])); + } + $data = []; $data[0] = '
'.__('Last remote contact').'
'; - $data[1] = ($agent['ultimo_contacto_remoto'] == '1970-01-01 00:00:00') ? ''.__('N/A').'' : date_w_fixed_tz($agent['ultimo_contacto_remoto']); + $data[1] = ($agent['ultimo_contacto_remoto'] == '1970-01-01 00:00:00') ? ''.__('N/A').'' : $lr_contact; $table_details->data[] = $data; $data = []; @@ -4729,6 +4770,13 @@ function events_page_general($event) $data[1] .= __('Last event').': '; $data[1] .= date($config['date_format'], $event['timestamp_last']); } else { + $user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone']; + if ($user_timezone) { + date_default_timezone_set($user_timezone); + } else { + date_default_timezone_set($config['timezone']); + } + $data[1] = date($config['date_format'], $event['utimestamp']); } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 6777ced4c3..23b8794b5c 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -527,10 +527,31 @@ if (is_ajax() === true) { (empty($tmp->ack_utimestamp) === true) ? 0 : $tmp->ack_utimestamp, true ); - $tmp->timestamp = ui_print_timestamp( - $tmp->timestamp, - true - ); + + $user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone']; + if (!$user_timezone) { + $timezone = timezone_open(date_default_timezone_get()); + $datetime_eur = date_create('now', timezone_open($config['timezone'])); + $dif = timezone_offset_get($timezone, $datetime_eur); + date($config['date_format'], $dif); + if (!date('I')) { + // For summer -3600sec. + $dif -= 3600; + } + + $total_sec = strtotime($tmp->timestamp); + $total_sec += $dif; + $last_contact = date($config['date_format'], $total_sec); + $last_contact_value = ui_print_timestamp($last_contact, true); + } else { + $user_timezone = users_get_user_by_id($_SESSION['id_usuario'])['timezone']; + date_default_timezone_set($user_timezone); + $title = date($config['date_format'], strtotime($tmp->timestamp)); + $value = human_time_comparation(strtotime($tmp->timestamp), 'large'); + $last_contact_value = ''.$value.''; + } + + $tmp->timestamp = $last_contact_value; if (is_numeric($tmp->data) === true) { $tmp->data = format_numeric(