TinyPortal

Development => Support => Topic started by: North East Man on January 29, 2022, 12:00:44 PM

Title: How to blank out number of guests online
Post by: North East Man on January 29, 2022, 12:00:44 PM

Link to my forum: https:test.way-up.co.uk
SMF version: 2.0.19
TP version: 2.1.0
Default Forum Language: English
Theme name and version: Temiz
Browser Name and Version:
Mods installed:
Related Error messages: None


On my live forum I have the Tiny Portal Online box activated which shows the number of guests and users online.  The forum does not allow guest access, however, there are almost always "guests" shown in the who's online box.  I suppose these are members who have previously logged in looked around and logged out.  I have a 15 minute activity threshold set in the forum, so again I'm guessing that these "Guests" are people who were active in the last 15 minutes.

I am sick of new members messaging me and saying that they thought the forum was private and who are these guests.  Every time, I have to explain that there are no guests, etc, etc.

Is there a way to just have the online box just not show how many guests there are?

I think I have tracked it down to the code module "onlinebox.blockcode" module which in turn returns info from the function ssi_logOnline in SSI.php, but Subs-Membersonline.php appears to be involved as well.

I commented out the echo comment in my theme's Boardindex.template whic output the guests info but that made no difference.

I don't want to alter any core code, but I would just like the box to say how many members are online with no mention of the non existant guests.  In effect to just blank out and not show guest info.

Is this do-able?
Title: Re: How to blank out number of guests online
Post by: tino on January 29, 2022, 12:26:52 PM
You will have to edit SSI.php as that's the function we call. The easiest way will be to just remove the part where it echo's the number of guests.

I can't access SMF2.0's code currently as it's not on GitHub but I expect it will be the same as 2.1 where it's just after the integrate function that you have to edit.

Most of those guests will be bots or similar trying to crawl the site.
Title: Re: How to blank out number of guests online
Post by: North East Man on January 29, 2022, 03:25:47 PM
Thanks for your reply.  I have looked in SSI.php and the only lines that I can see are


//   echo '
//      ', comma_format($return['num_guests']), ' ', $return['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ', comma_format($return['num_users_online']), ' ', $return['num_users_online'] == 1 ? $txt['user'] : $txt['users'];



I have commented the lines out as shown above having first tried just deleting the part of the line that refers to guests.  That didn't make any difference, so I tried commenting out the whole 2 lines of code as above - that still didn't make any difference either as the information still shows.  I can turn offthe block in TP and everything disappears, but I really like having who's online showing with their avatar.

I couldn't see anywhere in SSI.php where there was any mention of "integrate".

So I'm no further forward really.  Any other suggestions?

Thanks for your assistance

Title: Re: How to blank out number of guests online
Post by: @rjen on January 29, 2022, 04:25:50 PM
I think it is possible, but I need access to a pc to check.

Will look into this later.

I think the ssi_online is not used to output online with avatars. That's probably why your edits don't make a difference . Just for fun switch off tha avatars and try again...
Title: Re: How to blank out number of guests online
Post by: North East Man on January 29, 2022, 04:44:23 PM
Hi @Rjen,

With the code lines active in SSI.php I turned off the avatars in TP - the site just showed my name as being online but with no numbers of users shown and no guests - not even the text of users and guest online. 

With Avatars off and the lines commented out - the site showed just my name.  No atars and no text to say how many users and guests.

With avatars on and code commented out - back to just showing my avatar with no name but also showing 0 guests and 1 user.

Thanks for the help.
Title: Re: How to blank out number of guests online
Post by: @rjen on January 29, 2022, 04:58:42 PM
That confirms my statement. The display with avatars is elsewhere in the code.

I will not be near a pc before tomorrownight. So can't help you today...
Title: Re: How to blank out number of guests online
Post by: North East Man on January 29, 2022, 06:28:44 PM
No problem @Rjen.  I'm away from my PC myself now until tomorrow and this issue has been on my wish list for a while so am more than happy to wait for a solution.
Title: Re: How to blank out number of guests online
Post by: tino on January 29, 2022, 07:14:06 PM
Quote from: North East Man on January 29, 2022, 06:28:44 PM
No problem @Rjen.  I'm away from my PC myself now until tomorrow and this issue has been on my wish list for a while so am more than happy to wait for a solution.

Ohh if you're using avatars you just need to remove this line TPSubs.php

https://github.com/Tinyportal/TinyPortal/blob/5978395e9f32b013a1d41fb1a5bd07fa2a4f397d/Themes/default/TPsubs.template.php#L1025
Title: Re: How to blank out number of guests online
Post by: @rjen on January 29, 2022, 07:24:37 PM
Yeah, that's the one.

I am thinking; perhaps we can include a switch in the block setting in a next release.

That way an admin can suppress the guests without changing code
Title: Re: How to blank out number of guests online
Post by: North East Man on January 30, 2022, 12:41:59 PM
That did it - guests no longer show.  Perfect!

Of course I'll still get the questions when the number of users online doesn't match the number of avatars shown when people haven't uploaded an avatar!  But you can't have everything.

I think an admin switch / tick box in the next release would be a great idea.  For the moment I just had to delete the line as the //comment didn't deactivate the line.

Many, many thanks for your assistance.

Richard
Title: Re: How to blank out number of guests online
Post by: tino on January 30, 2022, 05:45:38 PM
If you want it as a php block (so no code edit's) and it won't get overwritten next time you update it's below.


global $txt, $scripturl;

    $whos = tpo_whosOnline();

    echo '<div>' . $whos['num_users_online'] .' ' , $whos['num_users_online'] == 1 ? $txt['user'] : $txt['users'] , '</div>';

    if(isset($whos['users_online']) && count($whos['users_online']) > 0) {
        $ids = array();
        $names = array();
        $times = array();
        foreach($whos['users_online'] as $w => $wh) {
            // For reasons historical, SMF produces the timestamp as
            // the timestamp followed by the user's name, so let's fix it.
            $timestamp = (int) strtr($w, array($wh['username'] => ''));
            $ids[] = $wh['id'];
            $names[$wh['id']] = $wh['name'];
            $times[$wh['id']] = timeformat($timestamp);
        }   
        $avy = progetAvatars($ids);
        foreach($avy as $a => $av) {
            echo '<a class="tp_avatar_single2" title="'.$names[$a].'" href="' . $scripturl . '?action=profile;u='.$a.'">' . $av . '</a>';
        }
    }
Title: Re: How to blank out number of guests online
Post by: North East Man on February 01, 2022, 04:58:28 PM
Hi again,

The PHP Box is a great idea - works very well without having to alter the base code.  If I wanted to have the same functionality where I can click on the online title and be shown an extended list of who is online and what pages they are viewing, which code would I have to add to the PHP block?

I'm very appreciative of the help on this issue.


Richard
Title: Re: How to blank out number of guests online
Post by: @rjen on February 01, 2022, 07:22:14 PM
change it to this


global $txt, $scripturl;

    $whos = tpo_whosOnline();

    echo '<div><a href="/index.php?action=who;start=0;show=members;sort=user;asc">' . $whos['num_users_online'] .' ' , $whos['num_users_online'] == 1 ? $txt['user'] : $txt['users'] , '</a></div>';

    if(isset($whos['users_online']) && count($whos['users_online']) > 0) {
        $ids = array();
        $names = array();
        $times = array();
        foreach($whos['users_online'] as $w => $wh) {
            // For reasons historical, SMF produces the timestamp as
            // the timestamp followed by the user's name, so let's fix it.
            $timestamp = (int) strtr($w, array($wh['username'] => ''));
            $ids[] = $wh['id'];
            $names[$wh['id']] = $wh['name'];
            $times[$wh['id']] = timeformat($timestamp);
        }   
        $avy = progetAvatars($ids);
        foreach($avy as $a => $av) {
            echo '<a class="tp_avatar_single2" title="'.$names[$a].'" href="' . $scripturl . '?action=profile;u='.$a.'">' . $av . '</a>';
        }
    }
Title: Re: How to blank out number of guests online
Post by: North East Man on February 01, 2022, 09:59:32 PM
Excellent - Thank you very much.  Perfect for my needs.


Richard