Version 5.0.6

This commit is contained in:
Neo committed 2025-12-19 18:55:49 -08:00
1 parent a3a4a9ccbd
commit b89858b2ff
1214 files changed
+92828 -14859

No files matched your search

@@ -212,14 +212,15 @@ class Vbulletin extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return VbulletinClass::fixPostData( $post, $className, $contentId );
return VbulletinClass::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -14,6 +14,7 @@ namespace IPS\convert\Software\Calendar;
/* To prevent PHP errors (extending class does not exist) revealing path */
use IPS\calendar\Date;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Software\Core\Vbulletin as VbulletinClass;
use IPS\Task;
@@ -108,14 +109,15 @@ class Vbulletin extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return VbulletinClass::fixPostData( $post, $className, $contentId );
return VbulletinClass::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -210,14 +210,15 @@ class Vbulletin extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return VbulletinClass::fixPostData( $post, $className, $contentId );
return VbulletinClass::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -17,6 +17,7 @@ use DomainException;
use Exception;
use IPS\Application\Module;
use IPS\Content\Search\Index;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\Data\Cache;
use IPS\Data\Store;
@@ -166,12 +167,13 @@ class Expressionengine extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return nl2br( $post );
}
@@ -17,6 +17,7 @@ use DomainException;
use Exception;
use IPS\Application\Module;
use IPS\Content\Search\Index;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\Data\Cache;
use IPS\Data\Store;
@@ -318,12 +319,13 @@ class Mybb extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
/* Replace align tags with left/right/center/justify */
$post = preg_replace( '/\[align=(justify|left|center|right)\](.+?)\[\/align\]/i', '[$1]$2[/$1]', $post );
@@ -19,6 +19,7 @@ use Exception;
use IPS\Application\Module;
use IPS\Content\Search\Index;
use IPS\convert\Login\HashCryptPrivate;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\core\Ignore;
use IPS\Data\Cache;
@@ -390,12 +391,13 @@ class Phpbb extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
/* Convert newlines to <br> tags */
$post = nl2br( $post );
@@ -16,6 +16,7 @@ namespace IPS\convert\Software\Core;
use Exception;
use IPS\Application\Module;
use IPS\Content\Search\Index;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\Data\Cache;
use IPS\Data\Store;
@@ -206,12 +207,13 @@ class Punbb extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
$post = nl2br( $post );
@@ -16,6 +16,7 @@ use DomainException;
use Exception;
use IPS\Application\Module;
use IPS\Content\Search\Index;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\core\Ignore;
use IPS\Data\Cache;
@@ -335,12 +336,13 @@ class Smf extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
// Replace BBCode - The table HTML is removed by our parser, but it leaves the posts cleaner than having unparsed bbcode
$search = array( '[li]', '[/li]', '[table]', '[/table]', '[tr]', '[/tr]', '[td]', '[/td]', '[tt]', '[/tt]' );
@@ -16,6 +16,7 @@ use DomainException;
use Exception;
use IPS\Application\Module;
use IPS\Content\Search\Index;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Software\Exception as SoftwareException;
use IPS\core\Ignore;
@@ -380,12 +381,13 @@ class UBBthreads extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
$post = preg_replace( "#\[quote=(.+?)\]#i", "[quote name=\"$1\"]", $post );
$post = preg_replace( '#\[img:(left|center|right)\](.+?)\[\/img\]#i', '[$1][img]$2[/img][/$1]', $post );
@@ -14,7 +14,9 @@ namespace IPS\convert\Software\Core;
use DateTimeZone;
use erusev\Parsedown;
use IPS\Application;
use IPS\Content\Search\Index;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\Data\Cache;
use IPS\Data\Store;
@@ -45,6 +47,81 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class Vanilla extends Software
{
/**
* Constructor
*
* @param 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( App $app, bool $needDB=TRUE )
{
parent::__construct( $app, $needDB );
/* Check for temp table */
if ( $needDB )
{
if( !Db::i()->checkForTable( 'convert_vanilla_temp' ) )
{
Db::i()->createTable( array(
'name' => 'convert_vanilla_temp',
'columns' => array(
'id' => array(
'name' => 'id',
'type' => 'int',
'length' => 10,
'allow_null' => false,
'auto_increment' => true
),
'media_id' => array(
'name' => 'media_id',
'type' => 'int',
'length' => 10,
'allow_null' => false,
'auto_increment' => false
),
'link_type' => array(
'name' => 'link_type',
'type' => 'varchar',
'length' => 255,
'allow_null' => true,
'default' => null
),
'content_id' => array(
'name' => 'content_id',
'type' => 'int',
'length' => 10,
'allow_null' => false,
'default' => 0
),
'post_id' => array(
'name' => 'post_id',
'type' => 'int',
'length' => 10,
'allow_null' => false,
'default' => 0
),
),
'indexes' => array(
'PRIMARY' => array(
'type' => 'primary',
'name' => 'PRIMARY',
'columns' => array( 'id', 'media_id' ),
'length' => array( NULL )
),
'lookup' => array(
'type' => 'index',
'name' => 'lookup',
'columns' => array( 'media_id', 'link_type' ),
'length' => array( NULL, NULL )
),
)
) );
}
}
}
/**
* Software Name
*
@@ -198,6 +275,10 @@ class Vanilla extends Software
'convertPrivateMessageReplies' => array(
'table' => 'ConversationMessage',
'where' => NULL,
),
'convertAttachments' => array(
'table' => 'Media',
'where' => [ "ForeignTable IN ('embed')" ]
)
);
}
@@ -316,6 +397,9 @@ class Vanilla extends Software
/* Attachments */
Task::queue( 'core', 'RebuildAttachmentThumbnails', array( 'app' => $this->app->app_id ), 1, array( 'app' ) );
/* Remove temp table */
Db::i()->dropTable('convert_vanilla_temp');
return array( "f_search_index_rebuild", "f_clear_caches", "f_rebuild_pms", "f_signatures_rebuild", "f_rebuild_attachments" );
}
@@ -327,12 +411,13 @@ class Vanilla extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
/* Is this Markdown? */
if( mb_substr( $post, 0, 15 ) == '<!--Markdown-->' )
@@ -347,67 +432,57 @@ class Vanilla extends Software
$post = str_replace( '<!--Markdown-->', '', $post );
$post = static::$_parseDown->text( $post );
}
elseif( mb_substr( $post, 0, 3 ) == '[{"' ) // Probably a delta
/* If rich, we've already processed it, but need to skip the legacy formatting */
elseif( mb_substr( $post, 0, 11 ) == '<!--Rich-->' )
{
$postData = str_replace( [ "\r\n","\n" ], '', $post );
$postData = json_decode( $postData, TRUE );
$post = str_replace( '<!--Rich-->', '', $post );
}
/* Deltas still tha haven't been previously processed */
elseif( mb_substr( $post, 0, 3 ) == '[{"' )
{
$post = static::processQuill( $post, $app );
}
/* LEGACY CONVERSIONS BELOW FOR OLDER CONTENT */
else
{
/* Mentions */
$matches = [];
preg_match_all( '/@("|&quot;)([^@"]+)("|&quot;)/i', $post, $matches );
$post = '';
foreach( $postData as $data )
if( count( $matches ) )
{
if( is_array( $data['insert'] ) )
foreach( $matches[0] as $key => $tag )
{
switch ( $data['insert']['embed-external']['data']['embedType'] )
$member = Member::load( $matches[2][ $key ], 'name' );
if( !$member->member_id )
{
case 'quote':
$post .= '[quote name="' . $data['insert']['embed-external']['data']['insertUser']['name'] . '" timestamp="' . strtotime( $data['insert']['embed-external']['data']['dateInserted'] ) . '"]' . $data['insert']['embed-external']['data']['body'] . "[/quote]";
break;
continue;
}
}
else
{
$post .= $data['insert'] . "<br>";
$post = str_replace( $tag, "[mention={$member->member_id}]{$member->name}[/mention]", $post );
}
}
/**
* Vanilla has a quotes plugin that seems to have changed formats quite often. - We'll try to match as many formats as we can
*/
$post = preg_replace( '/(?:<blockquote\s+(?:class=\"(?:User)?Quote\")?(?:\s+rel=\"(?:[^\"]+)\")?>)(?:\s+)?<div class=\"QuoteAuthor\">([^\"]+)<\/div>(?:\s+)?<div class=\"QuoteText\">(?:<p>)?(.*?)(?:<\/p>)?<\/div>(?:\s+)?<\/blockquote>/i',
'[quote name="$1"]$2[/quote]' ,
$post );
$post = preg_replace( '/(?:<blockquote\s+(?:class=\"Quote (?:User)?Quote\")?(?:\s+rel=\"(?:[^\"]+)\")?>)(?:\s+)?<div class=\"QuoteText\">(?:<p>)?(.*?)(?:<\/p>)?<\/div>(?:\s+)?<\/blockquote>/i',
'[quote]$1[/quote]' ,
$post );
$post = preg_replace( '/<blockquote\s+rel=\"([^\"]+)\"?>(.*?)<\/blockquote>/i',
'[quote name="$1"]$2[/quote]' ,
$post );
$post = preg_replace( '/<blockquote>(.*?)<\/blockquote>/ims',
'[quote]$1[/quote]' ,
$post );
}
/* Mentions */
$matches = [];
preg_match_all( '/@("|&quot;)([^@"]+)("|&quot;)/i', $post, $matches );
if( count( $matches ) )
{
foreach( $matches[0] as $key => $tag )
{
$member = Member::load( $matches[2][ $key ], 'name' );
if( !$member->member_id )
{
continue;
}
$post = str_replace( $tag, "[mention={$member->member_id}]{$member->name}[/mention]", $post );
}
}
/**
* Vanilla has a quotes plugin that seems to have changed formats quite often. - We'll try to match as many formats as we can
*/
$post = preg_replace( '/(?:<blockquote\s+(?:class=\"(?:User)?Quote\")?(?:\s+rel=\"(?:[^\"]+)\")?>)(?:\s+)?<div class=\"QuoteAuthor\">([^\"]+)<\/div>(?:\s+)?<div class=\"QuoteText\">(?:<p>)?(.*?)(?:<\/p>)?<\/div>(?:\s+)?<\/blockquote>/i',
'[quote name="$1"]$2[/quote]' ,
$post );
$post = preg_replace( '/(?:<blockquote\s+(?:class=\"Quote (?:User)?Quote\")?(?:\s+rel=\"(?:[^\"]+)\")?>)(?:\s+)?<div class=\"QuoteText\">(?:<p>)?(.*?)(?:<\/p>)?<\/div>(?:\s+)?<\/blockquote>/i',
'[quote]$1[/quote]' ,
$post );
$post = preg_replace( '/<blockquote\s+rel=\"([^\"]+)\"?>(.*?)<\/blockquote>/i',
'[quote name="$1"]$2[/quote]' ,
$post );
$post = preg_replace( '/<blockquote>(.*?)<\/blockquote>/ims',
'[quote]$1[/quote]' ,
$post );
return $post;
}
@@ -458,11 +533,15 @@ class Vanilla extends Software
$uploadsPath = $this->app->_session['more_info']['convertMembers']['attach_location'];
$users = $this->fetch( array( 'User', 'u' ), 'u.UserID', array( "u.Deleted<>?", 1 ), 'u.*, ur.RoleID' );
$users->join( array( 'UserRole', 'ur' ), 'ur.UserID=u.UserID' );
$users = $this->fetch( array( 'User', 'u' ), 'u.UserID', array( "u.Deleted<>?", 1 ) );
$data = iterator_to_array( $users );
$this->app->preCacheLinks( $data, [ 'core_groups' => 'RoleID' ] );
$userIds = array_column( $data, 'UserID' );
$roles = array_fill_keys( $userIds, [] );
foreach( $this->db->select( '*', 'UserRole', [ $this->db->in( 'UserID', $userIds ) ] ) as $role )
{
$roles[ $role['UserID'] ][] = $role['RoleID'];
}
foreach( $data AS $row )
{
@@ -482,22 +561,54 @@ class Vanilla extends Software
/* Work out banned stuff */
$tempBan = ( $row['Banned'] == 1 ) ? -1 : 0;
/* Get IP */
try
{
$ipAddress = ( $row['InsertIPAddress'] AND !str_contains( $row['InsertIPAddress'], '.' ) ) ? long2ip( hexdec( bin2hex( $row['InsertIPAddress'] ) ) ) : $row['InsertIPAddress'];
}
catch( \ErrorException $e )
{
$ipAddress = '';
}
if( !empty( $row['RoleID'] ) )
{
array_unshift( $roles[ $row['UserID'] ], $row['RoleID'] );
}
$allRoles = array_unique( $roles[ $row['UserID'] ] );
$primaryRole = NULL;
$secondaryRoles = [];
/* Find a primary role. */
if( count( $allRoles ) )
{
$primaryRole = array_shift( $allRoles );
}
/* Any remaining roles will be secondary */
if( count( $allRoles ) )
{
$secondaryRoles = $allRoles;
}
/* Array of basic data */
$info = array(
'member_id' => $row['UserID'],
'email' => $row['Email'],
'name' => $row['Name'],
'password' => $row['Password'],
'member_group_id' => $row['RoleID'] ?: NULL,
'member_group_id' => $primaryRole,
'mgroup_others' => $secondaryRoles,
'joined' => static::mysqlToDateTime( $row['DateInserted'] ),
'ip_address' => $row['InsertIPAddress'],
'ip_address' => $ipAddress,
'temp_ban' => $tempBan,
'bday_day' => $bdayDay,
'bday_month' => $bdayMonth,
'bday_year' => $bdayYear,
'msg_count_new' => (int) $row['CountUnreadDiscussions'],
'msg_count_total' => (int) $row['CountDiscussions'],
'last_visit' => static::mysqlToDateTime( $row['DateLastActive'] ),
'last_visit' => $row['DateLastActive'] ? static::mysqlToDateTime( $row['DateLastActive'] ) : NULL,
'timezone' => !empty( $row['HourOffset'] )
? (int) $row['HourOffset']
: new DateTimeZone(
@@ -570,10 +681,10 @@ class Vanilla extends Software
{
$maps[ $r['UserID'] ] = array(
'map_user_id' => $r['UserID'],
'map_read_time' => static::mysqlToDateTime( $r['DateLastViewed'] ),
'map_read_time' => $r['DateLastViewed'] ? static::mysqlToDateTime( $r['DateLastViewed'] ) : NULL,
//'map_folder_id' => TODO: Create a Bookmarks folder for "Bookmarked" conversations?
'map_user_active' => $r['Deleted'] == 0 ? 1 : 0,
'map_last_topic_reply' => static::mysqlToDateTime( $r['DateConversationUpdated'] )
'map_last_topic_reply' => $r['DateConversationUpdated'] ? static::mysqlToDateTime( $r['DateConversationUpdated'] ) : NULL
);
}
@@ -602,6 +713,20 @@ class Vanilla extends Software
{
$row['Body'] = '<!--Markdown-->' . $row['Body'];
}
elseif( $row['Format'] == 'Rich' )
{
$row['Body'] = static::processQuill( $row['Body'], $this->app, 'core_message_posts', $row['ConversationID'], $row['MessageID'] );
}
/* Get IP */
try
{
$ipAddress = ( $row['InsertIPAddress'] AND !str_contains( $row['InsertIPAddress'], '.' ) ) ? long2ip( hexdec( bin2hex( $row['InsertIPAddress'] ) ) ) : $row['InsertIPAddress'];
}
catch( \ErrorException $e )
{
$ipAddress = '';
}
$libraryClass->convertPrivateMessageReply( array(
'msg_id' => $row['MessageID'],
@@ -609,13 +734,106 @@ class Vanilla extends Software
'msg_date' => static::mysqlToDateTime( $row['DateInserted'] ),
'msg_post' => $row['Body'],
'msg_author_id' => $row['InsertUserID'],
'msg_ip_address' => $row['InsertIPAddress']
'msg_ip_address' => $ipAddress
) );
$libraryClass->setLastKeyValue( $row['MessageID'] );
}
}
/**
* @brief temporarily store post content
*/
protected array $_postContent = array();
/**
* Convert attachments
*
* @return void
*/
public function convertAttachments(): void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'MediaID' );
$this->_postContent = [];
foreach( $this->fetch( 'Media', 'MediaID', [ $this->db->in( 'ForeignTable', [ 'embed' ] ) ] ) AS $row )
{
$mediaRows = iterator_to_array(
\IPS\Db::i()->select(
'*',
'convert_vanilla_temp',
[ 'media_id=? AND ' . \IPS\Db::i()->in( 'link_type', [ 'core_message_posts' ] ), $row['MediaID'] ]
) );
// Nothing to do, attachment must be in another content type
if( !count( $mediaRows ) )
{
$libraryClass->setLastKeyValue( $row['MediaID'] );
continue;
}
$map = [
'id1' => $mediaRows[0]['content_id'],
'id2' => $mediaRows[0]['post_id']
];
$map['id1_type'] = 'core_message_topics';
$map['id2_type'] = 'core_message_posts';
$map['location_key'] = 'core_Messaging';
$map['id1_from_parent'] = FALSE;
$map['id2_from_parent'] = FALSE;
$map['id3_skip_link'] = TRUE;
/* File extension */
$ext = explode( '.', $row['Path'] );
$ext = array_pop( $ext );
$info = array(
'attach_id' => $row['MediaID'],
'attach_file' => $row['Name'],
'attach_date' => static::mysqlToDateTime( $row['DateInserted'] ),
'attach_member_id' => $row['InsertUserID'],
'attach_hits' => 0,
'attach_ext' => $ext,
'attach_filesize' => $row['Size'],
);
$uploadPath = static::parseMediaLocation( $row['Path'], $this->app->_session['more_info']['convertMembers']['attach_location'] );
$attachId = $libraryClass->convertAttachment( $info, $map, $uploadPath );
/* Do some re-jiggery on the post itself to make sure attachment displays */
if ( $attachId !== FALSE )
{
foreach( $mediaRows as $mediaRow )
{
try
{
$pid = $this->app->getLink( $map['id2'], 'core_message_posts' );
if( !isset( $this->_postContent[ $pid ] ) )
{
$this->_postContent[ $pid ] = Db::i()->select( 'msg_post', 'core_message_posts', array( "msg_id=?", $pid ) )->first();
}
$this->_postContent[ $pid ] = str_replace( "[ATTACH={$row['MediaID']}]", '[attachment=' . $attachId . ':name]', $this->_postContent[ $pid ] );
}
catch( UnderflowException|OutOfRangeException $e ) {}
}
}
unset( $mediaRows );
$libraryClass->setLastKeyValue( $row['MediaID'] );
}
/* Do the updates */
foreach( $this->_postContent as $pid => $content )
{
Db::i()->update( 'core_message_posts', array( 'msg_post' => $content ), array( 'msg_id=?', $pid ) );
}
}
/**
* Process a login
*
@@ -642,4 +860,38 @@ class Vanilla extends Software
return FALSE;
}
}
public static function processQuill( string $postJson, ?App $app=null, ?string $type=null, ?int $contentId=null, ?int $commentId=null ): string
{
/* Need to wrap so it's an expected format */
$post = '{"ops":' . $postJson . '}';
if ( strpos( $post, '"header":' ) !== false )
{
$post = preg_replace('/{"header":{"level":(\d+),"ref":"([^"]*)"}}/', '{"header":$1}', $post );
}
$data = json_decode( $post, true );
if ( !isset( $data['ops'][ count( $data['ops'] ) - 1 ]['insert'] ) OR is_array( $data['ops'][ count( $data['ops'] ) - 1 ]['insert'] ) OR \substr( $data['ops'][ count( $data['ops'] ) - 1 ]['insert'], -1 ) !== "\n" )
{
$data['ops'][] = [ "insert" => "\n" ];
}
/* Get the autoloader for the Quill library */
require_once Application::load( 'convert' )->getApplicationPath() . '/sources/Tools/Quill/vendor/autoload.php';
$lexer = new \nadar\quill\Lexer( $data );
$lexer->registerListener( new \IPS\convert\Tools\Vanilla\QuillListeners\Emoji() );
$lexer->registerListener( new \IPS\convert\Tools\Vanilla\QuillListeners\EmbedExternal( $type, $contentId, $commentId ) );
$lexer->registerListener( new \IPS\convert\Tools\Vanilla\QuillListeners\Mention( $app ) );
try
{
return '<!--Rich-->' . $lexer->render();
}
catch( \ErrorException $e )
{
return $postJson;
}
}
}
@@ -618,12 +618,13 @@ class Vbulletin extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
if( preg_match( "#\[sigpic]#i", $post ) )
{
@@ -553,12 +553,13 @@ class Vbulletin5 extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
/* IMG2 BBcode - Needs to be ran before htmlspecialchars due to it containing JSON */
$matches = array();
@@ -15,6 +15,7 @@ namespace IPS\convert\Software\Core;
use DomainException;
use IPS\Content\Search\Index;
use IPS\convert\App;
use IPS\convert\Exception;
use IPS\convert\Software;
use IPS\Data\Cache;
@@ -360,12 +361,13 @@ class Woltlab extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return $post;
}
@@ -14,6 +14,7 @@ namespace IPS\convert\Software\Core;
/* To prevent PHP errors (extending class does not exist) revealing path */
use IPS\Content\Search\Index;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\Data\Cache;
use IPS\Data\Store;
@@ -110,12 +111,13 @@ class Wordpress extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return nl2br( $post );
}
@@ -17,6 +17,7 @@ use DomainException;
use Exception;
use IPS\Application\Module;
use IPS\Content\Search\Index;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\Data\Cache;
use IPS\Data\Store;
@@ -139,12 +140,13 @@ class Wpforo extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
/* Mentions */
$matches = [];
@@ -563,12 +563,13 @@ class Xenforo extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
// run everything through htmlspecialchars to prevent XSS
$post = htmlspecialchars( $post, ENT_DISALLOWED | ENT_QUOTES, 'UTF-8', FALSE );
@@ -16,6 +16,7 @@ namespace IPS\convert\Software\Forums;
use DomainException;
use Exception;
use IPS\Content;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Software\Core\Expressionengine as ExpressionEngineCore;
use IPS\Db;
@@ -197,14 +198,15 @@ class Expressionengine extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId Content ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return ExpressionEngineCore::fixPostData( $post, $className, $contentId );
return ExpressionEngineCore::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -215,7 +217,6 @@ class Expressionengine extends Software
public function convertForumsForums() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'forum_id' );
foreach( $this->fetch( 'exp_forums', 'forum_id' ) AS $row )
@@ -226,12 +227,8 @@ class Expressionengine extends Software
'description' => $row['forum_description'],
'topics' => $row['forum_total_topics'],
'posts' => $row['forum_total_posts'],
'last_post' => $row['forum_last_post_date'],
'last_poster_id' => $row['forum_last_post_author_id'],
'last_poster_name' => $row['forum_last_post_author'],
'parent_id' => ( $row['forum_parent'] == 0 ) ? -1 : $row['forum_parent'],
'position' => $row['forum_order'],
'last_title' => $row['forum_last_post_title'],
'allow_poll' => 1,
'inc_postcount' => 1,
'sub_can_post' => 1,
@@ -16,6 +16,7 @@ namespace IPS\convert\Software\Forums;
use DomainException;
use Exception;
use IPS\Content;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Software\Core\Mybb as MybbCore;
use IPS\Db;
@@ -209,14 +210,15 @@ class Mybb extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId Content ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return MybbCore::fixPostData( $post, $className, $contentId );
return MybbCore::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -227,7 +229,6 @@ class Mybb extends Software
public function convertForumsForums(): void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'fid' );
foreach( $this->fetch( 'forums', 'fid' ) AS $row )
@@ -238,13 +239,9 @@ class Mybb extends Software
'description' => $row['description'],
'topics' => $row['threads'],
'posts' => $row['posts'],
'last_post' => $row['lastpost'],
'last_poster_id' => $row['lastposteruid'],
'last_poster_name' => $row['lastposter'],
'parent_id' => $row['pid'] ?: -1,
'position' => $row['disporder'],
'password' => $row['password'] ?: NULL,
'last_title' => $row['lastpostsubject'],
'inc_postcount' => $row['usepostcounts'],
'redirect_url' => $row['linkto'],
'sub_can_post' => ( $row['type'] == 'c' ) ? 0 : 1,
@@ -16,6 +16,7 @@ namespace IPS\convert\Software\Forums;
use DomainException;
use Exception;
use IPS\Content;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Software\Core\Phpbb as PhpbbCore;
use IPS\Db;
@@ -192,14 +193,15 @@ class Phpbb extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId Content ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return PhpbbCore::fixPostData( $post, $className, $contentId );
return PhpbbCore::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -210,7 +212,6 @@ class Phpbb extends Software
public function convertForumsForums(): void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'forum_id' );
foreach( $this->fetch( 'forums', 'forum_id' ) AS $row )
@@ -221,14 +222,10 @@ class Phpbb extends Software
'description' => $row['forum_desc'],
'topics' => $row['forum_topics_approved'] ?? $row['forum_topics'],
'posts' => $row['forum_posts_approved'] ?? $row['forum_posts'],
'last_post' => $row['forum_last_post_time'],
'last_poster_id' => $row['forum_last_poster_id'],
'last_poster_name' => $row['forum_last_poster_name'],
'parent_id' => ( $row['parent_id'] != 0 ) ? $row['parent_id'] : -1,
'conv_parent' => ( $row['parent_id'] != 0 ) ? $row['parent_id'] : -1,
'position' => $row['left_id'],
'password' => ( isset( $this->app->_session['more_info']['convertForumsForums']["forum_password_{$row['forum_id']}"] ) ) ? $this->app->_session['more_info']['convertForumsForums']["forum_password_{$row['forum_id']}"] : NULL,
'last_title' => $row['forum_last_post_subject'],
'queued_topics' => $row['forum_topics_unapproved'] ?? 0,
'queued_posts' => isset( $row['forum_posts_unapproved'] ) ? $row['forum_topics_unapproved'] : 0,
'sub_can_post' => $row['forum_type'] == 1
@@ -15,6 +15,7 @@ namespace IPS\convert\Software\Forums;
use Exception;
use IPS\Content;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Software\Core\Punbb as PunbbCore;
use IPS\Http\Url;
@@ -122,14 +123,15 @@ class Punbb extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId Content ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return PunbbCore::fixPostData( $post, $className, $contentId );
return PunbbCore::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -140,7 +142,6 @@ class Punbb extends Software
public function convertForumsForums(): void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id' );
foreach( $this->fetch( 'forums', 'id' ) AS $row )
@@ -166,24 +167,12 @@ class Punbb extends Software
catch( UnderflowException $e ) {}
}
/* They don't store the last poster ID. Makes me sad. */
$last_poster_id = 0;
try
{
/* Better hope they haven't changed their name */
$last_poster_id = $this->db->select( 'id', 'users', array( "username=?", $row['last_poster'] ) )->first();
}
catch( UnderflowException $e ) {}
$info = array(
'id' => $row['id'],
'name' => $row['forum_name'],
'description' => $row['forum_desc'],
'topics' => $row['num_topics'],
'posts' => $row['num_posts'],
'last_post' => $row['last_post'],
'last_poster_id' => $last_poster_id,
'last_poster_name' => $row['last_poster'],
'parent_id' => ( $row['parent_forum_id'] == 0 ) ? '1000' . $row['cat_id'] : $row['parent_forum_id'],
'position' => $row['disp_position'],
'redirect_url' => $row['redirect_url'],
@@ -17,6 +17,7 @@ namespace IPS\convert\Software\Forums;
use DomainException;
use Exception;
use IPS\Content;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Software\Core\Smf as SmfCore;
use IPS\Db;
@@ -228,14 +229,15 @@ class Smf extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId Content ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return SmfCore::fixPostData( $post, $className, $contentId );
return SmfCore::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -267,39 +269,18 @@ class Smf extends Software
public function convertForumsBoards(): void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id_board' );
foreach( $this->fetch( 'boards', 'id_board' ) AS $row )
{
$last_post_time = 0;
$last_poster = 0;
$last_title = NULL;
$last_poster_name = NULL;
try
{
$last_post = $this->db->select( '*', 'messages', array( "id_msg=?", $row['id_last_msg'] ) )->first();
$last_post_time = $last_post['poster_time'];
$last_poster = $last_post['id_member'];
$last_poster_name = $last_post['poster_name'];
$last_title = $last_post['subject']; # Yes, I know this is technically wrong, but it's better than just not showing anything
}
catch( UnderflowException $e ) {}
$info = array(
'id' => $row['id_board'],
'name' => $row['name'],
'description' => $row['description'],
'topics' => $row['num_topics'],
'posts' => $row['num_posts'],
'last_post' => $last_post_time,
'last_poster_id' => $last_poster,
'last_poster_name' => $last_poster_name,
'parent_id' => ( $row['id_parent'] <> 0 ) ? $row['id_parent'] : 'c' . $row['id_cat'],
'position' => $row['board_order'],
'last_title' => $last_title,
'redirect_url' => $row['redirect'],
'queued_topics' => $row['unapproved_topics'],
'queued_posts' => $row['unapproved_posts'],
@@ -14,6 +14,7 @@ namespace IPS\convert\Software\Forums;
/* To prevent PHP errors (extending class does not exist) revealing path */
use Exception;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Software\Core\UBBthreads as UBBthreadsCore;
use IPS\convert\Software\Exception as SoftwareException;
@@ -246,14 +247,15 @@ class UBBthreads extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId Content ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return UBBthreadsCore::fixPostData( $post, $className, $contentId );
return UBBthreadsCore::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -290,12 +292,8 @@ class UBBthreads extends Software
'description' => $row['FORUM_DESCRIPTION'],
'topics' => $row['FORUM_TOPICS'],
'posts' => $row['FORUM_POSTS'],
'last_post' => DateTime::create()->setTimestamp( $row['FORUM_LAST_POST_TIME'] ),
'last_poster_id' => $row['FORUM_LAST_POSTER_ID'],
'last_poster_name' => $row['FORUM_LAST_POSTER_NAME'],
'parent_id' => $row['FORUM_PARENT_ID'] ?: ( 10000 + $row['CATEGORY_ID'] ),
'position' => $row['FORUM_SORT_ORDER'],
'last_title' => $row['FORUM_LAST_POST_SUBJECT'],
'allow_poll' => $row['FORUM_ALLOW_POLLS']
) );
}
@@ -132,7 +132,7 @@ class Vanilla extends Software
),
'convertAttachments' => array(
'table' => 'Media',
'where' => array( 'ForeignTable=? OR ForeignTable=?', 'discussion', 'comment' )
'where' => [ "ForeignTable IN ('discussion', 'comment', 'embed')" ]
)
);
}
@@ -295,6 +295,7 @@ class Vanilla extends Software
{
/* Content Rebuilds */
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\forums\Forum', 'count' => 0 ), 4, array( 'class' ) );
Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts_first', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', 'class' ) );
Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', 'class' ) );
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\forums\Topic' ), 3, array( 'class' ) );
Task::queue( 'convert', 'RebuildFirstPostIds', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
@@ -313,16 +314,22 @@ class Vanilla extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId Content ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return VanillaCore::fixPostData( $post, $className, $contentId );
return VanillaCore::fixPostData( $post, $className, $contentId, $app );
}
/**
* @brief temporarily store post content
*/
protected array $_postContent = array();
/**
* Convert attachments
*
@@ -331,18 +338,41 @@ class Vanilla extends Software
public function convertAttachments(): void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'MediaID' );
$this->_postContent = [];
foreach( $this->fetch( 'Media', 'MediaID', array( 'ForeignTable=? OR ForeignTable=?', 'discussion', 'comment' ) ) AS $row )
foreach( $this->fetch( 'Media', 'MediaID', [ $this->db->in( 'ForeignTable', [ 'discussion', 'comment', 'embed' ] ) ] ) AS $row )
{
if( $row['ForeignTable'] == 'discussion' )
{
$map = array(
'id1' => 'fp-' . $row['ForeignID'],
'id1' => $row['ForeignID'],
'id2' => $row['ForeignID'],
'first_post' => true
);
}
elseif( $row['ForeignTable'] == 'embed' )
{
$mediaRows = iterator_to_array(
\IPS\Db::i()->select(
'*',
'convert_vanilla_temp',
[ 'media_id=? AND ' . \IPS\Db::i()->in( 'link_type', [ 'forums_posts', 'forums_posts_first'] ), $row['MediaID'] ]
) );
// Nothing to do, attachment must be in another content type
if( !count( $mediaRows ) )
{
$libraryClass->setLastKeyValue( $row['MediaID'] );
continue;
}
$map = [
'id1' => $mediaRows[0]['content_id'],
'id2' => $mediaRows[0]['post_id'],
'first_post' => ( $mediaRows[0]['link_type'] == 'forums_posts_first' ) ? true : false
];
}
else
{
try
@@ -377,9 +407,38 @@ class Vanilla extends Software
$uploadPath = VanillaCore::parseMediaLocation( $row['Path'], $this->app->_session['more_info']['convertAttachments']['attach_location'] );
$libraryClass->convertAttachment( $info, $map, $uploadPath );
$attachId = $libraryClass->convertAttachment( $info, $map, $uploadPath );
/* Do some re-jiggery on the post itself to make sure attachment displays */
if ( $attachId !== FALSE and isset( $mediaRows ) )
{
foreach( $mediaRows as $mediaRow )
{
try
{
$pid = $this->app->getLink( $map['id2'], ( isset( $map['first_post'] ) AND $map['first_post'] === TRUE ) ? 'forums_posts_first' : 'forums_posts' );
if( !isset( $this->_postContent[ $pid ] ) )
{
$this->_postContent[ $pid ] = Db::i()->select( 'post', 'forums_posts', array( "pid=?", $pid ) )->first();
}
$this->_postContent[ $pid ] = str_replace( "[ATTACH={$row['MediaID']}]", '[attachment=' . $attachId . ':name]', $this->_postContent[ $pid ] );
// dump($this->_postContent[ $pid ]);
}
catch( UnderflowException|OutOfRangeException $e ) {}
}
}
unset( $mediaRows );
$libraryClass->setLastKeyValue( $row['MediaID'] );
}
/* Do the updates */
foreach( $this->_postContent as $pid => $content )
{
Db::i()->update( 'forums_posts', array( 'post' => $content ), array( 'pid=?', $pid ) );
}
}
/**
@@ -394,11 +453,7 @@ class Vanilla extends Software
$uploadsPath = $this->app->_session['more_info']['convertForumsForums']['attach_location'];
$forums = $this->fetch( array( 'Category', 'c' ), 'CategoryID', array( 'c.CategoryID<>?', -1 ),
'c.*, lcu.UserID as LastCommentUserID, lcu.Name as LastCommentUserName, ld.Name as LastDiscussionName'
);
$forums->join( array( 'User', 'lcu' ), 'c.LastCommentID=lcu.UserID' );
$forums->join( array( 'Discussion', 'ld' ), 'c.LastDiscussionID=ld.DiscussionID' );
$forums = $this->fetch( array( 'Category', 'c' ), 'CategoryID', array( 'c.CategoryID<>?', -1 ) );
foreach( $forums AS $row )
{
@@ -409,12 +464,8 @@ class Vanilla extends Software
'description' => $row['Description'],
'topics' => $row['CountDiscussions'],
'posts' => $row['CountComments'],
'last_post' => VanillaCore::mysqlToDateTime( $row['LastDateInserted'] ),
'last_poster_id' => $row['LastCommentID'],
'last_poster_name' => $row['LastCommentUserName'],
'parent_id' => ( (int) $row['ParentCategoryID'] > 0 ) ? $row['ParentCategoryID'] : NULL,
'position' => $row['Sort'],
'last_title' => $row['LastDiscussionName'],
'icon' => $icon,
'sub_can_post' => $row['AllowDiscussions'] ?: 0
];
@@ -584,17 +635,31 @@ class Vanilla extends Software
{
$row['Body'] = '<!--Markdown-->' . $row['Body'];
}
elseif( $row['Format'] == 'Rich' )
{
$row['Body'] = VanillaCore::processQuill( $row['Body'], $this->app, 'forums_posts_first', $row['DiscussionID'], $row['DiscussionID'] );
}
/* Get IP */
try
{
$ipAddress = ( $row['InsertIPAddress'] AND !str_contains( $row['InsertIPAddress'], '.' ) ) ? long2ip( hexdec( bin2hex( $row['InsertIPAddress'] ) ) ) : $row['InsertIPAddress'];
}
catch( \ErrorException $e )
{
$ipAddress = '';
}
// First post
$info = array(
'pid' => 'fp-' . $row['DiscussionID'],
'pid' => $row['DiscussionID'],
'topic_id' => $row['DiscussionID'],
'post' => $row['Body'],
'new_topic' => 1,
'edit_time' => ( $editName === NULL ) ? NULL : VanillaCore::mysqlToDateTime( $row['DateUpdated'] ),
'edit_name' => $editName,
'author_id' => $row['InsertUserID'],
'ip_address' => $row['InsertIPAddress'],
'ip_address' => $ipAddress,
'post_date' => VanillaCore::mysqlToDateTime( $row['DateInserted'] ),
);
@@ -675,6 +740,20 @@ class Vanilla extends Software
{
$row['Body'] = '<!--Markdown-->' . $row['Body'];
}
elseif( $row['Format'] == 'Rich' )
{
$row['Body'] = VanillaCore::processQuill( $row['Body'], $this->app, 'forums_posts', $row['DiscussionID'], $row['CommentID'] );
}
/* Get IP */
try
{
$ipAddress = ( $row['InsertIPAddress'] AND !str_contains( $row['InsertIPAddress'], '.' ) ) ? long2ip( hexdec( bin2hex( $row['InsertIPAddress'] ) ) ) : $row['InsertIPAddress'];
}
catch( \ErrorException $e )
{
$ipAddress = '';
}
$info = [
'pid' => $row['CommentID'],
@@ -683,7 +762,7 @@ class Vanilla extends Software
'edit_time' => ( $editName === NULL ) ? NULL : VanillaCore::mysqlToDateTime( $row['DateUpdated'] ),
'edit_name' => $editName,
'author_id' => $row['InsertUserID'],
'ip_address' => $row['InsertIPAddress'],
'ip_address' => $ipAddress,
'post_date' => VanillaCore::mysqlToDateTime( $row['DateInserted'] ),
];
@@ -238,14 +238,15 @@ class Vbulletin extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return VbulletinCore::fixPostData( $post, $className, $contentId );
return VbulletinCore::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -369,13 +370,9 @@ class Vbulletin extends Software
'description' => $forum['description'],
'topics' => $forum['threadcount'],
'posts' => $forum['replycount'],
'last_post' => $forum['lastpost'],
'last_poster_id' => ( static::$isLegacy === FALSE or is_null( static::$isLegacy ) ) ? $forum['lastposterid'] : 0,
'last_poster_name' => $forum['lastposter'],
'parent_id' => $forum['parentid'],
'position' => $forum['displayorder'],
'password' => $forum['password'] ?: NULL,
'last_title' => $forum['lastthread'],
'preview_posts' => $checkpermission( 'forumoptions', 'moderatenewpost' ),
'inc_postcount' => $checkpermission( 'forumoptions', 'countposts' ),
'redirect_url' => $forum['link'],
@@ -208,14 +208,15 @@ class Vbulletin5 extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId Content ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return Vbulletin5Core::fixPostData( $post, $className, $contentId );
return Vbulletin5Core::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -295,7 +296,6 @@ class Vbulletin5 extends Software
public function convertForumsForums() : void
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'node.nodeid' );
$clubs = $this->fetchClubs();
@@ -334,9 +334,6 @@ class Vbulletin5 extends Software
'description' => $forum['description'],
'topics' => $forum['textcount'],
'posts' => $forum['totalcount'],
'last_post' => $forum['lastcontent'],
'last_poster_id' => $forum['lastauthorid'],
'last_poster_name' => $forum['lastcontentauthor'],
'parent_id' => ( !array_key_exists( $forum['nodeid'], $clubs ) ) ? $forum['parentid'] : -1,
'club_id' => ( array_key_exists( $forum['nodeid'], $clubs ) ) ? $forum['nodeid'] : NULL,
'position' => $forum['displayorder'],
@@ -16,6 +16,7 @@ namespace IPS\convert\Software\Forums;
use DomainException;
use Exception;
use IPS\Content;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Software\Core\Woltlab as WoltlabCore;
use IPS\Db;
@@ -175,14 +176,15 @@ class Woltlab extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId Content ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return WoltlabCore::fixPostData( $post, $className, $contentId );
return WoltlabCore::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -15,6 +15,7 @@ namespace IPS\convert\Software\Forums;
use Exception;
use IPS\Content;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\convert\Software\Core\Wpforo as WpforoCore;
use IPS\Db;
@@ -138,14 +139,15 @@ class Wpforo extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId Content ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return WpforoCore::fixPostData( $post, $className, $contentId );
return WpforoCore::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -273,14 +273,15 @@ class Xenforo extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post The post
* @param string|null $className Content Classname passed by post-conversion rebuild
* @param int|null $contentId Content ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return XenforoCore::fixPostData( $post, $className, $contentId );
return XenforoCore::fixPostData( $post, $className, $contentId, $app );
}
/**
@@ -338,12 +339,8 @@ class Xenforo extends Software
'description' => $row['description'],
'topics' => ( isset( $data['discussion_count'] ) ) ? $data['discussion_count'] : 0,
'posts' => ( isset( $data['message_count'] ) ) ? $data['message_count'] : 0,
'last_post' => ( isset( $data['last_post_date'] ) ) ? $data['last_post_date'] : 0,
'last_poster_id' => ( isset( $data['last_post_user_id'] ) ) ? $data['last_post_user_id'] : 0,
'last_poster_name' => ( isset( $data['last_poster_name'] ) ) ? $data['last_post_username'] : '',
'parent_id' => ( $row['parent_node_id'] == 0 ) ? -1 : $row['parent_node_id'],
'position' => $row['display_order'],
'last_title' => ( isset( $data['last_thread_title'] ) ) ? $data['last_thread_title'] : '',
'allow_poll' => ( isset( $data['allow_poll'] ) ) ? $data['allow_poll'] : 0,
'inc_postcount' => ( isset( $data['count_messages'] ) ) ? $data['count_messages'] : 0,
'redirect_url' => ( isset( $data['link_url'] ) ) ? $data['link_url'] : NULL,
@@ -192,14 +192,15 @@ class Vbulletin extends Software
/**
* Pre-process content for the Invision Community text parser
*
* @param string $post post
* @param string|null $className Classname passed by post-conversion rebuild
* @param int|null $contentId ID passed by post-conversion rebuild
* @param string The post
* @param string|null Content Classname passed by post-conversion rebuild
* @param int|null Content ID passed by post-conversion rebuild
* @param App|null App object if available
* @return string The converted post
*/
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null, ?App $app=null ): string
{
return VBulletinSoftware::fixPostData( $post, $className, $contentId );
return VBulletinSoftware::fixPostData( $post, $className, $contentId, $app );
}
/**