
04-24-2003, 02:09 PM
|
 |
|
|
Join Date: Jan 2002
Posts: 133
Благодарил(а): 0 раз(а)
Поблагодарили:
0 раз(а) в 0 сообщениях
|
|
Quote:
03-20-03 at 05:55 PM AlexanderT said this in Post #335
Actually, I changed the way to calculate local midnight in the snippet below. I think now everything is correct.
PHP Code:
$enddate = time();
$localdate = $enddate-(($timeoffset-$bbuserinfo['timezoneoffset'])*3600);
$date = getdate($localdate);
$day = $date['mday'];
$month = $date['mon'];
$year = $date['year'];
$midnight = mktime(0,0,0,$month, $day, $year);
$timepassed = $localdate - $midnight;
$startdate = $enddate - $timepassed;
$todayusers=$DB_site->query("SELECT userid, username, usergroupid, lastactivity, invisible FROM user
WHERE lastactivity BETWEEN $startdate AND $enddate
ORDER BY username");
With this code, 'Number of Active Users Today' should display the correct number of active users since local midnight of the current user logged in. 
What is still not taken care of different TZs is the 'Most users ever online on a day' part. With the current implementation of the hack, I don't think this is possible. Why? --
Imagine that in the timezone of your user, until 23:59pm you had 100 visitors on your board. Further imagine that all these 100 visitors visited at 23:50pm (your time). Finally imagine that this is the greatest number of visitors your board has ever seen in one day. So for you, that is for your user and all other users in your timezone, 'Most users ever online on a day' is 100.
So far so good. Now imagine that at 00:10am your time 10 more users logged in. For you, 'Most users ever online on a day' should be still 100, namely from the day before. However, for another user whose timezone is e.g. -1, 'Most users ever online on a day' is now 110, since he still hasn't reached midnight (it is 23:10pm) for him. As a result, the variable holding the Most users contains 110 now. And that means also for you, who is already in the next day, 'Most users ever online on a day' is suddenly 110. You see the problem?!
Greets
Alexander
|
Where do you put this code?
|