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,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 );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user