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

+13 -7
View File
@@ -11,7 +11,7 @@
namespace IPS\Member;
/* 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;
@@ -22,6 +22,9 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _Device extends \IPS\Patterns\ActiveRecord
{
/**
* @brief Login keys are valid for 3 months
*/
const LOGIN_KEY_VALIDITY = 'P3M';
/**
@@ -48,7 +51,7 @@ class _Device extends \IPS\Patterns\ActiveRecord
* Load device for current request, or create one if there isn't one
*
* @param \IPS\Member $member The member being authenticated
* @param bool $sendNewDeviceEmail If true, and the associated setting is enabled, and this is a new device, an email will be sent to the member. Only set to FALSE if the user is registering where the email would be redundant.
* @param bool $sendNewDeviceEmail If true, and the associated setting is enabled, and this is a new device, an email will be sent to the member. Only set to FALSE if the user is registering and while the MFA where the email would be redundant.
* @return \IPS\Member\Device
*/
public static function loadOrCreate( \IPS\Member $member, $sendNewDeviceEmail=TRUE )
@@ -182,16 +185,19 @@ class _Device extends \IPS\Patterns\ActiveRecord
if ( $rememberMe === NULL )
{
\IPS\Request::i()->setCookie( 'member_id', $this->member_id, $cookieExpiration );
\IPS\Request::i()->setCookie( 'loggedIn', 1, $cookieExpiration, FALSE );
}
elseif ( $rememberMe === TRUE )
{
\IPS\Request::i()->setCookie( 'member_id', $this->member_id, $cookieExpiration );
\IPS\Request::i()->setCookie( 'login_key', $this->login_key, $cookieExpiration );
\IPS\Request::i()->setCookie( 'loggedIn', 1, $cookieExpiration, FALSE );
}
else
{
\IPS\Request::i()->setCookie( 'member_id', $this->member_id, NULL ); // Just tells the guest caching mechanism that we are logged in, so it can expire on the session end
\IPS\Request::i()->setCookie( 'login_key', NULL ); // Clear it in case they previously had chosen "Remember Me"
\IPS\Request::i()->setCookie( 'loggedIn', 1, $cookieExpiration, FALSE );
}
}
}
@@ -215,11 +221,11 @@ class _Device extends \IPS\Patterns\ActiveRecord
/**
* Get user agent data
*
* @return \IPS\Http\UserAgent
* @return \IPS\Http\Useragent
*/
public function userAgent()
{
return \IPS\Http\UserAgent::parse( $this->user_agent );
return \IPS\Http\Useragent::parse( $this->user_agent );
}
/**
@@ -229,7 +235,7 @@ class _Device extends \IPS\Patterns\ActiveRecord
*/
public function loginMethod()
{
if ( is_numeric( $this->login_handler ) )
if ( \is_numeric( $this->login_handler ) )
{
try
{
@@ -251,7 +257,7 @@ class _Device extends \IPS\Patterns\ActiveRecord
protected function sendNewDeviceEmail()
{
$member = \IPS\Member::load( $this->member_id );
if ( \IPS\Settings::i()->new_device_email )
{
try
@@ -266,7 +272,7 @@ class _Device extends \IPS\Patterns\ActiveRecord
\IPS\Email::buildFromTemplate( 'core', 'new_device', array( $member, $this, $location ) )->send( $member );
}
$member->logHistory( 'core', 'login', array( 'type' => 'new_device', 'device' => $this->device_key ), FALSE );
$member->logHistory( 'core', 'login', array( 'type' => 'new_device', 'device' => $this->device_key, 'user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : NULL ), FALSE );
}
/**