Skip to content
Snippets Groups Projects
Commit 449ec1c2 authored by Olav Morken's avatar Olav Morken
Browse files

Add timezone-option.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1687 44740490-163a-0410-bde0-09ae8108e29a
parent 8635ad43
No related branches found
No related tags found
No related merge requests found
...@@ -71,7 +71,16 @@ $config = array ( ...@@ -71,7 +71,16 @@ $config = array (
*/ */
'technicalcontact_name' => 'Administrator', 'technicalcontact_name' => 'Administrator',
'technicalcontact_email' => 'na@example.org', 'technicalcontact_email' => 'na@example.org',
/*
* The timezone of the server. This option should be set to the timezone you want
* simpleSAMLphp to report the time in. The default is to guess the timezone based
* on your system timezone.
*
* See this page for a list of valid timezones: http://php.net/manual/en/timezones.php
*/
'timezone' => NULL,
/* /*
* Logging. * Logging.
* *
......
...@@ -166,6 +166,13 @@ file, `config.php`, right away: ...@@ -166,6 +166,13 @@ file, `config.php`, right away:
'language.default' => 'no', 'language.default' => 'no',
-
Set the timezone which you use:
'timezone' => 'Europe/Oslo',
* [List of Supported Timezones at php.net](http://php.net/manual/en/timezones.php)
Configuring PHP Configuring PHP
--------------- ---------------
...@@ -175,18 +182,6 @@ Configuring PHP ...@@ -175,18 +182,6 @@ Configuring PHP
Some parts of simpleSAMLphp will allow you to send e-mails. In example sending error reports to technical admin, as well as sending in metadata to the federation administrators. If you want to make use of this functionality, you should make sure your PHP installation is configured to be able to send e-mails. It's a common problem that PHP is not configured to send e-mails properly. The configuration differs from system to system. On UNIX, PHP is using sendmail, on Windows SMTP. Some parts of simpleSAMLphp will allow you to send e-mails. In example sending error reports to technical admin, as well as sending in metadata to the federation administrators. If you want to make use of this functionality, you should make sure your PHP installation is configured to be able to send e-mails. It's a common problem that PHP is not configured to send e-mails properly. The configuration differs from system to system. On UNIX, PHP is using sendmail, on Windows SMTP.
### Configuring time zone in PHP
Some default installations of PHP does not include a timezone setting. The result is that a lot of warnings is thrown in the log files, which may be annoying. Therefore we reccomend to always set a timezone in the `php.ini` configuration file. In example like this:
[Date]
; Defines the default timezone used by the date functions
date.timezone = Europe/Oslo
* [List of Supported Timezones at php.net](http://php.net/manual/en/timezones.php)
Enable modules Enable modules
-------------- --------------
......
...@@ -1920,6 +1920,50 @@ class SimpleSAML_Utilities { ...@@ -1920,6 +1920,50 @@ class SimpleSAML_Utilities {
SimpleSAML_Logger::debug('Successfully validated certificate.'); SimpleSAML_Logger::debug('Successfully validated certificate.');
} }
/**
* Initialize the timezone.
*
* This function should be called before any calls to date().
*/
public static function initTimezone() {
static $initialized = FALSE;
if ($initialized) {
return;
}
$initialized = TRUE;
$globalConfig = SimpleSAML_Configuration::getInstance();
$timezone = $globalConfig->getString('timezone', NULL);
if ($timezone !== NULL) {
if (!date_default_timezone_set($timezone)) {
throw new SimpleSAML_Error_Exception('Invalid timezone set in the \'timezone\'-option in config.php.');
}
return;
}
/* We don't have a timezone configured. */
/*
* The date_default_timezone_get()-function is likely to cause a warning.
* Since we have a custom error handler which logs the errors with a backtrace,
* this error will be logged even if we prefix the function call with '@'.
* Instead we temporarily replace the error handler.
*/
function ignoreError() {
/* Don't do anything with this error. */
return TRUE;
}
set_error_handler('ignoreError');
$serverTimezone = date_default_timezone_get();
restore_error_handler();
/* Set the timezone to the default. */
date_default_timezone_set($serverTimezone);
}
} }
?> ?>
\ No newline at end of file
...@@ -94,4 +94,7 @@ SimpleSAML_Configuration::setConfigDir($configdir); ...@@ -94,4 +94,7 @@ SimpleSAML_Configuration::setConfigDir($configdir);
/* Make sure that the session is initialized before any output. */ /* Make sure that the session is initialized before any output. */
SimpleSAML_Session::getInstance(); SimpleSAML_Session::getInstance();
/* Set the timezone. */
SimpleSAML_Utilities::initTimezone();
?> ?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment