summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2015-04-04 18:40:19 +0100
committerGreg Roach <fisharebest@gmail.com>2015-04-04 18:40:19 +0100
commit309092efc56540a95d8117fad7180fe470aadff6 (patch)
tree8fe4bf88c8a5c16daa564656706bb3264ac056f9
parentfc4a65d376a83865a7f464bd4127d22587f7293e (diff)
downloadwebtrees-309092efc56540a95d8117fad7180fe470aadff6.tar.gz
webtrees-309092efc56540a95d8117fad7180fe470aadff6.tar.bz2
webtrees-309092efc56540a95d8117fad7180fe470aadff6.zip
Fix #242 - messages and blocks using UTC instead of local time
-rw-r--r--admin_site_info.php20
-rw-r--r--admin_site_upgrade.php2
-rw-r--r--app/Module/HtmlBlockModule.php2
-rw-r--r--app/Module/LoginBlockModule.php2
-rw-r--r--app/Module/UserMessagesModule.php2
-rw-r--r--app/Report/ReportBase.php2
-rw-r--r--app/Stats.php13
-rw-r--r--includes/db_schema/db_schema_29_30.php6
-rw-r--r--includes/functions/functions.php2
-rw-r--r--includes/session.php12
-rw-r--r--login.php2
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
@@ -47,26 +47,6 @@ $html = $matches[1];
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
- <?php echo I18N::translate('Time'); ?>
- </h2>
- </div>
- <div class="panel-body">
- <?php echo /* I18N: The local time on the server */ I18N::translate('Server time'); ?> —
- <?php echo format_timestamp(WT_SERVER_TIMESTAMP); ?><br>
- <?php echo /* I18N: The local time on the client/browser */ I18N::translate('Client time'); ?> —
- <?php echo format_timestamp(WT_CLIENT_TIMESTAMP); ?><br>
- <?php echo /* I18N: Timezone - http://en.wikipedia.org/wiki/UTC */ I18N::translate('UTC'); ?> —
- <?php echo format_timestamp(WT_TIMESTAMP); ?>
- </div>
- </div>
- </div>
-</div>
-
-<div class="row">
- <div class="col-xs-12">
- <div class="panel panel-default">
- <div class="panel-heading">
- <h2 class="panel-title">
<?php echo I18N::translate('PHP information'); ?>
</h2>
</div>
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 = '<b dir="auto"><a href="' . Filter::escapeHtml($download_
// Show a friendly message while the site is being upgraded
$lock_file = __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'offline.txt';
-$lock_file_text = I18N::translate('This website is being upgraded. Try again in a few minutes.') . PHP_EOL . format_timestamp(WT_TIMESTAMP) . I18N::translate('UTC');
+$lock_file_text = I18N::translate('This website is being upgraded. Try again in a few minutes.') . PHP_EOL . format_timestamp(WT_TIMESTAMP) . /* I18N: Timezone - http://en.wikipedia.org/wiki/UTC */ I18N::translate('UTC');
// Success/failure indicators
$icon_success = '<i class="icon-yes"></i>';
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 .= '<br>' . format_timestamp($this->getBlockSetting($block_id, 'timestamp', WT_TIMESTAMP));
+ $content .= '<br>' . 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 = '<div id="login-box">
- <form id="login-form" name="login-form" method="post" action="'. WT_LOGIN_URL . '" onsubmit="d=new Date(); this.timediff.value=d.getTimezoneOffset()*60;">
+ <form id="login-form" name="login-form" method="post" action="'. WT_LOGIN_URL . '" onsubmit="d=new Date(); this.timediff.value=-60*d.getTimezoneOffset();">
<input type="hidden" name="action" value="login">
<input type="hidden" name="timediff" value="">';
$content .= '<div>
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 .= '<tr>';
$content .= '<td class="list_value_wrap"><input type="checkbox" id="cb_message' . $message->message_id . '" name="message_id[]" value="' . $message->message_id . '"></td>';
$content .= '<td class="list_value_wrap"><a href="#" onclick="return expand_layer(\'message' . $message->message_id . '\');"><i id="message' . $message->message_id . '_img" class="icon-plus"></i> <b dir="auto">' . Filter::escapeHtml($message->subject) . '</b></a></td>';
- $content .= '<td class="list_value_wrap">' . format_timestamp($message->created) . '</td>';
+ $content .= '<td class="list_value_wrap">' . format_timestamp($message->created + WT_TIMESTAMP_OFFSET) . '</td>';
$content .= '<td class="list_value_wrap">';
$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 '</div>';
echo '<div id="login-box">
- <form id="login-form" name="login-form" method="post" action="', WT_LOGIN_URL, '" onsubmit="d=new Date(); this.timediff.value=d.getTimezoneOffset()*60;">
+ <form id="login-form" name="login-form" method="post" action="', WT_LOGIN_URL, '" onsubmit="d=new Date(); this.timediff.value=-60*d.getTimezoneOffset();">
<input type="hidden" name="action" value="login">
<input type="hidden" name="url" value="', Filter::escapeHtml($url), '">
<input type="hidden" name="timediff" value="0">';