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,52 @@
|
||||
namespace IPS\convert\Software\Core;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Application\Module;
|
||||
use IPS\Content\Search\Index;
|
||||
use IPS\convert\App;
|
||||
use IPS\convert\Library;
|
||||
use IPS\convert\Software;
|
||||
use IPS\core\Ignore;
|
||||
use IPS\Data\Cache;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Http\Request\Exception;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Image;
|
||||
use IPS\Login;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Club;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function is_null;
|
||||
use function preg_match;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
use function unserialize;
|
||||
use const ENT_HTML5;
|
||||
use const ENT_QUOTES;
|
||||
|
||||
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 Core 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 +77,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 );
|
||||
|
||||
@@ -70,7 +106,7 @@ 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();
|
||||
}
|
||||
@@ -144,10 +180,6 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'table' => 'userchangelog',
|
||||
'where' => NULL
|
||||
),
|
||||
'convertStatuses' => array(
|
||||
'table' => 'visitormessage',
|
||||
'where' => NULL
|
||||
),
|
||||
'convertIgnoredUsers' => array(
|
||||
'table' => 'userlist',
|
||||
'where' => array( "type=?", 'ignore' )
|
||||
@@ -190,7 +222,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$rows['convertMembersFollowers'] = array(
|
||||
'step_method' => 'convertMembersFollowers',
|
||||
'step_title' => 'convert_follows',
|
||||
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'core_follow', array( 'follow_app=? and follow_area=?', 'core', 'member' ) ),
|
||||
'ips_rows' => Db::i()->select( 'COUNT(*)', 'core_follow', array( 'follow_app=? and follow_area=?', 'core', 'member' ) ),
|
||||
'source_rows' => $count,
|
||||
'per_cycle' => 200,
|
||||
'dependencies' => array( 'convertMembers' ),
|
||||
@@ -221,7 +253,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
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;
|
||||
|
||||
@@ -240,7 +272,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
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 ) );
|
||||
}
|
||||
|
||||
return parent::countRows( $table, $where, $recache );
|
||||
@@ -298,7 +330,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$setting = $this->db->select( 'varname, value', 'setting', array( "varname=?", $theirs ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -307,12 +339,12 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$title = $this->db->select( 'text', 'phrase', array( "varname=?", "setting_{$setting['varname']}_title" ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$title = $setting['varname'];
|
||||
}
|
||||
|
||||
$settings[$setting['varname']] = array( 'title' => $title, 'value' => $setting['value'], 'our_key' => $ours, 'our_title' => \IPS\Member::loggedIn()->language()->addToStack( $ours ) );
|
||||
$settings[$setting['varname']] = array( 'title' => $title, 'value' => $setting['value'], 'our_key' => $ours, 'our_title' => Member::loggedIn()->language()->addToStack( $ours ) );
|
||||
}
|
||||
|
||||
return $settings;
|
||||
@@ -364,8 +396,8 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_vb_smilie_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_hint' => Member::loggedIn()->language()->addToStack('convert_vb_smilie_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
),
|
||||
'keep_existing_emoticons' => array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Checkbox',
|
||||
@@ -381,8 +413,8 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$return['convertProfileFieldGroups'] = array();
|
||||
|
||||
$options = array();
|
||||
$options['none'] = \IPS\Member::loggedIn()->language()->addToStack( 'none' );
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_pfields_groups' ), 'IPS\core\ProfileFields\Group' ) AS $group )
|
||||
$options['none'] = Member::loggedIn()->language()->addToStack( 'none' );
|
||||
foreach( new ActiveRecordIterator( Db::i()->select( '*', 'core_pfields_groups' ), 'IPS\core\ProfileFields\Group' ) AS $group )
|
||||
{
|
||||
$options[$group->_id] = $group->_title;
|
||||
}
|
||||
@@ -393,14 +425,14 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["map_pfgroup_{$id}"] = $this->db->select( 'text', 'phrase', array( "varname=?", "category{$id}_title" ) )->first();
|
||||
Member::loggedIn()->language()->words["map_pfgroup_{$id}"] = $this->db->select( 'text', 'phrase', array( "varname=?", "category{$id}_title" ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["map_pfgroup_{$id}"] = "vBulletin Profile Group {$id}";
|
||||
Member::loggedIn()->language()->words["map_pfgroup_{$id}"] = "vBulletin Profile Group {$id}";
|
||||
}
|
||||
|
||||
\IPS\Member::loggedIn()->language()->words["map_pfgroup_{$id}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_pfgroup_desc' );
|
||||
Member::loggedIn()->language()->words["map_pfgroup_{$id}_desc"] = Member::loggedIn()->language()->addToStack( 'map_pfgroup_desc' );
|
||||
|
||||
$return['convertProfileFieldGroups']["map_pfgroup_{$group['profilefieldcategoryid']}"] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Select',
|
||||
@@ -416,8 +448,8 @@ class _Vbulletin 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;
|
||||
}
|
||||
@@ -426,13 +458,13 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['profilefieldid']}"] = $this->db->select( 'text', 'phrase', array( "varname=?", "field{$field['profilefieldid']}_title" ) )->first();
|
||||
Member::loggedIn()->language()->words["map_pfield_{$field['profilefieldid']}"] = $this->db->select( 'text', 'phrase', array( "varname=?", "field{$field['profilefieldid']}_title" ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['profilefieldid']}"] = "vBulletin Profile Field {$field['profilefieldid']}";
|
||||
Member::loggedIn()->language()->words["map_pfield_{$field['profilefieldid']}"] = "vBulletin Profile Field {$field['profilefieldid']}";
|
||||
}
|
||||
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['profilefieldid']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_pfield_desc' );
|
||||
Member::loggedIn()->language()->words["map_pfield_{$field['profilefieldid']}_desc"] = Member::loggedIn()->language()->addToStack( 'map_pfield_desc' );
|
||||
|
||||
$return['convertProfileFields']["map_pfield_{$field['profilefieldid']}"] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Select',
|
||||
@@ -449,15 +481,15 @@ class _Vbulletin 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( '*', 'usergroup' ) AS $group )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["map_group_{$group['usergroupid']}"] = $group['title'];
|
||||
\IPS\Member::loggedIn()->language()->words["map_group_{$group['usergroupid']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_group_desc' );
|
||||
Member::loggedIn()->language()->words["map_group_{$group['usergroupid']}"] = $group['title'];
|
||||
Member::loggedIn()->language()->words["map_group_{$group['usergroupid']}_desc"] = Member::loggedIn()->language()->addToStack( 'map_group_desc' );
|
||||
|
||||
$return['convertGroups']["map_group_{$group['usergroupid']}"] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Select',
|
||||
@@ -477,7 +509,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => 'avatars',
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array( 'options' => array( 'avatars' => \IPS\Member::loggedIn()->language()->addToStack( 'avatars' ), 'profile_photos' => \IPS\Member::loggedIn()->language()->addToStack( 'profile_photos' ) ) ),
|
||||
'field_extra' => array( 'options' => array( 'avatars' => Member::loggedIn()->language()->addToStack( 'avatars' ), 'profile_photos' => Member::loggedIn()->language()->addToStack( 'profile_photos' ) ) ),
|
||||
'field_hint' => NULL,
|
||||
);
|
||||
|
||||
@@ -488,13 +520,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 ( $value != 'database' AND !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_validation' => function( $value ) { if ( $value != 'database' AND !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
|
||||
/* Find out where the avatar gallery photos live */
|
||||
@@ -503,23 +535,23 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'field_default' => NULL,
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(),
|
||||
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_vb_avatar_gallery_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_hint' => Member::loggedIn()->language()->addToStack('convert_vb_avatar_gallery_path'),
|
||||
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
|
||||
/* And decide what to do about these... */
|
||||
foreach( array( 'homepage', 'icq', 'aim', 'yahoo', 'msn', 'skype', 'user_title' ) AS $field )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words["field_{$field}"] = \IPS\Member::loggedIn()->language()->addToStack( 'pseudo_field', FALSE, array( 'sprintf' => ucwords( $field ) ) );
|
||||
\IPS\Member::loggedIn()->language()->words["field_{$field}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'pseudo_field_desc' );
|
||||
Member::loggedIn()->language()->words["field_{$field}"] = Member::loggedIn()->language()->addToStack( 'pseudo_field', FALSE, array( 'sprintf' => ucwords( $field ) ) );
|
||||
Member::loggedIn()->language()->words["field_{$field}_desc"] = Member::loggedIn()->language()->addToStack( 'pseudo_field_desc' );
|
||||
$return['convertMembers']["field_{$field}"] = array(
|
||||
'field_class' => 'IPS\\Helpers\\Form\\Radio',
|
||||
'field_default' => 'no_convert',
|
||||
'field_required' => TRUE,
|
||||
'field_extra' => array(
|
||||
'options' => array(
|
||||
'no_convert' => \IPS\Member::loggedIn()->language()->addToStack( 'no_convert' ),
|
||||
'create_field' => \IPS\Member::loggedIn()->language()->addToStack( 'create_field' ),
|
||||
'no_convert' => Member::loggedIn()->language()->addToStack( 'no_convert' ),
|
||||
'create_field' => Member::loggedIn()->language()->addToStack( 'create_field' ),
|
||||
),
|
||||
'userSuppliedInput' => 'create_field'
|
||||
),
|
||||
@@ -529,7 +561,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
break;
|
||||
|
||||
case 'convertClubs':
|
||||
\IPS\Member::loggedIn()->language()->words['club_photo_location'] = \IPS\Member::loggedIn()->language()->addToStack( 'photo_location' );
|
||||
Member::loggedIn()->language()->words['club_photo_location'] = Member::loggedIn()->language()->addToStack( 'photo_location' );
|
||||
|
||||
$return['convertClubs'] = array();
|
||||
$return['convertClubs']['club_photo_location'] = array(
|
||||
@@ -538,13 +570,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 ( $value != 'database' AND !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
|
||||
'field_validation' => function( $value ) { if ( $value != 'database' AND !@is_dir( $value ) ) { throw new DomainException( 'path_invalid' ); } },
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -560,46 +592,45 @@ class _Vbulletin 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();
|
||||
|
||||
/* Content Rebuilds */
|
||||
\IPS\Task::queue( 'convert', 'RebuildContent', array( 'app' => $this->app->app_id, 'link' => 'core_member_status_updates', 'class' => 'IPS\core\Statuses\Status' ), 2, array( 'app', 'link', 'class' ) );
|
||||
Store::i()->clearAll();
|
||||
Cache::i()->clearAll();
|
||||
|
||||
/* Non-Content Rebuilds */
|
||||
\IPS\Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_announcements', 'extension' => 'core_Announcement' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
Task::queue( 'convert', 'RebuildProfilePhotos', array( 'app' => $this->app->app_id ), 5, array( 'app' ) );
|
||||
Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_announcements', 'extension' => 'core_Announcement' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_message_posts', 'extension' => 'core_Messaging' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 2, array( 'app', 'link', 'extension' ) );
|
||||
|
||||
/* Content Counts */
|
||||
\IPS\Task::queue( 'core', 'RecountMemberContent', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
|
||||
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\core\Messenger\Message' ), 3, array( 'class' ) );
|
||||
Task::queue( 'core', 'RecountMemberContent', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
|
||||
Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\core\Messenger\Message' ), 3, array( 'class' ) );
|
||||
|
||||
/* 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' ) );
|
||||
|
||||
/* 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' ) );
|
||||
|
||||
/* Attachments */
|
||||
\IPS\Task::queue( 'core', 'RebuildAttachmentThumbnails', array( 'app' => $this->app->app_id ), 1, array( 'app' ) );
|
||||
Task::queue( 'core', 'RebuildAttachmentThumbnails', array( 'app' => $this->app->app_id ), 1, array( 'app' ) );
|
||||
|
||||
return array( "f_search_index_rebuild", "f_clear_caches", "f_rebuild_pms", "f_signatures_rebuild", "f_announce_rebuild" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
if( \preg_match( "#\[sigpic]#i", $post ) )
|
||||
if( preg_match( "#\[sigpic]#i", $post ) )
|
||||
{
|
||||
$post = preg_replace( "#\[sigpic\](.+?)\[\/sigpic\]#i", "", $post );
|
||||
}
|
||||
@@ -607,7 +638,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$post = str_replace( ">", ">", $post );
|
||||
$post = str_replace( "'", "'", $post );
|
||||
|
||||
if( \preg_match( "#\[quote=#i", $post ) )
|
||||
if( preg_match( "#\[quote=#i", $post ) )
|
||||
{
|
||||
$post = preg_replace( "#\[quote=([^\];]+?)\]#i", "[quote name='$1']", $post );
|
||||
$post = preg_replace( "#\[quote=([^\];]+?);\d+\]#i", "[quote name='$1']", $post );
|
||||
@@ -615,21 +646,21 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/* Remove video tags and allow our parser to handle the embeds it supports */
|
||||
if( \preg_match( "#\[video=#i", $post ) )
|
||||
if( preg_match( "#\[video=#i", $post ) )
|
||||
{
|
||||
$post = preg_replace( "#\[video=[a-z_]+;[a-z0-9_-]+\](.*?)\[\/video\]#i", '$1', $post );
|
||||
}
|
||||
|
||||
/* This is not a core feature in vBulletin, but is a popular addon and the code was supplied below.
|
||||
Addon URL: https://www.dragonbyte-tech.com/store/product/20-advanced-user-tagging/ */
|
||||
if( \preg_match( "#\[mention=#i", $post ) )
|
||||
if( preg_match( "#\[mention=#i", $post ) )
|
||||
{
|
||||
preg_match_all( '#\[MENTION=(\d+)\](.+?)\[\/MENTION\]#i', $post, $matches );
|
||||
|
||||
if ( \count( $matches ) )
|
||||
if ( count( $matches ) )
|
||||
{
|
||||
/* Make sure we actually have mention data */
|
||||
if ( isset( $matches[1] ) AND \count( $matches[1] ) )
|
||||
if ( isset( $matches[1] ) AND count( $matches[1] ) )
|
||||
{
|
||||
$mentions = array();
|
||||
foreach ( $matches[1] AS $k => $v )
|
||||
@@ -640,7 +671,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
|
||||
$maps = iterator_to_array( \IPS\Db::i()->select( 'name, member_id', 'core_members', array( \IPS\Db::i()->in( 'name', array_keys( $mentions ) ) ) )->setKeyField( 'name' )->setValueField( 'member_id' ) );
|
||||
$maps = iterator_to_array( Db::i()->select( 'name, member_id', 'core_members', array( Db::i()->in( 'name', array_keys( $mentions ) ) ) )->setKeyField( 'name' )->setValueField( 'member_id' ) );
|
||||
|
||||
foreach ( $mentions AS $memberName => $memberId )
|
||||
{
|
||||
@@ -686,7 +717,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$imageCategory = $this->db->select( '*', 'imagecategory', array( "imagecategoryid=?", $emoticon['imagecategoryid'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$imageCategory = array(
|
||||
'title' => "Converted",
|
||||
@@ -707,7 +738,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
/* Remote */
|
||||
try
|
||||
{
|
||||
$filedata = (string) \IPS\Http\Url::external( $emoticon['smiliepath'] )->request()->get();
|
||||
$filedata = (string) Url::external( $emoticon['smiliepath'] )->request()->get();
|
||||
}
|
||||
catch( \Exception $e ) {}
|
||||
}
|
||||
@@ -739,7 +770,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$name = $this->db->select( 'text', 'phrase', array( "varname=?", "category{$group['profilefieldcategoryid']}_title" ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$name = "vBulletin Profile Group {$group['profilefieldcategoryid']}";
|
||||
}
|
||||
@@ -773,7 +804,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$name = $this->db->select( 'text', 'phrase', array( "varname=?", "field{$field['profilefieldid']}_title" ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$name = "vBulletin Profile Field {$field['profilefieldid']}";
|
||||
}
|
||||
@@ -782,16 +813,16 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$desc = $this->db->select( 'text', 'phrase', array( "varname=?", "field{$field['profilefieldid']}_desc" ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$desc = "";
|
||||
}
|
||||
|
||||
$merge = ( $this->app->_session['more_info']['convertProfileFields']["map_pfield_{$field['profilefieldid']}"] != 'none' ) ? $this->app->_session['more_info']['convertProfileFields']["map_pfield_{$field['profilefieldid']}"] : NULL;
|
||||
|
||||
if ( \in_array( mb_strtolower( $field['type'] ), array( 'select', 'radio', 'checkbox', 'select_multiple' ) ) )
|
||||
if ( in_array( mb_strtolower( $field['type'] ), array( 'select', 'radio', 'checkbox', 'select_multiple' ) ) )
|
||||
{
|
||||
$options = @\unserialize( $field['data'] );
|
||||
$options = @unserialize( $field['data'] );
|
||||
if ( $options )
|
||||
{
|
||||
$content = json_encode( $options );
|
||||
@@ -800,10 +831,10 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
/* We can try to restore the serialized value */
|
||||
$data = preg_replace_callback( '/s:(\d+):"(.*?)";/i', function( $match ) {
|
||||
return ( $match[1] == \strlen( $match[2] ) ) ? $match[0] : 's:' . \strlen( $match[2] ) . ':"' . $match[2] . '";';
|
||||
return ( $match[1] == strlen( $match[2] ) ) ? $match[0] : 's:' . strlen( $match[2] ) . ':"' . $match[2] . '";';
|
||||
}, $field['data'] );
|
||||
|
||||
if( $options = @\unserialize( $data ) )
|
||||
if( $options = @unserialize( $data ) )
|
||||
{
|
||||
$content = json_encode( $options );
|
||||
}
|
||||
@@ -833,7 +864,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'pf_desc' => $desc,
|
||||
'pf_type' => $type,
|
||||
'pf_content' => $content,
|
||||
'pf_not_null' => ( \in_array( $field['required'], array( 1, 3 ) ) ) ? 1 : 0,
|
||||
'pf_not_null' => ( in_array( $field['required'], array( 1, 3 ) ) ) ? 1 : 0,
|
||||
'pf_member_hide' => $field['hidden'] ? 'hide' : 'all',
|
||||
'pf_max_input' => $field['maxlength'],
|
||||
'pf_member_edit' => ( $field['editable'] >= 1 ) ? 1 : 0,
|
||||
@@ -916,7 +947,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$promotion = $this->db->select( '*', 'userpromotion', array( "usergroupid=?", $group['usergroupid'] ) )->first();
|
||||
|
||||
/* We only support Posts or Join Date */
|
||||
if ( \in_array( $promotion['strategy'], array( 17, 18 ) ) )
|
||||
if ( in_array( $promotion['strategy'], array( 17, 18 ) ) )
|
||||
{
|
||||
switch( $promotion['strategy'] )
|
||||
{
|
||||
@@ -931,7 +962,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
|
||||
/* Work out photo vars - vBulletin has a concept of avatars and profile photos, so we are just going to use the larger of the two */
|
||||
$g_max_photo_vars = array();
|
||||
@@ -990,10 +1021,8 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'g_signature_limits' => $g_signature_limits,
|
||||
'g_bitoptions' => array(
|
||||
'gbw_promote_unit_type' => $gbw_promote_unit, // Type of group promotion to use. 1 is days since joining, 0 is content count. Corresponds to g_promotion
|
||||
'gbw_no_status_update' => !$checkpermission( 'visitormessagepermissions', 'canmessageownprofile' ), // Can NOT post status updates
|
||||
'gbw_allow_upload_bgimage' => 1, // Can upload a cover photo?
|
||||
'gbw_view_reps' => $checkpermission( 'genericpermissions2', 'canprofilerep' ), // Can view who gave reputation?
|
||||
'gbw_no_status_import' => !$checkpermission( 'visitormessagepermissions', 'canmessageownprofile' ), // Can NOT import status updates from Facebook/Twitter
|
||||
'gbw_disable_tagging' => !$checkpermission( 'genericpermissions', 'cancreatetag' ), // Can NOT use tags
|
||||
'gbw_disable_prefixes' => !$checkpermission( 'genericpermissions', 'cancreatetag' ), // Can NOT use prefixes
|
||||
'gbw_pm_override_inbox_full'=> $checkpermission( 'pmpermissions', 'canignorequota' ), // 1 means this group can send other members PMs even when that member's inbox is full
|
||||
@@ -1002,8 +1031,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'g_hide_own_posts' => $checkpermission( 'forumpermissions', 'candeletepost' ),
|
||||
'g_pm_flood_mins' => $this->_setting( 'pmfloodtime' ) / 60,
|
||||
'g_post_polls' => $checkpermission( 'forumpermissions', 'canpostpoll' ) ? 1 : 0,
|
||||
'g_vote_polls' => $checkpermission( 'forumpermissions', 'canvote' ) ? 1 : 0,
|
||||
'g_topic_rate_setting' => $checkpermission( 'forumpermissions', 'canthreadrate' ) ? 1 : 0
|
||||
'g_vote_polls' => $checkpermission( 'forumpermissions', 'canvote' ) ? 1 : 0
|
||||
);
|
||||
|
||||
$merge = ( $this->app->_session['more_info']['convertGroups']["map_group_{$group['usergroupid']}"] != 'none' ) ? $this->app->_session['more_info']['convertGroups']["map_group_{$group['usergroupid']}"] : NULL;
|
||||
@@ -1014,7 +1042,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/* Now check for group promotions */
|
||||
if( \count( $libraryClass->groupPromotions ) )
|
||||
if( count( $libraryClass->groupPromotions ) )
|
||||
{
|
||||
foreach( $libraryClass->groupPromotions as $groupPromotion )
|
||||
{
|
||||
@@ -1118,7 +1146,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$lastWarning = 0;
|
||||
|
||||
/* If there are warnings, get the last warning */
|
||||
if( \count( $warnings ) )
|
||||
if( count( $warnings ) )
|
||||
{
|
||||
$lastWarning = end( $warnings );
|
||||
reset( $warnings );
|
||||
@@ -1162,7 +1190,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
if( !isset( $bans[ $user['userid'] ] ) )
|
||||
{
|
||||
throw new \UnderflowException();
|
||||
throw new UnderflowException();
|
||||
}
|
||||
$temp_ban = $bans[ $user['userid'] ];
|
||||
|
||||
@@ -1171,19 +1199,19 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$temp_ban = -1;
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
|
||||
/* Main Members Table */
|
||||
$info = array(
|
||||
'member_id' => $user['userid'],
|
||||
'member_group_id' => $user['usergroupid'],
|
||||
'mgroup_others' => $user['membergroupids'],
|
||||
'name' => html_entity_decode( $user['username'], \ENT_QUOTES | \ENT_HTML5, 'UTF-8' ),
|
||||
'name' => html_entity_decode( $user['username'], ENT_QUOTES | ENT_HTML5, 'UTF-8' ),
|
||||
'email' => $user['email'],
|
||||
'joined' => $user['joindate'],
|
||||
'ip_address' => $user['ipaddress'],
|
||||
'warn_level' => ( $user['ipoints'] > 2147483647 ) ? 2147483647 : $user['ipoints'],
|
||||
'warn_lastwarn' => ( \is_array( $lastWarning ) ) ? $lastWarning['dateline'] : $lastWarning,
|
||||
'warn_lastwarn' => ( is_array( $lastWarning ) ) ? $lastWarning['dateline'] : $lastWarning,
|
||||
'bday_day' => $bday_day,
|
||||
'bday_month' => $bday_month,
|
||||
'bday_year' => $bday_year,
|
||||
@@ -1215,13 +1243,13 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
if( !isset( $activation[ $user['userid'] ] ) )
|
||||
{
|
||||
throw new \UnderflowException();
|
||||
throw new UnderflowException();
|
||||
}
|
||||
$activation = $activation[ $user['userid'] ];
|
||||
|
||||
$info['members_bitoptions']['validating'] = TRUE;
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$activation = NULL;
|
||||
}
|
||||
@@ -1231,7 +1259,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
if( !isset( $fields[ $user['userid'] ] ) )
|
||||
{
|
||||
throw new \UnderflowException();
|
||||
throw new UnderflowException();
|
||||
}
|
||||
$profileFields = $fields[ $user['userid'] ];
|
||||
|
||||
@@ -1244,7 +1272,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$profileFields[ str_replace( 'field', '', $key ) ] = $value;
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$profileFields = array();
|
||||
}
|
||||
@@ -1264,7 +1292,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
/* We don't actually need this, but we need to make sure the field was created */
|
||||
$this->app->getLink( $pseudo, 'core_pfields_data' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$libraryClass->convertProfileField( array(
|
||||
'pf_id' => $pseudo,
|
||||
@@ -1281,7 +1309,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
|
||||
if( $pseudo == 'user_title' )
|
||||
{
|
||||
$profileFields[ $pseudo ] = \in_array( $user['usertitle'], $userTitles ) ? NULL : $user['usertitle'];
|
||||
$profileFields[ $pseudo ] = in_array( $user['usertitle'], $userTitles ) ? NULL : $user['usertitle'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1316,7 +1344,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
$filepath = NULL;
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1334,7 +1362,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
|
||||
$filepath = NULL;
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
list( $filedata, $filename, $filepath ) = array( NULL, NULL, NULL );
|
||||
}
|
||||
@@ -1379,11 +1407,11 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
else
|
||||
{
|
||||
/* Throw an exception so we can try the other */
|
||||
throw new \UnderflowException;
|
||||
throw new UnderflowException;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$ext = $this->db->select( 'filename', $secondTable, array( "userid=?", $user['userid'] ) )->first();
|
||||
$ext = explode( '.', $ext );
|
||||
@@ -1402,12 +1430,12 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \UnderflowException;
|
||||
throw new UnderflowException;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
list( $filedata, $filename, $filepath ) = array( NULL, NULL, NULL );
|
||||
}
|
||||
@@ -1418,7 +1446,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$avatar = $this->_getFromAvatarGallery( (int) $user['avatarid'] );
|
||||
|
||||
if( \is_array( $avatar ) )
|
||||
if( is_array( $avatar ) )
|
||||
{
|
||||
$filename = $avatar['name'];
|
||||
$filedata = $avatar['data'];
|
||||
@@ -1430,7 +1458,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
/* If we are validating, store our validation row entry */
|
||||
if( $activation !== NULL AND $memberId )
|
||||
{
|
||||
\IPS\Db::i()->replace( 'core_validating', array(
|
||||
Db::i()->replace( 'core_validating', array(
|
||||
'vid' => md5( $activation['activationid'] . $activation['useractivationid'] ),
|
||||
'member_id' => $memberId,
|
||||
'entry_date' => $activation['dateline'],
|
||||
@@ -1443,7 +1471,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/* Skip this if we know that the user doesn't have any warnings */
|
||||
if( \count( $warnings ) )
|
||||
if( count( $warnings ) )
|
||||
{
|
||||
/* And warn logs made on the profile - we'll do content specific later */
|
||||
foreach ( $warnings AS $warn )
|
||||
@@ -1502,52 +1530,6 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert status updates
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertStatuses()
|
||||
{
|
||||
$libraryClass = $this->getLibrary();
|
||||
|
||||
$libraryClass::setKey( 'vmid' );
|
||||
|
||||
foreach( $this->fetch( 'visitormessage', 'vmid' ) AS $status )
|
||||
{
|
||||
/* Work out approval status */
|
||||
switch( $status['state'] )
|
||||
{
|
||||
case 'moderation':
|
||||
$approved = 0;
|
||||
break;
|
||||
|
||||
case 'deleted':
|
||||
$approved = -1;
|
||||
break;
|
||||
|
||||
case 'visible':
|
||||
default:
|
||||
$approved = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'status_id' => $status['vmid'],
|
||||
'status_member_id' => $status['userid'],
|
||||
'status_date' => $status['dateline'],
|
||||
'status_content' => static::fixPostData( $status['pagetext'] ),
|
||||
'status_author_id' => $status['postuserid'],
|
||||
'status_author_ip' => $status['ipaddress'],
|
||||
'status_approved' => $approved
|
||||
);
|
||||
|
||||
$libraryClass->convertStatus( $info );
|
||||
|
||||
$libraryClass->setLastKeyValue( $status['vmid'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert one or more settings
|
||||
*
|
||||
@@ -1567,12 +1549,12 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$setting = $this->db->select( 'value', 'setting', array( "varname=?", $theirs ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => $setting ), array( "conf_key=?", $ours ) );
|
||||
Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => $setting ), array( "conf_key=?", $ours ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1593,7 +1575,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'ignore_ignore_id' => $ignore['relationid'],
|
||||
);
|
||||
|
||||
foreach( \IPS\core\Ignore::types() AS $type )
|
||||
foreach( Ignore::types() AS $type )
|
||||
{
|
||||
$info['ignore_' . $type] = 1;
|
||||
}
|
||||
@@ -1752,7 +1734,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$icon = $this->db->select( '*', 'socialgroupicon', array( "groupid=?", $group['groupid'] ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
|
||||
$info = array(
|
||||
'club_id' => $group['groupid'],
|
||||
@@ -1806,7 +1788,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$type = 'leader';
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
|
||||
if ( $type === NULL )
|
||||
{
|
||||
@@ -1827,7 +1809,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
* @brief Silly Bit Options for Groups. Typically we would leave out app specific options (such as Forums here) however we need them for some general permissions, like uploading.
|
||||
* @note This is public simply because I do not want to do this ever again if it ever changes.
|
||||
*/
|
||||
public static $bitOptions = array(
|
||||
public static array $bitOptions = array(
|
||||
'forumpermissions' => array(
|
||||
'canview' => 1,
|
||||
'canviewothers' => 2,
|
||||
@@ -2042,7 +2024,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$this->settingsCache[$key] = $setting['defaultvalue'];
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
/* If we failed to find it, we probably will fail again on later attempts */
|
||||
$this->settingsCache[$key] = NULL;
|
||||
@@ -2054,19 +2036,19 @@ 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();
|
||||
|
||||
/* Attachment URLs are the same across VB 3.8 and VB 4 */
|
||||
if( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'attachment.php' ) !== FALSE )
|
||||
if( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'attachment.php' ) !== FALSE )
|
||||
{
|
||||
$id = NULL;
|
||||
try
|
||||
{
|
||||
$id = (string) $this->app->getLink( \IPS\Request::i()->attachmentid, array( 'attachments', 'core_attachments' ) );
|
||||
$id = (string) $this->app->getLink( Request::i()->attachmentid, array( 'attachments', 'core_attachments' ) );
|
||||
}
|
||||
/* Try any child conversions */
|
||||
catch( \Exception $e )
|
||||
@@ -2075,7 +2057,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
try
|
||||
{
|
||||
$id = (string) $child->getLink( \IPS\Request::i()->attachmentid, array( 'attachments', 'core_attachments' ) );
|
||||
$id = (string) $child->getLink( Request::i()->attachmentid, array( 'attachments', 'core_attachments' ) );
|
||||
break;
|
||||
}
|
||||
catch( \Exception $e ) {}
|
||||
@@ -2087,19 +2069,19 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return \IPS\Http\Url::external( \IPS\Settings::i()->base_url . 'applications/core/interface/file/attachment.php' )->setQueryString( 'id', $id );
|
||||
return Url::external( Settings::i()->base_url . 'applications/core/interface/file/attachment.php' )->setQueryString( 'id', $id );
|
||||
}
|
||||
/* Tag URLs are straightforward */
|
||||
elseif( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'tags.php' ) !== FALSE AND isset( \IPS\Request::i()->tag ) )
|
||||
elseif( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'tags.php' ) !== FALSE AND isset( Request::i()->tag ) )
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=core&module=search&controller=search&tags=" . \IPS\Request::i()->tag, 'front', 'search' );
|
||||
return Url::internal( "app=core&module=search&controller=search&tags=" . Request::i()->tag, 'front', 'search' );
|
||||
}
|
||||
/* Club Index */
|
||||
elseif( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'group.php' ) !== FALSE AND isset( \IPS\Request::i()->groupid ) )
|
||||
elseif( mb_strpos( $url->data[ Url::COMPONENT_PATH ], 'group.php' ) !== FALSE AND isset( Request::i()->groupid ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\Member\Club::loadAndCheckPerms( (string) $this->app->getLink( \IPS\Request::i()->groupid, array( 'core_clubs' ) ) )->url();
|
||||
return Club::loadAndCheckPerms( (string) $this->app->getLink( Request::i()->groupid, array( 'core_clubs' ) ) )->url();
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
@@ -2109,7 +2091,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
else
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
@@ -2120,14 +2102,14 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
* /member.php?u=1
|
||||
* /member.php?1-name
|
||||
*/
|
||||
$path = $url->data[ \IPS\Http\Url::COMPONENT_PATH ];
|
||||
$path = $url->data[ Url::COMPONENT_PATH ];
|
||||
if( mb_strpos( $path, 'member.php' ) !== FALSE )
|
||||
{
|
||||
if( isset( \IPS\Request::i()->u ) )
|
||||
if( isset( Request::i()->u ) )
|
||||
{
|
||||
$oldId = \IPS\Request::i()->u;
|
||||
$oldId = Request::i()->u;
|
||||
}
|
||||
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];
|
||||
}
|
||||
@@ -2137,7 +2119,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
$oldId = $queryStringPieces[0];
|
||||
}
|
||||
}
|
||||
elseif( preg_match( '#/members/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
|
||||
elseif( preg_match( '#/members/([0-9]+)#i', $url->data[ Url::COMPONENT_PATH ], $matches ) )
|
||||
{
|
||||
$oldId = (int) $matches[1];
|
||||
}
|
||||
@@ -2147,7 +2129,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
try
|
||||
{
|
||||
$data = (string) $this->app->getLink( $oldId, array( 'members', 'core_members' ) );
|
||||
return \IPS\Member::load( $data )->url();
|
||||
return Member::load( $data )->url();
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
@@ -2162,13 +2144,13 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
/**
|
||||
* Process a login
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @param string $password Password from form
|
||||
* @return bool
|
||||
*/
|
||||
public static function login( $member, $password )
|
||||
{
|
||||
if ( \IPS\Login::compareHashes( $member->conv_password, md5( md5( str_replace( ''', "'", html_entity_decode( $password ) ) ) . $member->conv_password_extra ) ) )
|
||||
if ( Login::compareHashes( $member->conv_password, md5( md5( str_replace( ''', "'", html_entity_decode( $password ) ) ) . $member->conv_password_extra ) ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2181,23 +2163,23 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
/**
|
||||
* Centralised PM conversation conversion
|
||||
*
|
||||
* @param $libraryClass \IPS\convert\Library
|
||||
* @param $libraryClass Library
|
||||
* @param $pm array
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _convertPm( \IPS\convert\Library $libraryClass, array $pm )
|
||||
protected function _convertPm( Library $libraryClass, array $pm )
|
||||
{
|
||||
try
|
||||
{
|
||||
$replies = $this->db->select( 'COUNT(*)', 'pm', array( "parentpmid=? AND folderid!=?", $pm['pmid'], -1 ) )->first();
|
||||
$replies += 1;
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
$replies = 1;
|
||||
}
|
||||
|
||||
$toUserArray = @\unserialize( $pm['touserarray'] );
|
||||
$toUserArray = @unserialize( $pm['touserarray'] );
|
||||
|
||||
$topic = array(
|
||||
'mt_id' => $pm['pmid'],
|
||||
@@ -2206,7 +2188,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
'mt_starter_id' => $pm['fromuserid'],
|
||||
'mt_start_time' => $pm['dateline'],
|
||||
'mt_last_post_time' => $pm['dateline'],
|
||||
'mt_to_count' => ( $toUserArray AND \is_array( $toUserArray ) ) ? \count( $toUserArray ) : 1,
|
||||
'mt_to_count' => ( $toUserArray AND is_array( $toUserArray ) ) ? count( $toUserArray ) : 1,
|
||||
'mt_to_member_id' => $pm['userid'],
|
||||
'mt_replies' => $replies,
|
||||
'mt_first_msg_id' => $pm['pmid'],
|
||||
@@ -2225,17 +2207,17 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
catch( UnderflowException $e ) {}
|
||||
|
||||
/* Use stored author ids */
|
||||
if( isset( $toUserArray['cc'] ) AND \is_array( $toUserArray['cc'] ) )
|
||||
if( isset( $toUserArray['cc'] ) AND is_array( $toUserArray['cc'] ) )
|
||||
{
|
||||
foreach( array_keys( $toUserArray['cc'] ) as $id )
|
||||
{
|
||||
$authors[ $id ] = $id;
|
||||
}
|
||||
}
|
||||
elseif( $toUserArray AND \is_array( $toUserArray ) AND \count( $toUserArray ) )
|
||||
elseif( $toUserArray AND is_array( $toUserArray ) AND count( $toUserArray ) )
|
||||
{
|
||||
foreach( array_keys( $toUserArray ) as $id )
|
||||
{
|
||||
@@ -2279,32 +2261,32 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
{
|
||||
$avatar = $this->db->select( 'avatarpath', 'avatar', array( 'avatarid=?', $id ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
return $this->_avatars[ $id ] = FALSE;
|
||||
}
|
||||
|
||||
/* It might be a remote image */
|
||||
if( \substr( $avatar, 0, 8 ) === 'https://' OR \substr( $avatar, 0, 7 ) === 'http://' )
|
||||
if( substr( $avatar, 0, 8 ) === 'https://' OR substr( $avatar, 0, 7 ) === 'http://' )
|
||||
{
|
||||
try
|
||||
{
|
||||
$profilePhotoName = pathinfo( parse_url( $avatar, PHP_URL_PATH ), PATHINFO_BASENAME );
|
||||
$profilePhotoData = \IPS\Http\Url::external( $avatar )->request()->get();
|
||||
$profilePhotoData = Url::external( $avatar )->request()->get();
|
||||
|
||||
/* Check it's really an image */
|
||||
try
|
||||
{
|
||||
\IPS\Image::create( $profilePhotoData );
|
||||
Image::create( $profilePhotoData );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( InvalidArgumentException $e )
|
||||
{
|
||||
return $this->_avatars[ $id ] = FALSE;
|
||||
}
|
||||
|
||||
return $this->_avatars[ $id ] = array( 'data' => $profilePhotoData, 'name' => $profilePhotoName );
|
||||
}
|
||||
catch ( \IPS\Http\Request\Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
return $this->_avatars[ $id ] = FALSE;
|
||||
}
|
||||
@@ -2312,7 +2294,7 @@ class _Vbulletin extends \IPS\convert\Software
|
||||
|
||||
/* nope, it's a file */
|
||||
$dirName = pathinfo( $avatar, PATHINFO_DIRNAME );
|
||||
if( \substr( $this->app->_session['more_info']['convertMembers']['avatar_gallery_location'], -\strlen( $dirName ) ) == $dirName )
|
||||
if( substr( $this->app->_session['more_info']['convertMembers']['avatar_gallery_location'], -strlen( $dirName ) ) == $dirName )
|
||||
{
|
||||
$profilePhotoName = pathinfo( $avatar, PATHINFO_BASENAME );
|
||||
$profilePhotoData = file_get_contents( rtrim( $this->app->_session['more_info']['convertMembers']['avatar_gallery_location'], '/' ) . '/' . $profilePhotoName );
|
||||
|
||||
Reference in new issue
Block a user