Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

@@ -2,9 +2,9 @@
/**
* @brief Upgrader: Login
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 20 May 2014
* @version SVN_VERSION_NUMBER
*/
@@ -32,27 +32,41 @@ class _login extends \IPS\Dispatcher\Controller
public function manage()
{
/* Clear previous session data */
if( count( $_SESSION ) )
if( !isset( \IPS\Request::i()->sessionCheck ) AND count( $_SESSION ) )
{
foreach( $_SESSION as $k => $v )
{
unset( $_SESSION[ $k ] );
}
}
/* Store a session variable and then check it on the next page load to make sure PHP sessions are working */
if( !isset( \IPS\Request::i()->sessionCheck ) )
{
$_SESSION['sessionCheck'] = TRUE;
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setQueryString( 'sessionCheck', 1 ), NULL, 307 ); // 307 instructs the browser to resubmit the form as a POST request maintaining all the values from before
}
else
{
if( !isset( $_SESSION['sessionCheck'] ) OR !$_SESSION['sessionCheck'] )
{
\IPS\Output::i()->error( 'session_check_fail', '5C289/1', 500, '' );
}
}
/* Are we automatically logging in? */
if ( isset( \IPS\Request::i()->adsess ) )
{
$session = \IPS\Db::i()->select( '*', 'core_sys_cp_sessions', array( 'session_id=?', \IPS\Request::i()->adsess ) )->first();
$member = $session['session_member_id'] ? \IPS\Member::load( $session['session_member_id'] ) : new \IPS\Member;
if ( $member->member_id and $member->isAdmin() and ( !\IPS\Settings::i()->match_ipaddress or ( $session['session_ip_address'] === \IPS\Request::i()->ipAddress() ) ) )
if ( $member->member_id and $this->_memberHasUpgradePermission( $member ) and ( !\IPS\Settings::i()->match_ipaddress or ( $session['session_ip_address'] === \IPS\Request::i()->ipAddress() ) ) )
{
$_SESSION['uniqueKey'] = md5( uniqid( microtime(), TRUE ) );
$_SESSION['uniqueKey'] = \IPS\Login::generateRandomString();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=systemcheck" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
}
}
$login = new \IPS\Login( \IPS\Http\Url::internal( "controller=login&start=1", NULL, NULL, NULL, \IPS\Settings::i()->logins_over_https ) );
$login = new \IPS\Login( \IPS\Http\Url::internal( "controller=login&start=1&sessionCheck=1", NULL, NULL, NULL, \IPS\Settings::i()->logins_over_https ) );
$login->flagOptions = FALSE;
/* < 4.0.0 */
@@ -98,9 +112,19 @@ class _login extends \IPS\Dispatcher\Controller
$member = $login->authenticate();
if ( $member !== NULL )
{
/* Check permission */
if ( !$this->_memberHasUpgradePermission( $member ) )
{
throw new \DomainException('login_upgrader_no_permission');
}
/* Create a unique session key and redirect */
$_SESSION['uniqueKey'] = md5( uniqid( microtime(), TRUE ) );
$_SESSION['uniqueKey'] = \IPS\Login::generateRandomString();
/* IPS Cloud Sync */
\IPS\IPS::resyncIPSCloud();
/* Redirect */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=systemcheck" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
}
}
@@ -113,4 +137,69 @@ class _login extends \IPS\Dispatcher\Controller
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('login');
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms' )->login( $login->forms( TRUE ), $error );
}
/**
* Can member log into upgrader?
*
* @param \IPS\Member $member The member
* @return bool
*/
protected function _memberHasUpgradePermission( \IPS\Member $member )
{
/* 4.x */
if ( \IPS\Db::i()->checkForTable( 'core_admin_permission_rows' ) )
{
/* This permission was added in 4.1.6, so if we have it, use it */
if ( \IPS\Application::load('core')->long_version > 101021 )
{
return $member->hasAcpRestriction( 'core', 'overview', 'upgrade_manage' );
}
/* Otherwise, let them in if they're an admin */
else
{
return $member->isAdmin();
}
}
/* 3.x */
else
{
/* Does our primary group have permission? */
try
{
$admin = (bool) \IPS\Db::i()->select( 'g_access_cp', 'groups', array( 'g_id=?', $member->member_group_id ) )->first();
}
catch( \UnderflowException $e )
{
throw new \OutOfRangeException( 'upgrade_group_not_exist' );
}
if( $admin )
{
return TRUE;
}
/* Check secondary groups as well */
if( $member->mgroup_others )
{
/* In some versions we stored as ",1,2," with trailing/preceeding commas, so account for that */
foreach( explode( ',', trim( $member->mgroup_others, ',' ) ) as $group )
{
try
{
$admin = (bool) \IPS\Db::i()->select( 'g_access_cp', 'groups', array( 'g_id=?', $group ) )->first();
if( $admin )
{
return TRUE;
}
}
/* It is possible the user has an old group that no longer exists defined as a secondary group */
catch( \UnderflowException $e ){}
}
}
/* Still here? No permission */
return FALSE;
}
}
}