This is a repost of a post from the forum. Just to make sure it is on the right spot.
Problem
But a question for now: The way WB handles timezones is easy to follow but posing some problems. We have a time/date value in seconds from unix epoch and we do:
gmdate(TIME_FORMAT, $postposted_when?+TIMEZONE);
or even (just for example): mktime() + TIMEZONE
TIMEZONE is seconds from GMT.
I found in this forum some references to problems with Daylight Saving Time. Thats when the seconds from GMT change. I guess people in Holland (where I am) should use GMT + 1 in winter and GMT + 2 in summer or something like that, but when you change the timezone, "old" times also change.
PHP 5.1 gives new timezone support, through date_default_timezone_set, which changes the output of all date format functions that do not have the gm_..prefix.
My solution
I added (below) a patch to the original 2.6.5 file tree. Important elements:
The new file timezone.extensions.php which is called from initialize.php and selects the mode of operation: either "new framework" php timezone calculation or "old framework" GMT + seconds work.
This file also defines a new function, wbdate(format, timestamp), that could and should be used instead of gmdate(format, timestamp + TIMEZONE). There is also support code for getting the right TIMEZONE from the database and filling the timezone combo's in preferences and profiles.
Install: also shows the new timezone list if available. timezone in the users table is now a varchar.
Framework and other admin-like places: code changed to get the right TIMEZONE, also a fix for not unsetting $_SESSION[USE_DEFAULT_TIMEZONE] when a user changes his or her profile. gmdate(...) calls changed to wbdate
Default modules: use of wbdate
modules still using gmdate should work like in the old situation (my code sets TIMEZONE to the current offset of the used timezone). When the new php timezones are unavailabe (php < 5.1.0), gmdate and wbdate both use the old framework, and 'old' timezones like GMT + 2 etc are used.
I welcome your thoughts.
Patch
diff -Naur websitebaker-2.6.5/wb/account/details.php websitebaker-2.6.5.timezone-extensions/wb/account/details.php
--- websitebaker-2.6.5/wb/account/details.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/account/details.php 2007-05-25 16:17:45.000000000 +0200
@@ -31,7 +31,18 @@
// Get entered values
$display_name = $wb->add_slashes(strip_tags($wb->get_post('display_name')));
$language = $wb->get_post('language');
-$timezone = $wb->get_post('timezone')*60*60;
+//timezone.extensions.php change!
+ //When using the new timezone framework, the timezone value will not be
+ //integer. In that case $value will just be saved (being a string)
+ // Spin in het web, 20070525
+
+ //old code:
+ //$timezone = $wb->get_post('timezone')*60*60;
+ //new code:
+ $timezone = $wb->get_post('timezone');
+ if (is_numeric($timezone))
+ $timezone = $timezone*60*60;
+//end timezone.extensions.php change
$date_format = $wb->get_post('date_format');
$time_format = $wb->get_post('time_format');
diff -Naur websitebaker-2.6.5/wb/account/preferences_form.php websitebaker-2.6.5.timezone-extensions/wb/account/preferences_form.php
--- websitebaker-2.6.5/wb/account/preferences_form.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/account/preferences_form.php 2007-05-25 16:58:35.000000000 +0200
@@ -78,9 +78,28 @@
<option value="-20"><?php echo $TEXT['PLEASE_SELECT']; ?>...</option>
<?php
// Insert default timezone values
- require_once(ADMIN_PATH.'/interface/timezones.php');
+ //timezone.extensions.php change!
+ //We use a call that selects between php < 5.1 and above
+ // Spin in het web, 20070525
+
+ //old code:
+ //require_once(ADMIN_PATH.'/interface/timezones.php');
+ //new code:
+ set_TIMEZONES();
+ global $TIMEZONES;
+ //end timezone.extensions.php change
+
foreach($TIMEZONES AS $hour_offset => $title) {
- if($wb->get_timezone() == $hour_offset*60*60) {
+ //timezone.extensions.php change!
+ //$hour_offset is a name when using new timezone code (EXCEPT for the standard value -20), otherwise a numeric string
+ //when it is a string, we should not do the hour->second conversion like with numeric
+ // Spin in het web, 20070525
+
+ //old code
+ //if($wb->get_timezone() == $hour_offset*60*60) {
+ //new code
+ if ((is_numeric($hour_offset) && $wb->get_timezone() == $hour_offset*60*60) || ((! is_numeric($hour_offset)) && $wb->get_timezone() == $hour_offset)) {
+ //end timezone.extensions.php change
?>
<option value="<?php echo $hour_offset; ?>" selected><?php echo $title; ?></option>
<?php
diff -Naur websitebaker-2.6.5/wb/admin/interface/date_formats.php websitebaker-2.6.5.timezone-extensions/wb/admin/interface/date_formats.php
--- websitebaker-2.6.5/wb/admin/interface/date_formats.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/admin/interface/date_formats.php 2007-05-29 15:19:17.000000000 +0200
@@ -31,6 +31,12 @@
*/
+//timezone.extensions.php change!
+//we made a lot of changes to this file. We no longer use mktime to make time and add TIMEZONE.
+//instead, we use the new wbdate call to create a date using the current TIMEZONE
+//problem with this is that date will allways be displayed in the current user's timezone, but well
+
+
if(!defined('WB_URL')) {
header('Location: ../index.php');
exit(0);
@@ -44,34 +50,66 @@
// Create array
$DATE_FORMATS = array();
+//timezone.extensions.php change
+//this code removed:
+/*
// Get the current time (in the users timezone if required)
if(isset($user_time) AND $user_time == true) {
$mktime = mktime()+TIMEZONE;
} else {
$mktime = mktime()+DEFAULT_TIMEZONE;
}
+*/
+//end timezone.extensions.php change
// Add values to list
-$DATE_FORMATS['l,|jS|F,|Y'] = gmdate('l, jS F, Y', $mktime);
-$DATE_FORMATS['jS|F,|Y'] = gmdate('jS F, Y', $mktime);
-$DATE_FORMATS['d|M|Y'] = gmdate('d M Y', $mktime);
-$DATE_FORMATS['M|d|Y'] = gmdate('M d Y', $mktime);
-$DATE_FORMATS['D|M|d,|Y'] = gmdate('D M d, Y', $mktime);
-$DATE_FORMATS['d-m-Y'] = gmdate('d-m-Y', $mktime).' (D-M-Y)';
-$DATE_FORMATS['m-d-Y'] = gmdate('m-d-Y', $mktime).' (M-D-Y)';
-$DATE_FORMATS['d.m.Y'] = gmdate('d.m.Y', $mktime).' (D.M.Y)';
-$DATE_FORMATS['m.d.Y'] = gmdate('m.d.Y', $mktime).' (M.D.Y)';
-$DATE_FORMATS['d/m/Y'] = gmdate('d/m/Y', $mktime).' (D/M/Y)';
-$DATE_FORMATS['m/d/Y'] = gmdate('m/d/Y', $mktime).' (M/D/Y)';
-// Add "System Default" to list (if we need to)
-if(isset($user_time) AND $user_time == true) {
- if(isset($TEXT['SYSTEM_DEFAULT'])) {
- $DATE_FORMATS['system_default'] = gmdate(DEFAULT_DATE_FORMAT, $mktime).' ('.$TEXT['SYSTEM_DEFAULT'].')';
- } else {
- $DATE_FORMATS['system_default'] = gmdate(DEFAULT_DATE_FORMAT, $mktime).' (System Default)';
- }
-}
+//timezone.extensions.php change
+ //old code:
+ /*
+ $DATE_FORMATS['l,|jS|F,|Y'] = gmdate('l, jS F, Y', $mktime);
+ $DATE_FORMATS['jS|F,|Y'] = gmdate('jS F, Y', $mktime);
+ $DATE_FORMATS['d|M|Y'] = gmdate('d M Y', $mktime);
+ $DATE_FORMATS['M|d|Y'] = gmdate('M d Y', $mktime);
+ $DATE_FORMATS['D|M|d,|Y'] = gmdate('D M d, Y', $mktime);
+ $DATE_FORMATS['d-m-Y'] = gmdate('d-m-Y', $mktime).' (D-M-Y)';
+ $DATE_FORMATS['m-d-Y'] = gmdate('m-d-Y', $mktime).' (M-D-Y)';
+ $DATE_FORMATS['d.m.Y'] = gmdate('d.m.Y', $mktime).' (D.M.Y)';
+ $DATE_FORMATS['m.d.Y'] = gmdate('m.d.Y', $mktime).' (M.D.Y)';
+ $DATE_FORMATS['d/m/Y'] = gmdate('d/m/Y', $mktime).' (D/M/Y)';
+ $DATE_FORMATS['m/d/Y'] = gmdate('m/d/Y', $mktime).' (M/D/Y)';
+
+ // Add "System Default" to list (if we need to)
+ if(isset($user_time) AND $user_time == true) {
+ if(isset($TEXT['SYSTEM_DEFAULT'])) {
+ $DATE_FORMATS['system_default'] = gmdate(DEFAULT_DATE_FORMAT, $mktime).' ('.$TEXT['SYSTEM_DEFAULT'].')';
+ } else {
+ $DATE_FORMATS['system_default'] = gmdate(DEFAULT_DATE_FORMAT, $mktime).' (System Default)';
+ }
+ }
+ */
+ //new code:
+ $DATE_FORMATS['l,|jS|F,|Y'] = wbdate('l, jS F, Y');
+ $DATE_FORMATS['jS|F,|Y'] = wbdate('jS F, Y');
+ $DATE_FORMATS['d|M|Y'] = wbdate('d M Y');
+ $DATE_FORMATS['M|d|Y'] = wbdate('M d Y');
+ $DATE_FORMATS['D|M|d,|Y'] = wbdate('D M d, Y');
+ $DATE_FORMATS['d-m-Y'] = wbdate('d-m-Y').' (D-M-Y)';
+ $DATE_FORMATS['m-d-Y'] = wbdate('m-d-Y').' (M-D-Y)';
+ $DATE_FORMATS['d.m.Y'] = wbdate('d.m.Y').' (D.M.Y)';
+ $DATE_FORMATS['m.d.Y'] = wbdate('m.d.Y').' (M.D.Y)';
+ $DATE_FORMATS['d/m/Y'] = wbdate('d/m/Y').' (D/M/Y)';
+ $DATE_FORMATS['m/d/Y'] = wbdate('m/d/Y').' (M/D/Y)';
+
+ // Add "System Default" to list (if we need to)
+ if(isset($user_time) AND $user_time == true) {
+ if(isset($TEXT['SYSTEM_DEFAULT'])) {
+ $DATE_FORMATS['system_default'] = wbdate(DEFAULT_DATE_FORMAT).' ('.$TEXT['SYSTEM_DEFAULT'].')';
+ } else {
+ $DATE_FORMATS['system_default'] = wbdate(DEFAULT_DATE_FORMAT).' (System Default)';
+ }
+ }
+//end timezone.extensions.php change
// Reverse array so "System Default" is at the top
$DATE_FORMATS = array_reverse($DATE_FORMATS, true);
diff -Naur websitebaker-2.6.5/wb/admin/interface/time_formats.php websitebaker-2.6.5.timezone-extensions/wb/admin/interface/time_formats.php
--- websitebaker-2.6.5/wb/admin/interface/time_formats.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/admin/interface/time_formats.php 2007-05-29 15:21:39.000000000 +0200
@@ -30,6 +30,11 @@
This file is used to generate a list of time formats for the user to select
*/
+//timezone.extensions.php change!
+//we made a lot of changes to this file. We no longer use mktime to make time and add TIMEZONE.
+//instead, we use the new wbdate call to create a date using the current TIMEZONE
+//problem with this is that date will allways be displayed in the current user's timezone, but well
+
if(!defined('WB_URL')) {
header('Location: ../index.php');
@@ -44,14 +49,23 @@
// Create array
$TIME_FORMATS = array();
+//timezone.extensions.php change
+//this code removed:
+/*
// Get the current time (in the users timezone if required)
if(isset($user_time) AND $user_time == true) {
$mktime = mktime()+TIMEZONE;
} else {
$mktime = mktime()+DEFAULT_TIMEZONE;
}
+//end timezone.extensions.php change
+
// Add values to list
+
+//timezone.extensions.php change
+ //old code:
+ /*
$TIME_FORMATS['g:i|A'] = gmdate('g:i A', $mktime);
$TIME_FORMATS['g:i|a'] = gmdate('g:i a', $mktime);
$TIME_FORMATS['H:i:s'] = gmdate('H:i:s', $mktime);
@@ -65,6 +79,22 @@
$TIME_FORMATS['system_default'] = gmdate(DEFAULT_TIME_FORMAT, $mktime).' (System Default)';
}
}
+*/
+ //new code:
+ $TIME_FORMATS['g:i|A'] = wbdate('g:i A');
+ $TIME_FORMATS['g:i|a'] = wbdate('g:i a');
+ $TIME_FORMATS['H:i:s'] = wbdate('H:i:s');
+ $TIME_FORMATS['H:i'] = wbdate('H:i');
+
+ // Add "System Default" to list (if we need to)
+ if(isset($user_time) AND $user_time == true) {
+ if(isset($TEXT['SYSTEM_DEFAULT'])) {
+ $TIME_FORMATS['system_default'] = wbdate(DEFAULT_TIME_FORMAT).' ('.$TEXT['SYSTEM_DEFAULT'].')';
+ } else {
+ $TIME_FORMATS['system_default'] = wbdate(DEFAULT_TIME_FORMAT).' (System Default)';
+ }
+ }
+//end timezone.extensions.php change
// Reverse array so "System Default" is at the top
$TIME_FORMATS = array_reverse($TIME_FORMATS, true);
diff -Naur websitebaker-2.6.5/wb/admin/pages/modify.php websitebaker-2.6.5.timezone-extensions/wb/admin/pages/modify.php
--- websitebaker-2.6.5/wb/admin/pages/modify.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/admin/pages/modify.php 2007-05-29 12:51:59.000000000 +0200
@@ -49,7 +49,12 @@
// Convert the unix ts for modified_when to human a readable form
if($results_array['modified_when'] != 0) {
- $modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
+ //timezone.extensions.php change!
+ //old code
+ // $modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
+ //new code
+ $modified_ts = wbdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']);
+ //end timezone.extensions.php change
} else {
$modified_ts = 'Unknown';
}
diff -Naur websitebaker-2.6.5/wb/admin/pages/settings.php websitebaker-2.6.5.timezone-extensions/wb/admin/pages/settings.php
--- websitebaker-2.6.5/wb/admin/pages/settings.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/admin/pages/settings.php 2007-05-29 12:52:28.000000000 +0200
@@ -65,7 +65,12 @@
// Convert the unix ts for modified_when to human a readable form
if($results_array['modified_when'] != 0) {
- $modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
+ //timezone.extensions.php change!
+ //old code
+ // $modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
+ //new code
+ $modified_ts = wbdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']);
+ //end timezone.extensions.php change
} else {
$modified_ts = 'Unknown';
}
diff -Naur websitebaker-2.6.5/wb/admin/preferences/details.php websitebaker-2.6.5.timezone-extensions/wb/admin/preferences/details.php
--- websitebaker-2.6.5/wb/admin/preferences/details.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/admin/preferences/details.php 2007-05-29 15:38:45.000000000 +0200
@@ -31,7 +31,30 @@
// Get entered values
$display_name = $admin->add_slashes(strip_tags($admin->get_post('display_name')));
$language = $admin->get_post('language');
-$timezone = $admin->get_post('timezone')*60*60;
+
+//timezone.extensions.php change!
+ //When using the new timezone framework, the timezone value will not be
+ //integer. In that case $value will just be saved (being a string)
+ // Spin in het web, 20070525
+
+ //old code:
+ //$timezone = $admin->get_post('timezone')*60*60;
+ //new code:
+ $timezone = $admin->get_post('timezone');
+ if (is_numeric($timezone))
+ $timezone = $timezone*60*60;
+ //this seemed to be missing in the original code
+ if($timezone == '-72000')
+ {
+ // Set a session var so apps can tell user is using default tz
+ $_SESSION['USE_DEFAULT_TIMEZONE'] = true;
+ }
+ else
+ {
+ unset($_SESSION['USE_DEFAULT_TIMEZONE']);
+ }
+//end timezone.extensions.php change
+
$date_format = $admin->get_post('date_format');
$time_format = $admin->get_post('time_format');
diff -Naur websitebaker-2.6.5/wb/admin/preferences/index.php websitebaker-2.6.5.timezone-extensions/wb/admin/preferences/index.php
--- websitebaker-2.6.5/wb/admin/preferences/index.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/admin/preferences/index.php 2007-05-29 15:47:42.000000000 +0200
@@ -25,6 +25,8 @@
require('../../config.php');
require_once(WB_PATH.'/framework/class.admin.php');
+
+
$admin = new admin('Preferences');
// Create new template object for the preferences form
@@ -66,12 +68,40 @@
}
// Insert default timezone values
-require(ADMIN_PATH.'/interface/timezones.php');
+
+//timezone.extensions.php change!
+ //We use a call that selects between php < 5.1 and above
+ // Spin in het web, 20070525
+
+ //old code:
+ //require(ADMIN_PATH.'/interface/timezones.php');
+ //new code:
+ set_TIMEZONES();
+//end timezone.extensions.php change
+
$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
+
+//timezone.extensions.php change!
+ //we save admin->get_timezone() once, saves calling it for once or twice for every timezone
+ //code added:
+
+ $admintz = $admin->get_timezone();
+//end timezone.extensions.php change
+
foreach($TIMEZONES AS $hour_offset => $title) {
$template->set_var('VALUE', $hour_offset);
$template->set_var('NAME', $title);
- if($admin->get_timezone() == $hour_offset*60*60) {
+ //timezone.extensions.php change!
+ //$hour_offset is a name when using new timezone code (EXCEPT for the standard value -20), otherwise a numeric string
+ //when it is a string, we should not do the hour->second conversion like with numeric
+ // Spin in het web, 20070525
+
+ //old code
+ //if($admin->get_timezone() == $hour_offset*60*60) {
+ //new code
+
+ if ((is_numeric($hour_offset) && $admintz == $hour_offset*60*60) || ((! is_numeric($hour_offset)) && $admintz == $hour_offset)) {
+ //end timezone.extensions.php change
$template->set_var('SELECTED', 'selected');
} else {
$template->set_var('SELECTED', '');
diff -Naur websitebaker-2.6.5/wb/admin/settings/index.php websitebaker-2.6.5.timezone-extensions/wb/admin/settings/index.php
--- websitebaker-2.6.5/wb/admin/settings/index.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/admin/settings/index.php 2007-05-25 15:52:50.000000000 +0200
@@ -158,14 +158,34 @@
}
// Insert default timezone values
-require(ADMIN_PATH.'/interface/timezones.php');
+
+//timezone.extensions.php change!
+ //We use a call that selects between php < 5.1 and above
+ // Spin in het web, 20070525
+
+ //old code:
+ //require(ADMIN_PATH.'/interface/timezones.php');
+ //new code:
+ set_TIMEZONES();
+//end timezone.extensions.php change
+
$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
foreach($TIMEZONES AS $hour_offset => $title) {
// Make sure we dont list "System Default" as we are setting this value!
if($hour_offset != '-20') {
$template->set_var('VALUE', $hour_offset);
$template->set_var('NAME', $title);
- if(DEFAULT_TIMEZONE == $hour_offset*60*60) {
+
+ //timezone.extensions.php change!
+ //$hour_offset is a name when using new timezone code (EXCEPT for the standard value -20), otherwise a numeric string
+ //when it is a string, we should not do the hour->second conversion like with numeric
+ // Spin in het web, 20070525
+
+ //old code
+ //if(DEFAULT_TIMEZONE == $hour_offset*60*60) {
+ //new code
+ if ((is_numeric($hour_offset) && DEFAULT_TIMEZONE == $hour_offset*60*60) || ((! is_numeric($hour_offset)) && DEFAULT_TIMEZONE == $hour_offset)) {
+ //end timezone.extensions.php change
$template->set_var('SELECTED', 'selected');
} else {
$template->set_var('SELECTED', '');
diff -Naur websitebaker-2.6.5/wb/admin/settings/save.php websitebaker-2.6.5.timezone-extensions/wb/admin/settings/save.php
--- websitebaker-2.6.5/wb/admin/settings/save.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/admin/settings/save.php 2007-05-25 15:32:07.000000000 +0200
@@ -126,6 +126,14 @@
$value = $admin->add_slashes($value);
switch ($setting_name) {
case 'default_timezone':
+ //timezone.extensions.php change!
+ //When using the new timezone framework, this value will not be
+ //integer. In that case $value will just be saved (being a string)
+ // Spin in het web, 20070525
+
+ //added code:
+ if (is_numeric($value))
+ //end timezone.extensions.php change
$value=$value*60*60;
break;
case 'string_dir_mode':
diff -Naur websitebaker-2.6.5/wb/framework/initialize.php websitebaker-2.6.5.timezone-extensions/wb/framework/initialize.php
--- websitebaker-2.6.5/wb/framework/initialize.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/framework/initialize.php 2007-05-29 12:21:18.000000000 +0200
@@ -23,6 +23,11 @@
*/
+//timezone.extensions.php added
+//Spin in het Web 20070525
+require_once(WB_PATH.'/framework/timezone.extensions.php');
+//
+
if (file_exists(WB_PATH.'/framework/class.database.php')) {
require_once(WB_PATH.'/framework/class.database.php');
@@ -79,12 +84,22 @@
}
}
- // Get users timezone
- if(isset($_SESSION['TIMEZONE'])) {
- define('TIMEZONE', $_SESSION['TIMEZONE']);
- } else {
- define('TIMEZONE', DEFAULT_TIMEZONE);
- }
+ //timezone.extensions.php change!
+ //we now fix the timezone for the new timezone framework (see timezone.extensions.php)
+ //old code
+ /*
+ // Get users timezone
+ if(isset($_SESSION['TIMEZONE'])) {
+ define('TIMEZONE', $_SESSION['TIMEZONE']);
+ } else {
+ define('TIMEZONE', DEFAULT_TIMEZONE);
+ }
+ */
+ //new code
+ init_timezone();
+ //end timezone.extensions.php change
+
+
// Get users date format
if(isset($_SESSION['DATE_FORMAT'])) {
define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
diff -Naur websitebaker-2.6.5/wb/framework/timezone.extensions.php websitebaker-2.6.5.timezone-extensions/wb/framework/timezone.extensions.php
--- websitebaker-2.6.5/wb/framework/timezone.extensions.php 1970-01-01 01:00:00.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/framework/timezone.extensions.php 2007-05-29 16:11:38.000000000 +0200
@@ -0,0 +1,209 @@
+<?php
+
+// Timezone Extensions
+// This code will take advantages of the new timezone framework offered by php >= 5.1
+// while making sure everything keeps working when using an older php version
+
+// New timezones are like Europe/Amsterdam and automatically support daylight saving time etc
+
+// This file is (c) 2007 Spin in het Web (http://www.spininhetweb.nl), Jelmer Jellema
+// This code is placed into the public domain. Use it at your own risk.
+
+
+// This code is used in the framework of:
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2007, Ryan Djurovich
+
+ Website Baker is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ Website Baker is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Website Baker; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+
+/*
+General functions that could be used elsewhere in the Website Baker code or templates. The usualy differ in functionality with the new features enbabled (TZ+) or disabled (TZ-)
+
+- init_timezone. To be called when initializing sessions. Will define TIMEZONE the way initialize.php used to do it and:
+TZ-: do nothing, except for some stuff when php was *downgraded*
+TZ+: Will set the constant TIMEZONENAME with the chosen (new) timezone. Will set the old constant TIMEZONE to the *current* offset of that timestamp, so old code using gmtdate(.., timestamp + TIMEZONE) still works. When the preferences or user settings contain an old style timezone, this call tries to find a matching TIMEZONENAME and use it.
+
+- set_TIMEZONES: sets the TIMEZONES array like admin/interface/timezones.php does.
+TZ-: Will call the timezones.php file
+TZ+: Will fill the TIMEZONES array with the new timezones. Values and indices are both timezone names.
+
+- wbdate(timeformat,[timestamp = mktime()]). Our implementation of date() and gmdate(). Use it instead of gmdate("..",time + TIMEZONE)
+TZ-: will return the built-in gmdate(timeformat,timestamp + TIMEZONE)
+TZ+: will return date(timeformat,timestamp), using the right timezone
+
+
+*/
+
+// Stop this file from being accessed directly
+if(!defined('WB_URL')) {
+ header('Location: ../index.php');
+ exit(0);
+}
+
+// Define that this file has been loaded
+define('TIMEZONE_EXTENSIONS_FILE_LOADED', true);
+
+//Can we use the new framework?
+
+if (function_exists('date_default_timezone_set'))
+{
+///////////////////////// USING THE NEW TIMEZONE FRAMEWORK //////////////////
+
+ function init_timezone()
+ {
+ // Get users timezone
+ if(isset($_SESSION['TIMEZONE']) && $_SESSION['TIMEZONE'] != '-72000')
+ $timezone = $_SESSION['TIMEZONE'];
+ else
+ $timezone = DEFAULT_TIMEZONE;
+
+ //do we have a numeric or normal timezone?
+ if (is_numeric($timezone))
+ {
+ //probably upgraded php lately?
+ //Lets see if we can find a good one
+ //this is not perfect, because we do not know is dst is running or not
+
+ //informed guess: does the server use DST
+
+
+ $tz = false;
+ if ($month < 5 or $month > 10)
+ $dst = 0;
+ else
+ $dst = 1;
+ if (function_exists('timezone_name_from_abbr')) //5.1.3
+ $tz = timezone_name_from_abbr("", $timezone,date('I'));
+
+ if (! $tz)
+ $tz = 'UTC'; //what else can we do?
+ define('TIMEZONENAME',$tz);
+ }
+ else
+ {
+ define('TIMEZONENAME', $timezone);
+ }
+
+ //we set TIMEZONE to the offset that is now current
+ //there is a problem with this. All offset calculating functionality is bèta in php 5.1 and not
+ //included by default. So we do some tricks here
+
+ $now_universal = mktime(); //tz-independend unix timestamp
+ $oldtz = date_default_timezone_get();
+ date_default_timezone_set('GMT');
+
+ $gmdate = getdate($now_universal);
+ date_default_timezone_set(TIMEZONENAME);
+ $now_in_tz = mktime($gmdate['hours'],$gmdate['minutes'],$gmdate['seconds'],$gmdate['mon'],$gmdate['mday'],$gmdate['year'],-1);
+
+ //if now_in_tz is less then now_universal, this means it is usualy *later* in the time zone than in GMT
+ //
+ define('TIMEZONE',$now_universal - $now_in_tz);
+
+ date_default_timezone_set($oldtz);
+
+ //print "TZ $timezone<br>Timezone: " . TIMEZONE . "<br>Session timezone: " . $_SESSION['TIMEZONE'] . "<br>Timezone name: " . TIMEZONENAME . "<br>Use default: " . ($_SESSION['USE_DEFAULT_TIMEZONE'] ? 'true' : 'false') . "<br>";
+
+ //we do NOT use date_default_timezone_set, because this will set the TZ environment, which gives problem
+ //when used in apache php module: even apache will start logging in the new timezone
+ }
+
+ function set_TIMEZONES()
+ {
+ //set the TIMEZONE array using the new style values
+ global $TIMEZONES;
+ global $TEXT;
+
+ $TIMEZONES = array();
+ // Add "System Default" to top of list, just like timezones.php
+ if(isset($TEXT['SYSTEM_DEFAULT'])) {
+ $TIMEZONES['-20'] = $TEXT['SYSTEM_DEFAULT'];
+ } else {
+ $TIMEZONES['-20'] = 'System Default';
+ }
+
+ //add the current server timezone on the top of the list
+ $tz = date_default_timezone_get();
+ if ($tz)
+ $TIMEZONES[$tz] = $tz;
+ foreach (DateTimeZone::listIdentifiers() as $tz)
+ {
+ $TIMEZONES[$tz] = $tz;
+ }
+ }
+
+ function wbdate($timeformat, $timestamp = -1)
+ {
+ //create a time string like date() and gmdate(), using the timezone in TIMEZONENAME
+ //this is the new framework version. Old framework will call gmdate
+
+ //set the tz only when really needed (see init_timezone above)
+ $oldtz = '';
+ $oldtz = date_default_timezone_get();
+ date_default_timezone_set(TIMEZONENAME);
+
+ if ($timestamp == -1)
+ $r = date($timeformat);
+ else
+ $r = date($timeformat, $timestamp);
+
+ date_default_timezone_set($oldtz);
+ return $r;
+ }
+}
+///////////////////////// NOT USING THE NEW TIMEZONE FRAMEWORK //////////////////
+else
+{
+ //NOT USING THE NEW TIMEZONE FRAMEWORK
+
+ function init_timezone()
+ {
+
+ // Get users timezone
+ if(isset($_SESSION['TIMEZONE']) && $_SESSION['TIMEZONE'] != '-72000')
+ $timezone = $_SESSION['TIMEZONE'];
+ else
+ $timezone = DEFAULT_TIMEZONE;
+
+ //very special case: downgrading php
+ if (! is_numeric($timezone))
+ define(TIMEZONE,0); #numeric again
+ else
+ define(TIMEZONE,$timezone);
+ }
+
+ function set_TIMEZONES()
+ {
+ //usual WB code to read the timezones
+ global $TIMEZONES;
+ require_once(ADMIN_PATH.'/interface/timezones.php');
+
+ }
+
+ function wbdate($timeformat, $timestamp = -1)
+ {
+ //in the old framework, wbdate does the same as gmdate(format, timestamp + TIMEZONE)
+
+ if ($timestamp == -1)
+ return gmdate($timeformat, mktime() + TIMEZONE);
+ else
+ return gmdate($timeformat, $timestamp + TIMEZONE);
+ }
+}
\ No newline at end of file
diff -Naur websitebaker-2.6.5/wb/install/index.php websitebaker-2.6.5.timezone-extensions/wb/install/index.php
--- websitebaker-2.6.5/wb/install/index.php 2006-12-25 02:38:05.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/install/index.php 2007-05-29 15:58:56.000000000 +0200
@@ -201,39 +201,64 @@
</td>
<td>
<select tabindex="3" name="default_timezone" style="width: 100%;">
- <?php
- $TIMEZONES['-12'] = 'GMT - 12 Hours';
- $TIMEZONES['-11'] = 'GMT -11 Hours';
- $TIMEZONES['-10'] = 'GMT -10 Hours';
- $TIMEZONES['-9'] = 'GMT -9 Hours';
- $TIMEZONES['-8'] = 'GMT -8 Hours';
- $TIMEZONES['-7'] = 'GMT -7 Hours';
- $TIMEZONES['-6'] = 'GMT -6 Hours';
- $TIMEZONES['-5'] = 'GMT -5 Hours';
- $TIMEZONES['-4'] = 'GMT -4 Hours';
- $TIMEZONES['-3.5'] = 'GMT -3.5 Hours';
- $TIMEZONES['-3'] = 'GMT -3 Hours';
- $TIMEZONES['-2'] = 'GMT -2 Hours';
- $TIMEZONES['-1'] = 'GMT -1 Hour';
- $TIMEZONES['0'] = 'GMT';
- $TIMEZONES['1'] = 'GMT +1 Hour';
- $TIMEZONES['2'] = 'GMT +2 Hours';
- $TIMEZONES['3'] = 'GMT +3 Hours';
- $TIMEZONES['3.5'] = 'GMT +3.5 Hours';
- $TIMEZONES['4'] = 'GMT +4 Hours';
- $TIMEZONES['4.5'] = 'GMT +4.5 Hours';
- $TIMEZONES['5'] = 'GMT +5 Hours';
- $TIMEZONES['5.5'] = 'GMT +5.5 Hours';
- $TIMEZONES['6'] = 'GMT +6 Hours';
- $TIMEZONES['6.5'] = 'GMT +6.5 Hours';
- $TIMEZONES['7'] = 'GMT +7 Hours';
- $TIMEZONES['8'] = 'GMT +8 Hours';
- $TIMEZONES['9'] = 'GMT +9 Hours';
- $TIMEZONES['9.5'] = 'GMT +9.5 Hours';
- $TIMEZONES['10'] = 'GMT +10 Hours';
- $TIMEZONES['11'] = 'GMT +11 Hours';
- $TIMEZONES['12'] = 'GMT +12 Hours';
- $TIMEZONES['13'] = 'GMT +13 Hours';
+ <?php
+ //timezone.extensions.php change!
+ //when available, we use the new timezone framework
+
+ //added code:
+ if (function_exists('date_default_timezone_set'))
+ {
+ //New timezone framework
+ $TIMEZONES = array();
+ //add the current server timezone on the top of the list
+ $tz = date_default_timezone_get();
+ if ($tz)
+ $TIMEZONES[$tz] = $tz;
+ foreach (DateTimeZone::listIdentifiers() as $tz)
+ {
+ $TIMEZONES[$tz] = $tz;
+ }
+ }
+ else
+ {
+ //old timezone framework
+ //old code still active:
+ $TIMEZONES['-12'] = 'GMT - 12 Hours';
+ $TIMEZONES['-11'] = 'GMT -11 Hours';
+ $TIMEZONES['-10'] = 'GMT -10 Hours';
+ $TIMEZONES['-9'] = 'GMT -9 Hours';
+ $TIMEZONES['-8'] = 'GMT -8 Hours';
+ $TIMEZONES['-7'] = 'GMT -7 Hours';
+ $TIMEZONES['-6'] = 'GMT -6 Hours';
+ $TIMEZONES['-5'] = 'GMT -5 Hours';
+ $TIMEZONES['-4'] = 'GMT -4 Hours';
+ $TIMEZONES['-3.5'] = 'GMT -3.5 Hours';
+ $TIMEZONES['-3'] = 'GMT -3 Hours';
+ $TIMEZONES['-2'] = 'GMT -2 Hours';
+ $TIMEZONES['-1'] = 'GMT -1 Hour';
+ $TIMEZONES['0'] = 'GMT';
+ $TIMEZONES['1'] = 'GMT +1 Hour';
+ $TIMEZONES['2'] = 'GMT +2 Hours';
+ $TIMEZONES['3'] = 'GMT +3 Hours';
+ $TIMEZONES['3.5'] = 'GMT +3.5 Hours';
+ $TIMEZONES['4'] = 'GMT +4 Hours';
+ $TIMEZONES['4.5'] = 'GMT +4.5 Hours';
+ $TIMEZONES['5'] = 'GMT +5 Hours';
+ $TIMEZONES['5.5'] = 'GMT +5.5 Hours';
+ $TIMEZONES['6'] = 'GMT +6 Hours';
+ $TIMEZONES['6.5'] = 'GMT +6.5 Hours';
+ $TIMEZONES['7'] = 'GMT +7 Hours';
+ $TIMEZONES['8'] = 'GMT +8 Hours';
+ $TIMEZONES['9'] = 'GMT +9 Hours';
+ $TIMEZONES['9.5'] = 'GMT +9.5 Hours';
+ $TIMEZONES['10'] = 'GMT +10 Hours';
+ $TIMEZONES['11'] = 'GMT +11 Hours';
+ $TIMEZONES['12'] = 'GMT +12 Hours';
+ $TIMEZONES['13'] = 'GMT +13 Hours';
+ //added code:
+ }
+ //end timezone.extensions.php change
+
foreach($TIMEZONES AS $hour_offset => $title) {
?>
<option value="<?php echo $hour_offset; ?>"<?php if(isset($_SESSION['default_timezone']) AND $_SESSION['default_timezone'] == $hour_offset) { echo ' selected'; } elseif(!isset($_SESSION['default_timezone']) AND $hour_offset == 0) { echo 'selected'; } ?>><?php echo $title; ?></option>
diff -Naur websitebaker-2.6.5/wb/install/save.php websitebaker-2.6.5.timezone-extensions/wb/install/save.php
--- websitebaker-2.6.5/wb/install/save.php 2006-12-25 02:13:59.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/install/save.php 2007-05-29 16:54:16.000000000 +0200
@@ -160,12 +160,35 @@
if(substr($wb_url, strlen($wb_url)-1, 1) == "\\") {
$wb_url = substr($wb_url, 0, strlen($wb_url)-1);
}
+
// Get the default time zone
-if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) {
- set_error('Please select a valid default timezone');
-} else {
- $default_timezone = $_POST['default_timezone']*60*60;
-}
+//timezone.extensions.php change!
+//when available, we use the new timezone framework
+
+ //added code:
+ if (function_exists('date_default_timezone_set'))
+ {
+ //New timezone framework
+ if(!isset($_POST['default_timezone']) OR is_numeric($_POST['default_timezone'])) {
+ set_error('Please select a valid default timezone');
+ } else {
+ $default_timezone = $_POST['default_timezone'];
+ }
+ }
+ else
+ {
+ //old timezone framework
+ //old code still active:
+
+ if(!isset($_POST['default_timezone']) OR !is_numeric($_POST['default_timezone'])) {
+ set_error('Please select a valid default timezone');
+ } else {
+ $default_timezone = $_POST['default_timezone']*60*60;
+ }
+ //added code:
+ }
+//end timezone.extensions.php change
+
// End path and timezone details code
// Begin operating system specific code
@@ -490,7 +513,10 @@
. ' `last_reset` INT NOT NULL DEFAULT \'0\','
. ' `display_name` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
. ' `email` TEXT NOT NULL ,'
- . ' `timezone` INT NOT NULL DEFAULT \'0\','
+//SIHW
+//. ' `timezone` INT NOT NULL DEFAULT \'0\','
+ . ' `timezone` VARCHAR(40) NOT NULL DEFAULT \'-72000\','
+//_SIHW
. ' `date_format` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
. ' `time_format` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
. ' `language` VARCHAR( 5 ) NOT NULL DEFAULT \'\' ,'
@@ -685,4 +711,4 @@
'GROUPS_TABLE' => TABLE_PREFIX."groups",
)
);
-?>
\ No newline at end of file
+?>
diff -Naur websitebaker-2.6.5/wb/modules/admin.php websitebaker-2.6.5.timezone-extensions/wb/modules/admin.php
--- websitebaker-2.6.5/wb/modules/admin.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/modules/admin.php 2007-05-29 16:06:51.000000000 +0200
@@ -112,7 +112,14 @@
// Convert the unix ts for modified_when to human a readable form
if($results_array['modified_when'] != 0) {
- $modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
+//timezone.extensions.php change!
+//old code
+ /*
+ $modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
+ */
+//new code
+ $modified_ts = wbdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']);
+//end timezone.extensions.php change
} else {
$modified_ts = 'Unknown';
}
diff -Naur websitebaker-2.6.5/wb/modules/backup/backup-sql.php websitebaker-2.6.5.timezone-extensions/wb/modules/backup/backup-sql.php
--- websitebaker-2.6.5/wb/modules/backup/backup-sql.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/modules/backup/backup-sql.php 2007-05-29 16:14:57.000000000 +0200
@@ -23,9 +23,6 @@
*/
-// Filename to use
-$filename = $_SERVER['HTTP_HOST'].'-backup-'.gmdate('Y-m-d', mktime()+TIMEZONE).'.sql';
-
// Check if user clicked on the backup button
if(!isset($_POST['backup'])){
header('Location: ../');
@@ -39,12 +36,32 @@
require(WB_PATH.'/framework/class.admin.php');
$admin = new admin('Settings', 'settings_advanced', false);
+// Filename to use
+
+//timezone.extensions.php change!
+//we moved it a bit
+//old code
+ /*
+ $filename = $_SERVER['HTTP_HOST'].'-backup-'.gmdate('Y-m-d', mktime()+TIMEZONE).'.sql';
+ */
+//new code
+ $filename = $_SERVER['HTTP_HOST'].'-backup-'.wbdate('Y-m-d', mktime()).'.sql';
+//end timezone.extensions.php change
+
+
// Begin output var
$output = "".
"#\n".
"# Website Baker ".WB_VERSION." Database Backup\n".
"# ".WB_URL."\n".
-"# ".gmdate(DATE_FORMAT, mktime()+TIMEZONE).", ".gmdate(TIME_FORMAT, mktime()+TIMEZONE)."\n".
+//timezone.extensions.php change!
+//old code
+ /*
+ "# ".gmdate(DATE_FORMAT, mktime()+TIMEZONE).", ".gmdate(TIME_FORMAT, mktime()+TIMEZONE)."\n".
+ */
+//new code
+ "# ".wbdate(DATE_FORMAT).", ".wbdate(TIME_FORMAT)."\n".
+//end timezone.extensions.php change
"#".
"\n";
diff -Naur websitebaker-2.6.5/wb/modules/form/modify.php websitebaker-2.6.5.timezone-extensions/wb/modules/form/modify.php
--- websitebaker-2.6.5/wb/modules/form/modify.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/modules/form/modify.php 2007-05-29 16:10:25.000000000 +0200
@@ -164,7 +164,16 @@
</a>
</td>
<td width="237"><?php echo $TEXT['SUBMISSION_ID'].': '.$submission['submission_id']; ?></td>
- <td><?php echo $TEXT['SUBMITTED'].': '.gmdate(TIME_FORMAT.', '.DATE_FORMAT, $submission['submitted_when']+TIMEZONE); ?></td>
+ <td><?php echo $TEXT['SUBMITTED'].': '.
+ //timezone.extensions.php change!
+ //old code
+ /*
+ gmdate(TIME_FORMAT.', '.DATE_FORMAT, $submission['submitted_when']+TIMEZONE);
+ */
+ //new code
+ wbdate(TIME_FORMAT.', '.DATE_FORMAT, $submission['submitted_when']);
+ //end timezone.extensions.php change
+ ?></td>
<td width="20">
<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/form/delete_submission.php?page_id=<?php echo $page_id; ?>§ion_id=<?php echo $section_id; ?>&submission_id=<?php echo $submission['submission_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
diff -Naur websitebaker-2.6.5/wb/modules/form/view_submission.php websitebaker-2.6.5.timezone-extensions/wb/modules/form/view_submission.php
--- websitebaker-2.6.5/wb/modules/form/view_submission.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/modules/form/view_submission.php 2007-05-29 16:09:11.000000000 +0200
@@ -63,7 +63,16 @@
</tr>
<tr>
<td><?php echo $TEXT['SUBMITTED']; ?>:</td>
- <td><?php echo gmdate(TIME_FORMAT.', '.DATE_FORMAT, $submission['submitted_when']+TIMEZONE); ?></td>
+ <td><?php
+ //timezone.extensions.php change!
+ //old code
+ /*
+ echo gmdate(TIME_FORMAT.', '.DATE_FORMAT, $submission['submitted_when']+TIMEZONE);
+ */
+ //new code
+ echo wbdate(TIME_FORMAT.', '.DATE_FORMAT, $submission['submitted_when']);
+ //end timezone.extensions.php change
+ ?></td>
</td>
<tr>
<td><?php echo $TEXT['USER']; ?>:</td>
diff -Naur websitebaker-2.6.5/wb/modules/news/view.php websitebaker-2.6.5.timezone-extensions/wb/modules/news/view.php
--- websitebaker-2.6.5/wb/modules/news/view.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/modules/news/view.php 2007-05-29 16:18:00.000000000 +0200
@@ -167,8 +167,16 @@
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active
$uid = $post['posted_by']; // User who last modified the post
// Workout date and time of last modified post
- $post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE);
- $post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE);
+ //timezone.extensions.php change!
+ //old code
+ /*
+ $post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE);
+ $post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE);
+ */
+ //new code
+ $post_date = wbdate(DATE_FORMAT, $post['posted_when']);
+ $post_time = wbdate(TIME_FORMAT, $post['posted_when']);
+ //end timezone.extensions.php change
// Work-out the post link
$post_link = page_link($post['link']);
if(isset($_GET['p']) AND $position > 0) {
@@ -257,8 +265,16 @@
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false) { // Make sure parent group is active
$uid = $post['posted_by']; // User who last modified the post
// Workout date and time of last modified post
- $post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE);
- $post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE);
+ //timezone.extensions.php change!
+ //old code
+ /*
+ $post_date = gmdate(DATE_FORMAT, $post['posted_when']+TIMEZONE);
+ $post_time = gmdate(TIME_FORMAT, $post['posted_when']+TIMEZONE);
+ */
+ //new code
+ $post_date = wbdate(DATE_FORMAT, $post['posted_when']);
+ $post_time = wbdate(TIME_FORMAT, $post['posted_when']);
+ //end timezone.extensions.php change
// Get group id, title, and image
$group_id = $post['group_id'];
$group_title = $groups[$group_id]['title'];
@@ -305,8 +321,16 @@
$comment['comment'] = nl2br(($comment['comment']));
$comment['title'] = ($comment['title']);
// Print comments loop
- $commented_date = gmdate(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
- $commented_time = gmdate(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
+ //timezone.extensions.php change!
+ //old code
+ /*
+ $commented_date = gmdate(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
+ $commented_time = gmdate(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
+ */
+ //new code
+ $commented_date = wbdate(DATE_FORMAT, $comment['commented_when']);
+ $commented_time = wbdate(TIME_FORMAT, $comment['commented_when']);
+ //end timezone.extensions.php change
$uid = $comment['commented_by'];
$vars = array('[TITLE]','[COMMENT]','[DATE]','[TIME]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
diff -Naur websitebaker-2.6.5/wb/search/search.php websitebaker-2.6.5.timezone-extensions/wb/search/search.php
--- websitebaker-2.6.5/wb/search/search.php 2006-12-24 08:50:44.000000000 +0100
+++ websitebaker-2.6.5.timezone-extensions/wb/search/search.php 2007-05-29 16:06:07.000000000 +0200
@@ -150,8 +150,16 @@
// Set vars to be replaced by values
$vars = array('[LINK]', '[TITLE]', '[DESCRIPTION]', '[USERNAME]','[DISPLAY_NAME]','[DATE]','[TIME]','[TEXT_LAST_UPDATED_BY]','[TEXT_ON]');
if($page['modified_when'] > 0) {
- $date = gmdate(DATE_FORMAT, $page['modified_when']+TIMEZONE);
- $time = gmdate(TIME_FORMAT, $page['modified_when']+TIMEZONE);
+ //timezone.extensions.php change!
+ //old code
+ /*
+ $date = gmdate(DATE_FORMAT, $page['modified_when']+TIMEZONE);
+ $time = gmdate(TIME_FORMAT, $page['modified_when']+TIMEZONE);
+ */
+ //new code
+ $date = wbdate(DATE_FORMAT, $page['modified_when']);
+ $time = wbdate(TIME_FORMAT, $page['modified_when']);
+ //end timezone.extensions.php change
} else {
$date = $TEXT['UNKNOWN'].' '.$TEXT['DATE'];
$time = $TEXT['UNKNOWN'].' '.$TEXT['TIME'];
@@ -218,8 +226,16 @@
// Set vars to be replaced by values
$vars = array('[LINK]', '[TITLE]', '[DESCRIPTION]', '[USERNAME]','[DISPLAY_NAME]','[DATE]','[TIME]','[TEXT_LAST_UPDATED_BY]','[TEXT_ON]');
if($page[$fields['modified_when']] > 0) {
- $date = gmdate(DATE_FORMAT, $page[$fields['modified_when']]+TIMEZONE);
- $time = gmdate(TIME_FORMAT, $page[$fields['modified_when']]+TIMEZONE);
+ //timezone.extensions.php change!
+ //old code
+ /*
+ $date = gmdate(DATE_FORMAT, $page[$fields['modified_when']]+TIMEZONE);
+ $time = gmdate(TIME_FORMAT, $page[$fields['modified_when']]+TIMEZONE);
+ */
+ //new code
+ $date = wbdate(DATE_FORMAT, $page[$fields['modified_when']]);
+ $time = wbdate(TIME_FORMAT, $page[$fields['modified_when']]);
+ //end timezone.extensions.php change
} else {
$date = $TEXT['UNKNOWN'].' '.$TEXT['DATE'];
$time = $TEXT['UNKNOWN'].' '.$TEXT['TIME'];