Version 4.1.19.4

This commit is contained in:
Neo committed 2025-12-19 05:42:01 -08:00
1 parent 2bd5025018
commit 0dc2aee5ed
312 files changed
+53730 -32118

No files matched your search

@@ -0,0 +1,722 @@
<?php
/**
* @brief Converter ExpressionEngine Master Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @package IPS Community Suite
* @subpackage Converter
* @since 14 June 2016
*/
namespace IPS\convert\Software\Core;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
class _Expressionengine extends \IPS\convert\Software
{
/**
* Software Name
*
* @return string
*/
public static function softwareName()
{
return "Expression Engine";
}
/**
* Software Key
*
* @return string
*/
public static function softwareKey()
{
return 'expressionengine';
}
/**
* Content we can convert from this software.
*
* @return array
*/
public static function canConvert()
{
return array(
'convertProfileFields' => array(
'table' => 'exp_member_fields',
'where' => NULL
),
'convertGroups' => array(
'table' => 'exp_member_groups',
'where' => NULL
),
'convertMembers' => array(
'table' => 'exp_members',
'where' => NULL
),
'convertAttachments' => array(
'table' => 'exp_members',
'where' => array( "sig_img_filename<>''" )
),
'convertPrivateMessages' => array(
'table' => 'exp_message_data',
'where' => NULL
),
'convertPrivateMessageReplies' => array(
'table' => 'exp_message_data',
'where' => NULL,
'extra_steps' => array( 'convertPmAttachments' )
),
'convertPmAttachments' => array(
'table' => 'exp_message_attachments',
'where' => NULL,
),
'convertRanks' => array(
'table' => 'exp_forum_ranks',
'where' => NULL
)
);
}
/**
* Can we convert passwords from this software.
*
* @return boolean
*/
public static function loginEnabled()
{
return TRUE;
}
/**
* Can we convert settings?
*
* @return boolean
*/
public static function canConvertSettings()
{
return FALSE;
}
/**
* List of Conversion Methods that require more information
*
* @return array
*/
public static function checkConf()
{
return array(
'convertAttachments',
'convertProfileFields',
'convertGroups',
'convertMembers',
'convertPrivateMessages'
);
}
/**
* Fix post data
*
* @param string raw post data
* @return string parsed post data
*/
public static function fixPostData( $post )
{
return nl2br( $post );
}
/**
* Get More Information
*
* @param string $method Conversion method
* @return array
*/
public function getMoreInfo( $method )
{
$return = array();
switch ( $method )
{
case 'convertAttachments':
$return['convertAttachments'] = array(
'signature_attach_location' => array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_ee_sig_attach_path'),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
)
);
break;
case 'convertProfileFields':
$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[$field->_id] = $field->_title;
}
foreach( $this->db->select( '*', 'exp_member_fields' ) AS $field )
{
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['m_field_id']}"] = $field['m_field_label'];
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['m_field_id']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_pfield_desc' );
$return['convertProfileFields']["map_pfield_{$field['m_field_id']}"] = array(
'field_class' => 'IPS\\Helpers\\Form\\Select',
'field_default' => NULL,
'field_required' => FALSE,
'field_extra' => array( 'options' => $options ),
'field_hint' => NULL,
);
}
break;
case 'convertGroups':
$return['convertGroups'] = array();
$options = array();
$options['none'] = 'None';
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
{
$options[$group->g_id] = $group->name;
}
foreach( $this->db->select( '*', 'exp_member_groups' ) AS $group )
{
\IPS\Member::loggedIn()->language()->words["map_group_{$group['group_id']}"] = $group['group_title'];
\IPS\Member::loggedIn()->language()->words["map_group_{$group['group_id']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_group_desc' );
$return['convertGroups']["map_group_{$group['group_id']}"] = array(
'field_class' => 'IPS\\Helpers\\Form\\Select',
'field_default' => NULL,
'field_required' => FALSE,
'field_extra' => array( 'options' => $options ),
'field_hint' => NULL,
);
}
break;
case 'convertMembers':
$return['convertMembers'] = array();
/* We can only retain one type of photo */
$return['convertMembers']['photo_type'] = array(
'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_hint' => NULL,
);
/* Find out where the photos live */
\IPS\Member::loggedIn()->language()->words['photo_location_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'photo_location_nodb_desc' );
$return['convertMembers']['photo_location'] = array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_ee_avatar_path'),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
);
foreach( array( 'url', 'location', 'occupation', 'bio' ) AS $field )
{
\IPS\Member::loggedIn()->language()->words["field_{$field}"] = \IPS\Member::loggedIn()->language()->addToStack( 'pseudo_field', FALSE, array( 'sprintf' => $field ) );
\IPS\Member::loggedIn()->language()->words["field_{$field}_desc"] = \IPS\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' ),
),
'userSuppliedInput' => 'create_field'
),
'field_hint' => NULL
);
}
break;
case 'convertPrivateMessages':
$return['convertPrivateMessages'] = array(
'pm_attach_location' => array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_ee_pm_attach_path'),
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
)
);
break;
}
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
}
/**
* Finish
*
* @return array
*/
public function finish()
{
/* Search Index Rebuild */
\IPS\Content\Search\Index::i()->rebuild();
/* Clear Cache and Store */
\IPS\Data\Store::i()->clearAll();
\IPS\Data\Cache::i()->clearAll();
/* Non-Content Rebuilds */
\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' ) );
/* Content Counts */
\IPS\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' ) );
/* Attachments */
\IPS\Task::queue( 'core', 'RebuildAttachmentThumbnails', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
return array( "f_search_index_rebuild", "f_clear_caches", "f_rebuild_pms", "f_signatures_rebuild", "f_rebuild_attachments" );
}
/**
* Convert attachments
*
* @return void
*/
public function convertAttachments()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'member_id' );
$it = $this->fetch( 'exp_members', 'member_id', array( "sig_img_filename<>''" ) );
foreach( $it AS $row )
{
$map = array(
'id1' => $row['member_id'],
'id1_type' => 'core_members',
'id1_from_parent' => FALSE,
'location_key' => 'core_Signatures'
);
$ext = explode( '.', $row['sig_img_filename'] );
$ext = array_pop( $ext );
$info = array(
'attach_id' => $row['member_id'],
'attach_file' => $row['sig_img_filename'],
'attach_member_id' => $row['member_id'],
'attach_ext' => $ext
);
$path = rtrim( $this->app->_session['more_info']['convertAttachments']['signature_attach_location'], '/' ) . '/' . $row['sig_img_filename'];
$attachId = $libraryClass->convertAttachment( $info, $map, $path );
/* Update Post if we can */
try
{
if ( $attachId !== FALSE )
{
$ourAttachment = \IPS\File::get( 'core_Signature', \IPS\Db::i()->select( 'attach_location', 'core_attachments', array( 'attach_id=?', $attachId ) )->first() );
$memberId = $this->app->getLink( $row['member_id'], 'core_members' );
$signature = \IPS\Db::i()->select( 'signature', 'core_members', array( "member_id=?", $memberId ) )->first();
$signature .= '<p><a href="<fileStore.core_Signature>/' . (string) $ourAttachment . '" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="' . $attachId . '" src="<fileStore.core_Signature>/' . (string) $ourAttachment . '" class="ipsImage ipsImage_thumbnailed" alt=""></a></p>';
\IPS\Db::i()->update( 'core_members', array( 'signature' => $signature ), array( "member_id=?", $memberId ) );
}
}
catch( \UnderflowException $e ) {}
catch( \OutOfRangeException $e ) {}
$libraryClass->setLastKeyValue( $row['member_id'] );
}
}
/**
* Convert profile fields
*
* @return void
*/
public function convertProfileFields()
{
$libraryClass = $this->getLibrary();
foreach( $this->fetch( 'exp_member_fields', 'm_field_id' ) AS $row )
{
$info = array();
$info['pf_id'] = $row['m_field_id'];
$merge = $this->app->_session['more_info']['convertProfileFields']["map_pfield_{$row['m_field_id']}"] != 'none' ? $this->app->_session['more_info']['convertProfileFields']["map_pfield_{$row['m_field_id']}"] : NULL;
$info['pf_type'] = ucwords( $row['m_field_type'] );
$info['pf_name'] = $row['m_field_label'];
$info['pf_desc'] = $row['m_field_description'];
$info['pf_content'] = ( !in_array( $row['m_field_type'], array( 'textbox', 'textarea' ) ) ) ? explode( "\r", $row['field_choices'] ) : NULL;
$info['pf_not_null'] = $row['m_field_required'] == 'y' ? 1 : 0;
$info['pf_member_hide'] = $row['m_field_public'] == 'n' ? 1 : 0;
$info['pf_max_input'] = $row['m_field_maxl'];
$info['pf_member_edit'] = ( in_array( $row['user_editable'], array( 'yes', 'once' ) ) ) ? 0 : 1;
$info['pf_position'] = $row['m_field_order'];
$info['pf_show_on_reg'] = $row['m_field_reg'] == 'y' ? 1 : 0;
$info['pf_input_format'] = NULL;
$info['pf_multiple'] = 0;
$libraryClass->convertProfileField( $info, $merge );
}
}
/**
* Convert groups
*
* @return void
*/
public function convertGroups()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'group_id' );
foreach( $this->fetch( 'exp_member_groups', 'group_id' ) AS $row )
{
/* Basic info */
$info = array(
'g_id' => $row['group_id'],
'g_name' => $row['group_title'],
'g_view_board' => ( $row['can_view_online_system'] == 'y' ) ? 1 : 0,
'g_use_pm' => ( $row['can_send_private_messages'] == 'y' ) ? 1 : 0,
'g_max_messages' => $row['prv_msg_storage_limit'],
'g_pm_perday' => $row['prv_msg_send_limit'],
'g_search_flood' => $row['search_flood_control']
);
$merge = ( $this->app->_session['more_info']['convertGroups']["map_group_{$row['group_id']}"] != 'none' ) ? $this->app->_session['more_info']['convertGroups']["map_group_{$row['group_id']}"] : NULL;
$libraryClass->convertGroup( $info, $merge );
$libraryClass->setLastKeyValue( $row['group_id'] );
}
}
/**
* Convert members
*
* @return void
*/
public function convertMembers()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'exp_members.member_id' );
$it = $this->fetch( 'exp_members', 'exp_members.member_id' );
foreach( $it AS $row )
{
/* Main Member Information */
$info = array(
'member_id' => $row['member_id'],
'name' => $row['screen_name'],
'email' => $row['email'],
'conv_password' => $row['password'],
'member_group_id' => $row['group_id'],
'joined' => $row['join_date'],
'ip_address' => $row['ip_address'],
'bday_day' => $row['bday_d'],
'bday_month' => $row['bday_m'],
'bday_year' => $row['bday_y'],
'msg_count_total' => $row['private_messages'],
'last_visit' => $row['last_visit'],
'last_activity' => $row['last_activity'],
'signature' => $row['signature'],
'members_bitoptions' => array(
'view_sigs' => ( $row['display_signatures'] == 'y' ) ? 1 : 0
),
'pp_setting_count_comments' => 1,
'allow_admin_mails' => ( $row['accept_admin_email'] == 'y' ) ? 1 : 0,
'member_posts' => $row['total_forum_posts'],
);
/* Profile Fields */
try
{
$profileFields = $this->db->select( '*', 'exp_member_data', array( "member_id=?", $row['member_id'] ) )->first();
unset( $profileFields['member_id'] );
/* Basic fields - we only need ID => Value, the library will handle the rest */
foreach( $profileFields AS $key => $value )
{
$profileFields[ str_replace( 'm_field_id_', '', $key ) ] = $value;
}
}
catch( \UnderflowException $e )
{
$profileFields = array();
}
/* Pseudo Fields */
foreach( array( 'url', 'location', 'occupation', 'bio' ) AS $pseudo )
{
/* Are we retaining? */
if ( $this->app->_session['more_info']['convertMembers']["field_{$pseudo}"] == 'no_convert' )
{
/* No, skip */
continue;
}
try
{
/* We don't actually need this, but we need to make sure the field was created */
$fieldId = $this->app->getLink( $pseudo, 'core_pfields_data' );
}
catch( \OutOfRangeException $e )
{
$libraryClass->convertProfileField( array(
'pf_id' => $pseudo,
'pf_name' => $this->app->_session['more_info']['convertMembers']["field_{$pseudo}"],
'pf_desc' => '',
'pf_type' => 'Text',
'pf_content' => '[]',
'pf_member_hide' => 0,
'pf_max_input' => 500,
'pf_member_edit' => 1,
'pf_show_on_reg' => 0,
'pf_admin_only' => 0,
) );
}
$profileFields[ $pseudo ] = $row[ $pseudo ];
}
/* Profile Photos */
if ( $this->app->_session['more_info']['convertMembers']['photo_type'] == 'profile_photos' )
{
$filename = $row['photo_filename'];
}
else
{
$filename = $row['avatar_filename'];
}
$libraryClass->convertMember( $info, $profileFields, $filename, rtrim( $this->app->_session['more_info']['convertMembers']['photo_location'], '/' ) );
$libraryClass->setLastKeyValue( $row['member_id'] );
}
}
/**
* Convert ranks
*
* @return void
*/
public function convertRanks()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'rank_id' );
foreach( $this->fetch( 'exp_forum_ranks', 'rank_id' ) AS $row )
{
$libraryClass->convertRank( array(
'id' => $row['rank_id'],
'title' => $row['rank_title'],
'posts' => $row['rank_min_posts'],
'pips' => $row['rank_stars']
) );
$libraryClass->setLastKeyValue( $row['rank_id'] );
}
}
/**
* Convert PMs
*
* @return void
*/
public function convertPrivateMessages()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'message_id' );
foreach( $this->fetch( 'exp_message_data', 'message_id' ) AS $row )
{
/* Reset map array */
$maps = array();
$topic = array(
'mt_id' => $row['message_id'],
'mt_date' => $row['message_date'],
'mt_title' => $row['message_subject'],
'mt_starter_id' => $row['sender_id'],
'mt_start_time' => $row['message_date'],
'mt_last_post_time' => $row['message_date'],
'mt_to_count' => $row['total_recipients'],
);
/* Author Map */
$maps[ $row['sender_id'] ] = array(
'map_user_id' => $row['sender_id'],
'map_read_time' => $row['message_date'],
'map_user_active' => 1,
'map_user_banned' => 0,
'map_has_unread' => 0,
'map_is_starter' => 1,
'map_last_topic_reply' => $row['message_date']
);
foreach( $this->db->select( '*', 'exp_message_copies', array( 'message_id=?', $row['message_id'] ) ) AS $map )
{
$maps[ $map['recipient_id'] ] = array(
'map_user_id' => $map['recipient_id'],
'map_read_time' => $map['message_time_read'],
'map_user_active' => 1,
'map_user_banned' => 0,
'map_has_unread' => ( $map['message_read'] == 'n' ) ? 1 : 0,
'map_is_starter' => ( $map['recipient_id'] == $row['sender_id'] ) ? 1 : 0,
'map_last_topic_reply' => $row['message_date']
);
}
$libraryClass->convertPrivateMessage( $topic, $maps );
$libraryClass->setLastKeyValue( $row['message_id'] );
}
}
/**
* Convert PM replies
*
* @return void
*/
public function convertPrivateMessageReplies()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'message_id' );
foreach( $this->fetch( 'exp_message_data', 'message_id' ) AS $row )
{
$libraryClass->convertPrivateMessageReply( array(
'msg_id' => $row['message_id'],
'msg_topic_id' => $row['message_id'],
'msg_date' => $row['message_date'],
'msg_post' => $row['message_body'],
'msg_author_id' => $row['sender_id'],
'msg_is_first_post' => 1,
'msg_ip_address' => '127.0.0.1',
) );
$libraryClass->setLastKeyValue( $row['message_id'] );
}
}
/**
* Convert PM attachments
*
* @return void
*/
public function convertPmAttachments()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'attachment_id' );
$it = $this->fetch( 'exp_message_attachments', 'attachment_id' );
foreach( $it AS $row )
{
$map = array(
'id1' => $row['message_id'],
'id1_type' => 'core_message_topics',
'id1_from_parent' => FALSE,
'id2' => $row['message_id'],
'id2_type' => 'core_message_posts',
'id2_from_parent' => FALSE
);
$info = array(
'attach_id' => $row['attachment_id'],
'attach_file' => $row['attachment_name'],
'attach_date' => $row['attachment_date'],
'attach_member_id' => $row['sender_id'],
'attach_ext' => \strtolower( trim( $row['attachment_extension'], '.' ) ),
'attach_filesize' => ( $row['attachment_size'] * 1000 ), //convert to kb
);
$path = rtrim( $this->app->_session['more_info']['convertAttachments']['pm_attach_location'], '/' ) . '/' . $row['attachment_hash'] . $row['attachment_extension'];
$attachId = $libraryClass->convertAttachment( $info, $map, $path );
/* Update Post if we can */
try
{
if ( $attachId !== FALSE )
{
$ourAttachment = \IPS\File::get( 'core_Attachment', \IPS\Db::i()->select( 'attach_location', 'core_attachments', array( 'attach_id=?', $attachId ) )->first() );
$pmId = $this->app->getLink( $row['message_id'], 'core_message_posts' );
$message = \IPS\Db::i()->select( 'msg_post', 'core_message_posts', array( "msg_id=?", $pmId ) )->first();
$message .= '<p><a href="<fileStore.core_Attachment>/' . (string) $ourAttachment . '" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="' . $attachId . '" src="<fileStore.core_Attachment>/' . (string) $ourAttachment . '" class="ipsImage ipsImage_thumbnailed" alt=""></a></p>';
\IPS\Db::i()->update( 'core_message_posts', array( 'msg_post' => $message ), array( "msg_id=?", $pmId ) );
}
}
catch( \UnderflowException $e ) {}
catch( \OutOfRangeException $e ) {}
$libraryClass->setLastKeyValue( $row['attachment_id'] );
}
}
/**
* Check if we can redirect the legacy URLs from this software to the new locations
*
* @return NULL|\IPS\Http\Url
*/
public function checkRedirects()
{
/* If we can't access profiles, don't bother trying to redirect */
if( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) )
{
return NULL;
}
$url = \IPS\Request::i()->url();
if( preg_match( '#/member/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
{
try
{
$data = (string) $this->app->getLink( (int) $matches[1], array( 'members', 'core_members' ) );
return \IPS\Member::load( $data )->url();
}
catch( \Exception $e )
{
return NULL;
}
}
return NULL;
}
}
@@ -0,0 +1,223 @@
<?php
/**
* @brief Converter Joomla Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @package IPS Community Suite
* @subpackage Converter
* @since 21 Jan 2015
*/
namespace IPS\convert\Software\Core;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
class _Joomla extends \IPS\convert\Software
{
/**
* Software Name
*
* @return string
*/
public static function softwareName()
{
/* Child classes must override this method */
return "Joomla";
}
/**
* Software Key
*
* @return string
*/
public static function softwareKey()
{
/* Child classes must override this method */
return "joomla";
}
/**
* Content we can convert from this software.
*
* @return array
*/
public static function canConvert()
{
return array(
'convertGroups' => array(
'table' => 'usergroups',
'where' => NULL
),
'convertMembers' => array(
'table' => 'users',
'where' => NULL
),
);
}
/**
* Can we convert passwords from this software.
*
* @return boolean
*/
public static function loginEnabled()
{
return TRUE;
}
/**
* List of conversion methods that require additional information
*
* @return array
*/
public static function checkConf()
{
return array(
'convertGroups'
);
}
/**
* Get More Information
*
* @param string $method Method name
* @return array
*/
public function getMoreInfo( $method )
{
$return = array();
switch( $method )
{
case 'convertGroups':
$return['convertGroups'] = array();
$options = array();
$options['none'] = 'None';
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
{
$options[$group->g_id] = $group->name;
}
foreach( $this->db->select( '*', 'usergroups' ) AS $group )
{
\IPS\Member::loggedIn()->language()->words["map_group_{$group['id']}"] = $group['title'];
\IPS\Member::loggedIn()->language()->words["map_group_{$group['id']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_group_desc' );
$return['convertGroups']["map_group_{$group['id']}"] = array(
'field_class' => 'IPS\\Helpers\\Form\\Select',
'field_default' => NULL,
'field_required' => FALSE,
'field_extra' => array( 'options' => $options ),
'field_hint' => NULL,
);
}
break;
}
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
}
/**
* Finish - Adds everything it needs to the queues and clears data store
*
* @return array Messages to display
*/
public function finish()
{
/* Search Index Rebuild */
\IPS\Content\Search\Index::i()->rebuild();
/* Clear Cache and Store */
\IPS\Data\Store::i()->clearAll();
\IPS\Data\Cache::i()->clearAll();
/* Content Counts */
\IPS\Task::queue( 'core', 'RecountMemberContent', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
return array( "f_search_index_rebuild", "f_clear_caches" );
}
/**
* Convert groups
*
* @return void
*/
public function convertGroups()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id' );
foreach( $this->fetch( 'usergroups', 'id' ) as $row )
{
/* Basic info */
$info = array(
'g_id' => $row['id'],
'g_name' => $row['title'],
);
$merge = ( $this->app->_session['more_info']['convertGroups']["map_group_{$row['id']}"] != 'none' ) ? $this->app->_session['more_info']['convertGroups']["map_group_{$row['id']}"] : NULL;
$libraryClass->convertGroup( $info, $merge );
$libraryClass->setLastKeyValue( $row['id'] );
}
}
/**
* Convert members
*
* @return void
*/
public function convertMembers()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id' );
foreach( $this->fetch( 'users', 'id' ) as $row )
{
/* Basic info */
$info = array(
'member_id' => $row['id'],
'name' => $row['username'],
'email' => $row['email'],
'joined' => strtotime( $row['registerDate'] ),
'mgroup_others' => array(),
'temp_ban' => $row['block'] ? -1 : 0
);
/* Figure out password */
$pass = explode ( ':', $row['password'] );
$info['conv_password'] = $pass[0];
$info['conv_password_extra'] = $pass[1];
/* Figure out groups */
$libraryClass::$usingKeys = FALSE;
foreach( $this->fetch( 'user_usergroup_map', 'group_id', array( 'user_id=?', $row['id'] ), 'group_id' ) as $groupId )
{
/* First one we find we'll set as primary - Joomla does not make a distinction */
if( !isset( $info['member_group_id'] ) )
{
$info['member_group_id'] = $groupId;
}
else
{
$info['mgroup_others'][] = $groupId;
}
}
$libraryClass::$usingKeys = TRUE;
$libraryClass->convertMember( $info );
$libraryClass->setLastKeyValue( $row['id'] );
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,86 @@
<?php
/**
* @brief Converter Photopost Core Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @package IPS Community Suite
* @subpackage Converter
* @since 6 December 2016
* @note Only redirect scripts are supported right now
*/
namespace IPS\convert\Software\Core;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
class _Photopost extends \IPS\convert\Software
{
/**
* Software Name
*
* @return string
*/
public static function softwareName()
{
/* Child classes must override this method */
return "Photopost";
}
/**
* Software Key
*
* @return string
*/
public static function softwareKey()
{
/* Child classes must override this method */
return "photopost";
}
/**
* Content we can convert from this software.
*
* @return NULL
*/
public static function canConvert()
{
return NULL;
}
/**
* Check if we can redirect the legacy URLs from this software to the new locations
*
* @return NULL|\IPS\Http\Url
*/
public function checkRedirects()
{
/* If we can't access profiles, don't bother trying to redirect */
if( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) )
{
return NULL;
}
$url = \IPS\Request::i()->url();
if( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'member.php' ) !== FALSE )
{
try
{
$data = (string) $this->app->getLink( \IPS\Request::i()->cat, array( 'members', 'core_members' ) );
return \IPS\Member::load( $data )->url();
}
catch( \Exception $e )
{
return NULL;
}
}
return NULL;
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,86 @@
<?php
/**
* @brief Converter PhpMyForum Core Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @package IPS Community Suite
* @subpackage Converter
* @since 6 December 2016
* @note Only redirect scripts are supported right now
*/
namespace IPS\convert\Software\Core;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
class _Phpmyforum extends \IPS\convert\Software
{
/**
* Software Name
*
* @return string
*/
public static function softwareName()
{
/* Child classes must override this method */
return "PhpMyForum";
}
/**
* Software Key
*
* @return string
*/
public static function softwareKey()
{
/* Child classes must override this method */
return "phpmyforum";
}
/**
* Content we can convert from this software.
*
* @return NULL
*/
public static function canConvert()
{
return NULL;
}
/**
* Check if we can redirect the legacy URLs from this software to the new locations
*
* @return NULL|\IPS\Http\Url
*/
public function checkRedirects()
{
/* If we can't access profiles, don't bother trying to redirect */
if( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) )
{
return NULL;
}
$url = \IPS\Request::i()->url();
if( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'profile.php' ) !== FALSE )
{
try
{
$data = (string) $this->app->getLink( \IPS\Request::i()->id, array( 'members', 'core_members' ) );
return \IPS\Member::load( $data )->url();
}
catch( \Exception $e )
{
return NULL;
}
}
return NULL;
}
}
@@ -0,0 +1,448 @@
<?php
/**
* @brief Converter Punbb Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @package IPS Community Suite
* @subpackage Converter
* @since 21 Jan 2015
*/
namespace IPS\convert\Software\Core;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
class _Punbb extends \IPS\convert\Software
{
/**
* Software Name
*
* @return string
*/
public static function softwareName()
{
/* Child classes must override this method */
return "PunBB 1.x";
}
/**
* Software Key
*
* @return string
*/
public static function softwareKey()
{
/* Child classes must override this method */
return "punbb";
}
/**
* Content we can convert from this software.
*
* @return array
*/
public static function canConvert()
{
return array(
'convertGroups' => array(
'table' => 'groups',
'where' => NULL,
),
'convertMembers' => array(
'table' => 'users',
'where' => NULL,
),
'convertRanks' => array(
'table' => 'ranks',
'where' => NULL
),
'convertPrivateMessages' => array(
'table' => 'messages',
'where' => NULL,
),
'convertPrivateMessageReplies' => array(
'table' => 'messages',
'where' => NULL
)
);
}
/**
* Can we convert passwords from this software.
*
* @return boolean
*/
public static function loginEnabled()
{
return TRUE;
}
/**
* List of conversion methods that require additional information
*
* @return array
*/
public static function checkConf()
{
return array(
'convertGroups',
'convertMembers'
);
}
/**
* Get More Information
*
* @param string $method Conversion method
* @return array
*/
public function getMoreInfo( $method )
{
$return = array();
switch( $method )
{
case 'convertGroups':
$return['convertGroups'] = array();
$options = array();
$options['none'] = 'None';
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
{
$options[$group->g_id] = $group->name;
}
foreach( $this->db->select( '*', 'groups' ) AS $group )
{
\IPS\Member::loggedIn()->language()->words["map_group_{$group['g_id']}"] = $group['g_title'];
\IPS\Member::loggedIn()->language()->words["map_group_{$group['g_id']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_group_desc' );
$return['convertGroups']["map_group_{$group['g_id']}"] = array(
'field_class' => 'IPS\\Helpers\\Form\\Select',
'field_default' => NULL,
'field_required' => FALSE,
'field_extra' => array( 'options' => $options ),
'field_hint' => NULL,
);
}
break;
case 'convertMembers':
/* Pseudo Profile Fields */
foreach( [ 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location' ] 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' );
$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' ),
),
'userSuppliedInput' => 'create_field'
),
'field_hint' => NULL
);
}
break;
}
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
}
/**
* Finish - Adds everything it needs to the queues and clears data store
*
* @return array Messages to display
*/
public function finish()
{
/* Search Index Rebuild */
\IPS\Content\Search\Index::i()->rebuild();
/* Clear Cache and Store */
\IPS\Data\Store::i()->clearAll();
\IPS\Data\Cache::i()->clearAll();
/* Non-Content Rebuilds */
\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' ) );
/* Content Counts */
\IPS\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' ) );
return array( "f_search_index_rebuild", "f_clear_caches", "f_rebuild_pms", "f_signatures_rebuild" );
}
/**
* Fix post data
*
* @param string raw post data
* @return string parsed post data
*/
public static function fixPostData( $post )
{
$post = nl2br( $post );
$post = preg_replace( "#\[quote=(.+)\]#", "[quote name=$1]", $post );
return $post;
}
/**
* Convert groups
*
* @return void
*/
public function convertGroups()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'g_id' );
foreach( $this->fetch( 'groups', 'g_id' ) AS $row )
{
$info = array(
'g_id' => $row['g_id'],
'g_name' => $row['g_title'],
'g_view_board' => $row['g_read_board'],
'g_mem_info' => $row['g_view_users'],
'g_is_supmod' => $row['g_moderator'],
'g_use_search' => $row['g_search'],
'g_edit_posts' => $row['g_edit_posts'],
'g_use_pm' => $row['g_pm'],
'g_pm_flood_mins' => ( $row['g_email_flood'] ) ? ceil( $row['g_email_flood'] / 60 ) : 0,
'g_delete_own_posts' => $row['g_delete_posts'],
'g_avoid_flood' => ( $row['g_post_flood'] == 0 ) ? 1 : 0,
'g_max_messages' => $row['g_pm_limit'],
'prefix' => ( $row['g_color'] ) ? "<span style='color:{$row['g_color']}'>" : NULL,
'suffix' => ( $row['g_color'] ) ? "</span>" : NULL,
'g_search_flood' => $row['g_search_flood'],
);
$merge = ( $this->app->_session['more_info']['convertGroups']["map_group_{$row['g_id']}"] != 'none' ) ? $this->app->_session['more_info']['convertGroups']["map_group_{$row['g_id']}"] : NULL;
$libraryClass->convertGroup( $info );
$libraryClass->setLastKeyValue( $row['g_id'], $merge );
}
}
/**
* Convert members
*
* @return void
*/
public function convertMembers()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id' );
foreach( $this->fetch( 'users', 'id' ) AS $row )
{
$info = array(
'member_id' => $row['id'],
'email' => $row['email'],
'name' => $row['username'],
'password' => $row['password'],
'conv_password_extra' => $row['salt'],
'member_group_id' => $row['group_id'],
'joined' => $row['registered'],
'ip_address' => $row['registration_ip'],
'last_visit' => $row['last_visit'],
'last_activity' => $row['last_visit'],
'auto_track' => ( $row['auto_notify'] ) ? [ 'content' => 1, 'comments' => 1, 'method' => 'immediate' ] : 0,
'members_bitoptions' => [ 'view_sigs' => $row['show_sig'] ],
'signature' => $row['signature'],
'timezone' => $row['timezone'],
'member_title' => $row['title'],
'member_posts' => $row['num_posts'],
);
/* Pseudo Fields */
$profileFields = array();
foreach( [ 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location' ] AS $pseudo )
{
/* Are we retaining? */
if ( $this->app->_session['more_info']['convertMembers']["field_{$pseudo}"] == 'no_convert' )
{
/* No, skip */
continue;
}
try
{
/* We don't actually need this, but we need to make sure the field was created */
$fieldId = $this->app->getLink( $pseudo, 'core_pfields_data' );
}
catch( \OutOfRangeException $e )
{
$libraryClass->convertProfileField( array(
'pf_id' => $pseudo,
'pf_name' => $this->app->_session['more_info']['convertMembers']["field_{$pseudo}"],
'pf_desc' => '',
'pf_type' => 'Text',
'pf_content' => '[]',
'pf_member_hide' => 0,
'pf_max_input' => 255,
'pf_member_edit' => 1,
'pf_show_on_reg' => 0,
'pf_admin_only' => 0,
) );
}
$profileFields[$pseudo] = $row[$pseudo];
}
$libraryClass->convertMember( $info, $profileFields );
$libraryClass->setLastKeyValue( $row['id'] );
}
}
/**
* Convert ranks
*
* @return void
*/
public function convertRanks()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id' );
foreach( $this->fetch( 'ranks', 'id' ) AS $row )
{
$info = array(
'id' => $row['id'],
'title' => $row['rank'],
'posts' => $row['min_posts']
);
$libraryClass->convertRank( $info );
$libraryClass->setLastKeyValue( $row['id'] );
}
}
/**
* Convert private messages
*
* @return void
*/
public function convertPrivateMessages()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id' );
foreach( $this->fetch( 'messages', 'id' ) AS $row )
{
/* PunBB does not have conversations, so convert each one into and individual PM topic */
$topic = array(
'mt_id' => $row['id'],
'mt_date' => $row['posted'],
'mt_title' => $row['subject'],
'mt_starter_id' => $row['sender_id'],
'mt_start_time' => $row['posted'],
'mt_last_post_time' => $row['posted'],
'mt_to_count' => ( $row['sender_id'] == $row['owner'] ) ? 1 : 2,
'mt_replies' => 1,
);
$maps = array();
/* Sender */
$maps[$row['sender_id']] = array(
'map_user_id' => $row['sender_id'],
'map_is_starter' => 1,
'map_last_topic_reply' => $row['posted'],
);
/* Recipient... if it isn't the sender */
if ( $row['sender_id'] != $row['owner'] )
{
$maps[$row['owner']] = array(
'map_user_id' => $row['owner'],
'map_is_starter' => 0,
'map_last_topic_reply' => $row['posted']
);
}
/* Simples! */
$libraryClass->convertPrivateMessage( $topic, $maps );
$libraryClass->setLastKeyValue( $row['id'] );
}
}
/**
* Convert PM replies
*
* @return void
*/
public function convertPrivateMessageReplies()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id' );
foreach( $this->fetch( 'messages', 'id' ) AS $row )
{
$libraryClass->convertPrivateMessageReply( array(
'msg_id' => $row['id'],
'msg_topic_id' => $row['id'],
'msg_date' => $row['posted'],
'msg_post' => $row['message'],
'msg_author_id' => $row['sender_id'],
'msg_ip_address' => $row['sender_ip'],
'msg_is_first_post' => 1,
) );
$libraryClass->setLastKeyValue( $row['id'] );
}
}
/**
* Check if we can redirect the legacy URLs from this software to the new locations
*
* @return NULL|\IPS\Http\Url
*/
public function checkRedirects()
{
/* If we can't access profiles, don't bother trying to redirect */
if( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) )
{
return NULL;
}
$url = \IPS\Request::i()->url();
if( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'profile.php' ) !== FALSE )
{
try
{
$data = (string) $this->app->getLink( \IPS\Request::i()->u, array( 'members', 'core_members' ) );
return \IPS\Member::load( $data )->url();
}
catch( \Exception $e )
{
return NULL;
}
}
return NULL;
}
}
@@ -0,0 +1,894 @@
<?php
/**
* @brief Converter Smf Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2015 Invision Power Services, Inc.
* @package IPS Social Suite
* @subpackage Converter
* @since 21 Jan 2015
* @version
*/
namespace IPS\convert\Software\Core;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
class _Smf extends \IPS\convert\Software
{
/**
* Software Name
*
* @return string
*/
public static function softwareName()
{
/* Child classes must override this method */
return "Simple Machines Forum";
}
/**
* Software Key
*
* @return string
*/
public static function softwareKey()
{
/* Child classes must override this method */
return "smf";
}
/**
* Content we can convert from this software.
*
* @return array
*/
public static function canConvert()
{
return array(
'convertBanfilters' => array(
'table' => 'ban_items',
'where' => NULL,
),
'convertEmoticons' => array(
'table' => 'smileys',
'where' => NULL,
),
'convertProfileFields' => array(
'table' => 'custom_fields',
'where' => NULL,
),
'convertGroups' => array(
'table' => 'membergroups',
'where' => NULL,
),
'convertMembers' => array(
'table' => 'members',
'where' => NULL,
),
'convertPrivateMessages' => array(
'table' => 'personal_messages',
'where' => NULL
),
'convertPrivateMessageReplies' => array(
'table' => 'personal_messages',
'where' => NULL
),
'convertIgnoredUsers' => array(
'table' => 'members',
'where' => array( 'LENGTH( pm_ignore_list ) > 0' ),
),
);
}
/**
* Can we convert passwords from this software.
*
* @return boolean
*/
public static function loginEnabled()
{
return TRUE;
}
/**
* List of conversion methods that require additional information
*
* @return array
*/
public static function checkConf()
{
return array(
'convertEmoticons',
'convertProfileFields',
'convertGroups',
'convertMembers'
);
}
/**
* Count Source Rows for a specific step
*
* @param string $table The table containing the rows to count.
* @param array|NULL $where WHERE clause to only count specific rows, or NULL to count all.
* @param bool $recache Skip cache and pull directly (updating cache)
* @return integer
* @throws \IPS\convert\Exception
*/
public function countRows( $table, $where=NULL, $recache=FALSE )
{
switch( $table )
{
case 'ignored_users':
try
{
return $this->db->select( 'SUM(CHAR_LENGTH(buddy_list) - CHAR_LENGTH(REPLACE(buddy_list, ",", "") + 1))', 'members', array( "pm_ignore_list!=?", '' ) )->first();
}
catch( \UnderflowException $e )
{
return 0;
}
break;
default:
return parent::countRows( $table, $where, $recache );
break;
}
}
/**
* Get More Information
*
* @param string $method Conversion method
* @return array
*/
public function getMoreInfo( $method )
{
$return = array();
switch( $method )
{
case 'convertEmoticons':
$return['convertEmoticons']['emoticon_path'] = array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => NULL,
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
);
$return['convertEmoticons']['keep_existing_emoticons'] = array(
'field_class' => 'IPS\\Helpers\\Form\\Checkbox',
'field_default' => TRUE,
'field_required' => FALSE,
'field_extra' => array(),
'field_hint' => NULL,
);
break;
case 'convertProfileFields':
$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[$field->_id] = $field->_title;
}
foreach( $this->db->select( '*', 'custom_fields' ) AS $field )
{
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['id_field']}"] = $field['field_name'];
\IPS\Member::loggedIn()->language()->words["map_pfield_{$field['id_field']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_pfield_desc' );
$return['convertProfileFields']["map_pfield_{$field['id_field']}"] = array(
'field_class' => 'IPS\\Helpers\\Form\\Select',
'field_default' => NULL,
'field_required' => FALSE,
'field_extra' => array( 'options' => $options ),
'field_hint' => NULL,
);
}
break;
case 'convertGroups':
$return['convertGroups'] = array();
$options = array();
$options['none'] = \IPS\Member::loggedIn()->language()->addToStack( 'none' );
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
{
$options[$group->g_id] = $group->name;
}
foreach( $this->db->select( '*', 'membergroups' ) AS $group )
{
\IPS\Member::loggedIn()->language()->words["map_group_{$group['id_group']}"] = $group['group_name'];
\IPS\Member::loggedIn()->language()->words["map_group_{$group['id_group']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_group_desc' );
$return['convertGroups']["map_group_{$group['id_group']}"] = array(
'field_class' => 'IPS\\Helpers\\Form\\Select',
'field_default' => NULL,
'field_required' => FALSE,
'field_extra' => array( 'options' => $options ),
'field_hint' => NULL
);
}
break;
case 'convertMembers':
$return['convertMembers'] = array();
$return['convertMembers']['username_or_display_name'] = array(
'field_class' => 'IPS\\Helpers\\Form\\Radio',
'field_default' => 'user_name',
'field_required' => TRUE,
'field_extra' => array( 'options' => array( 'user_name', 'display_name' ) ),
'field_hint' => NULL,
);
\IPS\Member::loggedIn()->language()->words['photo_location_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'photo_location_nodb_desc' );
$return['convertMembers']['photo_location'] = array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => "This is typically: /path/to/smf/attachments/",
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
);
$return['convertMembers']['gallery_location'] = array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => "This is typically: /path/to/smf/uploads/avatars/",
'field_validation' => function( $value ) { if ( !@is_dir( $value ) ) { throw new \DomainException( 'path_invalid' ); } },
);
foreach( array( 'gender', 'website_url', 'location', 'icq', 'aim', 'yim', 'msn', 'personal_text' ) AS $field )
{
\IPS\Member::loggedIn()->language()->words["field_{$field}"] = \IPS\Member::loggedIn()->language()->addToStack( 'pseudo_field', FALSE, array( 'sprintf' => $field ) );
\IPS\Member::loggedIn()->language()->words["field_{$field}_desc"] = \IPS\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' ),
),
'userSuppliedInput' => 'create_field'
),
'field_hint' => NULL
);
}
break;
}
return $return[ $method ];
}
/**
* Finish - Adds everything it needs to the queues and clears data store
*
* @return array Message to display
*/
public function finish()
{
/* Search Index Rebuild */
\IPS\Content\Search\Index::i()->rebuild();
/* Clear Cache and Store */
\IPS\Data\Store::i()->clearAll();
\IPS\Data\Cache::i()->clearAll();
/* Non-Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 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' ) );
/* Content Counts */
\IPS\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' ) );
/* Attachments */
\IPS\Task::queue( 'core', 'RebuildAttachmentThumbnails', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
return array( "f_search_index_rebuild", "f_clear_caches", "f_rebuild_pms", "f_signatures_rebuild", "f_rebuild_attachments" );
}
/**
* Fix post data
*
* @param string raw post data
* @return string parsed post data
*/
public static function fixPostData( $post )
{
// Replace BBCode - The table HTML is removed by our parser, but it leaves the posts cleaner than having unparsed bbcode
$search = array( '[li]', '[/li]', '[table]', '[/table]', '[tr]', '[/tr]', '[td]', '[/td]', '[tt]', '[/tt]' );
$replace = array( '[*]', '', '<table>', '</table>', '<tr>', '</tr>', '<td>', '</td>', '[code]', '[/code]' );
$post = str_replace( $search, $replace, $post );
// And img tags
$post = preg_replace("#\[img width=(\d+) height=(\d+)\]([a-zA-Z0-9.:\-/]+)\[\/img\]#i", "[img]$3[/img]", $post);
//Quotes
$post = preg_replace("#\[quote author=(.+?) link=(.+?)=(\d+)\.msg(\d+)(.+?)date=(\d+)\](.+)\[\/quote\]#i", "[quote name=\"$1\" post=\"$4\" timestamp=\"$6\"]$7[/quote]", $post);
return $post;
}
/**
* Convert ban filters
*
* @return void
*/
public function convertBanfilters()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id_ban' );
foreach( $this->fetch( 'ban_items', 'id_ban' ) AS $row )
{
/* Hostnames aren't supported, and Members are done later */
if ( $row['hostname'] OR $row['id_member'] )
{
$libraryClass->setLastKeyValue( $row['id_ban'] );
continue;
}
if ( $row['ip_low1'] AND $row['ip_low2'] AND $row['ip_low3'] AND $row['ip_low4'] )
{
$libraryClass->convertBanfilter( array(
'ban_id' => $row['id_ban'],
'ban_type' => 'ip',
'ban_content' => $row['ip_low1'] . '.' . $row['ip_low2'] . '.' . $row['ip_low3'] . '.' . $row['ip_low4']
) );
}
if ( $row['email_address'] )
{
$libraryClass->convertBanfilter( array(
'ban_id' => $row['id_ban'],
'ban_type' => 'email',
'ban_content' => $row['email_address'],
) );
}
$libraryClass->setLastKeyValue( $row['id_ban'] );
}
}
/**
* Convert emoticons
*
* @return void
*/
public function convertEmoticons()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id_smiley' );
foreach( $this->fetch( 'smileys', 'id_smiley' ) AS $row )
{
$libraryClass->convertEmoticon( array(
'id' => $row['id_smiley'],
'typed' => $row['code'],
'filename' => $row['filename'],
'clickable' => !$row['hidden'],
'emo_position' => $row['smiley_order']
), array(
'set' => md5( 'Converted' ),
'title' => 'Converted',
'position' => 1
), $this->app->_session['more_info']['convertEmoticons']['keep_existing_emoticons'], rtrim( $this->app->_session['more_info']['convertEmoticons']['emoticon_path'], '/' ) );
$libraryClass->setLastKeyValue( $row['id_smiley'] );
}
}
/**
* Convert private messages
*
* @return void
*/
public function convertPrivateMessages()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id_pm' );
foreach( $this->fetch( 'personal_messages', 'id_pm' ) AS $row )
{
$topic = array(
'mt_id' => $row['id_pm'],
'mt_date' => $row['msgtime'],
'mt_title' => $row['subject'],
'mt_starter_id' => $row['id_member_from'],
'mt_start_time' => $row['msgtime'],
'mt_last_post_time' => $row['msgtime'],
'mt_to_count' => 0,
'mt_replies' => 0,
);
$maps = array(
$row['id_member_from'] = array(
'map_user_id' => $row['id_member_from'],
'map_read_time' => time(),
'map_user_active' => ( $row['deleted_by_sender'] ) ? 0 : 1,
'map_user_banned' => 0,
'map_has_unread' => 0,
'map_is_starter' => 1,
'map_last_topic_reply' => $row['msgtime']
)
);
foreach( $this->db->select( '*', 'pm_recipients', array( "id_pm=?", $row['id_pm'] ) ) AS $map )
{
if( !isset( $maps[ $map['id_member'] ] ) )
{
$maps[ $map['id_member'] ] = array(
'map_user_id' => $map['id_member'],
'map_read_time' => $map['is_new'] ? time() : 0,
'map_user_active' => $map['deleted'] ? 0 : 1,
'map_user_banned' => 0,
'map_has_unread' => $map['is_new'],
'map_is_starter' => 0,
'map_last_topic_reply' => $row['msgtime']
);
}
}
$libraryClass->convertPrivateMessage( $topic, $maps );
$libraryClass->setLastKeyValue( $row['id_pm'] );
}
}
/**
* Convert PM replies
*
* @return void
*/
public function convertPrivateMessageReplies()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id_pm' );
foreach( $this->fetch( 'personal_messages', 'id_pm' ) AS $row )
{
$libraryClass->convertPrivateMessageReply( array(
'msg_id' => $row['id_pm'],
'msg_topic_id' => $row['id_pm'],
'msg_date' => $row['msgtime'],
'msg_post' => $row['body'],
'msg_author_id' => $row['id_member_from'],
) );
$libraryClass->setLastKeyValue( $row['id_pm'] );
}
}
/**
* Convert custom fields
*
* @return void
*/
public function convertProfileFields()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id_field' );
foreach( $this->fetch( 'custom_fields', 'id_field' ) AS $row )
{
$type = NULL;
switch( $row['field_type'] )
{
case 'textarea':
$type = 'TextArea';
break;
case 'check':
$type = 'Checkbox';
break;
default:
$type = ucwords( $row['field_type'] );
break;
}
if ( $row['mask'] == 'email' )
{
$type = 'Email';
}
if ( $row['mask'] == 'number' )
{
$type = 'Number';
}
$info = array(
'pf_id' => $row['col_name'],
'pf_type' => $type,
'pf_name' => $row['field_name'],
'pf_desc' => $row['field_desc'],
'pf_content' => ( in_array( $row['field_type'], array( 'select', 'radio' ) ) ) ? json_encode( explode( ',', $row['field_options'] ) ) : NULL,
'pf_not_null' => ( $row['show_reg'] == 2 ) ? 1 : 0,
'pf_member_hide' => ( $row['private'] >= 3 ) ? 1 : 0,
'pf_max_input' => ( !in_array( $row['field_type'], array( 'select', 'radio', 'check' ) ) ) ? $row['field_length'] : NULL,
'pf_member_edit' => ( $row['private'] < 4 ) ? 1 : 0,
'pf_position' => $row['placement'],
'pf_show_on_reg' => ( $row['show_reg'] >= 1 ) ? 1 : 0,
'pf_input_format' => ( mb_substr( $row['mask'], 0, 5 ) == 'regex' ) ? str_replace( 'regex', '', $row['mask'] ) : NULL,
'pf_admin_only' => ( $row['private'] == 4 ) ? 1 : 0,
);
$merge = ( $this->app->_session['more_info']['convertProfileFields']["map_pfield_{$row['id_field']}"] != 'none' ) ? $this->app->_session['more_info']['convertProfileFields']["map_pfield_{$row['id_field']}"] : NULL;
$libraryClass->convertProfileField( $info, $merge );
$libraryClass->setLastKeyValue( $row['id_field'] );
}
}
/**
* Convert groups
*
* @return void
*/
public function convertGroups()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id_group' );
foreach( $this->fetch( 'membergroups', 'id_group' ) AS $row )
{
$prefix = NULL;
$suffix = NULL;
if ( $row['online_color'] )
{
$prefix = "<span style='color:{$row['online_color']}'>";
$suffix = "</span>";
}
$info = array(
'g_id' => $row['id_group'],
'g_name' => $row['group_name'],
'prefix' => $prefix,
'suffix' => $suffix,
'g_max_messages' => $row['max_messages'],
);
$merge = $this->app->_session['more_info']['convertGroups']["map_group_{$row['id_group']}"] != 'none' ? $this->app->_session['more_info']['convertGroups']["map_group_{$row['id_group']}"] : NULL;
$libraryClass->convertGroup( $info, $merge );
$libraryClass->setLastKeyValue( $row['id_group'] );
}
}
/**
* Convert members
*
* @return void
*/
public function convertMembers()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id_member' );
foreach( $this->fetch( 'members', 'id_member' ) AS $row )
{
$name = $row['real_name'];
if ( $this->app->_session['more_info']['convertMembers']['username_or_display_name'] == 'username' )
{
$name = $row['member_name'];
}
/* Restrictions */
$ban = 0;
$rp = 0;
try
{
$ban_data = $this->db->select( '*', 'ban_groups', array( "id_ban_group=?", $this->db->select( 'id_ban_group', 'ban_items', array( "id_member=?", $row['id_member'] ) )->first() ) )->first();
$time = -1;
if ( $ban_data['expire_time'] )
{
$time = $ban_data['expire_time'];
}
if ( $ban_data['cannot_access'] )
{
$ban = $time;
}
if ( $ban_data['cannot_post'] )
{
$rp = $time;
}
}
catch( \UnderflowException $e ) {}
$bday_year = $bday_month = $bday_day = NULL;
/* Make sure it isn't the SMF placeholder */
if( $row['birthdate'] != '0001-01-01' )
{
list( $bday_year, $bday_month, $bday_day ) = explode( '-', $row['birthdate'] );
}
$info = array(
'member_id' => $row['id_member'],
'email' => $row['email_address'],
'name' => $name,
'password' => $row['passwd'],
'password_extra' => $row['password_salt'],
'member_group_id' => $row['id_group'],
'joined' => $row['date_registered'],
'ip_address' => $row['member_ip'],
'msg_count_new' => $row['unread_messages'],
'msg_count_total' => $row['instant_messages'],
'msg_show_notification' => $row['new_pm'],
'last_visit' => $row['last_login'],
'last_activity' => $row['last_login'],
'restrict_post' => $rp,
'temp_ban' => $ban,
'bday_day' => $bday_day,
'bday_month' => $bday_month,
'bday_year' => $bday_year,
'mgroup_others' => $row['additional_groups'],
'signature' => $row['signature'],
'pp_reputation_points' => $row['karma_good'] - $row['karma_bad'],
'timezone' => $row['time_offset'],
'allow_admin_mails' => $row['notify_announcements'],
'member_title' => $row['usertitle'],
'member_posts' => $row['posts'],
);
$pfields = array();
/* Pseudo Profile Fields */
foreach( array( 'gender', 'website_url', 'location', 'icq', 'aim', 'yim', 'msn', 'personal_text' ) AS $pseudo )
{
/* Are we retaining? */
if ( $this->app->_session['more_info']['convertMembers']["field_{$pseudo}"] == 'no_convert' )
{
/* No, skip */
continue;
}
try
{
$fieldId = $this->app->getLink( $pseudo, 'core_pfields_data' );
}
catch( \OutOfRangeException $e )
{
$type = 'Text';
$content = '[]';
switch( $pseudo )
{
case 'gender':
$type = 'Select';
$content = json_encode( [ 'Male', 'Female', 'Undisclosed' ] );
break;
case 'personal_text':
$type = 'TextArea';
break;
}
$libraryClass->convertProfileField( array(
'pf_id' => $pseudo,
'pf_name' => $this->app->_session['more_info']['convertMembers']["field_{$pseudo}"],
'pf_desc' => '',
'pf_type' => $type,
'pf_content' => $content,
'pf_member_hide' => 0,
'pf_max_input' => 255,
'pf_member_edit' => 1,
'pf_show_on_reg' => 0,
'pf_admin_only' => 0,
) );
}
switch( $pseudo )
{
case 'gender':
switch( $row[$pseudo] )
{
case 1:
$pfields[$pseudo] = 'Male';
break;
case 2:
$pfields[$pseudo] = 'Female';
break;
default:
$pfields[$pseudo] = 'Undisclosed';
break;
}
break;
default:
$pfields[$pseudo] = $row[$pseudo];
break;
}
}
/* Real Profile Fields */
foreach( $this->db->select( 'variable, value', 'themes', array( "id_member=?", $row['id_member'] ) )->setKeyField( 'variable' )->setValueField( 'value' ) AS $key => $value )
{
$pfields[$key] = $value;
}
/* Photos */
$filedata = NULL;
$filename = NULL;
$filepath = NULL;
if ( $row['avatar'] )
{
if ( mb_substr( $row['avatar'], 0, 4 ) == 'http' )
{
/* Remote */
try
{
$file = \IPS\Http\Url::external( $row['avatar'] )->request()->get();
$filename = explode( '/', $row['avatar'] );
$filename = array_pop( $filename );
$filedata = (string) $file;
}
catch( \Exception $e ) {}
}
else
{
/* Gallery */
$file = rtrim( $this->app->_session['more_info']['convertMembers']['gallery_location'], '/' );
if ( @file_exists( $file . '/' . $row['avatar'] ) )
{
$filename = $row['avatar'];
$filepath = $file;
}
}
}
else
{
/* Maybe Uploaded */
try
{
$attach = $this->db->select( '*', 'attachments', array( "id_member=? AND filename LIKE CONCAT( ?, '%' )", $row['id_member'], 'avatar_' ) )->first();
$file = rtrim( $this->app->_session['more_info']['convertMembers']['photo_location'], '/' );
/* We need to figure out where it is */
if ( $attach['file_hash'] )
{
$location = $attach['id_attach'] . '_' . $attach['file_hash'];
}
else
{
/* Clean filename per legacy SMF requirements */
$cleanName = strtr( $attach['filename'], 'ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ', 'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy');
$cleanName = strtr( $cleanName, array( 'Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u' ) );
$cleanName = preg_replace( array( '/s/', '/[^w_.-]/' ), array( '_', '' ), $cleanName );
$location = $attach['id_attach'] . '_' . str_replace( '.', '_', $cleanName ) . md5( $cleanName );
}
if ( @file_exists( $file . '/' . $location ) )
{
$filename = $attach['filename'];
$filedata = file_get_contents( $file . '/' . $location );
}
}
catch( \UnderflowException $e ) {}
}
$libraryClass->convertMember( $info, $pfields, $filename, $filepath, $filedata );
$libraryClass->setLastKeyValue( $row['id_member'] );
}
}
/**
* Convert ignored users
*
* @return void
*/
public function convertIgnoredUsers()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'id_member' );
foreach( $this->fetch( 'members', 'id_member', array( 'LENGTH( pm_ignore_list ) > 0' ) ) AS $row )
{
if ( !$row['pm_ignore_list'] )
{
continue;
}
foreach( explode( ',', $row['pm_ignore_list'] ) AS $id )
{
$info = array();
$info['ignore_id'] = $row['id_member'] . '_' . $id;
$info['ignore_owner_id'] = $row['id_member'];
$info['ignore_ignore_id'] = $id;
foreach( \IPS\core\Ignore::types() AS $type )
{
$info['ignore_' . $type] = 1;
}
$libraryClass->convertIgnoredUser( $info );
}
$libraryClass->setLastKeyValue( $row['id_member'] );
}
}
/**
* Check if we can redirect the legacy URLs from this software to the new locations
*
* @return NULL|\IPS\Http\Url
* @note Current profile URL format: /index.php?action=profile;u=123
*/
public function checkRedirects()
{
/* If we can't access profiles, don't bother trying to redirect */
if( !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) )
{
return NULL;
}
if( isset( \IPS\Request::i()->action ) AND mb_strpos( \IPS\Request::i()->action, 'profile' ) !== FALSE )
{
if( isset( \IPS\Request::i()->u ) )
{
$oldId = \IPS\Request::i()->u;
}
else
{
$pieces = explode( ';', \IPS\Request::i()->action );
foreach( $pieces as $piece )
{
$_pieces = explode( '=', $piece );
if( $_pieces[0] === 'u' )
{
$oldId = (int) $_pieces[1];
break;
}
}
}
try
{
$data = (string) $this->app->getLink( $oldId, array( 'members', 'core_members' ) );
return \IPS\Member::load( $data )->url();
}
catch( \Exception $e )
{
return NULL;
}
}
return NULL;
}
}
@@ -0,0 +1,776 @@
<?php
/**
* @brief Converter UBBthreads Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2015 Invision Power Services, Inc.
* @package IPS Social Suite
* @subpackage Converter
* @since 21 Jan 2015
* @version
*/
namespace IPS\convert\Software\Core;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
class _UBBthreads extends \IPS\convert\Software
{
/**
* @brief Emoticons WHERE statement
* @see convertEmoticons()
*/
protected static $emoticonsWhere = 'GRAEMLIN_IS_ACTIVE=1';
/**
* @brief Groups WHERE statement
* @see convertGroups()
*/
protected static $groupsWhere = 'GROUP_IS_DISABLED=0';
/**
* @brief Ignored users WHERE statement
* @see convertIgnoredUsers()
*/
protected static $ignoredUsersWhere = "USER_IGNORE_LIST IS NOT NULL AND USER_IGNORE_LIST NOT IN ( '', '-' )";
/**
* @brief Members WHERE statement
* @see convertMembers()
*/
protected static $membersWhere = array( 'u.USER_LOGIN_NAME<>?', '**DONOTDELETE**' );
/**
* This is.. kind of hacky, but it's used so we can try and support non-exact profanity matches without converting
* other regexes we don't support
*
* @brief Profanity filters WHERE statement
* @see convertProfanityFilters()
*/
protected static $profanityFiltersWhere = '(
CENSOR_WORD NOT LIKE "%(.*)%" AND (
CENSOR_WORD NOT LIKE "%(.*?)%" OR (
CENSOR_WORD LIKE "%(.*?)" AND CENSOR_WORD NOT LIKE "%(.*?)%(.*?)"
)
)
)';
/**
* Software Name
*
* @return string
*/
public static function softwareName()
{
/* Child classes must override this method */
return "UBBthreads";
}
/**
* Software Key
*
* @return string
*/
public static function softwareKey()
{
/* Child classes must override this method */
return "UBBthreads";
}
/**
* Content we can convert from this software.
*
* @return array
*/
public static function canConvert()
{
return array(
'convertEmoticons' => array(
'table' => 'GRAEMLINS',
'where' => static::$emoticonsWhere,
),
'convertBanfilters' => array(
'table' => 'pseudo_banfilters', /** @see countRows() */
'where' => NULL
),
'convertGroups' => array(
'table' => 'GROUPS',
'where' => static::$groupsWhere
),
'convertMembers' => array(
'table' => array( 'USERS', 'u' ),
'where' => static::$membersWhere,
'extra_steps' => array( 'convertMembersFollowers' ),
),
'convertIgnoredUsers' => array(
'table' => 'USER_PROFILE',
'where' => static::$ignoredUsersWhere
),
'convertMembersFollowers' => array(
'table' => 'WATCH_LISTS',
'where' => array( 'WATCH_TYPE=?', 'u' )
),
'convertRanks' => array(
'table' => 'USER_TITLES',
'where' => NULL
),
'convertPrivateMessages' => array(
'table' => 'PRIVATE_MESSAGE_TOPICS',
'where' => NULL
),
'convertPrivateMessageReplies' => array(
'table' => 'PRIVATE_MESSAGE_POSTS',
'where' => NULL
),
'convertProfanityFilters' => array(
'table' => 'CENSOR_LIST',
'where' => static::$profanityFiltersWhere
),
);
}
/**
* Can we convert passwords from this software.
*
* @return boolean
*/
public static function loginEnabled()
{
return TRUE;
}
/**
* Count Source Rows for a specific step
*
* @param string $table The table containing the rows to count.
* @param array|NULL $where WHERE clause to only count specific rows, or NULL to count all.
* @param bool $recache Skip cache and pull directly (updating cache)
* @return integer
* @throws \IPS\convert\Exception
*/
public function countRows( $table, $where=NULL, $recache=FALSE )
{
switch ( $table )
{
case 'pseudo_banfilters':
return parent::countRows( 'BANNED_EMAILS' )
+ parent::countRows( 'BANNED_HOSTS' )
+ parent::countRows( 'RESERVED_NAMES' );
}
return parent::countRows( $table, $where, $recache );
}
/**
* List of conversion methods that require additional information
*
* @return array
*/
public static function checkConf()
{
return array(
'convertEmoticons',
'convertGroups',
'convertMembers'
);
}
/**
* Attempt to convert a textual date(time) representation to a DateTime instance
*
* @param string $date
* @return \IPS\DateTime|null
*/
protected function stringToDateTime( $date )
{
try
{
return new \IPS\DateTime( $date );
}
catch( \Exception $e )
{
return NULL;
}
}
/**
* Get More Information
*
* @param string $method Conversion method
* @return array
*/
public function getMoreInfo( $method )
{
$return = array();
switch( $method )
{
case 'convertEmoticons':
$return['convertEmoticons'] = array();
\IPS\Member::loggedIn()->language()->words['emoticon_path'] = \IPS\Member::loggedIn()->language()->addToStack( 'source_path', FALSE, array( 'sprintf' => array( 'UBBthreads' ) ) );
$return['convertEmoticons']['emoticon_path'] = array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => NULL
);
$return['convertEmoticons']['keep_existing_emoticons'] = array(
'field_class' => 'IPS\\Helpers\\Form\\Checkbox',
'field_default' => TRUE,
'field_required' => FALSE,
'field_extra' => array(),
'field_hint' => NULL,
);
break;
case 'convertGroups':
$return['convertGroups'] = array();
$options = array();
$options['none'] = \IPS\Member::loggedIn()->language()->addToStack( 'none' );
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
{
$options[ $group->g_id ] = $group->name;
}
foreach( $this->db->select( '*', 'GROUPS' ) AS $group )
{
\IPS\Member::loggedIn()->language()->words["map_group_{$group['GROUP_ID']}"] = $group['GROUP_NAME'];
\IPS\Member::loggedIn()->language()->words["map_group_{$group['GROUP_ID']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_group_desc' );
$return['convertGroups']["map_group_{$group['GROUP_ID']}"] = array(
'field_class' => 'IPS\\Helpers\\Form\\Select',
'field_default' => NULL,
'field_required' => FALSE,
'field_extra' => array( 'options' => $options ),
'field_hint' => NULL
);
}
break;
case 'convertMembers':
$return['convertMembers'] = array();
/* Should we use the username or display name property when converting? */
$return['convertMembers']['username'] = array(
'field_class' => 'IPS\\Helpers\\Form\\Radio',
'field_default' => 'display_name',
'field_required' => TRUE,
'field_extra' => array( 'options' => array( 'username' => \IPS\Member::loggedIn()->language()->addToStack( 'user_name' ), 'display_name' => \IPS\Member::loggedIn()->language()->addToStack( 'display_name' ) ) ),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack( 'username_hint' ),
);
foreach( array( 'homepage', 'occupation', 'hobbies', 'location', 'icq', 'yahoo', 'aim', 'msn' ) AS $field )
{
\IPS\Member::loggedIn()->language()->words["field_{$field}"] = \IPS\Member::loggedIn()->language()->addToStack( 'pseudo_field', FALSE, array( 'sprintf' => $field ) );
\IPS\Member::loggedIn()->language()->words["field_{$field}_desc"] = \IPS\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' ),
),
'userSuppliedInput' => 'create_field'
),
'field_hint' => NULL
);
}
break;
}
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
}
/**
* Finish - Adds everything it needs to the queues and clears data store
*
* @return array Messages to display
*/
public function finish()
{
/* Search Index Rebuild */
\IPS\Content\Search\Index::i()->rebuild();
/* Clear Cache and Store */
\IPS\Data\Store::i()->clearAll();
\IPS\Data\Cache::i()->clearAll();
/* Non-Content Rebuilds */
\IPS\Task::queue( 'convert', 'RebuildNonContent', array( 'app' => $this->app->app_id, 'link' => 'core_members', 'extension' => 'core_Signatures' ), 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' ) );
/* 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\Conversation' ), 3, array( 'class' ) );
/* First Post Data */
\IPS\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 ), 4, array( 'app' ) );
return array( "f_search_index_rebuild", "f_clear_caches", "f_rebuild_pms", "f_signatures_rebuild", "f_rebuild_attachments" );
}
/**
* Fix post data
*
* @param string raw post data
* @return string parsed post data
*/
public static function fixPostData( $post )
{
$post = preg_replace( "#\[quote=(.+?)\]#i", "[quote name=\"$1\"]", $post );
$post = str_ireplace( [ "[image]", '[/image]', '[size:', '[color:' ], [ '[img]', '[/img]', '[size=', '[color=' ], $post );
return $post;
}
/**
* Convert ban filters
*
* @return void
*/
public function convertBanfilters()
{
$libraryClass = $this->getLibrary();
/* Banned e-mails */
foreach ( $this->db->select( 'BANNED_EMAIL', 'BANNED_EMAILS' ) as $row )
{
$libraryClass->convertBanfilter( array(
'ban_id' => $row, // We don't actually have an ID column
'ban_type' => 'email',
'ban_content' => str_replace( '%', '*', $row ) // Replace UBB's wildcard character
) );
}
/* Banned IP's */
foreach( $this->db->select( 'BANNED_HOST', 'BANNED_HOSTS' ) as $row )
{
$libraryClass->convertBanfilter( array(
'ban_id' => $row, // We don't actually have an ID column
'ban_type' => 'ip',
'ban_content' => str_replace( '%', '*', $row ) // Replace UBB's wildcard character
) );
}
/* Banned / "reserved" names */
foreach ( $this->db->select( 'RESERVED_USERNAME', 'RESERVED_NAMES' ) as $row )
{
$libraryClass->convertBanfilter( array(
'ban_id' => $row, // We don't actually have an ID column
'ban_type' => 'name',
'ban_content' => str_replace( '%', '*', $row ) // Replace UBB's wildcard character; TODO: Verify UBB actually supports wildcards here
) );
}
throw new \IPS\convert\Software\Exception;
}
/**
* Convert emoticons
*
* @return void
*/
public function convertEmoticons()
{
$libraryClass = $this->getLibrary();
foreach( $this->fetch( 'GRAEMLINS', 'GRAEMLIN_ID', static::$emoticonsWhere ) as $row )
{
$info = array(
'id' => $row['GRAEMLIN_ID'],
'typed' => $row['GRAEMLIN_SMILEY_CODE'] ?: ':'.$row['GRAEMLIN_MARKUP_CODE'].':',
'width' => $row['GRAEMLIN_WIDTH'],
'height' => $row['GRAEMLIN_HEIGHT'],
'filename' => $row['GRAEMLIN_IMAGE'],
'emo_position' => $row['GRAEMLIN_ID'],
);
$set = array(
'set' => md5( 'Converted' ),
'title' => 'Converted',
'position' => 1,
);
$libraryClass->convertEmoticon(
$info, $set, $this->app->_session['more_info']['convertEmoticons']['keep_existing_emoticons'],
rtrim( $this->app->_session['more_info']['convertEmoticons']['emoticon_path'], '/' ) . "/images/graemlins/default"
);
$libraryClass->setLastKeyValue( $row['GRAEMLIN_ID'] );
}
}
/**
* Convert groups
*
* @return void
*/
public function convertGroups()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'GROUP_ID' );
foreach ( $this->fetch( 'GROUPS', 'GROUP_ID', static::$groupsWhere ) as $row )
{
/* @TODO: Can we enable custom titles per group? */
$info = array(
'g_id' => $row['GROUP_ID'],
'g_name' => $row['GROUP_NAME'],
);
$merge = $this->app->_session['more_info']['convertGroups']["map_group_{$row['GROUP_ID']}"] != 'none' ? $this->app->_session['more_info']['convertGroups']["map_group_{$row['GROUP_ID']}"] : NULL;
$libraryClass->convertGroup( $info, $merge );
$libraryClass->setLastKeyValue( $row['GROUP_ID'] );
}
}
/**
* Convert ignored users
*
* @return void
*/
public function convertIgnoredUsers()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'USER_ID' );
foreach ( $this->fetch( 'USER_PROFILE', 'USER_ID', static::$ignoredUsersWhere ) as $row )
{
/* Proper database modeling? CSV's? JSON? What are those things? */
foreach ( explode( '-', $row['USER_IGNORE_LIST'] ) as $ignoredMemberMaybe )
{
if ( ! $ignoredMemberMaybe )
{
/* We split an empty string. Fabulous. */
continue;
}
$info = array(
'ignore_id' => $row['USER_ID'] . '-' . $ignoredMemberMaybe,
'ignore_owner_id' => $row['USER_ID'],
'ignore_ignore_id' => $ignoredMemberMaybe
);
/* Assume we want to ignore everything by this member */
foreach ( \IPS\core\Ignore::types() as $type )
{
$info[ 'ignore_' . $type ] = 1;
}
$libraryClass->convertIgnoredUser( $info );
$libraryClass->setLastKeyValue( $row['USER_ID'] );
}
}
}
/**
* Convert members
*
* @return void
*/
public function convertMembers()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'u.USER_ID' );
$select = $this->fetch( array( 'USERS', 'u' ), 'u.USER_ID', static::$membersWhere )
->join( array( 'BANNED_USERS', 'b' ), 'u.USER_ID=b.USER_ID', 'LEFT' )
->join( array( 'USER_PROFILE', 'p' ), 'u.USER_ID=p.USER_ID' )
->join( array( 'USER_DATA', 'd' ), 'u.USER_ID=d.USER_ID' );
foreach ( $select as $row )
{
/* Birthday */
$birthday = array( 'day' => NULL, 'month' => NULL, 'year' => NULL );
if ( $birthdayDt = $this->stringToDateTime( $row['USER_BIRTHDAY'] ) )
{
$birthday['day'] = $birthdayDt->format( 'j' );
$birthday['month'] = $birthdayDt->format( 'n' );
$birthday['year'] = $birthdayDt->format( 'Y' );
}
/* Member groups */
$secondaryGroups = iterator_to_array( $this->db->select( 'GROUP_ID', 'USER_GROUPS', array( 'USER_ID=?', $row['USER_ID'] ) ) );
$primaryGroup = array_shift( $secondaryGroups );
$info = array(
'member_id' => $row['USER_ID'],
'name' => ( $this->app->_session['more_info']['convertMembers']['username'] == 'user_name' )
? $row['USER_LOGIN_NAME']
: $row['USER_DISPLAY_NAME'],
'email' => $row['USER_REAL_EMAIL'],
'md5_password' => $row['USER_PASSWORD'],
'member_group_id' => $primaryGroup,
'mgroup_others' => $secondaryGroups,
'joined' => \IPS\DateTime::create()->setTimestamp( $row['USER_REGISTERED_ON'] ),
'ip_address' => $row['USER_REGISTRATION_IP'],
'bday_day' => $birthday['day'],
'bday_month' => $birthday['month'],
'bday_year' => $birthday['year'],
'msg_count_total' => $row['USER_TOTAL_PM'],
'last_visit' => \IPS\DateTime::create()->setTimestamp( $row['USER_LAST_VISIT_TIME'] ),
'last_activity' => \IPS\DateTime::create()->setTimestamp(
max( (int) $row['USER_LAST_POST_TIME'], (int) $row['USER_LAST_SEARCH_TIME'] )
),
'allow_admin_mails' => ( $row['USER_ACCEPT_ADMIN_EMAILS'] != 'Off' ),
'member_title' => $row['USER_CUSTOM_TITLE'],
'member_posts' => $row['USER_TOTAL_POSTS'],
'signature' => $row['USER_DEFAULT_SIGNATURE'],
'member_last_post' => \IPS\DateTime::create()->setTimestamp( $row['USER_LAST_POST_TIME'] ),
'temp_ban' => isset( $row['BAN_EXPIRATION'] )
? ( ( (string) $row['BAN_EXPIRATION'] === '0' )
? -1
: \IPS\DateTime::create()->setTimestamp( $row['BAN_EXPIRATION'] ) )
: NULL,
);
/* Profile fields */
$pfields = array();
foreach( array( 'homepage', 'occupation', 'hobbies', 'location', 'icq', 'yahoo', 'aim', 'msn' ) AS $pseudo )
{
/* Are we retaining? */
if ( $this->app->_session['more_info']['convertMembers']["field_{$pseudo}"] == 'no_convert' )
{
/* No, skip */
continue;
}
try
{
/* We don't actually need this, but we need to make sure the field was created */
$fieldId = $this->app->getLink( $pseudo, 'core_pfields_data' );
}
catch( \OutOfRangeException $e )
{
$libraryClass->convertProfileField( array(
'pf_id' => $pseudo,
'pf_name' => $this->app->_session['more_info']['convertMembers']["field_{$pseudo}"],
'pf_desc' => '',
'pf_type' => 'Text',
'pf_content' => '[]',
'pf_member_hide' => 0,
'pf_max_input' => 255,
'pf_member_edit' => 1,
'pf_show_on_reg' => 0,
'pf_admin_only' => 0,
) );
}
$fieldColumn = 'USER_' . \strtoupper( $pseudo );
$pfields[ $pseudo ] = isset( $row[ $fieldColumn ] ) ? $row[ $fieldColumn ] : NULL;
}
/* Profile photo */
$profilePhotoName = NULL;
$profilePhotoData = NULL;
if ( !empty( $row['USER_AVATAR'] ) AND ( $row['USER_AVATAR'] != 'http://' ) )
{
try
{
$profilePhotoName = pathinfo( parse_url( $row['USER_AVATAR'], PHP_URL_PATH ), PATHINFO_BASENAME );
$profilePhotoData = \IPS\Http\Url::external( $row['USER_AVATAR'] )->request()->get();
}
catch( \IPS\Http\Request\Exception $e ) { }
}
$libraryClass->convertMember( $info, $pfields, $profilePhotoName, NULL, $profilePhotoData );
$libraryClass->setLastKeyValue( $row['USER_ID'] );
}
}
/**
* Convert member followers
*
* @return void
*/
public function convertMembersFollowers()
{
$libraryClass = $this->getLibrary();
foreach ( $this->fetch( 'WATCH_LISTS', 'WATCH_ID', array( 'WATCH_TYPE=?', 'u' ), 'USER_ID ASC, WATCH_ID ASC' ) as $row )
{
$libraryClass->convertFollow( array(
'follow_app' => 'core',
'follow_area' => 'member',
'follow_rel_id' => $row['WATCH_ID'],
'follow_rel_id_type' => 'core_members',
'follow_member_id' => $row['USER_ID'],
'follow_notify_freq' => $row['WATCH_NOTIFY_IMMEDIATE'] ? 'immediate' : 'none',
) );
}
}
/**
* Convert member ranks
*
* @return void
*/
public function convertRanks()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'USER_TITLE_ID' );
foreach ( $this->fetch( 'USER_TITLES', 'USER_TITLE_ID' ) as $row )
{
/**
* @TODO: We should probably prompt to keep or overwrite existing titles, since this can currently result...
* ...in duplicate entries for the same post counts if the local rows are not dropped
*/
$libraryClass->convertRank( array(
'id' => $row['USER_TITLE_ID'],
'title' => $row['USER_TITLE_NAME'],
'posts' => $row['USER_TITLE_POST_COUNT']
) );
$libraryClass->setLastKeyValue( $row['USER_TITLE_ID'] );
}
}
/**
* Convert private messages
*
* @return void
*/
public function convertPrivateMessages()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'TOPIC_ID' );
foreach ( $this->fetch( 'PRIVATE_MESSAGE_TOPICS', 'TOPIC_ID' ) as $topicRow )
{
$topic = array(
'mt_id' => $topicRow['TOPIC_ID'],
'mt_date' => \IPS\DateTime::create()->setTimestamp( $topicRow['TOPIC_TIME'] ),
'mt_title' => $topicRow['TOPIC_SUBJECT'],
'mt_starter_id' => $topicRow['USER_ID'],
'mt_start_time' => \IPS\DateTime::create()->setTimestamp( $topicRow['TOPIC_TIME'] ),
'mt_last_post_time' => \IPS\DateTime::create()->setTimestamp( $topicRow['TOPIC_LAST_REPLY_TIME'] ),
'mt_replies' => $topicRow['TOPIC_REPLIES'],
);
$maps = array();
/* Make sure the topic starter is in the map */
$maps[ $topicRow['USER_ID'] ] = array(
'map_user_id' => $topicRow['USER_ID'],
'map_read_time' => \IPS\DateTime::create()->setTimestamp( $topicRow['TOPIC_TIME'] )
);
foreach ( $this->db->select( '*', 'PRIVATE_MESSAGE_USERS', array( 'TOPIC_ID=?', $topicRow['TOPIC_ID'] ) ) as $userRow )
{
$maps[ $userRow['USER_ID'] ] = array(
'map_user_id' => $userRow['USER_ID'],
'map_read_time' => $userRow['MESSAGE_LAST_READ']
);
}
$libraryClass->convertPrivateMessage( $topic, $maps );
$libraryClass->setLastKeyValue( $topicRow['TOPIC_ID'] );
}
}
/**
* Convert private message replies
*
* @return void
*/
public function convertPrivateMessageReplies()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'POST_ID' );
foreach( $this->fetch( 'PRIVATE_MESSAGE_POSTS', 'POST_ID' ) AS $row )
{
$libraryClass->convertPrivateMessageReply( array(
'msg_id' => $row['POST_ID'],
'msg_topic_id' => $row['TOPIC_ID'],
'msg_date' => \IPS\DateTime::create()->setTimestamp( $row['POST_TIME'] ),
'msg_post' => $row['POST_DEFAULT_BODY'],
'msg_author_id' => $row['USER_ID'],
'msg_ip_address' => '127.0.0.1',
) );
$libraryClass->setLastKeyValue( $row['POST_ID'] );
}
}
/**
* Convert profanity filters
*
* @return void
*/
public function convertProfanityFilters()
{
$libraryClass = $this->getLibrary();
foreach ( $this->db->select( '*', 'CENSOR_LIST', static::$profanityFiltersWhere ) as $row )
{
/**
* UBB seems to support regex based profanity filters to some extent. We want to avoid converting those,
* but if there is a filter that ends with with a wildcard match, we can convert it to a non-exact profanity
* filter
*/
$parsedWord = str_replace( '(.*?)', '', $row['CENSOR_WORD'] );
$exact = ( $parsedWord == $row['CENSOR_WORD'] );
$libraryClass->convertProfanityFilter( array(
'wid' => $row['CENSOR_WORD'],
'type' => $parsedWord,
'swop' => $row['CENSOR_REPLACE_WITH'],
'm_exact' => $exact
) );
}
throw new \IPS\convert\Software\Exception;
}
/**
* Check if we can redirect the legacy URLs from this software to the new locations
*
* @return NULL|\IPS\Http\Url
*/
public function checkRedirects()
{
$url = \IPS\Request::i()->url();
/* Make sure it's a UBBThreads URL */
if( mb_strpos( $url->data[ \IPS\Http\Url::COMPONENT_PATH ], 'ubbthreads.php' ) === FALSE )
{
return NULL;
}
if( preg_match( '#/ubbthreads.php/users/([0-9]+)#i', $url->data[ \IPS\Http\Url::COMPONENT_PATH ], $matches ) )
{
try
{
$data = $this->app->getLink( (int) $matches[1], array( 'members', 'core_members' ) );
$item = \IPS\Member::load( $data );
if( $item->canView() )
{
return $item->url();
}
}
catch( \Exception $e )
{
return NULL;
}
}
return NULL;
}
}
@@ -0,0 +1,522 @@
<?php
/**
* @brief Converter Vanilla Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2015 Invision Power Services, Inc.
* @package IPS Social Suite
* @subpackage Converter
* @since 21 Jan 2015
* @version
*/
namespace IPS\convert\Software\Core;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
class _Vanilla extends \IPS\convert\Software
{
/**
* Software Name
*
* @return string
*/
public static function softwareName()
{
/* Child classes must override this method */
return "Vanilla 2";
}
/**
* Software Key
*
* @return string
*/
public static function softwareKey()
{
/* Child classes must override this method */
return "vanilla";
}
/**
* @brief The activity type ID for status updates
*/
protected static $activityStatusType = NULL;
/**
* Constructor
*
* @param \IPS\convert\App The application to reference for database and other information.
* @throws \InvalidArgumentException
*/
public function __construct( \IPS\convert\App $app )
{
$return = parent::__construct( $app );
/* What is the activity type ID for status updates? */
if ( static::$activityStatusType === NULL )
{
try
{
static::$activityStatusType = $this->db->select( 'ActivityTypeID', 'ActivityType',
array( 'Name=?', 'Status' ), NULL, 1
)->first();
}
catch ( \Exception $e ) {}
}
return $return;
}
/**
* Resolve the filesystem location of a file from a path stored in the database
* There are several different ways Vanilla may store these, including as remote URL's
*
* @param $location File location retrieved from the database
* @param $uploadsPath Configured uploads path
* @return \IPS\Http\Url|string|void
*/
public static function parseMediaLocation( $location, $uploadsPath )
{
$uploadsPath = str_replace( '\\', '/', $uploadsPath );
// URL
if ( preg_match( '`^https?://`', $location ) )
{
return \IPS\Http\Url::external( $location );
}
// Full filesystem path
elseif ( mb_strpos( $location, $uploadsPath ) === 0 )
{
return $location;
}
// Deprecated "plugin based" path
elseif ( preg_match( '`^~([^/]*)/(.*)$`', $location, $matches ) )
{
return $uploadsPath.'/'.$matches[2];
}
else
{
$parts = parse_url( $location );
if ( empty( $parts['scheme'] ) )
{
return $uploadsPath.'/'.$location;
}
else
{
if ( !isset( $parts['path'], $parts['host'] ) )
{
return;
}
// This is a url in the format type:://domain/path.
$result = array(
'name' => ltrim( $parts['path'], '/'),
'type' => $parts['scheme'],
'domain' => $parts['host']
);
// @TODO: This is deprecated, and I'm not sure what it was for.
#$format = "{$result['type']}://{$result['domain']}/%s";
#return sprintf( $format, $result['name'] );
}
}
}
/**
* Attempt to convert a MySQL datetime string into a unix timestamp
*
* @param string $date Date(Time) string
* @return int|null Timestamp on successful conversion, otherwise NULL
*/
public static function mysqlToDateTime( $date )
{
return \IPS\DateTime::ts( strtotime( $date ) ?: time() );
}
/**
* Content we can convert from this software.
*
* @return array
*/
public static function canConvert()
{
return array(
'convertGroups' => array(
'table' => 'Role',
'where' => NULL
),
'convertMembers' => array(
'table' => 'User',
'where' => NULL,
),
'convertRemoteAvatars' => array(
'table' => NULL,
'where' => NULL,
),
'convertStatuses' => array(
'table' => 'Activity',
'where' => array( 'ActivityTypeId=?', (int) static::$activityStatusType )
),
'convertPrivateMessages' => array(
'table' => 'Conversation',
'where' => NULL
),
'convertPrivateMessageReplies' => array(
'table' => 'ConversationMessage',
'where' => NULL,
)
);
}
/**
* Can we convert passwords from this software.
*
* @return boolean
*/
public static function loginEnabled()
{
return TRUE;
}
/**
* Returns a block of text, or a language string, that explains what the admin must do to start this conversion
*
* @return string
*/
public static function getPreConversionInformation()
{
return 'convert_vanilla_preconvert';
}
/**
* List of conversion methods that require additional information
*
* @return array
*/
public static function checkConf()
{
return array(
'convertGroups',
'convertMembers'
);
}
/**
* Get More Information
*
* @param string $method Conversion method
* @return array
*/
public function getMoreInfo( $method )
{
switch( $method )
{
case 'convertGroups':
$return['convertGroups'] = array();
$options = array();
$options['none'] = 'None';
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_groups' ), 'IPS\Member\Group' ) AS $group )
{
$options[ $group->g_id ] = $group->name;
}
foreach( $this->db->select( '*', 'Role' ) AS $group )
{
\IPS\Member::loggedIn()->language()->words["map_group_{$group['RoleID']}"] = $group['Name'];
\IPS\Member::loggedIn()->language()->words["map_group_{$group['RoleID']}_desc"] = \IPS\Member::loggedIn()->language()->addToStack( 'map_group_desc' );
$return['convertGroups']["map_group_{$group['RoleID']}"] = array(
'field_class' => 'IPS\\Helpers\\Form\\Select',
'field_default' => NULL,
'field_required' => FALSE,
'field_extra' => array( 'options' => $options ),
'field_hint' => NULL,
);
}
break;
case 'convertMembers':
$return['convertMembers'] = array();
/* Find out where the photos live */
\IPS\Member::loggedIn()->language()->words['attach_location_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'attach_location' );
$return['convertMembers']['attach_location'] = array(
'field_class' => 'IPS\\Helpers\\Form\\Text',
'field_default' => NULL,
'field_required' => TRUE,
'field_extra' => array(),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack('convert_vanilla_photopath'),
);
break;
}
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
}
/**
* Finish - Adds everything it needs to the queues and clears data store
*
* @return string Message to display
*/
public function finish()
{
/* Search Index Rebuild */
\IPS\Content\Search\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' ) );
/* Non-Content Rebuilds */
\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' ) );
/* Content Counts */
\IPS\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' ) );
/* Attachments */
\IPS\Task::queue( 'core', 'RebuildAttachmentThumbnails', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
return array( "f_search_index_rebuild", "f_clear_caches", "f_rebuild_pms", "f_signatures_rebuild", "f_rebuild_attachments" );
}
/**
* Fix post data
*
* @param string raw post data
* @return string parsed post data
*/
public static function fixPostData( $post )
{
return $post;
}
/**
* Convert groups
*
* @return void
*/
public function convertGroups()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'r.RoleID' );
/* Ready Roles */
$roles = $this->fetch( array( 'Role', 'r' ), 'RoleID' );
//$roles->join( array( 'Permission', 'p' ), 'r.RoleID=p.PermissionID' );
/* Run conversions */
foreach ( $roles as $row )
{
$info = array(
'g_id' => $row['RoleID'],
'g_name' => $row['Name'],
);
$merge = ( $this->app->_session['more_info']['convertGroups']["map_group_{$row['RoleID']}"] != 'none' )
? $this->app->_session['more_info']['convertGroups']["map_group_{$row['RoleID']}"]
: NULL;
$libraryClass->convertGroup( $info, $merge );
$libraryClass->setLastKeyValue( $row['RoleID'] );
}
}
/**
* Convert members
*
* @return void
*/
public function convertMembers()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'u.UserID' );
$uploadsPath = $this->app->_session['more_info']['convertMembers']['attach_location'];
$users = $this->fetch( array( 'User', 'u' ), 'u.UserID', array( "u.Deleted<>?", 1 ) );
$users->join( array( 'UserRole', 'ur' ), 'ur.UserID=u.UserID' );
foreach( $users AS $row )
{
/* Work out birthday */
$bdayDay = NULL;
$bdayMonth = NULL;
$bdayYear = NULL;
$dateOfBirth = !empty( $row['DateOfBirth'] ) ? @\IPS\DateTime::ts( strtotime( $row['DateOfBirth'] ) ) : NULL;
if ( $dateOfBirth instanceof \IPS\DateTime )
{
$bdayYear = $dateOfBirth->format( 'Y' );
$bdayMonth = $dateOfBirth->format( 'n' );
$bdayDay = $dateOfBirth->format( 'j' );
}
/* Work out banned stuff */
$tempBan = ( $row['Banned'] == 1 ) ? -1 : 0;
/* Array of basic data */
$info = array(
'member_id' => $row['UserID'],
'email' => $row['Email'],
'name' => $row['Name'],
'password' => $row['Password'],
'member_group_id' => $row['RoleID'] ?: NULL,
'joined' => static::mysqlToDateTime( $row['DateInserted'] ),
'ip_address' => $row['InsertIPAddress'],
'temp_ban' => $tempBan,
'bday_day' => $bdayDay,
'bday_month' => $bdayMonth,
'bday_year' => $bdayYear,
'msg_count_new' => (int) $row['CountUnreadDiscussions'],
'msg_count_total' => (int) $row['CountDiscussions'],
'last_visit' => static::mysqlToDateTime( $row['DateLastActive'] ),
'timezone' => !empty( $row['HourOffset'] )
? (int) $row['HourOffset']
: new \DateTimeZone(
'UTC'
),
'member_posts' => (int) $row['CountComments'],
);
/* Profile Photos */
$filepath = NULL;
$filename = NULL;
if ( !empty( $row['Photo'] ) AND ( $location = static::parseMediaLocation( $row['Photo'], $uploadsPath ) ) )
{
if ( $location instanceof \IPS\Http\Url )
{
/* The library uses file_get_contents() so we can just pop the file name off and pass the URL directly */
$filebits = explode( '/', (string) $location );
$filename = array_pop( $filebits );
$filepath = implode( '/', $filebits );
}
else
{
// Full-sized profile photos start with "p", small profile photos start with "n"
$filename = 'p' . pathinfo( $location, \PATHINFO_BASENAME );
$filepath = pathinfo( $location, \PATHINFO_DIRNAME );
}
}
/* Finally */
$libraryClass->convertMember( $info, NULL, $filename, $filepath );
$libraryClass->setLastKeyValue( $row['UserID'] );
}
}
/**
* Convert statuses
*
* @return void
*/
public function convertStatuses()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'ActivityID' );
$statuses = $this->fetch( 'Activity', 'ActivityID', array( 'ActivityTypeID=?', static::$activityStatusType ) );
/* Run conversions */
foreach ( $statuses as $row )
{
$info = array(
'status_id' => $row['ActivityID'],
'status_member_id' => $row['ActivityUserID'],
'status_date' => \IPS\DateTime::ts( strtotime( $row['DateInserted'] ) ?: time() ),
'status_content' => $row['Story'],
//'status_replies' => $this->countRows( 'ActivityComment', array( 'ActivityID=?', $row['ActivityID'] ) ),
'status_author_id' => $row['ActivityUserID'],
'status_author_ip' => $row['InsertIPAddress'],
);
$libraryClass->convertStatus( $info );
$libraryClass->setLastKeyValue( $row['ActivityID'] );
}
}
/**
* Convert PMs
*
* @return void
*/
public function convertPrivateMessages()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'ConversationID' );
$messages = $this->fetch( 'Conversation', 'ConversationID' );
/* Run conversions */
foreach ( $messages as $row )
{
/* Message topic information */
//$firstMessageId = $row['FirstMessageID'];
$topicInfo = array(
'mt_id' => $row['ConversationID'],
'mt_title' => $row['Subject'] ?: NULL,
'mt_date' => static::mysqlToDateTime( $row['DateInserted'] ),
'mt_starter_id' => $row['InsertUserID'],
'mt_last_post_time' => static::mysqlToDateTime( $row['DateUpdated'] ),
'mt_to_count' => $row['CountParticipants'],
'mt_replies' => $row['CountMessages'],
);
/* Message maps */
$maps = array();
$rows = $this->fetch( 'UserConversation', 'UserID', array( 'ConversationID=?', $row['ConversationID'] ) );
foreach ( $rows as $row )
{
$maps[ $row['UserID'] ] = array(
'map_user_id' => $row['UserID'],
'map_read_time' => static::mysqlToDateTime( $row['DateLastViewed'] ),
//'map_folder_id' => TODO: Create a Bookmarks folder for "Bookmarked" conversations?
'map_user_active' => (int) ( $row['Deleted'] != '0' ),
'map_last_topic_reply' => static::mysqlToDateTime( $row['DateConversationUpdated'] )
);
}
$libraryClass->convertPrivateMessage( $topicInfo, $maps );
$libraryClass->setLastKeyValue( $row['MessageID'] );
}
}
/**
* Convert PM replies
*
* @return void
*/
public function convertPrivateMessageReplies()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'MessageID' );
foreach( $this->fetch( 'ConversationMessage', 'MessageID' ) AS $row )
{
$libraryClass->convertPrivateMessageReply( array(
'msg_id' => $row['MessageID'],
'msg_topic_id' => $row['ConversationID'],
'msg_date' => static::mysqlToDateTime( $row['DateInserted'] ),
'msg_post' => $row['Body'],
'msg_author_id' => $row['InsertUserID'],
'msg_ip_address' => $row['InsertIPAddress']
) );
$libraryClass->setLastKeyValue( $row['MessageID'] );
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,234 @@
<?php
/**
* @brief Converter Wordpress Core Class
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @package IPS Community Suite
* @subpackage Converter
* @since 12 December 2015
*/
namespace IPS\convert\Software\Core;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
class _Wordpress extends \IPS\convert\Software
{
/**
* Software Name
*
* @return string
*/
public static function softwareName()
{
/* Child classes must override this method */
return "WordPress (4.x)";
}
/**
* Software Key
*
* @return string
*/
public static function softwareKey()
{
/* Child classes must override this method */
return "wordpress";
}
/**
* Content we can convert from this software.
*
* @return array
*/
public static function canConvert()
{
return array(
'convertMembers' => array(
'table' => 'users',
'where' => NULL
)
);
}
/**
* Can we convert passwords from this software.
*
* @return boolean
*/
public static function loginEnabled()
{
return TRUE;
}
/**
* Returns a block of text, or a language string, that explains what the admin must do to start this conversion
*
* @return string
*/
public static function getPreConversionInformation()
{
return 'convert_wordpress_preconvert';
}
/**
* List of conversion methods that require additional information
*
* @return array
*/
public static function checkConf()
{
return array(
'convertMembers',
);
}
/**
* Fix post data
*
* @param string raw post data
* @return string parsed post data
*/
public static function fixPostData( $post )
{
return nl2br( $post );
}
/**
* Get More Information
*
* @param string $method Conversion method
* @return array
*/
public function getMoreInfo( $method )
{
$return = array();
switch( $method )
{
case 'convertMembers':
$return['convertMembers']['username'] = array(
'field_class' => 'IPS\\Helpers\\Form\\Radio',
'field_default' => 'display_name',
'field_required' => TRUE,
'field_extra' => array( 'options' => array( 'username' => \IPS\Member::loggedIn()->language()->addToStack( 'user_name' ), 'display_name' => \IPS\Member::loggedIn()->language()->addToStack( 'display_name' ) ) ),
'field_hint' => \IPS\Member::loggedIn()->language()->addToStack( 'username_hint' ),
);
/* Pseudo Fieds */
foreach( array( 'first_name', 'last_name', 'user_url' ) AS $field )
{
\IPS\Member::loggedIn()->language()->words["field_{$field}"] = \IPS\Member::loggedIn()->language()->addToStack( 'pseudo_field', FALSE, array( 'sprintf' => ucwords( str_replace( '_', ' ', $field ) ) ) );
\IPS\Member::loggedIn()->language()->words["field_{$field}_desc"] = \IPS\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' ),
),
'userSuppliedInput' => 'create_field'
),
'field_hint' => NULL
);
}
break;
}
return ( isset( $return[ $method ] ) ) ? $return[ $method ] : array();
}
/**
* Convert members
*
* @return void
*/
public function convertMembers()
{
$libraryClass = $this->getLibrary();
$libraryClass::setKey( 'users.ID' );
foreach( $this->fetch( 'users', 'users.ID', NULL, 'users.*, usermeta.meta_value as user_level' )->join( 'usermeta', "users.ID=usermeta.user_id AND usermeta.meta_key='wp_user_level'" ) AS $user )
{
/* Main Members Table */
$info = array(
'member_id' => $user['ID'],
'ips_group_id' => $user['user_level'] > 9 ? \IPS\Settings::i()->admin_group : \IPS\Settings::i()->member_group,
'name' => $this->app->_session['more_info']['convertMembers']['username'] == 'username' ? $user['user_login'] : $user['display_name'],
'email' => $user['user_email'],
'joined' => new \IPS\DateTime( $user['user_registered'] ),
'conv_password' => $user['user_pass'],
'pp_photo_type' => 'gravatar',
'pp_gravatar' => $user['user_email'], # WordPress always uses gravatar, as it's their service
);
$fields = array();
foreach( array( 'first_name', 'last_name', 'user_url' ) AS $field )
{
if ( $this->app->_session['more_info']['convertMembers']["field_{$field}"] != 'no_convert' )
{
try
{
$fieldId = $this->app->getLink( $field, 'core_pfields_data' );
}
catch( \OutOfRangeException $e )
{
$libraryClass->convertProfileField( array(
'pf_id' => $field,
'pf_name' => $this->app->_session['more_info']['convertMembers']["field_{$field}"],
'pf_desc' => '',
'pf_type' => 'Text',
'pf_content' => '[]',
'pf_member_hide' => 0,
'pf_max_input' => 255,
'pf_member_edit' => 1,
'pf_show_on_reg' => 0,
'pf_admin_only' => 0,
) );
}
if ( isset( $user[$field] ) )
{
$fields[$field] = $user[$field];
}
else
{
$fields[$field] = '';
}
}
}
$libraryClass->convertMember( $info, $fields );
$libraryClass->setLastKeyValue( $user['ID'] );
}
}
/**
* Finish - Adds everything it needs to the queues and clears data store
*
* @return array Messages to display
*/
public function finish()
{
/* Search Index Rebuild */
\IPS\Content\Search\Index::i()->rebuild();
/* Clear Cache and Store */
\IPS\Data\Store::i()->clearAll();
\IPS\Data\Cache::i()->clearAll();
/* Content Counts */
\IPS\Task::queue( 'core', 'RecountMemberContent', array( 'app' => $this->app->app_id ), 4, array( 'app' ) );
return array( "f_search_index_rebuild", "f_clear_caches" );
}
}
File diff suppressed because it is too large. Load diff