Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

@@ -64,77 +64,87 @@ class _login extends \IPS\Dispatcher\Controller
\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&sessionCheck=1", NULL, NULL, NULL, \IPS\Settings::i()->logins_over_https ) );
$login->flagOptions = FALSE;
/* < 4.0.0 */
$legacy = FALSE;
if( \IPS\Db::i()->checkForTable( 'login_methods' ) )
if ( \IPS\BYPASS_UPGRADER_LOGIN )
{
$legacy = TRUE;
$_SESSION['uniqueKey'] = \IPS\Login::generateRandomString();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=systemcheck" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
}
/* Restoring a part finished upgrade means no log in hander rows even though table has been renamed */
if ( \IPS\Db::i()->checkForTable( 'core_login_handlers' ) )
/* Before going any further, make sure there is an actual upgrade to be done. This both provides a nicer experience (so
people don't log in ust to be told there's nothing to upgrade) and prevents having a permenantly available login
screen which doesn't use locking (which could be use to bruteforce an account) */
$canUpgrade = FALSE;
foreach( \IPS\Application::applications() as $app => $data )
{
$legacy = FALSE;
$path = \IPS\ROOT_PATH . '/applications/' . $app;
if ( ! \IPS\Db::i()->select( 'COUNT(*)', 'core_login_handlers' )->first() )
if ( $app != 'chat' and is_dir( $path . '/data' ) )
{
$legacy = TRUE;
}
}
if ( $legacy === TRUE )
{
/* Force internal only as we don't have the framework installed (JS/templates, etc) at this point to run external log in modules */
\IPS\Login\LoginAbstract::$databaseTable = 'login_methods';
$login::$allHandlers['internal'] = \IPS\Login\LoginAbstract::constructFromData( array (
'login_key' => 'Upgrade',
'login_enabled' => 1,
'login_settings' => '{"auth_types":"3"}',
'login_order' => 1,
'login_acp' => 1
) );
$login::$handlers = $login::$allHandlers;
}
$handlers = \IPS\Login::handlers();
/* Process */
$error = NULL;
try
{
$member = $login->authenticate();
if ( $member !== NULL )
{
/* Check permission */
if ( !$this->_memberHasUpgradePermission( $member ) )
$currentVersion = \IPS\Application::load( $app )->long_version;
$availableVersion = \IPS\Application::getAvailableVersion( $app );
if ( empty( $errors ) AND $availableVersion > $currentVersion )
{
throw new \DomainException('login_upgrader_no_permission');
$canUpgrade = TRUE;
}
/* Create a unique session key and redirect */
$_SESSION['uniqueKey'] = \IPS\Login::generateRandomString();
/* IPS Cloud Sync */
\IPS\IPS::resyncIPSCloud('Beginning upgrade');
/* Redirect */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=systemcheck" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
}
}
catch ( \Exception $e )
/* We need to allow logins if the previous upgrade wasn't finished */
if( file_exists( \IPS\ROOT_PATH . '/uploads/logs/upgrader_data.cgi' ) )
{
$error = $e->getMessage();
$canUpgrade = TRUE;
}
/* Output */
if ( !$canUpgrade )
{
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms' )->noapps();
return;
}
/* Nope, show a form */
$error = NULL;
if ( isset( \IPS\Request::i()->auth ) and isset( \IPS\Request::i()->password ) )
{
$table = 'core_members';
if ( \IPS\Db::i()->checkForTable( 'members' ) AND !\IPS\Db::i()->checkForTable( 'core_members' ) )
{
$table = 'members';
}
$memberRows = \IPS\Db::i()->select( '*', $table, array( 'email=? OR email=? OR name=? OR name=?', \IPS\Request::i()->auth, \IPS\Request::legacyEscape( \IPS\Request::i()->auth ), \IPS\Request::i()->auth, \IPS\Request::legacyEscape( \IPS\Request::i()->auth ) ) );
if ( count( $memberRows ) )
{
foreach( $memberRows as $memberRow )
{
$member = \IPS\Member::constructFromData( $memberRow );
if ( password_verify( \IPS\Request::i()->password, $member->members_pass_hash ) or $member->verifyLegacyPassword( \IPS\Request::i()->password ) )
{
if ( $this->_memberHasUpgradePermission( $member ) )
{
$_SESSION['uniqueKey'] = \IPS\Login::generateRandomString();
\IPS\IPS::resyncIPSCloud('Beginning upgrade');
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=systemcheck" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
}
else
{
$error = 'login_upgrader_no_permission';
}
}
else
{
$error = 'login_err_bad_password';
}
}
}
else
{
$error = 'login_err_no_account';
}
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('login');
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms' )->login( $login->forms( TRUE ), $error );
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms' )->login( $error );
}
/**