Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-06-2008, 03:57 AM
Akuma2000 Akuma2000 is offline
 
Join Date: Dec 2007
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Show users online on html/php page other than forum

Which code/script can let me show the users online on a html/php website other than the forum?

With PHPBB I'm using this code:

Code:
<?php
define('IN_PHPBB', true);
$phpbb_root_path = "forum/"; 
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.'.$phpEx); 
@$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length); 
@init_userprefs($userdata); 
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip 
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"; 
$result = $db->sql_query($sql); 
if(!$result) 
{ 
message_die(GENERAL_ERROR, "Couldn't obtain user/online information.", "", __LINE__, __FILE__, $sql); 
} 
$userlist_ary = array(); 
$userlist_visible = array(); 
$logged_visible_online = 0; 
$logged_hidden_online = 0; 
$guests_online = 0; 
$online_userlist = ""; 
$prev_user_id = 0; 
$prev_session_ip = 0; 
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'] == MOD ) 
{ 
$row['username'] = '<b>' . $row['username'] . '</b>'; 
$style_color = 'style="color:#' . $theme['fontcolor2'] . '"'; 
} 
if( $row['user_allow_viewonline'] ) 
{ 
$user_online_link = '<a href="' . append_sid($phpbb_root_path."profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .' target="_blank">' . $row['username'] . '</a>'; 
$logged_visible_online++; 
} 
else 
{ 
$user_online_link = '<a href="' . append_sid($phpbb_root_path."profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><i>' . $row['username'] . 'target="_blank"</i></a>'; 
$logged_hidden_online++; 
} 
 
if( $row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN ) 
{ 
$online_userlist .= ( $online_userlist != "" ) ? ", " . $user_online_link : $user_online_link; 
} 
} 
} 
else 
{ 
if( $row['session_ip'] != $prev_session_ip )
{
$guests_online++; 
} 
} 
$prev_user_id = $row['user_id']; 
$prev_session_ip = $row['session_ip']; 
} 
if( empty($online_userlist) ) 
{ 
$online_userlist = $lang['None']; 
} 
$online_userlist = ( ( isset($forum_id) ) ? $lang['Browsing_forum'] : $lang['Registered_users'] ) . " " . $online_userlist; 
$total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online; 
if( $total_online_users == 0 ) 
{ 
$l_t_user_s = $lang['Online_users_zero_total']; 
} 
else if( $total_online_users == 1 ) 
{ 
$l_t_user_s = $lang['Online_user_total']; 
} 
else 
{ 
$l_t_user_s = $lang['Online_users_total']; 
} 
if( $logged_visible_online == 0 ) 
{ 
$l_r_user_s = $lang['Reg_users_zero_total']; 
} 
else if( $logged_visible_online == 1 ) 
{ 
$l_r_user_s = $lang['Reg_user_total']; 
} 
else 
{ 
$l_r_user_s = $lang['Reg_users_total']; 
} 
if( $logged_hidden_online == 0 ) 
{ 
$l_h_user_s = $lang['Hidden_users_zero_total']; 
} 
else if( $logged_hidden_online == 1 ) 
{ 
$l_h_user_s = $lang['Hidden_user_total']; 
} 
else 
{ 
$l_h_user_s = $lang['Hidden_users_total']; 
} 
if( $guests_online == 0 ) 
{ 
$l_g_user_s = $lang['Guest_users_zero_total']; 
} 
else if( $guests_online == 1 ) 
{ 
$l_g_user_s = $lang['Guest_user_total']; 
} 
else 
{ 
$l_g_user_s = $lang['Guest_users_total']; 
} 
$l_online_users = sprintf($l_t_user_s, $total_online_users); // all users
$l_online_users .= sprintf($l_r_user_s, $logged_visible_online); // visible users
$l_online_users .= sprintf($l_h_user_s, $logged_hidden_online); // hidden users
$l_online_users .= sprintf($l_g_user_s, $guests_online); // guests
$onlinet="$l_online_users<br>$online_userlist<br>"; 
echo "
<body leftmargin=\"7\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">
<p style='font: 12px arial; color: #000000;'>" . $onlinet . "</p>
";
?>

Is this also available with vbulletin?
I hope so!
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:16 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03738 seconds
  • Memory Usage 2,330KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete