WebsiteBaker Community Forum

WebsiteBaker Support (2.13.x) => General Help & Support => Topic started by: crnogorac081 on October 09, 2023, 07:48:06 PM

Title: need some code help
Post by: crnogorac081 on October 09, 2023, 07:48:06 PM
I am writing some code, and I need to get data from loged in user, like

Code: [Select]

$this->oReg->getUserId();

but it is not working. The code is inside the class, so it possible to get loged in user data without using $admin or Session ?
Title: Re: need some code help
Post by: crnogorac081 on October 09, 2023, 11:46:56 PM
I found this in oApp - $this->oApp->->getUserId();


Also would like to report to add timezone to Login class, in lines 419 AND 577 I believe

from
Code: [Select]
                             . 'SET `login_when`='.\time().', '
to

Code: [Select]
                             . 'SET `login_when`='.\time() + $this->oReg->DefaultTimezone.', '

where origianal code is

Code: [Select]
                        $sql = 'UPDATE `'.TABLE_PREFIX.'users` '
                             . 'SET `login_when`='.\time().', '
                             .     '`login_ip`=\''.$sRemoteAddress.'\' '
                             . 'WHERE `user_id`=\''.$user_id.'\'';


Title: Re: need some code help
Post by: sternchen8875 on October 10, 2023, 12:44:28 PM
to the timezone (the old theme...)

normalize, all times are stored in the database in UTC (that's London time). for account-specific datas, the system search everytime, when needed, for the timezone of the logged user and add this timezone to the utc-time. in other, no-user-timezone-specific, it use the DefaultTimezone from the WB-Settings, for example: the date of the last modification in the frontend.

to understand all this, we need an example:

i was for a long time the admin of a charter boot service homepage in the caribic, the page was hosted in germany, because, the owner was a german. so the server-time was utc. as admin, i use utc+1 in winter and utc+2 in summertime. DefaultTimezone in Wb-Settings was UTC +5 and the page-owner has also utc +5 in his profile, because, he live's there in the caribic. If the two of us, the owner and I, log in at the same time, with the "private timezone-settings" from the user-profile, his login time will be 4:30 p.m. (UTC +5) and mine will be 1:30 p.m. (UTC +2), but we are online at the same time. if we use the globale DefaultTimezone from the WB-Settings, the database say's: i'm online at 4.30 p.m., but here it is 0.30 p.m.
If we only use time(), everyone has the same time in the database and WB then uses the profile data to calculate the correct time


Title: Re: need some code help
Post by: DarkViper on October 10, 2023, 01:03:41 PM
It is definitely not a good idea to change the kind of table column value. Other modules and also the core trust on the fact that they find a time in UTC here and not values ​​that are distorted by any time zone information.
Note: Never change other modules without really knowing all the side effects that can be triggered!
Time zone information should only be used for input and display purposes. All internal time calculations are always carried out in UTC.
This is the only way to ensure stable handling across all time zones.

Example:
Code: [Select]
Input : Local_time - Timezone = UTC
Output: UTC + Timezone        = Local_time

have a nice day
Manuela
Title: Re: need some code help
Post by: crnogorac081 on October 10, 2023, 04:21:12 PM
Thank you both I understand now