Kod: Tümünü seç
###################################################################################
##
## Hack Title: Who is active in which forum - Index
## Hack Version: 1.0.3
## Author: Acid
## Support: http://www.phpbbhacks.com/forums/
##
## Description: You can see which user is active in which forum.. on index.
##
## Files To Edit: 3
## index.php
## language/lang_english/lang_main.php
## templates/xxx/index_body.tpl
##
###################################################################################
##
## Note:
## First always make a back-up from the files that you're going to edit.
##
## I used the code from page_header.php.
##
## See optional part at bottom of this file.
##
###################################################################################
##
## Revision History:
##
## v1.0.3 - Junior Admins/Supermoderators will be displayed in their own color now
## - forgot to delete some code
## v1.0.2 - fixed a typo
## v1.0.1 - just cleaned the code and added optional part
## v1.0.0 - Release
##
##########################################################################################
#
#-----[ ACTION: OPEN ]------------------------------------------
# index.php
#
#-----[ FIND ]------------------------------------------
#
$template->assign_block_vars('catrow.forumrow', array(
'ROW_COLOR' => '#' . $row_color,
#
#-----[ REPLACE WITH ]------------------------------------------
#
// start: forum active
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip, s.session_page
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 300 ) . " AND s.session_page = $forum_id
ORDER BY u.username ASC, s.session_ip ASC";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain activities in forums.', '', __LINE__, __FILE__, $sql);
}
$userlist_ary = array();
$userlist_visible = array();
$logged_visible_active = 0;
$logged_hidden_active = 0;
$guests_active = 0;
$active_userlist = '';
$prev_user_id = 0;
$prev_user_ip = '';
while( $row = $db->sql_fetchrow($result) )
{
if ( $row['session_logged_in'] )
{
if ( $row['user_id'] != $prev_user_id )
{
$style_color = '';
if ( $row['user_level'] == ADMIN )
{
$row['username'] = '<b>' . $row['username'] . '</b>';
$style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
}
else if ( $row['user_level'] == JUNIOR_ADMIN )
{
$row['username'] = '<b>' . $row['username'] . '</b>';
$style_color = 'style="color:#00B0FF"'; // color can be changed of course
}
else if ( $row['user_level'] == LESS_ADMIN )
{
$row['username'] = '<b>' . $row['username'] . '</b>';
$style_color = 'style="color:#00B0FF"'; // color can be changed of course
}
else if ( $row['user_level'] == MOD )
{
$row['username'] = '<b>' . $row['username'] . '</b>';
$style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
}
if ( $row['user_allow_viewonline'] )
{
$user_active_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a>';
$logged_visible_active++;
}
else
{
$user_active_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><i>' . $row['username'] . '</i></a>';
$logged_hidden_active++;
}
if ( $row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )
{
$active_userlist .= ( $active_userlist != '' ) ? ', ' . $user_active_link : $user_active_link;
}
}
$prev_user_id = $row['user_id'];
}
else
{
if ( $row['session_ip'] != $prev_session_ip )
{
$guests_active++;
}
}
$prev_session_ip = $row['session_ip'];
}
$total_active_users = $logged_visible_active + $logged_hidden_active + $guests_active;
$l_t_user_s = ( $total_active_users == 0 ) ? $lang['Forum_no_active'] : ( ( $total_active_users == 1 ) ? $lang['Forum_one_active'] : $lang['Forum_more_active'] );
$l_h_user_s = ( $logged_hidden_active == 0 || $userdata['user_level'] == ADMIN ) ? '' : ( ( $logged_hidden_active == 1 ) ? $lang['Forum_one_hidden_active'] : $lang['Forum_more_hidden_active'] );
$l_g_user_s = ( $guests_active == 0 ) ? '' : ( ( $guests_active == 1 ) ? $lang['Forum_one_guest_active'] : $lang['Forum_more_guest_active'] );
$l_active_users = sprintf($l_t_user_s, $total_active_users);
$l_active_users_info = sprintf($l_h_user_s, $logged_hidden_active);
$l_active_users_info .= sprintf($l_g_user_s, $guests_active);
$active_total = $l_active_users;
$active_info = $l_active_users_info;
$active = $active_userlist;
// end: forum active
$template->assign_block_vars('catrow.forumrow', array(
'ACTIVE' => $active,
'ACTIVE_TOTAL' => $active_total,
'ACTIVE_INFO' => $active_info,
'ROW_COLOR' => '#' . $row_color,
#
#-----[ ACTION: OPEM ]------------------------------------------
# language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
$lang['Moderators'] = 'Moderators';
#
#-----[ BELOW ADD ]------------------------------------------
#
// if you don´t want to display "0 users" uncomment the following
// and put the slashes before the other "0 users" line
// $lang['Forum_no_active'] = '';
$lang['Forum_no_active'] = '<b>0</b> Users active'; // <-- this one
$lang['Forum_one_active'] = '<b>%d</b> User active: ';
$lang['Forum_more_active'] = '<b>%d</b> Users active: ';
$lang['Forum_one_hidden_active'] = '<b>%d</b> Hidden';
$lang['Forum_more_hidden_active'] = '<b>%d</b> Hidden';
$lang['Forum_one_guest_active'] = '<b>%d</b> Guest';
$lang['Forum_more_guests_active'] = '<b>%d</b> Guests';
#
#-----[ ACTION: OPEN ]------------------------------------------
# templates/xxx/index_body.tpl
#
#-----[ FIND ]------------------------------------------
#
</span><span class="gensmall">{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}</span></td>
#
#-----[ REPLACE WITH ]------------------------------------------
# if you can´t find the mentioned line (maybe you´re using a different template) just
# search for a part of it
</span><span class="gensmall">{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}</span><br />
<span class="gensmall">{catrow.forumrow.ACTIVE_TOTAL} {catrow.forumrow.ACTIVE} {catrow.forumrow.ACTIVE_INFO}</span></td>
###################################################################################
#
#-----[ OPTIONAL PART ]---------------------------------------------
#
# if you have the "junior admin" or "super mod" hack installed and want to
# change the displayed color
#
#-----[ FIND (index.php) ]------------------------------------------
#
# replace #00B0FF with your color
else if ( $row['user_level'] == JUNIOR_ADMIN || $row['user_level'] == LESS_ADMIN )
{
$row['username'] = '<b>' . $row['username'] . '</b>';
$style_color = 'style="color:#00B0FF"';
}
#-------------------------------------------------------------------
# if you want to enable this activities information only for admins
#
#-----[ FIND (index.php) ]------------------------------------------
#
$active_total = $l_active_users;
$active_info = $l_active_users_info;
$active = $active_userlist;
#
#-----[ REPLACE WITH ]----------------------------------------------
#
if( $userdata['user_level'] == ADMIN )
{
$active_total = $l_active_users;
$active_info = $l_active_users_info;
$active = $active_userlist;
}
#-------------------------------------------------------------------
# if you want to enable the current activities information only
# for the moderators of the current forums
#
#-----[ FIND (index.php) ]------------------------------------------
#
$active_total = $l_active_users;
$active_info = $l_active_users_info;
$active = $active_userlist;
#
#-----[ REPLACE WITH ]----------------------------------------------
#
$is_auth = array();
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_topic_data);
if( $is_auth['auth_mod'] )
{
$active_total = $l_active_users;
$active_info = $l_active_users_info;
$active = $active_userlist;
}
###################################################################################
###################################################################################