Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Who's Online Sidebar Block Details »»
Who's Online Sidebar Block
Version: 1.00, by grey_goose grey_goose is offline
Developer Last Online: Mar 2020 Show Printable Version Email this Page

Category: vBulletin Forum Sideblocks - Version: 4.1.4 Rating:
Released: 07-13-2011 Last Update: Never Installs: 35
Template Edits
Translations  
No support by the author.

This is tested and working with Everywhere Sidebar 4 VB4

Step One: Create a Template
ACP > Style Manager > Add New Template
Title: block_online
Code:
<div class="blocksubhead">{vb:rawphrase x_members_and_y_guests, {vb:raw numberregistered}, {vb:raw numberguest}}</div>
<div class="blockrow">
  <vb:if condition="$activeusers">
    <vb:each from="activeusers" value="loggedin">
      <a class="username" href="{vb:link member, {vb:raw loggedin}}">{vb:raw loggedin.musername}</a>{vb:raw loggedin.invisiblemark}{vb:raw loggedin.buddymark},
    </vb:each>
  <vb:else />
    {vb:rawphrase no_x_online, {vb:rawphrase members}}
  </vb:if>
</div>
<div class="blockrow">{vb:rawphrase most_users_ever_online_was_x_y_at_z, {vb:raw recordusers}, {vb:raw recorddate}, {vb:raw recordtime}}</div>
Step Two: Create the Block
ACP > Forums & Moderators > Forum Blocks Manager > Add Block
Select Block Type: Custom HTML/PHP
Title: Online Users
Cache Time (in minutes): 5
Active: Yes
Content Type: PHP
Code:
global $vbulletin;
global $db;

// space separated list of group ids to filter out
$filter_groupids = "";

// members logged into forums
$loggedinusers = array();
$activeusers = array();
$invisiblecount = 0;

// Logged in user
if ($vbulletin->userinfo['userid'])
  {
    $loggedinusers[$vbulletin->userinfo['userid']] = array(
      'userid' => $vbulletin->userinfo['userid'],
      'username' => $vbulletin->userinfo['username'],
      'invisiblemark' => ($vbulletin->userinfo['invisible']) ? '*' : '',
      'displaygroupid' => $vbulletin->userinfo['displaygroupid'],
      'musername' => fetch_musername($vbulletin->userinfo)
    );
  }

$getonline = $db->query_read("
			SELECT session.userid, username, usergroupid, (user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, membergroupids
			FROM " . TABLE_PREFIX . "session AS session
			LEFT JOIN " . TABLE_PREFIX . "user AS user USING (userid)
			WHERE session.lastactivity > " . (TIMENOW - $vbulletin->options['cookietimeout']) . "
			ORDER BY username ASC
		");

$filter_groupids = explode(" ", $filter_groupids);
while ($onlineusers = $db->fetch_array($getonline))
  {
    if (!$onlineusers['userid'])
      {
	$numberguest++;
      }
    else
      {
	if ($onlineusers['invisible'])
	  {
	    if (($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehidden']) OR $onlineusers['userid'] == $vbulletin->userinfo['userid'])
	      {
		$onlineusers['invisiblemark'] = '*';
	      }
	    else
	      {
		$invisiblecount++;
		continue;
	      }
	  }

	$groupids = array();
	array_push($groupids, $onlineusers['usergroupid'], $onlineusers['displaygroupid']);
	$groupids = array_merge
	  (
	   $groupids,
	   explode(" ", $onlineusers['membergroupids'])
	  );
	foreach($groupids as $value)
	  if(in_array($value, $filter_groupids))
	    continue;
	$loggedinusers[$onlineusers['userid']] = $onlineusers;
      }
  }

$db->free_result($getonline);
unset($onlineusers);

// ##### Process Online Users Module
$numberregistered = sizeof($loggedinusers);
$show['comma_leader'] = false;
$show['divrow'] = false;

if (!empty($loggedinusers))
  {
    foreach ($loggedinusers AS $loggedinuserid => $loggedin)
      {
	$loggedin['musername'] = fetch_musername($loggedin);

	($hook = vBulletinHook::fetch_hook('vba_cmps_module_onlineuserbits')) ? eval($hook) : false;

	$activeusers[$loggedinuserid] = $loggedin;
      }
  }

// Process the total first, before number_format is applied
$totalonline = $numberregistered + $numberguest + $invisiblecount;

if ($vbulletin->maxloggedin['maxonline'] <= $totalonline)
  {
    $vbulletin->maxloggedin['maxonline'] = $totalonline;
    $vbulletin->maxloggedin['maxonlinedate'] = TIMENOW;
    build_datastore('maxloggedin', serialize($vbulletin->maxloggedin), 1);
  }

$totalonline = vb_number_format($totalonline);
$numberregistered = vb_number_format($numberregistered + $invisiblecount);
$numberguest = vb_number_format($numberguest);

$recordusers = vb_number_format($vbulletin->maxloggedin['maxonline']);
$recorddate = vbdate($vbulletin->options['dateformat'], $vbulletin->maxloggedin['maxonlinedate'], 1);
$recordtime = vbdate($vbulletin->options['timeformat'], $vbulletin->maxloggedin['maxonlinedate']);

// print everything 
$templater = vB_Template::create('block_online');
$templater->register('activeusers', $activeusers);
$templater->register('altbgclass', $altbgclass);
$templater->register('bgclass', $bgclass);
$templater->register('numberguest', $numberguest);
$templater->register('numberregistered', $numberregistered);
$templater->register('recorddate', $recorddate);
$templater->register('recordtime', $recordtime);
$templater->register('recordusers', $recordusers);
$content = $templater->render();
unset($loggedinusers, $activeusers);
return $content;
Line 5 of the block can be edited to exclude usergroups from displaying at:
$filter_groupids = "(insert numbers here)";

Enjoy.

Screenshots

File Type: png OnlineUserBlock.png (31.7 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Благодарность от:
Rodrigo.

Comments
  #2  
Old 07-14-2011, 01:02 AM
CaneInsider CaneInsider is offline
 
Join Date: Sep 2010
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed. Anyway to turn off showing who is online? I have over 750 members logged in so it makes my sidebar go down a long way....
Reply With Quote
  #3  
Old 07-14-2011, 02:43 AM
Khriz's Avatar
Khriz Khriz is offline
 
Join Date: Apr 2011
Location: Per?
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="https://vborg.vbsupport.ru/showthread.php?t=233965" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=233965</a> ?
Reply With Quote
  #4  
Old 07-14-2011, 10:47 AM
grey_goose grey_goose is offline
 
Join Date: Jun 2009
Posts: 284
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

CI: Time permitting, I'll give it a go

Khriz: We never could get that to work with ESB, this one does *shrug*
Reply With Quote
  #5  
Old 07-14-2011, 02:03 PM
Khriz's Avatar
Khriz Khriz is offline
 
Join Date: Apr 2011
Location: Per?
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I will test it
I will try to block lateral statistics
I want to have a sidebar similar to xenforo ^ ^
Reply With Quote
  #6  
Old 07-14-2011, 03:38 PM
grey_goose grey_goose is offline
 
Join Date: Jun 2009
Posts: 284
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Prove what? There's a screenshot and installs, it works.

Done trolling now ?
Reply With Quote
  #7  
Old 07-14-2011, 04:13 PM
voglermc's Avatar
voglermc voglermc is offline
 
Join Date: Oct 2006
Location: Piedmont Triad, NC, USA
Posts: 295
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

A cms block would be cool too! Thanks and nominated/rated!
Reply With Quote
  #8  
Old 07-14-2011, 08:29 PM
grey_goose grey_goose is offline
 
Join Date: Jun 2009
Posts: 284
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks voglermc!

Unfortunately a cms block won't be forthcoming from me... we just have the forums (not the suite) and use mediawiki for our content management.
Reply With Quote
Благодарность от:
voglermc
  #9  
Old 07-14-2011, 08:40 PM
Macgiber Macgiber is offline
 
Join Date: Apr 2009
Location: PR
Posts: 81
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed
Reply With Quote
  #10  
Old 07-16-2011, 02:56 PM
grey_goose grey_goose is offline
 
Join Date: Jun 2009
Posts: 284
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by CaneInsider View Post
Installed. Anyway to turn off showing who is online? I have over 750 members logged in so it makes my sidebar go down a long way....
Here you go.

Replace your block content entirely with this, then add your usergroup numbers to:

// space separated list of group ids to filter out
$filter_groupids = "";


Code:
global $vbulletin;
global $db;

// space separated list of group ids to filter out
$filter_groupids = "";

// members logged into forums
$loggedinusers = array();
$activeusers = array();
$invisiblecount = 0;

// Logged in user
if ($vbulletin->userinfo['userid'])
  {
    $loggedinusers[$vbulletin->userinfo['userid']] = array(
      'userid' => $vbulletin->userinfo['userid'],
      'username' => $vbulletin->userinfo['username'],
      'invisiblemark' => ($vbulletin->userinfo['invisible']) ? '*' : '',
      'displaygroupid' => $vbulletin->userinfo['displaygroupid'],
      'musername' => fetch_musername($vbulletin->userinfo)
    );
  }

$getonline = $db->query_read("
			SELECT session.userid, username, usergroupid, (user.options & " . $vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, membergroupids
			FROM " . TABLE_PREFIX . "session AS session
			LEFT JOIN " . TABLE_PREFIX . "user AS user USING (userid)
			WHERE session.lastactivity > " . (TIMENOW - $vbulletin->options['cookietimeout']) . "
			ORDER BY username ASC
		");

$filter_groupids = explode(" ", $filter_groupids);
while ($onlineusers = $db->fetch_array($getonline))
  {
    if (!$onlineusers['userid'])
      {
	$numberguest++;
      }
    else
      {
	if ($onlineusers['invisible'])
	  {
	    if (($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehidden']) OR $onlineusers['userid'] == $vbulletin->userinfo['userid'])
	      {
		$onlineusers['invisiblemark'] = '*';
	      }
	    else
	      {
		$invisiblecount++;
		continue;
	      }
	  }

	$groupids = array();
	array_push($groupids, $onlineusers['usergroupid'], $onlineusers['displaygroupid']);
	$groupids = array_merge
	  (
	   $groupids,
	   explode(" ", $onlineusers['membergroupids'])
	  );
	foreach($groupids as $value)
	  if(in_array($value, $filter_groupids))
	    continue;
	$loggedinusers[$onlineusers['userid']] = $onlineusers;
      }
  }

$db->free_result($getonline);
unset($onlineusers);

// ##### Process Online Users Module
$numberregistered = sizeof($loggedinusers);
$show['comma_leader'] = false;
$show['divrow'] = false;

if (!empty($loggedinusers))
  {
    foreach ($loggedinusers AS $loggedinuserid => $loggedin)
      {
	$loggedin['musername'] = fetch_musername($loggedin);

	($hook = vBulletinHook::fetch_hook('vba_cmps_module_onlineuserbits')) ? eval($hook) : false;

	$activeusers[$loggedinuserid] = $loggedin;
      }
  }

// Process the total first, before number_format is applied
$totalonline = $numberregistered + $numberguest + $invisiblecount;

if ($vbulletin->maxloggedin['maxonline'] <= $totalonline)
  {
    $vbulletin->maxloggedin['maxonline'] = $totalonline;
    $vbulletin->maxloggedin['maxonlinedate'] = TIMENOW;
    build_datastore('maxloggedin', serialize($vbulletin->maxloggedin), 1);
  }

$totalonline = vb_number_format($totalonline);
$numberregistered = vb_number_format($numberregistered + $invisiblecount);
$numberguest = vb_number_format($numberguest);

$recordusers = vb_number_format($vbulletin->maxloggedin['maxonline']);
$recorddate = vbdate($vbulletin->options['dateformat'], $vbulletin->maxloggedin['maxonlinedate'], 1);
$recordtime = vbdate($vbulletin->options['timeformat'], $vbulletin->maxloggedin['maxonlinedate']);

// print everything 
$templater = vB_Template::create('block_online');
$templater->register('activeusers', $activeusers);
$templater->register('altbgclass', $altbgclass);
$templater->register('bgclass', $bgclass);
$templater->register('numberguest', $numberguest);
$templater->register('numberregistered', $numberregistered);
$templater->register('recorddate', $recorddate);
$templater->register('recordtime', $recordtime);
$templater->register('recordusers', $recordusers);
$content = $templater->render();
unset($loggedinusers, $activeusers);
return $content;
Reply With Quote
Reply


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 10:09 AM.


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.06020 seconds
  • Memory Usage 2,342KB
  • Queries Executed 24 (?)
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
  • (3)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (2)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (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_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • 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
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete