Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

+58 -14
View File
@@ -1,12 +1,11 @@
<?php
/**
* @brief Front-end Dispatcher
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 18 Feb 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\Dispatcher;
@@ -35,6 +34,9 @@ class _Front extends \IPS\Dispatcher\Standard
*/
public function init()
{
/* Get cached page if available */
$this->checkCached();
/* Set up in progress? */
if ( isset( \IPS\Settings::i()->setup_in_progress ) AND \IPS\Settings::i()->setup_in_progress )
{
@@ -51,9 +53,6 @@ class _Front extends \IPS\Dispatcher\Standard
exit;
}
/* Get cached page if available */
$this->checkCached();
/* Sync stuff when in developer mode */
if ( \IPS\IN_DEV )
{
@@ -139,10 +138,16 @@ class _Front extends \IPS\Dispatcher\Standard
if ( $this->notAllowedBannedPage() )
{
$url = \IPS\Http\Url::internal( 'app=core&module=system&controller=login', 'front', 'login' );
if ( \IPS\Request::i()->url() != \IPS\Settings::i()->base_url )
if ( \IPS\Request::i()->url() != \IPS\Settings::i()->base_url AND !isset( \IPS\Request::i()->_mfaLogin ) )
{
$url = $url->setQueryString( 'ref', base64_encode( \IPS\Request::i()->url() ) );
}
else if ( isset( \IPS\Request::i()->_mfaLogin ) )
{
$url = $url->setQueryString( '_mfaLogin', 1 );
}
\IPS\Output::i()->redirect( $url );
}
}
@@ -175,6 +180,17 @@ class _Front extends \IPS\Dispatcher\Standard
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=system&controller=register&do=reconfirm', 'front', 'register' )->setQueryString( 'ref', base64_encode( \IPS\Request::i()->url() ) ) );
}
/* Have required profile actions that need completing */
else if ( !\IPS\Member::loggedIn()->members_bitoptions['profile_completed'] AND !in_array( $this->controller, array( 'register', 'login', 'redirect', 'contact', 'privacy', 'ajax', 'settings' ) ) AND $completion = \IPS\Member::loggedIn()->profileCompletion() AND count( $completion['required'] ) )
{
foreach( $completion['required'] AS $id => $completed )
{
if ( $completed === FALSE )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=system&controller=register&do=finish", 'front', 'register' ) );
}
}
}
/* Need to set up MFA... */
elseif ( !in_array( $this->controller, array( 'register', 'login', 'redirect', 'contact', 'privacy', 'ajax', 'settings' ) ) )
{
@@ -213,6 +229,10 @@ class _Front extends \IPS\Dispatcher\Standard
/* Permission Check */
if ( !\IPS\Member::loggedIn()->canAccessModule( $this->module ) )
{
if ( !\IPS\Member::loggedIn()->member_id and isset( \IPS\Request::i()->_mfaLogin ) )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=system&controller=login", 'front', 'login', NULL, \IPS\Settings::i()->logins_over_https )->setQueryString( '_mfaLogin', 1 ) );
}
\IPS\Output::i()->error( ( \IPS\Member::loggedIn()->member_id ? 'no_module_permission' : 'no_module_permission_guest' ), '2S100/2', 403, 'no_module_permission_admin' );
}
@@ -351,6 +371,12 @@ class _Front extends \IPS\Dispatcher\Standard
*/
protected function checkCached()
{
/* If we are using a caching engine and Database datastore, then avoid checking cache validity because it will hit MySQL to load the cacheKeys. As this is guest caching, we accept that stale data is ok */
if ( \IPS\STORE_METHOD === 'Database' AND \IPS\CACHE_METHOD !== 'None' )
{
\IPS\Data\Store::i()->cacheCheck = false;
}
/* If this is a guest and there's a full cached page, we can serve that */
if( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and !isset( \IPS\Request::i()->csrfKey ) and !isset( \IPS\Request::i()->_mfaLogin ) and !\IPS\Session\Front::loggedIn() and !isset( \IPS\Request::i()->cookie['noCache'] ) and !\IPS\Request::i()->ipAddressIsBanned() and \IPS\CACHE_PAGE_TIMEOUT )
{
@@ -379,9 +405,15 @@ class _Front extends \IPS\Dispatcher\Standard
$cache = \IPS\Data\Cache::i()->getWithExpire( 'page_' . md5( (int) \IPS\Request::i()->isSecure() . ( !empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] ) . '/' . $_SERVER['REQUEST_URI'] ) . "_{$language}_{$theme}", TRUE );
$sessionId = isset( \IPS\Request::i()->cookie['IPSSessionFront'] ) ? \IPS\Request::i()->cookie['IPSSessionFront'] : \IPS\Session::i()->id;
\IPS\Output::i()->sendOutput( str_replace( '{{csrfKey}}', md5( '&& 0&' . $sessionId ), $cache['output'] ), $cache['code'], $cache['contentType'], $cache['httpHeaders'], FALSE, TRUE );
\IPS\Output::i()->sendOutput( str_replace( '{{csrfKey}}', md5( '& 0&' . $sessionId ), $cache['output'] ), $cache['code'], $cache['contentType'], $cache['httpHeaders'], FALSE, TRUE );
}
catch ( \OutOfRangeException $e ) {}
/* Turn back on cache validation if we are still here */
if ( \IPS\STORE_METHOD === 'Database' AND \IPS\CACHE_METHOD !== 'None' )
{
\IPS\Data\Store::i()->cacheCheck = true;
}
}
}
@@ -449,7 +481,7 @@ class _Front extends \IPS\Dispatcher\Standard
if( count( $widgets ) )
{
if ( \IPS\CACHE_METHOD === 'None' )
if ( \IPS\CACHE_METHOD === 'None' and ! \IPS\Theme::isUsingTemplateDiskCache() )
{
$templateLoad = array();
foreach ( $widgets as $areaKey => $area )
@@ -527,17 +559,29 @@ class _Front extends \IPS\Dispatcher\Standard
/**
* Check MFA to see if we need to supply a code
*
* @param boolean $return Return any HTML (true) or add to Output (false)
*
* @return void
*/
public function checkMfa()
public function checkMfa( $return=FALSE )
{
/* MFA Login? */
if ( isset( \IPS\Request::i()->_mfaLogin ) and isset( $_SESSION['processing2FA'] ) and $member = \IPS\Member::load( $_SESSION['processing2FA']['memberId'] ) and $member->member_id )
{
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'core', 'AuthenticateFront', \IPS\Http\Url::internal( 'app=core&module=system&controller=login&do=mfa', 'front', 'login' ), $member ) )
$device = \IPS\Member\Device::loadOrCreate( $member );
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'core', $device->known ? 'AuthenticateFrontKnown' : 'AuthenticateFront', \IPS\Request::i()->url(), $member ) )
{
if ( $return )
{
return $output;
}
\IPS\Output::i()->output .= $output;
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=system&controller=login&do=mfa', 'front', 'login' ) );
}
}
}
@@ -591,7 +635,7 @@ class _Front extends \IPS\Dispatcher\Standard
if ( !\IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'core.css', 'core', 'front' ) );
if ( \IPS\Theme::i()->settings['responsive'] )
if ( \IPS\Output::i()->responsive and \IPS\Theme::i()->settings['responsive'] )
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'core_responsive.css', 'core', 'front' ) );
}