Jump to content

Who's Online cut off time


Will Munny

Recommended Posts

I think I figured this out myself. In /applications/core/modules/front/online. . .

        /* Initial filters */
        $where = array(
            array( "core_sessions.running_time>?", \IPS\DateTime::create()->sub( new \DateInterval( 'PT30M' ) )->getTimeStamp() ),

If I change the 'PT30M' to something like 'PT15M' or 'PT90M', it appears to work. Is this a safe edit?

Link to comment
Share on other sites

Actually it seems you also have to edit the following line to make it work. . .

		$table->limit = 30;

That also makes the online users page much bigger or smaller though (depending on which way you edit the limit). I actually prefer to see bigges online users pages.

Any devs got some input for this?

Link to comment
Share on other sites

Actually it seems you also have to edit the following line to make it work. . .

		$table->limit = 30;

That also makes the online users page much bigger or smaller though (depending on which way you edit the limit). I actually prefer to see bigges online users pages.

Any devs got some input for this?

​Um no thats the SQL result limit and you're actually cutting the amount of results in the query. You probably shouldn't touch that.

Pretty sure you should be modifying the widget not the online module. File: core\widget\whosOnline.php

Make sure you edit times for both member and guest. Hopefully IPS will give this widget an option panel for this, probably just an oversight.

Link to comment
Share on other sites

Yes you're right, thanks for the pointer. There were two references to the 30 minute limit in that file you mentioned and changing them both (one for members, one for guests) appears to work. . .

        /* Get Members */
        $members = iterator_to_array( \IPS\Db::i()->select( array( 'member_id', 'member_name', 'seo_name', 'member_group' ), 'core_sessions', array(
            array( 'login_type=' . \IPS\Session\Front::LOGIN_TYPE_MEMBER ),
            array( 'running_time>' . \IPS\DateTime::create()->sub( new \DateInterval( 'PT90M' ) )->getTimeStamp() )
        ), 'running_time DESC', $this->orientation === 'horizontal' ? NULL : 60 )->setKeyField( 'member_id' ) );
        
        /* Get guests count */
        $memberCount = 0;
        $guests = 0;
        $anonymous = 0;
        if ( $this->orientation === 'horizontal' )
        {
            foreach ( \IPS\Db::i()->select( 'login_type, COUNT(*) AS count', 'core_sessions', array( 'running_time>' . \IPS\DateTime::create()->sub( new \DateInterval( 'PT90M' ) )->getTimeStamp() ), NULL, NULL, 'login_type' ) as $row )

Safe???

Also, There appears to be no setting to make this box only available to members. Do you have any advice for me on how to hide it from guests?

Link to comment
Share on other sites

 

Safe???

Also, There appears to be no setting to make this box only available to members. Do you have any advice for me on how to hide it from guests?

​Yes that should be safe, it doesn't modify the database if thats what you mean.

Regarding group visibility, at the end of that file you'll see /* Display */ Return, replace that with:

/* Display */
$visibleToGroups = array(2,4); // 2 = Guest, 4 = Default Admin group
return (in_array(\IPS\Member::loggedIn()->member_group_id,$visibleToGroups) ? $this->output( $members, $memberCount, $guests, $anonymous ) : '');

Add more group id's to that $visibleToGroups array.

 

EDIT:

You could do the opposite way if it's more suitable so you don't have to edit for new groups.

/* Display */
$hideForGroups = array(2); // 2 = Guest
return (in_array(\IPS\Member::loggedIn()->member_group_id,$hideForGroups) ? '' : $this->output( $members, $memberCount, $guests, $anonymous ));

 

Link to comment
Share on other sites

If altering this you would need to also make sure PHP is configured so that the session expiration time is at least as high as the value you set or you'll see varying results when garbage collection runs. that is one of the reasons it is no longer configurable as increasing the value does not necessarily lead to reliable results

Edited by Andy Millne
Link to comment
Share on other sites

 However, I've now realised there's a group permissions setting in ACP to hide the online users from specific groups altogether.

Maybe I'm being completely blind, I can't find the setting in the group settings?

If altering this you would need to also make sure PHP is configured so that the session expiration time is at least as high as the value you set or you'll see varying results when garbage collection runs. that is one of the reasons it is no longer configurable as increasing the value does not necessarily lead to reliable results

​Ah yes, good point. Probably a good idea for an article as no doubt this question will come up several times.

Link to comment
Share on other sites

If altering this you would need to also make sure PHP is configured so that the session expiration time is at least as high as the value you set or you'll see varying results when garbage collection runs. that is one of the reasons it is no longer configurable as increasing the value does not necessarily lead to reliable results

Is this the session.gc_maxlifetime setting?

Link to comment
Share on other sites

​Hopefully IPS will give this widget an option panel for this, probably just an oversight.

​I sure hope so. This is one feature I used for sure and set to 60 minutes instead of 5 or whatever it is. Every site I visited used a different time here it seemed. Kiss it goodbye I guess. Wow...

Link to comment
Share on other sites

  • 1 month later...

This appears to have changed in the latest version. There now appears to be only one place to make the edit. The 'PT30M'. Is this a safe edit, are there any gotchas I may have missed?. . .

/applications/core/widgets. . .

		/* Do we have permission? */
		if ( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'online' ) ) )
		{
			return "";
		}

		$where = array(
			array( 'core_sessions.running_time>' . \IPS\DateTime::create()->sub( new \DateInterval( 'PT30M' ) )->getTimeStamp() ),
			array( 'core_groups.g_hide_online_list=0' )
		);

 

Edited by Will Munny
Link to comment
Share on other sites

  • 1 year later...
  • Management
5 hours ago, Stritix said:

Why is there no setting to change this? Basic functions from IPB3 are missing in IPS4. I just upgraded to IPS4. I'd rather not modify files. Please let us change the cut off time.

Because IPS4 uses PHP sessions and the default garbage collection is 30 minutes. Editing PHP configurations is beyond most users and and it's really not necessary - if you want to make your site look more busy than it actually is, there's plugins in the marketplace to replace the online user block. You should ideally leave the stock settings alone. 

Link to comment
Share on other sites

5 hours ago, Lindy said:

Because IPS4 uses PHP sessions and the default garbage collection is 30 minutes. Editing PHP configurations is beyond most users and and it's really not necessary - if you want to make your site look more busy than it actually is, there's plugins in the marketplace to replace the online user block. You should ideally leave the stock settings alone. 

I don't really like using plugins. They aren't often reliable. Is there a way to simply edit a file to change this setting? It seems that the past method is now outdated.

Link to comment
Share on other sites

  • Management
3 hours ago, Stritix said:

I don't really like using plugins. They aren't often reliable. Is there a way to simply edit a file to change this setting? It seems that the past method is now outdated.

I can nearly guarantee a plugin that simply selects from the user table to determine who has been active in the past X hours to manipulate the list is going to be more reliable than hacking code, changing server configs, etc. ^_^ I'm not sure you understand what you're actually doing here - you're not setting a display cutoff, you're altering the PHP garbage collection config. 

We've had issues with people tinkering with this and I feel compelled to note, you're "voiding your warranty" so-to-speak and we will not provide tech support should you end up with "people aren't staying logged in" etc. Proceed at your own risk. 

Link to comment
Share on other sites

1 hour ago, Lindy said:

I can nearly guarantee a plugin that simply selects from the user table to determine who has been active in the past X hours to manipulate the list is going to be more reliable than hacking code, changing server configs, etc. ^_^ I'm not sure you understand what you're actually doing here - you're not setting a display cutoff, you're altering the PHP garbage collection config. 

We've had issues with people tinkering with this and I feel compelled to note, you're "voiding your warranty" so-to-speak and we will not provide tech support should you end up with "people aren't staying logged in" etc. Proceed at your own risk. 

I will not be altering anything if that's the case. What plugin do you recommend?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...