KalenderMx 1.4 Timezone

Begonnen von spcx, 19 August 2005, 19:09:05

⏪ vorheriges - nächstes ⏩

0 Mitglieder und 1 Gast betrachten dieses Thema.

spcx

Hi Jubilee, finally I get to registered an account and managed to start a thread. Sorry but I dont understand a single German word. Sorry  :-X

Alright, I have KalenderMx 1.4b at my site www.mash.com.my

Here's my problem:

I'm in a GMT +8 timezone, and my server is actually at GMT -5. My events' timing are out of sync from my timezone, it's slowed by 13 hours. Can I know what code I should change to adjust the Kalender's timezone? Is there a way to set the GMT for the Kalender instead of following the server's timezone? Probably adding 13 hours (+13) at $timestamp or @mktime ? I'm not a PHP code wiz, and I'm having real headaches. Been fixing this for 3 days and still not able to fix it.

PLEASE HELP!  :-\

jubilee

#1
Howdi !
ZitatSorry but I dont understand a single German word. Sorry
Don't worry about that.
My teacher always told me that i  don't write any korrect german word ;)

ZitatI'm in a GMT +8 timezone, and my server is actually at GMT -5....slowed by 13 hours
That is seriously an little problem
We have to wait for Andi. He has written the Module and knows it best.
Maybe he has a solution.

greetings
jubilee

spcx

i'll be waiting ya, thanks so much jubilee. hope you'll let andi know abot this.

jubilee

Hello !
Zitathope you'll let andi know abot this.
Still done ;)
Hope he finds time during weekend to look an find a solution.

greetings
jubilee

Andi

Hello :)

yes, this is an old problem in this calendar.
I'm searching for a solution for a long time...

I will look at this in the next few days, but i think there is no quick solution.
Maybe...
schön´s Grüssle, Andi

spcx

Alright Andi, thanks for looking up into this. I hope we get a solution here. By the way, you could have a look at some other calenders, I think there are some which u're able to change the timezone.

Maybe in the date() or mktime strings, I could add an extra 13 hours into it, making it from GMT-5 (my server time) to GMT +8 (my timezone)?

thanks, hope I'll be getting some answers, love ur kalender anyways. :)

jubilee

Hello !
ZitatMaybe in the date() or mktime strings, I could add an extra 13 hours into it, making it from GMT-5 (my server time) to GMT +8 (my timezone)?
That *could* work. But remember there are several places in the source where this must altered.
A other solution: Is that a virtual or a root server you are using. Maybe you can set the general servertime
to your needs ?
other solution (and @Andi: vielleicht hilft das in diesem Fall ? )
i found in old php-Docs for setting new Timezone temporally:

<?php
//Set the Timezone
print("server timezone is: " . getenv('TZ') . "\n");
print("server time is: " . date("H:i:s") . "\n");
print("changing server time zone to US/Pacific....\n");
putenv("TZ=US/Pacific"); // this sets new timezone
print("new server time is: " . date("H:i:s") . "\n");
print("new server timezone for this script is: " . getenv('TZ'));
//some Unix servers may use a different format for TZ.  Example: putenv("TZ=PST8EDT");
// runs in php3 but not sure for php4
?>

For that SafeMode must disabled. With enabled SafeMode putenv ist not accesible
greetings
jubilee

spcx

ZitatThat *could* work. But remember there are several places in the source where this must altered.

Can Andi help me with this? I'm sure editing the date() or mktime strings could produce a result. But I'm not really sure because I'm not a coder wiz.

ZitatA other solution: Is that a virtual or a root server you are using. Maybe you can set the general servertime
to your needs ?

Virtual server. Requested for a server timezone change but failed. :)

Zitatother solution (and @Andi: vielleicht hilft das in diesem Fall ? )
i found in old php-Docs for setting new Timezone temporally:
<?php
//Set the Timezone
print("server timezone is: " . getenv('TZ') . "\n");
print("server time is: " . date("H:i:s") . "\n");
print("changing server time zone to US/Pacific....\n");
putenv("TZ=US/Pacific"); // this sets new timezone
print("new server time is: " . date("H:i:s") . "\n");
print("new server timezone for this script is: " . getenv('TZ'));
//some Unix servers may use a different format for TZ.  Example: putenv("TZ=PST8EDT");
// runs in php3 but not sure for php4
?>

i think this is for Unix servers only, I'm in Windows IIS server. I could try this out, not sure it works for IIS server. Where do I insert this code? index.php of my Nuke root? or index.php of Kalender's module?

Thx jubilee for trying to help out.

BowlingX

Try to change the index.php of the calender's modul. Just paste this line: after -> if(!defined()...)
putenv("TZ=US/Pacific"); // this sets new timezone

David
Kein Support über Mail, (ungefragter) PN oder ICQ, ausschließlich direkt im Forum!

spcx

Hi Bowling, I've added this into my Kalender's module index.php

if (eregi(basename(__file__), $_SERVER["PHP_SELF"])) die ("classement: You can't access this file directly...");

if (!defined("CAL_MODULE_NAME")) define("CAL_MODULE_NAME",basename(dirname(__FILE__)));
if (!defined("CAL_MODULE_PATH")) define("CAL_MODULE_PATH","modules/".CAL_MODULE_NAME."/");

if (!isset($calconf))             @include(CAL_MODULE_PATH."config/config.php");
if (!defined("CAL_TABLE_EVENTS")) @include_once(CAL_MODULE_PATH."includes/functions.php");
putenv("TZ=Asia/Kuala_Lumpur"); // this sets new timezone
get_lang(CAL_MODULE_NAME);

global $popupwidth, $popupdelay;

Notice the putenv("TZ=Asia/Kuala_Lumpur"); // this sets new timezone I've inserted. Is it correct? Currently there isn't any effect yet. :/

Thanks anyway, any other solutions?

jubilee

#10
Hello !
ZitatNotice the putenv("TZ=Asia/Kuala_Lumpur"); // this sets new timezone I've inserted. Is it correct? Currently there isn't any effect yet. :/
Hmmm ....
Try this :
<?php
$wgLocaltimezone = "UTC";
$wgLocalTZoffset = date("Z") / 3600;
putenv("TZ=".$wgLocaltimezone."-".$wgLocalTZoffset.""); // if going west take - if going east take +
mktime(0,0,0,1,1,1980) //dirty hack sometimes timezone putenv doesn't work without
?>
this should set the Timezone to your local Timezone (eg.to the Timezone of the requesting webbrowser)

But the general problem could be this  (from php-docu)
Zitat
Setting certain environment variables may be a potential security breach. The safe_mode_allowed_env_vars directive contains a comma-delimited list of prefixes. In Safe Mode, the user may only alter environment variables whose names begin with the prefixes supplied by this directive. By default, users will only be able to set environment variables that begin with PHP_ (e.g. PHP_FOO=BAR). Note: if this directive is empty, PHP will let the user modify ANY environment variable!

The safe_mode_protected_env_vars directive contains a comma-delimited list of environment variables, that the end user won't be able to change using putenv(). These variables will be protected even if safe_mode_allowed_env_vars is set to allow to change them.

So if SafeMode is active you have to look for php-config-var safe_mode_allowed_env_vars
where putenv TZ must be listed. But NOT in safe_mode_protected_env_vars.
And remeber this setting in a script only works for script execution. When script execution ends, it will be resetted to default (eg. when you switch to another script via Webform etc. ).

greetings
jubilee

spcx

Ok jubilee, when I've inserted the code into Kalender's index.php, I get a blank page when i click on the events link at my block. :(

Grrrr, I'm sure there's a way to add in 13 hours in the index.php script at the mktime strings, just that i'm not good enuff in php.