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,34 @@
|
||||
namespace IPS\convert\Software\Forums;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\convert\Software;
|
||||
use IPS\convert\Software\Core\UBBthreads;
|
||||
use IPS\DateTime;
|
||||
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\Request;
|
||||
use IPS\Task;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
use const PATHINFO_EXTENSION;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* UBBThreads Forums Converter
|
||||
*/
|
||||
class _UBBthreads extends \IPS\convert\Software
|
||||
class UBBthreads extends Software
|
||||
{
|
||||
/**
|
||||
* Software Name
|
||||
@@ -101,7 +119,7 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
$rows['convertForumsTopicsRatings'] = array(
|
||||
'step_method' => 'convertForumsTopicsRatings',
|
||||
'step_title' => 'convert_ratings',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_ratings' ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'core_ratings' ),
|
||||
'source_rows' => $count,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertForumsTopics' ),
|
||||
@@ -116,7 +134,7 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
$rows['convertForumsTopicsFollowers'] = array(
|
||||
'step_method' => 'convertForumsTopicsFollowers',
|
||||
'step_title' => 'convert_follows',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_follow' ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'core_follow' ),
|
||||
'source_rows' => $count,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertForumsTopics' ),
|
||||
@@ -198,7 +216,7 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_ubb_attach_path'),
|
||||
'field_hint' => Member::loggedIn()->language()->addToStack('convert_ubb_attach_path'),
|
||||
),
|
||||
);
|
||||
break;
|
||||
@@ -215,24 +233,26 @@ class _UBBthreads 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' ), 3, array( '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', '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' ), 3, array( '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' ) );
|
||||
|
||||
return array( "f_forum_last_post_data", "f_rebuild_posts", "f_recounting_forums", "f_recounting_topics" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fix post data
|
||||
* Pre-process content for the Invision Community text parser
|
||||
*
|
||||
* @param string $post raw post data
|
||||
* @return string Parsed post data
|
||||
* @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\UBBthreads::fixPostData( $post );
|
||||
return UBBthreads::fixPostData( $post, $className, $contentId );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,7 +289,7 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
'description' => $row['FORUM_DESCRIPTION'],
|
||||
'topics' => $row['FORUM_TOPICS'],
|
||||
'posts' => $row['FORUM_POSTS'],
|
||||
'last_post' => \IPS\DateTime::create()->setTimestamp( $row['FORUM_LAST_POST_TIME'] ),
|
||||
'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'] ),
|
||||
@@ -352,7 +372,7 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
'votes' => $votes
|
||||
) ),
|
||||
'poll_question' => strip_tags( $pollData['POLL_BODY'] ),
|
||||
'start_date' => \IPS\DateTime::create()->setTimestamp( $row['POLL_START_TIME'] ),
|
||||
'start_date' => DateTime::create()->setTimestamp( $row['POLL_START_TIME'] ),
|
||||
'starter_id' => $row['USER_ID'],
|
||||
);
|
||||
|
||||
@@ -380,7 +400,7 @@ class _UBBthreads 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
|
||||
}
|
||||
|
||||
$libraryClass->convertForumsTopic( array(
|
||||
@@ -390,9 +410,9 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
'state' => ( $row['TOPIC_STATUS'] == 'C' ) ? 'closed' : 'open',
|
||||
'posts' => $row['TOPIC_REPLIES'],
|
||||
'starter_id' => $row['USER_ID'],
|
||||
'start_date' => \IPS\DateTime::create()->setTimestamp( $row['TOPIC_CREATED_TIME'] ),
|
||||
'start_date' => DateTime::create()->setTimestamp( $row['TOPIC_CREATED_TIME'] ),
|
||||
'last_poster_id' => $row['TOPIC_LAST_POSTER_ID'],
|
||||
'last_post' => \IPS\DateTime::create()->setTimestamp( $row['TOPIC_LAST_REPLY_TIME'] ),
|
||||
'last_post' => DateTime::create()->setTimestamp( $row['TOPIC_LAST_REPLY_TIME'] ),
|
||||
'last_poster_name' => $row['TOPIC_LAST_POSTER_NAME'],
|
||||
'views' => $row['TOPIC_VIEWS'],
|
||||
'approved' => $row['TOPIC_IS_APPROVED'],
|
||||
@@ -469,7 +489,7 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
'author_id' => $row['USER_ID'],
|
||||
'author_name' => $row['POST_POSTER_NAME'],
|
||||
'ip_address' => $row['POST_POSTER_IP'],
|
||||
'post_date' => \IPS\DateTime::create()->setTimestamp( $row['POST_POSTED_TIME'] ),
|
||||
'post_date' => DateTime::create()->setTimestamp( $row['POST_POSTED_TIME'] ),
|
||||
'queued' => ( ! $row['POST_IS_APPROVED'] ),
|
||||
'new_topic' => $row['POST_IS_TOPIC'],
|
||||
) );
|
||||
@@ -501,15 +521,15 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
$map['id1'] = $topicId;
|
||||
$map['id2'] = $row['POST_ID'];
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
|
||||
$info = array(
|
||||
'attach_id' => $row['FILE_ID'],
|
||||
'attach_file' => $row['FILE_NAME'],
|
||||
'attach_date' => \IPS\DateTime::create()->setTimestamp( $row['FILE_ADD_TIME'] ),
|
||||
'attach_date' => DateTime::create()->setTimestamp( $row['FILE_ADD_TIME'] ),
|
||||
'attach_member_id' => $row['USER_ID'],
|
||||
'attach_hits' => $row['FILE_DOWNLOADS'],
|
||||
'attach_ext' => pathinfo( $row['FILE_NAME'], \PATHINFO_EXTENSION ),
|
||||
'attach_ext' => pathinfo( $row['FILE_NAME'], PATHINFO_EXTENSION ),
|
||||
'attach_filesize' => $row['FILE_SIZE'], // Note: Apparently not always readily available?
|
||||
);
|
||||
|
||||
@@ -521,37 +541,37 @@ class _UBBthreads 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();
|
||||
|
||||
/* Make sure it's a UBBThreads URL */
|
||||
if( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'ubbthreads.php' ) === FALSE )
|
||||
if( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'ubbthreads.php' ) === FALSE )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//ubbthreads.php?ubb=showflat&Number=?
|
||||
if( isset( \IPS\Request::i()->Number ) AND isset( \IPS\Request::i()->ubb ) )
|
||||
if( isset( Request::i()->Number ) AND isset( Request::i()->ubb ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( (int) \IPS\Request::i()->Number, array( 'posts', 'forums_posts' ) );
|
||||
$post = \IPS\forums\Topic\Post::load( $data );
|
||||
$data = (string) $this->app->getLink( (int) Request::i()->Number, array( 'posts', 'forums_posts' ) );
|
||||
$post = Post::load( $data );
|
||||
|
||||
if( $post->item()->canView() )
|
||||
{
|
||||
return $post->url();
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
elseif( preg_match( '#/ubbthreads.php/topics/([0-9]+)($|/)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
elseif( preg_match( '#/ubbthreads.php/topics/([0-9]+)($|/)#i', $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -559,64 +579,64 @@ class _UBBthreads extends \IPS\convert\Software
|
||||
{
|
||||
$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 )
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( (int) $matches[1], array( 'posts', 'forums_posts' ) );
|
||||
$post = \IPS\forums\Topic\Post::load( $data );
|
||||
$post = Post::load( $data );
|
||||
|
||||
if( $post->item()->canView() )
|
||||
{
|
||||
return $post->url();
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException $e ) { }
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
elseif( preg_match( '#/ubbthreads.php/forums/([0-9]+)($|/)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
elseif( preg_match( '#/ubbthreads.php/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;
|
||||
}
|
||||
}
|
||||
elseif( preg_match( '#ubbthreads.php/ubb/showflat/Number/([0-9]+)($|/)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
elseif( preg_match( '#ubbthreads.php/ubb/showflat/Number/([0-9]+)($|/)#i', $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( (int) $matches[1], array( 'posts', 'forums_posts' ) );
|
||||
$post = \IPS\forums\Topic\Post::load( $data );
|
||||
$post = Post::load( $data );
|
||||
|
||||
if( $post->item()->canView() )
|
||||
{
|
||||
return $post->url();
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user