Version 4.7.13

This commit is contained in:
Neo committed 2025-12-19 16:14:56 -08:00
1 parent fd22d99e69
commit 7124a02564
954 files changed
+29277 -59308

No files matched your search

+73 -1
View File
@@ -50,7 +50,7 @@ class _Request extends \IPS\Patterns\Singleton
$this->parseIncomingRecursively( $_GET );
$this->parseIncomingRecursively( $_POST );
}
array_walk_recursive( $_COOKIE, array( $this, 'clean' ) );
/* If we have a cookie prefix, we have to strip it first */
@@ -380,6 +380,16 @@ class _Request extends \IPS\Patterns\Singleton
return $path;
}
/**
* Get essential cookies
*
* @return array|string[] List of essential cookies that can't be skipped
*/
public static function getEssentialCookies(): array
{
return \IPS\Application::getEssentialCookieNames();
}
/**
* Set a cookie
@@ -394,6 +404,13 @@ class _Request extends \IPS\Patterns\Singleton
*/
public function setCookie( $name, $value, $expire=NULL, $httpOnly=TRUE, $domain=NULL, $path=NULL )
{
/* Let's see if this is an optional cookie and if it is one, if the user wants them */
if( $this->skipCookie( $name ) )
{
\IPS\Log::debug('skipping ' . $name, 'cookie' );
return FALSE;
}
/* Work out the path and if cookies should be SSL only */
$sslOnly = FALSE;
if( mb_substr( \IPS\Settings::i()->base_url, 0, 5 ) == 'https' AND \IPS\COOKIE_BYPASS_SSLONLY !== TRUE )
@@ -425,6 +442,61 @@ class _Request extends \IPS\Patterns\Singleton
}
return FALSE;
}
/**
* Should the cookie be set or skipped? Takes the controller location and members cookie preferences into account.
*
* @param string $name
* @return bool
*/
protected function skipCookie( string $name ): bool
{
if( \IPS\Dispatcher::hasInstance() AND \IPS\Dispatcher::i()->controllerLocation === 'admin' )
{
return FALSE;
}
elseif( $this->cookieConsentEnabled() !== TRUE )
{
return FALSE;
}
if( in_array( $name, static::getEssentialCookies() ) )
{
return FALSE;
}
/* Check wildcard cookies */
foreach( static::getEssentialCookies() as $c )
{
if( mb_substr( $c, -1, 1 ) === '*' AND rtrim( $name, '*' ) === $name )
{
return FALSE;
}
}
return ( !\IPS\Member::loggedIn()->optionalCookiesAllowed );
}
/**
* @brief Storage of cookie consent status
*/
protected $_cookieConsentEnabled = NULL;
/**
* Check whether cookie consent is required
*
* @return bool
*/
public function cookieConsentEnabled():? bool
{
// See if cookie consent is enabled
if( \IPS\Dispatcher::hasInstance() AND $this->_cookieConsentEnabled === NULL )
{
$this->_cookieConsentEnabled = ( \IPS\Settings::i()->guest_terms_bar AND mb_strstr( \IPS\Member::loggedIn()->language()->get('guest_terms_bar_text_value'), '%4$s' ) );
}
return $this->_cookieConsentEnabled;
}
/**
* Clear login cookies