Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+25 -8
View File
@@ -11,7 +11,7 @@
namespace IPS\Session\Store;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -96,7 +96,7 @@ class _Database extends \IPS\Session\Store
* @param array|NULL $keepSessionIds Array of session ids to keep [optional]
* @return void
*/
public function deleteByMember( $memberId, $userAgent=NULL, $keepSessionIds=NULL )
public function deleteByMember( int $memberId, string $userAgent=NULL, array $keepSessionIds=NULL )
{
$where = array( array( 'member_id=?', $memberId ) );
@@ -105,7 +105,7 @@ class _Database extends \IPS\Session\Store
$where[] = array( 'browser=?', $userAgent );
}
if ( $keepSessionIds )
if ( \is_array( $keepSessionIds ) AND \count( $keepSessionIds ) )
{
$where[] = array( \IPS\Db::i()->in( 'id', $keepSessionIds, TRUE ) );
}
@@ -172,9 +172,16 @@ class _Database extends \IPS\Session\Store
if ( ! $showAnonymous )
{
$where[] = array( "s.login_type!=?", \IPS\Session\Front::LOGIN_TYPE_ANONYMOUS );
if( \IPS\Member::loggedIn()->member_id )
{
$where[] = array( "(s.login_type!=? OR s.member_id=?)", \IPS\Session\Front::LOGIN_TYPE_ANONYMOUS, \IPS\Member::loggedIn()->member_id );
}
else
{
$where[] = array( "s.login_type!=?", \IPS\Session\Front::LOGIN_TYPE_ANONYMOUS );
}
}
if ( ! $flags and ! $limit )
{
/* Simple query for PHP processing */
@@ -183,10 +190,20 @@ class _Database extends \IPS\Session\Store
else
{
/* Complex group by mode with all the lovely trimmings yum */
$subWhere = $where;
$guestSubWhere = $where;
$guestSubWhere[] = 's.member_id IS NULL';
$memberSubWhere = $where;
$memberSubWhere[] = 's.member_id IS NOT NULL';
/* Ok, this looks odd, but the ONLY_FULL_GROUP_BY bites us here, so selecting max(id) allows us to return a session ID even though we're grouping on member_id */
$where = array( array( "( core_sessions.id IN(?) OR ( core_sessions.member_id IS NULL AND core_sessions.login_type != ? AND core_sessions.running_time > ?) )", \IPS\Db::i()->select( 'MAX(id)', array( 'core_sessions', 's' ), $subWhere, NULL, NULL, 'member_id' ), \IPS\Session\Front::LOGIN_TYPE_SPIDER, \IPS\DateTime::create()->sub( new \DateInterval( 'PT30M' ) )->getTimeStamp() ) );
$where = array(
array(
"( core_sessions.id IN(?) OR core_sessions.id IN(?) )",
\IPS\Db::i()->select( 'MAX(id)', array( 'core_sessions', 's' ), $memberSubWhere, NULL, NULL, 'member_id' ),
\IPS\Db::i()->select( 'MAX(id)', array( 'core_sessions', 's' ), $guestSubWhere, NULL, NULL, 'ip_address' )
)
);
/* Limiting to a user group? */
if ( $memberGroup )
@@ -243,7 +260,7 @@ class _Database extends \IPS\Session\Store
{
$where[] = array( 'core_sessions.current_id = ?', \IPS\Request::i()->id );
}
foreach( \IPS\Db::i()->select( 'core_sessions.member_id,core_sessions.member_name,core_sessions.seo_name,core_sessions.member_group,core_sessions.login_type,core_sessions.in_editor', 'core_sessions', $where, 'core_sessions.running_time DESC' ) as $row )
{
if( $row['login_type'] == \IPS\Session\Front::LOGIN_TYPE_MEMBER and $row['member_name'] )