Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,32 +11,48 @@
|
||||
namespace IPS\core\modules\setup\install;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Email;
|
||||
use IPS\Helpers\Form\Password;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\TextArea;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
use function file_put_contents;
|
||||
use function function_exists;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installer: Admin Account
|
||||
*/
|
||||
class _admin extends \IPS\Dispatcher\Controller
|
||||
class admin extends Controller
|
||||
{
|
||||
/**
|
||||
* Show Form
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'admin', 'continue' );
|
||||
$form = new Form( 'admin', 'continue' );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'admin_user', NULL, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Password( 'admin_pass1', NULL, TRUE, array() ) );
|
||||
$form->add( new \IPS\Helpers\Form\Password( 'admin_pass2', NULL, TRUE, array( 'confirm' => 'admin_pass1' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Email( 'admin_email', NULL, TRUE ) );
|
||||
$form->add( new Text( 'admin_user', NULL, TRUE ) );
|
||||
$form->add( new Password( 'admin_pass1', NULL, TRUE, array() ) );
|
||||
$form->add( new Password( 'admin_pass2', NULL, TRUE, array( 'confirm' => 'admin_pass1' ) ) );
|
||||
$form->add( new Email( 'admin_email', NULL, TRUE ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$INFO = NULL;
|
||||
$INFO = [];
|
||||
require \IPS\ROOT_PATH . '/conf_global.php';
|
||||
$INFO = array_merge( $INFO, $values );
|
||||
|
||||
@@ -44,33 +60,33 @@ class _admin extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
if ( \file_put_contents( \IPS\ROOT_PATH . '/conf_global.php', $toWrite ) )
|
||||
if ( file_put_contents( \IPS\ROOT_PATH . '/conf_global.php', $toWrite ) )
|
||||
{
|
||||
/* PHP 5.5 - clear opcode cache or details won't be seen on next page load */
|
||||
if ( \function_exists( 'opcache_invalidate' ) )
|
||||
if ( function_exists( 'opcache_invalidate' ) )
|
||||
{
|
||||
@opcache_invalidate( \IPS\ROOT_PATH . '/conf_global.php' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'controller=install' ) );
|
||||
Output::i()->redirect( Url::internal( 'controller=install' ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
catch( Exception $ex )
|
||||
{
|
||||
$errorform = new \IPS\Helpers\Form( 'admin', 'continue' );
|
||||
$errorform->add( new \IPS\Helpers\Form\TextArea( 'conf_global_error', $toWrite, FALSE ) );
|
||||
$errorform = new Form( 'admin', 'continue' );
|
||||
$errorform->add( new TextArea( 'conf_global_error', $toWrite, FALSE ) );
|
||||
|
||||
foreach( $values as $k => $v )
|
||||
{
|
||||
$errorform->hiddenValues[ $k ] = $v;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->confWriteError( $errorform, \IPS\ROOT_PATH );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->confWriteError( $errorform, \IPS\ROOT_PATH );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('admin');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'admin', $form );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('admin');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'admin', $form );
|
||||
}
|
||||
}
|
||||
@@ -11,37 +11,56 @@
|
||||
namespace IPS\core\modules\setup\install;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DirectoryIterator;
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Custom;
|
||||
use IPS\Helpers\Form\TextArea;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use IPS\Xml\XMLReader;
|
||||
use function defined;
|
||||
use function file_put_contents;
|
||||
use function function_exists;
|
||||
use function in_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installer: Applications
|
||||
*/
|
||||
class _applications extends \IPS\Dispatcher\Controller
|
||||
class applications extends Controller
|
||||
{
|
||||
/**
|
||||
* Show Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
$INFO = NULL;
|
||||
require \IPS\ROOT_PATH . '/conf_global.php';
|
||||
|
||||
if( !isset( $INFO['lkey'] ) OR !$INFO['lkey'] )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'controller=license' ) );
|
||||
Output::i()->redirect( Url::internal( 'controller=license' ) );
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'applications', 'continue' );
|
||||
$form = new Form( 'applications', 'continue' );
|
||||
|
||||
$apps = array();
|
||||
$defaultTicks = array( 'core' );
|
||||
foreach( new \DirectoryIterator( \IPS\ROOT_PATH . '/applications' ) as $app )
|
||||
foreach( new DirectoryIterator( \IPS\ROOT_PATH . '/applications' ) as $app )
|
||||
{
|
||||
if ( mb_substr( $app, 0, 1 ) !== '.' and $app != 'index.html' )
|
||||
{
|
||||
@@ -68,7 +87,7 @@ class _applications extends \IPS\Dispatcher\Controller
|
||||
/* Get app name */
|
||||
if ( file_exists( $app->getPathName() . '/data/lang.xml' ) )
|
||||
{
|
||||
$xml = \IPS\Xml\XMLReader::safeOpen( $app->getPathName() . '/data/lang.xml' );
|
||||
$xml = XMLReader::safeOpen( $app->getPathName() . '/data/lang.xml' );
|
||||
$xml->read();
|
||||
|
||||
$xml->read();
|
||||
@@ -100,26 +119,26 @@ class _applications extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
$apps = array_merge( $system, $apps );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'apps', $defaultTicks, TRUE, array(
|
||||
$form->add( new Custom( 'apps', $defaultTicks, TRUE, array(
|
||||
'getHtml' => function( $element ) use ( $apps )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'forms' )->apps( $apps, $element->value );
|
||||
return Theme::i()->getTemplate( 'forms' )->apps( $apps, $element->value );
|
||||
},
|
||||
'validate' => function( $element ) use ( $defaultTicks )
|
||||
{
|
||||
if ( !\in_array( 'core', $element->value ) )
|
||||
if ( !in_array( 'core', $element->value ) )
|
||||
{
|
||||
$element->value['core'] = TRUE;
|
||||
}
|
||||
$uninstallable = array_diff( array_keys( $element->value ), $defaultTicks );
|
||||
if ( !empty( $uninstallable ) )
|
||||
{
|
||||
throw new \DomainException;
|
||||
throw new DomainException;
|
||||
}
|
||||
}
|
||||
) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'default_app', 'forums', TRUE, array(
|
||||
$form->add( new Custom( 'default_app', 'forums', TRUE, array(
|
||||
'getHtml' => function( $element ) use ( $apps )
|
||||
{
|
||||
$options = array_combine( array_keys( $apps ), array_map( function( $value ){ return $value['name']; }, $apps ) );
|
||||
@@ -127,22 +146,22 @@ class _applications extends \IPS\Dispatcher\Controller
|
||||
unset( $options['core'] );
|
||||
unset( $options['cloud'] );
|
||||
$options['core'] = $apps['core']['name'];
|
||||
return \IPS\Theme::i()->getTemplate( 'forms' )->select( 'default_app', $element->value, TRUE, $options );
|
||||
return Theme::i()->getTemplate( 'forms' )->select( 'default_app', $element->value, TRUE, $options );
|
||||
},
|
||||
'validate' => function( $element ) use ( $apps )
|
||||
{
|
||||
if ( !\in_array( $element->value, array_keys( $apps ) ) or !array_key_exists( $element->value, \IPS\Request::i()->apps ) )
|
||||
if ( !in_array( $element->value, array_keys( $apps ) ) or !array_key_exists( $element->value, Request::i()->apps ) )
|
||||
{
|
||||
throw new \DomainException('default_app_invalid');
|
||||
throw new DomainException('default_app_invalid');
|
||||
}
|
||||
}
|
||||
) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
if ( !\in_array( $values['default_app'], array_keys( $values['apps'] ) ) )
|
||||
if ( !in_array( $values['default_app'], array_keys( $values['apps'] ) ) )
|
||||
{
|
||||
throw new \DomainException('default_app_invalid');
|
||||
throw new DomainException('default_app_invalid');
|
||||
}
|
||||
|
||||
$INFO['apps'] = array_keys( $values['apps'] );
|
||||
@@ -152,21 +171,21 @@ class _applications extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
if ( \file_put_contents( \IPS\ROOT_PATH . '/conf_global.php', $toWrite ) )
|
||||
if ( file_put_contents( \IPS\ROOT_PATH . '/conf_global.php', $toWrite ) )
|
||||
{
|
||||
/* PHP 5.5 - clear opcode cache or details won't be seen on next page load */
|
||||
if ( \function_exists( 'opcache_invalidate' ) )
|
||||
if ( function_exists( 'opcache_invalidate' ) )
|
||||
{
|
||||
@opcache_invalidate( \IPS\ROOT_PATH . '/conf_global.php' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'controller=serverdetails' ) );
|
||||
Output::i()->redirect( Url::internal( 'controller=serverdetails' ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
catch( Exception $ex )
|
||||
{
|
||||
$errorform = new \IPS\Helpers\Form( 'applications', 'continue' );
|
||||
$errorform->add( new \IPS\Helpers\Form\TextArea( 'conf_global_error', $toWrite, FALSE ) );
|
||||
$errorform = new Form( 'applications', 'continue' );
|
||||
$errorform->add( new TextArea( 'conf_global_error', $toWrite, FALSE ) );
|
||||
$errorform->class = 'ipsForm_vertical';
|
||||
|
||||
foreach( $values as $k => $v )
|
||||
@@ -174,12 +193,12 @@ class _applications extends \IPS\Dispatcher\Controller
|
||||
$errorform->hiddenValues[ $k ] = $v;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->confWriteError( $errorform, \IPS\ROOT_PATH );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->confWriteError( $errorform, \IPS\ROOT_PATH );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('applications');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'applications', $form );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('applications');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'applications', $form );
|
||||
}
|
||||
}
|
||||
@@ -11,40 +11,52 @@
|
||||
namespace IPS\core\modules\setup\install;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\core\FrontNavigation;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
use function file_put_contents;
|
||||
use function function_exists;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installer: Finished Screen
|
||||
*/
|
||||
class _done extends \IPS\Dispatcher\Controller
|
||||
class done extends Controller
|
||||
{
|
||||
/**
|
||||
* Finished
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
/* Reset theme maps to make sure bad data hasn't been cached by visits mid-setup */
|
||||
foreach( \IPS\Application::applications() as $app => $data )
|
||||
foreach( Application::applications() as $app => $data )
|
||||
{
|
||||
\IPS\Theme::deleteCompiledTemplate( $app);
|
||||
\IPS\Theme::deleteCompiledCss( $app );
|
||||
\IPS\Theme::deleteCompiledResources( $app );
|
||||
Theme::deleteCompiledTemplate( $app);
|
||||
Theme::deleteCompiledCss( $app );
|
||||
Theme::deleteCompiledResources( $app );
|
||||
}
|
||||
|
||||
\IPS\Output::clearJsFiles();
|
||||
Output::clearJsFiles();
|
||||
|
||||
/* Build default front navigation - if you visit ACP directly after it won't build, and you can run into issues */
|
||||
\IPS\core\FrontNavigation::i()->buildDefaultFrontNavigation();
|
||||
FrontNavigation::i()->buildDefaultFrontNavigation( true );
|
||||
|
||||
require \IPS\ROOT_PATH . '/conf_global.php';
|
||||
|
||||
\IPS\Settings::i()->changeValues( array( 'ipb_reg_number' => $INFO['lkey'], 'site_secret_key' => md5( $INFO['sql_pass'] . $INFO['base_url'] . $INFO['sql_database'] ) ) );
|
||||
Settings::i()->changeValues( array( 'ipb_reg_number' => $INFO['lkey'], 'site_secret_key' => md5( $INFO['sql_pass'] . $INFO['base_url'] . $INFO['sql_database'] ) ) );
|
||||
|
||||
\file_put_contents( \IPS\ROOT_PATH . '/conf_global.php', "<?php\n\n" . '$INFO = ' . var_export( array(
|
||||
file_put_contents( \IPS\ROOT_PATH . '/conf_global.php', "<?php\n\n" . '$INFO = ' . var_export( array(
|
||||
'sql_host' => $INFO['sql_host'],
|
||||
'sql_database' => $INFO['sql_database'],
|
||||
'sql_user' => $INFO['sql_user'],
|
||||
@@ -62,13 +74,13 @@ class _done extends \IPS\Dispatcher\Controller
|
||||
), TRUE ) . ';' );
|
||||
|
||||
/* PHP 5.5 - clear opcode cache or details won't be seen on next page load */
|
||||
if ( \function_exists( 'opcache_invalidate' ) )
|
||||
if ( function_exists( 'opcache_invalidate' ) )
|
||||
{
|
||||
@opcache_invalidate( \IPS\ROOT_PATH . '/conf_global.php' );
|
||||
}
|
||||
|
||||
\IPS\Settings::i()->base_url = $INFO['base_url'];
|
||||
Settings::i()->base_url = $INFO['base_url'];
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('done');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('done');
|
||||
}
|
||||
}
|
||||
@@ -11,21 +11,34 @@
|
||||
namespace IPS\core\modules\setup\install;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\core\Setup\Install as InstallClass;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\MultipleRedirect;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installer: Install
|
||||
*/
|
||||
class _install extends \IPS\Dispatcher\Controller
|
||||
class install extends Controller
|
||||
{
|
||||
/**
|
||||
* Install
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
require \IPS\ROOT_PATH . '/conf_global.php';
|
||||
|
||||
@@ -34,20 +47,20 @@ class _install extends \IPS\Dispatcher\Controller
|
||||
a pause fixes the issue so we manually request a page refresh rather than doing it automatically */
|
||||
if ( ! isset( $INFO['admin_user'] ) )
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('install');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->manualStart();
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('install');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->manualStart();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$multipleRedirect = new \IPS\Helpers\MultipleRedirect(
|
||||
\IPS\Http\Url::internal( 'controller=install' ),
|
||||
$multipleRedirect = new MultipleRedirect(
|
||||
Url::internal( 'controller=install' ),
|
||||
function( $data )
|
||||
{
|
||||
try
|
||||
{
|
||||
require \IPS\ROOT_PATH . '/conf_global.php';
|
||||
$install = new \IPS\core\Setup\Install(
|
||||
$install = new InstallClass(
|
||||
$INFO['apps'],
|
||||
$INFO['default_app'],
|
||||
$INFO['base_url'],
|
||||
@@ -59,43 +72,43 @@ class _install extends \IPS\Dispatcher\Controller
|
||||
$INFO['diagnostics_reporting']
|
||||
);
|
||||
}
|
||||
catch ( \InvalidArgumentException $e )
|
||||
catch ( InvalidArgumentException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'error', '4S112/1', 403, '' );
|
||||
Output::i()->error( 'error', '4S112/1', 403, '' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return $install->process( $data );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
$backtrace = $e->getTraceAsString();
|
||||
|
||||
$error = \IPS\Theme::i()->getTemplate( 'global' )->error( "Error", $e->getMessage() ?: "Error", $e->getCode(), $backtrace );
|
||||
$error = Theme::i()->getTemplate( 'global' )->error( "Error", $e->getMessage() ?: "Error", $e->getCode(), $backtrace );
|
||||
|
||||
\IPS\Request::i()->start = true;
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('error');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'install', $error, FALSE );
|
||||
Request::i()->start = true;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('error');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'install', $error, FALSE );
|
||||
|
||||
/* If we're still here - output */
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Output::i()->output, 200, 'text/html' );
|
||||
Output::i()->sendOutput( Output::i()->output, 200, 'text/html' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->globalTemplate( \IPS\Output::i()->title, \IPS\Output::i()->output ), 403, 'text/html' );
|
||||
Output::i()->sendOutput( Theme::i()->getTemplate( 'global', 'core' )->globalTemplate( Output::i()->title, Output::i()->output ), 403, 'text/html' );
|
||||
}
|
||||
}
|
||||
},
|
||||
function()
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'controller=done' ) );
|
||||
Output::i()->redirect( Url::internal( 'controller=done' ) );
|
||||
}
|
||||
);
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('install');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'install', $multipleRedirect, FALSE );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('install');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'install', $multipleRedirect, FALSE );
|
||||
}
|
||||
}
|
||||
@@ -11,36 +11,54 @@
|
||||
namespace IPS\core\modules\setup\install;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Checkbox;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\TextArea;
|
||||
use IPS\Http\Url;
|
||||
use IPS\IPS;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
use function file_put_contents;
|
||||
use function function_exists;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installer: License
|
||||
*/
|
||||
class _license extends \IPS\Dispatcher\Controller
|
||||
class license extends Controller
|
||||
{
|
||||
/**
|
||||
* Show Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'license', 'continue', \IPS\Http\Url::external( ( \IPS\Request::i()->isSecure() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '?controller=license' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'lkey', NULL, TRUE, array( 'size' => 50 ), function( $val )
|
||||
$form = new Form( 'license', 'continue', Url::external( ( Request::i()->isSecure() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '?controller=license' ) );
|
||||
$form->add( new Text( 'lkey', NULL, TRUE, array( 'size' => 50 ), function( $val )
|
||||
{
|
||||
\IPS\IPS::checkLicenseKey( $val, ( \IPS\Request::i()->isSecure() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . mb_substr( $_SERVER['SCRIPT_NAME'], 0, -mb_strlen( \IPS\CP_DIRECTORY . '/install/index.php' ) ) );
|
||||
}, NULL, '<a href="' . \IPS\Http\Url::ips( 'docs/find_lkey' ) . '" target="_blank" rel="noopener">' . \IPS\Member::loggedIn()->language()->addToStack('lkey_help') . '</a>' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Checkbox( 'eula', FALSE, TRUE, array( 'label' => 'eula_suffix' ), function( $val )
|
||||
IPS::checkLicenseKey( $val, ( Request::i()->isSecure() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . mb_substr( $_SERVER['SCRIPT_NAME'], 0, -mb_strlen( 'admin/install/index.php' ) ) );
|
||||
}, NULL, '<a href="' . Url::ips( 'docs/find_lkey' ) . '" target="_blank" rel="noopener">' . Member::loggedIn()->language()->addToStack('lkey_help') . ' <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M320 0c-17.7 0-32 14.3-32 32s14.3 32 32 32h82.7L201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L448 109.3V192c0 17.7 14.3 32 32 32s32-14.3 32-32V32c0-17.7-14.3-32-32-32H320zM80 32C35.8 32 0 67.8 0 112V432c0 44.2 35.8 80 80 80H400c44.2 0 80-35.8 80-80V320c0-17.7-14.3-32-32-32s-32 14.3-32 32V432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V112c0-8.8 7.2-16 16-16H192c17.7 0 32-14.3 32-32s-14.3-32-32-32H80z"/></svg></a>' ) );
|
||||
$form->add( new Checkbox( 'eula', FALSE, TRUE, array( 'label' => 'eula_suffix' ), function( $val )
|
||||
{
|
||||
if ( !$val )
|
||||
{
|
||||
throw new \InvalidArgumentException('eula_err');
|
||||
throw new InvalidArgumentException('eula_err');
|
||||
}
|
||||
}, "<textarea disabled style='width: 100%; height: 250px'>" . file_get_contents( 'eula.txt' ) . "</textarea><br>" ) );
|
||||
}, "<textarea disabled style='width: 100%; height: 250px'>" . file_get_contents( 'eula.txt' ) . "</textarea>" ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -55,40 +73,40 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$file = @\file_put_contents( \IPS\ROOT_PATH . '/conf_global.php', $toWrite );
|
||||
$file = @file_put_contents( \IPS\ROOT_PATH . '/conf_global.php', $toWrite );
|
||||
if ( !$file )
|
||||
{
|
||||
throw new \Exception;
|
||||
throw new Exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* PHP 5.5 - clear opcode cache or details won't be seen on next page load */
|
||||
if ( \function_exists( 'opcache_invalidate' ) )
|
||||
if ( function_exists( 'opcache_invalidate' ) )
|
||||
{
|
||||
@opcache_invalidate( \IPS\ROOT_PATH . '/conf_global.php' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'controller=applications' ) );
|
||||
Output::i()->redirect( Url::internal( 'controller=applications' ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
catch( Exception $ex )
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'error' );
|
||||
$errorform = new \IPS\Helpers\Form( 'license', 'continue' );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'error' );
|
||||
$errorform = new Form( 'license', 'continue' );
|
||||
$errorform->class = '';
|
||||
$errorform->add( new \IPS\Helpers\Form\TextArea( 'conf_global_error', $toWrite, FALSE ) );
|
||||
$errorform->add( new TextArea( 'conf_global_error', $toWrite, FALSE ) );
|
||||
|
||||
foreach( $values as $k => $v )
|
||||
{
|
||||
$errorform->hiddenValues[ $k ] = $v;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->confWriteError( $errorform, \IPS\ROOT_PATH );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->confWriteError( $errorform, \IPS\ROOT_PATH );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('license');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'license', $form, TRUE, TRUE );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('license');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'license', $form, TRUE, TRUE );
|
||||
}
|
||||
}
|
||||
@@ -11,37 +11,61 @@
|
||||
namespace IPS\core\modules\setup\install;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use IPS\core\Setup\Upgrade;
|
||||
use IPS\Db;
|
||||
use IPS\Db\Exception as DbException;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Password;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\TextArea;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
use function file_put_contents;
|
||||
use function function_exists;
|
||||
use const IPS\CIC;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installer: Server Details
|
||||
*/
|
||||
class _serverdetails extends \IPS\Dispatcher\Controller
|
||||
class serverdetails extends Controller
|
||||
{
|
||||
/**
|
||||
* Show Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'serverdetails', 'continue' );
|
||||
$form = new Form( 'serverdetails', 'continue' );
|
||||
|
||||
$form->addHeader( 'mysql_server' );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'sql_host', ini_get('mysqli.default_host') ?: 'localhost', TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'sql_user', ini_get('mysqli.default_user'), TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Password( 'sql_pass', ini_get('mysqli.default_pw'), FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'sql_database', NULL, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'sql_port', ini_get('mysqli.default_port'), FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'sql_socket', ini_get('mysqli.default_socket'), FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'sql_tbl_prefix', NULL, FALSE, [ 'regex' => '/^([a-z0-9_-]+?)?$/i' ] ) );
|
||||
$form->add( new Text( 'sql_host', ini_get('mysqli.default_host') ?: 'localhost', TRUE ) );
|
||||
$form->add( new Text( 'sql_user', ini_get('mysqli.default_user'), TRUE ) );
|
||||
$form->add( new Password( 'sql_pass', ini_get('mysqli.default_pw'), FALSE ) );
|
||||
$form->add( new Text( 'sql_database', NULL, TRUE ) );
|
||||
$form->add( new Number( 'sql_port', ini_get('mysqli.default_port'), FALSE ) );
|
||||
$form->add( new Text( 'sql_socket', ini_get('mysqli.default_socket'), FALSE ) );
|
||||
$form->add( new Text( 'sql_tbl_prefix', NULL, FALSE, [ 'regex' => '/^([a-z0-9_-]+?)?$/i' ] ) );
|
||||
$form->addHeader( 'http_server' );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'base_url', ( \IPS\Request::i()->isSecure() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . mb_substr( $_SERVER['SCRIPT_NAME'], 0, -mb_strlen( \IPS\CP_DIRECTORY . '/install/index.php' ) ), TRUE, array( 'size' => 50 ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'diagnostics_reporting', TRUE ) );
|
||||
$form->add( new Text( 'base_url', ( Request::i()->isSecure() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . mb_substr( $_SERVER['SCRIPT_NAME'], 0, -mb_strlen( 'admin/install/index.php' ) ), TRUE, array( 'size' => 50 ) ) );
|
||||
$form->add( new YesNo( 'diagnostics_reporting', TRUE ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -52,17 +76,17 @@ class _serverdetails extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
$db = \IPS\Db::i( 'test', $values );
|
||||
$db = Db::i( 'test', $values );
|
||||
|
||||
/* Connection Success, check MySQL version */
|
||||
$result = \IPS\core\Setup\Upgrade::mysqlRequirements( $db );
|
||||
$result = Upgrade::mysqlRequirements( $db );
|
||||
|
||||
if( !$result['requirements']['MySQL']['version']['success'] AND !\IPS\CIC )
|
||||
if( !$result['requirements']['MySQL']['version']['success'] AND !CIC )
|
||||
{
|
||||
throw new \DomainException( $result['requirements']['MySQL']['version']['message'] );
|
||||
throw new DomainException( $result['requirements']['MySQL']['version']['message'] );
|
||||
}
|
||||
}
|
||||
catch( \IPS\Db\Exception $e )
|
||||
catch( DbException $e )
|
||||
{
|
||||
/* Can't connect. Maybe db doesn't exist, let's create it if allowed */
|
||||
if( $e->getCode() == 1049 )
|
||||
@@ -72,19 +96,19 @@ class _serverdetails extends \IPS\Dispatcher\Controller
|
||||
$dbName = $values['sql_database'];
|
||||
unset( $values['sql_database'] );
|
||||
|
||||
$db = \IPS\Db::i( 'create', $values )->createDatabase( $dbName );
|
||||
$db = Db::i( 'create', $values )->createDatabase( $dbName );
|
||||
$values['sql_database'] = $dbName;
|
||||
|
||||
$db = \IPS\Db::i( 'created', $values );
|
||||
$db = Db::i( 'created', $values );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack('err_db_cant_create') );
|
||||
throw new DomainException( Member::loggedIn()->language()->addToStack('err_db_cant_create') );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \DomainException( $e->getMessage() );
|
||||
throw new DomainException( $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,10 +116,10 @@ class _serverdetails extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( $db->checkForTable( 'core_sys_conf_settings') )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack('err_db_exists') );
|
||||
throw new DomainException( Member::loggedIn()->language()->addToStack('err_db_exists') );
|
||||
}
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
catch ( UnderflowException $e ) { }
|
||||
|
||||
$INFO = NULL;
|
||||
require \IPS\ROOT_PATH . '/conf_global.php';
|
||||
@@ -105,36 +129,36 @@ class _serverdetails extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
if ( \file_put_contents( \IPS\ROOT_PATH . '/conf_global.php', $toWrite ) )
|
||||
if ( file_put_contents( \IPS\ROOT_PATH . '/conf_global.php', $toWrite ) )
|
||||
{
|
||||
/* PHP 5.6 - clear opcode cache or details won't be seen on next page load */
|
||||
if ( \function_exists( 'opcache_invalidate' ) )
|
||||
if ( function_exists( 'opcache_invalidate' ) )
|
||||
{
|
||||
@opcache_invalidate( \IPS\ROOT_PATH . '/conf_global.php' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'controller=admin' ) );
|
||||
Output::i()->redirect( Url::internal( 'controller=admin' ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
catch( Exception $ex )
|
||||
{
|
||||
$errorform = new \IPS\Helpers\Form( 'serverdetails', 'continue' );
|
||||
$errorform->add( new \IPS\Helpers\Form\TextArea( 'conf_global_error', $toWrite, FALSE ) );
|
||||
$errorform = new Form( 'serverdetails', 'continue' );
|
||||
$errorform->add( new TextArea( 'conf_global_error', $toWrite, FALSE ) );
|
||||
|
||||
foreach( $values as $k => $v )
|
||||
{
|
||||
$errorform->hiddenValues[ $k ] = $v;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->confWriteError( $errorform, \IPS\ROOT_PATH );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->confWriteError( $errorform, \IPS\ROOT_PATH );
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
if( $e->getMessage() == 'mysqli::set_charset(): Error executing query' )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('err_no_utf8mb4');
|
||||
$form->error = Member::loggedIn()->language()->addToStack('err_no_utf8mb4');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -143,7 +167,7 @@ class _serverdetails extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('serverdetails');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'serverdetails', $form );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('serverdetails');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'serverdetails', $form );
|
||||
}
|
||||
}
|
||||
@@ -11,26 +11,36 @@
|
||||
namespace IPS\core\modules\setup\install;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\Setup\Install;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installer: System Check
|
||||
*/
|
||||
class _systemcheck extends \IPS\Dispatcher\Controller
|
||||
class systemcheck extends Controller
|
||||
{
|
||||
/**
|
||||
* Show Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
/* Clear previous session data */
|
||||
if( !isset( \IPS\Request::i()->sessionCheck ) AND \count( $_SESSION ) )
|
||||
if( !isset( Request::i()->sessionCheck ) AND count( $_SESSION ) )
|
||||
{
|
||||
foreach( $_SESSION as $k => $v )
|
||||
{
|
||||
@@ -39,20 +49,20 @@ class _systemcheck extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* 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 ) )
|
||||
if( !isset( Request::i()->sessionCheck ) )
|
||||
{
|
||||
$_SESSION['sessionCheck'] = TRUE;
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setQueryString( 'sessionCheck', 1 ) );
|
||||
Output::i()->redirect( Request::i()->url()->setQueryString( 'sessionCheck', 1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !isset( $_SESSION['sessionCheck'] ) OR !$_SESSION['sessionCheck'] )
|
||||
{
|
||||
\IPS\Output::i()->error( 'session_check_fail', '5C348/1', 500, '' );
|
||||
Output::i()->error( 'session_check_fail', '5C348/1', 500, '' );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('healthcheck');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->healthcheck( \IPS\core\Setup\Install::systemRequirements() );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('healthcheck');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->healthcheck( Install::systemRequirements() );
|
||||
}
|
||||
}
|
||||
@@ -11,50 +11,72 @@
|
||||
namespace IPS\core\modules\setup\upgrade;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Application;
|
||||
use IPS\core\Setup\Upgrade;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\IPS;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use IPS\Xml\XMLReader;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrader: Applications
|
||||
*/
|
||||
class _applications extends \IPS\Dispatcher\Controller
|
||||
class applications extends Controller
|
||||
{
|
||||
/**
|
||||
* Show Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
$apps = array();
|
||||
|
||||
/* Update old app keys or everything gets confused */
|
||||
\IPS\Db::i()->update( 'core_applications', array( 'app_directory' => 'cms' ), array( 'app_directory=?', 'ccs' ) );
|
||||
\IPS\Db::i()->update( 'core_applications', array( 'app_directory' => 'chat' ), array( 'app_directory=?', 'ipchat' ) );
|
||||
|
||||
/* We had a bug in an earlier beta where the version may not have updated properly, so we need to account for that but it has to happen before we load version files */
|
||||
/* @todo We may want to remove those down the road as it should only affect users who have upgraded to early betas */
|
||||
if( \IPS\Db::i()->checkForTable( 'core_widgets' ) AND !\IPS\Db::i()->checkForColumn( 'core_widgets', 'embeddable' ) )
|
||||
/* Stop here if we are trying to upgrade from a version older than 4.5 */
|
||||
if( Application::load( 'core' )->long_version < 105100 )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_applications', array( 'app_version' => '4.0.0 Beta 1', 'app_long_version' => '100001' ) );
|
||||
Upgrade::setUpgradingFlag( FALSE );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('applications');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'applications', Theme::i()->getTemplate( 'forms' )->minversioncheck() );
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we are upgrading from a version older than v5, disable all 3rd party apps */
|
||||
if( Application::load( 'core' )->long_version < 200000 )
|
||||
{
|
||||
Db::i()->update( 'core_applications', array( 'app_enabled' => 0, 'app_requires_manual_intervention' => 1 ), Db::i()->in( 'app_directory', IPS::$ipsApps, true ) );
|
||||
}
|
||||
|
||||
/* Clear any caches or else we might not see new versions */
|
||||
if ( isset( \IPS\Data\Store::i()->applications ) )
|
||||
if ( isset( Store::i()->applications ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->applications );
|
||||
unset( Store::i()->applications );
|
||||
}
|
||||
if ( isset( \IPS\Data\Store::i()->modules ) )
|
||||
if ( isset( Store::i()->modules ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->modules );
|
||||
unset( Store::i()->modules );
|
||||
}
|
||||
|
||||
foreach( \IPS\Application::applications() as $app => $data )
|
||||
foreach( Application::applications() as $app => $data )
|
||||
{
|
||||
$path = \IPS\Application::getRootPath( $app ) . '/applications/' . $app;
|
||||
$path = Application::getRootPath( $app ) . '/applications/' . $app;
|
||||
|
||||
if ( $app == 'chat' )
|
||||
{
|
||||
@@ -76,15 +98,15 @@ class _applications extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Figure out of an upgrade is even available */
|
||||
$currentVersion = \IPS\Application::load( $app )->long_version;
|
||||
$availableVersion = \IPS\Application::getAvailableVersion( $app );
|
||||
$currentVersion = Application::load( $app )->long_version;
|
||||
$availableVersion = Application::getAvailableVersion( $app );
|
||||
|
||||
$name = $data->_title;
|
||||
|
||||
/* Get app name */
|
||||
if ( file_exists( $path . '/data/lang.xml' ) )
|
||||
{
|
||||
$xml = \IPS\Xml\XMLReader::safeOpen( $path . '/data/lang.xml' );
|
||||
$xml = XMLReader::safeOpen( $path . '/data/lang.xml' );
|
||||
$xml->read();
|
||||
|
||||
$xml->read();
|
||||
@@ -104,14 +126,14 @@ class _applications extends \IPS\Dispatcher\Controller
|
||||
'name' => $name,
|
||||
'disabled' => ( !empty( $errors ) OR $availableVersion <= $currentVersion ),
|
||||
'errors' => $errors,
|
||||
'current' => \IPS\Application::load( $app )->version,
|
||||
'available' => \IPS\Application::getAvailableVersion( $app, TRUE )
|
||||
'current' => Application::load( $app )->version,
|
||||
'available' => Application::getAvailableVersion( $app, TRUE )
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( \count( $apps ) )
|
||||
if( count( $apps ) )
|
||||
{
|
||||
/* Make sure the core app is the first index */
|
||||
if( isset( $apps['core'] ) )
|
||||
@@ -122,8 +144,8 @@ class _applications extends \IPS\Dispatcher\Controller
|
||||
$_SESSION['apps'] = $apps;
|
||||
|
||||
$warnings = array();
|
||||
$coreVersion = array_key_exists( 'core', $_SESSION['apps'] ) ? \IPS\Application::getAvailableVersion( 'core' ) : \IPS\Application::load( 'core' )->long_version;
|
||||
foreach ( \IPS\IPS::$ipsApps as $key )
|
||||
$coreVersion = array_key_exists( 'core', $_SESSION['apps'] ) ? Application::getAvailableVersion( 'core' ) : Application::load( 'core' )->long_version;
|
||||
foreach ( IPS::$ipsApps as $key )
|
||||
{
|
||||
if ( $key == 'chat' )
|
||||
{
|
||||
@@ -132,35 +154,35 @@ class _applications extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$appVersion = array_key_exists( $key, $_SESSION['apps'] ) ? \IPS\Application::getAvailableVersion( $key ) : \IPS\Application::load( $key )->long_version;
|
||||
$appVersion = array_key_exists( $key, $_SESSION['apps'] ) ? Application::getAvailableVersion( $key ) : Application::load( $key )->long_version;
|
||||
if ( $appVersion != $coreVersion )
|
||||
{
|
||||
$warnings[] = $key;
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
/* The application is not installed */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ( \count( $warnings ) )
|
||||
if ( count( $warnings ) )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=applications&do=warning" )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'warnings' => implode( ',', $warnings ) ) ) );
|
||||
Output::i()->redirect( Url::internal( "controller=applications&do=warning" )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'warnings' => implode( ',', $warnings ) ) ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=customoptions" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
Output::i()->redirect( Url::internal( "controller=customoptions" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$form = \IPS\Theme::i()->getTemplate( 'forms' )->noapps();
|
||||
$form = Theme::i()->getTemplate( 'forms' )->noapps();
|
||||
|
||||
\IPS\core\Setup\Upgrade::setUpgradingFlag( FALSE );
|
||||
Upgrade::setUpgradingFlag( FALSE );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('applications');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'applications', $form );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('applications');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'applications', $form );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,18 +190,18 @@ class _applications extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function warning()
|
||||
public function warning() : void
|
||||
{
|
||||
$apps = array();
|
||||
foreach ( explode( ',', \IPS\Request::i()->warnings ) as $key )
|
||||
foreach ( explode( ',', Request::i()->warnings ) as $key )
|
||||
{
|
||||
try
|
||||
{
|
||||
$name = \IPS\Application::load( $key )->_title;
|
||||
$name = Application::load( $key )->_title;
|
||||
$path = \IPS\ROOT_PATH . '/applications/' . $key;
|
||||
if ( file_exists( $path . '/data/lang.xml' ) )
|
||||
{
|
||||
$xml = \IPS\Xml\XMLReader::safeOpen( $path . '/data/lang.xml' );
|
||||
$xml = XMLReader::safeOpen( $path . '/data/lang.xml' );
|
||||
$xml->read();
|
||||
|
||||
$xml->read();
|
||||
@@ -194,10 +216,10 @@ class _applications extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
$apps[] = $name;
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
catch ( Exception $e ) { }
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('applications');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'applications', \IPS\Theme::i()->getTemplate( 'global' )->appWarnings( $apps ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('applications');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'applications', Theme::i()->getTemplate( 'global' )->appWarnings( $apps ) );
|
||||
}
|
||||
}
|
||||
@@ -11,23 +11,31 @@
|
||||
namespace IPS\core\modules\setup\upgrade;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrader: Confirm
|
||||
*/
|
||||
class _confirm extends \IPS\Dispatcher\Controller
|
||||
class confirm extends Controller
|
||||
{
|
||||
/**
|
||||
* Show Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
/* reset a few things */
|
||||
$_SESSION['lastJsonIndex'] = 0;
|
||||
@@ -35,9 +43,9 @@ class _confirm extends \IPS\Dispatcher\Controller
|
||||
$_SESSION['sqlFinished'] = array();
|
||||
|
||||
/* Create our temporary upgrade data storage table */
|
||||
if( !\IPS\Db::i()->checkForTable( 'upgrade_temp' ) )
|
||||
if( !Db::i()->checkForTable( 'upgrade_temp' ) )
|
||||
{
|
||||
\IPS\Db::i()->createTable( array(
|
||||
Db::i()->createTable( array(
|
||||
'name' => 'upgrade_temp',
|
||||
'columns' => array(
|
||||
'id' => array(
|
||||
@@ -73,7 +81,7 @@ class _confirm extends \IPS\Dispatcher\Controller
|
||||
) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('confirmpage');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->confirm();
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('confirmpage');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->confirm();
|
||||
}
|
||||
}
|
||||
@@ -11,37 +11,46 @@
|
||||
namespace IPS\core\modules\setup\upgrade;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Output;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrader: Continue Upgrade
|
||||
*/
|
||||
class _continueupgrade extends \IPS\Dispatcher\Controller
|
||||
class continueupgrade extends Controller
|
||||
{
|
||||
/**
|
||||
* Show Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
/* Best check for the upgrade file first */
|
||||
try
|
||||
{
|
||||
$json = json_decode( \IPS\Db::i()->select( 'upgrade_data', 'upgrade_temp' )->first(), TRUE );
|
||||
$json = json_decode( Db::i()->select( 'upgrade_data', 'upgrade_temp' )->first(), TRUE );
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$json = NULL;
|
||||
}
|
||||
|
||||
if ( \is_array( $json ) and isset( $json['session'] ) and isset( $json['data'] ) )
|
||||
if ( is_array( $json ) and isset( $json['session'] ) and isset( $json['data'] ) )
|
||||
{
|
||||
$url = \IPS\Http\Url::internal( "controller=upgrade" )->setQueryString( 'key', $_SESSION['uniqueKey'] );
|
||||
$url = Url::internal( "controller=upgrade" )->setQueryString( 'key', $_SESSION['uniqueKey'] );
|
||||
|
||||
/* Update session */
|
||||
foreach( $json['session'] as $k => $v )
|
||||
@@ -54,11 +63,11 @@ class _continueupgrade extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Populate the MR data */
|
||||
$_SESSION[ 'mr-' . md5( $url ) ] = json_encode( $json['data'] );
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
Output::i()->redirect( $url );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->error( 'cannot_continue_upgrade', '', 403, '' );
|
||||
Output::i()->error( 'cannot_continue_upgrade', '', 403, '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,23 +11,37 @@
|
||||
namespace IPS\core\modules\setup\upgrade;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrader: Custom Upgrade Options
|
||||
*/
|
||||
class _customoptions extends \IPS\Dispatcher\Controller
|
||||
class customoptions extends Controller
|
||||
{
|
||||
/**
|
||||
* Show Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
$elements = array();
|
||||
|
||||
@@ -38,7 +52,7 @@ class _customoptions extends \IPS\Dispatcher\Controller
|
||||
At the same time we look for any pre-upgrade checks, which completely halt everything. */
|
||||
foreach( $_SESSION['apps'] as $app => $upgrade )
|
||||
{
|
||||
$application = \IPS\Application::load( $app );
|
||||
$application = Application::load( $app );
|
||||
$steps = $application->getUpgradeSteps( $application->long_version );
|
||||
|
||||
foreach( $steps as $step )
|
||||
@@ -50,8 +64,8 @@ class _customoptions extends \IPS\Dispatcher\Controller
|
||||
|
||||
if( $output !== NULL )
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('admin');
|
||||
\IPS\Output::i()->output = $output;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('admin');
|
||||
Output::i()->output = $output;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -79,27 +93,27 @@ class _customoptions extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Do we need to disable any apps? */
|
||||
if( isset( \IPS\Request::i()->disable ) )
|
||||
if( isset( Request::i()->disable ) )
|
||||
{
|
||||
foreach( explode( ',', \IPS\Request::i()->disable ) as $app )
|
||||
foreach( explode( ',', Request::i()->disable ) as $app )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_applications', array( 'app_enabled' => 0 ), array( 'app_directory=?', $app ) );
|
||||
Db::i()->update( 'core_applications', array( 'app_enabled' => 0 ), array( 'app_directory=?', $app ) );
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Data\Store::i()->applications ) )
|
||||
if ( isset( Store::i()->applications ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->applications );
|
||||
unset( Store::i()->applications );
|
||||
}
|
||||
}
|
||||
|
||||
/* If there are no options, no need to show an empty/blank form */
|
||||
if( !\count( $elements ) )
|
||||
if( !count( $elements ) )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=confirm" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
Output::i()->redirect( Url::internal( "controller=confirm" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
}
|
||||
|
||||
/* Otherwise, show the form */
|
||||
$form = new \IPS\Helpers\Form( 'options', 'continue' );
|
||||
$form = new Form( 'options', 'continue' );
|
||||
|
||||
foreach( $elements as $element )
|
||||
{
|
||||
@@ -120,10 +134,10 @@ class _customoptions extends \IPS\Dispatcher\Controller
|
||||
$_SESSION['upgrade_options'][ $app ][ $version ][ $key ] = $value;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=confirm" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
Output::i()->redirect( Url::internal( "controller=confirm" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('admin');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'admin', $form );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('admin');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'admin', $form );
|
||||
}
|
||||
}
|
||||
@@ -11,31 +11,46 @@
|
||||
namespace IPS\core\modules\setup\upgrade;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use IPS\Application;
|
||||
use IPS\core\AdminNotification;
|
||||
use IPS\Data\Store;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\IPS;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrader: Finished Screen
|
||||
*/
|
||||
class _done extends \IPS\Dispatcher\Controller
|
||||
class done extends Controller
|
||||
{
|
||||
/**
|
||||
* Finished
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
\IPS\Output::clearJsFiles();
|
||||
Output::clearJsFiles();
|
||||
|
||||
/* Get rid of temporary upgrade data */
|
||||
\IPS\Db::i()->dropTable( 'upgrade_temp', TRUE );
|
||||
Db::i()->dropTable( 'upgrade_temp', TRUE );
|
||||
|
||||
/* Reset theme maps to make sure bad data hasn't been cached by visits mid-setup */
|
||||
foreach( \IPS\Theme::themes() as $id => $set )
|
||||
foreach( Theme::themes() as $id => $set )
|
||||
{
|
||||
/* Update mappings */
|
||||
$set->css_map = array();
|
||||
@@ -43,6 +58,8 @@ class _done extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Delete some variables we stored in our session */
|
||||
unset( $_SESSION['apps'] );
|
||||
|
||||
if( isset( $_SESSION['upgrade_options'] ) )
|
||||
{
|
||||
unset( $_SESSION['upgrade_options'] );
|
||||
@@ -61,105 +78,24 @@ class _done extends \IPS\Dispatcher\Controller
|
||||
unset( $_SESSION['key'] );
|
||||
|
||||
/* Clear recent datastore logs to prevent an error message displaying immediately after upgrade */
|
||||
\IPS\Db::i()->delete( 'core_log', array( '`category`=? AND `time`>?', 'datastore', \IPS\DateTime::create()->sub( new \DateInterval( 'PT1H' ) )->getTimestamp() ) );
|
||||
Db::i()->delete( 'core_log', array( '`category`=? AND `time`>?', 'datastore', DateTime::create()->sub( new DateInterval( 'PT1H' ) )->getTimestamp() ) );
|
||||
|
||||
/* Unset settings datastore to prevent any upgrade settings that were overridden becoming persistent */
|
||||
\IPS\Settings::i()->clearCache();
|
||||
Settings::i()->clearCache();
|
||||
|
||||
/* IPS Cloud Sync */
|
||||
\IPS\IPS::resyncIPSCloud('Upgraded community');
|
||||
IPS::resyncIPSCloud('Upgraded community');
|
||||
|
||||
/* Remove any new version ACP Notifications */
|
||||
\IPS\core\AdminNotification::remove( 'core', 'NewVersion' );
|
||||
AdminNotification::remove( 'core', 'NewVersion' );
|
||||
|
||||
/* Send v5 notification if the version actually changed */
|
||||
if( !empty( $_SESSION['apps']['core'] ) AND $_SESSION['apps']['core']['current'] !== $_SESSION['apps']['core']['available'] AND !\IPS\IPS::isManaged() )
|
||||
{
|
||||
\IPS\core\AdminNotification::send( 'core', 'VersionFive', NULL, TRUE );
|
||||
}
|
||||
/* Clear any previous editor plugins */
|
||||
Application::resetEditorPlugins();
|
||||
|
||||
unset( $_SESSION['apps'] );
|
||||
|
||||
/* Check for php8 method substitution issues */
|
||||
if ( \IPS\Application\Scanner::scanCustomizationIssues( false, true ) !== null )
|
||||
{
|
||||
$foundIssues = \IPS\Application\Scanner::scanCustomizationIssues()[0];
|
||||
$disabledApps = array();
|
||||
$disabledPlugins = array();
|
||||
foreach ( $foundIssues as $appOrPlugin => $classes )
|
||||
{
|
||||
$components = explode( "-", $appOrPlugin );
|
||||
$isApp = \mb_strtolower( trim( $components[0] ) ) === 'app';
|
||||
$appDir = trim( $components[1] );
|
||||
|
||||
/* Disable the plugin/app and flag for manual intervention */
|
||||
if ( $isApp and ( empty( $disabledApps[$appDir] ) ) )
|
||||
{
|
||||
/* IPS Code is flawless, skip it */
|
||||
if ( \in_array( $appDir, \IPS\IPS::$ipsApps ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$app = \IPS\Application::load( $appDir );
|
||||
$app->_enabled = false;
|
||||
|
||||
if ( ! \IPS\IN_DEV )
|
||||
{
|
||||
$app->requires_manual_intervention = 1;
|
||||
}
|
||||
|
||||
$app->save();
|
||||
$disabledApps[$appDir] = $app->_title;
|
||||
}
|
||||
catch ( \InvalidArgumentException|\OutOfRangeException $e )
|
||||
{
|
||||
/* This still won't work, so don't leave it empty */
|
||||
$disabledApps[$appDir] = $appDir;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
elseif ( empty( $disabledPlugins[$appDir] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$pluginId = \IPS\Db::i()->select( 'plugin_id', 'core_plugins', [ 'plugin_location=?', $appDir ], null, 1 )->first();
|
||||
$plugin = \IPS\Plugin::load( $pluginId );
|
||||
$plugin->_enabled = false;
|
||||
|
||||
if ( ! \IPS\IN_DEV )
|
||||
{
|
||||
$plugin->requires_manual_intervention = 1;
|
||||
}
|
||||
|
||||
$plugin->save();
|
||||
$disabledPlugins[$appDir] = $plugin->name;
|
||||
}
|
||||
catch ( \UnderflowException|\InvalidArgumentException|\OutOfRangeException $e )
|
||||
{
|
||||
/* This still won't work, so don't leave it empty */
|
||||
$disabledPlugins[$appDir] = $appDir;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( \count( $disabledPlugins ) OR \count( $disabledApps ) )
|
||||
{
|
||||
\IPS\core\AdminNotification::send( 'core', 'ManualInterventionMessage' );
|
||||
|
||||
$_SESSION['upgrade_postUpgrade']['core'][] = \IPS\Theme::i()->getTemplate( 'global' )->methodIssues(
|
||||
\IPS\Theme::i()->getTemplate( 'global' )->disabled3rdParty( array_keys( $disabledApps ), array_keys( $disabledPlugins ), false )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* And show the complete page - the template handles this step special already so we don't have to output anything */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('done');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('done');
|
||||
|
||||
/* The upgrader will cause a few syncs on Cloud2, but we don't have to wait for those. Clear the flag here. */
|
||||
unset( \IPS\Data\Store::i()->syncCompleted );
|
||||
unset( Store::i()->syncCompleted );
|
||||
}
|
||||
}
|
||||
@@ -11,16 +11,31 @@
|
||||
namespace IPS\core\modules\setup\upgrade;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Http\Url;
|
||||
use IPS\IPS;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrader: License
|
||||
*/
|
||||
class _license extends \IPS\Dispatcher\Controller
|
||||
class license extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -28,12 +43,12 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
/* Check license key */
|
||||
if( \IPS\Db::i()->checkForTable( 'core_store' ) )
|
||||
if( Db::i()->checkForTable( 'core_store' ) )
|
||||
{
|
||||
$licenseData = \IPS\IPS::licenseKey( TRUE );
|
||||
$licenseData = IPS::licenseKey( TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -41,10 +56,10 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$license = \IPS\Db::i()->select( '*', 'cache_store', array( 'cs_key=?', 'licenseData' ) )->first();
|
||||
$license = Db::i()->select( '*', 'cache_store', array( 'cs_key=?', 'licenseData' ) )->first();
|
||||
$licenseData = unserialize( $license['cs_value'] );
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception $e ){}
|
||||
}
|
||||
|
||||
if( isset( $licenseData['key'] ) AND !isset( $licenseData['expires'] ) )
|
||||
@@ -64,10 +79,9 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
if ( !$active )
|
||||
{
|
||||
$response = NULL;
|
||||
$active = NULL;
|
||||
$form = new \IPS\Helpers\Form( 'licensekey', 'continue' );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ipb_reg_number', NULL, TRUE, array(), function( $val ){
|
||||
\IPS\IPS::checkLicenseKey( $val, \IPS\Settings::i()->base_url );
|
||||
$form = new Form( 'licensekey', 'continue' );
|
||||
$form->add( new Text( 'ipb_reg_number', NULL, TRUE, array(), function( $val ){
|
||||
IPS::checkLicenseKey( $val, Settings::i()->base_url );
|
||||
} ) );
|
||||
|
||||
if( $values = $form->values() )
|
||||
@@ -83,10 +97,10 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Refresh the locally stored license info */
|
||||
if( \IPS\Db::i()->checkForTable( 'core_store' ) )
|
||||
if( Db::i()->checkForTable( 'core_store' ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->license_data );
|
||||
$licenseData = \IPS\IPS::licenseKey();
|
||||
unset( Store::i()->license_data );
|
||||
$licenseData = IPS::licenseKey();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -107,29 +121,29 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
if( $active )
|
||||
{
|
||||
/* Clear any caches or else we might not see new versions on the next screen */
|
||||
if ( isset( \IPS\Data\Store::i()->applications ) )
|
||||
if ( isset( Store::i()->applications ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->applications );
|
||||
unset( Store::i()->applications );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=applications" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
Output::i()->redirect( Url::internal( "controller=applications" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('license');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->license( $form, $active );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('license');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->license( $form, $active );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve license data from license server
|
||||
*
|
||||
* @return mixed
|
||||
* @return array|null
|
||||
*/
|
||||
protected function getLicenseData()
|
||||
protected function getLicenseData() : ?array
|
||||
{
|
||||
/* Call the main server */
|
||||
try
|
||||
{
|
||||
$response = \IPS\Http\Url::ips( 'license/' . \IPS\Settings::i()->ipb_reg_number )->request()->get();
|
||||
$response = Url::ips( 'license/' . Settings::i()->ipb_reg_number )->request()->get();
|
||||
if ( $response->httpResponseCode == 404 )
|
||||
{
|
||||
$licenseData = NULL;
|
||||
@@ -139,7 +153,7 @@ class _license extends \IPS\Dispatcher\Controller
|
||||
$licenseData = $response->decodeJson();
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$licenseData = NULL;
|
||||
}
|
||||
|
||||
@@ -11,27 +11,56 @@
|
||||
namespace IPS\core\modules\setup\upgrade;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\core\Setup\Upgrade;
|
||||
use IPS\Data\Cache;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\IPS;
|
||||
use IPS\Login as LoginClass;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use const IPS\BYPASS_UPGRADER_LOGIN;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrader: Login
|
||||
*/
|
||||
class _login extends \IPS\Dispatcher\Controller
|
||||
class login extends Controller
|
||||
{
|
||||
/**
|
||||
* Anything lower than this will cause the upgrader to disable
|
||||
* non-1st party apps
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected static int $minimumv5 = 5000015;
|
||||
|
||||
/**
|
||||
* Show login form and/or process login form
|
||||
*
|
||||
* @todo [Upgrade] Will also need to account for things in the input (e.g. password) that would be replaced, like & to &
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
/* Clear previous session data */
|
||||
if( !isset( \IPS\Request::i()->sessionCheck ) AND \count( $_SESSION ) )
|
||||
if( !isset( Request::i()->sessionCheck ) AND count( $_SESSION ) )
|
||||
{
|
||||
foreach( $_SESSION as $k => $v )
|
||||
{
|
||||
@@ -40,52 +69,78 @@ class _login extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* 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 ) )
|
||||
if( !isset( 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
|
||||
Output::i()->redirect( 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, '' );
|
||||
Output::i()->error( 'session_check_fail', '5C289/1', 500, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/* Are we automatically logging in? */
|
||||
if ( isset( \IPS\Request::i()->autologin ) and isset( \IPS\Request::i()->cookie['IPSSessionAdmin'] ) )
|
||||
if ( isset( Request::i()->autologin ) and isset( Request::i()->cookie['IPSSessionAdmin'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$session = \IPS\Db::i()->select( '*', 'core_sys_cp_sessions', array( 'session_id=?', \IPS\Request::i()->cookie['IPSSessionAdmin'] ) )->first();
|
||||
$member = $session['session_member_id'] ? \IPS\Member::load( $session['session_member_id'] ) : new \IPS\Member;
|
||||
if ( $member->member_id and $this->_memberHasUpgradePermission( $member ) and ( !\IPS\Settings::i()->match_ipaddress or ( $session['session_ip_address'] === \IPS\Request::i()->ipAddress() ) ) )
|
||||
$session = Db::i()->select( '*', 'core_sys_cp_sessions', array( 'session_id=?', Request::i()->cookie['IPSSessionAdmin'] ) )->first();
|
||||
$member = $session['session_member_id'] ? Member::load( $session['session_member_id'] ) : new Member;
|
||||
if ( $member->member_id and $this->_memberHasUpgradePermission( $member ) and ( !Settings::i()->match_ipaddress or ( $session['session_ip_address'] === Request::i()->ipAddress() ) ) )
|
||||
{
|
||||
$_SESSION['uniqueKey'] = \IPS\Login::generateRandomString();
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=systemcheck" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
$_SESSION['uniqueKey'] = LoginClass::generateRandomString();
|
||||
Output::i()->redirect( Url::internal( "controller=systemcheck" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
}
|
||||
if ( \IPS\BYPASS_UPGRADER_LOGIN )
|
||||
if ( BYPASS_UPGRADER_LOGIN )
|
||||
{
|
||||
$_SESSION['uniqueKey'] = \IPS\Login::generateRandomString();
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=systemcheck" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
$_SESSION['uniqueKey'] = LoginClass::generateRandomString();
|
||||
Output::i()->redirect( Url::internal( "controller=systemcheck" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
}
|
||||
|
||||
/* Drop the data store before we continue */
|
||||
|
||||
/* 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 )
|
||||
$currentBaseVersion = Db::i()->select( 'app_long_version', 'core_applications', [ 'app_directory=?', 'core' ] )->first();
|
||||
|
||||
/* If we are upgrading from a version earlier than v5, disable and lock anything that isn't 1st party */
|
||||
if( $currentBaseVersion < static::$minimumv5 )
|
||||
{
|
||||
$path = \IPS\Application::getRootPath( $app ) . '/applications/' . $app;
|
||||
Db::i()->update( 'core_applications', [ 'app_enabled' => 0, 'app_requires_manual_intervention' => 1 ], Db::i()->in( 'app_directory', IPS::$ipsApps, true ) );
|
||||
Cache::i()->clearAll();
|
||||
Store::i()->clearAll();
|
||||
}
|
||||
|
||||
foreach( Application::getStore() as $data )
|
||||
{
|
||||
$app = $data['app_directory'];
|
||||
|
||||
/* If we are upgrading from a version earlier than v5, only check 1st party apps */
|
||||
if( $currentBaseVersion < static::$minimumv5 and !in_array( $app, IPS::$ipsApps ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Skip anything that is locked */
|
||||
if( $data['app_requires_manual_intervention'] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = Application::getRootPath( $app ) . '/applications/' . $app;
|
||||
|
||||
if ( $app != 'chat' and is_dir( $path . '/data' ) )
|
||||
{
|
||||
$currentVersion = \IPS\Application::load( $app )->long_version;
|
||||
$availableVersion = \IPS\Application::getAvailableVersion( $app );
|
||||
$currentVersion = Application::load( $app )->long_version;
|
||||
$availableVersion = Application::getAvailableVersion( $app );
|
||||
|
||||
if ( empty( $errors ) AND $availableVersion > $currentVersion )
|
||||
{
|
||||
@@ -95,44 +150,44 @@ class _login extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* We need to allow logins if the previous upgrade wasn't finished */
|
||||
if( \IPS\Db::i()->checkForTable( 'upgrade_temp' ) )
|
||||
if( Db::i()->checkForTable( 'upgrade_temp' ) )
|
||||
{
|
||||
$canUpgrade = TRUE;
|
||||
}
|
||||
|
||||
if ( !$canUpgrade )
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms' )->noapps();
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'forms' )->noapps();
|
||||
|
||||
/* We do this just to be 100% certain the flag didn't get "stuck" and needs to be reset. */
|
||||
\IPS\core\Setup\Upgrade::setUpgradingFlag( FALSE );
|
||||
Upgrade::setUpgradingFlag( FALSE );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Nope, show a form */
|
||||
$error = NULL;
|
||||
if ( isset( \IPS\Request::i()->auth ) and isset( \IPS\Request::i()->password ) )
|
||||
if ( isset( Request::i()->auth ) and isset( Request::i()->password ) )
|
||||
{
|
||||
$table = 'core_members';
|
||||
if ( \IPS\Db::i()->checkForTable( 'members' ) AND !\IPS\Db::i()->checkForTable( 'core_members' ) )
|
||||
if ( Db::i()->checkForTable( 'members' ) AND !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 ) )
|
||||
$memberRows = Db::i()->select( '*', $table, array( 'email=? OR email=?', Request::i()->auth, Request::legacyEscape( Request::i()->auth ) ) );
|
||||
if ( count( $memberRows ) )
|
||||
{
|
||||
foreach( $memberRows as $memberRow )
|
||||
{
|
||||
$member = \IPS\Member::constructFromData( $memberRow );
|
||||
$member = Member::constructFromData( $memberRow );
|
||||
|
||||
if ( password_verify( \IPS\Request::i()->password, $member->members_pass_hash ) or $member->verifyLegacyPassword( \IPS\Request::i()->protect('password') ) )
|
||||
if ( password_verify( Request::i()->password, $member->members_pass_hash ) or $member->verifyLegacyPassword( Request::i()->protect('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'] ) );
|
||||
$_SESSION['uniqueKey'] = LoginClass::generateRandomString();
|
||||
IPS::resyncIPSCloud('Beginning upgrade');
|
||||
Output::i()->redirect( Url::internal( "controller=systemcheck" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -153,26 +208,26 @@ class _login extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $error )
|
||||
{
|
||||
$error = \IPS\Member::loggedIn()->language()->addToStack( $error, FALSE, array( 'pluralize' => array( 3 ) ) );
|
||||
$error = Member::loggedIn()->language()->addToStack( $error, FALSE, array( 'pluralize' => array( 3 ) ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('login');
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms' )->login( $error );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('login');
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'forms' )->login( $error );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can member log into upgrader?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @return bool
|
||||
*/
|
||||
protected function _memberHasUpgradePermission( \IPS\Member $member )
|
||||
protected function _memberHasUpgradePermission( Member $member ) : bool
|
||||
{
|
||||
/* 4.x */
|
||||
if ( \IPS\Db::i()->checkForTable( 'core_admin_permission_rows' ) )
|
||||
if ( 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 )
|
||||
if ( Application::load('core')->long_version > 101021 )
|
||||
{
|
||||
return $member->hasAcpRestriction( 'core', 'overview', 'upgrade_manage' );
|
||||
}
|
||||
@@ -188,11 +243,11 @@ class _login extends \IPS\Dispatcher\Controller
|
||||
/* 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();
|
||||
$admin = (bool) Db::i()->select( 'g_access_cp', 'groups', array( 'g_id=?', $member->member_group_id ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
throw new \OutOfRangeException( 'upgrade_group_not_exist' );
|
||||
throw new OutOfRangeException( 'upgrade_group_not_exist' );
|
||||
}
|
||||
|
||||
if( $admin )
|
||||
@@ -208,7 +263,7 @@ class _login extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
$admin = (bool) \IPS\Db::i()->select( 'g_access_cp', 'groups', array( 'g_id=?', $group ) )->first();
|
||||
$admin = (bool) Db::i()->select( 'g_access_cp', 'groups', array( 'g_id=?', $group ) )->first();
|
||||
|
||||
if( $admin )
|
||||
{
|
||||
@@ -216,7 +271,7 @@ class _login extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
/* It is possible the user has an old group that no longer exists defined as a secondary group */
|
||||
catch( \UnderflowException $e ){}
|
||||
catch( UnderflowException $e ){}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,87 +11,116 @@
|
||||
namespace IPS\core\modules\setup\upgrade;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Application;
|
||||
use IPS\core\Setup\Upgrade;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
use const IPS\UPGRADE_MD5_CHECK;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrader: System Check
|
||||
*/
|
||||
class _systemcheck extends \IPS\Dispatcher\Controller
|
||||
class systemcheck extends Controller
|
||||
{
|
||||
/**
|
||||
* Show Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
/* Do we have an older upgrade session hanging around? */
|
||||
if ( ! isset( \IPS\Request::i()->skippreviousupgrade ) AND \IPS\Db::i()->checkForTable( 'upgrade_temp' ) )
|
||||
if ( ! isset( Request::i()->skippreviousupgrade ) AND Db::i()->checkForTable( 'upgrade_temp' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$row = \IPS\Db::i()->select( '*', 'upgrade_temp' )->first();
|
||||
$row = Db::i()->select( '*', 'upgrade_temp' )->first();
|
||||
$json = json_decode( $row['upgrade_data'], TRUE );
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$json = NULL;
|
||||
}
|
||||
|
||||
if ( \is_array( $json ) and isset( $json['session'] ) and isset( $json['data'] ) )
|
||||
if ( is_array( $json ) and isset( $json['session'] ) and isset( $json['data'] ) )
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('unfinished_upgrade');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->unfinishedUpgrade( $json, $row['lastaccess'] );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('unfinished_upgrade');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->unfinishedUpgrade( $json, $row['lastaccess'] );
|
||||
return;
|
||||
}
|
||||
}
|
||||
elseif( isset( \IPS\Request::i()->skippreviousupgrade ) AND \IPS\Request::i()->skippreviousupgrade )
|
||||
elseif( isset( Request::i()->skippreviousupgrade ) AND Request::i()->skippreviousupgrade )
|
||||
{
|
||||
/* If we skip the previous upgrade remove the temp upgrade data now. That way if we hit utf8 upgrader and come back to upgrader we are
|
||||
not prompted again to continue our upgrade we already elected to start over */
|
||||
\IPS\Db::i()->dropTable( 'upgrade_temp', TRUE );
|
||||
Db::i()->dropTable( 'upgrade_temp', TRUE );
|
||||
}
|
||||
|
||||
/* Do we need to disable designer mode? */
|
||||
if ( isset( \IPS\Request::i()->disableDesignersMode ) )
|
||||
if ( isset( Request::i()->disableDesignersMode ) )
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array( 'theme_designers_mode' => 0 ) );
|
||||
Settings::i()->changeValues( array( 'theme_designer_mode' => 0 ) );
|
||||
}
|
||||
|
||||
/* Get requirements */
|
||||
$requirements = \IPS\core\Setup\Upgrade::systemRequirements();
|
||||
$designersModeEnabled = ( \IPS\Application::load('core')->long_version >= 40000 and \IPS\Theme::designersModeEnabled() ) ? TRUE : FALSE;
|
||||
|
||||
$requirements = Upgrade::systemRequirements();
|
||||
|
||||
/* Can we just skip this screen? */
|
||||
$canProceed = FALSE;
|
||||
if ( !$designersModeEnabled )
|
||||
$canProceed = !isset( $requirements['advice'] ) or !count( $requirements['advice'] );
|
||||
if ( $canProceed )
|
||||
{
|
||||
$canProceed = !isset( $requirements['advice'] ) or !\count( $requirements['advice'] );
|
||||
if ( $canProceed )
|
||||
foreach ( $requirements['requirements'] as $k => $_requirements )
|
||||
{
|
||||
foreach ( $requirements['requirements'] as $k => $_requirements )
|
||||
foreach ( $_requirements as $item )
|
||||
{
|
||||
foreach ( $_requirements as $item )
|
||||
if ( !$item['success'] )
|
||||
{
|
||||
if ( !$item['success'] )
|
||||
{
|
||||
$canProceed = FALSE;
|
||||
}
|
||||
$canProceed = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check we have the latest version and run an md5 check */
|
||||
$incorrectFiles = array();
|
||||
if ( UPGRADE_MD5_CHECK )
|
||||
{
|
||||
try
|
||||
{
|
||||
$incorrectFiles = Application::md5Check( Application::getAvailableVersion('core') );
|
||||
if ( count( $incorrectFiles ) )
|
||||
{
|
||||
$canProceed = FALSE;
|
||||
}
|
||||
}
|
||||
catch ( Exception $e ) { }
|
||||
}
|
||||
|
||||
/* Display */
|
||||
if ( $canProceed )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal("controller=license&key={$_SESSION['uniqueKey']}") );
|
||||
Output::i()->redirect( Url::internal("controller=license&key={$_SESSION['uniqueKey']}") );
|
||||
}
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('healthcheck');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->healthcheck( $requirements, $designersModeEnabled );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('healthcheck');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->healthcheck( $requirements, $incorrectFiles );
|
||||
}
|
||||
}
|
||||
@@ -11,73 +11,86 @@
|
||||
namespace IPS\core\modules\setup\upgrade;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use BadMethodCallException;
|
||||
use Exception;
|
||||
use IPS\core\Setup\Upgrade as UpgradeClass;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\MultipleRedirect;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Log;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrader: Perform Upgrade
|
||||
*/
|
||||
class _upgrade extends \IPS\Dispatcher\Controller
|
||||
class upgrade extends Controller
|
||||
{
|
||||
/**
|
||||
* Upgrade
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
$multipleRedirect = new \IPS\Helpers\MultipleRedirect(
|
||||
\IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( 'key', $_SESSION['uniqueKey'] ),
|
||||
$multipleRedirect = new MultipleRedirect(
|
||||
Url::internal( 'controller=upgrade' )->setQueryString( 'key', $_SESSION['uniqueKey'] ),
|
||||
function( $data )
|
||||
{
|
||||
try
|
||||
{
|
||||
$upgrader = new \IPS\core\Setup\Upgrade( array_keys( $_SESSION['apps'] ) );
|
||||
$upgrader = new UpgradeClass( array_keys( $_SESSION['apps'] ) );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'error', '2C222/1', 403, '' );
|
||||
Output::i()->error( 'error', '2C222/1', 403, '' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return $upgrader->process( $data );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( BadMethodCallException $e )
|
||||
{
|
||||
\IPS\Log::log( $e, 'upgrade_error' );
|
||||
/* Allow multi-redirect handle this */
|
||||
throw $e;
|
||||
}
|
||||
catch( Exception $e )
|
||||
{
|
||||
Log::log( $e, 'upgrade_error' );
|
||||
|
||||
/* Error thrown that we want to handle differently */
|
||||
$key = 'mr-' . md5( \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
$key = 'mr-' . md5( Url::internal( 'controller=upgrade' )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
|
||||
|
||||
if ( isset( $_SESSION['updatedData'] ) and isset( $_SESSION['updatedData'][1] ) )
|
||||
{
|
||||
$_SESSION[ $key ] = json_encode( $_SESSION['updatedData'] );
|
||||
}
|
||||
|
||||
$continueUrl = \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr' => 1, 'mr_continue' => 1 ) );
|
||||
$retryUrl = \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr' => 1 ) );
|
||||
$continueUrl = Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr' => 1, 'mr_continue' => 1 ) );
|
||||
$retryUrl = Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr' => 1 ) );
|
||||
|
||||
$error = \IPS\Theme::i()->getTemplate( 'global' )->upgradeError( $e, $continueUrl, $retryUrl );
|
||||
$error = Theme::i()->getTemplate( 'global' )->upgradeError( $e, $continueUrl, $retryUrl );
|
||||
|
||||
return array( \IPS\Theme::i()->getTemplate( 'global' )->block( 'install', $error, FALSE ) );
|
||||
}
|
||||
catch( \BadMethodCallException $e )
|
||||
{
|
||||
/* Allow multi-redirect handle this */
|
||||
throw $e;
|
||||
return array( Theme::i()->getTemplate( 'global' )->block( 'install', $error, FALSE ) );
|
||||
}
|
||||
},
|
||||
function()
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'controller=done' ) );
|
||||
Output::i()->redirect( Url::internal( 'controller=done' ) );
|
||||
}
|
||||
);
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('upgrade');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'upgrade', $multipleRedirect, FALSE );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('upgrade');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'upgrade', $multipleRedirect, FALSE );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user