WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.13.x) »
  • General Help & Support »
  • need some code help
  • Print
Pages: [1]   Go Down

Author Topic: need some code help  (Read 9101 times)

Offline crnogorac081

  • Posts: 2161
  • Gender: Male
need some code help
« 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 ?
Logged
Web developer

Offline crnogorac081

  • Posts: 2161
  • Gender: Male
Re: need some code help
« Reply #1 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.'\'';


Logged
Web developer

Offline sternchen8875

  • Global Moderator
  • *****
  • Posts: 601
Re: need some code help
« Reply #2 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


Logged

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 3087
  • Gender: Female
Re: need some code help
« Reply #3 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
Logged
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"We need education to cope with digitalization - and NOT the digitalization of education.!"

Tägliches Stoßgebet: Oh Herr, wirf Hirn vom Himmel !

Offline crnogorac081

  • Posts: 2161
  • Gender: Male
Re: need some code help
« Reply #4 on: October 10, 2023, 04:21:12 PM »
Thank you both I understand now
Logged
Web developer

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.13.x) »
  • General Help & Support »
  • need some code help
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2