Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
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() );
}
}