Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
+22
-64
@@ -67,11 +67,6 @@ class _Front extends \IPS\Session
|
||||
*/
|
||||
protected $save = TRUE;
|
||||
|
||||
/**
|
||||
* @brief No write guest session?
|
||||
*/
|
||||
protected $noWriteGuestSession = FALSE;
|
||||
|
||||
/**
|
||||
* Open Session
|
||||
*
|
||||
@@ -97,12 +92,6 @@ class _Front extends \IPS\Session
|
||||
/* Get user agent info */
|
||||
$this->userAgent = \IPS\Http\Useragent::parse();
|
||||
|
||||
if ( ! static::loggedIn() and isset( \IPS\Request::i()->cookie['guestTime'] ) and ( !isset( \IPS\Request::i()->cookie['noCache'] ) or !\IPS\Request::i()->cookie['noCache'] ) and time() < ( \IPS\Request::i()->cookie['guestTime'] + \IPS\CACHE_PAGE_TIMEOUT ) and \IPS\Request::i()->requestMethod() == 'GET' )
|
||||
{
|
||||
$this->sessionData = $this->setNoWriteGuestSession();
|
||||
return (string) $this->sessionData['data'];
|
||||
}
|
||||
|
||||
$session = \IPS\Session\Store::i()->loadSession( $this->sessionId );
|
||||
|
||||
/* Only use sessions with matching IP address */
|
||||
@@ -183,6 +172,7 @@ class _Front extends \IPS\Session
|
||||
if ( $success )
|
||||
{
|
||||
$this->member = $expectedMember;
|
||||
$expectedMember->achievementAction( 'core', 'SessionStartDaily' );
|
||||
}
|
||||
/* Or if the access token wasn't valid, log it as a fail so that it can't be bruteforced */
|
||||
else
|
||||
@@ -219,6 +209,9 @@ class _Front extends \IPS\Session
|
||||
|
||||
/* Set member in session */
|
||||
$this->member = $member;
|
||||
|
||||
$member->recordLogin();
|
||||
$member->achievementAction( 'core', 'SessionStartDaily' );
|
||||
|
||||
/* Update device */
|
||||
$device->updateAfterAuthentication( TRUE, NULL, FALSE );
|
||||
@@ -262,9 +255,7 @@ class _Front extends \IPS\Session
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Request::i()->setCookie( 'guestTime', time() );
|
||||
|
||||
{
|
||||
$type = $this->userAgent->spider ? static::LOGIN_TYPE_SPIDER : static::LOGIN_TYPE_GUEST;
|
||||
}
|
||||
|
||||
@@ -330,6 +321,9 @@ class _Front extends \IPS\Session
|
||||
{
|
||||
parent::setMember( $member );
|
||||
|
||||
$member->recordLogin();
|
||||
$member->achievementAction( 'core', 'SessionStartDaily' );
|
||||
|
||||
/* Make sure session handler saves during write() */
|
||||
$this->save = TRUE;
|
||||
}
|
||||
@@ -343,22 +337,29 @@ class _Front extends \IPS\Session
|
||||
*/
|
||||
public function write( $sessionId, $data )
|
||||
{
|
||||
if ( $this->noWriteGuestSession and empty( $_SESSION['forcedWrite'] ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( !isset( $this->data['data'] ) or $data !== $this->data['data'] or $this->data['member_id'] != $this->member->member_id )
|
||||
{
|
||||
$this->save = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Don't update if instant notifications are checking to reduce overhead on the session table */
|
||||
if ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->app ) and \IPS\Request::i()->app === 'core' and isset( \IPS\Request::i()->controller ) and \IPS\Request::i()->controller === 'ajax' and isset( \IPS\Request::i()->do ) and \IPS\Request::i()->do === 'instantNotifications' )
|
||||
{
|
||||
$this->save = FALSE;
|
||||
}
|
||||
|
||||
/* Don't update if there is a hit on the manifest. Why do we use the url()? When page caching grabs and returns, the \IPS\Request::i()->do/controller variables are no populated */
|
||||
if ( isset( \IPS\Request::i()->url()->hiddenQueryString['controller'] ) and \IPS\Request::i()->url()->hiddenQueryString['controller'] === 'metatags' and isset( \IPS\Request::i()->url()->hiddenQueryString['do'] ) and \IPS\Request::i()->url()->hiddenQueryString['do'] === 'manifest' )
|
||||
{
|
||||
$this->save = FALSE;
|
||||
}
|
||||
|
||||
/* Don't update if there is a hit on the serviceworker */
|
||||
if ( isset( \IPS\Request::i()->app ) and \IPS\Request::i()->app === 'core' and isset( \IPS\Request::i()->controller ) and \IPS\Request::i()->controller === 'serviceworker' )
|
||||
{
|
||||
$this->save = FALSE;
|
||||
}
|
||||
|
||||
$this->data['member_name'] = $this->member->member_id ? $this->member->name : '';
|
||||
$this->data['member_id'] = $this->member->member_id ?: NULL;
|
||||
$this->data['data'] = $data;
|
||||
@@ -653,7 +654,7 @@ class _Front extends \IPS\Session
|
||||
/**
|
||||
* Garbage Collection
|
||||
*
|
||||
* @param int $lifetime Unix timestamp of the oldest session to keep
|
||||
* @param int $lifetime Number of seconds to consider sessions expired beyond
|
||||
* @return bool
|
||||
*/
|
||||
public function gc( $lifetime )
|
||||
@@ -661,47 +662,4 @@ class _Front extends \IPS\Session
|
||||
static::clearSessions( $lifetime );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up a session that doesn't require a DB read or write
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function setNoWriteGuestSession()
|
||||
{
|
||||
$this->noWriteGuestSession = TRUE;
|
||||
|
||||
$this->member = new \IPS\Member;
|
||||
|
||||
/* Set data */
|
||||
$this->data = array(
|
||||
'id' => $this->sessionId,
|
||||
'member_name' => '',
|
||||
'seo_name' => '',
|
||||
'member_id' => 0,
|
||||
'ip_address' => \IPS\Request::i()->ipAddress(),
|
||||
'browser' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '',
|
||||
'running_time' => time(),
|
||||
'login_type' => $this->userAgent->spider ? static::LOGIN_TYPE_SPIDER : static::LOGIN_TYPE_GUEST,
|
||||
'member_group' => \IPS\Settings::i()->guest_group,
|
||||
'current_appcomponent' => '',
|
||||
'current_module' => '',
|
||||
'current_controller' => NULL,
|
||||
'current_id' => \intval( \IPS\Request::i()->id ),
|
||||
'uagent_key' => $this->userAgent->browser ?: '',
|
||||
'uagent_version' => $this->userAgent->browserVersion ?: '',
|
||||
'uagent_type' => $this->userAgent->spider ? 'search' : 'browser',
|
||||
'search_thread_id' => 0,
|
||||
'search_thread_time' => 0,
|
||||
'data' => '',
|
||||
'location_url' => NULL,
|
||||
'location_lang' => NULL,
|
||||
'location_data' => NULL,
|
||||
'location_permissions' => NULL,
|
||||
'theme_id' => isset( \IPS\Request::i()->cookie['theme'] ) ? \IPS\Request::i()->cookie['theme'] : 0,
|
||||
'in_editor' => 0,
|
||||
);
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user