Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,16 +12,38 @@
|
||||
namespace IPS\convert\Software\Forums;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use IPS\convert\App;
|
||||
use IPS\convert\Software;
|
||||
use IPS\convert\Software\Core\Vbulletin5;
|
||||
use IPS\Db;
|
||||
use IPS\forums\Topic;
|
||||
use IPS\forums\Topic\Post;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Request;
|
||||
use IPS\Task;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use UnexpectedValueException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function unserialize;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* vBulletin 5 Forums Converter
|
||||
*/
|
||||
class _Vbulletin5 extends \IPS\convert\Software
|
||||
class Vbulletin5 extends Software
|
||||
{
|
||||
/**
|
||||
* Software Name
|
||||
@@ -88,7 +110,7 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
$rows['convertAttachments2'] = array(
|
||||
'step_method' => 'convertAttachments2',
|
||||
'step_title' => 'convert_attachments',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_attachments_map', array( "location_key=?", 'gallery_Images' ) ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'core_attachments_map', array( "location_key=?", 'gallery_Images' ) ),
|
||||
'source_rows' => array( 'table' => static::canConvert()['convertAttachments2']['table'], 'where' => static::canConvert()['convertAttachments2']['where'] ),
|
||||
'per_cycle' => 10,
|
||||
'dependencies' => array( 'convertAttachments' ),
|
||||
@@ -112,28 +134,28 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
switch( $table )
|
||||
{
|
||||
case 'forum':
|
||||
return \count( $this->fetchForums() );
|
||||
return count( $this->fetchForums() );
|
||||
break;
|
||||
|
||||
case 'thread':
|
||||
try
|
||||
{
|
||||
return parent::countRows( 'node', array( \IPS\Db::i()->in( 'contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Poll' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ) ) ) . " AND " . \IPS\Db::i()->in( 'parentid', array_keys( $this->fetchForums() ) ), $this->fetchType( 'Text' ), $this->fetchType( 'Poll' ) ) );
|
||||
return parent::countRows( 'node', array( Db::i()->in( 'contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Poll' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ) ) ) . " AND " . Db::i()->in( 'parentid', array_keys( $this->fetchForums() ) ), $this->fetchType( 'Text' ), $this->fetchType( 'Poll' ) ) );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
throw new \IPS\convert\Exception( sprintf( \IPS\Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
|
||||
throw new \IPS\convert\Exception( sprintf( Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'post':
|
||||
try
|
||||
{
|
||||
return parent::countRows( 'node', array( \IPS\Db::i()->in( 'contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ), $this->fetchType( 'Poll' ) ) ) ) );
|
||||
return parent::countRows( 'node', array( Db::i()->in( 'contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ), $this->fetchType( 'Poll' ) ) ) ) );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
throw new \IPS\convert\Exception( sprintf( \IPS\Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
|
||||
throw new \IPS\convert\Exception( sprintf( Member::loggedIn()->language()->get( 'could_not_count_rows' ), $table ) );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -175,28 +197,30 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
public function finish()
|
||||
{
|
||||
/* Content Rebuilds */
|
||||
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\forums\Topic' ), 2, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\forums\Forum', 'count' => 0 ), 4, array( 'class' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'forums_posts', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', 'class' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildFirstPostIds', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
|
||||
\IPS\Task::queue( 'convert', 'DeleteEmptyTopics', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
|
||||
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\forums\Topic' ), 2, array( 'class' ) );
|
||||
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', 'class' => 'IPS\forums\Topic\Post' ), 2, array( 'app', 'link', 'class' ) );
|
||||
Task::queue( 'convert', 'RebuildFirstPostIds', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
|
||||
Task::queue( 'convert', 'DeleteEmptyTopics', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
|
||||
|
||||
/* Rebuild Leaderboard */
|
||||
\IPS\Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
|
||||
\IPS\Db::i()->delete('core_reputation_leaderboard_history');
|
||||
Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
|
||||
Db::i()->delete('core_reputation_leaderboard_history');
|
||||
|
||||
return array( 'f_rebuild_posts', 'f_recounting_forums', 'f_recounting_topics' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fix Post Data
|
||||
* Pre-process content for the Invision Community text parser
|
||||
*
|
||||
* @param string $post Post
|
||||
* @return string Fixed Posts
|
||||
* @param string The post
|
||||
* @param string|null Content Classname passed by post-conversion rebuild
|
||||
* @param int|null Content ID passed by post-conversion rebuild
|
||||
* @return string The converted post
|
||||
*/
|
||||
public static function fixPostData( $post )
|
||||
public static function fixPostData( string $post, ?string $className=null, ?int $contentId=null ): string
|
||||
{
|
||||
return \IPS\convert\Software\Core\Vbulletin5::fixPostData( $post );
|
||||
return Vbulletin5::fixPostData( $post, $className, $contentId );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,10 +251,10 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
/* Get our reactions to let the admin map them */
|
||||
$options = array();
|
||||
$descriptions = array();
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_reactions' ), 'IPS\Content\Reaction' ) AS $reaction )
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'core_reactions' ), 'IPS\Content\Reaction' ) AS $reaction )
|
||||
{
|
||||
$options[ $reaction->id ] = $reaction->_icon->url;
|
||||
$descriptions[ $reaction->id ] = \IPS\Member::loggedIn()->language()->addToStack('reaction_title_' . $reaction->id ) . '<br>' . $reaction->_description;
|
||||
$descriptions[ $reaction->id ] = Member::loggedIn()->language()->addToStack('reaction_title_' . $reaction->id ) . '<br>' . $reaction->_description;
|
||||
}
|
||||
|
||||
$return['convertForumsPosts'] = array(
|
||||
@@ -253,13 +277,13 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(
|
||||
'options' => array(
|
||||
'database' => \IPS\Member::loggedIn()->language()->addToStack( 'conv_store_database' ),
|
||||
'file_system' => \IPS\Member::loggedIn()->language()->addToStack( 'conv_store_file_system' ),
|
||||
'database' => Member::loggedIn()->language()->addToStack( 'conv_store_database' ),
|
||||
'file_system' => Member::loggedIn()->language()->addToStack( 'conv_store_file_system' ),
|
||||
),
|
||||
'userSuppliedInput' => 'file_system',
|
||||
),
|
||||
'field_hint' => NULL,
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
)
|
||||
);
|
||||
break;
|
||||
@@ -287,10 +311,10 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
{
|
||||
$this->app->getLink( $forum['nodeid'], 'forums_forums' );
|
||||
$libraryClass->setLastKeyValue( $forum['nodeid'] );
|
||||
$this->app->log( 'vb5_skipped_forum', __METHOD__, \IPS\convert\App::LOG_WARNING );
|
||||
$this->app->log( 'vb5_skipped_forum', __METHOD__, App::LOG_WARNING );
|
||||
continue;
|
||||
}
|
||||
catch( \OutOfRangeException $e ){}
|
||||
catch( OutOfRangeException $e ){}
|
||||
|
||||
$self = $this;
|
||||
$checkpermission = function( $name, $perm ) use ( $forum, $self )
|
||||
@@ -345,7 +369,7 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
$libraryClass::setKey( 'node.nodeid' );
|
||||
|
||||
$clubs = $this->fetchClubs();
|
||||
foreach( $this->fetch( 'node', 'node.nodeid', array( "( " . \IPS\Db::i()->in( 'node.parentid', array_keys( $this->fetchForums() ) ) . " OR " . $this->db->in( 'node.parentid', array_keys( $clubs ) ) . " ) AND " . \IPS\Db::i()->in( 'node.contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Poll' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ) ) ) ) ) AS $topic )
|
||||
foreach( $this->fetch( 'node', 'node.nodeid', array( "( " . Db::i()->in( 'node.parentid', array_keys( $this->fetchForums() ) ) . " OR " . $this->db->in( 'node.parentid', array_keys( $clubs ) ) . " ) AND " . Db::i()->in( 'node.contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Poll' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ) ) ) ) ) AS $topic )
|
||||
{
|
||||
/* Pesky Polls */
|
||||
$poll = NULL;
|
||||
@@ -354,12 +378,12 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
{
|
||||
/* Does this topic have a corresponding poll? */
|
||||
$pollData = $this->db->select( '*', 'poll', array( "nodeid=?", $topic['nodeid'] ) )->first();
|
||||
$pollOptions = @\unserialize( $pollData['options'] );
|
||||
$pollOptions = @unserialize( $pollData['options'] );
|
||||
$lastVote = $pollData['lastvote'];
|
||||
|
||||
if ( $pollOptions === FALSE )
|
||||
{
|
||||
throw new \UnexpectedValueException;
|
||||
throw new UnexpectedValueException;
|
||||
}
|
||||
|
||||
$choices = array();
|
||||
@@ -417,8 +441,8 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
);
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {} # if the poll is missing, don't bother
|
||||
catch( \UnexpectedValueException $e ) {} # if poll data is corrupt, then skip
|
||||
catch( UnderflowException $e ) {} # if the poll is missing, don't bother
|
||||
catch( UnexpectedValueException $e ) {} # if poll data is corrupt, then skip
|
||||
|
||||
$info = array(
|
||||
'tid' => $topic['nodeid'],
|
||||
@@ -468,12 +492,12 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
$softDeleteId = $this->app->getLink( $topic['deleteuserid'], 'core_members', TRUE );
|
||||
}
|
||||
/* User link doesn't exist */
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
$softDeleteId = 0;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->insert( 'core_soft_delete_log', array(
|
||||
Db::i()->insert( 'core_soft_delete_log', array(
|
||||
'sdl_obj_id' => $topicId,
|
||||
'sdl_obj_key' => 'topic',
|
||||
'sdl_obj_member_id' => $softDeleteId,
|
||||
@@ -499,7 +523,7 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
|
||||
$libraryClass::setKey( 'node.nodeid' );
|
||||
|
||||
foreach( $this->fetch( 'node', 'node.nodeid', array( \IPS\Db::i()->in( 'node.contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ), $this->fetchType( 'Poll' ) ) ) ), 'node.*, text.rawtext, text.htmlstate' )->join( 'text', 'text.nodeid = node.nodeid' ) AS $post )
|
||||
foreach( $this->fetch( 'node', 'node.nodeid', array( Db::i()->in( 'node.contenttypeid', array( $this->fetchType( 'Text' ), $this->fetchType( 'Gallery' ), $this->fetchType( 'Video' ), $this->fetchType( 'Link' ), $this->fetchType( 'Poll' ) ) ) ), 'node.*, text.rawtext, text.htmlstate' )->join( 'text', 'text.nodeid = node.nodeid' ) AS $post )
|
||||
{
|
||||
/* Comments of comments of comments of comments */
|
||||
$isSubComment = FALSE;
|
||||
@@ -510,14 +534,14 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
|
||||
$post['parentid'] = $post['nodeid'];
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
/* If parentid exists as a forums_topics link, we don't actually need to do anything */
|
||||
$this->app->getLink( $post['parentid'], 'forums_topics' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -532,18 +556,18 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
$post['parentid'] = $parent['parentid'];
|
||||
$post['rawtext'] = "[quote name='" . $parent['authorname'] ."' timestamp='" . $parent['created'] . "']" . $parent['rawtext'] . "[/quote]\n" . $post['rawtext'];
|
||||
}
|
||||
catch( \OutOfRangeException $e ) # we need to go deeper!
|
||||
catch( OutOfRangeException $e ) # we need to go deeper!
|
||||
{
|
||||
/* Actually, we don't - end of the line */
|
||||
$libraryClass->setLastKeyValue( $post['nodeid'] );
|
||||
$this->app->log( 'vb5_post_missing_parent_post', __METHOD__, \IPS\convert\App::LOG_WARNING, $post['nodeid'] );
|
||||
$this->app->log( 'vb5_post_missing_parent_post', __METHOD__, App::LOG_WARNING, $post['nodeid'] );
|
||||
continue;
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
/* Loading the parent failed - move on */
|
||||
$libraryClass->setLastKeyValue( $post['nodeid'] );
|
||||
$this->app->log( 'vb5_post_missing_parent_post_2', __METHOD__, \IPS\convert\App::LOG_WARNING, $post['nodeid'] );
|
||||
$this->app->log( 'vb5_post_missing_parent_post_2', __METHOD__, App::LOG_WARNING, $post['nodeid'] );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -572,7 +596,7 @@ class _Vbulletin5 extends \IPS\convert\Software
|
||||
'ip_address' => $post['ipaddress'],
|
||||
'post_date' => $post['publishdate'],
|
||||
'queued' => $queued,
|
||||
'post_htmlstate' => ( \in_array( $post['htmlstate'], array( 'on', 'on_nl2br' ) ) ) ? 1 : 0,
|
||||
'post_htmlstate' => ( in_array( $post['htmlstate'], array( 'on', 'on_nl2br' ) ) ) ? 1 : 0,
|
||||
);
|
||||
|
||||
/* Any vB5 Links? */
|
||||
@@ -597,7 +621,7 @@ LINK;
|
||||
LINK;
|
||||
}
|
||||
}
|
||||
catch ( \UnderflowException $e ) {}
|
||||
catch ( UnderflowException $e ) {}
|
||||
}
|
||||
|
||||
$post_id = $libraryClass->convertForumsPost( $info );
|
||||
@@ -618,12 +642,12 @@ LINK;
|
||||
$softDeleteId = $this->app->getLink( $post['deleteuserid'], 'core_members', TRUE );
|
||||
}
|
||||
/* User link doesn't exist */
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
$softDeleteId = 0;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->insert( 'core_soft_delete_log', array(
|
||||
Db::i()->insert( 'core_soft_delete_log', array(
|
||||
'sdl_obj_id' => $post_id,
|
||||
'sdl_obj_key' => 'post',
|
||||
'sdl_obj_member_id' => $softDeleteId,
|
||||
@@ -704,7 +728,7 @@ LINK;
|
||||
/* 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 ) );
|
||||
Db::i()->update( 'forums_posts', array( 'append_edit' => 1, 'edit_time' => $latestedit, 'edit_name' => $name, 'post_edit_reason' => $reason ), array( "pid=?", $post_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -736,7 +760,7 @@ LINK;
|
||||
$post_id = $attachment['parentid'];
|
||||
}
|
||||
/* It isn't the first post in the topic */
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -746,18 +770,18 @@ LINK;
|
||||
$attachment['parentid'] = $parent['parentid'];
|
||||
$post_id = $parent['nodeid'];
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
/* No valid converter link for the parent post */
|
||||
$libraryClass->setLastKeyValue( $attachment['nodeid'] );
|
||||
$this->app->log( 'vb5_attach_missing_post_link', __METHOD__, \IPS\convert\App::LOG_WARNING, $attachment['nodeid'] );
|
||||
$this->app->log( 'vb5_attach_missing_post_link', __METHOD__, App::LOG_WARNING, $attachment['nodeid'] );
|
||||
continue;
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
/* Parent post does not exist in vB database */
|
||||
$libraryClass->setLastKeyValue( $attachment['nodeid'] );
|
||||
$this->app->log( 'vb5_attach_missing_post', __METHOD__, \IPS\convert\App::LOG_WARNING, $attachment['nodeid'] );
|
||||
$this->app->log( 'vb5_attach_missing_post', __METHOD__, App::LOG_WARNING, $attachment['nodeid'] );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -812,9 +836,9 @@ LINK;
|
||||
{
|
||||
$pid = $this->app->getLink( $post_id, 'forums_posts' );
|
||||
|
||||
$post = \IPS\Db::i()->select( 'post', 'forums_posts', array( "pid=?", $pid ) )->first();
|
||||
$post = Db::i()->select( 'post', 'forums_posts', array( "pid=?", $pid ) )->first();
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
/* If the post didn't exist and this is just an orphaned attachment, move along */
|
||||
$libraryClass->setLastKeyValue( $attachment['nodeid'] );
|
||||
@@ -825,7 +849,7 @@ LINK;
|
||||
{
|
||||
$post = preg_replace( "/\[ATTACH([^\]]+?)?\]n" . $attachment['nodeid'] . "\[\/ATTACH\]/i", '[attachment=' . $attach_id . ':name]', $post );
|
||||
|
||||
\IPS\Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
|
||||
Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -838,7 +862,7 @@ LINK;
|
||||
$oldAttachId = $this->db->select( 'attachmentid', 'attachment', array( 'filedataid=?', $attachment['filedataid'] ) )->first();
|
||||
}
|
||||
/* Don't fail if this table/value doesn't exist */
|
||||
catch( \Exception $e ) { }
|
||||
catch( Exception $e ) { }
|
||||
|
||||
if ( $oldAttachId !== NULL and preg_match( "/\[ATTACH([^\]]+?)?\]" . $oldAttachId . "\[\/ATTACH\]/i", $post ) )
|
||||
{
|
||||
@@ -853,7 +877,7 @@ LINK;
|
||||
|
||||
if( $update )
|
||||
{
|
||||
\IPS\Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
|
||||
Db::i()->update( 'forums_posts', array( 'post' => $post ), array( "pid=?", $pid ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -886,7 +910,7 @@ LINK;
|
||||
$post_id = $attachment['parentid'];
|
||||
}
|
||||
/* It isn't the first post in the topic */
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -896,18 +920,18 @@ LINK;
|
||||
$attachment['parentid'] = $parent['parentid'];
|
||||
$post_id = $parent['nodeid'];
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
/* No valid converter link for the parent post */
|
||||
$libraryClass->setLastKeyValue( $attachment['nodeid'] );
|
||||
$this->app->log( 'vb5_attach_missing_post_link', __METHOD__, \IPS\convert\App::LOG_WARNING, $attachment['nodeid'] );
|
||||
$this->app->log( 'vb5_attach_missing_post_link', __METHOD__, App::LOG_WARNING, $attachment['nodeid'] );
|
||||
continue;
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
/* Parent post does not exist in vB database */
|
||||
$libraryClass->setLastKeyValue( $attachment['nodeid'] );
|
||||
$this->app->log( 'vb5_attach_missing_post', __METHOD__, \IPS\convert\App::LOG_WARNING, $attachment['nodeid'] );
|
||||
$this->app->log( 'vb5_attach_missing_post', __METHOD__, App::LOG_WARNING, $attachment['nodeid'] );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -964,7 +988,7 @@ LINK;
|
||||
/**
|
||||
* @brief Silly Bitwise
|
||||
*/
|
||||
public static $bitOptions = array (
|
||||
public static array $bitOptions = array (
|
||||
'forumoptions' => array(
|
||||
'active' => 1,
|
||||
'allowposting' => 2,
|
||||
@@ -1020,7 +1044,7 @@ LINK;
|
||||
try
|
||||
{
|
||||
/* Get the main social group node ID from the channel GUID. */
|
||||
$mainNodeId = $this->db->select( 'nodeid', 'channel', array( "guid=?", \IPS\convert\Software\Core\Vbulletin5::$guids['clubs'] ) )->first();
|
||||
$mainNodeId = $this->db->select( 'nodeid', 'channel', array( "guid=?", Vbulletin5::$guids['clubs'] ) )->first();
|
||||
|
||||
$categories = array();
|
||||
foreach( $this->db->select( 'nodeid', 'node', array( "parentid=?", $mainNodeId ) ) AS $cat )
|
||||
@@ -1034,7 +1058,7 @@ LINK;
|
||||
$clubs[ $row['nodeid'] ] = $row;
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) { /* Just in case something goofy happened and there is no main channel */ }
|
||||
catch( UnderflowException $e ) { /* Just in case something goofy happened and there is no main channel */ }
|
||||
|
||||
return $clubs;
|
||||
}
|
||||
@@ -1052,7 +1076,7 @@ LINK;
|
||||
*/
|
||||
protected function fetchType( $type )
|
||||
{
|
||||
if ( \count( $this->typesCache ) )
|
||||
if ( count( $this->typesCache ) )
|
||||
{
|
||||
return $this->typesCache[ $type ];
|
||||
}
|
||||
@@ -1070,49 +1094,49 @@ LINK;
|
||||
/**
|
||||
* Check if we can redirect the legacy URLs from this software to the new locations
|
||||
*
|
||||
* @return NULL|\IPS\Http\Url
|
||||
* @return NULL|Url
|
||||
* @note Forum URLs do not have IDs in them, so we cannot redirect them reliably
|
||||
*/
|
||||
public function checkRedirects()
|
||||
{
|
||||
$url = \IPS\Request::i()->url();
|
||||
$url = 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 ] )
|
||||
( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'showthread.php' ) !== FALSE OR
|
||||
mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'showpost.php' ) !== FALSE OR
|
||||
preg_match( '#/threads/([0-9]+)#i', $url->data[ Url::COMPONENT_PATH ] )
|
||||
)
|
||||
AND ( isset( \IPS\Request::i()->p ) OR isset( \IPS\Request::i()->postid ) )
|
||||
AND ( isset( Request::i()->p ) OR isset( Request::i()->postid ) )
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
$postId = \IPS\Request::i()->postid ?? \IPS\Request::i()->p;
|
||||
$postId = Request::i()->postid ?? Request::i()->p;
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( $postId, array( 'forums_posts_old' ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
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 );
|
||||
$item = Post::load( $data );
|
||||
|
||||
if( $item->canView() )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
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 ) )
|
||||
elseif( ( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'showthread.php' ) !== FALSE OR
|
||||
mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'printthread.php' ) !== FALSE )
|
||||
AND ( isset( Request::i()->t ) OR isset( Request::i()->threadid ) )
|
||||
)
|
||||
{
|
||||
/* Topic URLs.
|
||||
@@ -1121,18 +1145,18 @@ LINK;
|
||||
* /showthread.php?threadid=?
|
||||
* /printthread.php?threadid=?
|
||||
*/
|
||||
$path = $url->data[ \IPS\Http\Url::COMPONENT_PATH ];
|
||||
$path = $url->data[ Url::COMPONENT_PATH ];
|
||||
if( mb_strpos( $path, 'showthread.php' ) !== FALSE OR mb_strpos( $path, 'printthread.php' ) !== FALSE )
|
||||
{
|
||||
if( isset( \IPS\Request::i()->t ) )
|
||||
if( isset( Request::i()->t ) )
|
||||
{
|
||||
$oldId = \IPS\Request::i()->t;
|
||||
$oldId = Request::i()->t;
|
||||
}
|
||||
elseif( isset( \IPS\Request::i()->threadid ) )
|
||||
elseif( isset( Request::i()->threadid ) )
|
||||
{
|
||||
$oldId = \IPS\Request::i()->threadid;
|
||||
$oldId = Request::i()->threadid;
|
||||
}
|
||||
elseif( preg_match( '#^(\d+)-[^/]+#i', $url->data[ \IPS\Http\Url::COMPONENT_QUERY ], $matches ) )
|
||||
elseif( preg_match( '#^(\d+)-[^/]+#i', $url->data[ Url::COMPONENT_QUERY ], $matches ) )
|
||||
{
|
||||
$oldId = $matches[1];
|
||||
}
|
||||
@@ -1151,26 +1175,26 @@ LINK;
|
||||
{
|
||||
$data = (string) $this->app->getLink( $oldId, array( 'forums_topics_old' ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
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 );
|
||||
$item = Topic::load( $data );
|
||||
|
||||
if( $item->canView() )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( preg_match( '#(?<!topic|file|image)/([0-9]+)\-([^/]*?)#', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
if( preg_match( '#(?<!topic|file|image)/([0-9]+)\-([^/]*?)#', $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1178,18 +1202,18 @@ LINK;
|
||||
{
|
||||
$data = (string) $this->app->getLink( (int) $matches[1], array( 'topics', 'forums_topics' ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$data = (string) $this->app->getLink( (int) $matches[1], array( 'topics', 'forums_topics' ), FALSE, TRUE );
|
||||
}
|
||||
$item = \IPS\forums\Topic::load( $data );
|
||||
$item = Topic::load( $data );
|
||||
|
||||
if( $item->canView() )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user