" . __('Type Periodicity:') . " ".
html_print_select(array(
@@ -1226,7 +1231,7 @@ ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascri
// Warning message about the problems caused updating a past planned downtime
var type_execution = "";
var datetime_from = ;
- var datetime_now = ;
+ var datetime_now = ;
var create = ;
if (!create && (type_execution == 'periodically' || (type_execution == 'once' && datetime_from < datetime_now))) {
$("input#submit-updbutton, input#submit-add_item, table#list a").click(function (e) {
diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php
index 8bf72aa53a..5fc232490a 100644
--- a/pandora_console/godmode/alerts/configure_alert_template.php
+++ b/pandora_console/godmode/alerts/configure_alert_template.php
@@ -782,6 +782,10 @@ else {
}
}
+if ($step == 2) {
+ echo ui_get_using_system_timezone_warning();
+}
+
/* If it's the last step it will redirect to template lists */
if ($step >= LAST_STEP) {
echo ' |
+
diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php
index 04481885a2..eaeb612826 100644
--- a/pandora_console/godmode/servers/servers.build_table.php
+++ b/pandora_console/godmode/servers/servers.build_table.php
@@ -87,7 +87,7 @@ foreach ($servers as $server) {
//Status
$data[1] = ui_print_status_image (STATUS_SERVER_OK, '', true);
- if (($server['status'] == 0) || (($date - strtotime($server['keepalive'])) > ($server['server_keepalive'])*2)) {
+ if (($server['status'] == 0) || (($date - time_w_fixed_tz($server['keepalive'])) > ($server['server_keepalive'])*2)) {
$data[1] = ui_print_status_image (STATUS_SERVER_DOWN, '', true);
}
diff --git a/pandora_console/godmode/setup/news.php b/pandora_console/godmode/setup/news.php
index 7f6e251d00..f32cdaa410 100644
--- a/pandora_console/godmode/setup/news.php
+++ b/pandora_console/godmode/setup/news.php
@@ -36,10 +36,11 @@ if (isset ($_POST["create"])) { // If create
$id_group = get_parameter ("id_group");
$modal = get_parameter ("modal");
$expire = get_parameter ("expire");
- $expire_date = get_parameter ("expire_date");
- $expire_date = date('Y-m-d', strtotime($expire_date));
- $expire_time = get_parameter ("expire_time");
- $expire_timestamp = "$expire_date $expire_time";
+ $expire_date = get_parameter("expire_date");
+ $expire_time = get_parameter("expire_time");
+ // Change the user's timezone to the system's timezone
+ $expire_timestamp = strtotime("$expire_date $expire_time") - get_fixed_offset();
+ $expire_timestamp = date("Y-m-d H:i:s", $expire_timestamp);
$values = array('subject' => $subject,
'text' => $text,
@@ -64,10 +65,11 @@ if (isset ($_POST["update"])) { // if update
$id_group = get_parameter ("id_group");
$modal = get_parameter ("modal");
$expire = get_parameter ("expire");
- $expire_date = get_parameter ("expire_date");
- $expire_date = date('Y-m-d', strtotime($expire_date));
- $expire_time = get_parameter ("expire_time");
- $expire_timestamp = "$expire_date $expire_time";
+ $expire_date = get_parameter("expire_date");
+ $expire_time = get_parameter("expire_time");
+ // Change the user's timezone to the system's timezone
+ $expire_timestamp = strtotime("$expire_date $expire_time") - get_fixed_offset();
+ $expire_timestamp = date("Y-m-d H:i:s", $expire_timestamp);
//NOW() column exists in any table and always displays the current date and time, so let's get the value from a row in a table which can't be deleted.
//This way we prevent getting no value for this variable
@@ -117,10 +119,10 @@ if ((isset ($_GET["form_add"])) || (isset ($_GET["form_edit"]))) {
if ($expire) {
$expire_timestamp = $result["expire_timestamp"];
- $expire_utimestamp = strtotime($expire_timestamp);
+ $expire_utimestamp = time_w_fixed_tz($expire_timestamp);
}
else {
- $expire_utimestamp = time() + SECONDS_1WEEK;
+ $expire_utimestamp = get_system_time() + SECONDS_1WEEK;
}
$expire_date = date('Y/m/d', $expire_utimestamp);
@@ -138,8 +140,8 @@ if ((isset ($_GET["form_add"])) || (isset ($_GET["form_edit"]))) {
$id_group = 0;
$modal = 0;
$expire = 0;
- $expire_date = date('Y/m/d', time() + SECONDS_1WEEK);
- $expire_time = date('H:i:s', time());
+ $expire_date = date('Y/m/d', get_system_time() + SECONDS_1WEEK);
+ $expire_time = date('H:i:s', get_system_time());
}
// Create news
@@ -246,10 +248,10 @@ else {
}
echo " | ".$row["author"]." | ";
- $utimestamp = strtotime($row["timestamp"]);
- echo "" . date($config['date_format'], strtotime($row["timestamp"])) . " | ";
+ $utimestamp = time_w_fixed_tz($row["timestamp"]);
+ echo "" . date($config['date_format'], $utimestamp) . " | ";
if ($row["expire"]) {
- $expire_utimestamp = strtotime($row["expire_timestamp"]);
+ $expire_utimestamp = time_w_fixed_tz($row["expire_timestamp"]);
$expire_in_secs = $expire_utimestamp - $utimestamp;
if( $expire_in_secs <= 0) {
diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php
index eb89c22389..df5d1a729f 100644
--- a/pandora_console/godmode/users/configure_user.php
+++ b/pandora_console/godmode/users/configure_user.php
@@ -126,6 +126,7 @@ if ($new_user && $config['admin_can_add_user']) {
$user_info['comments'] = '';
$user_info['is_admin'] = 0;
$user_info['language'] = 'default';
+ $user_info['timezone'] = '';
$user_info["not_login"] = false;
$user_info["strict_acl"] = false;
$user_info["session_time"] = 0;
@@ -164,6 +165,7 @@ if ($create_user) {
$values['comments'] = (string) get_parameter ('comments');
$values['is_admin'] = (int) get_parameter ('is_admin', 0);
$values['language'] = get_parameter ('language', 'default');
+ $values['timezone'] = (string) get_parameter('timezone');
$values['default_event_filter'] = (int) get_parameter('default_event_filter');
$dashboard = get_parameter('dashboard', '');
$visual_console = get_parameter('visual_console', '');
@@ -222,7 +224,7 @@ if ($create_user) {
}
else {
$info =
- '{"Id_user":"' . $values['id_user'] . '","FullName":"' . $values['fullname'] . '","Firstname":"'. $values['firstname'] .'","Lastname":"'. $values['lastname'] . '","Email":"' . $values['email'] . '","Phone":"' . $values['phone'] . '","Comments":"' . $values['comments'] .'","Is_admin":"' . $values['is_admin'] .'","Language":"' . $values['language'] . '","Block size":"' . $values['block_size'] . '","Interactive Charts":"' . $values['flash_chart'].'"';
+ '{"Id_user":"' . $values['id_user'] . '","FullName":"' . $values['fullname'] . '","Firstname":"'. $values['firstname'] .'","Lastname":"'. $values['lastname'] . '","Email":"' . $values['email'] . '","Phone":"' . $values['phone'] . '","Comments":"' . $values['comments'] .'","Is_admin":"' . $values['is_admin'] .'","Language":"' . $values['language'] .'","Timezone":"' . $values['timezone'] . '","Block size":"' . $values['block_size'] . '","Interactive Charts":"' . $values['flash_chart'].'"';
if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
$info .= ',"Skin":"' . $values['id_skin'].'"}';
@@ -287,6 +289,7 @@ if ($update_user) {
$values['comments'] = (string) get_parameter ('comments');
$values['is_admin'] = get_parameter ('is_admin', 0 );
$values['language'] = (string) get_parameter ('language');
+ $values['timezone'] = (string) get_parameter('timezone');
$values['default_event_filter'] = (int) get_parameter('default_event_filter');
$dashboard = get_parameter('dashboard', '');
$visual_console = get_parameter('visual_console', '');
@@ -376,6 +379,7 @@ if ($update_user) {
"Comments":"' . $values['comments'] . '",
"Is_admin":"' . $values['is_admin'] . '",
"Language":"' . $values['language'] . '",
+ "Timezone":"' . $values['timezone'] . '",
"Block size":"' . $values['block_size'] . '",
"Flash Chats":"' . $values['flash_chart'] . '",
"Section":"' . $values['section'].'"';
@@ -522,6 +526,9 @@ $table->data[2][0] = __('Language');
$table->data[2][1] = html_print_select_from_sql ('SELECT id_language, name FROM tlanguage',
'language', $user_info['language'], '', __('Default'), 'default', true);
+$table->data[3][0] = __('Timezone');
+$table->data[3][1] = html_print_timezone_select("timezone", $user_info["timezone"]);
+
if ($config['user_can_update_password']) {
$table->data[4][0] = __('Password');
$table->data[4][1] = html_print_input_text_extended ('password_new', '', '', '',
diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php
index a98d65ed1e..d0089fdcef 100755
--- a/pandora_console/include/ajax/module.php
+++ b/pandora_console/include/ajax/module.php
@@ -118,13 +118,14 @@ if ($get_module_detail) {
$conexion = false;
}
- $selection_mode = get_parameter('selection_mode', 'fromnow');
- $date_from = (string) get_parameter ('date_from', date ('Y-m-j'));
- $time_from = (string) get_parameter ('time_from', date ('h:iA'));
- $date_to = (string) get_parameter ('date_to', date ('Y-m-j'));
- $time_to = (string) get_parameter ('time_to', date ('h:iA'));
$freesearch = (string) get_parameter ('freesearch', '');
$free_checkbox = (bool) get_parameter ('free_checkbox', false);
+ $selection_mode = get_parameter('selection_mode', 'fromnow');
+ $utimestamp = get_system_time();
+ $date_from = (string) get_parameter ('date_from', date(DATE_FORMAT, $utimestamp - SECONDS_1DAY));
+ $time_from = (string) get_parameter ('time_from', date(TIME_FORMAT, $utimestamp - SECONDS_1DAY));
+ $date_to = (string) get_parameter ('date_to', date(DATE_FORMAT, $utimestamp));
+ $time_to = (string) get_parameter ('time_to', date(TIME_FORMAT, $utimestamp));
$formtable->width = '98%';
$formtable->class = "databox";
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index 3918da045e..67ecef2ee6 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -313,7 +313,7 @@ function human_time_comparation ($timestamp, $units = 'large') {
global $config;
if (!is_numeric ($timestamp)) {
- $timestamp = strtotime ($timestamp);
+ $timestamp = time_w_fixed_tz($timestamp);
}
$seconds = get_system_time () - $timestamp;
@@ -2371,7 +2371,11 @@ function print_audit_csv ($data) {
__('Source IP') . ';' .
__('Comments') ."\n";
foreach ($data as $line) {
- echo io_safe_output($line['id_usuario']) . ';' . io_safe_output($line['accion']) . ';' . $line['fecha'] . ';' . $line['ip_origen'] . ';'. io_safe_output($line['descripcion']). "\n";
+ echo io_safe_output($line['id_usuario']) . ';'
+ . io_safe_output($line['accion']) . ';'
+ . date($config["date_format"], $line['utimestamp']) . ';'
+ . $line['ip_origen'] . ';'
+ . io_safe_output($line['descripcion']). "\n";
}
exit;
@@ -2824,6 +2828,62 @@ function validate_address($address){
return true;
}
+/**
+ * Used to get the offset in seconds to the UTC date.
+ *
+ * @param string Timezone identifier.
+ */
+function get_utc_offset ($timezone) {
+ if (empty($timezone)) return 0;
+
+ $dtz = new DateTimeZone($timezone);
+ $dt = new DateTime("now", $dtz);
+
+ return $dtz->getOffset($dt);
+}
+
+function get_system_utc_offset () {
+ global $config;
+ return get_utc_offset($config["timezone"]);
+}
+
+function get_current_utc_offset () {
+ return get_utc_offset(date_default_timezone_get());
+}
+
+function get_fixed_offset () {
+ return get_current_utc_offset() - get_system_utc_offset();
+}
+
+/**
+ * Used to transform the dates without timezone information (like '2018/05/23 10:10:10')
+ * to a unix timestamp compatible with the user custom timezone.
+ *
+ * @param string Date without timezone information.
+ * @param number Offset between the date timezone and the user's default timezone.
+ */
+function time_w_fixed_tz ($date, $timezone_offset = null) {
+ if ($timezone_offset === null) $timezone_offset = get_fixed_offset();
+
+ return strtotime($date) + $timezone_offset;
+}
+
+/**
+ * Used to transform the dates without timezone information (like '2018/05/23 10:10:10')
+ * to a date compatible with the user custom timezone.
+ *
+ * @param string Date without timezone information.
+ * @param string Date format.
+ * @param number Offset between the date timezone and the user's default timezone.
+ */
+function date_w_fixed_tz ($date, $format = null, $timezone_offset = null) {
+ global $config;
+
+ if ($format === null) $format = $config["date_format"];
+
+ return date($format, time_w_fixed_tz($date, $timezone_offset));
+}
+
function color_graph_array(){
global $config;
@@ -3217,4 +3277,5 @@ function get_copyright_notice () {
}
return $stored_name;
}
+
?>
diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php
index 80228a68a3..e084c16381 100644
--- a/pandora_console/include/functions_agents.php
+++ b/pandora_console/include/functions_agents.php
@@ -697,20 +697,13 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co
}
function agents_get_next_contact($idAgent, $maxModules = false) {
- $agent = db_get_row_sql("SELECT *
- FROM tagente
- WHERE id_agente = " . $idAgent);
+ $agent = db_get_row("tagente", "id_agente", $idAgent);
+ $last_contact = time_w_fixed_tz($agent["ultimo_contacto"]);
+ $difference = time() - $last_contact;
-
- $difference = get_system_time () - strtotime ($agent["ultimo_contacto"]);
-
-
- if ($agent["intervalo"] > 0 && strtotime($agent["ultimo_contacto"]) > 0) {
- return round ($difference / ($agent["intervalo"] / 100));
- }
- else {
- return 0;
- }
+ return ($agent["intervalo"] > 0 && $last_contact > 0)
+ ? round ($difference / ($agent["intervalo"] / 100))
+ : 0;
}
/**
@@ -1454,7 +1447,7 @@ function agents_get_interval ($id_agent) {
function agents_get_interval_status ($agent) {
$return = '';
- $last_time = strtotime ($agent["ultimo_contacto"]);
+ $last_time = time_w_fixed_tz($agent["ultimo_contacto"]);
$now = time ();
$diferencia = $now - $last_time;
$time = ui_print_timestamp ($last_time, true, array('style' => 'font-size:6.5pt'));
diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php
index 6c1938e4d8..3e3d424227 100644
--- a/pandora_console/include/functions_alerts.php
+++ b/pandora_console/include/functions_alerts.php
@@ -1603,10 +1603,10 @@ function get_alert_type ($id_type) {
*/
function get_agent_alert_fired ($id_agent, $id_alert, $period, $date = 0) {
if (!is_numeric ($date)) {
- $date = strtotime ($date);
+ $date = time_w_fixed_tz($date);
}
if (empty ($date)) {
- $date = get_system_time ();
+ $date = get_system_time();
}
$datelimit = $date - $period;
@@ -1635,10 +1635,10 @@ function get_agent_alert_fired ($id_agent, $id_alert, $period, $date = 0) {
function get_module_alert_fired ($id_agent_module, $id_alert, $period, $date = 0) {
if (!is_numeric ($date)) {
- $date = strtotime ($date);
+ $date = time_w_fixed_tz($date);
}
if (empty ($date)) {
- $date = get_system_time ();
+ $date = get_system_time();
}
$datelimit = $date - $period;
diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php
index 3fa323b3f0..309bb9b215 100644
--- a/pandora_console/include/functions_api.php
+++ b/pandora_console/include/functions_api.php
@@ -5027,9 +5027,7 @@ function api_set_stop_downtime($id, $thrash1, $other, $thrash3) {
return;
}
- $date_stop = date ("Y-m-j",get_system_time ());
- $time_stop = date ("h:iA",get_system_time ());
- $date_time_stop = strtotime ($date_stop.' '.$time_stop);
+ $date_time_stop = get_system_time();
$values = array();
$values['date_to'] = $date_time_stop;
diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php
index a33862889a..5e4ad2041a 100644
--- a/pandora_console/include/functions_events.php
+++ b/pandora_console/include/functions_events.php
@@ -1275,7 +1275,7 @@ function events_get_agent ($id_agent, $period, $date = 0,
global $config;
if (!is_numeric ($date)) {
- $date = strtotime ($date);
+ $date = time_w_fixed_tz($date);
}
if (empty ($date)) {
$date = get_system_time ();
@@ -1922,7 +1922,7 @@ function events_get_response_target($event_id, $response_id, $server_id, $histor
if (strpos($target, '_event_date_') !== false) {
$target = str_replace(
'_event_date_',
- date ($config["date_format"], strtotime($event["timestamp"])),
+ date ($config["date_format"], $event["utimestamp"]),
$target
);
}
@@ -2155,12 +2155,12 @@ function events_page_details ($event, $server = "") {
$data = array();
$data[0] = ''.__('Last contact').' ';
- $data[1] = $agent["ultimo_contacto"] == "1970-01-01 00:00:00" ? ''.__('N/A').'' : $agent["ultimo_contacto"];
+ $data[1] = $agent["ultimo_contacto"] == "1970-01-01 00:00:00" ? ''.__('N/A').'' : date_w_fixed_tz($agent["ultimo_contacto"]);
$table_details->data[] = $data;
$data = array();
$data[0] = ''.__('Last remote contact').' ';
- $data[1] = $agent["ultimo_contacto_remoto"] == "1970-01-01 00:00:00" ? ''.__('N/A').'' : $agent["ultimo_contacto_remoto"];
+ $data[1] = $agent["ultimo_contacto_remoto"] == "1970-01-01 00:00:00" ? ''.__('N/A').'' : date_w_fixed_tz($agent["ultimo_contacto_remoto"]);
$table_details->data[] = $data;
$data = array();
@@ -2469,11 +2469,12 @@ function events_page_general ($event) {
$data = array();
$data[0] = __('Timestamp');
+
if ($group_rep == 1 && $event["event_rep"] > 1) {
$data[1] = __('First event').': '.date ($config["date_format"], $event['timestamp_first']).' '.__('Last event').': '.date ($config["date_format"], $event['timestamp_last']);
}
else {
- $data[1] = date ($config["date_format"], strtotime($event["timestamp"]));
+ $data[1] = date ($config["date_format"], $event["utimestamp"]);
}
$table_general->data[] = $data;
@@ -2717,7 +2718,7 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
//date
if (!is_numeric ($date)) {
- $date = strtotime ($date);
+ $date = time_w_fixed_tz($date);
}
if (empty ($date)) {
$date = get_system_time ();
@@ -2872,7 +2873,7 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
//date
if (!is_numeric ($date)) {
- $date = strtotime ($date);
+ $date = time_w_fixed_tz($date);
}
if (empty ($date)) {
$date = get_system_time ();
@@ -3017,7 +3018,7 @@ function events_get_count_events_by_criticity ($filter, $period, $date,
}
if (!is_numeric ($date)) {
- $date = strtotime ($date);
+ $date = time_w_fixed_tz($date);
}
if (empty ($date)) {
$date = get_system_time ();
@@ -3159,7 +3160,7 @@ function events_get_count_events_validated ($filter, $period = null, $date = nul
//date
if (!is_numeric ($date)) {
- $date = strtotime ($date);
+ $date = time_w_fixed_tz($date);
}
if (empty ($date)) {
$date = get_system_time ();
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index 04cd81e0dd..a941a96790 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -2336,4 +2336,130 @@ function html_print_autocomplete_modules($name = 'module',
echo $output;
}
}
+
+/**
+ * @param string Select form name
+ * @param string Current selected value
+ *
+ * @return string HTML code
+ */
+function html_print_timezone_select ($name, $selected = "") {
+ $timezones = array(
+ "Pacific/Midway" => "(GMT-11:00) " . __("Midway Island"),
+ "US/Samoa" => "(GMT-11:00) " . __("Samoa"),
+ "US/Hawaii" => "(GMT-10:00) " . __("Hawaii"),
+ "US/Alaska" => "(GMT-09:00) " . __("Alaska"),
+ "US/Pacific" => "(GMT-08:00) " . __("Pacific Time (US & Canada)"),
+ "America/Tijuana" => "(GMT-08:00) " . __("Tijuana"),
+ "US/Arizona" => "(GMT-07:00) " . __("Arizona"),
+ "US/Mountain" => "(GMT-07:00) " . __("Mountain Time (US & Canada)"),
+ "America/Chihuahua" => "(GMT-07:00) " . __("Chihuahua"),
+ "America/Mazatlan" => "(GMT-07:00) " . __("Mazatlan"),
+ "America/Mexico_City" => "(GMT-06:00) " . __("Mexico City"),
+ "America/Monterrey" => "(GMT-06:00) " . __("Monterrey"),
+ "Canada/Saskatchewan" => "(GMT-06:00) " . __("Saskatchewan"),
+ "US/Central" => "(GMT-06:00) " . __("Central Time (US & Canada)"),
+ "US/Eastern" => "(GMT-05:00) " . __("Eastern Time (US & Canada)"),
+ "US/East-Indiana" => "(GMT-05:00) " . __("Indiana (East)"),
+ "America/Bogota" => "(GMT-05:00) " . __("Bogota"),
+ "America/Lima" => "(GMT-05:00) " . __("Lima"),
+ "America/Caracas" => "(GMT-04:30) " . __("Caracas"),
+ "Canada/Atlantic" => "(GMT-04:00) " . __("Atlantic Time (Canada)"),
+ "America/La_Paz" => "(GMT-04:00) " . __("La Paz"),
+ "America/Santiago" => "(GMT-04:00) " . __("Santiago"),
+ "Canada/Newfoundland" => "(GMT-03:30) " . __("Newfoundland"),
+ "America/Buenos_Aires" => "(GMT-03:00) " . __("Buenos Aires"),
+ "Greenland'" => "(GMT-03:00) " . __("Greenland"),
+ "Atlantic/Stanley" => "(GMT-02:00) " . __("Stanley"),
+ "Atlantic/Azores" => "(GMT-01:00) " . __("Azores"),
+ "Atlantic/Cape_Verde" => "(GMT-01:00) " . __("Cape Verde Is."),
+ "Africa/Casablanca" => "(GMT+00:00) " . __("Casablanca"),
+ "Europe/Dublin" => "(GMT+00:00) " . __("Dublin"),
+ "Europe/Lisbon" => "(GMT+00:00) " . __("Lisbon"),
+ "Europe/London" => "(GMT+00:00) " . __("London"),
+ "Africa/Monrovia" => "(GMT+00:00) " . __("Monrovia"),
+ "Europe/Amsterdam" => "(GMT+01:00) " . __("Amsterdam"),
+ "Europe/Belgrade" => "(GMT+01:00) " . __("Belgrade"),
+ "Europe/Berlin" => "(GMT+01:00) " . __("Berlin"),
+ "Europe/Bratislava" => "(GMT+01:00) " . __("Bratislava"),
+ "Europe/Brussels" => "(GMT+01:00) " . __("Brussels"),
+ "Europe/Budapest" => "(GMT+01:00) " . __("Budapest"),
+ "Europe/Copenhagen" => "(GMT+01:00) " . __("Copenhagen"),
+ "Europe/Ljubljana" => "(GMT+01:00) " . __("Ljubljana"),
+ "Europe/Madrid" => "(GMT+01:00) " . __("Madrid"),
+ "Europe/Paris" => "(GMT+01:00) " . __("Paris"),
+ "Europe/Prague" => "(GMT+01:00) " . __("Prague"),
+ "Europe/Rome" => "(GMT+01:00) " . __("Rome"),
+ "Europe/Sarajevo" => "(GMT+01:00) " . __("Sarajevo"),
+ "Europe/Skopje" => "(GMT+01:00) " . __("Skopje"),
+ "Europe/Stockholm" => "(GMT+01:00) " . __("Stockholm"),
+ "Europe/Vienna" => "(GMT+01:00) " . __("Vienna"),
+ "Europe/Warsaw" => "(GMT+01:00) " . __("Warsaw"),
+ "Europe/Zagreb" => "(GMT+01:00) " . __("Zagreb"),
+ "Europe/Athens" => "(GMT+02:00) " . __("Athens"),
+ "Europe/Bucharest" => "(GMT+02:00) " . __("Bucharest"),
+ "Africa/Cairo" => "(GMT+02:00) " . __("Cairo"),
+ "Africa/Harare" => "(GMT+02:00) " . __("Harare"),
+ "Europe/Helsinki" => "(GMT+02:00) " . __("Helsinki"),
+ "Europe/Istanbul" => "(GMT+02:00) " . __("Istanbul"),
+ "Asia/Jerusalem" => "(GMT+02:00) " . __("Jerusalem"),
+ "Europe/Kiev" => "(GMT+02:00) " . __("Kyiv"),
+ "Europe/Minsk" => "(GMT+02:00) " . __("Minsk"),
+ "Europe/Riga" => "(GMT+02:00) " . __("Riga"),
+ "Europe/Sofia" => "(GMT+02:00) " . __("Sofia"),
+ "Europe/Tallinn" => "(GMT+02:00) " . __("Tallinn"),
+ "Europe/Vilnius" => "(GMT+02:00) " . __("Vilnius"),
+ "Asia/Baghdad" => "(GMT+03:00) " . __("Baghdad"),
+ "Asia/Kuwait" => "(GMT+03:00) " . __("Kuwait"),
+ "Africa/Nairobi" => "(GMT+03:00) " . __("Nairobi"),
+ "Asia/Riyadh" => "(GMT+03:00) " . __("Riyadh"),
+ "Europe/Moscow" => "(GMT+03:00) " . __("Moscow"),
+ "Asia/Tehran" => "(GMT+03:30) " . __("Tehran"),
+ "Asia/Baku" => "(GMT+04:00) " . __("Baku"),
+ "Europe/Volgograd" => "(GMT+04:00) " . __("Volgograd"),
+ "Asia/Muscat" => "(GMT+04:00) " . __("Muscat"),
+ "Asia/Tbilisi" => "(GMT+04:00) " . __("Tbilisi"),
+ "Asia/Yerevan" => "(GMT+04:00) " . __("Yerevan"),
+ "Asia/Kabul" => "(GMT+04:30) " . __("Kabul"),
+ "Asia/Karachi" => "(GMT+05:00) " . __("Karachi"),
+ "Asia/Tashkent" => "(GMT+05:00) " . __("Tashkent"),
+ "Asia/Kolkata" => "(GMT+05:30) " . __("Kolkata"),
+ "Asia/Kathmandu" => "(GMT+05:45) " . __("Kathmandu"),
+ "Asia/Yekaterinburg" => "(GMT+06:00) " . __("Ekaterinburg"),
+ "Asia/Almaty" => "(GMT+06:00) " . __("Almaty"),
+ "Asia/Dhaka" => "(GMT+06:00) " . __("Dhaka"),
+ "Asia/Novosibirsk" => "(GMT+07:00) " . __("Novosibirsk"),
+ "Asia/Bangkok" => "(GMT+07:00) " . __("Bangkok"),
+ "Asia/Jakarta" => "(GMT+07:00) " . __("Jakarta"),
+ "Asia/Krasnoyarsk" => "(GMT+08:00) " . __("Krasnoyarsk"),
+ "Asia/Chongqing" => "(GMT+08:00) " . __("Chongqing"),
+ "Asia/Hong_Kong" => "(GMT+08:00) " . __("Hong Kong"),
+ "Asia/Kuala_Lumpur" => "(GMT+08:00) " . __("Kuala Lumpur"),
+ "Australia/Perth" => "(GMT+08:00) " . __("Perth"),
+ "Asia/Singapore" => "(GMT+08:00) " . __("Singapore"),
+ "Asia/Taipei" => "(GMT+08:00) " . __("Taipei"),
+ "Asia/Ulaanbaatar" => "(GMT+08:00) " . __("Ulaan Bataar"),
+ "Asia/Urumqi" => "(GMT+08:00) " . __("Urumqi"),
+ "Asia/Irkutsk" => "(GMT+09:00) " . __("Irkutsk"),
+ "Asia/Seoul" => "(GMT+09:00) " . __("Seoul"),
+ "Asia/Tokyo" => "(GMT+09:00) " . __("Tokyo"),
+ "Australia/Adelaide" => "(GMT+09:30) " . __("Adelaide"),
+ "Australia/Darwin" => "(GMT+09:30) " . __("Darwin"),
+ "Asia/Yakutsk" => "(GMT+10:00) " . __("Yakutsk"),
+ "Australia/Brisbane" => "(GMT+10:00) " . __("Brisbane"),
+ "Australia/Canberra" => "(GMT+10:00) " . __("Canberra"),
+ "Pacific/Guam" => "(GMT+10:00) " . __("Guam"),
+ "Australia/Hobart" => "(GMT+10:00) " . __("Hobart"),
+ "Australia/Melbourne" => "(GMT+10:00) " . __("Melbourne"),
+ "Pacific/Port_Moresby" => "(GMT+10:00) " . __("Port Moresby"),
+ "Australia/Sydney" => "(GMT+10:00) " . __("Sydney"),
+ "Asia/Vladivostok" => "(GMT+11:00) " . __("Vladivostok"),
+ "Asia/Magadan" => "(GMT+12:00) " . __("Magadan"),
+ "Pacific/Auckland" => "(GMT+12:00) " . __("Auckland"),
+ "Pacific/Fiji" => "(GMT+12:00) " . __("Fiji"),
+ );
+
+ return html_print_select($timezones, $name, $selected, "", __("None"), "", true, false, false);
+}
+
?>
diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php
index 214ac50eb7..633f007784 100755
--- a/pandora_console/include/functions_ui.php
+++ b/pandora_console/include/functions_ui.php
@@ -446,7 +446,7 @@ function ui_print_timestamp ($unixtime, $return = false, $option = array ()) {
}
if (!is_numeric ($unixtime)) {
- $unixtime = strtotime ($unixtime);
+ $unixtime = time_w_fixed_tz($unixtime);
}
//prominent_time is either timestamp or comparation
@@ -3916,6 +3916,20 @@ function ui_get_snapshot_link($params, $only_params = false) {
return "winopeng_var('" . implode("', '", $link_parts) . "')";
}
+function ui_get_using_system_timezone_warning ($tag = "h3", $return = true) {
+ global $config;
+
+ $user_offset = (-get_fixed_offset() / 60) / 60;
+
+ $message = sprintf(
+ __("These controls are using the timezone of the system (%s) instead of yours (%s). The difference with your time zone in hours is %s."),
+ $config["timezone"],
+ date_default_timezone_get(),
+ $user_offset > 0 ? "+" . $user_offset : $user_offset
+ );
+ return ui_print_info_message($message, '', $return, $tag);
+}
+
/**
* Get the custom docs logo
*
diff --git a/pandora_console/mobile/include/user.class.php b/pandora_console/mobile/include/user.class.php
index 82f10fd38e..735e20c1c4 100644
--- a/pandora_console/mobile/include/user.class.php
+++ b/pandora_console/mobile/include/user.class.php
@@ -52,6 +52,8 @@ class User {
$system->setSessionBase('id_usuario', $this->user);
$system->setSession('user', $this);
+
+ config_user_set_custom_config();
}
}
diff --git a/pandora_console/mobile/operation/agents.php b/pandora_console/mobile/operation/agents.php
index 040fa58ee6..36dc2ef385 100644
--- a/pandora_console/mobile/operation/agents.php
+++ b/pandora_console/mobile/operation/agents.php
@@ -232,7 +232,7 @@ class Agents {
private function getListAgents($page = 0, $ajax = false) {
$system = System::getInstance();
-
+
$total = 0;
$agents = array();
@@ -351,8 +351,10 @@ class Agents {
'' . __('Modules') . ' ' .
'' . reporting_tiny_stats($agent, true, 'agent', ' ') . ' ';
- $last_time = strtotime ($agent["ultimo_contacto"]);
- $now = time ();
+ $last_time = time_w_fixed_tz($agent["ultimo_contacto"]);
+ html_debug(date('r', $last_time), true);
+ html_debug(get_current_utc_offset(), true);
+ $now = get_system_time();
$diferencia = $now - $last_time;
$time = ui_print_timestamp ($last_time, true, array('style' => 'font-size: 12px; margin-left: 20px;', 'units' => 'tiny'));
$style = '';
diff --git a/pandora_console/mobile/operation/events.php b/pandora_console/mobile/operation/events.php
index 1e91809614..d60fc248cc 100644
--- a/pandora_console/mobile/operation/events.php
+++ b/pandora_console/mobile/operation/events.php
@@ -162,7 +162,7 @@ class Events {
$event['evento'] = io_safe_output($event['evento']);
$event['clean_tags'] = events_clean_tags($event['tags']);
- $event["timestamp"] = date($system->getConfig("date_format"), strtotime($event["timestamp"]));
+ $event["timestamp"] = date($system->getConfig("date_format"), $event["utimestamp"]);
if (empty($event["owner_user"])) {
$event["owner_user"] = '' . __('N/A') . '';
}
diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php
index 57a50e6c9a..f7a9b9709f 100755
--- a/pandora_console/operation/agentes/estado_generalagente.php
+++ b/pandora_console/operation/agentes/estado_generalagente.php
@@ -239,7 +239,7 @@ if ($agent["ultimo_contacto_remoto"] == "01-01-1970 00:00:00") {
$data[1] .= __('Never');
}
else {
- $data[1] .= $agent["ultimo_contacto_remoto"];
+ $data[1] .= date_w_fixed_tz($agent["ultimo_contacto_remoto"]);
}
$table_contact->data[] = $data;
diff --git a/pandora_console/operation/agentes/exportdata.php b/pandora_console/operation/agentes/exportdata.php
index b79b558ef5..731294ce64 100644
--- a/pandora_console/operation/agentes/exportdata.php
+++ b/pandora_console/operation/agentes/exportdata.php
@@ -71,13 +71,16 @@ if (!empty ($export_btn) && !empty ($module)) {
$sql_cache = array ('saved' => array());
- //Convert start time and end time to unix timestamps
- $start = strtotime ($start_date . " " . $start_time);
- $end = strtotime ($end_date . " " . $end_time);
+ // Convert start time and end time to unix timestamps.
+ // The date/time will have the user's timezone,
+ // so we need to change it to the system's timezone.
+ $fixed_offset = get_fixed_offset();
+ $start = strtotime ($start_date . " " . $start_time) - $fixed_offset;
+ $end = strtotime ($end_date . " " . $end_time) - $fixed_offset;
$period = $end - $start;
$data = array ();
- //If time is negative or zero, don't process - it's invalid
+ // If time is negative or zero, don't process - it's invalid
if ($start < 1 || $end < 1) {
ui_print_error_message (__('Invalid time specified'));
return;
@@ -168,12 +171,16 @@ if (!empty ($export_btn) && !empty ($module)) {
$output .= $module['data'];
$output .= $divider;
switch($export_type) {
- case "data":
- $output .= date("Y-m-d G:i:s", $module['utimestamp']);
- break;
- case "avg":
- $output .= date ("Y-m-d G:i:s", $work_start) . ' - ' . date ("Y-m-d G:i:s", $work_end);
- break;
+ case "data":
+ // Change from the system's timezone to the user's timezone
+ $output .= date("Y-m-d G:i:s", $module['utimestamp'] + $fixed_offset);
+ break;
+ case "avg":
+ // Change from the system's timezone to the user's timezone
+ $output .= date ("Y-m-d G:i:s", $work_start + $fixed_offset)
+ . ' - '
+ . date ("Y-m-d G:i:s", $work_end + $fixed_offset);
+ break;
}
$output .= $rowend;
}
diff --git a/pandora_console/operation/agentes/gis_view.php b/pandora_console/operation/agentes/gis_view.php
index 9784d65fc0..c67a97037a 100644
--- a/pandora_console/operation/agentes/gis_view.php
+++ b/pandora_console/operation/agentes/gis_view.php
@@ -33,7 +33,9 @@ ui_require_javascript_file('openlayers.pandora');
/* Get the parameters */
$period = (int)get_parameter ("period", SECONDS_1DAY);
$agentId = (int)get_parameter('id_agente');
+$id_agente = $agentId;
$agent_name = agents_get_name($id_agente);
+$agent_alias = agents_get_alias($id_agente);
$agentData = gis_get_data_last_position_agent($id_agente);
//Avoid the agents with characters that fails the div.
@@ -206,7 +208,7 @@ if ($result !== false) {
__("Manual placement"));
$table->class = 'position_data_table';
$table->id = $agent_name.'_position_data_table';
- $table->title = $agent_name_original . " " . __("positional data");
+ $table->title = $agent_alias . " " . __("positional data");
$table->titlestyle = "background-color:#799E48;";
html_print_table($table); unset($table);
diff --git a/pandora_console/operation/events/events.build_query.php b/pandora_console/operation/events/events.build_query.php
index b0e6a0cd68..4271542d25 100755
--- a/pandora_console/operation/events/events.build_query.php
+++ b/pandora_console/operation/events/events.build_query.php
@@ -209,27 +209,24 @@ if (($date_from == '') && ($date_to == '')) {
}
}
else {
- if ($date_from != '') {
- if($time_from != '') {
- $filter_resume['time_from'] = $date_from . " " . $time_from;
- $udate_from = strtotime($date_from . " " . $time_from);
- $sql_post .= " AND (utimestamp >= " . $udate_from . ")";
- } else {
- $filter_resume['time_from'] = $date_from;
- $udate_from = strtotime($date_from . " 00:00:00");
- $sql_post .= " AND (utimestamp >= " . $udate_from . ")";
- }
+ // Some of this values will have the user's timezone,
+ // so we need to reverse it to the system's timezone
+ // before using it into the db
+ $fixed_offset = get_fixed_offset();
+
+ if (!empty($date_from)) {
+ if (empty($time_from)) $time_from = "00:00:00";
+
+ $utimestamp_from = strtotime($date_from . " " . $time_from) - $fixed_offset;
+ $filter_resume['time_from'] = date(DATE_FORMAT . " " . TIME_FORMAT, $utimestamp_from);
+ $sql_post .= " AND (utimestamp >= " . $utimestamp_from . ")";
}
- if ($date_to != '') {
- if($time_to != '') {
- $filter_resume['time_to'] = $date_to . " " . $time_to;
- $udate_to = strtotime($date_to . " " . $time_to);
- $sql_post .= " AND (utimestamp <= " . $udate_to . ")";
- } else {
- $filter_resume['time_to'] = $date_to;
- $udate_to = strtotime($date_to . " 23:59:59");
- $sql_post .= " AND (utimestamp <= " . $udate_to . ")";
- }
+ if (!empty($date_to)) {
+ if (empty($time_to)) $time_to = "23:59:59";
+
+ $utimestamp_to = strtotime($date_to . " " . $time_to) - $fixed_offset;
+ $filter_resume['time_to'] = date(DATE_FORMAT . " " . TIME_FORMAT, $utimestamp_to);
+ $sql_post .= " AND (utimestamp <= " . $utimestamp_to . ")";
}
}
diff --git a/pandora_console/operation/events/export_csv.php b/pandora_console/operation/events/export_csv.php
index 04d0bd3154..4b342b0d97 100644
--- a/pandora_console/operation/events/export_csv.php
+++ b/pandora_console/operation/events/export_csv.php
@@ -101,7 +101,23 @@ $now = date ("Y-m-d");
Header ("Content-type: text/txt");
header ('Content-Disposition: attachment; filename="pandora_export_event'.$now.'.csv"');
-echo "timestamp, agent, group, event, status, user, event_type, severity, id";
+echo "timestamp";
+echo $config["csv_divider"];
+echo "agent";
+echo $config["csv_divider"];
+echo "group";
+echo $config["csv_divider"];
+echo "event";
+echo $config["csv_divider"];
+echo "status";
+echo $config["csv_divider"];
+echo "user";
+echo $config["csv_divider"];
+echo "event_type";
+echo $config["csv_divider"];
+echo "severity";
+echo $config["csv_divider"];
+echo "id";
echo chr (13);
$new = true;
@@ -113,22 +129,22 @@ while ($event = db_get_all_row_by_steps_sql($new, $result, $sql)) {
(!check_acl($config["id_user"], 0, "PM") && $event["event_type"] == 'system'))
continue;
- echo $event["timestamp"];
- echo ",";
+ echo date($config["date_format"], $event["utimestamp"]);
+ echo $config["csv_divider"];
echo io_safe_output($alias);
- echo ",";
+ echo $config["csv_divider"];
echo io_safe_output(groups_get_name($event["id_grupo"]));
- echo ",";
+ echo $config["csv_divider"];
echo io_safe_output($event["evento"]);
- echo ",";
+ echo $config["csv_divider"];
echo io_safe_output($event["estado"]);
- echo ",";
+ echo $config["csv_divider"];
echo io_safe_output($event["id_usuario"]);
- echo ",";
+ echo $config["csv_divider"];
echo io_safe_output($event["event_type"]);
- echo ",";
+ echo $config["csv_divider"];
echo $event["criticity"];
- echo ",";
+ echo $config["csv_divider"];
echo $event["id_evento"];
echo chr (13);
}
diff --git a/pandora_console/operation/gis_maps/ajax.php b/pandora_console/operation/gis_maps/ajax.php
index e706b11414..758382f425 100644
--- a/pandora_console/operation/gis_maps/ajax.php
+++ b/pandora_console/operation/gis_maps/ajax.php
@@ -325,7 +325,7 @@ switch ($opt) {
$row[] = __('Never');
}
else {
- $row[] = $agent["ultimo_contacto"];
+ $row[] = date_w_fixed_tz($agent["ultimo_contacto"]);
}
$table->data[] = $row;
@@ -336,7 +336,7 @@ switch ($opt) {
$row[] = __('Never');
}
else {
- $row[] = $agent["ultimo_contacto_remoto"];
+ $row[] = date_w_fixed_tz($agent["ultimo_contacto_remoto"]);
}
$table->data[] = $row;
diff --git a/pandora_console/operation/incidents/incident_detail.php b/pandora_console/operation/incidents/incident_detail.php
index afc57daf45..ebe6c94b90 100755
--- a/pandora_console/operation/incidents/incident_detail.php
+++ b/pandora_console/operation/incidents/incident_detail.php
@@ -41,8 +41,8 @@ if (isset ($_GET["id"])) {
// Get values
$titulo = $row["titulo"];
$texto = $row["descripcion"];
- $inicio = strtotime ($row["inicio"]);
- $actualizacion = strtotime ($row["actualizacion"]);
+ $inicio = time_w_fixed_tz($row["inicio"]);
+ $actualizacion = time_w_fixed_tz($row["actualizacion"]);
$estado = $row["estado"];
$prioridad = $row["prioridad"];
$origen = $row["origen"];
diff --git a/pandora_console/operation/search_agents.php b/pandora_console/operation/search_agents.php
index 3282deaa70..33f206edeb 100755
--- a/pandora_console/operation/search_agents.php
+++ b/pandora_console/operation/search_agents.php
@@ -111,8 +111,8 @@ else {
$cellName .= "";
}
- $last_time = strtotime ($agent["ultimo_contacto"]);
- $now = time ();
+ $last_time = time_w_fixed_tz($agent["ultimo_contacto"]);
+ $now = get_system_time();
$diferencia = $now - $last_time;
$time = ui_print_timestamp ($last_time, true);
$time_style = $time;
diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php
index ec8df08265..80826864f4 100644
--- a/pandora_console/operation/users/user_edit.php
+++ b/pandora_console/operation/users/user_edit.php
@@ -76,6 +76,7 @@ if (isset ($_GET["modified"]) && !$view_mode) {
$upd_info["phone"] = get_parameter_post ("phone", $user_info["phone"]);
$upd_info["comments"] = get_parameter_post ("comments", $user_info["comments"]);
$upd_info["language"] = get_parameter_post ("language", $user_info["language"]);
+ $upd_info["timezone"] = get_parameter_post ("timezone", "");
$upd_info["id_skin"] = get_parameter ("skin", $user_info["id_skin"]);
$upd_info["id_filter"] = get_parameter ("event_filter",NULL);
$upd_info["block_size"] = get_parameter ("block_size", $config["block_size"]);
@@ -271,8 +272,10 @@ else
$usr_groups = (users_get_groups($config['id_user'], 'AR', $display_all_group));
$id_usr = $config['id_user'];
+
+$data = array();
+
if (!$meta) {
- $data = array();
$data[0] = ''.__('Home screen'). ui_print_help_tip(__('User can customize the home page. By default, will display \'Agent Detail\'. Example: Select \'Other\' and type sec=estado&sec2=operation/agentes/estado_agente to show agent detail view'), true).'';
$values = array (
'Default' =>__('Default'),
@@ -326,10 +329,18 @@ if (!$meta) {
$data[1] .= $jump . ''. skins_print_select($id_usr,'skin', $user_info['id_skin'], '', __('None'), 0, true).'';
}
}
- $table->rowclass[] = '';
- $table->rowstyle[] = 'font-weight: bold;';
- $table->data[] = $data;
}
+else {
+ $data[0] = "";
+ $data[1] = "";
+}
+
+$data[2] = ''.__('Timezone').'';
+$data[2] .= $jump . html_print_timezone_select("timezone", $user_info["timezone"]);
+
+$table->rowclass[] = '';
+$table->rowstyle[] = 'font-weight: bold;';
+$table->data[] = $data;
// Double auth
$double_auth_enabled = (bool) db_get_value('id', 'tuser_double_auth', 'id_user', $config['id_user']);
|