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,39 @@
|
||||
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 InvalidArgumentException;
|
||||
use IPS\convert\App;
|
||||
use IPS\convert\Software;
|
||||
use IPS\convert\Software\Core\Vbulletin;
|
||||
use IPS\Db;
|
||||
use IPS\forums\Forum;
|
||||
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 function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_null;
|
||||
|
||||
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 Forums Converter
|
||||
*/
|
||||
class _Vbulletin extends \IPS\convert\Software
|
||||
class Vbulletin extends Software
|
||||
{
|
||||
/**
|
||||
* @brief vBulletin 4 Stores all attachments under one table - this will store the content type for the forums app.
|
||||
@@ -41,12 +64,12 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\convert\App $app The application to reference for database and other information.
|
||||
* @param App $app The application to reference for database and other information.
|
||||
* @param bool $needDB Establish a DB connection
|
||||
* @return void
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct( \IPS\convert\App $app, $needDB=TRUE )
|
||||
public function __construct( App $app, $needDB=TRUE )
|
||||
{
|
||||
$return = parent::__construct( $app, $needDB );
|
||||
|
||||
@@ -71,12 +94,12 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
|
||||
|
||||
/* If this is vB4, what is the content type ID for posts? */
|
||||
if ( static::$postContentType === NULL AND ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) ) )
|
||||
if ( static::$postContentType === NULL AND ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) )
|
||||
{
|
||||
static::$postContentType = $this->db->select( 'contenttypeid', 'contenttype', array( "class=?", 'Post' ) )->first();
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) {}
|
||||
catch( Exception $e ) {}
|
||||
}
|
||||
|
||||
return $return;
|
||||
@@ -131,7 +154,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
),
|
||||
'convertClubForums' => array(
|
||||
'table' => 'socialgroup',
|
||||
'where' => array( \IPS\Db::i()->bitwiseWhere( array( 'options' => static::$bitOptions['cluboptions'] ), 'enable_group_messages' ) )
|
||||
'where' => array( Db::i()->bitwiseWhere( array( 'options' => static::$bitOptions['cluboptions'] ), 'enable_group_messages' ) )
|
||||
),
|
||||
'convertClubTopics' => array(
|
||||
'table' => 'discussion',
|
||||
@@ -143,7 +166,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
),
|
||||
'convertAttachments' => array(
|
||||
'table' => 'attachment',
|
||||
'where' => ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) ) ? array( "contenttypeid=?", static::$postContentType ) : NULL
|
||||
'where' => ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) ? array( "contenttypeid=?", static::$postContentType ) : NULL
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -159,7 +182,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$rows['convertForumsTopicsFollowers'] = array(
|
||||
'step_title' => 'convert_forums_topics_followers',
|
||||
'step_method' => 'convertForumsTopicsFollowers',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_follow', array( 'follow_app=? AND follow_area=?', 'forums', 'topics' ) ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'core_follow', array( 'follow_app=? AND follow_area=?', 'forums', 'topics' ) ),
|
||||
'source_rows' => array( 'table' => static::canConvert()['convertForumsTopicsFollowers']['table'], 'where' => static::canConvert()['convertForumsTopicsFollowers']['where'] ),
|
||||
'per_cycle' => 2000,
|
||||
'dependencies' => array( 'convertForumsTopics' ),
|
||||
@@ -198,31 +221,33 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
public function finish()
|
||||
{
|
||||
/* Content Rebuilds */
|
||||
\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( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\forums\Topic' ), 2, array( 'class' ) ); // This must run before the CMS item count task runs.
|
||||
\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', '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( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\forums\Topic' ), 2, array( 'class' ) ); // This must run before the CMS item count task runs.
|
||||
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');
|
||||
|
||||
/* Caches */
|
||||
\IPS\Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'forums_topics', 'class' => 'IPS\forums\Topic' ), 3, array( 'app', 'link', 'class' ) );
|
||||
Task::queue( 'convert', 'RebuildTagCache', array( 'app' => $this->app->app_id, 'link' => 'forums_topics', 'class' => 'IPS\forums\Topic' ), 3, array( 'app', 'link', 'class' ) );
|
||||
|
||||
return array( "f_forum_last_post_data", "f_rebuild_posts", "f_recounting_forums", "f_recounting_topics", "f_topic_tags_recount" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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\Vbulletin::fixPostData( $post );
|
||||
return Vbulletin::fixPostData( $post, $className, $contentId );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,10 +278,10 @@ class _Vbulletin 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(
|
||||
@@ -295,13 +320,13 @@ class _Vbulletin 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;
|
||||
@@ -347,7 +372,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'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_id' => ( static::$isLegacy === FALSE or is_null( static::$isLegacy ) ) ? $forum['lastposterid'] : 0,
|
||||
'last_poster_name' => $forum['lastposter'],
|
||||
'parent_id' => $forum['parentid'],
|
||||
'position' => $forum['displayorder'],
|
||||
@@ -494,7 +519,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
);
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {} # if the poll is missing, don't bother
|
||||
catch( UnderflowException $e ) {} # if the poll is missing, don't bother
|
||||
}
|
||||
|
||||
switch( $topic['visible'] )
|
||||
@@ -520,7 +545,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'posts' => $topic['replycount'],
|
||||
'starter_id' => $topic['postuserid'],
|
||||
'start_date' => $topic['dateline'],
|
||||
'last_poster_id' => ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) ) ? $topic['lastposterid'] : NULL,
|
||||
'last_poster_id' => ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) ? $topic['lastposterid'] : NULL,
|
||||
'last_post' => $topic['lastpost'],
|
||||
'starter_name' => $topic['postusername'],
|
||||
'last_poster_name' => $topic['lastposter'],
|
||||
@@ -569,13 +594,13 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'tag_prefix' => 1, # key to this whole operation right here
|
||||
) );
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
|
||||
/* Tags */
|
||||
if( $topic['taglist'] !== NULL AND !empty( $topic['taglist'] ) )
|
||||
{
|
||||
$tags = explode( ',', $topic['taglist'] );
|
||||
if ( \count( $tags ) )
|
||||
if ( count( $tags ) )
|
||||
{
|
||||
foreach( $tags AS $tag )
|
||||
{
|
||||
@@ -698,7 +723,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'ip_address' => $post['ipaddress'],
|
||||
'post_date' => $post['dateline'],
|
||||
'queued' => $queued,
|
||||
'post_htmlstate' => ( static::$isLegacy === FALSE AND \in_array( $post['htmlstate'], array( 'on', 'on_nl2br' ) ) ) ? 1 : 0,
|
||||
'post_htmlstate' => ( static::$isLegacy === FALSE AND in_array( $post['htmlstate'], array( 'on', 'on_nl2br' ) ) ) ? 1 : 0,
|
||||
);
|
||||
|
||||
/* Edited? */
|
||||
@@ -710,7 +735,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$info['edit_name'] = $lastEdit['username'];
|
||||
$info['post_edit_reason'] = $lastEdit['reason'] ?? null;
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
|
||||
$libraryClass->convertForumsPost( $info );
|
||||
|
||||
@@ -803,7 +828,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$where = NULL;
|
||||
$column = NULL;
|
||||
|
||||
if ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) )
|
||||
if ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) )
|
||||
{
|
||||
$where = array( "contenttypeid=?", static::$postContentType );
|
||||
$column = 'contentid';
|
||||
@@ -819,25 +844,25 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$topic_id = $this->db->select( 'threadid', 'post', array( "postid=?", $attachment[$column] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
/* If the topic is missing, there isn't much we can do. */
|
||||
$libraryClass->setLastKeyValue( $attachment['attachmentid'] );
|
||||
$this->app->log( 'vb_attach_missing_topic', __METHOD__, \IPS\convert\App::LOG_WARNING, $attachment['attachmentid'] );
|
||||
$this->app->log( 'vb_attach_missing_topic', __METHOD__, App::LOG_WARNING, $attachment['attachmentid'] );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) )
|
||||
if ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$filedata = $this->db->select( '*', 'filedata', array( "filedataid=?", $attachment['filedataid'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
/* If the filedata row is missing, there isn't much we can do. */
|
||||
$libraryClass->setLastKeyValue( $attachment['attachmentid'] );
|
||||
$this->app->log( 'vb_attach_missing_filedata', __METHOD__, \IPS\convert\App::LOG_WARNING, $attachment['attachmentid'] );
|
||||
$this->app->log( 'vb_attach_missing_filedata', __METHOD__, App::LOG_WARNING, $attachment['attachmentid'] );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -884,17 +909,17 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$pid = $this->app->getLink( $attachment[$column], '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();
|
||||
|
||||
if ( preg_match( "/\[ATTACH([^\]]+?)?\]".$attachment['attachmentid']."\[\/ATTACH\]/i", $post ) )
|
||||
{
|
||||
$post = preg_replace( "/\[ATTACH([^\]]+?)?\]" . $attachment['attachmentid'] . "\[\/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 ) );
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( \OutOfRangeException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
catch( OutOfRangeException $e ) {}
|
||||
}
|
||||
|
||||
$libraryClass->setLastKeyValue( $attachment['attachmentid'] );
|
||||
@@ -910,7 +935,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
$libraryClass::setKey( 'groupid' );
|
||||
foreach( $this->fetch( 'socialgroup', 'groupid', array( \IPS\Db::i()->bitwiseWhere( array( 'options' => static::$bitOptions['cluboptions'] ), 'enable_group_messages' ) ) ) AS $row )
|
||||
foreach( $this->fetch( 'socialgroup', 'groupid', array( Db::i()->bitwiseWhere( array( 'options' => static::$bitOptions['cluboptions'] ), 'enable_group_messages' ) ) ) AS $row )
|
||||
{
|
||||
$libraryClass->convertClubForum( array(
|
||||
'id' => "clubforum{$row['groupid']}",
|
||||
@@ -939,7 +964,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$firstpost = $this->db->select( '*', 'groupmessage', array( "gmid=?", $row['firstpostid'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$libraryClass->setLastKeyValue( $row['discussionid'] );
|
||||
continue;
|
||||
@@ -1022,7 +1047,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
/**
|
||||
* @brief Silly Bitwise
|
||||
*/
|
||||
public static $bitOptions = array (
|
||||
public static array $bitOptions = array (
|
||||
'forumoptions' => array(
|
||||
'active' => 1,
|
||||
'allowposting' => 2,
|
||||
@@ -1059,38 +1084,38 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
/**
|
||||
* Check if we can redirect the legacy URLs from this software to the new locations
|
||||
*
|
||||
* @return NULL|\IPS\Http\Url
|
||||
* @return NULL|Url
|
||||
*/
|
||||
public function checkRedirects()
|
||||
{
|
||||
$url = \IPS\Request::i()->url();
|
||||
$url = Request::i()->url();
|
||||
|
||||
/* If it looks like a VBSEO URL, rewrite it */
|
||||
if( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], '.html' ) !== FALSE )
|
||||
if( mb_strpos( $url->data[ Url::COMPONENT_PATH ], '.html' ) !== FALSE )
|
||||
{
|
||||
/* Paginated topics */
|
||||
if( preg_match( "/\/(\d+)\-.+?\-(\d+)\.html/", $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
if( preg_match( "/\/(\d+)\-.+?\-(\d+)\.html/", $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
$url = $url->setPath( preg_replace( "/\/(\d+)\-.+?\-(\d+)\.html/", "/showthread.php", $url->data[ \IPS\Http\Url::COMPONENT_PATH ] ) )->setQueryString( array( 't' => $matches[1], 'page' => $matches[2] ) );
|
||||
\IPS\Request::i()->t = $matches[1];
|
||||
\IPS\Request::i()->page = $matches[2];
|
||||
$url = $url->setPath( preg_replace( "/\/(\d+)\-.+?\-(\d+)\.html/", "/showthread.php", $url->data[ Url::COMPONENT_PATH ] ) )->setQueryString( array( 't' => $matches[1], 'page' => $matches[2] ) );
|
||||
Request::i()->t = $matches[1];
|
||||
Request::i()->page = $matches[2];
|
||||
}
|
||||
/* Normal Topics */
|
||||
elseif( preg_match( "/\/(\d+)\-.+?\.html/", $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
elseif( preg_match( "/\/(\d+)\-.+?\.html/", $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
$url = $url->setPath( preg_replace( "/\/(\d+)\-.+?\.html/", "/showthread.php", $url->data[ \IPS\Http\Url::COMPONENT_PATH ] ) )->setQueryString( 't', $matches[1] );
|
||||
\IPS\Request::i()->t = $matches[1];
|
||||
$url = $url->setPath( preg_replace( "/\/(\d+)\-.+?\.html/", "/showthread.php", $url->data[ Url::COMPONENT_PATH ] ) )->setQueryString( 't', $matches[1] );
|
||||
Request::i()->t = $matches[1];
|
||||
}
|
||||
/* Post Links */
|
||||
elseif( preg_match( "/\/(\d+)\-.+?\-post(\d+)\.html/", $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
elseif( preg_match( "/\/(\d+)\-.+?\-post(\d+)\.html/", $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
$url = $url->setPath( preg_replace( "/\/(\d+)\-.+?\-post(\d+)\.html/", "/showpost.php", $url->data[ \IPS\Http\Url::COMPONENT_PATH ] ) )->setQueryString( 'p', $matches[2] );
|
||||
\IPS\Request::i()->p = $matches[2];
|
||||
$url = $url->setPath( preg_replace( "/\/(\d+)\-.+?\-post(\d+)\.html/", "/showpost.php", $url->data[ Url::COMPONENT_PATH ] ) )->setQueryString( 'p', $matches[2] );
|
||||
Request::i()->p = $matches[2];
|
||||
}
|
||||
}
|
||||
|
||||
/* Forum URLs are the same across VB 3.8 and VB 4 */
|
||||
if( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'forumdisplay.php' ) !== FALSE )
|
||||
if( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'forumdisplay.php' ) !== FALSE )
|
||||
{
|
||||
/* Forum URLs can be in one of 4 formats really...
|
||||
* /forumdisplay.php/1-name
|
||||
@@ -1098,14 +1123,14 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
* /forumdisplay.php?f=1
|
||||
* /forumdisplay.php?1-name
|
||||
*/
|
||||
$path = $url->data[ \IPS\Http\Url::COMPONENT_PATH ];
|
||||
$path = $url->data[ Url::COMPONENT_PATH ];
|
||||
if( mb_strpos( $path, 'forumdisplay.php' ) !== FALSE )
|
||||
{
|
||||
if( isset( \IPS\Request::i()->f ) )
|
||||
if( isset( Request::i()->f ) )
|
||||
{
|
||||
$oldId = \IPS\Request::i()->f;
|
||||
$oldId = Request::i()->f;
|
||||
}
|
||||
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];
|
||||
}
|
||||
@@ -1121,72 +1146,72 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( $oldId, array( 'forums', 'forums_forums' ) );
|
||||
$item = \IPS\forums\Forum::load( $data );
|
||||
$item = Forum::load( $data );
|
||||
|
||||
if( $item->can( 'view' ) )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif( preg_match( '#/forums/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
elseif( preg_match( '#/forums/([0-9]+)#i', $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( (int) $matches[1], array( 'forums', 'forums_forums' ) );
|
||||
$item = \IPS\forums\Forum::load( $data );
|
||||
$item = Forum::load( $data );
|
||||
|
||||
if( $item->can( 'view' ) )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/* And then post URLs, simple */
|
||||
elseif(
|
||||
( 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( (int) $postId, array( 'posts', 'forums_posts' ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
/* Try the main table */
|
||||
$data = (string) $this->app->getLink( (int) $postId, array( 'posts', 'forums_posts' ), 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 )
|
||||
elseif( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'showthread.php' ) !== FALSE OR
|
||||
mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'printthread.php' ) !== FALSE )
|
||||
{
|
||||
/* Topic URLs can be in one of 4 formats really...
|
||||
* /showthread.php/1-name
|
||||
@@ -1196,18 +1221,18 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
* /printthread.php?t=1
|
||||
* /showthread.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];
|
||||
}
|
||||
@@ -1217,7 +1242,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$oldId = $queryStringPieces[0];
|
||||
}
|
||||
}
|
||||
elseif( preg_match( '#/forums/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
elseif( preg_match( '#/forums/([0-9]+)#i', $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
$oldId = (int) $matches[1];
|
||||
}
|
||||
@@ -1230,25 +1255,25 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$data = (string) $this->app->getLink( $oldId, array( 'topics', 'forums_topics' ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
/* Try the main table */
|
||||
$data = (string) $this->app->getLink( $oldId, 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif( preg_match( '#/threads/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
elseif( preg_match( '#/threads/([0-9]+)#i', $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1256,27 +1281,27 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$data = (string) $this->app->getLink( (int) $matches[1], array( 'topics', 'forums_topics' ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
/* Try the main table */
|
||||
$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;
|
||||
}
|
||||
}
|
||||
/* And finally, archives */
|
||||
elseif( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'archive/index.php' ) !== FALSE )
|
||||
elseif( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'archive/index.php' ) !== FALSE )
|
||||
{
|
||||
$request = explode( '/', $url->data[ \IPS\Http\Url::COMPONENT_PATH ] );
|
||||
$request = explode( '/', $url->data[ Url::COMPONENT_PATH ] );
|
||||
$parameters = explode( '-', array_pop( $request ) );
|
||||
$parameters[1] = str_replace( '.html', '', $parameters[1] );
|
||||
|
||||
@@ -1289,11 +1314,11 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$data = $this->app->getLink( (string) $parameters[1], array( 'topics', 'forums_topics' ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$data = $this->app->getLink( (string) $parameters[1], array( 'topics', 'forums_topics' ), FALSE, TRUE );
|
||||
}
|
||||
$item = \IPS\forums\Topic::load( $data );
|
||||
$item = Topic::load( $data );
|
||||
|
||||
if( $item->canView() )
|
||||
{
|
||||
@@ -1303,7 +1328,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
|
||||
case 'f':
|
||||
$data = $this->app->getLink( (string) $parameters[1], array( 'forums', 'forums_forums' ) );
|
||||
$item = \IPS\forums\Forum::load( $data );
|
||||
$item = Forum::load( $data );
|
||||
|
||||
if( $item->can( 'view' ) )
|
||||
{
|
||||
@@ -1312,26 +1337,26 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/* Club Discussions */
|
||||
elseif( ( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'group.php' ) !== FALSE AND isset( \IPS\Request::i()->discussionid ) ) OR
|
||||
preg_match( '#/social-groups/(.*)/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
elseif( ( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'group.php' ) !== FALSE AND isset( Request::i()->discussionid ) ) OR
|
||||
preg_match( '#/social-groups/(.*)/([0-9]+)#i', $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
$id = \IPS\Request::i()->discussionid ?? $matches[2];
|
||||
$id = Request::i()->discussionid ?? $matches[2];
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( 'clubtopic' . $id, array( 'topics', 'forums_topics' ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$item = \IPS\forums\Topic::load( $data );
|
||||
$item = Topic::load( $data );
|
||||
|
||||
if( $item->canView() )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user