From ac8c7a9347ffdd945a0515eb26174cbdd94b5150 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 11 Feb 2020 13:21:02 -0500 Subject: [PATCH 1/6] default ZM_TIMEZONE value to empty in which case we don't set the value --- scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index cd93dfe15..de4eb6984 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -785,7 +785,7 @@ our @options = ( }, { name => 'ZM_TIMEZONE', - default => 'UTC', + default => '', description => 'The timezone that php should use.', help => q` This should be set equal to the system timezone of the mysql server`, From 821355c117668b32d56729a30700b8bf779aa294 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 11 Feb 2020 13:21:28 -0500 Subject: [PATCH 2/6] Only set date.timezone if we have a configured value in the Config --- web/includes/config.php.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/includes/config.php.in b/web/includes/config.php.in index 909a10e15..57064f22d 100644 --- a/web/includes/config.php.in +++ b/web/includes/config.php.in @@ -193,7 +193,8 @@ if ( ! defined('ZM_SERVER_ID') ) { } } -ini_set('date.timezone', ZM_TIMEZONE); +if ( ZM_TIMEZONE ) + ini_set('date.timezone', ZM_TIMEZONE); function process_configfile($configFile) { if ( is_readable( $configFile ) ) { From 600dbba8c52b3ed5c27260617321659a90edbce2 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 11 Feb 2020 13:23:53 -0500 Subject: [PATCH 3/6] We don't need to set date_default_timezone_get --- web/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/index.php b/web/index.php index 7f6e17432..2f1a6cf62 100644 --- a/web/index.php +++ b/web/index.php @@ -202,7 +202,8 @@ isset($action) || $action = NULL; if ( (!$view and !$request) or ($view == 'console') ) { // Verify the system, php, and mysql timezones all match - date_default_timezone_set(ZM_TIMEZONE); + #if ( ZM_TIMEZONE ) + #date_default_timezone_set(ZM_TIMEZONE); check_timezone(); } From 844ff529e1919bf3ee78aa5d168398e138cf13e3 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 11 Feb 2020 13:24:26 -0500 Subject: [PATCH 4/6] add an unset value to ZM_TIMEZONE in Options->System --- web/skins/classic/views/options.php | 58 ++++++++++++++--------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/web/skins/classic/views/options.php b/web/skins/classic/views/options.php index 82692fbaf..731c7ac11 100644 --- a/web/skins/classic/views/options.php +++ b/web/skins/classic/views/options.php @@ -393,41 +393,41 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*',GLOB_ONLYDIR)) as $ $configCats[$tab]['ZM_SKIN_DEFAULT']['Hint'] = join('|', array_map('basename', glob('skins/*',GLOB_ONLYDIR))); $configCats[$tab]['ZM_CSS_DEFAULT']['Hint'] = join('|', array_map ( 'basename', glob('skins/'.ZM_SKIN_DEFAULT.'/css/*',GLOB_ONLYDIR) )); $configCats[$tab]['ZM_BANDWIDTH_DEFAULT']['Hint'] = $bandwidth_options; + function timezone_list() { - static $timezones = null; + static $timezones = null; - if ($timezones === null) { - $timezones = []; - $offsets = []; - $now = new DateTime('now', new DateTimeZone('UTC')); + if ( $timezones === null ) { + $timezones = []; + $offsets = []; + $now = new DateTime('now', new DateTimeZone('UTC')); - foreach (DateTimeZone::listIdentifiers() as $timezone) { - $now->setTimezone(new DateTimeZone($timezone)); - $offsets[] = $offset = $now->getOffset(); - $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone); + foreach ( DateTimeZone::listIdentifiers() as $timezone ) { + $now->setTimezone(new DateTimeZone($timezone)); + $offsets[] = $offset = $now->getOffset(); + $timezones[$timezone] = '(' . format_GMT_offset($offset) . ') ' . format_timezone_name($timezone); + } + + array_multisort($offsets, $timezones); + } + + return $timezones; } - array_multisort($offsets, $timezones); - } + function format_GMT_offset($offset) { + $hours = intval($offset / 3600); + $minutes = abs(intval($offset % 3600 / 60)); + return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : ''); + } - return $timezones; -} - -function format_GMT_offset($offset) { - $hours = intval($offset / 3600); - $minutes = abs(intval($offset % 3600 / 60)); - return 'GMT' . ($offset ? sprintf('%+03d:%02d', $hours, $minutes) : ''); -} - -function format_timezone_name($name) { - $name = str_replace('/', ', ', $name); - $name = str_replace('_', ' ', $name); - $name = str_replace('St ', 'St. ', $name); - return $name; -} - $configCats[$tab]['ZM_TIMEZONE']['Hint'] = timezone_list(); - - } + function format_timezone_name($name) { + $name = str_replace('/', ', ', $name); + $name = str_replace('_', ' ', $name); + $name = str_replace('St ', 'St. ', $name); + return $name; + } + $configCats[$tab]['ZM_TIMEZONE']['Hint'] = array('', translate('Unset') + timezone_list(); + } # end if tab == system ?>
From 9f9a97f596c9c97ad13424988038e883759058ce Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 11 Feb 2020 14:29:21 -0500 Subject: [PATCH 5/6] fix dropdown with unset option --- web/skins/classic/views/options.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/options.php b/web/skins/classic/views/options.php index 731c7ac11..2775656a3 100644 --- a/web/skins/classic/views/options.php +++ b/web/skins/classic/views/options.php @@ -426,7 +426,7 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*',GLOB_ONLYDIR)) as $ $name = str_replace('St ', 'St. ', $name); return $name; } - $configCats[$tab]['ZM_TIMEZONE']['Hint'] = array('', translate('Unset') + timezone_list(); + $configCats[$tab]['ZM_TIMEZONE']['Hint'] = array(''=> translate('Unset')) + timezone_list(); } # end if tab == system ?> From 289bde869d95f859a6a13909248f0bfc170c89d3 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 11 Feb 2020 14:31:48 -0500 Subject: [PATCH 6/6] use a better language for unset value --- web/lang/en_gb.php | 1 + web/skins/classic/views/options.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/web/lang/en_gb.php b/web/lang/en_gb.php index ad4911a4d..a8569639c 100644 --- a/web/lang/en_gb.php +++ b/web/lang/en_gb.php @@ -771,6 +771,7 @@ $SLANG = array( 'TurboPanSpeed' => 'Turbo Pan Speed', 'TurboTiltSpeed' => 'Turbo Tilt Speed', 'Type' => 'Type', + 'TZUnset' => 'Unset - use value in php.ini', 'Unarchive' => 'Unarchive', 'Undefined' => 'Undefined', 'Units' => 'Units', diff --git a/web/skins/classic/views/options.php b/web/skins/classic/views/options.php index 2775656a3..e1a77b874 100644 --- a/web/skins/classic/views/options.php +++ b/web/skins/classic/views/options.php @@ -426,7 +426,7 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*',GLOB_ONLYDIR)) as $ $name = str_replace('St ', 'St. ', $name); return $name; } - $configCats[$tab]['ZM_TIMEZONE']['Hint'] = array(''=> translate('Unset')) + timezone_list(); + $configCats[$tab]['ZM_TIMEZONE']['Hint'] = array(''=> translate('TZUnset')) + timezone_list(); } # end if tab == system ?>