Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2015, 05:00 AM
Wisc Wisc is offline
 
Join Date: Aug 2009
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default sidebar block

I would like to have sidebar block "Visiting Members" That shows the visiting members for X amount of days

What is the code I would put in the content box to accomplish this.

As always Thank you in advance!
Reply With Quote
  #2  
Old 12-05-2015, 05:53 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here is how I set it up on my local dev site:



And this is the PHP code I wrote:

PHP Code:
global $vbulletin$db;
$output '<div class="restore"><ul>';

$users_visited $vbulletin->db->query_read("
    SELECT user.*
    FROM " 
TABLE_PREFIX "user AS user
    WHERE lastvisit >= " 
TIMENOW " - " 86400 "
    ORDER BY lastvisit DESC
"
);

$vcount 0;
while (
$visitor $db->fetch_array($users_visited))
{
    
$output .= '<li>' visitor_link($visitor$visitor['lastvisit']) . '</li>';
    
$vcount++;
}

$output .= '</ul></div>';

$output '<div style="text-align: center; font-weight: bold; margin-bottom: 1em">' $vcount ' Visiting Members</div>' $output;

return 
$output;

function 
visitor_link($user_name$dateline)
{
    global 
$vbulletin;
    
$link 'member.php?do=getinfo&username=' $user_name['username'];

    if (
$user_name['displaygroupid'])
    {
        
$groupid $user_name['displaygroupid'];
    }
    else
    {
        
$groupid $user_name['usergroupid'];
    }

    
$open_tag $vbulletin->usergroupcache[$groupid]['opentag'];
    
$close_tag $vbulletin->usergroupcache[$groupid]['closetag'];
    
$title 'Last Visited: ' vbdate($vbulletin->options['dateformat'], $dateline1) . ' at ' vbdate($vbulletin->options['timeformat'], $dateline);
    return 
'<a title="' $title '" href="' $link '">' $open_tag $user_name['username'] . $close_tag '</a>';

This is the result:



Each username is shown with their usergroup HTML markup in a bulleted list, and each username links to their profile, with a tooltip showing their last visit time.

Please give this a try, and let me know of any changes you would like.
Attached Images
File Type: png visitorblock.png (44.7 KB, 0 views)
File Type: png visitorblock2.png (3.8 KB, 0 views)
Reply With Quote
2 благодарности(ей) от:
Dragonsys, Wisc
  #3  
Old 12-07-2015, 03:23 AM
Wisc Wisc is offline
 
Join Date: Aug 2009
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

gave me : 406 Not Acceptable
when i tried to save it...
Reply With Quote
  #4  
Old 12-07-2015, 03:47 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Wisc View Post
gave me : 406 Not Acceptable
when i tried to save it...
406 happens when the server cannot respond with the accept-header specified in the request.

Unfortunately, I cannot duplicate the error, it works fine on both my local and online dev sites.
Reply With Quote
  #5  
Old 12-07-2015, 04:05 AM
Wisc Wisc is offline
 
Join Date: Aug 2009
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so id server issue or I should try to
refresh the blocks
clear the cache

and do again?

Thank you for your hard work...
I think will be helpful for a lot of people
Reply With Quote
  #6  
Old 12-07-2015, 04:14 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Wisc View Post
so id server issue or I should try to
refresh the blocks
clear the cache

and do again?

Thank you for your hard work...
I think will be helpful for a lot of people
It sounds like a server issue to me, from the brief amount I read about it online. As such, it is outside my relatively diminutive areas of expertise, so I don't know what to tell you to try to resolve the issue. Hopefully someone else here can offer some suggestions.

What I suggest doing is creating a new thread, where the title indicates you are getting a 406 error when trying to save a forum block, and this will be more likely to get you some help rather than to trust that someone who knows how to fix it will stumble across this thread.
Reply With Quote
  #7  
Old 12-07-2015, 05:46 AM
Wisc Wisc is offline
 
Join Date: Aug 2009
Posts: 50
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you again MarK...the code is a huge help and others will use too i am sure
Happy Holidays
Reply With Quote
  #8  
Old 12-15-2015, 11:04 AM
webmastersun's Avatar
webmastersun webmastersun is offline
 
Join Date: Oct 2013
Location: www.webmastersun.com
Posts: 433
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cool tips Mark!

Your codes can be edited a bit to make a block on right sidebar that show users online last 24 hours...instead of showing at the bottom of homepage.
Reply With Quote
Благодарность от:
MarkFL
  #9  
Old 12-30-2015, 03:47 PM
setishock setishock is offline
 
Join Date: Feb 2008
Location: Houma, La.
Posts: 1,177
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Mark, is there a way to make it so it doesn't show banned members? All but a few of the listed visitors are spammers that got banned. I'd prefer not to show those.
Reply With Quote
  #10  
Old 12-30-2015, 06:35 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by setishock View Post
Mark, is there a way to make it so it doesn't show banned members? All but a few of the listed visitors are spammers that got banned. I'd prefer not to show those.
Yes, change the query near the top of the PHP content to read:

PHP Code:
$users_visited $vbulletin->db->query_read("
    SELECT user.*
    FROM " 
TABLE_PREFIX "user AS user
    WHERE lastvisit >= " 
TIMENOW " - " 86400 "
    AND usergroupid != 8
    ORDER BY lastvisit DESC
"
); 
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 07:55 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.04346 seconds
  • Memory Usage 2,306KB
  • Queries Executed 14 (?)
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)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (3)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
  • (10)postbit
  • (2)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_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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • 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_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete