Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Upgrader: Custom Upgrade Options
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 3 Aug 2017
|
||||
*/
|
||||
|
||||
$options = array();
|
||||
|
||||
/* Usage reporting */
|
||||
$options[] = new \IPS\Helpers\Form\YesNo( '103000_usage_reporting', TRUE );
|
||||
|
||||
/* Is IPS Connect enabled? */
|
||||
$ipsConnectEnabled = FALSE;
|
||||
try
|
||||
{
|
||||
$ipsConnectEnabled = (bool) \IPS\Db::i()->select( 'COUNT(*)', 'core_login_handlers', array( 'login_key=? AND login_enabled=1', 'Ipsconnect' ) )->first();
|
||||
}
|
||||
catch ( \IPS\Db\Exception $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
$ipsConnectEnabled = (bool) \IPS\Db::i()->select( 'COUNT(*)', 'login_methods', array( 'login_folder_name=? AND login_enabled=1', 'ipsconnect' ) )->first();
|
||||
}
|
||||
catch ( \IPS\Db\Exception $e ) { }
|
||||
}
|
||||
if( $ipsConnectEnabled )
|
||||
{
|
||||
$options[] = new \IPS\Helpers\Form\Custom( 'ipsconnect', null, FALSE, array( 'getHtml' => function( $element ) use ( $members ){
|
||||
$url = \IPS\Http\Url::ips('docs/login_invision');
|
||||
return "<br>IPS Connect has been replaced with a new OAuth-based system for connecting two or more communities.<br><br><strong>If you have already upgraded the master install in your IPS Connect network</strong> follow the <a href='{$url}' target='_blank'>Connect Two Invision Communities</a> guide to get the Client Identifier and Client Secret and enter them below.<br><strong>If you have not yet upgraded the master install in your IPS Connect network or do not want to enter these details yet</strong> you can leave the settings below blank, but make sure you have bookmarked the <a href='{$url}' target='_blank'>Connect Two Invision Communities</a> guide to refer to after you have finished the upgrade.<br><br><strong class='ipsType_warning'><i class='fa fa-exclamation-triangle'></i> If you do not provide these details now you will not be able to log in using IPS Connect once the upgrade is complete. If you find yourself unable to log in after the upgrade, use the Forgot Password tool to regain access to your account.</strong>";
|
||||
} ), function( $val ) {}, NULL, NULL, 'ipsconnect' );
|
||||
|
||||
$row = \IPS\Db::i()->select( '*', 'core_login_handlers', array( 'login_key=? AND login_enabled=1', 'Ipsconnect' ) )->first();
|
||||
$settings = json_decode( $row['login_settings'], TRUE );
|
||||
|
||||
$options[] = new \IPS\Helpers\Form\Text( '103000_ipsconnect_url', preg_replace( '/applications\/core\/interface\/ipsconnect\/ipsconnect\.php$/', '', $settings['url'] ) );
|
||||
$options[] = new \IPS\Helpers\Form\Text( '103000_ipsconnect_client_id' );
|
||||
$options[] = new \IPS\Helpers\Form\Text( '103000_ipsconnect_client_secret' );
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Login over HTTPs */
|
||||
if( \IPS\Settings::i()->logins_over_https OR ( \IPS\Settings::i()->nexus_https AND \IPS\Application::appIsEnabled( 'nexus' ) ) )
|
||||
{
|
||||
$setting = array();
|
||||
|
||||
if( \IPS\Settings::i()->logins_over_https )
|
||||
{
|
||||
$setting[] = '"Use https for logins and the AdminCP?"';
|
||||
}
|
||||
|
||||
if( \IPS\Application::appIsEnabled( 'nexus' ) AND \IPS\Settings::i()->nexus_https )
|
||||
{
|
||||
$setting[] = '"Use a secure connection for checkout?"';
|
||||
}
|
||||
|
||||
$options[] = new \IPS\Helpers\Form\Custom( 'https_settings_changes', null, FALSE, array( 'getHtml' => function( ) use ( $setting ){
|
||||
$url = \IPS\Http\Url::ips('docs/https');
|
||||
$settingString = implode( ' and ', $setting );
|
||||
$pluralS = count( $setting ) > 1 ? 's' : '';
|
||||
$pluralThis = count( $setting ) > 1 ? 'these' : 'this';
|
||||
$pluralIs = count( $setting ) > 1 ? 'are' : 'is';
|
||||
return "You currently have the {$settingString} setting{$pluralS} enabled. Due to recent changes to some browsers, {$pluralThis} feature{$pluralS} can cause browser warnings and so {$pluralIs} no longer supported in Invision Community. To keep the security benefits, we recommend moving your entire community to using https after this upgrade is complete. <a href='{$url}' rel='external' target='_blank'>Learn how</a>";
|
||||
} ), function( $val ) {}, NULL, NULL, 'https_settings_changes' );
|
||||
}
|
||||
|
||||
/* Is the link to the admin directory hidden? */
|
||||
if( \IPS\Settings::i()->security_remove_acp_link )
|
||||
{
|
||||
$options[] = new \IPS\Helpers\Form\Custom( 'admincp_hide_deprecate', null, FALSE, array( 'getHtml' => function( $element ) use ( $members ){
|
||||
$url = \IPS\Http\Url::ips('docs/hide_acp');
|
||||
return "<br>The setting to hide the link to the AdminCP has been removed. After completing the upgrade, follow the <a href='{$url}' target='_blank'>Hiding the AdminCP</a> guide to retain this functionality.<br><br><strong class='ipsType_warning'><i class='fa fa-exclamation-triangle'></i> Before continuing, ensure you have bookmarked this guide to refer to after you have finished the upgrade.</strong>";
|
||||
} ), function( $val ) {}, NULL, NULL, 'admincp_hide_deprecate' );
|
||||
}
|
||||
|
||||
/* reCAPTCHA v1 Removed */
|
||||
if( \IPS\Settings::i()->bot_antispam_type === 'recaptcha' )
|
||||
{
|
||||
|
||||
$options[] = new \IPS\Helpers\Form\Custom( 'recaptcha_v1_removed', null, FALSE, array( 'getHtml' => function( $element ) use ( $members ){
|
||||
$url = \IPS\Http\Url::ips('docs/captcha_recaptcha_invisible');
|
||||
return "<br>Your community was set to use reCAPTCHA 1, a CAPTCHA method where the user is shown two distorted words and must type the displayed words. Google recently retired this service so we are automatically upgrading you to the latest <a href='{$url}' target='_blank'>Invisible reCAPTCHA</a> method. This doesn't require user input as the system intelligently detects if the user is human in the background.";
|
||||
} ), function( $val ) {}, NULL, NULL, 'recaptcha_v1_removed' );
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,641 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief 4.3.0 Beta 1 Upgrade Code
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 19 Oct 2017
|
||||
*/
|
||||
|
||||
namespace IPS\core\setup\upg_103000;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 4.3.0 Beta 1 Upgrade Code
|
||||
*/
|
||||
class _Upgrade
|
||||
{
|
||||
/**
|
||||
* Step 1
|
||||
* Move login handlers
|
||||
*
|
||||
* @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
|
||||
*/
|
||||
public function step1()
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_login_handlers' ) as $row )
|
||||
{
|
||||
$settings = ( isset( $row['login_settings'] ) and $row['login_settings'] ) ? json_decode( $row['login_settings'], TRUE ) : array();
|
||||
|
||||
$title = $row['login_key'];
|
||||
switch ( mb_strtolower( $row['login_key'] ) )
|
||||
{
|
||||
case 'internal':
|
||||
$classname = 'IPS\\Login\\Handler\\Standard';
|
||||
$title = "Standard";
|
||||
/* This may not be set for some communities - check that it's valid */
|
||||
if( !isset( $settings['auth_types'] ) )
|
||||
{
|
||||
$settings['auth_types'] = \IPS\Login::AUTH_TYPE_USERNAME;
|
||||
}
|
||||
break;
|
||||
case 'facebook':
|
||||
$classname = 'IPS\\Login\\Handler\\OAuth2\\Facebook';
|
||||
$settings['client_id'] = isset( $settings['app_id'] ) ? $settings['app_id'] : NULL;
|
||||
$settings['client_secret'] = isset( $settings['app_secret'] ) ? $settings['app_secret'] : NULL;
|
||||
$settings['legacy_redirect'] = TRUE;
|
||||
$title = "Facebook";
|
||||
break;
|
||||
case 'google':
|
||||
$classname = 'IPS\\Login\\Handler\\OAuth2\\Google';
|
||||
$settings['legacy_redirect'] = TRUE;
|
||||
$title = "Google";
|
||||
break;
|
||||
case 'linkedin':
|
||||
$classname = 'IPS\\Login\\Handler\\OAuth2\\LinkedIn';
|
||||
$settings['client_id'] = isset( $settings['api_key'] ) ? $settings['api_key'] : NULL;
|
||||
$settings['client_secret'] = isset( $settings['secret_key'] ) ? $settings['secret_key'] : NULL;
|
||||
$settings['legacy_redirect'] = TRUE;
|
||||
$title = "LinkedIn";
|
||||
break;
|
||||
case 'live':
|
||||
case 'microsoft':
|
||||
$classname = 'IPS\\Login\\Handler\\OAuth2\\Microsoft';
|
||||
$settings['legacy_redirect'] = TRUE;
|
||||
$title = "Microsoft";
|
||||
break;
|
||||
case 'twitter':
|
||||
$classname = 'IPS\\Login\\Handler\\OAuth1\\Twitter';
|
||||
$title = "Twitter";
|
||||
break;
|
||||
case 'external':
|
||||
$classname = 'IPS\\Login\\Handler\\ExternalDatabase';
|
||||
$title = "MySQL Database";
|
||||
break;
|
||||
case 'ldap':
|
||||
$classname = 'IPS\\Login\\Handler\\LDAP';
|
||||
$title = "LDAP";
|
||||
break;
|
||||
case 'ipsconnect':
|
||||
$classname = 'IPS\\Login\\Handler\\OAuth2\\Invision';
|
||||
$title = "Invision Community";
|
||||
$oldsettings = $settings;
|
||||
$settings = array();
|
||||
$settings['url'] = $_SESSION['upgrade_options']['core']['103000']['ipsconnect_url'];
|
||||
$settings['grant_type'] = 'password';
|
||||
$settings['client_id'] = $_SESSION['upgrade_options']['core']['103000']['ipsconnect_client_id'];
|
||||
$settings['client_secret'] = $_SESSION['upgrade_options']['core']['103000']['ipsconnect_client_secret'];
|
||||
$settings['auth_types'] = $oldsettings['auth_types'];
|
||||
$settings['button_color'] = '#3e4148';
|
||||
$settings['button_text'] = NULL;
|
||||
$settings['button_icon'] = '';
|
||||
$settings['show_in_ucp'] = 'loggedin';
|
||||
$settings['update_name_changes'] = ( defined( '\IPS\CONNECT_NOSYNC_NAMES' ) and \IPS\CONNECT_NOSYNC_NAMES ) ? 'disabled' : 'force';
|
||||
$settings['update_email_changes'] = 'force';
|
||||
break;
|
||||
case 'convert':
|
||||
continue 2;
|
||||
break;
|
||||
default:
|
||||
$classname = 'IPS\\Login\\' . $row['login_key'];
|
||||
break;
|
||||
}
|
||||
|
||||
$id = \IPS\Db::i()->insert( 'core_login_methods', array(
|
||||
'login_classname' => $classname,
|
||||
'login_order' => $row['login_order'],
|
||||
'login_acp' => $row['login_acp'],
|
||||
'login_settings' => json_encode( $settings ),
|
||||
'login_enabled' => $row['login_enabled'],
|
||||
/* If we are coming from 3.x the setting will not exist yet, so we should default to 1. There was previously a no_reg setting in 3.x,
|
||||
however it is removed during 40000/step21 so we can't check it. */
|
||||
'login_register' => ( isset( \IPS\Settings::i()->allow_reg ) ) ? \IPS\Settings::i()->allow_reg : 1
|
||||
) );
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', "login_method_{$id}", $title );
|
||||
|
||||
\IPS\Db::i()->update( 'core_members_known_devices', array( 'login_handler' => $id ), array( 'login_handler=?', $row['login_key'] ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom title for this step
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function step1CustomTitle()
|
||||
{
|
||||
return 'Updating login handlers';
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2
|
||||
* Update Login IDs
|
||||
*
|
||||
* @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
|
||||
*/
|
||||
public function step2()
|
||||
{
|
||||
$loginMethods = iterator_to_array( \IPS\Db::i()->select( '*', 'core_login_methods' )->setKeyField('login_classname') );
|
||||
|
||||
/* Some init */
|
||||
$did = 0;
|
||||
$limit = 0;
|
||||
|
||||
if( isset( \IPS\Request::i()->extra ) )
|
||||
{
|
||||
$limit = \IPS\Request::i()->extra;
|
||||
}
|
||||
|
||||
/* Try to prevent timeouts to the extent possible */
|
||||
$cutOff = \IPS\core\Setup\Upgrade::determineCutoff();
|
||||
|
||||
$where = array();
|
||||
if ( \IPS\Db::i()->checkForColumn( 'core_members', 'fb_uid' ) )
|
||||
{
|
||||
$where[] = 'fb_uid>0';
|
||||
}
|
||||
if ( \IPS\Db::i()->checkForColumn( 'core_members', 'live_id' ) )
|
||||
{
|
||||
$where[] = 'live_id IS NOT NULL';
|
||||
}
|
||||
if ( \IPS\Db::i()->checkForColumn( 'core_members', 'twitter_id' ) )
|
||||
{
|
||||
$where[] = "twitter_id<>''";
|
||||
}
|
||||
if ( \IPS\Db::i()->checkForColumn( 'core_members', 'google_id' ) )
|
||||
{
|
||||
$where[] = 'google_id IS NOT NULL';
|
||||
}
|
||||
if ( \IPS\Db::i()->checkForColumn( 'core_members', 'linkedin_id' ) )
|
||||
{
|
||||
$where[] = 'linkedin_id IS NOT NULL';
|
||||
}
|
||||
if ( \IPS\Db::i()->checkForColumn( 'core_members', 'ipsconnect_id' ) )
|
||||
{
|
||||
$where[] = 'ipsconnect_id>0';
|
||||
}
|
||||
if ( $where )
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_members', implode( $where, ' OR ' ), 'member_id ASC', array( $limit, 500 ) ) as $member )
|
||||
{
|
||||
if( $cutOff !== null AND time() >= $cutOff )
|
||||
{
|
||||
return ( $limit + $did );
|
||||
}
|
||||
|
||||
$did++;
|
||||
|
||||
if ( isset( $member['fb_uid'] ) and $member['fb_uid'] and isset( $loginMethods['IPS\\Login\\Handler\\OAuth2\\Facebook'] ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_login_links', array(
|
||||
'token_login_method' => $loginMethods['IPS\\Login\\Handler\\OAuth2\\Facebook']['login_id'],
|
||||
'token_member' => $member['member_id'],
|
||||
'token_identifier' => $member['fb_uid'],
|
||||
'token_linked' => TRUE,
|
||||
'token_access_token' => $member['fb_token'],
|
||||
), FALSE, TRUE );
|
||||
}
|
||||
if ( isset( $member['live_id'] ) and $member['live_id'] and isset( $loginMethods['IPS\\Login\\Handler\\OAuth2\\Microsoft'] ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_login_links', array(
|
||||
'token_login_method' => $loginMethods['IPS\\Login\\Handler\\OAuth2\\Microsoft']['login_id'],
|
||||
'token_member' => $member['member_id'],
|
||||
'token_identifier' => $member['live_id'],
|
||||
'token_linked' => TRUE,
|
||||
'token_access_token' => $member['live_token'],
|
||||
), FALSE, TRUE );
|
||||
}
|
||||
if ( isset( $member['twitter_id'] ) and $member['twitter_id'] and isset( $loginMethods['IPS\\Login\\Handler\\OAuth1\\Twitter'] ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_login_links', array(
|
||||
'token_login_method' => $loginMethods['IPS\\Login\\Handler\\OAuth1\\Twitter']['login_id'],
|
||||
'token_member' => $member['member_id'],
|
||||
'token_identifier' => $member['twitter_id'],
|
||||
'token_linked' => TRUE,
|
||||
'token_access_token' => $member['twitter_token'],
|
||||
'token_secret' => $member['twitter_secret'],
|
||||
), FALSE, TRUE );
|
||||
}
|
||||
if ( isset( $member['google_id'] ) and $member['google_id'] and isset( $loginMethods['IPS\\Login\\Handler\\OAuth2\\Google'] ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_login_links', array(
|
||||
'token_login_method' => $loginMethods['IPS\\Login\\Handler\\OAuth2\\Google']['login_id'],
|
||||
'token_member' => $member['member_id'],
|
||||
'token_identifier' => $member['google_id'],
|
||||
'token_linked' => TRUE,
|
||||
'token_access_token' => $member['google_token'],
|
||||
), FALSE, TRUE );
|
||||
}
|
||||
if ( isset( $member['linkedin_id'] ) and $member['linkedin_id'] and isset( $loginMethods['IPS\\Login\\Handler\\OAuth2\\LinkedIn'] ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_login_links', array(
|
||||
'token_login_method' => $loginMethods['IPS\\Login\\Handler\\OAuth2\\LinkedIn']['login_id'],
|
||||
'token_member' => $member['member_id'],
|
||||
'token_identifier' => $member['linkedin_id'],
|
||||
'token_linked' => TRUE,
|
||||
'token_access_token' => $member['linkedin_token'],
|
||||
), FALSE, TRUE );
|
||||
}
|
||||
if ( isset( $member['ipsconnect_id'] ) and $member['ipsconnect_id'] and isset( $loginMethods['IPS\\Login\\Handler\\OAuth2\\Invision'] ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_login_links', array(
|
||||
'token_login_method' => $loginMethods['IPS\\Login\\Handler\\OAuth2\\Invision']['login_id'],
|
||||
'token_member' => $member['member_id'],
|
||||
'token_identifier' => $member['ipsconnect_id'],
|
||||
'token_linked' => TRUE,
|
||||
), FALSE, TRUE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $did )
|
||||
{
|
||||
return $limit + $did;
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $_SESSION['_step2Count'] );
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom title for this step
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function step2CustomTitle()
|
||||
{
|
||||
$limit = isset( \IPS\Request::i()->extra ) ? \IPS\Request::i()->extra : 0;
|
||||
|
||||
if( !isset( $_SESSION['_step2Count'] ) )
|
||||
{
|
||||
$where = array();
|
||||
if ( \IPS\Db::i()->checkForColumn( 'core_members', 'fb_uid' ) )
|
||||
{
|
||||
$where[] = 'fb_uid>0';
|
||||
}
|
||||
if ( \IPS\Db::i()->checkForColumn( 'core_members', 'live_id' ) )
|
||||
{
|
||||
$where[] = 'live_id IS NOT NULL';
|
||||
}
|
||||
if ( \IPS\Db::i()->checkForColumn( 'core_members', 'twitter_id' ) )
|
||||
{
|
||||
$where[] = "twitter_id<>''";
|
||||
}
|
||||
if ( \IPS\Db::i()->checkForColumn( 'core_members', 'google_id' ) )
|
||||
{
|
||||
$where[] = 'google_id IS NOT NULL';
|
||||
}
|
||||
if ( \IPS\Db::i()->checkForColumn( 'core_members', 'linkedin_id' ) )
|
||||
{
|
||||
$where[] = 'linkedin_id IS NOT NULL';
|
||||
}
|
||||
if ( $where )
|
||||
{
|
||||
$_SESSION['_step2Count'] = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', implode( $where, ' OR ' ) )->first();
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['_step2Count'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 'Converting login handlers for 4.3 (Fixed so far: ' . ( ( $limit > $_SESSION['_step2Count'] ) ? $_SESSION['_step2Count'] : $limit ) . ' out of ' . $_SESSION['_step2Count'] . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 3
|
||||
* Drop old columns
|
||||
*
|
||||
* @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
|
||||
*/
|
||||
public function step3()
|
||||
{
|
||||
$columnsToDrop = array();
|
||||
foreach ( array('fb_uid','fb_token','live_id','live_token','twitter_id','twitter_token','twitter_secret','tc_last_sid_import','tc_photo','tc_bwoptions','fb_photo','fb_photo_thumb','fb_bwoptions','google_id','google_token','linkedin_id','linkedin_token') as $col )
|
||||
{
|
||||
if ( \IPS\Db::i()->checkForColumn( 'core_members', $col ) )
|
||||
{
|
||||
$columnsToDrop[] = $col;
|
||||
}
|
||||
}
|
||||
\IPS\Db::i()->dropColumn( 'core_members', $columnsToDrop );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom title for this step
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function step3CustomTitle()
|
||||
{
|
||||
return 'Removing unused login data';
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate spam defense whitelist with installed domain
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function step4()
|
||||
{
|
||||
$domain = rtrim( str_replace( 'www.', '', parse_url( \IPS\Settings::i()->base_url, PHP_URL_HOST ) ), '/' );
|
||||
\IPS\Db::i()->insert( 'core_spam_whitelist', array( 'whitelist_type' => 'domain', 'whitelist_content' => $domain, 'whitelist_date' => time(), 'whitelist_reason' => 'Install Domain' ) );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom title for this step
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function step4CustomTitle()
|
||||
{
|
||||
return 'Setting defaults for spam service email address whitelist';
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 5
|
||||
* Update Email Settings if Sparkpost is used
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function step5()
|
||||
{
|
||||
if ( \IPS\Settings::i()->sparkpost_api_key AND \IPS\Settings::i()->sparkpost_use_for )
|
||||
{
|
||||
$newSettings = array(
|
||||
'mail_method' => 'smtp',
|
||||
'smtp_host' => 'smtp.sparkpostmail.com',
|
||||
'smtp_port' => '587',
|
||||
'smtp_protocol' => 'tls',
|
||||
'smtp_user' => 'SMTP_Injection',
|
||||
'smtp_pass' => \IPS\Settings::i()->sparkpost_api_key,
|
||||
);
|
||||
\IPS\Settings::i()->changeValues( $newSettings );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom title for this step
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function step5CustomTitle()
|
||||
{
|
||||
return 'Checking Sparkpost configuration';
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 6
|
||||
* Fix themes
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function step6()
|
||||
{
|
||||
/* Get rid of any duplicates that will cause a unique key error */
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_theme_templates', array( 'template_set_id=0 and template_added_to > 0' ) ) as $template )
|
||||
{
|
||||
try
|
||||
{
|
||||
/* See if we have a 'default' copy of this template yet */
|
||||
\IPS\Db::i()->select( 'template_id', 'core_theme_templates', array( 'template_set_id=? and template_group=? and template_name=? and template_app=? and template_location=?', $template['template_added_to'], $template['template_group'], $template['template_name'], $template['template_app'], $template['template_location'] ) )->first();
|
||||
|
||||
/* If we're here, it means this template exists */
|
||||
\IPS\Db::i()->delete( 'core_theme_templates', array( 'template_id=?', $template['template_id'] ) );
|
||||
}
|
||||
/* We want an underflow exception - it means the template isn't present */
|
||||
catch( \UnderflowException $e ){}
|
||||
}
|
||||
|
||||
/* Fix template_set_id=0 for non master */
|
||||
\IPS\Db::i()->update( 'core_theme_templates', 'template_set_id=template_added_to', array( 'template_set_id=0 and template_added_to > 0' ) );
|
||||
|
||||
/* Set customized flag */
|
||||
foreach( \IPS\Db::i()->select( 'set_id', 'core_themes' ) as $theme )
|
||||
{
|
||||
\IPS\Theme::setThemeCustomized( $theme['set_id'] );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom title for this step
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function step6CustomTitle()
|
||||
{
|
||||
return 'Flagging customized theme templates';
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 7
|
||||
* Settings Changes
|
||||
*
|
||||
* @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
|
||||
*/
|
||||
public function step7()
|
||||
{
|
||||
/* Usage reporting settings */
|
||||
\IPS\Db::i()->replace( 'core_sys_conf_settings', array(
|
||||
'conf_key' => 'usage_reporting',
|
||||
'conf_value' => intval( $_SESSION['upgrade_options']['core']['103000']['usage_reporting'] ),
|
||||
'conf_default' => 1,
|
||||
'conf_app' => 'core'
|
||||
) );
|
||||
|
||||
/* reCAPTCHA 1 removed */
|
||||
if ( \IPS\Settings::i()->bot_antispam_type === 'recaptcha' )
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array(
|
||||
'bot_antispam_type' => 'invisible',
|
||||
'recaptcha2_public_key' => '6LcH7UEUAAAAAIGWgOoyBKAqjLmOIKzfJTOjyC7z',
|
||||
'recaptcha2_private_key'=> '6LcH7UEUAAAAANmcQmZErdGW2FXwVhtRBVXBWBUA',
|
||||
) );
|
||||
}
|
||||
\IPS\Db::i()->delete( 'core_sys_lang_words', array( 'word_app=? AND word_key=?', 'core', 'recaptcha2_public_key_desc' ) );
|
||||
\IPS\Db::i()->delete( 'core_sys_lang_words', array( 'word_app=? AND word_key=?', 'core', 'recaptcha_public_key' ) );
|
||||
\IPS\Db::i()->delete( 'core_sys_lang_words', array( 'word_app=? AND word_key=?', 'core', 'recaptcha_private_key' ) );
|
||||
\IPS\Db::i()->delete( 'core_sys_lang_words', array( 'word_app=? AND word_key=?', 'core', 'recaptcha_private_key_desc' ) );
|
||||
\IPS\Db::i()->delete( 'core_sys_lang_words', array( 'word_app=? AND word_key=?', 'core', 'captcha_type_recaptcha' ) );
|
||||
\IPS\Db::i()->delete( 'core_sys_lang_words', array( 'word_app=? AND word_key=?', 'core', 'captcha_type_recaptcha_desc' ) );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom title for this step
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function step7CustomTitle()
|
||||
{
|
||||
return "Updating CAPTCHA settings";
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 8
|
||||
* Update positions for profile steps
|
||||
*
|
||||
* @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
|
||||
*/
|
||||
public function step8()
|
||||
{
|
||||
$position = 1;
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_profile_steps' ), 'IPS\Member\ProfileStep' ) AS $step )
|
||||
{
|
||||
$step->position = $position;
|
||||
$step->save();
|
||||
|
||||
$position++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom title for this step
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function step8CustomTitle()
|
||||
{
|
||||
return 'Adjusting profile step configuration';
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 9
|
||||
* Remove announcement widgets
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function step9()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( 'id, widgets', 'core_widget_areas', array( 'widgets LIKE(?)', '"key": "announcements"' ) )->setKeyField('id')->setValueField( 'widgets' ) as $id => $config )
|
||||
{
|
||||
$json = json_decode( $config, TRUE );
|
||||
|
||||
foreach( $json as $key => $value )
|
||||
{
|
||||
if( $value['key'] == 'announcements' AND $value['app'] == 'core' )
|
||||
{
|
||||
unset( $json[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'core_widget_areas', array( 'widgets' => json_encode( $json ) ), array( 'id=?', $id ) );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->delete( 'core_widgets', array( 'app=? AND `key`=?', 'core', 'announcements' ) );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom title for this step
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function step9CustomTitle()
|
||||
{
|
||||
return "Removing announcement widgets";
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 10
|
||||
* Remove orphaned known device data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function step10()
|
||||
{
|
||||
$queries = array();
|
||||
|
||||
/* Orphaned devices */
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( 'count(*)', 'core_members_known_devices', array( 'member_id NOT IN ( ' . \IPS\Db::i()->select( 'member_id', 'core_members' ) . ' )' ), NULL, 1 )->first();
|
||||
|
||||
\IPS\Db::i()->returnQuery = TRUE;
|
||||
$queries[] = array(
|
||||
'table' => 'core_members_known_devices',
|
||||
'query' => \IPS\Db::i()->delete( 'core_members_known_devices', array( 'member_id NOT IN ( ' . \IPS\Db::i()->select( 'member_id', 'core_members' ) . ' )' ) )
|
||||
);
|
||||
\IPS\Db::i()->returnQuery = FALSE;
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
|
||||
|
||||
/* Orphaned ip addresses */
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( 'COUNT(*)', 'core_members_known_ip_addresses', array( 'member_id NOT IN ( ' . \IPS\Db::i()->select( 'member_id', 'core_members' ) . ' )' ), NULL, 1 )->first();
|
||||
|
||||
/* Remove the offending entries */
|
||||
\IPS\Db::i()->returnQuery = TRUE;
|
||||
$queries[] = array(
|
||||
'table' => 'core_members_known_ip_addresses',
|
||||
'query' => \IPS\Db::i()->delete( 'core_members_known_ip_addresses', array( 'member_id NOT IN ( ' . \IPS\Db::i()->select( 'member_id', 'core_members' ) . ' )' ) )
|
||||
);
|
||||
\IPS\Db::i()->returnQuery = FALSE;
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
|
||||
/* Is this site affected by any of these issues? */
|
||||
if( !count( $queries ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$toRun = \IPS\core\Setup\Upgrade::runManualQueries( $queries );
|
||||
|
||||
if ( count( $toRun ) )
|
||||
{
|
||||
\IPS\core\Setup\Upgrade::adjustMultipleRedirect( array( 1 => 'core', 'extra' => array( '_upgradeStep' => 11 ) ) );
|
||||
|
||||
/* Queries to run manually */
|
||||
return array( 'html' => \IPS\Theme::i()->getTemplate( 'forms' )->queries( $toRun, \IPS\Http\Url::internal( 'controller=upgrade' )->setQueryString( array( 'key' => $_SESSION['uniqueKey'], 'mr_continue' => 1, 'mr' => \IPS\Request::i()->mr ) ) ) );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom title for this step
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function step10CustomTitle()
|
||||
{
|
||||
return "Removing orphaned member data";
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild search index
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
\IPS\Content\Search\Index::i()->rebuild();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user