Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

+108 -65
View File
@@ -178,6 +178,12 @@ class _Upgrade
$guestGroup = $INFO['guest_group'];
$validatingGroup = $INFO['auth_group'];
$memberGroup = $INFO['member_group'];
/* If the admin for some reason set member_group and auth_group to the same value in conf_global, that's no good */
if( $validatingGroup == $memberGroup )
{
$validatingGroup = NULL;
}
$url = \IPS\Request::i()->url();
@@ -462,7 +468,7 @@ class _Upgrade
$newSecondaryGroups = array();
foreach( explode( ',', $row['mgroup_others'] ) AS $secondaryGroup )
{
if ( ! in_array( $secondaryGroup, array( $bannedGroup, $validatingGroup, $guestGroup ) ) )
if ( $secondaryGroup AND ! in_array( $secondaryGroup, array( $bannedGroup, $validatingGroup, $guestGroup ) ) )
{
$newSecondaryGroups[] = $secondaryGroup;
}
@@ -561,7 +567,7 @@ class _Upgrade
}
/* Decode names */
$row['name'] = html_entity_decode( $row['name'], ENT_QUOTES, 'UTF-8' );
$row['name'] = \IPS\Text\Parser::utf8mb4SafeDecode( $row['name'] );
/* Remap some columns */
$row['member_posts'] = (int) $row['posts'];
@@ -675,9 +681,14 @@ class _Upgrade
\IPS\Db::i()->dropTable( 'profile_portal' );
\IPS\Db::i()->renameTable( 'core_members_temp', 'core_members' );
if ( $bannedGroup and $validatingGroup )
if ( $bannedGroup )
{
\IPS\Db::i()->delete( 'core_groups', 'g_id IN(' . $bannedGroup . ',' . $validatingGroup . ')' );
\IPS\Db::i()->delete( 'core_groups', 'g_id=' . $bannedGroup );
}
if ( $validatingGroup )
{
\IPS\Db::i()->delete( 'core_groups', 'g_id=' . $validatingGroup );
}
if( isset( $_SESSION['idm_block_submissions'] ) )
@@ -782,7 +793,7 @@ class _Upgrade
/* Retain log in method (username, email or both) */
if( $login['login_user_id'] )
{
$data = ( $data === NULL ) ? array() : $data;
$data = ( is_array( $data ) ) ? $data : array();
switch( $login['login_user_id'] )
{
@@ -1804,42 +1815,44 @@ DROP INDEX like_lookup_area"
catch( \UnderflowException $e ){}
$className = $insert['class'];
try
if( class_exists( $className ) )
{
/* Some tables haven't been renamed yet so build the data manually */
if( $table )
try
{
$row = \IPS\DB::i()->select( "*", $table, array( "{$className::$databaseColumnId} = ?", $report['exdat3'] ? $report['exdat2'] : $report['exdat1'] ) )->first();
$content = $className::constructFromData( $row );
if( $itemTable )
/* Some tables haven't been renamed yet so build the data manually */
if( $table )
{
$itemClass = $className::$itemClass;
$itemRow = \IPS\DB::i()->select("*", $itemTable, array("{$itemClass::$databaseColumnId} = ?", $content->mapped('item')))->first();
$item = $itemClass::constructFromData($itemRow);
$row = \IPS\DB::i()->select( "*", $table, array( "{$className::$databaseColumnId} = ?", $report['exdat3'] ? $report['exdat2'] : $report['exdat1'] ) )->first();
$content = $className::constructFromData( $row );
$containerClass = $itemClass::$containerNodeClass;
$containerRow = \IPS\DB::i()->select("*", $containerTable, array("{$containerClass::$databaseColumnId} = ?", $item->mapped('container')))->first();
$container = $containerClass::constructFromData($containerRow);
if( $itemTable )
{
$itemClass = $className::$itemClass;
$itemRow = \IPS\DB::i()->select("*", $itemTable, array("{$itemClass::$databaseColumnId} = ?", $content->mapped('item')))->first();
$item = $itemClass::constructFromData($itemRow);
$permissions = $container->permissions();
$insert['perm_id'] = $permissions['perm_id'];
$containerClass = $itemClass::$containerNodeClass;
$containerRow = \IPS\DB::i()->select("*", $containerTable, array("{$containerClass::$databaseColumnId} = ?", $item->mapped('container')))->first();
$container = $containerClass::constructFromData($containerRow);
$permissions = $container->permissions();
$insert['perm_id'] = $permissions['perm_id'];
}
}
else
{
$content = $className::load( $report['exdat3'] ? $report['exdat2'] : $report['exdat1'] );
$insert['perm_id'] = $content->permId();
}
}
else
{
$content = $className::load( $report['exdat3'] ? $report['exdat2'] : $report['exdat1'] );
$insert['perm_id'] = $content->permId();
}
$insert['author'] = $content->mapped('author');
$insert['author'] = $content->mapped('author');
}
catch( \Exception $e ){}
/* Insert new report */
\IPS\Db::i()->insert( 'core_rc_index', $insert );
}
catch( \Exception $e ){}
/* Insert new report */
\IPS\Db::i()->insert( 'core_rc_index', $insert );
}
if( $did )
@@ -2617,7 +2630,7 @@ DROP INDEX like_lookup_area"
$table = 'core_attachments';
$url = \IPS\Request::i()->url();
$settings = array( 'upload_dir' => \IPS\ROOT_PATH . '/uploads' , 'upload_url' => str_replace( 'http://', '//', preg_replace( '#/admin/.*$#', '/uploads', $url ) ) );
$settings = array( 'upload_dir' => '', 'upload_url' => '' );
foreach( \IPS\Db::i()->select( '*', 'core_sys_conf_settings', array( "conf_key IN('upload_dir', 'upload_url', 'gallery_images_url', 'gallery_images_path', 'idm_screenshot_url',
'idm_filestorage', 'idm_localfilepath', 'idm_localsspath', 'idm_remoteport', 'idm_remotessurl', 'idm_remotefileurl', 'idm_filestorage', 'idm_remoteurl', 'idm_remoteuser',
@@ -2632,7 +2645,7 @@ DROP INDEX like_lookup_area"
$settings[ $row['conf_key'] ] = $row['conf_value'];
}
else
else if( $row['conf_default'] )
{
$settings[ $row['conf_key'] ] = $row['conf_default'];
}
@@ -2647,6 +2660,12 @@ DROP INDEX like_lookup_area"
/* if the old dir doesn't exist, set this now so at least themes work */
if( ! is_dir( $settings['upload_dir'] ) )
{
/* Protocol relative URLs in 3.x confuse this upgrade step */
if ( mb_substr( \IPS\Settings::i()->base_url, 0, 2 ) === '//' )
{
\IPS\Settings::i()->base_url = 'http:' . \IPS\Settings::i()->base_url;
}
$settings['upload_dir'] = \IPS\ROOT_PATH . '/uploads';
$settings['upload_url'] = \IPS\Settings::i()->base_url . 'uploads';
}
@@ -2693,7 +2712,7 @@ DROP INDEX like_lookup_area"
}
/* Gallery */
if( isset( $settings['gallery_images_path'] ) AND $settings['gallery_images_path'] != $settings['upload_dir'] )
if( isset( $settings['gallery_images_path'] ) AND $settings['gallery_images_path'] AND $settings['gallery_images_path'] != $settings['upload_dir'] )
{
$url = $settings['gallery_images_url'] ?: rtrim( \IPS\Settings::i()->base_url, '/' ) . '/applications/gallery/interface/legacy/image.php?path=';
$gallery = \IPS\Db::i()->insert( 'core_file_storage', array( 'method' => 'FileSystem', 'configuration' => json_encode( array( 'dir' => str_replace( \IPS\ROOT_PATH, '{root}', $settings['gallery_images_path'] ), 'url' => str_replace( $strReplace, '', $url ) ) ) ) );
@@ -2704,7 +2723,7 @@ DROP INDEX like_lookup_area"
}
/* Blog */
if( isset( $settings['blog_upload_dir'] ) AND $settings['blog_upload_dir'] != $settings['upload_dir'] )
if( isset( $settings['blog_upload_dir'] ) AND $settings['blog_upload_dir'] AND $settings['blog_upload_dir'] != $settings['upload_dir'] )
{
$blog = \IPS\Db::i()->insert( 'core_file_storage', array( 'method' => 'FileSystem', 'configuration' => json_encode( array( 'dir' => str_replace( \IPS\ROOT_PATH, '{root}', $settings['blog_upload_dir'] ), 'url' => str_replace( $strReplace, '', $settings['blog_upload_url'] ) ) ) ) );
}
@@ -2752,15 +2771,15 @@ DROP INDEX like_lookup_area"
if( \IPS\Db::i()->checkForTable( 'downloads_files_records' ) )
{
\IPS\Db::i()->insert( 'core_files',
\IPS\Db::i()->select( "NULL, " . \IPS\Db::i()->prefix . "downloads_files_records.record_realname, MD5( RAND() ), " . \IPS\Db::i()->prefix . "downloads_filestorage.storage_file, NULL", 'downloads_filestorage' )->join( 'downloads_files_records', \IPS\Db::i()->prefix . "downloads_filestorage.storage_id=" . \IPS\Db::i()->prefix . "downloads_files_records.record_id" )
\IPS\Db::i()->select( "NULL, downloads_files_records.record_realname, MD5( RAND() ), downloads_filestorage.storage_file, NULL", 'downloads_filestorage' )->join( 'downloads_files_records', "downloads_filestorage.storage_id=downloads_files_records.record_id" )
);
\IPS\Db::i()->insert( 'core_files',
\IPS\Db::i()->select( "NULL, " . \IPS\Db::i()->prefix . "downloads_files_records.record_realname, MD5( RAND() ), " . \IPS\Db::i()->prefix . "downloads_filestorage.storage_ss, NULL", 'downloads_filestorage' )->join( 'downloads_files_records', \IPS\Db::i()->prefix . "downloads_filestorage.storage_id=" . \IPS\Db::i()->prefix . "downloads_files_records.record_id" )
\IPS\Db::i()->select( "NULL, downloads_files_records.record_realname, MD5( RAND() ), downloads_filestorage.storage_ss, NULL", 'downloads_filestorage' )->join( 'downloads_files_records', "downloads_filestorage.storage_id=downloads_files_records.record_id" )
);
\IPS\Db::i()->insert( 'core_files',
\IPS\Db::i()->select( "NULL, " . \IPS\Db::i()->prefix . "downloads_files_records.record_realname, MD5( RAND() ), " . \IPS\Db::i()->prefix . "downloads_filestorage.storage_thumb, NULL", 'downloads_filestorage' )->join( 'downloads_files_records', \IPS\Db::i()->prefix . "downloads_filestorage.storage_id=" . \IPS\Db::i()->prefix . "downloads_files_records.record_id" )
\IPS\Db::i()->select( "NULL, downloads_files_records.record_realname, MD5( RAND() ), downloads_filestorage.storage_thumb, NULL", 'downloads_filestorage' )->join( 'downloads_files_records', "downloads_filestorage.storage_id=downloads_files_records.record_id" )
);
}
@@ -2867,7 +2886,7 @@ DROP INDEX like_lookup_area"
{
$pathDetails = explode( '/', $row[ $column ] );
$fileName = array_pop( $pathDetails );
$newPathname = implode( '/', $pathDetails ) . '/' . $row['attach_file'] . '.' . md5( uniqid( microtime() ) );
$newPathname = ltrim( implode( '/', $pathDetails ) . '/' . $row['attach_file'] . '.' . md5( uniqid( microtime() ) ), '/' );
if( @rename( $settings['upload_dir'] . '/' . $row[ $column ], $settings['upload_dir'] . '/' . $newPathname ) )
{
@@ -2878,40 +2897,47 @@ DROP INDEX like_lookup_area"
if ( $table === 'core_member_ranks' )
{
if ( !is_numeric( $row[ $column ] ) )
/* The "pips" column is not required to be filled in */
if ( $row[ $column ] AND !is_numeric( $row[ $column ] ) )
{
if ( file_exists( \IPS\ROOT_PATH . '/' . $publicPath . '/style_extra/team_icons/' . $row[ $column ] ) )
{
@copy( \IPS\ROOT_PATH . '/' . $publicPath . '/style_extra/team_icons/' . $row[ $column ], $settings['upload_dir'] . '/pip_' . $row[ $column ] );
$update[ $column ] = 'pip_' . $row[ $column ];
}
$update[ $column ] = 'pip_' . $row[ $column ];
}
}
else if ( $table === 'core_groups' )
{
if ( mb_strpos( $row[ $column ], 'team_icons' ) AND file_exists( \IPS\ROOT_PATH . '/' . $row[ $column ] ) )
/* Do we have an image? */
if( $row[ $column ] )
{
$path = explode( '/', $row[ $column ] );
$file = array_pop( $path );
$_test = parse_url( $row[ $column ] );
$path = explode( '/', $row[ $column ] );
$file = array_pop( $path );
@copy( \IPS\ROOT_PATH . '/' . $row[ $column ], $settings['upload_dir'] . '/team_' . $file );
$update[ $column ] = 'team_' . $file;
}
else
{
if( $row[ $column ] )
/* If this is a relative path, we should copy the image and use that path */
if( ( !isset( $_test['host'] ) OR !$_test['host'] ) AND file_exists( \IPS\ROOT_PATH . '/' . $row[ $column ] ) )
{
$_test = parse_url( $row[ $column ] );
@copy( \IPS\ROOT_PATH . '/' . $row[ $column ], $settings['upload_dir'] . '/team_' . $file );
if( !isset( $_test['host'] ) OR !$_test['host'] )
$update[ $column ] = 'team_' . $file;
}
/* Otherwise if this is a URL, we should copy the file locally */
else
{
try
{
$update[ $column ] = rtrim( \IPS\Settings::i()->base_url, '/' ) . '/' . $row[ $column ];
$contents = \IPS\Http\Url::external( $row[ $column ] )->request()->get();
@file_put_contents( $settings['upload_dir'] . '/team_' . $file, $contents );
$update[ $column ] = 'team_' . $file;
}
catch( \Exception $e ){}
}
}
}
else if ( $table === 'core_emoticons' )
{
@@ -2932,9 +2958,23 @@ DROP INDEX like_lookup_area"
if ( file_exists( \IPS\ROOT_PATH . '/' . $publicPath . '/style_emoticons/' . $row['emo_set'] . '/' . $row['image'] ) )
{
@copy( \IPS\ROOT_PATH . '/' . $publicPath . '/style_emoticons/' . $row['emo_set'] . '/' . $row['image'], $path . '/' . $row['emo_set'] . '_' . $row['image'] );
$update[ $column ] = $url . $row['emo_set'] . '_' . $row['image'];
/* The emoticon may have existed in a sub-folder */
if ( mb_stripos( $row['image'], '/' ) !== FALSE )
{
/* Work out the path */
$emo_path = explode( '/', $row['image'] );
$emo_name = array_pop( $emo_path );
@copy( \IPS\ROOT_PATH . '/' . $publicPath . '/style_emoticons/' . $row['emo_set'] . '/' . implode( '/', $emo_path ) . '/' . $emo_name, $path . '/' . $row['emo_set'] . '_' . implode( '_', $emo_path ) . '_' . $emo_name );
$update[ $column ] = $url . $row['emo_set'] . '_' . implode( '_', $emo_path ) . '_' . $emo_name;
}
else
{
@copy( \IPS\ROOT_PATH . '/' . $publicPath . '/style_emoticons/' . $row['emo_set'] . '/' . $row['image'], $path . '/' . $row['emo_set'] . '_' . $row['image'] );
$update[ $column ] = $url . $row['emo_set'] . '_' . $row['image'];
}
}
else
{
@@ -3213,9 +3253,6 @@ DROP INDEX like_lookup_area"
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => 'ban,delete' ), array( 'conf_key=?', 'spm_option' ) );
}
/* Update Search Engine setting - Sphinx needs new special setup for 4 */
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => 'mysql' ), array( 'conf_key=?', 'search_engine' ) );
/* Make sure license key does not have extra spaces at end */
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => trim( \IPS\Settings::i()->ipb_reg_number ) ), array( 'conf_key=?', 'ipb_reg_number' ) );
@@ -3344,6 +3381,14 @@ DROP INDEX like_lookup_area"
\IPS\Db::i()->update( 'core_applications', $update, array( 'app_directory=?', 'gallery' ) );
}
/* Update guest group access to site if required */
if( \IPS\Settings::i()->force_login )
{
$group = \IPS\Member\Group::load( \IPS\Settings::i()->guest_group );
$group->g_view_board = FALSE;
$group->save();
}
/* Disable cron task job */
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => 0 ), array( 'conf_key=?', 'task_use_cron' ) );
@@ -3780,8 +3825,6 @@ DROP INDEX like_lookup_area"
\IPS\Task::queue( 'core', 'RebuildNonContentPosts', array( 'extension' => 'core_Reports' ), 2 );
\IPS\Task::queue( 'core', 'RebuildNonContentPosts', array( 'extension' => 'core_Modcp' ), 2 );
\IPS\Settings::i()->search_engine = 'mysql';
\IPS\Content\Search\Index::i()->rebuild();
/* Recount content */