Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -12,16 +12,42 @@
namespace IPS\convert\Software\Core;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DateTimeZone;
use DomainException;
use Exception;
use InvalidArgumentException;
use IPS\Application;
use IPS\Application\Module;
use IPS\Content\Search\Index;
use IPS\convert\App;
use IPS\convert\Library;
use IPS\convert\Software;
use IPS\Data\Cache;
use IPS\Data\Store;
use IPS\Db;
use IPS\File;
use IPS\Http\Url;
use IPS\Member;
use IPS\Patterns\ActiveRecordIterator;
use IPS\Request;
use IPS\Task;
use UnderflowException;
use function count;
use function defined;
use function in_array;
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 Core Converter
*/
class _Invisioncommunity extends \IPS\convert\Software
class Invisioncommunity extends Software
{
/**
* @brief Whether the versions of IPS4 match
@@ -36,15 +62,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 +83,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;
}
@@ -76,7 +102,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 . ')';
}
/**
@@ -171,14 +197,6 @@ class _Invisioncommunity extends \IPS\convert\Software
'table' => 'core_member_history',
'where' => array( 'log_app=? AND log_type=?', 'core', 'display_name' )
),
'convertStatuses' => array(
'table' => 'core_member_status_updates',
'where' => NULL
),
'convertStatusReplies' => array(
'table' => 'core_member_status_replies',
'where' => NULL
),
'convertMemberHistory' => array(
'table' => 'core_member_history',
'where' => array( 'log_app=? AND log_type!=?', 'core', 'display_name' )
@@ -265,16 +283,16 @@ class _Invisioncommunity extends \IPS\convert\Software
case 'convertClubs':
case 'convertAttachments':
case 'convertReactions':
\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->app->_session['more_info']['convertEmoticons']['upload_path'] ) ? $this->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_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
'field_hint' => Member::loggedIn()->language()->addToStack('convert_invision_upload_path'),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
)
);
@@ -294,16 +312,16 @@ class _Invisioncommunity extends \IPS\convert\Software
$return['convertProfileFields'] = array();
$options = array();
$options['none'] = \IPS\Member::loggedIn()->language()->addToStack( 'none' );
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_pfields_data' ), 'IPS\core\ProfileFields\Field' ) AS $field )
$options['none'] = Member::loggedIn()->language()->addToStack( 'none' );
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'core_pfields_data' ), 'IPS\core\ProfileFields\Field' ) AS $field )
{
$options[ $field->_id ] = $field->_title;
}
foreach( $this->db->select( '*', 'core_pfields_data' ) AS $field )
{
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['pf_id']}"] = $this->getWord( 'core_pfield_' . $field['pf_id'] );
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['pf_id']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_pfield_desc' );
Member::loggedIn()->language()->words["map_pfield_{$field['pf_id']}"] = $this->getWord( 'core_pfield_' . $field['pf_id'] );
Member::loggedIn()->language()->words["map_pfield_{$field['pf_id']}_desc"] = Member::loggedIn()->language()->addToStack( 'map_pfield_desc' );
$return['convertProfileFields']["map_pfield_{$field['pf_id']}"] = array(
'field_class' => 'IPS\\Helpers\\Form\\Select',
@@ -320,15 +338,15 @@ class _Invisioncommunity extends \IPS\convert\Software
$options = array();
$options['none'] = 'None';
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
{
$options[$group->g_id] = $group->name;
}
foreach( $this->db->select( '*', 'core_groups' ) AS $group )
{
\IPS\Member::loggedIn()->language()->words["map_group_{$group['g_id']}"] = $this->getWord( 'core_group_' . $group['g_id'] );
\IPS\Member::loggedIn()->language()->words["map_group_{$group['g_id']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_group_desc' );
Member::loggedIn()->language()->words["map_group_{$group['g_id']}"] = $this->getWord( 'core_group_' . $group['g_id'] );
Member::loggedIn()->language()->words["map_group_{$group['g_id']}_desc"] = Member::loggedIn()->language()->addToStack( 'map_group_desc' );
$return['convertGroups']["map_group_{$group['g_id']}"] = array(
'field_class' => 'IPS\\Helpers\\Form\\Select',
@@ -352,24 +370,24 @@ class _Invisioncommunity extends \IPS\convert\Software
public function finish()
{
/* Search Index Rebuild */
\IPS\Content\Search\Index::i()->rebuild();
Index::i()->rebuild();
/* Clear Cache and Store */
\IPS\Data\Store::i()->clearAll();
\IPS\Data\Cache::i()->clearAll();
Store::i()->clearAll();
Cache::i()->clearAll();
/* Content Counts */
\IPS\Task::queue( 'core', 'RecountMemberContent', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
Task::queue( 'core', 'RecountMemberContent', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
/* First Post Data */
\IPS\Task::queue( 'convert', 'RebuildConversationFirstIds', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
Task::queue( 'convert', 'RebuildConversationFirstIds', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
/* Clubs */
\IPS\Task::queue( 'convert', 'RecountClubMembers', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
Task::queue( 'convert', 'RecountClubMembers', array( 'app' => $this->app->app_id ), 2, array( 'app' ) );
/* Attachments */
\IPS\Task::queue( 'core', 'RebuildAttachmentThumbnails', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
Task::queue( 'core', 'RebuildAttachmentThumbnails', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
return array( "f_search_index_rebuild", "f_clear_caches" );
}
@@ -496,22 +514,22 @@ class _Invisioncommunity extends \IPS\convert\Software
{
try
{
\IPS\File::get( 'core_Emoticons', $row['filename'] );
File::get( 'core_Emoticons', $row['filename'] );
}
catch( \Exception $ex )
catch( Exception $ex )
{
\IPS\File::create( 'core_Emoticons', $row['filename'], file_get_contents( $path . '/' . $row['filename'] ), 'emoticons', FALSE, NULL, FALSE );
File::create( 'core_Emoticons', $row['filename'], file_get_contents( $path . '/' . $row['filename'] ), 'emoticons', FALSE, NULL, FALSE );
}
if( isset( $path2 ) )
{
try
{
\IPS\File::get( 'core_Emoticons', $row['filenamex2'] );
File::get( 'core_Emoticons', $row['filenamex2'] );
}
catch( \Exception $ex )
catch( Exception $ex )
{
\IPS\File::create( 'core_Emoticons', $row['filenamex2'], file_get_contents( $path2 . '/' . $row['filenamex2'] ), 'emoticons', FALSE, NULL, FALSE );
File::create( 'core_Emoticons', $row['filenamex2'], file_get_contents( $path2 . '/' . $row['filenamex2'] ), 'emoticons', FALSE, NULL, FALSE );
}
}
}
@@ -566,7 +584,7 @@ class _Invisioncommunity extends \IPS\convert\Software
}
/* Now check for group promotions */
if( \count( $libraryClass->groupPromotions ) )
if( count( $libraryClass->groupPromotions ) )
{
foreach( $libraryClass->groupPromotions as $groupPromotion )
{
@@ -641,7 +659,7 @@ class _Invisioncommunity extends \IPS\convert\Software
$this->unsetNonStandardColumns( $row, 'core_members' );
$profilePhotoName = NULL;
if( !\in_array( $row['pp_photo_type'], array( 'letter', 'none', 'twitter', 'facebook', 'microsoft', '' ) ) )
if( !in_array( $row['pp_photo_type'], array( 'letter', 'none', 'twitter', 'facebook', 'microsoft', '' ) ) )
{
$bits = explode( '/', $row['pp_main_photo'] );
$profilePhotoName = array_pop( $bits );
@@ -667,7 +685,7 @@ class _Invisioncommunity extends \IPS\convert\Software
$profileFields[ str_replace( 'field_', '', $key ) ] = $value;
}
}
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
$profileFields = array();
}
@@ -675,9 +693,9 @@ class _Invisioncommunity extends \IPS\convert\Software
/* Load TZ into an object and validate */
try
{
$row['timezone'] = new \DateTimeZone( $row['timezone'] );
$row['timezone'] = new DateTimeZone( $row['timezone'] );
}
catch( \Exception $e )
catch( Exception $e )
{
unset( $row['timezone'] );
}
@@ -892,46 +910,6 @@ class _Invisioncommunity extends \IPS\convert\Software
}
}
/**
* Convert status updates
*
* @return void
*/
public function convertStatuses()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'status_id' );
foreach( $this->fetch( 'core_member_status_updates', 'status_id' ) AS $row )
{
/* Remove non-standard columns */
$this->unsetNonStandardColumns( $row, 'core_member_status_updates' );
$libraryClass->convertStatus( $row );
$libraryClass->setLastKeyValue( $row['status_id'] );
}
}
/**
* Convert status updates
*
* @return void
*/
public function convertStatusReplies()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'reply_id' );
foreach( $this->fetch( 'core_member_status_replies', 'status_id' ) AS $row )
{
/* Remove non-standard columns */
$this->unsetNonStandardColumns( $row, 'core_member_status_replies' );
$libraryClass->convertStatusReply( $row );
$libraryClass->setLastKeyValue( $row['reply_id'] );
}
}
/**
* Convert ignored users
*
@@ -1092,7 +1070,7 @@ class _Invisioncommunity extends \IPS\convert\Software
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'attach_id' );
$mapTypes = array_keys( \IPS\Application::load('core')->extensions( 'core', 'EditorLocations', FALSE, FALSE ) );
$mapTypes = array_keys( Application::load('core')->extensions( 'core', 'EditorLocations', FALSE, FALSE ) );
array_walk( $mapTypes, function( &$value )
{
$value = 'core_' . $value;
@@ -1102,9 +1080,9 @@ class _Invisioncommunity extends \IPS\convert\Software
{
try
{
$attachmentMap = $this->db->select( '*', 'core_attachments_map', array( 'attachment_id=? AND ' . \IPS\Db::i()->in( 'location_key', $mapTypes ), $row['attach_id'] ) )->first();
$attachmentMap = $this->db->select( '*', 'core_attachments_map', array( 'attachment_id=? AND ' . Db::i()->in( 'location_key', $mapTypes ), $row['attach_id'] ) )->first();
}
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
$libraryClass->setLastKeyValue( $row['attach_id'] );
continue;
@@ -1227,7 +1205,7 @@ class _Invisioncommunity extends \IPS\convert\Software
$result = $this->_words[ $key ] = $this->db->select( 'word_custom, word_default', 'core_sys_lang_words', array( 'word_key=? AND lang_id=?', $key, $this->_defaultLanguage() ) )->first();
}
/* Can't find the word, so return the original string */
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
return $this->_words[ $key ] = $key;
}
@@ -1283,24 +1261,24 @@ 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->app_id ) )
if( !stristr( $url->data[ Url::COMPONENT_PATH ], 'ic-merge-' . $this->app->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( '#/profile/([0-9]+)-(.+?)#i', $searchOn, $matches ) )
{
/* If we can't access profiles, don't bother trying to redirect */
if( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) )
if( !Member::loggedIn()->canAccessModule( Module::get( 'core', 'members' ) ) )
{
return NULL;
}
@@ -1308,9 +1286,9 @@ class _Invisioncommunity extends \IPS\convert\Software
try
{
$data = (string) $this->app->getLink( (int) $matches[1], array( 'members', 'core_members' ) );
return \IPS\Member::load( $data )->url();
return Member::load( $data )->url();
}
catch( \Exception $e )
catch( Exception $e )
{
return NULL;
}