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
  #12  
Old 07-23-2011, 09:22 PM
apn3a apn3a is offline
 
Join Date: Oct 2004
Location: Athens Greece
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey

Can we have something like that for the Today birthday users?

Thank you
Reply With Quote
  #13  
Old 07-24-2011, 07:00 AM
ErnieTheMilk ErnieTheMilk is offline
 
Join Date: Mar 2007
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are there any permissions issues related to this, when I try this I get a message telling me I don't have Permission to access the document...
Reply With Quote
  #14  
Old 09-07-2011, 06:28 PM
Steve_GB Steve_GB is offline
 
Join Date: Oct 2003
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Neat.

Some feedback:

The buddymark doesn't actually display when I try this. Should be a + next to friends etc but none seen when I run this. I can see it is meant to be there from the code etc.

After each name is a comma but in VB those seem to often be at the end of runs of things when viewed with ie8 and that is what I see with this too, a comma between members fine, like john, fred.. but also one after fred, which looks wrong of course.

One workaround for that is simply to delete the comma from the template, then you just get a space between member names and no commas at all, which looks a little better perhaps. Your example graphic actually shows the unwanted comma at the end of the list of members so you are seeing this too.

Hope the feedback is helpful and thanks for sharing this here.

Steve
Reply With Quote
  #15  
Old 12-03-2011, 11:51 PM
Malcolm-X Malcolm-X is offline
 
Join Date: Sep 2010
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

in my sidebar it just says "Most users ever online was , at ." but nothing alse is shown... please help.. I use ESB 1.4.4.4 and vb4.1.7

thanks
Reply With Quote
  #16  
Old 05-24-2012, 10:57 PM
dsantana dsantana is offline
 
Join Date: Dec 2011
Posts: 67
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I added this as a widget as well for my CMS page...
Just used the php code in a PHP Direct Execution setup...

Thanks a bunch!!!
Reply With Quote
  #17  
Old 06-08-2012, 12:33 AM
Dave-ahfb Dave-ahfb is offline
 
Join Date: Mar 2002
Posts: 117
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed on 4.2

Most ever online now only shows the actual users online, The most ever stat was even wiped out on the default VB WOL block
Reply With Quote
  #18  
Old 11-05-2015, 07:36 AM
3saltoot 3saltoot is offline
 
Join Date: Mar 2015
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

nice ,, thank you ..
Reply With Quote
  #19  
Old 02-27-2017, 06:24 PM
Hellendor's Avatar
Hellendor Hellendor is offline
 
Join Date: Feb 2017
Location: Alcobendas, Madrid, Spain
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello friends, I have version vB 4.2.3 and I do not know how to create the first part of the block which is to create the template. You can help me step by step, please. Thank you very much.
Reply With Quote
  #20  
Old 01-22-2018, 12:53 PM
IggyP IggyP is offline
 
Join Date: May 2012
Posts: 252
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wondering the way to take an idea like this and just move the whole WGO block to sidebar...
Reply With Quote
  #21  
Old 04-07-2023, 11:50 PM
oldfan's Avatar
oldfan oldfan is offline
 
Join Date: Jul 2004
Posts: 813
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

works on 4.2.5.php 7.2
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:31 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.05128 seconds
  • Memory Usage 2,336KB
  • Queries Executed 28 (?)
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
  • (2)bbcode_code
  • (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
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)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_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
  • 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