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,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 );
}
}