Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -31,7 +31,7 @@ class _Phpbb extends \IPS\convert\Software
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return "phpBB (3.1.x/3.2.x)";
|
||||
return "phpBB (3.1.x/3.2.x/3.3.x)";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -402,6 +402,16 @@ class _Phpbb extends \IPS\convert\Software
|
||||
{
|
||||
$visibility = $row['post_approved'];
|
||||
}
|
||||
|
||||
$editName = null;
|
||||
if( $row['post_edit_time'] AND $row['post_edit_user'] )
|
||||
{
|
||||
try
|
||||
{
|
||||
$editName = $this->db->select( 'username', 'users', array( 'user_id=?', $row['post_edit_user'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'pid' => $row['post_id'],
|
||||
@@ -409,6 +419,8 @@ class _Phpbb extends \IPS\convert\Software
|
||||
'post' => \IPS\convert\Software\Core\Phpbb::stripUid( $row['post_text'], $row['bbcode_uid'] ),
|
||||
'append_edit' => ( $row['post_edit_user'] ) ? 1 : 0,
|
||||
'edit_time' => $row['post_edit_time'],
|
||||
'edit_name' => $editName,
|
||||
'post_edit_reason' => $row['post_edit_reason'] ?? null,
|
||||
'author_id' => $row['poster_id'],
|
||||
'ip_address' => $row['poster_ip'],
|
||||
'post_date' => $row['post_time'],
|
||||
@@ -456,6 +468,11 @@ class _Phpbb extends \IPS\convert\Software
|
||||
$libraryClass->setLastKeyValue( $row['post_id'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief temporarily store post content
|
||||
*/
|
||||
protected $_postContent = array();
|
||||
|
||||
/**
|
||||
* Convert attachments
|
||||
@@ -494,28 +511,32 @@ class _Phpbb extends \IPS\convert\Software
|
||||
{
|
||||
$pid = $this->app->getLink( $row['post_msg_id'], 'forums_posts' );
|
||||
|
||||
$post = \IPS\Db::i()->select( 'post', 'forums_posts', array( "pid=?", $pid ) )->first();
|
||||
if( !isset( $this->_postContent[ $pid ] ) )
|
||||
{
|
||||
$this->_postContent[ $pid ] = \IPS\Db::i()->select( 'post', 'forums_posts', array( "pid=?", $pid ) )->first();
|
||||
}
|
||||
|
||||
$attachmentName = preg_quote( $row['real_filename'], '/' );
|
||||
|
||||
$regex31 = '/\[attachment=(.+?)?\]\<\!\-\- ia[\d]+ \-\-\>' . $attachmentName . '\<\!\-\- ia[\d]+ \-\-\>\[\/attachment\]/i';
|
||||
$regex32 = '/\<ATTACHMENT filename\="(.+?)?" index\="(.+?)?"\>\<s\>\[attachment\=(.+?)?\]\<\/s\>' . $attachmentName . '<e\>\[\/attachment\]\<\/e\>\<\/ATTACHMENT\>/i';
|
||||
$changed = FALSE;
|
||||
$regex31 = '/\[attachment=(\d+)?\]\<\!\-\- ia[\d]+ \-\-\>' . $attachmentName . '\<\!\-\- ia[\d]+ \-\-\>\[\/attachment\]/i';
|
||||
$regex32 = '/\<ATTACHMENT filename\="(.+?)?" index\="(.+?)?"\>\<s\>\[attachment\=(\d+)?\]\<\/s\>' . $attachmentName . '<e\>\[\/attachment\]\<\/e\>\<\/ATTACHMENT\>/i';
|
||||
|
||||
if( preg_match( $regex31, $post ) )
|
||||
$replacement = '[attachment=' . $attachId . ':name]';
|
||||
if( $row['attach_comment'] )
|
||||
{
|
||||
$changed = TRUE;
|
||||
$post = preg_replace( $regex31, '[attachment=' . $attachId . ':name]', $post );
|
||||
$replacement .= '<p>' . $row['attach_comment'] . '</p>';
|
||||
}
|
||||
elseif( preg_match( $regex32, $post ) )
|
||||
if( preg_match( $regex31, $this->_postContent[ $pid ] ) )
|
||||
{
|
||||
$changed = TRUE;
|
||||
$post = preg_replace( $regex32, '[attachment=' . $attachId . ':name]', $post );
|
||||
$this->_postContent[ $pid ] = preg_replace( $regex31, $replacement, $this->_postContent[ $pid ] );
|
||||
}
|
||||
|
||||
if( $changed )
|
||||
elseif( preg_match( $regex32, $this->_postContent[ $pid ] ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
|
||||
$this->_postContent[ $pid ] = preg_replace( $regex32, $replacement, $this->_postContent[ $pid ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_postContent[ $pid ] .= '<br>' . $replacement;
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
@@ -524,6 +545,12 @@ class _Phpbb extends \IPS\convert\Software
|
||||
|
||||
$libraryClass->setLastKeyValue( $row['attach_id'] );
|
||||
}
|
||||
|
||||
/* Do the updates */
|
||||
foreach( $this->_postContent as $pid => $content )
|
||||
{
|
||||
\IPS\Db::i()->update( 'forums_posts', array( 'post' => $content ), array( 'pid=?', $pid ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user