Version 4.7.0

This commit is contained in:
Neo committed 2025-12-19 16:00:35 -08:00
1 parent 517a5e1f70
commit 8ba7d43898
1933 files changed
+65613 -11332

No files matched your search

+7 -15
View File
@@ -415,7 +415,7 @@ class _App extends \IPS\Patterns\ActiveRecord
{
$table = 'convert_link';
if ( \in_array( $type, array( 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map', 'forums_topics', 'forums_posts' ) ) AND $mainTable === FALSE )
if ( \in_array( $type, [ 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map', 'forums_topics', 'forums_posts', 'forums_topics_old', 'forums_posts_old' ] ) AND $mainTable === FALSE )
{
if ( \in_array( $type, array( 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map' ) ) )
{
@@ -423,7 +423,7 @@ class _App extends \IPS\Patterns\ActiveRecord
}
else
{
$tableType = str_replace( 'forums_', '', $type );
$tableType = str_replace( [ 'forums_', '_old' ], '', $type );
$table = "convert_link_{$tableType}";
}
}
@@ -558,24 +558,16 @@ class _App extends \IPS\Patterns\ActiveRecord
* @param string $type The type of item
* @return void
*/
public function deleteLink( $foreignId, $type )
public function deleteLink( $foreignId, string $type )
{
/* Build cache key */
if ( !\is_array( $type ) )
{
$type = array( $type );
}
$key = \count( $type ) > 1 ? md5( implode('', $type ) ) : $type[0];
$table = $this->_getLinkTableName( $type );
\IPS\Db::i()->delete( $table, array( 'foreign_id=? AND type=? AND app=?', $foreignId, $type, $this->app_id ) );
/* Remove this from the link cache */
if( isset( $this->linkCache[ $key ][ $foreignId ] ) )
if( isset( $this->linkCache[ $type ][ $foreignId ] ) )
{
unset( $this->linkCache[ $key ][ $foreignId ] );
unset( $this->linkCache[ $type ][ $foreignId ] );
}
}
@@ -827,7 +819,7 @@ class _App extends \IPS\Patterns\ActiveRecord
if ( $mainTable === FALSE )
{
if ( \in_array( $type, array( 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map', 'forums_topics', 'forums_posts' ) ) )
if ( \in_array( $type, array( 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map', 'forums_topics', 'forums_posts', 'forums_topics_old', 'forums_posts_old' ) ) )
{
if ( \in_array( $type, array( 'core_message_topics', 'core_message_posts', 'core_message_topic_user_map' ) ) )
{
@@ -835,7 +827,7 @@ class _App extends \IPS\Patterns\ActiveRecord
}
else
{
$tableType = str_replace( 'forums_', '', $type );
$tableType = str_replace( [ 'forums_', '_old' ], '', $type );
$table = "convert_link_{$tableType}";
}
}
+51 -33
View File
@@ -671,7 +671,7 @@ class _Core extends \IPS\convert\Library
break;
case 'convertPrivateMessages':
$return['convertPrivateMessages'] = array( 'core_message_topics' => NULL, 'core_message_topic_user_map' => NULL );
$return['convertPrivateMessages'] = array( 'core_message_topics' => NULL, 'core_message_topic_user_map' => NULL, 'core_message_posts' => NULL );
break;
case 'convertPrivateMessageReplies':
@@ -856,7 +856,7 @@ class _Core extends \IPS\convert\Library
{
$imageData = file_get_contents( $imagePath );
}
$file = \IPS\File::create( 'core_Badges', $info['icon'], $imageData, NULL, FALSE, NULL, FALSE );
$file = \IPS\File::create( 'core_Ranks', $info['icon'], $imageData, NULL, FALSE, NULL, FALSE );
$info['icon'] = (string) $file;
}
catch( \ErrorException | \Exception $e )
@@ -1095,6 +1095,16 @@ class _Core extends \IPS\convert\Library
$info['announce_location'] = '*';
}
if ( !isset( $info['announce_permissions'] ) )
{
$info['announce_permissions'] = '*';
}
if ( !isset( $info['announce_color'] ) )
{
$info['announce_color'] = 'none';
}
if ( !isset( $info['announce_page_location'] ) )
{
$info['announce_page_location'] = array( 'sidebar' );
@@ -2975,7 +2985,7 @@ class _Core extends \IPS\convert\Library
{
$group = \IPS\Member\Group::load( $info['ips_group_id'] )->g_id;
}
catch( \ OutOfRangeException $ex ) {}
catch( \OutOfRangeException $ex ) {}
unset( $info['ips_group_id'] );
}
@@ -3352,23 +3362,23 @@ class _Core extends \IPS\convert\Library
{
try
{
$container = 'monthly_' . date( 'Y', $info['joined'] ) . '_' . date( 'm', $info['joined'] );
if ( \is_null( $profileFileData ) AND !\is_null( $profilePhotoPath ) )
{
$profileFileData = file_get_contents( rtrim( $profilePhotoPath, '/' ) . '/' . $profilePhotoName );
\IPS\File::$copyFiles = TRUE;
$photo = \IPS\File::create( 'core_Profile', $profilePhotoName, NULL, $container, FALSE, rtrim( $profilePhotoPath, '/' ) . '/' . $profilePhotoName );
\IPS\File::$copyFiles = FALSE;
}
$photo = \IPS\File::create( 'core_Profile', $profilePhotoName, $profileFileData );
else
{
$photo = \IPS\File::create( 'core_Profile', $profilePhotoName, $profileFileData, $container );
}
$info['pp_photo_type'] = 'custom';
$info['pp_main_photo'] = (string) $photo;
$info['pp_thumb_photo'] = (string) $photo->thumbnail( 'core_Profile', \IPS\PHOTO_THUMBNAIL_SIZE, \IPS\PHOTO_THUMBNAIL_SIZE, TRUE );
$info['pp_thumb_photo'] = NULL;
}
catch( \Exception $e )
{
$info['pp_photo_type'] = '';
$info['pp_main_photo'] = NULL;
$info['pp_thumb_photo'] = NULL;
}
catch( \ErrorException $e )
catch( \ErrorException | \Exception $e )
{
$info['pp_photo_type'] = '';
$info['pp_main_photo'] = NULL;
@@ -3396,12 +3406,7 @@ class _Core extends \IPS\convert\Library
/* Designs are different so this will never likely be correct, we'll try it if one is supplied though */
$info['pp_cover_offset'] = isset( $info['pp_cover_offset'] ) ? $info['pp_cover_offset'] : 0;
}
catch( \Exception $e )
{
$info['pp_cover_photo'] = '';
$info['pp_cover_offset'] = 0;
}
catch( \ErrorException $e )
catch( \ErrorException | \Exception $e )
{
$info['pp_cover_photo'] = '';
$info['pp_cover_offset'] = 0;
@@ -3484,6 +3489,11 @@ class _Core extends \IPS\convert\Library
{
$info['member_posts'] = 0;
}
/* If number is larger than the field we have */
elseif( $info['member_posts'] > 8388606 )
{
$info['member_posts'] = 0;
}
if ( isset( $info['member_last_post'] ) )
{
@@ -4013,7 +4023,7 @@ class _Core extends \IPS\convert\Library
if ( \count( $maps ) == 0 )
{
$this->software->app->log( 'private_message_topic_no_users', __METHOD__, \IPS\convert\App::LOG_WARNING );
$this->software->app->log( 'private_message_topic_no_users', __METHOD__, \IPS\convert\App::LOG_WARNING, $topic['mt_id'] );
return FALSE;
}
@@ -4369,16 +4379,24 @@ class _Core extends \IPS\convert\Library
{
$info['perms'] = json_encode( $info['perms'] );
}
switch( $info['type'] )
try
{
case 'm':
$info['id'] = $this->software->app->getLink( $info['id'], 'core_members' );
break;
case 'g':
$info['id'] = $this->software->app->getLink( $info['id'], 'core_groups' );
break;
switch( $info['type'] )
{
case 'm':
$info['id'] = $this->software->app->getLink( $info['id'], 'core_members' );
break;
case 'g':
$info['id'] = $this->software->app->getLink( $info['id'], 'core_groups' );
break;
}
}
catch( \OutOfRangeException $e )
{
$this->software->app->log( 'moderator_missing', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['id'] );
return FALSE;
}
try
@@ -6150,11 +6168,11 @@ class _Core extends \IPS\convert\Library
* Convert an RSS Imported Item... or try to, anyway.
*
* @param array $info Data to insert
* @param array $contentType Content Link Type
* @param string $type Link type for RSS Feed
* @param mixed $contentType Content Link Type
* @return boolean TRUE on success, or FALSE on failure.
*/
public function convertRssImported( $info=array(), $contentType, $type='core_rss_import' )
public function convertRssImported( $info=array(), $type='core_rss_import', $contentType )
{
/* Godspeed */
if ( isset( $info['rss_imported_import_id'] ) )
@@ -6285,7 +6303,7 @@ class _Core extends \IPS\convert\Library
$info['tag_member_id'] = 0;
}
if ( isset( $info['tag_added'] ) )
if ( !empty( $info['tag_added'] ) )
{
if ( $info['tag_added'] instanceof \IPS\DateTime )
{
@@ -140,7 +140,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_title' => 'convert_club_downloads_files',
'step_method' => 'convertClubDownloadsFiles',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_files', array( \IPS\Db::i()->in( 'file_category_id', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ),
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_files', array( \IPS\Db::i()->in( 'file_cat', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 10,
'dependencies' => array( 'convertClubDownloadsCategories' ),
@@ -152,7 +152,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_title' => 'convert_club_downloads_comments',
'step_method' => 'convertClubDownloadsComments',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_comments', array( \IPS\Db::i()->in( 'comment_file_id', \IPS\Db::i()->select( 'file_id', 'downloads_files', array( \IPS\Db::i()->in( 'file_category_id', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ) ) ) ),
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_comments', array( \IPS\Db::i()->in( 'comment_file_id', \IPS\Db::i()->select( 'file_id', 'downloads_files', array( \IPS\Db::i()->in( 'file_cat', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ) ) ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertClubDownloadsFiles' ),
@@ -164,7 +164,7 @@ class _Downloads extends Core
$return[ $k ] = array(
'step_title' => 'convert_club_downloads_reviews',
'step_method' => 'convertClubDownloadsReviews',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_files_reviews', array( \IPS\Db::i()->in( 'review_file_id', \IPS\Db::i()->select( 'file_id', 'downloads_files', array( \IPS\Db::i()->in( 'file_category_id', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ) ) ) ),
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_files_reviews', array( \IPS\Db::i()->in( 'review_file_id', \IPS\Db::i()->select( 'file_id', 'downloads_files', array( \IPS\Db::i()->in( 'file_cat', \IPS\Db::i()->select( 'cid', 'downloads_categories', array( "cclub_id IS NOT NULL" ) ) ) ) ) ) ) ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 200,
'dependencies' => array( 'convertClubDownloadsFiles' ),
@@ -385,13 +385,15 @@ class _Downloads extends Core
$id = $info['cf_id'];
$fieldName = isset( $info['cf_name'] ) ? $info['cf_name'] : NULL;
unset( $info['cf_id'], $info['cf_name'] );
$fieldDescription = isset( $info['cf_desc'] ) ? $info['cf_desc'] : NULL;
unset( $info['cf_id'], $info['cf_name'], $info['cf_desc'] );
$inserted_id = \IPS\Db::i()->insert( 'downloads_cfields', $info );
$this->software->app->addLink( $inserted_id, $id, 'downloads_cfields' );
/* Field Name */
\IPS\Lang::saveCustom( 'downloads', "downloads_field_{$inserted_id}", $fieldName ?: "Converted Field {$inserted_id}" );
\IPS\Lang::saveCustom( 'downloads', "downloads_field_{$inserted_id}_desc", $fieldDescription ?: '' );
/* Now... create our column */
$columnDefinition = array( 'name' => "field_{$inserted_id}" );
@@ -658,7 +660,7 @@ class _Downloads extends Core
$info['ctypes'] = NULL;
}
if ( !isset( $info['csortorder'] ) OR !\in_array( $info['csortoder'], array( 'updated', 'last_comment', 'title', 'rating', 'date', 'num_comments', 'num_reviews', 'views' ) ) )
if ( !isset( $info['csortorder'] ) OR !\in_array( $info['csortorder'], array( 'updated', 'last_comment', 'title', 'rating', 'date', 'num_comments', 'num_reviews', 'views' ) ) )
{
$info['csortorder'] = 'updated';
}
@@ -1042,6 +1044,7 @@ class _Downloads extends Core
/* Now our records */
$totalFileSize = 0;
$primaryScreenshot = FALSE;
foreach( $records AS $record )
{
/* We don't really need this */
@@ -1080,6 +1083,18 @@ class _Downloads extends Core
$record['record_realname'] = $fileName;
}
}
if ( isset( $record['record_time'] ) )
{
if ( $record['record_time'] instanceof \IPS\DateTime )
{
$record['record_time'] = $record['record_time']->getTimestamp();
}
}
else
{
$record['record_time'] = $info['file_submitted'];
}
try
{
@@ -1088,6 +1103,9 @@ class _Downloads extends Core
$record['file_data'] = NULL;
}
/* Figure out the container */
$container = 'monthly_' . date( 'Y', $record['record_time'] ) . '_' . date( 'm', $record['record_time'] );
/* We need the file storage to copy the file rather than move it */
\IPS\File::$copyFiles = TRUE;
@@ -1098,7 +1116,7 @@ class _Downloads extends Core
}
else if ( $record['record_type'] == 'upload' )
{
$file = \IPS\File::create( 'downloads_Files', $record['record_realname'], $record['file_data'], NULL, TRUE, $record['file_path'] );
$file = \IPS\File::create( 'downloads_Files', $record['record_realname'], $record['file_data'], $container, TRUE, $record['file_path'] );
$record['record_location'] = (string) $file;
$record['record_size'] = $file->filesize();
@@ -1109,7 +1127,7 @@ class _Downloads extends Core
}
else
{
$file = \IPS\File::create( 'downloads_Screenshots', $record['record_realname'], $record['file_data'], NULL, TRUE, $record['file_path'] );
$file = \IPS\File::create( 'downloads_Screenshots', $record['record_realname'], $record['file_data'], $container, TRUE, $record['file_path'] );
$record['record_location'] = (string) $file;
$record['record_thumb'] = (string) $file->thumbnail( 'downloads_Screenshots' );
$record['record_size'] = $file->filesize();
@@ -1130,18 +1148,6 @@ class _Downloads extends Core
\IPS\File::$copyFiles = FALSE;
unset( $record['file_data'], $file, $record['file_path'] );
if ( isset( $record['record_time'] ) )
{
if ( $record['record_time'] instanceof \IPS\DateTime )
{
$record['record_time'] = $record['record_time']->getTimestamp();
}
}
else
{
$record['record_time'] = $info['file_submitted'];
}
if ( $hasId )
{
$recordId = $record['record_id'];
@@ -1709,7 +1709,7 @@ class _Forums extends Core
*/
public function convertForumsRssImported( $info=array() )
{
return parent::convertRssImported( $info, 'forums_topics', 'forums_rss_import' );
return parent::convertRssImported( $info, 'forums_rss_import', 'forums_topics' );
}
/**
@@ -406,13 +406,13 @@ class _Gallery extends Core
/* Album Sort Order */
$sortOrders = array( 'album_last_img_date', 'album_last_comment', 'album_rating_aggregate', 'album_comments','album_reviews', 'album_name', 'album_count_comments', 'album_count_imgs' );
if ( !isset( $info['category_sort_options'] ) OR !in_array( $info['category_sort_options'], $sortOrders ) )
if ( !isset( $info['category_sort_options'] ) OR !\in_array( $info['category_sort_options'], $sortOrders ) )
{
$info['category_sort_options'] = 'album_last_img_date';
}
/* Image Sort Order */
if ( !isset( $info['category_sort_options_img'] ) OR !in_array( $info['category_sort_options_img'], array( 'updated', 'last_comment', 'title', 'rating', 'date', 'num_comments', 'num_reviews', 'views' ) ) )
if ( !isset( $info['category_sort_options_img'] ) OR !\in_array( $info['category_sort_options_img'], array( 'updated', 'last_comment', 'title', 'rating', 'date', 'num_comments', 'num_reviews', 'views' ) ) )
{
$info['category_sort_options_img'] = 'updated';
}
@@ -869,6 +869,7 @@ class _Gallery extends Core
if( isset( $info['image_container'] ) )
{
$container = $info['image_container'];
unset( $info['image_container'] );
}
/* Okay, let's create our image. We can use data returned from this later if it's missing. */
@@ -183,6 +183,7 @@ abstract class _Software
'xenfororm' => 'IPS\convert\Software\Cms\Xenfororm',
),
'downloads' => array(
'invisioncommunity' => 'IPS\convert\Software\Downloads\Invisioncommunity',
'xenforo' => 'IPS\convert\Software\Downloads\Xenforo',
),
'forums' => array(
@@ -204,6 +205,7 @@ abstract class _Software
),
'gallery' => array(
'coppermine' => 'IPS\convert\Software\Gallery\Coppermine',
'invisioncommunity' => 'IPS\convert\Software\Gallery\Invisioncommunity',
'photoplog' => 'IPS\convert\Software\Gallery\Photoplog',
'photopost' => 'IPS\convert\Software\Gallery\Photopost',
'vbulletin' => 'IPS\convert\Software\Gallery\Vbulletin',
@@ -466,6 +466,7 @@ class _Vbulletin extends \IPS\convert\Software
'tag_meta_id' => $entry['blogid'],
'tag_text' => $data['title'],
'tag_member_id' => $data['userid'],
'tag_added' => $entry['dateline'],
'tag_prefix' => 0
) );
}
@@ -515,6 +515,7 @@ class _Vbulletin extends \IPS\convert\Software
'tag_meta_id' => $row['contentid'],
'tag_text' => $cmsCategories[ $key ],
'tag_member_id' => $node['userid'],
'tag_added' => $node['publishdate'],
'tag_prefix' => 0,
'tag_meta_link' => 'cms_custom_database_' . $database,
'tag_meta_parent_link' => 'cms_database_categories',
@@ -545,6 +546,7 @@ class _Vbulletin extends \IPS\convert\Software
'tag_meta_id' => $tag['contentid'],
'tag_text' => $tag['tagtext'],
'tag_member_id' => $tag['userid'],
'tag_added' => $node['publishdate'],
'tag_prefix' => 0,
'tag_meta_link' => 'cms_custom_database_' . $database,
'tag_meta_parent_link' => 'cms_database_categories',
@@ -408,6 +408,7 @@ class _Wordpress extends \IPS\convert\Software
'tag_meta_id' => $row['ID'],
'tag_text' => $tag,
'tag_member_id' => $row['post_author'],
'tag_added' => new \IPS\DateTime( $row['post_date'] ),
'tag_prefix' => 0,
'tag_meta_link' => 'cms_custom_database_' . $database,
'tag_meta_parent_link' => 'cms_database_categories',
@@ -31,7 +31,7 @@ class _Xenforo extends \IPS\convert\Software
public static function softwareName()
{
/* Child classes must override this method */
return "XenForo Page Nodes (1.5.x/2.0.x/2.1.x)";
return "XenForo Page Nodes (1.5.x/2.0.x/2.1.x/2.2.x)";
}
/**
@@ -41,7 +41,7 @@ class _Xenfororm extends \IPS\convert\Software
public static function softwareName()
{
/* Child classes must override this method */
return "XenForo Resource Manager Articles (1.5.x/2.0.x/2.1.x)";
return "XenForo Resource Manager Articles (1.5.x/2.0.x/2.1.x/2.2.x)";
}
/**
@@ -298,6 +298,7 @@ class _Expressionengine extends \IPS\convert\Software
\IPS\Data\Cache::i()->clearAll();
/* Non-Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
@@ -52,13 +52,17 @@ class _Invisioncommunity extends \IPS\convert\Software
{
static::$dbNeeded = TRUE;
$version = $this->db->select( 'app_version', 'core_applications', array( 'app_directory=?', 'core' ) )->first();
/* We're matching against the human version since the long version can change with patches */
if( $version == \IPS\Application::load( 'core')->version )
try
{
static::$versionMatch = TRUE;
$version = $this->db->select( 'app_version', 'core_applications', array( 'app_directory=?', 'core' ) )->first();
/* We're matching against the human version since the long version can change with patches */
if ( $version == \IPS\Application::load( 'core' )->version )
{
static::$versionMatch = TRUE;
}
}
catch( \IPS\Db\Exception $e ) {}
}
return $return;
@@ -365,6 +369,7 @@ class _Invisioncommunity extends \IPS\convert\Software
/* Attachments */
\IPS\Task::queue( 'core', 'RebuildAttachmentThumbnails', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
return array( "f_search_index_rebuild", "f_clear_caches" );
}
@@ -672,8 +677,8 @@ class _Invisioncommunity extends \IPS\convert\Software
$row['ips_members_bitoptions2'] = $row['members_bitoptions2'];
unset( $row['members_bitoptions'], $row['members_bitoptions2'] );
$path = $this->app->_session['more_info']['convertMembers']['upload_path'] . '/profile';
$libraryClass->convertMember( $row, $profileFields, $profilePhotoName, $path, NULL, $coverPhotoName, $path );
$path = $this->app->_session['more_info']['convertMembers']['upload_path'] . '/';
$libraryClass->convertMember( $row, $profileFields, $profilePhotoName, $path . ( isset( $bits ) ? $bits[0] : '' ), NULL, $coverPhotoName, $path . ( isset( $coverBits[0] ) ? $coverBits[0] : '' ) );
/* Any friends need converting to followers? */
foreach( $this->db->select( '*', 'core_follow', array( 'follow_app=? AND follow_area=? AND follow_rel_id=?', 'core', 'member', $row['member_id'] ) ) as $follow )
@@ -1130,6 +1135,7 @@ class _Invisioncommunity extends \IPS\convert\Software
/* This applies to all options */
$attachmentMap['id1_from_parent'] = FALSE;
$attachmentMap['id3_skip_link'] = TRUE;
/* Remap rows */
$name = explode( '/', $row['attach_location'] );
@@ -273,6 +273,7 @@ class _Mybb extends \IPS\convert\Software
\IPS\Data\Cache::i()->clearAll();
/* Non-Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_announcements', 'extension' => 'core_Announcement' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
@@ -167,6 +167,7 @@ class _Photopost extends \IPS\convert\Software
\IPS\Data\Cache::i()->clearAll();
/* Non-Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
/* Content Counts */
@@ -331,7 +331,8 @@ class _Phpbb extends \IPS\convert\Software
/* Clear Cache and Store */
\IPS\Data\Store::i()->clearAll();
\IPS\Data\Cache::i()->clearAll();
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
@@ -294,6 +294,7 @@ class _Smf extends \IPS\convert\Software
\IPS\Data\Cache::i()->clearAll();
/* Non-Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
@@ -337,6 +337,7 @@ class _UBBthreads extends \IPS\convert\Software
\IPS\Data\Cache::i()->clearAll();
/* Non-Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
@@ -322,6 +322,7 @@ class _Vanilla extends \IPS\convert\Software
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'core_member_status_updates', 'class' => 'IPS\core\Statuses\Status' ), 2, array( 'app', 'link', 'class' ) );
/* Non-Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
@@ -132,8 +132,13 @@ class _Vbulletin extends \IPS\convert\Software
'where' => NULL
),
'convertMembers' => array(
'table' => 'user',
'where' => NULL
'table' => 'user',
'where' => NULL,
'extra_steps' => array( 'convertMembersFollowers' ),
),
'convertMembersFollowers' => array(
'table' => 'userlist',
'where' => array( "type=? AND friend=?", 'buddy', 'yes' )
),
'convertMemberHistory' => array(
'table' => 'userchangelog',
@@ -170,6 +175,32 @@ class _Vbulletin extends \IPS\convert\Software
);
}
/**
* Allows software to add additional menu row options
*
* @return array
*/
public function extraMenuRows()
{
$rows = array();
$count = $this->countRows( static::canConvert()['convertMembersFollowers']['table'], static::canConvert()['convertMembersFollowers']['where'] );
if( $count )
{
$rows['convertMembersFollowers'] = array(
'step_method' => 'convertMembersFollowers',
'step_title' => 'convert_follows',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_follow', array( 'follow_app=? and follow_area=?', 'core', 'member' ) ),
'source_rows' => $count,
'per_cycle' => 200,
'dependencies' => array( 'convertMembers' ),
'link_type' => 'core_follow',
);
}
return $rows;
}
/**
* Count Source Rows for a specific step
*
@@ -539,6 +570,7 @@ class _Vbulletin extends \IPS\convert\Software
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'core_member_status_updates', 'class' => 'IPS\core\Statuses\Status' ), 2, array( 'app', 'link', 'class' ) );
/* Non-Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_announcements', 'extension' => 'core_Announcement' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
@@ -585,7 +617,7 @@ class _Vbulletin extends \IPS\convert\Software
/* Remove video tags and allow our parser to handle the embeds it supports */
if( \preg_match( "#\[video=#i", $post ) )
{
$post = preg_replace( "#\[video=[a-z_]+;[a-z0-9_]+\](.*?)\[\/video\]#i", '$1', $post );
$post = preg_replace( "#\[video=[a-z_]+;[a-z0-9_-]+\](.*?)\[\/video\]#i", '$1', $post );
}
/* This is not a core feature in vBulletin, but is a popular addon and the code was supplied below.
@@ -667,8 +699,24 @@ class _Vbulletin extends \IPS\convert\Software
'title' => $imageCategory['title'],
'position' => $imageCategory['displayorder']
);
/* In some rare cases, these may be URLs to a CDN */
$filedata = $filepath = null;
if ( mb_substr( $emoticon['smiliepath'], 0, 4 ) == 'http' )
{
/* Remote */
try
{
$filedata = (string) \IPS\Http\Url::external( $emoticon['smiliepath'] )->request()->get();
}
catch( \Exception $e ) {}
}
else
{
$filepath = $this->app->_session['more_info']['convertEmoticons']['emoticon_path'];
}
$libraryClass->convertEmoticon( $info, $set, $this->app->_session['more_info']['convertEmoticons']['keep_existing_emoticons'], $this->app->_session['more_info']['convertEmoticons']['emoticon_path'] );
$libraryClass->convertEmoticon( $info, $set, $this->app->_session['more_info']['convertEmoticons']['keep_existing_emoticons'], $filepath, $filedata );
$libraryClass->setLastKeyValue( $emoticon['smilieid'] );
}
@@ -1013,6 +1061,11 @@ class _Vbulletin extends \IPS\convert\Software
}
}
/**
* @brief default pseudo fields to convert
*/
protected static $pseudoFields = [ 'homepage', 'icq', 'aim', 'yahoo', 'msn', 'skype', 'user_title' ];
/**
* Convert members
*
@@ -1021,14 +1074,21 @@ class _Vbulletin extends \IPS\convert\Software
public function convertMembers()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'user.userid' );
/* User titles */
$userTitles = iterator_to_array( $this->db->select( 'title', 'usertitle' ) );
$userTitles = array_merge( $userTitles, iterator_to_array( $this->db->select( 'usertitle', 'usergroup', [ 'usertitle!=?', '' ] ) ) );
foreach( $this->fetch( 'user', 'user.userid', NULL, 'user.*, usertextfield.signature' )->join( 'usertextfield', 'user.userid = usertextfield.userid' ) AS $user )
$data = iterator_to_array( $this->fetch( 'user', 'user.userid', NULL, 'user.*, usertextfield.signature' )->join( 'usertextfield', 'user.userid = usertextfield.userid' ) );
$userIds = array_column( $data, 'userid' );
/* User Data */
$bans = iterator_to_array( $this->db->select( 'liftdate, userid', 'userban', [ $this->db->in( 'userid', $userIds ) ] )->setKeyField('userid')->setValueField( 'liftdate') );
$activation = iterator_to_array( $this->db->select( '*', 'useractivation', [ $this->db->in( 'userid', $userIds ) ] )->setKeyField('userid') );
$fields = iterator_to_array( $this->db->select( '*', 'userfield', [ $this->db->in( 'userid', $userIds ) ] )->setKeyField( 'userid' ) );
foreach( $data AS $user )
{
/* <3 Closures */
$self = $this;
@@ -1100,7 +1160,11 @@ class _Vbulletin extends \IPS\convert\Software
$temp_ban = 0;
try
{
$temp_ban = $this->db->select( 'liftdate', 'userban', array( "userid=?", $user['userid'] ) )->first();
if( !isset( $bans[ $user['userid'] ] ) )
{
throw new \UnderflowException();
}
$temp_ban = $bans[ $user['userid'] ];
if ( $temp_ban == 0 )
{
@@ -1149,7 +1213,11 @@ class _Vbulletin extends \IPS\convert\Software
/* If there is a validation record for this user, treat them as validating */
try
{
$activation = $this->db->select( '*', 'useractivation', array( "userid=?", $user['userid'] ) )->first();
if( !isset( $activation[ $user['userid'] ] ) )
{
throw new \UnderflowException();
}
$activation = $activation[ $user['userid'] ];
$info['members_bitoptions']['validating'] = TRUE;
}
@@ -1161,7 +1229,11 @@ class _Vbulletin extends \IPS\convert\Software
/* Profile Fields */
try
{
$profileFields = $this->db->select( '*', 'userfield', array( "userid=?", $user['userid'] ) )->first();
if( !isset( $fields[ $user['userid'] ] ) )
{
throw new \UnderflowException();
}
$profileFields = $fields[ $user['userid'] ];
unset( $profileFields['userid'] );
unset( $profileFields['temp'] );
@@ -1178,7 +1250,7 @@ class _Vbulletin extends \IPS\convert\Software
}
/* Pseudo Fields */
foreach( array( 'homepage', 'icq', 'aim', 'yahoo', 'msn', 'skype', 'user_title' ) AS $pseudo )
foreach( static::$pseudoFields AS $pseudo )
{
/* Are we retaining? */
if ( $this->app->_session['more_info']['convertMembers']["field_{$pseudo}"] == 'no_convert' )
@@ -1190,7 +1262,7 @@ class _Vbulletin extends \IPS\convert\Software
try
{
/* We don't actually need this, but we need to make sure the field was created */
$fieldId = $this->app->getLink( $pseudo, 'core_pfields_data' );
$this->app->getLink( $pseudo, 'core_pfields_data' );
}
catch( \OutOfRangeException $e )
{
@@ -1369,18 +1441,6 @@ class _Vbulletin extends \IPS\convert\Software
'email_sent' => $activation['dateline']
) );
}
/* Any friends need converting to followers? */
foreach( $this->db->select( '*', 'userlist', array( "type=? AND friend=? AND userid=?", 'buddy', 'yes', $user['userid'] ) ) AS $follower )
{
$libraryClass->convertFollow( array(
'follow_app' => 'core',
'follow_area' => 'member',
'follow_rel_id' => $follower['relationid'],
'follow_rel_id_type' => 'core_members',
'follow_member_id' => $follower['userid'],
) );
}
/* Skip this if we know that the user doesn't have any warnings */
if( \count( $warnings ) )
@@ -1420,6 +1480,28 @@ class _Vbulletin extends \IPS\convert\Software
}
}
/**
* Convert member followers
*
* @return void
*/
public function convertMembersFollowers()
{
$libraryClass = $this->getLibrary();
foreach ( $this->fetch( 'userlist', 'relationid', array( "type=? AND friend=?", 'buddy', 'yes' ) ) as $row )
{
$libraryClass->convertFollow( array(
'follow_app' => 'core',
'follow_area' => 'member',
'follow_rel_id' => $row['relationid'],
'follow_rel_id_type' => 'core_members',
'follow_member_id' => $row['userid'],
'follow_notify_freq' => 'none',
) );
}
}
/**
* Convert status updates
*
@@ -508,6 +508,7 @@ class _Vbulletin5 extends \IPS\convert\Software
\IPS\Data\Cache::i()->clearAll();
/* Non-Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
@@ -609,7 +610,7 @@ class _Vbulletin5 extends \IPS\convert\Software
$post = preg_replace( "#\[quote=([^\];]+?);n\d+\]#i", "[quote name='$1']", $post );
/* Remove video tags and allow our parser to handle the embeds it supports */
$post = preg_replace( "#\[video=[a-z_]+;[a-z0-9_]+\](.*?)\[\/video\]#i", '$1', $post );
$post = preg_replace( "#\[video=[a-z_]+;[a-z0-9_-]+\](.*?)\[\/video\]#i", '$1', $post );
return $post;
}
@@ -2044,6 +2045,17 @@ class _Vbulletin5 extends \IPS\convert\Software
$member->conv_password_extra = $token[1];
return \IPS\convert\Software\Core\Vbulletin::login( $member, $password );
break;
/** vBulletin 5.6.2 was able to also use the Argon2id password hashing scheme. */
case 'argon2id':
if( defined('PASSWORD_ARGON2ID') ) {
return password_verify( md5( $password ), $member->conv_password );
}
else
{
return FALSE;
}
break;
}
}
}
@@ -321,6 +321,7 @@ class _Woltlab extends \IPS\convert\Software
\IPS\Data\Cache::i()->clearAll();
/* Non-Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_announcements', 'extension' => 'core_Announcement' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
@@ -591,6 +591,7 @@ class _Wpforo extends \IPS\convert\Software
\IPS\Data\Cache::i()->clearAll();
/* Non-Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', [ 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ], 2, [ 'app', 'link', 'extension' ] );
\IPS\Task::queue( 'convert', 'RebuildNonContent', [ 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ], 2, [ 'app', 'link', 'extension' ] );
\IPS\Task::queue( 'convert', 'RebuildNonContent', [ 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ], 2, [ 'app', 'link', 'extension' ] );
@@ -617,7 +618,7 @@ class _Wpforo extends \IPS\convert\Software
*/
public static function login( $member, $password )
{
return \IPS\convert\Software\Core\WordPress::login( $member, $password );
return \IPS\convert\Software\Core\Wordpress::login( $member, $password );
}
/**
@@ -72,7 +72,7 @@ class _Xenforo extends \IPS\convert\Software
{
static::$isLegacy = FALSE;
/* Is this XF 2.1 */
/* Is this XF 2.1/2.2 */
if ( $version > 2010010 )
{
static::$useJson = TRUE;
@@ -93,7 +93,7 @@ class _Xenforo extends \IPS\convert\Software
*/
public static function softwareName()
{
return "XenForo (1.5.x/2.0.x/2.1.x)";
return "XenForo (1.5.x/2.0.x/2.1.x/2.2.x)";
}
/**
@@ -515,7 +515,8 @@ class _Xenforo extends \IPS\convert\Software
/* Clear Cache and Store */
\IPS\Data\Store::i()->clearAll();
\IPS\Data\Cache::i()->clearAll();
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
@@ -546,16 +547,31 @@ class _Xenforo extends \IPS\convert\Software
{
// run everything through htmlspecialchars to prevent XSS
$post = htmlspecialchars( $post, ENT_DISALLOWED | ENT_QUOTES, 'UTF-8', FALSE );
// find YouTube ID's and replace.
if( \preg_match( "#\[media=#i", $post ) )
if ( \preg_match( "#\[media=#i", $post ) )
{
$post = preg_replace( '#\[media=youtube\](.+?)\[/media\]#i', 'https://www.youtube.com/watch?v=$1', $post );
$post = preg_replace( '#\[media=facebook\](.+?)\[/media\]#i', 'https://www.facebook.com/video.php?v=$1', $post );
$post = preg_replace( '#\[media=twitter\](.+?)\[/media\]#i', 'https://twitter.com/username/status/$1', $post );
$post = preg_replace( '#\[media=reddit\](.+?)\[/media\]#i', 'https://reddit.com/r/$1', $post );
$post = preg_replace( '#\[media=imgur\](.+?)\[/media\]#i', '[img]https://imgur.com/$1[/img]', $post );
$post = preg_replace( '#\[media=instagram\](.+?)\[/media\]#i', 'https://instagram.com/p/$1', $post );
$post = preg_replace( '#\[media=vimeo\](.+?)\[/media\]#i', 'https://vimeo.com/$1', $post );
}
// Remove extra attributes
if ( \preg_match( "#\[img #i", $post ) )
{
$post = preg_replace( '/\[img .*\](.*?)\[\/img\]/i', '[img]$1[/img]', $post );
}
if ( \preg_match( "#\[url unfurl#i", $post ) )
{
$post = preg_replace( '/\[url unfurl=.*\](.*?)\[\/url\]/i', '[url]$1[/url]', $post );
}
/* Quick check for the presence of user tags */
if( \preg_match( "#\[user=#i", $post ) )
if ( \preg_match( "#\[user=#i", $post ) )
{
/* Mentions */
preg_match_all( '#\[user=(\d+)\](.+?)\[\/user\]#i', $post, $matches );
@@ -563,10 +579,10 @@ class _Xenforo extends \IPS\convert\Software
if ( \count( $matches ) )
{
/* Make sure we actually have mention data */
if ( isset( $matches[1] ) AND \count( $matches[1] ) )
if ( isset( $matches[1] ) and \count( $matches[1] ) )
{
$mentions = array();
foreach ( $matches[1] AS $k => $v )
foreach ( $matches[1] as $k => $v )
{
if ( isset( $matches[2][ $k ] ) )
{
@@ -576,7 +592,7 @@ class _Xenforo extends \IPS\convert\Software
$maps = iterator_to_array( \IPS\Db::i()->select( 'name, member_id', 'core_members', array( \IPS\Db::i()->in( 'name', array_keys( $mentions ) ) ) )->setKeyField( 'name' )->setValueField( 'member_id' ) );
foreach ( $mentions AS $memberName => $memberId )
foreach ( $mentions as $memberName => $memberId )
{
if ( !isset( $maps[ $memberName ] ) )
{
@@ -591,9 +607,9 @@ class _Xenforo extends \IPS\convert\Software
}
/* Quotes */
if( \preg_match( "#\[quote=#i", $post ) )
if ( \preg_match( "#\[quote=#i", $post ) )
{
$post = preg_replace( '#\[quote=&quot;([a-zA-Z0-9-_ ]+)(,(.?)+)?&quot;]#i', "[quote name='$1']", $post );
$post = preg_replace( '#\[quote=&quot;([a-zA-Z0-9-_ ]+)(,([a-z0-9\s:])+)?(,([a-z0-9\s:])+)?&quot;]#i', "[quote name='$1']", $post );
}
// finally, give us the post back.
@@ -655,9 +671,9 @@ class _Xenforo extends \IPS\convert\Software
$post = \IPS\Db::i()->select( 'msg_post', 'core_message_posts', array( "msg_id=?", $messagePostId ) )->first();
if ( preg_match( "/\[ATTACH([^\]]+?)?\]" . $row['attachment_id'] . "\[\/ATTACH\]/i", $post ) )
if ( preg_match( "/\[ATTACH([^\]]+?)?\]" . $row['attachment_id'] . "(\._xfImport)?\[\/ATTACH\]/i", $post ) )
{
$post = preg_replace( "/\[ATTACH([^\]]+?)?\]" . $row['attachment_id'] . "\[\/ATTACH\]/i", '[attachment=' . $attachId . ':name]', $post );
$post = preg_replace( "/\[ATTACH([^\]]+?)?\]" . $row['attachment_id'] . "(\._xfImport)?\[\/ATTACH\]/i", '[attachment=' . $attachId . ':name]', $post );
}
\IPS\Db::i()->update( 'core_message_posts', array( 'msg_post' => $post ), array( "msg_id=?", $messagePostId ) );
@@ -868,12 +884,18 @@ class _Xenforo extends \IPS\convert\Software
$info = array(
'g_id' => $row['user_group_id'],
'g_name' => $row['title'],
'prefix' => NULL,
'suffix' => NULL
);
/* XenForo stores raw CSS to style usernames - we can convert this into a <span> tag with an inline style attribute */
$style = str_replace( array( '<br>', '<br />' ), '', nl2br( $row['username_css'] ) );
$info['prefix'] = "<span style='{$style}'>";
$info['suffix'] = "</span>";
if( mb_strlen( $style ) < 220 )
{
$info['prefix'] = "<span style='{$style}'>";
$info['suffix'] = "</span>";
}
/* General Permissions */
foreach( $this->db->select( '*', 'xf_permission_entry', array( "user_group_id=?", $row['user_group_id'] ) ) AS $perm )
@@ -1040,17 +1062,32 @@ class _Xenforo extends \IPS\convert\Software
$libraryClass::setKey( 'xf_user.user_id' );
$it = $this->fetch( 'xf_user', 'xf_user.user_id' )
$it = iterator_to_array( $this->fetch( 'xf_user', 'xf_user.user_id' )
->join( 'xf_user_profile', 'xf_user.user_id = xf_user_profile.user_id' )
->join( 'xf_user_option', 'xf_user.user_id = xf_user_option.user_id' );
->join( 'xf_user_option', 'xf_user.user_id = xf_user_option.user_id' )
);
$userIds = array_column( $it, 'user_id' );
$passwords = iterator_to_array(
$this->db->select( 'user_id, data', 'xf_user_authenticate', array( $this->db->in( 'user_id', $userIds ) ) )
->setKeyField('user_id')
->setValueField('data')
);
$bans = iterator_to_array(
$this->db->select( 'user_id, max(end_date) as end_date', 'xf_user_ban', array( $this->db->in( 'user_id', $userIds ) ), NULL, NULL, 'user_id' )
->setKeyField('user_id')
->setValueField('end_date')
);
foreach( $it AS $row )
{
/* Fetch our password. XenForo supports multiple authentication types (XF, vB, SMF, etc.) so let's try and retain these as much as possible. */
try
{
$auth = $this->db->select( 'data', 'xf_user_authenticate', array( "user_id=?", $row['user_id'] ) )->first();
$data = \unserialize( $auth );
if( !isset( $passwords[ $row['user_id'] ] ) )
{
throw new \UnderflowException;
}
$data = \unserialize( $passwords[ $row['user_id'] ] );
if( !isset( $data['hash'] ) )
{
@@ -1130,7 +1167,12 @@ class _Xenforo extends \IPS\convert\Software
/* Ban */
try
{
$ban = $this->db->select( 'end_date', 'xf_user_ban', array( "user_id=?", $row['user_id'] ) )->first();
if( !isset( $bans[ $row['user_id'] ] ) )
{
throw new \UnderflowException;
}
$ban = $bans[ $row['user_id'] ];
if ( $ban == 0 )
{
@@ -1608,7 +1650,6 @@ class _Xenforo extends \IPS\convert\Software
}
$libraryClass->convertPrivateMessage( $topic, $maps );
$libraryClass->setLastKeyValue( $row['conversation_id'] );
}
}
@@ -0,0 +1,529 @@
<?php
/**
* @brief Converter Invision Community Class
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @package Invision Community
* @subpackage convert
* @since 13 July 2021
*/
namespace IPS\convert\Software\Downloads;
/* 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;
}
/**
* Invision Downloads Converter
*/
class _Invisioncommunity extends \IPS\convert\Software
{
/**
* @brief Whether the versions of IPS4 match
*/
public static $versionMatch = FALSE;
/**
* @brief Whether the database has been required
*/
public static $dbNeeded = FALSE;
/**
* Constructor
*
* @param \IPS\convert\App $app The application to reference for database and other information.
* @param bool $needDB Establish a DB connection
* @return void
* @throws \InvalidArgumentException
*/
public function __construct( \IPS\convert\App $app, $needDB = TRUE )
{
/* Set filename obscuring flag */
\IPS\convert\Library::$obscureFilenames = FALSE;
$return = parent::__construct( $app, $needDB );
if ( $needDB )
{
static::$dbNeeded = TRUE;
try
{
$version = $this->db->select( 'app_version', 'core_applications', array( 'app_directory=?', 'core' ) )->first();
/* We're matching against the human version since the long version can change with patches */
if ( $version == \IPS\Application::load( 'core' )->version )
{
static::$versionMatch = TRUE;
}
}
catch( \IPS\Db\Exception $e ) {}
/* Get parent sauce */
$this->parent = $this->app->_parent->getSource();
}
return $return;
}
/**
* Software Name
*
* @return string
*/
public static function softwareName()
{
/* Child classes must override this method */
return 'Invision Community (' . \IPS\Application::load( 'core' )->version . ')';
}
/**
* Software Key
*
* @return string
*/
public static function softwareKey()
{
/* Child classes must override this method */
return "invisioncommunity";
}
/**
* Content we can convert from this software.
*
* @return array
*/
public static function canConvert()
{
if ( !static::$versionMatch and static::$dbNeeded )
{
throw new \IPS\convert\Exception( 'convert_invision_mismatch' );
}
return array(
'convertDownloadsCategories' => array(
'table' => 'downloads_categories',
'where' => NULL,
),
'convertDownloadsCfields' => array(
'table' => 'downloads_cfields',
'where' => NULL,
),
'convertDownloadsComments' => array(
'table' => 'downloads_comments',
'where' => NULL,
),
'convertDownloadsFiles' => array(
'table' => 'downloads_files',
'where' => NULL,
),
'convertDownloadsReviews' => array(
'table' => 'downloads_reviews',
'where' => NULL,
),
'convertAttachments' => array(
'table' => 'core_attachments',
'where' => NULL,
)
);
}
/**
* Requires Parent
*
* @return boolean
*/
public static function requiresParent()
{
return TRUE;
}
/**
* Possible Parent Conversions
*
* @return array
*/
public static function parents()
{
return array( 'core' => array( 'invisioncommunity' ) );
}
/**
* List of conversion methods that require additional information
*
* @return array
*/
public static function checkConf()
{
return array(
'convertAttachments',
'convertDownloadsFiles'
);
}
/**
* Finish
*
* @return array Messages to display
*/
public function finish()
{
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\downloads\File', 'count' => 0 ), 4, array( 'class' ) );
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\downloads\Category', 'count' => 0 ), 5, array( 'class' ) );
\IPS\Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File', 'link' => 'downloads_files' ), 2, array( 'app', 'link', 'class' ) );
\IPS\Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File\Review', 'link' => 'downloads_reviews' ), 2, array( 'app', 'link', 'class' ) );
\IPS\Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File\Comment', 'link' => 'downloads_comments' ), 2, array( 'app', 'link', 'class' ) );
return array( );
}
/**
* Convert attachments
*
* @return void
*/
public function convertAttachments()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'attach_id' );
foreach( $this->fetch( 'core_attachments', 'attach_id' ) AS $row )
{
try
{
$attachmentMap = $this->db->select( '*', 'core_attachments_map', array( 'attachment_id=? AND location_key=?', $row['attach_id'], 'downloads_Downloads' ) )->first();
}
catch( \UnderflowException $e )
{
$libraryClass->setLastKeyValue( $row['attach_id'] );
continue;
}
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'core_attachments' );
$this->parent->unsetNonStandardColumns( $attachmentMap, 'core_attachments_map' );
/* Remap rows */
$name = explode( '/', $row['attach_location'] );
$row['attach_container'] = isset( $name[1] ) ? $name[0] : NULL;
$thumbName = explode( '/', $row['attach_thumb_location'] );
$row['attach_thumb_container'] = isset( $thumbName[1] ) ? $thumbName[0] : NULL;
$filePath = $this->app->_session['more_info']['convertAttachments']['upload_path'] . '/' . $row['attach_location'];
$thumbnailPath = $this->app->_session['more_info']['convertAttachments']['upload_path'] . '/' . $row['attach_thumb_location'];
unset( $row['attach_file'] );
$libraryClass->convertAttachment( $row, $attachmentMap, $filePath, NULL, $thumbnailPath );
$libraryClass->setLastKeyValue( $row['attach_id'] );
}
}
/**
* Get More Information
*
* @param string $method Method name
* @return array
*/
public function getMoreInfo( $method )
{
$return = array();
switch ( $method )
{
case 'convertAttachments':
case 'convertDownloadsFiles':
\IPS\Member::loggedIn()->language()->words["upload_path"] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input' );
\IPS\Member::loggedIn()->language()->words["upload_path_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input_desc' );
$return[ $method ] = array(
'upload_path' => array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => isset( $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] ) ? $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] : NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_path' ),
'field_validation' => function ( $value ) {
if ( !@is_dir( $value ) )
{
throw new \DomainException( 'path_invalid' );
}
},
)
);
break;
}
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
}
/**
* Convert downloads category
*
* @return void
*/
public function convertDownloadsCategories()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'cid' );
foreach( $this->fetch( 'downloads_categories', 'cid' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'downloads_categories', 'downloads' );
/* Add name after clearing other columns */
$row['cname'] = $this->parent->getWord( 'downloads_category_' . $row['cid'] );
$row['cdesc'] = $this->parent->getWord( 'downloads_category_' . $row['cid'] . '_desc' );
$id = $libraryClass->convertDownloadsCategory( $row );
if( !empty( $id ) )
{
/* Convert Follows */
foreach ( $this->db->select( '*', 'core_follow', array( 'follow_app=? AND follow_area=? AND follow_rel_id=?', 'downloads', 'category', $row['cid'] ) ) as $follow )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $follow, 'core_follow', 'core' );
/* Change follow data */
$follow['follow_rel_id_type'] = 'downloads_categories';
$libraryClass->convertFollow( $follow );
}
}
$libraryClass->setLastKeyValue( $row['cid'] );
}
}
/**
* Convert downloads fields
*
* @return void
*/
public function convertDownloadsCfields()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'cf_id' );
foreach( $this->fetch( 'downloads_cfields', 'cf_id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'downloads_cfields', 'downloads' );
/* Add name after clearing other columns */
$row['cf_name'] = $this->parent->getWord( 'downloads_field_' . $row['cf_id'] );
$row['cf_desc'] = $this->parent->getWord( 'downloads_field_' . $row['cid'] . '_desc' );
$libraryClass->convertDownloadsCfield( $row );
$libraryClass->setLastKeyValue( $row['cf_id'] );
}
}
/**
* Convert comments
*
* @return void
*/
public function convertDownloadsComments()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'comment_id' );
foreach( $this->fetch( 'downloads_comments', 'comment_id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'downloads_comments', 'downloads' );
$id = $libraryClass->convertDownloadsComment( $row );
if( !empty( $id ) )
{
/* Reputation */
foreach( $this->db->select( '*', 'core_reputation_index', array( "app=? AND type=? AND type_id=?", 'downloads', 'comment_id', $row['comment_id'] ) ) AS $rep )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $rep, 'core_reputation_index', 'core' );
$libraryClass->convertReputation( $rep );
}
}
$libraryClass->setLastKeyValue( $row['comment_id'] );
}
}
/**
* Convert downloads file
*
* @return void
*/
public function convertDownloadsFiles()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'file_id' );
foreach( $this->fetch( 'downloads_files', 'file_id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'downloads_files', 'downloads' );
$records = [];
foreach( $this->db->select( '*', 'downloads_files_records', [ 'record_file_id=?', $row['file_id'] ] ) as $record )
{
$record['file_path'] = $this->app->_session['more_info']['convertDownloadsFiles']['upload_path'] . '/' . $record['record_location'];
$records[] = $record;
}
$customFields = iterator_to_array( $this->db->select( '*', 'downloads_ccontent', [ 'file_id=?', $row['file_id'] ] ) );
$id = $libraryClass->convertDownloadsFile( $row, $records, $customFields );
if( !empty( $id ) )
{
/* Convert Follows */
foreach ( $this->db->select( '*', 'core_follow', array( 'follow_app=? AND follow_area=? AND follow_rel_id=?', 'downloads', 'file', $row['file_id'] ) ) as $follow )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $follow, 'core_follow', 'core' );
/* Change follow data */
$follow['follow_rel_id_type'] = 'downloads_file';
$libraryClass->convertFollow( $follow );
}
/* Convert Tags */
foreach ( $this->db->select( '*', 'core_tags', array( 'tag_meta_app=? AND tag_meta_area=? AND tag_meta_id=?', 'downloads', 'downloads', $row['file_id'] ) ) as $tag )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $tag, 'core_tags', 'core' );
$libraryClass->convertTag( $tag );
}
/* Reputation */
foreach( $this->db->select( '*', 'core_reputation_index', array( "app=? AND type=? AND type_id=?", 'downloads', 'file_id', $row['file_id'] ) ) AS $rep )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $rep, 'core_reputation_index', 'core' );
$libraryClass->convertReputation( $rep );
}
}
$libraryClass->setLastKeyValue( $row['file_id'] );
}
}
/**
* Convert reviews
*
* @return void
*/
public function convertDownloadsReviews()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'comment_id' );
foreach( $this->fetch( 'downloads_reviews', 'review_id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'downloads_reviews', 'downloads' );
$id = $libraryClass->convertDownloadsReview( $row );
if( !empty( $id ) )
{
/* Reputation */
foreach( $this->db->select( '*', 'core_reputation_index', array( "app=? AND type=? AND type_id=?", 'downloads', 'review_id', $row['review_id'] ) ) AS $rep )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $rep, 'core_reputation_index', 'core' );
$libraryClass->convertReputation( $rep );
}
}
$libraryClass->setLastKeyValue( $row['review_id'] );
}
}
/**
* Check if we can redirect the legacy URLs from this software to the new locations
*
* @return NULL|\IPS\Http\Url
*/
public function checkRedirects()
{
$url = \IPS\Request::i()->url();
if( !\stristr( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'ic-merge-' . $this->app->_parent->app_id ) )
{
return NULL;
}
/* account for non-mod_rewrite links */
$searchOn = \stristr( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'index.php' ) ? $url->data[ \IPS\Http\Url::COMPONENT_QUERY ] : $url->data[ \IPS\Http\Url::COMPONENT_PATH ];
if( preg_match( '#/(category|file)/([0-9]+)-(.+?)#i', $searchOn, $matches ) )
{
$oldId = (int) $matches[2];
switch( $matches[1] )
{
case 'category':
$class = '\IPS\downloads\Category';
$types = array( 'downloads_categories' );
break;
case 'file':
$class = '\IPS\downloads\File';
$types = array( 'downloads_files' );
break;
}
}
if( isset( $class ) )
{
try
{
try
{
$data = (string) $this->app->getLink( $oldId, $types );
}
catch( \OutOfRangeException $e )
{
$data = (string) $this->app->getLink( $oldId, $types, FALSE, TRUE );
}
$item = $class::load( $data );
if( $item instanceof \IPS\Content )
{
if( $item->canView() )
{
return $item->url();
}
}
elseif( $item instanceof \IPS\Node\Model )
{
if( $item->can( 'view' ) )
{
return $item->url();
}
}
}
catch( \Exception $e )
{
return NULL;
}
}
return NULL;
}
}
@@ -92,7 +92,7 @@ class _Xenforo extends \IPS\convert\Software
public static function softwareName()
{
/* Child classes must override this method */
return "XenForo Resource Manager (1.5.x/2.0.x/2.1.x)";
return "XenForo Resource Manager (1.5.x/2.0.x/2.1.x/2.2.x)";
}
/**
@@ -205,6 +205,8 @@ class _Xenforo extends \IPS\convert\Software
*/
public function finish()
{
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\downloads\File', 'count' => 0 ), 4, array( 'class' ) );
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\downloads\Category', 'count' => 0 ), 5, array( 'class' ) );
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File', 'link' => 'downloads_files' ), 2, array( 'app', 'link', 'class' ) );
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File\Review', 'link' => 'downloads_reviews' ), 2, array( 'app', 'link', 'class' ) );
@@ -52,13 +52,17 @@ class _Invisioncommunity extends \IPS\convert\Software
{
static::$dbNeeded = TRUE;
$version = $this->db->select( 'app_version', 'core_applications', array( 'app_directory=?', 'core' ) )->first();
/* We're matching against the human version since the long version can change with patches */
if( $version == \IPS\Application::load( 'core')->version )
try
{
static::$versionMatch = TRUE;
$version = $this->db->select( 'app_version', 'core_applications', array( 'app_directory=?', 'core' ) )->first();
/* We're matching against the human version since the long version can change with patches */
if ( $version == \IPS\Application::load( 'core' )->version )
{
static::$versionMatch = TRUE;
}
}
catch( \IPS\Db\Exception $e ) {}
/* Get parent sauce */
$this->parent = $this->app->_parent->getSource();
@@ -404,6 +404,7 @@ class _Mybb extends \IPS\convert\Software
'tag_meta_id' => $row['tid'],
'tag_text' => $prefix,
'tag_member_id' => $row['uid'],
'tag_added' => $row['dateline'],
'tag_prefix' => 1,
) );
}
@@ -471,7 +472,14 @@ class _Mybb extends \IPS\convert\Software
break;
case -1:
$queued = -1;
if( !$row['replyto'] )
{
$queued = 2; // First post in topic
}
else
{
$queued = -1;
}
break;
}
@@ -487,6 +495,12 @@ class _Mybb extends \IPS\convert\Software
'queued' => $queued,
'post_edit_reason' => $row['editreason'],
);
// Flag as first post in topic
if( $queued == 2 )
{
$info['new_topic'] = 1;
}
$libraryClass->convertForumsPost( $info );
@@ -506,6 +506,7 @@ class _Vanilla extends \IPS\convert\Software
'tag_meta_id' => $row['DiscussionID'],
'tag_text' => $spacedTag,
'tag_member_id' => $row['InsertUserID'],
'tag_added' => $info['start_date'],
'tag_prefix' => 0,
) );
}
@@ -565,6 +565,7 @@ class _Vbulletin extends \IPS\convert\Software
'tag_meta_id' => $topic['threadid'],
'tag_text' => $lang['text'],
'tag_member_id' => $topic['postuserid'],
'tag_added' => $info['start_date'],
'tag_prefix' => 1, # key to this whole operation right here
) );
}
@@ -585,6 +586,7 @@ class _Vbulletin extends \IPS\convert\Software
'tag_meta_id' => $topic['threadid'],
'tag_text' => $tag,
'tag_member_id' => $topic['postuserid'],
'tag_added' => $info['start_date'],
'tag_prefix' => 0,
) );
}
@@ -440,8 +440,48 @@ class _Vbulletin5 extends \IPS\convert\Software
);
unset( $poll );
$softDeleted = FALSE;
if ( $topic['deleteuserid'] )
{
$info['approved'] = -1;
$softDeleted = TRUE;
}
$topic_id = $libraryClass->convertForumsTopic( $info );
$topicId = $libraryClass->convertForumsTopic( $info );
/* post conversion things */
if( !empty( $topicId ) )
{
/* Record old vB 2/3/4 ID */
if ( !empty( $topic['oldid'] ) )
{
$this->app->addLink( $topicId, $topic['oldid'], 'forums_topics_old' );
}
/* Need to insert into the SDL? */
if ( $softDeleted )
{
try
{
$softDeleteId = $this->app->getLink( $topic['deleteuserid'], 'core_members', TRUE );
}
/* User link doesn't exist */
catch ( \OutOfRangeException $e )
{
$softDeleteId = 0;
}
\IPS\Db::i()->insert( 'core_soft_delete_log', array(
'sdl_obj_id' => $topicId,
'sdl_obj_key' => 'topic',
'sdl_obj_member_id' => $softDeleteId,
'sdl_obj_date' => $topic['unpublishdate'] ?: time(),
'sdl_obj_reason' => $topic['deletereason'] ?: NULL,
'sdl_locked' => 0
) );
}
}
$libraryClass->setLastKeyValue( $topic['nodeid'] );
}
@@ -560,102 +600,111 @@ LINK;
}
$post_id = $libraryClass->convertForumsPost( $info );
/* Need to insert into the SDL? */
if ( $softDeleted )
if( !empty( $post_id ) )
{
try
/* Record old vB 2/3/4 ID */
if( !empty( $post['oldid'] ) )
{
$softDeleteId = $this->app->getLink( $post['deleteuserid'], 'core_members', TRUE );
}
/* User link doesn't exist */
catch( \OutOfRangeException $e )
{
$softDeleteId = 0;
$this->app->addLink( $post_id, $post['oldid'], 'forums_posts_old' );
}
\IPS\Db::i()->insert( 'core_soft_delete_log', array(
'sdl_obj_id' => $post_id,
'sdl_obj_key' => 'post',
'sdl_obj_member_id' => $softDeleteId,
'sdl_obj_date' => $post['unpublishdate'] ?: time(),
'sdl_obj_reason' => $post['deletereason'] ?: NULL,
'sdl_locked' => 0
) );
}
/* Reputation */
foreach( $this->db->select( '*', 'reputation', array( "nodeid=?", $post['nodeid'] ) ) AS $rep )
{
$libraryClass->convertReputation( array(
'id' => $rep['reputationid'],
'app' => 'forums',
'type' => 'pid',
'type_id' => $post['nodeid'],
'member_id' => $rep['whoadded'],
'member_received' => $rep['userid'],
'rep_date' => $rep['dateline'],
'reaction' => $this->app->_session['more_info']['convertForumsPosts']['rep_like']
) );
}
/* Edit History */
$latestedit = 0;
$reason = NULL;
$name = NULL;
$newText = $post['rawtext'];
foreach( $this->db->select( '*', 'postedithistory', array( "nodeid=?", $post['nodeid'] ) ) AS $edit )
{
$libraryClass->convertEditHistory( array(
'id' => $edit['postedithistoryid'],
'class' => 'IPS\\forums\\Topic\\Post',
'comment_id' => $post['nodeid'],
'member' => $edit['userid'],
'time' => $edit['dateline'],
'old' => $edit['pagetext'],
'new' => $newText
) );
$newText = $edit['pagetext'];
if ( $edit['dateline'] > $latestedit )
/* Need to insert into the SDL? */
if ( $softDeleted )
{
$latestedit = $edit['dateline'];
$reason = $edit['reason'];
$name = $edit['username'];
}
}
/* Warnings */
foreach( $this->db->select( '*', 'infraction', array( "nodeid=?", $post['nodeid'] ) ) AS $warn )
{
$warnId = $libraryClass->convertWarnLog( array(
'wl_id' => $warn['infractionid'],
'wl_member' => $warn['nodeid'],
'wl_moderator' => $warn['whoadded'],
'wl_date' => $warn['dateline'],
'wl_points' => $warn['points'],
'wl_note_member' => $warn['note'],
'wl_note_mods' => $warn['customreason'],
) );
try
{
$softDeleteId = $this->app->getLink( $post['deleteuserid'], 'core_members', TRUE );
}
/* User link doesn't exist */
catch ( \OutOfRangeException $e )
{
$softDeleteId = 0;
}
/* Add a member history record for this member */
$libraryClass->convertMemberHistory( array(
'log_id' => 'w' . $warn['infractionid'],
'log_member' => $warn['userid'],
'log_by' => $warn['whoadded'],
'log_type' => 'warning',
'log_data' => array( 'wid' => $warnId ),
'log_date' => $warn['dateline']
)
);
}
/* If we have a latest edit, then update the main post - this should really be in the library, as the converters should not be altering data */
if ( $latestedit )
{
\IPS\Db::i()->update( 'forums_posts', array( 'append_edit' => 1, 'edit_time' => $latestedit, 'edit_name' => $name, 'post_edit_reason' => $reason ), array( "pid=?", $post_id ) );
\IPS\Db::i()->insert( 'core_soft_delete_log', array(
'sdl_obj_id' => $post_id,
'sdl_obj_key' => 'post',
'sdl_obj_member_id' => $softDeleteId,
'sdl_obj_date' => $post['unpublishdate'] ?: time(),
'sdl_obj_reason' => $post['deletereason'] ?: NULL,
'sdl_locked' => 0
) );
}
/* Reputation */
foreach ( $this->db->select( '*', 'reputation', array( "nodeid=?", $post['nodeid'] ) ) as $rep )
{
$libraryClass->convertReputation( array(
'id' => $rep['reputationid'],
'app' => 'forums',
'type' => 'pid',
'type_id' => $post['nodeid'],
'member_id' => $rep['whoadded'],
'member_received' => $rep['userid'],
'rep_date' => $rep['dateline'],
'reaction' => $this->app->_session['more_info']['convertForumsPosts']['rep_like']
) );
}
/* Edit History */
$latestedit = 0;
$reason = NULL;
$name = NULL;
$newText = $post['rawtext'];
foreach ( $this->db->select( '*', 'postedithistory', array( "nodeid=?", $post['nodeid'] ) ) as $edit )
{
$libraryClass->convertEditHistory( array(
'id' => $edit['postedithistoryid'],
'class' => 'IPS\\forums\\Topic\\Post',
'comment_id' => $post['nodeid'],
'member' => $edit['userid'],
'time' => $edit['dateline'],
'old' => $edit['pagetext'],
'new' => $newText
) );
$newText = $edit['pagetext'];
if ( $edit['dateline'] > $latestedit )
{
$latestedit = $edit['dateline'];
$reason = $edit['reason'];
$name = $edit['username'];
}
}
/* Warnings */
foreach ( $this->db->select( '*', 'infraction', array( "nodeid=?", $post['nodeid'] ) ) as $warn )
{
$warnId = $libraryClass->convertWarnLog( array(
'wl_id' => $warn['infractionid'],
'wl_member' => $warn['nodeid'],
'wl_moderator' => $warn['whoadded'],
'wl_date' => $warn['dateline'],
'wl_points' => $warn['points'],
'wl_note_member' => $warn['note'],
'wl_note_mods' => $warn['customreason'],
) );
/* Add a member history record for this member */
$libraryClass->convertMemberHistory( array(
'log_id' => 'w' . $warn['infractionid'],
'log_member' => $warn['userid'],
'log_by' => $warn['whoadded'],
'log_type' => 'warning',
'log_data' => array( 'wid' => $warnId ),
'log_date' => $warn['dateline']
)
);
}
/* If we have a latest edit, then update the main post - this should really be in the library, as the converters should not be altering data */
if ( $latestedit )
{
\IPS\Db::i()->update( 'forums_posts', array( 'append_edit' => 1, 'edit_time' => $latestedit, 'edit_name' => $name, 'post_edit_reason' => $reason ), array( "pid=?", $post_id ) );
}
}
$libraryClass->setLastKeyValue( $post['nodeid'] );
@@ -1027,6 +1076,99 @@ LINK;
{
$url = \IPS\Request::i()->url();
if(
( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'showthread.php' ) !== FALSE OR
mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'showpost.php' ) !== FALSE OR
preg_match( '#/threads/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ] )
)
AND ( isset( \IPS\Request::i()->p ) OR isset( \IPS\Request::i()->postid ) )
)
{
try
{
$postId = \IPS\Request::i()->postid ?? \IPS\Request::i()->p;
try
{
$data = (string) $this->app->getLink( $postId, array( 'forums_posts_old' ) );
}
catch( \OutOfRangeException $e )
{
/* Try the main table */
$data = (string) $this->app->getLink( $postId, array( 'forums_posts_old' ), FALSE, TRUE );
}
$item = \IPS\forums\Topic\Post::load( $data );
if( $item->canView() )
{
return $item->url();
}
}
catch( \Exception $e )
{
return NULL;
}
}
/* And then topic URLs, same idea */
elseif( ( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'showthread.php' ) !== FALSE OR
mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'printthread.php' ) !== FALSE )
AND ( isset( \IPS\Request::i()->t ) OR isset( \IPS\Request::i()->threadid ) )
)
{
/* Topic URLs.
* /showthread.php?t=1
* /printthread.php?t=1
* /showthread.php?threadid=?
* /printthread.php?threadid=?
*/
$path = $url->data[ \IPS\Http\Url::COMPONENT_PATH ];
if( mb_strpos( $path, 'showthread.php' ) !== FALSE OR mb_strpos( $path, 'printthread.php' ) !== FALSE )
{
if( isset( \IPS\Request::i()->t ) )
{
$oldId = \IPS\Request::i()->t;
}
elseif( isset( \IPS\Request::i()->threadid ) )
{
$oldId = \IPS\Request::i()->threadid;
}
elseif( preg_match( '#^(\d+)-[^/]+#i', $url->data[ \IPS\Http\Url::COMPONENT_QUERY ], $matches ) )
{
$oldId = $matches[1];
}
else
{
$queryStringPieces = explode( '-', mb_substr( $path, mb_strpos( $path, 'showthread.php/' ) + mb_strlen( 'showthread.php/' ) ) );
$oldId = $queryStringPieces[0];
}
}
if( isset( $oldId ) )
{
try
{
try
{
$data = (string) $this->app->getLink( $oldId, array( 'forums_topics_old' ) );
}
catch( \OutOfRangeException $e )
{
/* Try the main table */
$data = (string) $this->app->getLink( $oldId, array( 'forums_topics_old' ), FALSE, TRUE );
}
$item = \IPS\forums\Topic::load( $data );
if( $item->canView() )
{
return $item->url();
}
}
catch( \Exception $e )
{
return NULL;
}
}
}
if( preg_match( '#(?<!topic|file|image)/([0-9]+)\-([^/]*?)#', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
{
try
@@ -336,6 +336,7 @@ class _Woltlab extends \IPS\convert\Software
'tag_meta_id' => $row['threadID'],
'tag_text' => $text,
'tag_member_id' => $row['userID'],
'tag_added' => $info['start_date']
) );
}
@@ -271,6 +271,7 @@ class _Wpforo extends \IPS\convert\Software
'tag_meta_id' => $row['topicid'],
'tag_text' => $text,
'tag_member_id' => $row['userid'],
'tag_added' => $info['start_date']
] );
}
@@ -93,7 +93,7 @@ class _Xenforo extends \IPS\convert\Software
public static function softwareName()
{
/* Child classes must override this method */
return "XenForo (1.5.x/2.0.x/2.1.x)";
return "XenForo (1.5.x/2.0.x/2.1.x/2.2.x)";
}
/**
@@ -509,6 +509,7 @@ class _Xenforo extends \IPS\convert\Software
'tag_meta_id' => $row['thread_id'],
'tag_text' => $prefix,
'tag_member_id' => $row['user_id'],
'tag_added' => $row['post_date'],
'tag_prefix' => 1, # key to this whole operation right here
) );
}
@@ -529,6 +530,7 @@ class _Xenforo extends \IPS\convert\Software
'tag_meta_id' => $row['thread_id'],
'tag_text' => $tag['tag'],
'tag_member_id' => $row['user_id'],
'tag_added' => $row['post_date'],
'tag_prefix' => 0
) );
}
@@ -744,9 +746,9 @@ class _Xenforo extends \IPS\convert\Software
$post = \IPS\Db::i()->select( 'post', 'forums_posts', array( "pid=?", $pid ) )->first();
if ( preg_match( "/\[ATTACH([^\]]+?)?\]" . $row['attachment_id'] . "\[\/ATTACH\]/i", $post ) )
if ( preg_match( "/\[ATTACH([^\]]+?)?\]" . $row['attachment_id'] . "(\._xfImport)?\[\/ATTACH\]/i", $post ) )
{
$post = preg_replace( "/\[ATTACH([^\]]+?)?\]" . $row['attachment_id'] . "\[\/ATTACH\]/i", '[attachment=' . $attachId . ':name]', $post );
$post = preg_replace( "/\[ATTACH([^\]]+?)?\]" . $row['attachment_id'] . "(\._xfImport)?\[\/ATTACH\]/i", '[attachment=' . $attachId . ':name]', $post );
\IPS\Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
}
}
@@ -276,7 +276,8 @@ class _Coppermine extends \IPS\convert\Software
'tag_meta_id' => $row['pid'],
'tag_text' => $w,
'tag_prefix' => 0,
'tag_member_id' => $row['owner_id']
'tag_member_id' => $row['owner_id'],
'tag_added' => $row['ctime']
) );
}
}
@@ -0,0 +1,585 @@
<?php
/**
* @brief Converter Invision Community Class
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @package Invision Community
* @subpackage convert
* @since 13 July 2021
*/
namespace IPS\convert\Software\Gallery;
/* 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;
}
/**
* Invision Gallery Converter
*/
class _Invisioncommunity extends \IPS\convert\Software
{
/**
* @brief Whether the versions of IPS4 match
*/
public static $versionMatch = FALSE;
/**
* @brief Whether the database has been required
*/
public static $dbNeeded = FALSE;
/**
* Constructor
*
* @param \IPS\convert\App $app The application to reference for database and other information.
* @param bool $needDB Establish a DB connection
* @return void
* @throws \InvalidArgumentException
*/
public function __construct( \IPS\convert\App $app, $needDB = TRUE )
{
/* Set filename obscuring flag */
\IPS\convert\Library::$obscureFilenames = FALSE;
$return = parent::__construct( $app, $needDB );
if ( $needDB )
{
static::$dbNeeded = TRUE;
try
{
$version = $this->db->select( 'app_version', 'core_applications', array( 'app_directory=?', 'core' ) )->first();
/* We're matching against the human version since the long version can change with patches */
if ( $version == \IPS\Application::load( 'core' )->version )
{
static::$versionMatch = TRUE;
}
}
catch( \IPS\Db\Exception $e ) {}
/* Get parent sauce */
$this->parent = $this->app->_parent->getSource();
}
return $return;
}
/**
* Software Name
*
* @return string
*/
public static function softwareName()
{
/* Child classes must override this method */
return 'Invision Community (' . \IPS\Application::load( 'core' )->version . ')';
}
/**
* Software Key
*
* @return string
*/
public static function softwareKey()
{
/* Child classes must override this method */
return "invisioncommunity";
}
/**
* Content we can convert from this software.
*
* @return array
*/
public static function canConvert()
{
if( !static::$versionMatch AND static::$dbNeeded )
{
throw new \IPS\convert\Exception( 'convert_invision_mismatch' );
}
return array(
'convertGalleryAlbums' => array(
'table' => 'gallery_albums',
'where' => NULL,
),
'convertGalleryAlbumComments' => array(
'table' => 'gallery_album_comments',
'where' => NULL,
),
'convertGalleryAlbumReviews' => array(
'table' => 'gallery_album_reviews',
'where' => NULL,
),
'convertGalleryCategories' => array(
'table' => 'gallery_categories',
'where' => NULL,
),
'convertGalleryComments' => array(
'table' => 'gallery_comments',
'where' => NULL,
),
'convertGalleryImages' => array(
'table' => 'gallery_images',
'where' => NULL,
),
'convertGalleryReviews' => array(
'table' => 'gallery_reviews',
'where' => NULL,
),
'convertAttachments' => array(
'table' => 'core_attachments',
'where' => NULL,
)
);
}
/**
* Requires Parent
*
* @return boolean
*/
public static function requiresParent()
{
return TRUE;
}
/**
* Possible Parent Conversions
*
* @return array
*/
public static function parents()
{
return array( 'core' => array( 'invisioncommunity' ) );
}
/**
* List of conversion methods that require additional information
*
* @return array
*/
public static function checkConf()
{
return array(
'convertAttachments',
'convertGalleryImages'
);
}
/**
* Get More Information
*
* @param string $method Method name
* @return array
*/
public function getMoreInfo( $method )
{
$return = array();
switch( $method )
{
case 'convertAttachments':
case 'convertGalleryImages':
\IPS\Member::loggedIn()->language()->words["upload_path"] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input' );
\IPS\Member::loggedIn()->language()->words["upload_path_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input_desc' );
$return[ $method ] = array(
'upload_path' => array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => isset( $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] ) ? $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] : NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_invision_upload_path'),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
)
);
break;
}
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
}
/**
* Finish - Adds everything it needs to the queues and clears data store
*
* @return array Messages to display
*/
public function finish()
{
/* Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildGalleryImages', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
\IPS\Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'link' => 'gallery_comments', 'class' => 'IPS\gallery\Image\Comment' ), 2, array( 'app', 'link', 'class' ) );
\IPS\Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'link' => 'gallery_reviews', 'class' => 'IPS\gallery\Image\Review' ), 2, array( 'app', 'link', 'class' ) );
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\gallery\Image' ), 3, array( 'class' ) );
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Album', 'count' => 0 ), 4, array( 'class' ) );
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\gallery\Category', 'count' => 0 ), 5, array( 'class' ) );
/* Caches */
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'gallery_images', 'class' => 'IPS\gallery\Image' ), 3, array( 'app', 'link', 'class' ) );
return array( "f_gallery_images_rebuild", "f_gallery_cat_recount", "f_gallery_album_recount", "f_gallery_image_recount", "f_image_tags_recount" );
}
/**
* Convert attachments
*
* @return void
*/
public function convertAttachments()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'attach_id' );
foreach( $this->fetch( 'core_attachments', 'attach_id' ) AS $row )
{
try
{
$attachmentMap = $this->db->select( '*', 'core_attachments_map', array( 'attachment_id=? AND location_key=?', $row['attach_id'], 'gallery_Gallery' ) )->first();
}
catch( \UnderflowException $e )
{
$libraryClass->setLastKeyValue( $row['attach_id'] );
continue;
}
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'core_attachments' );
$this->parent->unsetNonStandardColumns( $attachmentMap, 'core_attachments_map' );
/* Remap rows */
$name = explode( '/', $row['attach_location'] );
$row['attach_container'] = isset( $name[1] ) ? $name[0] : NULL;
$thumbName = explode( '/', $row['attach_thumb_location'] );
$row['attach_thumb_container'] = isset( $thumbName[1] ) ? $thumbName[0] : NULL;
$filePath = $this->app->_session['more_info']['convertAttachments']['upload_path'] . '/' . $row['attach_location'];
$thumbnailPath = $this->app->_session['more_info']['convertAttachments']['upload_path'] . '/' . $row['attach_thumb_location'];
unset( $row['attach_file'] );
$libraryClass->convertAttachment( $row, $attachmentMap, $filePath, NULL, $thumbnailPath );
$libraryClass->setLastKeyValue( $row['attach_id'] );
}
}
/**
* Convert albums
*
* @return void
*/
public function convertGalleryAlbums()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'album_id' );
foreach( $this->fetch( 'gallery_albums', 'album_id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'gallery_albums', 'gallery' );
$id = $libraryClass->convertGalleryAlbum( $row );
if( !empty( $id ) )
{
/* Convert Follows */
foreach( $this->db->select( '*', 'core_follow', array( 'follow_app=? AND follow_area=? AND follow_rel_id=?', 'gallery', 'album', $row['album_id'] ) ) as $follow )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $follow, 'core_follow', 'core' );
/* Change follow data */
$follow['follow_rel_id_type'] = 'gallery_albums';
$libraryClass->convertFollow( $follow );
}
/* Reputation */
foreach( $this->db->select( '*', 'core_reputation_index', array( "app=? AND type=? AND type_id=?", 'gallery', 'album_id', $row['album_id'] ) ) AS $rep )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $rep, 'core_reputation_index', 'core' );
$libraryClass->convertReputation( $rep );
}
}
$libraryClass->setLastKeyValue( $row['album_id'] );
}
}
/**
* Convert album comments
*
* @return void
*/
public function convertGalleryAlbumComments()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'comment_id' );
foreach( $this->fetch( 'gallery_album_comments', 'comment_id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'gallery_album_comments', 'gallery' );
$id = $libraryClass->convertGalleryAlbumComment( $row );
if( !empty( $id ) )
{
/* Reputation */
foreach( $this->db->select( '*', 'core_reputation_index', array( "app=? AND type=? AND type_id=?", 'gallery', 'album_comment', $row['comment_id'] ) ) AS $rep )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $rep, 'core_reputation_index', 'core' );
$libraryClass->convertReputation( $rep );
}
}
$libraryClass->setLastKeyValue( $row['comment_id'] );
}
}
/**
* Convert album reviews
*
* @return void
*/
public function convertGalleryAlbumReviews()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'review_id' );
foreach( $this->fetch( 'gallery_album_reviews', 'review_id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'gallery_album_reviews', 'gallery' );
$id = $libraryClass->convertGalleryAlbumReview( $row );
if( !empty( $id ) )
{
/* Reputation */
foreach( $this->db->select( '*', 'core_reputation_index', array( "app=? AND type=? AND type_id=?", 'gallery', 'album_review', $row['review_id'] ) ) AS $rep )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $rep, 'core_reputation_index', 'core' );
$libraryClass->convertReputation( $rep );
}
}
$libraryClass->setLastKeyValue( $row['review_id'] );
}
}
/**
* Convert gallery category
*
* @return void
*/
public function convertGalleryCategories()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'category_id' );
foreach( $this->fetch( 'gallery_categories', 'category_id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'gallery_categories', 'gallery' );
/* Add name after clearing other columns */
$row['category_name'] = $this->parent->getWord( 'gallery_category_' . $row['category_id'] );
$row['category_desc'] = $this->parent->getWord( 'gallery_category_' . $row['category_id'] . '_desc' );
$id = $libraryClass->convertGalleryCategory( $row );
if( !empty( $id ) )
{
/* Convert Follows */
foreach ( $this->db->select( '*', 'core_follow', array( 'follow_app=? AND follow_area=? AND follow_rel_id=?', 'gallery', 'category', $row['category_id'] ) ) as $follow )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $follow, 'core_follow', 'core' );
/* Change follow data */
$follow['follow_rel_id_type'] = 'gallery_categories';
$libraryClass->convertFollow( $follow );
}
}
$libraryClass->setLastKeyValue( $row['category_id'] );
}
}
/**
* Convert comments
*
* @return void
*/
public function convertGalleryComments()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'comment_id' );
foreach( $this->fetch( 'gallery_comments', 'comment_id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'gallery_comments', 'gallery' );
$id = $libraryClass->convertGalleryComment( $row );
if( !empty( $id ) )
{
/* Reputation */
foreach( $this->db->select( '*', 'core_reputation_index', array( "app=? AND type=? AND type_id=?", 'gallery', 'comment_id', $row['comment_id'] ) ) AS $rep )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $rep, 'core_reputation_index', 'core' );
$libraryClass->convertReputation( $rep );
}
}
$libraryClass->setLastKeyValue( $row['comment_id'] );
}
}
/**
* Convert gallery images
*
* @return void
*/
public function convertGalleryImages()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'image_id' );
foreach( $this->fetch( 'gallery_images', 'image_id' ) AS $row )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $row, 'gallery_images', 'gallery' );
/* Remap rows */
$name = explode( '/', $row['image_original_file_name'] );
$row['image_container'] = isset( $name[1] ) ? $name[0] : NULL;
$filePath = $this->app->_session['more_info']['convertGalleryImages']['upload_path'] . '/' . $row['image_original_file_name'];
unset( $row['image_original_file_name'] );
$id = $libraryClass->convertGalleryImage( $row, $filePath );
if( !empty( $id ) )
{
/* Convert Follows */
foreach ( $this->db->select( '*', 'core_follow', array( 'follow_app=? AND follow_area=? AND follow_rel_id=?', 'gallery', 'image', $row['image_id'] ) ) as $follow )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $follow, 'core_follow', 'core' );
/* Change follow data */
$follow['follow_rel_id_type'] = 'gallery_images';
$libraryClass->convertFollow( $follow );
}
/* Convert Tags */
foreach ( $this->db->select( '*', 'core_tags', array( 'tag_meta_app=? AND tag_meta_area=? AND tag_meta_id=?', 'gallery', 'gallery', $row['image_id'] ) ) as $tag )
{
/* Remove non-standard columns */
$this->parent->unsetNonStandardColumns( $tag, 'core_tags', 'core' );
$libraryClass->convertTag( $tag );
}
}
$libraryClass->setLastKeyValue( $row['image_id'] );
}
}
/**
* Check if we can redirect the legacy URLs from this software to the new locations
*
* @return NULL|\IPS\Http\Url
*/
public function checkRedirects()
{
$url = \IPS\Request::i()->url();
if( !\stristr( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'ic-merge-' . $this->app->_parent->app_id ) )
{
return NULL;
}
/* account for non-mod_rewrite links */
$searchOn = \stristr( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'index.php' ) ? $url->data[ \IPS\Http\Url::COMPONENT_QUERY ] : $url->data[ \IPS\Http\Url::COMPONENT_PATH ];
if( preg_match( '#/(category|album|image)/([0-9]+)-(.+?)#i', $searchOn, $matches ) )
{
$oldId = (int) $matches[2];
switch( $matches[1] )
{
case 'category':
$class = '\IPS\gallery\Category';
$types = array( 'gallery_categories' );
break;
case 'album':
$class = '\IPS\gallery\Album';
$types = array( 'gallery_albums' );
break;
case 'image':
$class = '\IPS\gallery\Image';
$types = array( 'gallery_images' );
break;
}
}
if( isset( $class ) )
{
try
{
try
{
$data = (string) $this->app->getLink( $oldId, $types );
}
catch( \OutOfRangeException $e )
{
$data = (string) $this->app->getLink( $oldId, $types, FALSE, TRUE );
}
$item = $class::load( $data );
if( $item instanceof \IPS\Content )
{
if( $item->canView() )
{
return $item->url();
}
}
elseif( $item instanceof \IPS\Node\Model )
{
if( $item->can( 'view' ) )
{
return $item->url();
}
}
}
catch( \Exception $e )
{
return NULL;
}
}
return NULL;
}
}
@@ -89,7 +89,7 @@ class _Xenforo extends \IPS\convert\Software
public static function softwareName()
{
/* Child classes must override this method */
return "XenForo Media Gallery (1.5.x/2.0.x/2.1.x)";
return "XenForo Media Gallery (1.5.x/2.0.x/2.1.x/2.2.x)";
}
/**
@@ -710,7 +710,8 @@ class _Xenforo extends \IPS\convert\Software
'tag_meta_id' => $row['media_id'],
'tag_text' => isset( $tag['tag_clean'] ) ? $tag['tag_clean'] : $tag['tag'], // Select 1.0 or 1.1 version
'tag_prefix' => 0,
'tag_member_id' => $row['user_id']
'tag_member_id' => $row['user_id'],
'tag_added' => $row['media_date']
) );
}
}