vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   sidebar block (https://vborg.vbsupport.ru/showthread.php?t=320977)

Wisc 12-05-2015 05:00 AM

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!

MarkFL 12-05-2015 05:53 AM

1 Attachment(s)
Here is how I set it up on my local dev site:

https://vborg.vbsupport.ru/attachmen...1&d=1449301635

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:

https://vborg.vbsupport.ru/attachmen...1&d=1449301765

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.

Wisc 12-07-2015 03:23 AM

gave me : 406 Not Acceptable
when i tried to save it...

MarkFL 12-07-2015 03:47 AM

Quote:

Originally Posted by Wisc (Post 2559858)
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.

Wisc 12-07-2015 04:05 AM

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

MarkFL 12-07-2015 04:14 AM

Quote:

Originally Posted by Wisc (Post 2559860)
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. :D

Wisc 12-07-2015 05:46 AM

Thank you again MarK...the code is a huge help and others will use too i am sure
Happy Holidays

webmastersun 12-15-2015 11:04 AM

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.

setishock 12-30-2015 03:47 PM

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.

MarkFL 12-30-2015 06:35 PM

Quote:

Originally Posted by setishock (Post 2561423)
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
"
); 



All times are GMT. The time now is 03:57 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01199 seconds
  • Memory Usage 1,756KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete