From 309092efc56540a95d8117fad7180fe470aadff6 Mon Sep 17 00:00:00 2001 From: Greg Roach Date: Sat, 4 Apr 2015 18:40:19 +0100 Subject: Fix #242 - messages and blocks using UTC instead of local time --- admin_site_info.php | 20 -------------------- admin_site_upgrade.php | 2 +- app/Module/HtmlBlockModule.php | 2 +- app/Module/LoginBlockModule.php | 2 +- app/Module/UserMessagesModule.php | 2 +- app/Report/ReportBase.php | 2 +- app/Stats.php | 13 +++---------- includes/db_schema/db_schema_29_30.php | 6 ++++++ includes/functions/functions.php | 2 +- includes/session.php | 12 +++--------- login.php | 2 +- 11 files changed, 19 insertions(+), 46 deletions(-) diff --git a/admin_site_info.php b/admin_site_info.php index 1334ff2c6c..663f813421 100644 --- a/admin_site_info.php +++ b/admin_site_info.php @@ -42,26 +42,6 @@ $html = $matches[1];

getPageTitle(); ?>

-
-
-
-
-

- -

-
-
- — -
- — -
- — - -
-
-
-
-
diff --git a/admin_site_upgrade.php b/admin_site_upgrade.php index 61e87bdeee..8bc46c662f 100644 --- a/admin_site_upgrade.php +++ b/admin_site_upgrade.php @@ -36,7 +36,7 @@ $download_url_html = ''; diff --git a/app/Module/HtmlBlockModule.php b/app/Module/HtmlBlockModule.php index 4c0592e933..7f4fe9e603 100644 --- a/app/Module/HtmlBlockModule.php +++ b/app/Module/HtmlBlockModule.php @@ -90,7 +90,7 @@ class HtmlBlockModule extends AbstractModule implements ModuleBlockInterface { $content = $html; if ($show_timestamp) { - $content .= '
' . format_timestamp($this->getBlockSetting($block_id, 'timestamp', WT_TIMESTAMP)); + $content .= '
' . format_timestamp($this->getBlockSetting($block_id, 'timestamp', WT_TIMESTAMP) + WT_TIMESTAMP_OFFSET); } if ($template) { diff --git a/app/Module/LoginBlockModule.php b/app/Module/LoginBlockModule.php index dd2380f0ec..baa8b45796 100644 --- a/app/Module/LoginBlockModule.php +++ b/app/Module/LoginBlockModule.php @@ -55,7 +55,7 @@ class LoginBlockModule extends AbstractModule implements ModuleBlockInterface { } else { $title = I18N::translate('Login'); $content = '
-
+ '; $content .= '
diff --git a/app/Module/UserMessagesModule.php b/app/Module/UserMessagesModule.php index c484b13e2b..d9c4fda5e9 100644 --- a/app/Module/UserMessagesModule.php +++ b/app/Module/UserMessagesModule.php @@ -83,7 +83,7 @@ class UserMessagesModule extends AbstractModule implements ModuleBlockInterface $content .= ''; $content .= ''; $content .= ' ' . Filter::escapeHtml($message->subject) . ''; - $content .= '' . format_timestamp($message->created) . ''; + $content .= '' . format_timestamp($message->created + WT_TIMESTAMP_OFFSET) . ''; $content .= ''; $user = User::findByIdentifier($message->sender); if ($user) { diff --git a/app/Report/ReportBase.php b/app/Report/ReportBase.php index d2f6ca4253..ecb7a2c2bf 100644 --- a/app/Report/ReportBase.php +++ b/app/Report/ReportBase.php @@ -924,7 +924,7 @@ function cellEndHandler() { function nowStartHandler() { global $currentElement; - $g = timestamp_to_gedcom_date(WT_CLIENT_TIMESTAMP); + $g = timestamp_to_gedcom_date(WT_TIMESTAMP + WT_TIMESTAMP_OFFSET); $currentElement->addText($g->display()); } diff --git a/app/Stats.php b/app/Stats.php index 82fd62a8a5..e7fcf321cd 100644 --- a/app/Stats.php +++ b/app/Stats.php @@ -5662,28 +5662,21 @@ class Stats { * @return string */ public function browserDate() { - return timestamp_to_gedcom_date(WT_CLIENT_TIMESTAMP)->display(); + return timestamp_to_gedcom_date(WT_TIMESTAMP + WT_TIMESTAMP_OFFSET)->display(); } /** * @return string */ public function browserTime() { - return date('g:i a', WT_CLIENT_TIMESTAMP); - } - - /** - * @return string - */ - public function browserTime24() { - return date('G:i', WT_CLIENT_TIMESTAMP); + return date(str_replace('%', '', I18N::timeFormat()), WT_TIMESTAMP + WT_TIMESTAMP_OFFSET); } /** * @return string */ public function browserTimezone() { - return date('T', WT_CLIENT_TIMESTAMP); + return date('T', WT_TIMESTAMP + WT_TIMESTAMP_OFFSET); } /** diff --git a/includes/db_schema/db_schema_29_30.php b/includes/db_schema/db_schema_29_30.php index 7a2c626019..38cde6cfd4 100644 --- a/includes/db_schema/db_schema_29_30.php +++ b/includes/db_schema/db_schema_29_30.php @@ -46,6 +46,12 @@ Database::exec( " SET setting_value = REPLACE(setting_value, '#WT_VERSION#', '#webtreesVersion#')" . " WHERE setting_name = 'html' AND module_name = 'html'" ); +Database::exec( + "UPDATE `##block_setting` " . + " JOIN `##block` USING (block_id)" . + " SET setting_value = REPLACE(setting_value, '#browserTime24#', '#browserTime#')" . + " WHERE setting_name = 'html' AND module_name = 'html'" +); // Language settings have changed from locale (en_GB) to language tag (en-GB) Database::exec( diff --git a/includes/functions/functions.php b/includes/functions/functions.php index 9e045fbb7a..e9c985031f 100644 --- a/includes/functions/functions.php +++ b/includes/functions/functions.php @@ -30,7 +30,7 @@ function fetch_latest_version() { if ($last_update_timestamp < WT_TIMESTAMP - 24 * 60 * 60) { $row = Database::prepare("SHOW VARIABLES LIKE 'version'")->fetchOneRow(); $params = '?w=' . WT_VERSION . '&p=' . PHP_VERSION . '&m=' . $row->value . '&o=' . (DIRECTORY_SEPARATOR === '/' ? 'u' : 'w'); - $latest_version_txt = File::fetchUrl('http://svn.webtrees.net/build/latest-version.txt' . $params); + $latest_version_txt = File::fetchUrl('http://dev.webtrees.net/build/latest-version.txt' . $params); if ($latest_version_txt) { Site::setPreference('LATEST_WT_VERSION', $latest_version_txt); Site::setPreference('LATEST_WT_VERSION_TIMESTAMP', WT_TIMESTAMP); diff --git a/includes/session.php b/includes/session.php index f60d88afed..50ae6e95b2 100644 --- a/includes/session.php +++ b/includes/session.php @@ -457,22 +457,16 @@ if (empty($WEBTREES_EMAIL)) { // Note that the database/webservers may not be synchronised, so use DB time throughout. define('WT_TIMESTAMP', (int) Database::prepare("SELECT UNIX_TIMESTAMP()")->fetchOne()); -// Server timezone is defined in php.ini -define('WT_SERVER_TIMESTAMP', WT_TIMESTAMP + (int) date('Z')); - if (Auth::check()) { - define('WT_CLIENT_TIMESTAMP', WT_TIMESTAMP - $WT_SESSION->timediff); + define('WT_TIMESTAMP_OFFSET', $WT_SESSION->timediff); } else { - define('WT_CLIENT_TIMESTAMP', WT_SERVER_TIMESTAMP); + define('WT_TIMESTAMP_OFFSET', (int) date('Z')); } -define('WT_CLIENT_JD', 2440588 + (int) (WT_CLIENT_TIMESTAMP / 86400)); +define('WT_CLIENT_JD', 2440588 + (int) ((WT_TIMESTAMP + WT_TIMESTAMP_OFFSET) / 86400)); // Application configuration data - things that aren’t (yet?) user-editable require WT_ROOT . 'includes/config_data.php'; - - - // The login URL must be an absolute URL, and can be user-defined if (Site::getPreference('LOGIN_URL')) { define('WT_LOGIN_URL', Site::getPreference('LOGIN_URL')); diff --git a/login.php b/login.php index 5229df7bf9..56d67065bf 100644 --- a/login.php +++ b/login.php @@ -170,7 +170,7 @@ default: echo '
'; echo '
- + '; -- cgit v1.3