Version 4.0.13.1

This commit is contained in:
Neo committed 2025-12-19 04:57:54 -08:00
1 parent f9e857d255
commit c6a86f0d9b
7517 files changed
+597400 -668041

No files matched your search

Whitespace-only changes.
@@ -0,0 +1,78 @@
<?php
/**
* @brief Installer: Admin Account
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 2 Apr 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\install;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Installer: Admin Account
*/
class _admin extends \IPS\Dispatcher\Controller
{
/**
* Show Form
*/
public function manage()
{
$form = new \IPS\Helpers\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 ) );
$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 ) );
if ( $values = $form->values() )
{
$INFO = NULL;
require \IPS\ROOT_PATH . '/conf_global.php';
$INFO = array_merge( $INFO, $values );
$toWrite = "<?php\n\n" . '$INFO = ' . var_export( $INFO, TRUE ) . ";";
try
{
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_reset') )
{
/* Avoid throwing an exception Zend OPcache API is restricted by "restrict_api" configuration directive */
@opcache_reset();
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'controller=install' ) );
}
}
catch( \Exception $ex )
{
$errorform = new \IPS\Helpers\Form( 'admin', 'continue' );
$errorform->add( new \IPS\Helpers\Form\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 );
return;
}
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('admin');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'admin', $form );
}
}
@@ -0,0 +1,179 @@
<?php
/**
* @brief Installer: Applications
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 2 Apr 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\install;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Installer: Applications
*/
class _applications extends \IPS\Dispatcher\Controller
{
/**
* Show Form
*
* @return void
*/
public function manage()
{
$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' ) );
}
$form = new \IPS\Helpers\Form( 'applications', 'continue' );
$apps = array();
$defaultTicks = array( 'core' );
foreach( new \DirectoryIterator( \IPS\ROOT_PATH . '/applications' ) as $app )
{
if ( mb_substr( $app, 0, 1 ) !== '.' and $app != 'index.html' )
{
/* Skip incomplete apps */
if ( ! is_dir( $app->getPathName() . '/data' ) )
{
continue;
}
$errors = array();
if ( file_exists( $app->getPathName() . '/setup/requirements.php' ) )
{
require $app->getPathName() . '/setup/requirements.php';
}
if ( empty( $errors ) and (string) $app !== 'core' )
{
$defaultTicks[] = (string) $app;
}
$name = $app;
/* Get app name */
if ( file_exists( $app->getPathName() . '/data/lang.xml' ) )
{
$xml = new \XMLReader;
$xml->open( $app->getPathName() . '/data/lang.xml' );
$xml->read();
$xml->read();
while ( $xml->read() )
{
if ( $xml->getAttribute('key') === '__app_' . $app )
{
$name = $xml->readString();
break;
}
}
}
$apps[ (string) $app ] = array(
'name' => (string) $name,
'disabled' => ( !empty( $errors ) or (string) $app === 'core' ),
'errors' => $errors,
);
}
}
/* Bring core app to top */
$system['core'] = $apps['core'];
unset( $apps['core'] );
$apps = array_merge( $system, $apps );
$form->add( new \IPS\Helpers\Form\Custom( 'apps', $defaultTicks, TRUE, array(
'getHtml' => function( $element ) use ( $apps )
{
return \IPS\Theme::i()->getTemplate( 'forms' )->apps( $apps, $element->value );
},
'validate' => function( $element ) use ( $defaultTicks )
{
if ( !in_array( 'core', $element->value ) )
{
$element->value['core'] = TRUE;
}
$uninstallable = array_diff( array_keys( $element->value ), $defaultTicks );
if ( !empty( $uninstallable ) )
{
throw new \DomainException;
}
}
) ) );
$form->add( new \IPS\Helpers\Form\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 ) );
return \IPS\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 ) )
{
throw new \DomainException('default_app_invalid');
}
}
) ) );
if ( $values = $form->values() )
{
if ( !in_array( $values['default_app'], array_keys( $values['apps'] ) ) )
{
throw new \DomainException('default_app_invalid');
}
$INFO['apps'] = array_keys( $values['apps'] );
$INFO['default_app'] = $values['default_app'];
$toWrite = "<?php\n\n" . '$INFO = ' . var_export( $INFO, TRUE ) . ';';
try
{
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_reset') )
{
/* Avoid throwing an exception Zend OPcache API is restricted by "restrict_api" configuration directive */
@opcache_reset();
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'controller=serverdetails' ) );
}
}
catch( \Exception $ex )
{
$errorform = new \IPS\Helpers\Form( 'applications', 'continue' );
$errorform->add( new \IPS\Helpers\Form\TextArea( 'conf_global_error', $toWrite, FALSE ) );
$errorform->class = 'ipsForm_vertical';
foreach( $values as $k => $v )
{
$errorform->hiddenValues[ $k ] = $v;
}
\IPS\Output::i()->output = \IPS\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 );
}
}
@@ -0,0 +1,75 @@
<?php
/**
* @brief Installer: Finished Screen
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 2 Apr 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\install;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Installer: Finished Screen
*/
class _done extends \IPS\Dispatcher\Controller
{
/**
* Finished
*/
public function manage()
{
/* Reset theme maps to make sure bad data hasn't been cached by visits mid-setup */
foreach( \IPS\Application::applications() as $app => $data )
{
\IPS\Theme::deleteCompiledTemplate( $app);
\IPS\Theme::deleteCompiledCss( $app );
\IPS\Theme::deleteCompiledResources( $app );
}
\IPS\Output::clearJsFiles();
require \IPS\ROOT_PATH . '/conf_global.php';
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => $INFO['lkey'] ), array( 'conf_key=?', 'ipb_reg_number' ) );
\IPS\Settings::i()->ipb_reg_number = $INFO['lkey'];
unset( \IPS\Data\Store::i()->settings );
\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'],
'sql_pass' => $INFO['sql_pass'],
'sql_port' => $INFO['sql_port'],
'sql_socket' => $INFO['sql_socket'],
'sql_tbl_prefix' => $INFO['sql_tbl_prefix'],
'sql_utf8mb4' => $INFO['sql_utf8mb4'],
'board_start' => time(),
'installed' => TRUE,
'base_url' => $INFO['base_url'],
'guest_group' => 2,
'member_group' => 3,
'admin_group' => 4
), TRUE ) . ';' );
/* PHP 5.6 - clear opcode cache or details won't be seen on next page load */
if( function_exists('opcache_reset') )
{
/* Avoid throwing an exception Zend OPcache API is restricted by "restrict_api" configuration directive */
@opcache_reset();
}
\IPS\Settings::i()->base_url = $INFO['base_url'];
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('done');
}
}
Whitespace-only changes.
@@ -0,0 +1,103 @@
<?php
/**
* @brief Installer: Install
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 2 Apr 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\install;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Installer: Install
*/
class _install extends \IPS\Dispatcher\Controller
{
/**
* Install
*/
public function manage()
{
require \IPS\ROOT_PATH . '/conf_global.php';
/* Zend Server has an issue where it caches 'require'd files which means the admin details written in the
previous step aren't in the $INFO array which causes the MultiRedirect to fail. Making the page reload after
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();
return;
}
$multipleRedirect = new \IPS\Helpers\MultipleRedirect(
\IPS\Http\Url::internal( 'controller=install' ),
function( $data )
{
try
{
require \IPS\ROOT_PATH . '/conf_global.php';
$install = new \IPS\core\Setup\Install(
$INFO['apps'],
$INFO['default_app'],
$INFO['base_url'],
mb_substr( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), 0, -mb_strlen( 'install/index.php' ) ),
array( 'sql_host' => $INFO['sql_host'], 'sql_user' => $INFO['sql_user'], 'sql_pass' => $INFO['sql_pass'], 'sql_database' => $INFO['sql_database'], 'sql_port' => $INFO['sql_port'], 'sql_socket' => $INFO['sql_socket'], 'sql_tbl_prefix' => $INFO['sql_tbl_prefix'] ),
$INFO['admin_user'],
$INFO['admin_pass1'],
$INFO['admin_email'],
$INFO['lkey']
);
}
catch ( \InvalidArgumentException $e )
{
\IPS\Output::i()->error( 'error', '4S112/1', 403, '' );
}
try
{
return $install->process( $data );
}
catch( \Exception $e )
{
ob_start();
$backtrace = print_r( debug_backtrace( 0 ), TRUE );
$error = \IPS\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 );
/* If we're still here - output */
if ( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( \IPS\Output::i()->output, 200, 'text/html', \IPS\Output::i()->httpHeaders );
}
else
{
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->globalTemplate( \IPS\Output::i()->title, \IPS\Output::i()->output ), 403, 'text/html', \IPS\Output::i()->httpHeaders );
}
}
},
function()
{
\IPS\Output::i()->redirect( \IPS\Http\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 );
}
}
@@ -0,0 +1,96 @@
<?php
/**
* @brief Installer: License
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 2 Apr 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\install;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Installer: License
*/
class _license extends \IPS\Dispatcher\Controller
{
/**
* Show Form
*
* @return void
*/
public function manage()
{
$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 )
{
\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">' . \IPS\Member::loggedIn()->language()->addToStack('lkey_help') . '</a>' ) );
$form->add( new \IPS\Helpers\Form\Checkbox( 'eula', FALSE, TRUE, array( 'label' => 'eula_suffix' ), function( $val )
{
if ( !$val )
{
throw new \InvalidArgumentException('eula_err');
}
}, "<textarea disabled style='width: 100%; height: 250px'>" . file_get_contents( 'eula.txt' ) . "</textarea><br>" ) );
if ( $values = $form->values() )
{
$values['lkey'] = trim( $values['lkey'] );
if ( mb_substr( $values['lkey'], -12 ) === '-TESTINSTALL' )
{
$values['lkey'] = mb_substr( $values['lkey'], 0, -12 );
}
$toWrite = "<?php\n\n" . '$INFO = ' . var_export( array( 'lkey' => $values['lkey'] ), TRUE ) . ';';
try
{
$file = @\file_put_contents( \IPS\ROOT_PATH . '/conf_global.php', $toWrite );
if ( !$file )
{
throw new \Exception;
}
else
{
/* PHP 5.6 - clear opcode cache or details won't be seen on next page load */
if( function_exists('opcache_reset') )
{
/* Avoid throwing an exception Zend OPcache API is restricted by "restrict_api" configuration directive */
@opcache_reset();
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'controller=applications' ) );
}
}
catch( \Exception $ex )
{
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'error' );
$errorform = new \IPS\Helpers\Form( 'license', 'continue' );
$errorform->class = '';
$errorform->add( new \IPS\Helpers\Form\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 );
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 );
}
}
@@ -0,0 +1,145 @@
<?php
/**
* @brief Installer: Server Details
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 2 Apr 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\install;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Installer: Server Details
*/
class _serverdetails extends \IPS\Dispatcher\Controller
{
/**
* Show Form
*
* @return void
*/
public function manage()
{
$form = new \IPS\Helpers\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 ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'sql_utf8mb4', TRUE, FALSE ) );
$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 ) ) );
if ( $values = $form->values() )
{
try
{
try
{
$db = \IPS\Db::i( 'test', $values );
}
catch( \IPS\Db\Exception $e )
{
/* Can't connect. Maybe db doesn't exist, let's create it if allowed */
if( $e->getCode() == 1049 )
{
try
{
$dbName = $values['sql_database'];
unset( $values['sql_database'] );
$db = \IPS\Db::i( 'create', $values )->createDatabase( $dbName );
$values['sql_database'] = $dbName;
$db = \IPS\Db::i( 'created', $values );
}
catch( \Exception $e )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack('err_db_cant_create') );
}
}
else
{
throw new \DomainException( $e->getMessage() );
}
}
try
{
if ( $db->checkForTable( 'core_sys_conf_settings') )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack('err_db_exists') );
}
}
catch ( \UnderflowException $e ) { }
if ( $values['sql_utf8mb4'] and version_compare( $db->server_info, '5.5.3', '<' ) )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack('err_no_utf8mb4') );
}
$INFO = NULL;
require \IPS\ROOT_PATH . '/conf_global.php';
$INFO = array_merge( $INFO, $values );
$toWrite = "<?php\n\n" . '$INFO = ' . var_export( $INFO, TRUE ) . ';';
try
{
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_reset') )
{
/* Avoid throwing an exception Zend OPcache API is restricted by "restrict_api" configuration directive */
@opcache_reset();
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'controller=admin' ) );
}
}
catch( \Exception $ex )
{
$errorform = new \IPS\Helpers\Form( 'serverdetails', 'continue' );
$errorform->add( new \IPS\Helpers\Form\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 );
return;
}
}
catch ( \Exception $e )
{
if( $e->getMessage() == 'mysqli::set_charset(): Error executing query' )
{
$form->error = \IPS\Member::loggedIn()->language()->addToStack('err_no_utf8mb4');
}
else
{
$form->error = $e->getMessage();
}
}
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('serverdetails');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'serverdetails', $form );
}
}
@@ -0,0 +1,36 @@
<?php
/**
* @brief Installer: System Check
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 10 Dec 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\install;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Installer: System Check
*/
class _systemcheck extends \IPS\Dispatcher\Controller
{
/**
* Show Form
*
* @return void
*/
public function manage()
{
\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() );
}
}
@@ -0,0 +1,245 @@
<?php
/**
* @brief Upgrader: Applications
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 20 May 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\upgrade;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Upgrader: Applications
*/
class _applications extends \IPS\Dispatcher\Controller
{
/**
* Show Form
*
* @todo [Upgrade] This may not accurately detect older versions - need to test and adjust
* @return void
*/
public function manage()
{
$apps = array();
$defaultTicks = 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' ) )
{
\IPS\Db::i()->update( 'core_applications', array( 'app_version' => '4.0.0 Beta 1', 'app_long_version' => '100001' ) );
}
/* Clear any caches or else we might not see new versions */
if ( isset( \IPS\Data\Store::i()->applications ) )
{
unset( \IPS\Data\Store::i()->applications );
}
if ( isset( \IPS\Data\Store::i()->modules ) )
{
unset( \IPS\Data\Store::i()->modules );
}
$haltUpgrade = FALSE;
foreach( \IPS\Application::applications() as $app => $data )
{
$path = \IPS\ROOT_PATH . '/applications/' . $app;
/* Skip incomplete apps */
if ( ! is_dir( $path . '/data' ) )
{
continue;
}
/* See if there are any errors */
$errors = array();
if ( file_exists( $path . '/setup/requirements.php' ) )
{
require $path . '/setup/requirements.php';
}
/* Figure out of an upgrade is even available */
$currentVersion = \IPS\Application::load( $app )->long_version;
$availableVersion = \IPS\Application::getAvailableVersion( $app );
if ( empty( $errors ) AND $availableVersion > $currentVersion )
{
$defaultTicks[] = $app;
}
$name = $data->_title;
/* Get app name */
if ( file_exists( $path . '/data/lang.xml' ) )
{
$xml = new \XMLReader;
$xml->open( $path . '/data/lang.xml' );
$xml->read();
$xml->read();
while ( $xml->read() )
{
if ( $xml->getAttribute('key') === '__app_' . $app )
{
$name = $xml->readString();
break;
}
}
}
if( count( $errors ) )
{
$haltUpgrade = TRUE;
}
$apps[ $app ] = array(
'name' => $name,
'disabled' => ( !empty( $errors ) OR $availableVersion <= $currentVersion ),
'errors' => $errors,
'current' => \IPS\Application::load( $app )->version,
'available' => \IPS\Application::getAvailableVersion( $app, TRUE ),
'force' => ( $app === 'core' and $availableVersion > $currentVersion )
);
}
/* Bring core app to top */
$system['core'] = $apps['core'];
unset( $apps['core'] );
$apps = array_merge( $system, $apps );
if( count( $defaultTicks ) )
{
$form = new \IPS\Helpers\Form( 'applications', 'continue' );
$form->add( new \IPS\Helpers\Form\Custom( 'apps', $defaultTicks, TRUE, array(
'getHtml' => function( $element ) use ( $apps )
{
return \IPS\Theme::i()->getTemplate( 'forms' )->apps( $apps, $element->value );
},
'validate' => function( $element ) use ( $defaultTicks )
{
$uninstallable = array_diff( array_keys( $element->value ), $defaultTicks );
if ( !empty( $uninstallable ) )
{
throw new \DomainException;
}
}
) ) );
if ( $values = $form->values() )
{
$_SESSION['apps'] = array();
if ( $apps['core']['force'] )
{
$_SESSION['apps']['core'] = 'core';
}
if( count( $values['apps'] ) )
{
foreach ( $values['apps'] as $k => $v )
{
if ( !is_int( $k ) )
{
$_SESSION['apps'][$k] = $k;
}
}
}
$warnings = array();
$coreVersion = array_key_exists( 'core', $_SESSION['apps'] ) ? \IPS\Application::getAvailableVersion( 'core' ) : \IPS\Application::load( 'core' )->long_version;
foreach ( \IPS\Application::$ipsApps as $key )
{
try
{
$appVersion = array_key_exists( $key, $_SESSION['apps'] ) ? \IPS\Application::getAvailableVersion( $key ) : \IPS\Application::load( $key )->long_version;
if ( $appVersion != $coreVersion )
{
$warnings[] = $key;
}
}
catch( \OutOfRangeException $e )
{
/* The application is not installed */
continue;
}
}
if ( count( $warnings ) )
{
\IPS\Output::i()->redirect( \IPS\Http\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'] ) );
}
if( $haltUpgrade )
{
$form->actionButtons = array( \IPS\Theme::i()->getTemplate( 'forms', 'core', 'global' )->button( "continue", 'submit', null, 'ipsButton ipsButton_disabled', array( 'disabled' => 'disabled' ) ) );
}
}
else
{
$form = \IPS\Theme::i()->getTemplate( 'forms' )->noapps();
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('applications');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'applications', $form );
}
/**
* Show Warning
*
* @return void
*/
public function warning()
{
$apps = array();
foreach ( explode( ',', \IPS\Request::i()->warnings ) as $key )
{
try
{
$name = \IPS\Application::load( $key )->_title;
$path = \IPS\ROOT_PATH . '/applications/' . $key;
if ( file_exists( $path . '/data/lang.xml' ) )
{
$xml = new \XMLReader;
$xml->open( $path . '/data/lang.xml' );
$xml->read();
$xml->read();
while ( $xml->read() )
{
if ( $xml->getAttribute('key') === '__app_' . $key )
{
$name = $xml->readString();
break;
}
}
}
$apps[] = $name;
}
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 ) );
}
}
@@ -0,0 +1,41 @@
<?php
/**
* @brief Upgrader: Confirm
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 20 May 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\upgrade;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Upgrader: Confirm
*/
class _confirm extends \IPS\Dispatcher\Controller
{
/**
* Show Form
*
* @return void
*/
public function manage()
{
/* reset a few things */
$_SESSION['lastJsonIndex'] = 0;
$_SESSION['lastSqlError'] = NULL;
$_SESSION['sqlFinished'] = array();
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('confirmpage');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->confirm();
}
}
@@ -0,0 +1,57 @@
<?php
/**
* @brief Upgrader: Continue Upgrade
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 4 Nov 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\upgrade;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Upgrader: Continue Upgrade
*/
class _continueupgrade extends \IPS\Dispatcher\Controller
{
/**
* Show Form
*
* @return void
*/
public function manage()
{
/* Best check for the upgrade file first */
$json = json_decode( @file_get_contents( \IPS\ROOT_PATH . '/uploads/logs/upgrader_data.cgi' ), TRUE );
if ( is_array( $json ) and isset( $json['session'] ) and isset( $json['data'] ) )
{
$url = \IPS\Http\Url::internal( "controller=upgrade" )->setQueryString( 'key', $_SESSION['uniqueKey'] );
$mr = array();
/* Update session */
foreach( $json['session'] as $k => $v )
{
if ( $k !== 'uniqueKey' )
{
$_SESSION[ $k ] = $v;
}
}
\IPS\Output::i()->redirect( $url->setQueryString( 'mr', base64_encode( urlencode( json_encode( $json['data'] ) ) ) )->setQueryString( 'mr_continue', 1 ) );
}
else
{
\IPS\Output::i()->error( 'cannot_continue_upgrade', '', 403, '' );
}
}
}
@@ -0,0 +1,115 @@
<?php
/**
* @brief Upgrader: Custom Upgrade Options
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 20 May 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\upgrade;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Upgrader: Custom Upgrade Options
*/
class _customoptions extends \IPS\Dispatcher\Controller
{
/**
* Show Form
*
* @return void
*/
public function manage()
{
$elements = array();
/* We need to store option_name => app reference for use later, otherwise all options get stored for the last app in the list. */
$appOptions = array();
/* Loop through all applications we are upgrading and all versions for those applications and see if any custom options are available.
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 );
$steps = $application->getUpgradeSteps( $application->long_version );
foreach( $steps as $step )
{
if( file_exists( \IPS\ROOT_PATH . "/applications/{$app}/setup/upg_{$step}/checks.php" ) )
{
$output = NULL;
require_once( \IPS\ROOT_PATH . "/applications/{$app}/setup/upg_{$step}/checks.php" );
if( $output !== NULL )
{
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('admin');
\IPS\Output::i()->output = $output;
return;
}
}
if( file_exists( \IPS\ROOT_PATH . "/applications/{$app}/setup/upg_{$step}/options.php" ) )
{
require_once( \IPS\ROOT_PATH . "/applications/{$app}/setup/upg_{$step}/options.php" );
$elements = array_merge( $elements, $options );
foreach( $options AS $option )
{
$appOptions[$option->name] = $app;
}
}
}
}
/* Do we need to disable any apps? */
if( isset( \IPS\Request::i()->disable ) )
{
foreach( explode( ',', \IPS\Request::i()->disable ) as $app )
{
\IPS\Db::i()->update( 'core_applications', array( 'app_enabled' => 0 ), array( 'app_directory=?', $app ) );
}
}
/* If there are no options, no need to show an empty/blank form */
if( !count( $elements ) )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=confirm" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
}
/* Otherwise, show the form */
$form = new \IPS\Helpers\Form( 'options', 'continue' );
foreach( $elements as $element )
{
$form->add( $element );
}
if( $values = $form->values() )
{
foreach( $values as $key => $value )
{
$app = $appOptions[$key];
if ( preg_match( '#^(\d{5,6})_#', $key ) )
{
$version = mb_substr( $key, 0, mb_strpos( $key, '_' ) );
$key = mb_substr( $key, mb_strpos( $key, '_' ) + 1 );
}
$_SESSION['upgrade_options'][ $app ][ $version ][ $key ] = $value;
}
\IPS\Output::i()->redirect( \IPS\Http\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 );
}
}
@@ -0,0 +1,66 @@
<?php
/**
* @brief Upgrader: Finished Screen
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 20 May 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\upgrade;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Upgrader: Finished Screen
*/
class _done extends \IPS\Dispatcher\Controller
{
/**
* Finished
*
* @return void
*/
public function manage()
{
\IPS\Output::clearJsFiles();
if ( file_exists( \IPS\ROOT_PATH . '/uploads/logs/upgrader_data.cgi' ) )
{
@unlink( \IPS\ROOT_PATH . '/uploads/logs/upgrader_data.cgi' );
}
/* Reset theme maps to make sure bad data hasn't been cached by visits mid-setup */
foreach( \IPS\Theme::themes() as $id => $set )
{
/* Update mappings */
$set->css_map = array();
$set->save();
}
/* Delete some variables we stored in our session */
unset( $_SESSION['apps'] );
if( isset( $_SESSION['upgrade_options'] ) )
{
unset( $_SESSION['upgrade_options'] );
}
if( isset( $_SESSION['sqlFinished'] ) )
{
unset( $_SESSION['sqlFinished'] );
}
unset( $_SESSION['key'] );
/* 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');
}
}
Whitespace-only changes.
@@ -0,0 +1,138 @@
<?php
/**
* @brief Upgrader: License
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 25 Sep 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\upgrade;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Upgrader: License
*/
class _license extends \IPS\Dispatcher\Controller
{
/**
* Show Form
*
* @return void
*/
public function manage()
{
/* Check license key */
if( \IPS\Db::i()->checkForTable( 'core_store' ) )
{
$licenseData = \IPS\IPS::licenseKey();
}
else
{
$licenseData = NULL;
try
{
$license = \IPS\Db::i()->select( '*', 'cache_store', array( 'cs_key=?', 'licenseData' ) )->first();
$licenseData = unserialize( $license['cs_value'] );
}
catch( \Exception $e ){}
}
if( isset( $licenseData['key'] ) AND !isset( $licenseData['expires'] ) )
{
$licenseData = $this->getLicenseData();
}
if ( !$licenseData or !isset( $licenseData['expires'] ) )
{
$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 );
} ) );
if( $values = $form->values() )
{
$values['ipb_reg_number'] = trim( $values['ipb_reg_number'] );
if ( mb_substr( $values['ipb_reg_number'], -12 ) === '-TESTINSTALL' )
{
$values['ipb_reg_number'] = mb_substr( $values['ipb_reg_number'], 0, -12 );
}
/* Save */
$form->saveAsSettings( $values );
/* Refresh the locally stored license info */
if( \IPS\Db::i()->checkForTable( 'core_store' ) )
{
unset( \IPS\Data\Store::i()->license_data );
$licenseData = \IPS\IPS::licenseKey();
}
else
{
/* Call the main server */
$licenseData = $this->getLicenseData();
}
/* Reset some vars now */
$form = NULL;
$active = isset( $licenseData['expires'] ) ? strtotime( $licenseData['expires'] ) > time() : NULL;
}
}
else
{
$active = isset( $licenseData['expires'] ) ? strtotime( $licenseData['expires'] ) > time() : NULL;
}
if( $active )
{
\IPS\Output::i()->redirect( \IPS\Http\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 );
}
/**
* Retrieve license data from license server
*
* @return mixed
*/
protected function getLicenseData()
{
/* Call the main server */
try
{
$response = \IPS\Http\Url::ips( 'license/' . \IPS\Settings::i()->ipb_reg_number )->request()->get();
if ( $response->httpResponseCode == 404 )
{
$licenseData = NULL;
}
else
{
$licenseData = $response->decodeJson();
}
\IPS\Db::i()->replace( 'cache_store', array( 'cs_key' => 'licenseData', 'cs_array' => 1, 'cs_value' => serialize( $licenseData ) ) );
}
catch ( \Exception $e )
{
$licenseData = NULL;
}
return $licenseData;
}
}
@@ -0,0 +1,104 @@
<?php
/**
* @brief Upgrader: Login
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 20 May 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\upgrade;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Upgrader: Login
*/
class _login extends \IPS\Dispatcher\Controller
{
/**
* 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 &amp;
* @return void
*/
public function manage()
{
/* Clear previous session data */
if( count( $_SESSION ) )
{
foreach( $_SESSION as $k => $v )
{
unset( $_SESSION[ $k ] );
}
}
$login = new \IPS\Login( \IPS\Http\Url::internal( "controller=login&start=1", NULL, NULL, NULL, \IPS\Settings::i()->logins_over_https ) );
$login->flagOptions = FALSE;
/* < 4.0.0 */
$legacy = FALSE;
if( \IPS\Db::i()->checkForTable( 'login_methods' ) )
{
$legacy = TRUE;
}
/* Restoring a part finished upgrade means no log in hander rows even though table has been renamed */
if ( \IPS\Db::i()->checkForTable( 'core_login_handlers' ) )
{
$legacy = FALSE;
if ( ! \IPS\Db::i()->select( 'COUNT(*)', 'core_login_handlers' )->first() )
{
$legacy = TRUE;
}
}
if ( $legacy === TRUE )
{
/* Force internal only as we don't have the framework installed (JS/templates, etc) at this point to run external log in modules */
\IPS\Login\LoginAbstract::$databaseTable = 'login_methods';
$login::$allHandlers['internal'] = \IPS\Login\LoginAbstract::constructFromData( array (
'login_key' => 'Upgrade',
'login_enabled' => 1,
'login_settings' => '{"auth_types":"3"}',
'login_order' => 1,
'login_acp' => 1
) );
$login::$handlers = $login::$allHandlers;
}
$handlers = \IPS\Login::handlers();
/* Process */
$error = NULL;
try
{
$member = $login->authenticate();
if ( $member !== NULL )
{
/* Create a unique session key and redirect */
$_SESSION['uniqueKey'] = md5( uniqid( microtime(), TRUE ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "controller=systemcheck" )->setQueryString( 'key', $_SESSION['uniqueKey'] ) );
}
}
catch ( \Exception $e )
{
$error = $e->getMessage();
}
/* Output */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('login');
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms' )->login( $login->forms( TRUE ), $error );
}
}
@@ -0,0 +1,57 @@
<?php
/**
* @brief Upgrader: System Check
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 20 May 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\upgrade;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Upgrader: System Check
*/
class _systemcheck extends \IPS\Dispatcher\Controller
{
/**
* Show Form
*
* @return void
*/
public function manage()
{
/* Do we have an older upgrade session hanging around? */
if ( ! isset( \IPS\Request::i()->skippreviousupgrade ) AND file_exists( \IPS\ROOT_PATH . '/uploads/logs/upgrader_data.cgi' ) )
{
$json = json_decode( @file_get_contents( \IPS\ROOT_PATH . '/uploads/logs/upgrader_data.cgi' ), TRUE );
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, \IPS\DateTime::ts( @filemtime( \IPS\ROOT_PATH . '/uploads/logs/upgrader_data.cgi' ) ) );
return;
}
}
/* Do we need to disable designer mode? */
if ( isset( \IPS\Request::i()->disableDesignersMode ) )
{
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => 0 ), array( 'conf_key=?', 'theme_designers_mode' ) );
unset( \IPS\Data\Store::i()->settings );
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('healthcheck');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->healthcheck( \IPS\core\Setup\Upgrade::systemRequirements(), ( \IPS\Application::load('core')->long_version >= 40000 and \IPS\Theme::designersModeEnabled() ) ? TRUE : FALSE );
}
}
@@ -0,0 +1,114 @@
<?php
/**
* @brief Upgrader: Perform Upgrade
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 20 May 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\setup\upgrade;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Upgrader: Perform Upgrade
*/
class _upgrade extends \IPS\Dispatcher\Controller
{
/**
* Upgrade
*
* @return void
*/
public function manage()
{
$multipleRedirect = new \IPS\Helpers\MultipleRedirect(
\IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( 'key', $_SESSION['uniqueKey'] ),
function( $data )
{
try
{
$upgrader = new \IPS\core\Setup\Upgrade( array_keys( $_SESSION['apps'] ) );
}
catch ( \Exception $e )
{
\IPS\Output::i()->error( 'error', '2C222/1', 403, '' );
}
try
{
return $upgrader->process( $data );
}
catch( \Exception $e )
{
try
{
\IPS\Log::i( LOG_ERR )->write( "Error : " . $e->getMessage() . "\n" . $e->getTraceAsString(), 'upgrade_error' );
}
catch( \RuntimeException $ex ){}
/* Error thrown that we want to handle differently */
$mrData = json_decode( urldecode( base64_decode( \IPS\Request::i()->mr ) ), true );
if ( isset( $_SESSION['updatedData'] ) and isset( $_SESSION['updatedData'][1] ) )
{
$mrData = $_SESSION['updatedData'];
}
$continueData = $mrData;
$retryData = $mrData;
if ( isset( $mrData['extra'] ) or isset( $_SESSION['lastJsonIndex'] ) )
{
$continueData['extra']['lastSqlId'] = ( isset($_SESSION['lastJsonIndex']) ? ( $_SESSION['lastJsonIndex'] + 1 ) : 0 );
$retryData['extra']['lastSqlId'] = ( ( isset($_SESSION['lastJsonIndex']) and $_SESSION['lastJsonIndex'] > 1 ) ? $_SESSION['lastJsonIndex'] - 1 : 0 );
}
if ( isset( $mrData['extra']['_upgradeStep'] ) )
{
$continueData['extra']['_upgradeStep'] += 1;
$continueData['extra']['_upgradeData'] = 0;
}
$continueUrl = \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr' => base64_encode( urlencode( json_encode( $continueData ) ) ), 'mr_continue' => 1 ) );
$retryUrl = \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr' => base64_encode( urlencode( json_encode( $retryData ) ) ), 'mr_continue' => 1 ) );
$error = \IPS\Theme::i()->getTemplate( 'global' )->upgradeError( $e, $continueUrl, $retryUrl );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('error');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'install', $error, FALSE );
/* If we're still here - output */
if ( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->blankTemplate( \IPS\Output::i()->output ), 200, 'text/html', \IPS\Output::i()->httpHeaders );
}
else
{
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->globalTemplate( \IPS\Output::i()->title, \IPS\Output::i()->output ), 200, 'text/html', \IPS\Output::i()->httpHeaders );
}
}
catch( \BadMethodCallException $e )
{
/* Allow multi-redirect handle this */
throw $e;
}
},
function()
{
\IPS\Output::i()->redirect( \IPS\Http\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 );
}
}