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,35 @@
|
||||
namespace IPS\convert\Software\Downloads;
|
||||
|
||||
/* 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\Application;
|
||||
use IPS\Content;
|
||||
use IPS\convert\App;
|
||||
use IPS\convert\Library;
|
||||
use IPS\convert\Software;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Request;
|
||||
use IPS\Task;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
use function stristr;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invision Downloads Converter
|
||||
*/
|
||||
class _Invisioncommunity extends \IPS\convert\Software
|
||||
class Invisioncommunity extends Software
|
||||
{
|
||||
/**
|
||||
* @brief Whether the versions of IPS4 match
|
||||
@@ -36,15 +55,15 @@ class _Invisioncommunity 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 )
|
||||
{
|
||||
/* Set filename obscuring flag */
|
||||
\IPS\convert\Library::$obscureFilenames = FALSE;
|
||||
Library::$obscureFilenames = FALSE;
|
||||
|
||||
$return = parent::__construct( $app, $needDB );
|
||||
|
||||
@@ -57,7 +76,7 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
$version = $this->db->select( 'app_version', 'core_applications', array( 'app_directory=?', 'core' ) )->first();
|
||||
|
||||
/* We're matching against the human version since the long version can change with patches */
|
||||
if ( $version == \IPS\Application::load( 'core' )->version )
|
||||
if ( $version == Application::load( 'core' )->version )
|
||||
{
|
||||
static::$versionMatch = TRUE;
|
||||
}
|
||||
@@ -79,7 +98,7 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
public static function softwareName()
|
||||
{
|
||||
/* Child classes must override this method */
|
||||
return 'Invision Community (' . \IPS\Application::load( 'core' )->version . ')';
|
||||
return 'Invision Community (' . Application::load( 'core' )->version . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,11 +192,11 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\downloads\File', 'count' => 0 ), 4, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\downloads\Category', 'count' => 0 ), 5, array( 'class' ) );
|
||||
\IPS\Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File', 'link' => 'downloads_files' ), 2, array( 'app', 'link', 'class' ) );
|
||||
\IPS\Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File\Review', 'link' => 'downloads_reviews' ), 2, array( 'app', 'link', 'class' ) );
|
||||
\IPS\Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File\Comment', 'link' => 'downloads_comments' ), 2, array( 'app', 'link', 'class' ) );
|
||||
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\downloads\File', 'count' => 0 ), 4, array( 'class' ) );
|
||||
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\downloads\Category', 'count' => 0 ), 5, array( 'class' ) );
|
||||
Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File', 'link' => 'downloads_files' ), 2, array( 'app', 'link', 'class' ) );
|
||||
Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File\Review', 'link' => 'downloads_reviews' ), 2, array( 'app', 'link', 'class' ) );
|
||||
Task::queue( 'convert', 'InvisionCommunityRebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File\Comment', 'link' => 'downloads_comments' ), 2, array( 'app', 'link', 'class' ) );
|
||||
|
||||
return array( );
|
||||
}
|
||||
@@ -198,7 +217,7 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
{
|
||||
$attachmentMap = $this->db->select( '*', 'core_attachments_map', array( 'attachment_id=? AND location_key=?', $row['attach_id'], 'downloads_Downloads' ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$libraryClass->setLastKeyValue( $row['attach_id'] );
|
||||
continue;
|
||||
@@ -238,19 +257,19 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
{
|
||||
case 'convertAttachments':
|
||||
case 'convertDownloadsFiles':
|
||||
\IPS\Member::loggedIn()->language()->words["upload_path"] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input' );
|
||||
\IPS\Member::loggedIn()->language()->words["upload_path_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input_desc' );
|
||||
Member::loggedIn()->language()->words["upload_path"] = Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input' );
|
||||
Member::loggedIn()->language()->words["upload_path_desc"] = Member::loggedIn()->language()->addToStack( 'convert_invision_upload_input_desc' );
|
||||
$return[ $method ] = array(
|
||||
'upload_path' => array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Text',
|
||||
'field_default' => isset( $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] ) ? $this->parent->app->_session['more_info']['convertEmoticons']['upload_path'] : NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack( 'convert_invision_upload_path' ),
|
||||
'field_hint' => Member::loggedIn()->language()->addToStack( 'convert_invision_upload_path' ),
|
||||
'field_validation' => function ( $value ) {
|
||||
if ( !@is_dir( $value ) )
|
||||
{
|
||||
throw new \DomainException( 'path_invalid' );
|
||||
throw new DomainException( 'path_invalid' );
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -457,19 +476,19 @@ class _Invisioncommunity 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( !\stristr( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'ic-merge-' . $this->app->_parent->app_id ) )
|
||||
if( !stristr( $url->data[ Url::COMPONENT_PATH ], 'ic-merge-' . $this->app->_parent->app_id ) )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* account for non-mod_rewrite links */
|
||||
$searchOn = \stristr( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'index.php' ) ? $url->data[ \IPS\Http\Url::COMPONENT_QUERY ] : $url->data[ \IPS\Http\Url::COMPONENT_PATH ];
|
||||
$searchOn = stristr( $url->data[ Url::COMPONENT_PATH ], 'index.php' ) ? $url->data[ Url::COMPONENT_QUERY ] : $url->data[ Url::COMPONENT_PATH ];
|
||||
|
||||
if( preg_match( '#/(category|file)/([0-9]+)-(.+?)#i', $searchOn, $matches ) )
|
||||
{
|
||||
@@ -497,20 +516,20 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
{
|
||||
$data = (string) $this->app->getLink( $oldId, $types );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$data = (string) $this->app->getLink( $oldId, $types, FALSE, TRUE );
|
||||
}
|
||||
$item = $class::load( $data );
|
||||
|
||||
if( $item instanceof \IPS\Content )
|
||||
if( $item instanceof Content )
|
||||
{
|
||||
if( $item->canView() )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
elseif( $item instanceof \IPS\Node\Model )
|
||||
elseif( $item instanceof Model )
|
||||
{
|
||||
if( $item->can( 'view' ) )
|
||||
{
|
||||
@@ -518,7 +537,7 @@ class _Invisioncommunity extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -12,18 +12,39 @@
|
||||
namespace IPS\convert\Software\Downloads;
|
||||
|
||||
/* 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\Content;
|
||||
use IPS\convert\App;
|
||||
use IPS\convert\Software;
|
||||
use IPS\convert\Tools\Xenforo;
|
||||
use IPS\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Request;
|
||||
use IPS\Task;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_null;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Xenforo Downloads Converter
|
||||
*/
|
||||
class _Xenforo extends \IPS\convert\Software
|
||||
class Xenforo extends Software
|
||||
{
|
||||
use \IPS\convert\Tools\Xenforo;
|
||||
use Xenforo;
|
||||
|
||||
/**
|
||||
* @brief The similarities between XF1 and XF2 are close enough that we can use the same converter
|
||||
@@ -43,12 +64,12 @@ class _Xenforo 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 );
|
||||
|
||||
@@ -59,7 +80,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
/* Is this XF1 or XF2 */
|
||||
if ( static::$isLegacy === NULL )
|
||||
{
|
||||
$version = $this->db->select( 'MAX(version_id)', 'xf_template', array( \IPS\Db::i()->in( 'addon_id', array( 'XF', 'XenForo' ) ) ) )->first();
|
||||
$version = $this->db->select( 'MAX(version_id)', 'xf_template', array( Db::i()->in( 'addon_id', array( 'XF', 'XenForo' ) ) ) )->first();
|
||||
|
||||
if ( $version < 2000010 )
|
||||
{
|
||||
@@ -78,7 +99,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) {} # If we can't query, we won't be able to do anything anyway
|
||||
catch( Exception $e ) {} # If we can't query, we won't be able to do anything anyway
|
||||
}
|
||||
|
||||
return $return;
|
||||
@@ -205,10 +226,10 @@ class _Xenforo extends \IPS\convert\Software
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\downloads\File', 'count' => 0 ), 4, array( 'class' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\downloads\Category', 'count' => 0 ), 5, array( 'class' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File', 'link' => 'downloads_files' ), 2, array( 'app', 'link', 'class' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File\Review', 'link' => 'downloads_reviews' ), 2, array( 'app', 'link', 'class' ) );
|
||||
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\downloads\File', 'count' => 0 ), 4, array( 'class' ) );
|
||||
Task::queue( 'core', 'RebuildContainerCounts', array( 'class' => 'IPS\downloads\Category', 'count' => 0 ), 5, array( 'class' ) );
|
||||
Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File', 'link' => 'downloads_files' ), 2, array( 'app', 'link', 'class' ) );
|
||||
Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'class' => 'IPS\downloads\File\Review', 'link' => 'downloads_reviews' ), 2, array( 'app', 'link', 'class' ) );
|
||||
|
||||
return array( );
|
||||
}
|
||||
@@ -230,8 +251,8 @@ class _Xenforo extends \IPS\convert\Software
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_xf_attach_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_hint' => Member::loggedIn()->language()->addToStack('convert_xf_attach_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -259,10 +280,10 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
try
|
||||
{
|
||||
$title = ( static::$isLegacy === FALSE OR \is_null( static::$isLegacy ) ) ? $xfTwoTitle : $xfOneTitle;
|
||||
$title = ( static::$isLegacy === FALSE OR is_null( static::$isLegacy ) ) ? $xfTwoTitle : $xfOneTitle;
|
||||
return $this->db->select( 'phrase_text', 'xf_phrase', array( "title=?", $title ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -298,7 +319,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
'cf_max_input' => $row['max_length'],
|
||||
'cf_input_format' => $inputFormat,
|
||||
'cf_position' => $row['display_order'],
|
||||
'cf_multiple' => ( \in_array( $row['field_type'], array( 'checkbox', 'multiselect' ) ) ) ? 1 : 0
|
||||
'cf_multiple' => ( in_array( $row['field_type'], array( 'checkbox', 'multiselect' ) ) ) ? 1 : 0
|
||||
);
|
||||
|
||||
$libraryClass->convertDownloadsCfield( $info );
|
||||
@@ -383,7 +404,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
$prefix = $this->getPhrase( "thread_prefix_{$row['thread_prefix_id']}", "thread_prefix.{$row['thread_prefix_id']}" );
|
||||
|
||||
if ( \is_null( $prefix ) )
|
||||
if ( is_null( $prefix ) )
|
||||
{
|
||||
$prefix = '';
|
||||
}
|
||||
@@ -455,7 +476,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
|
||||
$featured = 1;
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
|
||||
$info = array(
|
||||
'file_id' => $row['resource_id'],
|
||||
@@ -493,9 +514,9 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
$file_data = $this->db->select( '*', 'xf_attachment', array( "xf_attachment.content_type=? AND xf_attachment.content_id=?", 'resource_version', $record['resource_version_id'] ) )->join( 'xf_attachment_data', "xf_attachment.data_id = xf_attachment_data.data_id" )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$this->app->log( 'xenforo_resource_missing_record', __METHOD__, \IPS\convert\App::LOG_WARNING, $record['resource_update_id'] );
|
||||
$this->app->log( 'xenforo_resource_missing_record', __METHOD__, App::LOG_WARNING, $record['resource_update_id'] );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -525,9 +546,9 @@ class _Xenforo extends \IPS\convert\Software
|
||||
);
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$this->app->log( 'xenforo_resource_missing_screenshot', __METHOD__, \IPS\convert\App::LOG_WARNING, $record['resource_update_id'] );
|
||||
$this->app->log( 'xenforo_resource_missing_screenshot', __METHOD__, App::LOG_WARNING, $record['resource_update_id'] );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,9 +557,9 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
$field_type = $this->db->select( 'field_type', 'xf_' . static::$tablePrefix . 'resource_field', array( "field_id=?", $key ) )->first();
|
||||
|
||||
if ( \in_array( $field_type, array( 'checkbox', 'multiselect' ) ) )
|
||||
if ( in_array( $field_type, array( 'checkbox', 'multiselect' ) ) )
|
||||
{
|
||||
$cfields[$key] = static::$isLegacy ? json_encode( \unserialize( $value ) ) : $value;
|
||||
$cfields[$key] = static::$isLegacy ? json_encode( unserialize( $value ) ) : $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -652,13 +673,13 @@ class _Xenforo 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( preg_match( '#/(resources/categories|resources)/(.+?)\.([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
if( preg_match( '#/(resources/categories|resources)/(.+?)\.([0-9]+)#i', $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
$oldId = (int) $matches[3];
|
||||
|
||||
@@ -684,20 +705,20 @@ class _Xenforo extends \IPS\convert\Software
|
||||
{
|
||||
$data = (string) $this->app->getLink( $oldId, $types );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$data = (string) $this->app->getLink( $oldId, $types, FALSE, TRUE );
|
||||
}
|
||||
$item = $class::load( $data );
|
||||
|
||||
if( $item instanceof \IPS\Content )
|
||||
if( $item instanceof Content )
|
||||
{
|
||||
if( $item->canView() )
|
||||
{
|
||||
return $item->url();
|
||||
}
|
||||
}
|
||||
elseif( $item instanceof \IPS\Node\Model )
|
||||
elseif( $item instanceof Model )
|
||||
{
|
||||
if( $item->can( 'view' ) )
|
||||
{
|
||||
@@ -705,7 +726,7 @@ class _Xenforo extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user