From 7190b532ddcb259e887df40540d7ec16ddbbc931 Mon Sep 17 00:00:00 2001 From: baffo32 Date: Mon, 12 Oct 2015 13:07:07 -0400 Subject: [PATCH 1/6] Fatal error if date.timezone is unset --- web/index.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/index.php b/web/index.php index 4b9ab3409..62a809977 100644 --- a/web/index.php +++ b/web/index.php @@ -46,6 +46,11 @@ if ( false ) ob_end_clean(); } +// Check time zone is set +if (!ini_get('date.timezone')) { + trigger_error( "date.timezone in php.ini is unset. ZoneMinder is not installed properly. ", E_USER_ERROR ); +} + require_once( 'includes/config.php' ); require_once( 'includes/logger.php' ); From d20478a15f56b7a07a30f37c4d67cbdff4c88808 Mon Sep 17 00:00:00 2001 From: baffo32 Date: Mon, 12 Oct 2015 13:22:30 -0400 Subject: [PATCH 2/6] Detect invalid timezones --- web/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/index.php b/web/index.php index 62a809977..9ba3df8b0 100644 --- a/web/index.php +++ b/web/index.php @@ -48,7 +48,9 @@ if ( false ) // Check time zone is set if (!ini_get('date.timezone')) { - trigger_error( "date.timezone in php.ini is unset. ZoneMinder is not installed properly. ", E_USER_ERROR ); + trigger_error( "ZoneMinder is not installed properly: date.timezone in php.ini is unset", E_USER_ERROR ); +} else if(!date_default_timezone_set(ini_get('date.timezone'))) { + trigger_error( "ZoneMinder is not installed properly: date.timezone in php.ini is invalid", E_USER_ERROR ); } require_once( 'includes/config.php' ); From 24454253af4690a4af5fb8ba2274fa28beb43696 Mon Sep 17 00:00:00 2001 From: baffo32 Date: Mon, 12 Oct 2015 15:25:30 -0400 Subject: [PATCH 3/6] Add date.timezone step to INSTALL --- INSTALL | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/INSTALL b/INSTALL index 8f892e840..310e3029b 100644 --- a/INSTALL +++ b/INSTALL @@ -92,8 +92,9 @@ NOTE: The database server, database name, user and password can be different and 7) Populate the zoneminder database using the script zm_create.sql. This should be found in /share/zoneminder/db or in the project/db directory. 8) Create an apache virtual host for ZoneMinder. Make sure to use the same paths as ZM_WEBDIR and ZM_CGIDIR in /etc/zm.conf -9) Create other config if desired (e.g. rsyslog, logrotate and such). Some of this can be found in /share/zoneminder/misc or project/misc directory -10) Setup an appropriate startup script for your system. Two generic startup scripts have been provided, a legacy Sys V Init script and a Systemd service file. +9) Set date.timezone to your correct timezone in php.ini +10) Create other config if desired (e.g. rsyslog, logrotate and such). Some of this can be found in /share/zoneminder/misc or project/misc directory +11) Setup an appropriate startup script for your system. Two generic startup scripts have been provided, a legacy Sys V Init script and a Systemd service file. *Sys V Init Setup* - Copy the sys v init script /scripts/zm from the build folder to /etc/init. From 4a280a73d1e2df10a1589bcb76a72a8762ada02e Mon Sep 17 00:00:00 2001 From: baffo32 Date: Mon, 12 Oct 2015 15:43:24 -0400 Subject: [PATCH 4/6] Use Fatal function to report bad timezone --- web/index.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/web/index.php b/web/index.php index 9ba3df8b0..79dd70ce5 100644 --- a/web/index.php +++ b/web/index.php @@ -46,13 +46,6 @@ if ( false ) ob_end_clean(); } -// Check time zone is set -if (!ini_get('date.timezone')) { - trigger_error( "ZoneMinder is not installed properly: date.timezone in php.ini is unset", E_USER_ERROR ); -} else if(!date_default_timezone_set(ini_get('date.timezone'))) { - trigger_error( "ZoneMinder is not installed properly: date.timezone in php.ini is invalid", E_USER_ERROR ); -} - require_once( 'includes/config.php' ); require_once( 'includes/logger.php' ); @@ -67,6 +60,12 @@ else define( "ZM_BASE_PROTOCOL", $protocol ); define( "ZM_BASE_URL", $protocol.'://'.$_SERVER['HTTP_HOST'] ); +// Check time zone is set +if (!ini_get('date.timezone') || !date_default_timezone_set(ini_get('date.timezone'))) { + date_default_timezone_set('UTC'); + Fatal( "ZoneMinder is not installed properly: date.timezone in php.ini is not set to a valid timezone" ); +} + if ( isset($_GET['skin']) ) $skin = $_GET['skin']; elseif ( isset($_COOKIE['zmSkin']) ) From ec12d448e4ac8d742bd25baa3edc09aab2459c92 Mon Sep 17 00:00:00 2001 From: baffo32 Date: Tue, 13 Oct 2015 16:52:39 -0400 Subject: [PATCH 5/6] Generalization date.timezone installation step --- INSTALL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index 310e3029b..35deec3c4 100644 --- a/INSTALL +++ b/INSTALL @@ -92,7 +92,7 @@ NOTE: The database server, database name, user and password can be different and 7) Populate the zoneminder database using the script zm_create.sql. This should be found in /share/zoneminder/db or in the project/db directory. 8) Create an apache virtual host for ZoneMinder. Make sure to use the same paths as ZM_WEBDIR and ZM_CGIDIR in /etc/zm.conf -9) Set date.timezone to your correct timezone in php.ini +9) Verify date.timezone is set to your timezone. This parameter is often found inside the system php.ini file. Consult your distribution's documentation for the proper way to set this value. 10) Create other config if desired (e.g. rsyslog, logrotate and such). Some of this can be found in /share/zoneminder/misc or project/misc directory 11) Setup an appropriate startup script for your system. Two generic startup scripts have been provided, a legacy Sys V Init script and a Systemd service file. From da8e9dd81b5cedb1d865b2f1ec5ccff1909bd18e Mon Sep 17 00:00:00 2001 From: baffo32 Date: Tue, 13 Oct 2015 16:55:38 -0400 Subject: [PATCH 6/6] Remove reference to php.ini from timezone error --- web/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/index.php b/web/index.php index 79dd70ce5..fadaabc6a 100644 --- a/web/index.php +++ b/web/index.php @@ -63,7 +63,7 @@ define( "ZM_BASE_URL", $protocol.'://'.$_SERVER['HTTP_HOST'] ); // Check time zone is set if (!ini_get('date.timezone') || !date_default_timezone_set(ini_get('date.timezone'))) { date_default_timezone_set('UTC'); - Fatal( "ZoneMinder is not installed properly: date.timezone in php.ini is not set to a valid timezone" ); + Fatal( "ZoneMinder is not installed properly: php's date.timezone is not set to a valid timezone" ); } if ( isset($_GET['skin']) )