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

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