I assume that you have created your login pages by adding the phpbb code to the top of them.WhiskeyMike wrote:This may have already been addressed but after going through about 60 results pages, I gave up. I'm trying to do some integration. I've successfully done the login/logout with no problems. Now I'm trying to see if there's a script that will not only show how MANY people are online, but who they are.
An actual list of usernames that are currently online, like at the bottom of the forum index... only for use on a non PHPBB page.
Code: Select all
<?php
//
// Get user list
//
$sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_time, s.session_page, s.session_ip, u.user_session_time, s.session_start
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 300 ) . "
ORDER BY u.username ASC, s.session_ip ASC";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql);
}
$guest_users = 0;
$registered_users = 0;
$hidden_users = 0;
$reg_counter = 0;
$guest_counter = 0;
$prev_user = 0;
$prev_ip = '';
while ( $row = $db->sql_fetchrow($result) )
{
$view_online = false;
if ( $row['session_logged_in'] )
{
$user_id = $row['user_id'];
if ( $user_id != $prev_user )
{
$username = $row['username'];
// SIMPLE COLORED USERGROUPS MOD START
$style_color = ($user_color = color_groups_user($row['user_id'])) ? 'style="font-weight:bold;color: #' . $user_color . '"' : '';
$username = '<span ' . $style_color . '>' . $username . '</span>';
// COLOR GROUPS END
if ( !$row['user_allow_viewonline'] )
{
$view_online = ( $userdata['user_level'] == ADMIN ) ? true : false;
$hidden_users++;
$username = '<i>' . $username . '</i>';
}
else
{
$view_online = true;
$registered_users++;
}
$which_counter = 'reg_counter';
$which_row = 'reg_user_row';
$prev_user = $user_id;
}
}
else
{
if ( $row['session_ip'] != $prev_ip )
{
$username = $lang['Guest'];
$view_online = true;
$guest_users++;
$which_counter = 'guest_counter';
$which_row = 'guest_user_row';
}
}
$prev_ip = $row['session_ip'];
if ( $view_online )
{
if ( $row['session_page'] < 1 || !$is_auth_ary[$row['session_page']]['auth_view'] )
{
switch( $row['session_page'] )
{
case PAGE_INDEX:
$location = 'Site index';
$location_url = "index.$phpEx";
break;
case PAGE_ABOUT:
$location = 'Browsing about page';
$location_url = "about.$phpEx";
break;
case PAGE_FORUM:
$location = 'Forum index';
$location_url = "forum.$phpEx";
break;
case PAGE_POSTING:
$location = 'Posting a message';
$location_url = "index.$phpEx";
break;
case PAGE_READING:
$location = 'Viewing a post';
$location_url = "index.$phpEx";
break;
case PAGE_LOGIN:
$location = 'Logging in';
$location_url = "login.$phpEx";
break;
case PAGE_SEARCH:
$location = 'Searching';
$location_url = "search.$phpEx";
break;
case PAGE_PROFILE:
$location = 'Viewing a profile';
$location_url = "index.$phpEx";
break;
case PAGE_VIEWONLINE:
$location = 'Viewing online users';
$location_url = "viewonline.$phpEx";
break;
case PAGE_ADMIN:
$location = 'Administration control panel';
$location_url = "adm/index.$phpEx";
break;
case PAGE_VIEWMEMBERS:
$location = 'Viewing memberlist';
$location_url = "memberlist.$phpEx";
break;
case PAGE_PRIVMSGS:
$location = 'Browsing mailbox';
$location_url = "privmsg.$phpEx";
break;
case PAGE_FAQ:
$location = 'Viewing FAQs';
$location_url = "faq.$phpEx";
break;
case PAGE_GAMES:
$location = 'Playing games';
$location_url = "games.$phpEx";
break;
case PAGE_USERCP:
$location = 'Browsing user control panel';
$location_url = "usercp.$phpEx";
break;
default:
$location = 'about';
$location_url = "index.$phpEx";
}
}
else
{
$location_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . '=' . $row['session_page']);
$location = $forum_data[$row['session_page']];
}
$reg_ip = decode_ip($row['session_ip']);
$last_update = create_date($userdata['user_dateformat'], $row['user_session_time'], $userdata['user_timezone']);
$session_start = create_date($userdata['user_dateformat'], $row['session_start'], $userdata['user_timezone']);
$each .= ( $$which_counter % 2 ) ? '<tr class="row2">' : '<tr class="row1">' ;
$each .= '<td><a href="../viewprofile.php?id=' . $row['user_id'] . '">' . $username . '</a></td><td>' . $session_start . '</td><td>' . $last_update . '</td><td><a href="' . $phpbb_root_path . $location_url . '">' . $location . '</a></td><td>' . $reg_ip . '</td></tr>';
$$which_counter++;
}
}
if( $registered_users == 0 )
{
$l_r_user_s = $lang['Reg_users_zero_online'];
}
else if( $registered_users == 1 )
{
$l_r_user_s = $lang['Reg_user_online'];
}
else
{
$l_r_user_s = $lang['Reg_users_online'];
}
if( $hidden_users == 0 )
{
$l_h_user_s = $lang['Hidden_users_zero_online'];
}
else if( $hidden_users == 1 )
{
$l_h_user_s = $lang['Hidden_user_online'];
}
else
{
$l_h_user_s = $lang['Hidden_users_online'];
}
if( $guest_users == 0 )
{
$l_g_user_s = $lang['Guest_users_zero_online'];
}
else if( $guest_users == 1 )
{
$l_g_user_s = $lang['Guest_user_online'];
}
else
{
$l_g_user_s = $lang['Guest_users_online'];
}
?>
Code: Select all
$each .= ( $$which_counter % 2 ) ? '<tr class="row2">' : '<tr class="row1">' ;
$each .= '<td><a href="../viewprofile.php?id=' . $row['user_id'] . '">' . $username . '</a></td><td>' . $session_start . '</td><td>' . $last_update . '</td><td><a href="' . $phpbb_root_path . $location_url . '">' . $location . '</a></td><td>' . $reg_ip . '</td></tr>';
Code: Select all
$each .= '<a href="profile.' . $phpEx . '?mode=viewprofile&u=' . $row['user_id'] . '">' . $username . '</a>, ';