phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Active members in the last 24 hours


 
Search this topic... | Search MOD Requests... | Search Box
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Author Message
Sylver Cheetah 53
Board Member



Joined: 17 Dec 2008

Posts: 426
Location: Milky Way


flag
PostPosted: Fri Jul 30, 2010 11:57 pm 
Post subject: Active members in the last 24 hours

I am not decided what MOD to choose for doing this. For the momment, I am thinking about Users of the daz 2.1
Code:
## MOD Title:   Users of the day
## MOD Version: 2.1
## Author:     ZoZo <zozo@etoiles.net>
##
## Description: 
## Displays, under the online users list, a list of the registered users
## who have visited during the last XX hours. Can also display the list
## of the users who didn't come. (see "Edit below")
##
## Installation Level:  easy
## Installation Time:  2-3 minutes
##
## Files To Edit:         3
##                   - /templates/subSilver/index_body.tpl
##                   - /language/lang_english/lang_main.php
##                   - /includes/page_header.php
##
## Included Files:      None

But the problem is it can show who has not been connected, if the admin chooses. I&#355;m afraid that, even if I decide to not show up who has not beeen conected (not interesting!), the SQL querry could still run. Not sure if that's a fact. icon_confused.gif
Code:
#-----[ ACTION: open ]---------------------------------
#
/templates/subSilver/index_body.tpl
#
#-----[ ACTION: find ]---------------------------------
#
   <td class="row1" align="center" valign="middle" rowspan="2"><img src="templates/subSilver/images/whosonline.gif" alt="{L_WHO_IS_ONLINE}" /></td>
#
#-----[ ACTION: replace by ]---------------------------
#
   <td class="row1" align="center" valign="middle" rowspan="3"><img src="templates/subSilver/images/whosonline.gif" alt="{L_WHO_IS_ONLINE}" /></td>
#
#-----[ ACTION: find ]---------------------------------
#
   <td class="row1" align="left"><span class="gensmall">{TOTAL_USERS_ONLINE} &nbsp; [ {L_WHOSONLINE_ADMIN} ] &nbsp; [ {L_WHOSONLINE_MOD} ]<br />{RECORD_USERS}<br />{LOGGED_IN_USER_LIST}</span></td>
#
#-----[ ACTION: add after ]----------------------------
#
  </tr>
  <tr>
   <td class="row1" align="left"><span class="gensmall">{USERS_OF_THE_DAY_LIST}</span></td>
#
#-----[ ACTION: repeat for all templates ]-------------
#



#
#-----[ ACTION: open ]--------------------------------
#
/language/lang_english/lang_main.php
#
#-----[ ACTION: find ]--------------------------------
#
$lang['Registered_users'] = 'Registered Users:';
#
#-----[ ACTION: add before ]--------------------------
#
$lang['Day_users'] = '%d registered users visit during the last %d hours:';
$lang['Not_day_users'] = '%d registered users <span style="color:red">DIDN\'T</span> visit during the last %d hours:';
#
#-----[ ACTION: repeat for all languages ]------------
#



#
#-----[ ACTION: open ]--------------------------------
#
/includes/page_header.php
#
#-----[ ACTION: find ]--------------------------------
#
   'LOGGED_IN_USER_LIST' => $online_userlist,
#
#-----[ ACTION: add after ]---------------------------
#
   'USERS_OF_THE_DAY_LIST' => $day_userlist,
#
#-----[ ACTION: find ]--------------------------------
#
//
// Obtain number of new private messages
// if user is logged in
//
#
#-----[ ACTION: add before ]--------------------------
#
//
// Users of the day MOD
//

// ############ Edit below ############
// #
$display_not_day_userlist = 0;   // change to 1 here if you also want the list of the users who didn't visit to be displayed
$users_list_delay = 24;      // change here to the number of hours wanted for the list
// #
// ############ Edit above ############

$sql = "SELECT user_id, username, user_allow_viewonline, user_level, user_session_time
   FROM ".USERS_TABLE."
   WHERE user_id > 0
   ORDER BY IF(user_level=1,3,user_level) DESC, username ASC";
if( !($result = $db->sql_query($sql)) )
{
   message_die(GENERAL_ERROR, 'Could not obtain user/day information', '', __LINE__, __FILE__, $sql);
}

$day_userlist = '';
$day_users = 0;
$not_day_userlist = '';
$not_day_users = 0;

while( $row = $db->sql_fetchrow($result) )
{
   $style_color = '';
   if ( $row['user_level'] == ADMIN )
   {
      $row['username'] = '<b>' . $row['username'] . '</b>';
      $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
   }
   else if ( $row['user_level'] == MOD )
   {
      $row['username'] = '<b>' . $row['username'] . '</b>';
      $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
   }
   if ( $row['user_allow_viewonline'] )
   {
      $user_day_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a>';
   }
   else
   {
      $user_day_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><i>' . $row['username'] . '</i></a>';
   }
   if ( $row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )
   {
      if ( $row['user_session_time'] >= ( time() - $users_list_delay * 3600 ) )
      {
         $day_userlist .= ( $day_userlist != '' ) ? ', ' . $user_day_link : $user_day_link;
         $day_users++;
      }
      else
      {
         $not_day_userlist .= ( $not_day_userlist != '' ) ? ', ' . $user_day_link : $user_day_link;
         $not_day_users++;
      }
   }
}

$day_userlist = ( ( isset($forum_id) ) ? '' : sprintf($lang['Day_users'], $day_users, $users_list_delay) ) . ' ' . $day_userlist;

$not_day_userlist = ( ( isset($forum_id) ) ? '' : sprintf($lang['Not_day_users'], $not_day_users, $users_list_delay) ) . ' ' . $not_day_userlist;

if ( $display_not_day_userlist )
{
   $day_userlist .= '<br />' . $not_day_userlist;
}

//
// End of MOD

If that's a fact and if there is no better MOD for what I want, probably this should be modified to completly take out the bits of code refering to the possibility to display non-active members. icon_rolleyes.gif

_________________
Image link
My Forum || My Blog

phpBB2 forever! icon_smile.gif
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 418
Location: Québec


flag
PostPosted: Sat Jul 31, 2010 12:42 am 
Post subject: Re: Active members in the last 24 hours

As far as I can tell, they are using only one and the same query either way, so you would have to change it to something like this:

Code:
$sql = "SELECT user_id, username, user_allow_viewonline, user_level, user_session_time
   FROM ".USERS_TABLE."
   WHERE user_id > 0 AND user_session_time >= " . time() - $users_list_delay * 3600 . "
   ORDER BY IF(user_level=1,3,user_level) DESC, username ASC";

I'm not 100% that query is legit, but you get the idea. However with this code the MOD would ONLY work when not showing inactive members. You can fix that easily by using $display_not_day_userlist to check a condition and use a different query in either case.
Back to top
Sylver Cheetah 53
Board Member



Joined: 17 Dec 2008

Posts: 426
Location: Milky Way


flag
PostPosted: Mon Aug 02, 2010 1:58 am 
Post subject: Re: Active members in the last 24 hours

This is perfect: http://www.phpbb.com/community/viewtopic.php?f=15&t=398165&start=135
_________________
Image link
My Forum || My Blog

phpBB2 forever! icon_smile.gif
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0311 seconds using 15 queries. (SQL 0.0019 Parse 0.0008 Other 0.0284)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo