Users Online Today Mod

Started by Nibogo, November 06, 2005, 01:42:31 AM

Previous topic - Next topic

DemonicInfluence

What latest? It is still 1.3.0 rc3...

I am pretty sure the boardindex.php file is modified correctly according to 1.3.0 rc3 because when i uninstall, it works properly...

QuoteAlso that you are patching the files that are actually served by the webserver.

What does that mean?

Carceri

Quote from: Libo on November 18, 2005, 11:49:05 AM
QuoteAlso that you are patching the files that are actually served by the webserver.
What does that mean?
If you have multiple forums, then that you are patching the right one :) Yes, a longshot, but the behaviour you are experiencing are not consistent with 1.3.0 RC3.

DemonicInfluence

very long shot. I only have one forum...

Ah, i see. it was because I had multiple edits. I must have had one from 1.0 and frogot to uninstall.

It works perfectly now...

Only question when is stats center gonna be working?

beemer

#83
Quote from: Libo on November 18, 2005, 02:57:50 PM
very long shot. I only have one forum...

Ah, i see. it was because I had multiple edits. I must have had one from 1.0 and frogot to uninstall.

It works perfectly now...

Only question when is stats center gonna be working?


It is ? Isnt it?

GREAT Mod Thanx alot Carceri
http://www.bmw7resource.co.uk
SMF 1.1 RC1
MKP 1.1 RC1
Helios Multi RC1
-------------------------------------------------------
http://www.thefishsheadnhorsesarse.co.uk
SMF 1.1 RC2
TinyPortal 0.8.6

Carceri

Quote from: Libo on November 18, 2005, 02:57:50 PM
Only question when is stats center gonna be working?
One short answer: I don't know :) Right now things are working and the added functionality to the stats center is a feature for a future release. I have looked at it briefly and it doesn't seem to be that hard to implement, but it will require changes to the database. When I have some time to do it, I will do it, but I can't promise a date.

The most important thing for me (regarding this mod) was to get 1.3.0 final ready which is done now.

Thanks all for helping me with the timezone problems. I'm glad that so many people can actually use this mod that I originally made just for myself :)

Juggler

OK,

Just logged into my forum (6:51am) and it's not picking me up as being logged in today. So as far as the "Users Online Today" Section is concerned no one has been online as it's it's showing 0 people online. So I made sure it wasn't a theme problem and went into the default theme and it still shows 0 people online.

Thoughts?
The Blue Buzzards
Flying Scooter Display Team
#69 Squadron
www.bluebuzzards.com

Carceri

Must be some timezone problem that haven't been fixed. You know what information I need to look at it :)

Of course, first make sure that you are running 1.3.0

Juggler

Well I installed the latest version the other day but when checking the files I found that it still had the old offset code. So I changed the code as mentioned in the thread but still have the same problem. I'm at work at the moment so I can't access the files just set so I'll dig into it later.

Which files do you need again?
The Blue Buzzards
Flying Scooter Display Team
#69 Squadron
www.bluebuzzards.com

Carceri

I would like to know the server time, forum time, whether or not the error occurs when you are logged in or as guest. If you can provide your BoardIndex.php then I can see that there are no old parts of some previous modification that are messing things up.

Juggler

No problem, I'll dig it out later. Looking at the admin side of things I'm at plus 5 on the overall offset to bring it to UK time. So I guess that would make it 1.51am on the server?

I'll mail/PM you the boardIndex file when I can get at it.
The Blue Buzzards
Flying Scooter Display Team
#69 Squadron
www.bluebuzzards.com

Juggler

OK, managed to access the file via my cpanel so here's all the Online Today stuff from it :-

Quote// Load the users online today.
   $nowdate = @getdate(forum_time(false));
   $midnight = mktime(0, 0, 0, $nowdate['mon'], $nowdate['mday'], $nowdate['year']) - ($modSettings['time_offset'] * 3600);

   $s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
   if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
      $time_fmt = '%I:%M' . $s . ' %p';
   else
      $time_fmt = '%H:%M' . $s;

   $result = db_query("
      SELECT
         mem.ID_MEMBER, mem.lastLogin, mem.realName, mem.memberName, mem.showOnline,
         mg.onlineColor, mg.ID_GROUP, mg.groupName
      FROM {$db_prefix}members AS mem
         LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)) WHERE mem.lastLogin >= $midnight", __FILE__, __LINE__);

   $context['users_online_today'] = array();
   $context['list_users_online_today'] = array();

   while ($row = mysql_fetch_assoc($result))
   {
      $userday = strftime('%d', forum_time(true));
      $loginday = strftime('%d', forum_time(true, $row['lastLogin']));
      $yesterday = $userday == $loginday ? '' : $txt['uot_yesterday'];
   
      $lastLogin = $yesterday . strftime($time_fmt, forum_time(true, $row['lastLogin']));
      $title = (allowedTo('moderate_forum') || !empty($row['showOnline'])) ? ' title="' . $lastLogin . '"' : '';

      // Some basic color coding...
      if (!empty($row['onlineColor']))
         $link = ' $row['ID_MEMBER'],
         'username' => $row['memberName'],
         'name' => $row['realName'],
         'group' => $row['ID_GROUP'],
         'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
         'link' => $link,
         'is_buddy' => $is_buddy,
         'hidden' => empty($row['showOnline']),
      );

      $context['list_users_online_today'][$row['lastLogin'] . $row['memberName']] = (empty($row['showOnline']) && allowedTo('moderate_forum')) ? '' . $link . '' : $link;
   }
   mysql_free_result($result);

   krsort($context['users_online_today']);
   krsort($context['list_users_online_today']);

   $context['num_users_online_today'] = count($context['users_online_today']);
         
   // Load the users online today.
   $frag = explode('-', strftime('%Y-%m-%d', time()));
$midnight = forum_time(false, mktime(0, 0, 0, (int) $frag[1], (int) $frag[2], (int) $frag[0]));

   $s = strpos($user_info['time_format'], '%S') === false ? '' : ':%S';
   if (strpos($user_info['time_format'], '%H') === false && strpos($user_info['time_format'], '%T') === false)
      $time_fmt = '%I:%M' . $s . ' %p';
   else
      $time_fmt = '%H:%M' . $s;

   $result = db_query("
      SELECT
         mem.ID_MEMBER, mem.lastLogin, mem.realName, mem.memberName, mem.showOnline,
         mg.onlineColor, mg.ID_GROUP, mg.groupName
      FROM {$db_prefix}members AS mem
         LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)) WHERE mem.lastLogin >= $midnight", __FILE__, __LINE__);

   $context['users_online_today'] = array();
   $context['list_users_online_today'] = array();

   while ($row = mysql_fetch_assoc($result))
   {
      $lastLogin = strftime($time_fmt, forum_time(true, $row['lastLogin']));
      $title = (allowedTo('moderate_forum') || !empty($row['showOnline'])) ? ' title="' . $lastLogin . '"' : '';

      // Some basic color coding...
      if (!empty($row['onlineColor']))
         $link = ' $row['ID_MEMBER'],
         'username' => $row['memberName'],
         'name' => $row['realName'],
         'group' => $row['ID_GROUP'],
         'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
         'link' => $link,
         'is_buddy' => $is_buddy,
         'hidden' => empty($row['showOnline']),
      );

      $context['list_users_online_today'][$row['lastLogin'] . $row['memberName']] = (empty($row['showOnline']) && allowedTo('moderate_forum')) ? '' . $link . '' : $link;
   }
   mysql_free_result($result);

   krsort($context['users_online_today']);
   krsort($context['list_users_online_today']);

   $context['num_users_online_today'] = count($context['users_online_today']);
         
   // Load the users online right now.
   $result = db_query("
      SELECT
         lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
         mg.onlineColor, mg.ID_GROUP, mg.groupName
      FROM {$db_prefix}log_online AS lo
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
         LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))", __FILE__, __LINE__);

   $context['users_online'] = array();
   $context['list_users_online'] = array();
   $context['online_groups'] = array();
   $context['num_guests'] = 0;
   $context['num_buddies'] = 0;
   $context['num_users_hidden'] = 0;

   $context['show_buddies'] = !empty($user_info['buddies']);

   while ($row = mysql_fetch_assoc($result))
   {
      if (empty($row['realName']))
      {
         $context['num_guests']++;
         continue;
      }
      elseif (empty($row['showOnline']) && !allowedTo('moderate_forum'))
      {
         $context['num_users_hidden']++;
         continue;
      }

      // Some basic color coding...
      if (!empty($row['onlineColor']))
         $link = '' . $row['realName'] . '';
      else
         $link = '' . $row['realName'] . '';

      $is_buddy = in_array($row['ID_MEMBER'], $user_info['buddies']);
      if ($is_buddy)
      {
         $context['num_buddies']++;
         $link = '' . $link . '';
      }

      $context['users_online'][$row['logTime'] . $row['memberName']] = array(
         'id' => $row['ID_MEMBER'],
         'username' => $row['memberName'],
         'name' => $row['realName'],
         'group' => $row['ID_GROUP'],
         'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
         'link' => $link,
         'is_buddy' => $is_buddy,
         'hidden' => empty($row['showOnline']),
      );

      $context['list_users_online'][$row['logTime'] . $row['memberName']] = empty($row['showOnline']) ? '' . $link . '' : $link;

      if (!isset($context['online_groups'][$row['ID_GROUP']]))
         $context['online_groups'][$row['ID_GROUP']] = array(
            'id' => $row['ID_GROUP'],
            'name' => $row['groupName'],
            'color' => $row['onlineColor']
         );
   }
   mysql_free_result($result);

   krsort($context['users_online']);
   krsort($context['list_users_online']);
   ksort($context['online_groups']);

   $context['num_users_online'] = count($context['users_online']) + $context['num_users_hidden'];
The Blue Buzzards
Flying Scooter Display Team
#69 Squadron
www.bluebuzzards.com

Jorg40

I have a small problem

"2.     Execute Modification     ./Themes/default/BoardIndex.template.php     Failure"

What is the cause to this? I'm using a skin, can that be the problem?

Carceri

Quote from: Juggler on November 19, 2005, 06:54:57 AM
OK, managed to access the file via my cpanel so here's all the Online Today stuff from it :-

You have both the old and the new version installed. The line

// Load the users online today.

indicates the start of the mod, but is present two places in the file. First comes the new version and after that the old version, which overwrites the settings from the new version.

Carceri

Quote from: Jorg40 on November 19, 2005, 11:01:48 AM
I have a small problem

"2.     Execute Modification     ./Themes/default/BoardIndex.template.php     Failure"

What is the cause to this? I'm using a skin, can that be the problem?
Apparently something has changed BoardIndex.template.php and my mod is only tested agains the original file. You can probably still apply the mod manually.

Jorg40

#94
How to install it manually?

Here is the total list of errors in 1.3.0

1. Execute Modification ./Sources/BoardIndex.php Success
2. Execute Modification ./Sources/Stats.php Failure
3. Execute Modification ./Themes/default/BoardIndex.template.php Failure
4. Execute Modification ./Themes/default/Stats.template.php Failure
5. Execute Modification ./Themes/default/languages/Modifications.english.php Success
6. Execute Modification ./Themes/default/languages/Stats.english.php Failure

I use SMF 1.0.5

Carceri


Jorg40

What version does it support then?

Carceri

Quote from: Jorg40 on November 19, 2005, 03:57:52 PM
What version does it support then?
It is written on the download page for the mod... 1.1 RC1

Jorg40

Sorry, didnt read close enough... so now I have one last question:

How does I change the path of the install to anther skin?
Or do I have to install it manually then?

Carceri

Quote from: Jorg40 on November 19, 2005, 04:51:03 PM
How does I change the path of the install to anther skin?
Or do I have to install it manually then?
You can change the file section of the mod, but I would suggest to install it manually as it might not even work on some themes.

Advertisement: