Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -5,19 +5,22 @@
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @package Invision Community
|
||||
* @subpackage Converter
|
||||
* @subpackage convert
|
||||
* @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' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* MyBB Core Converter
|
||||
*/
|
||||
class _Mybb extends \IPS\convert\Software
|
||||
{
|
||||
/**
|
||||
@@ -88,11 +91,11 @@ class _Mybb extends \IPS\convert\Software
|
||||
),
|
||||
'convertPrivateMessages' => array(
|
||||
'table' => 'privatemessages',
|
||||
'where' => NULL
|
||||
'where' => array( 'fromid<>uid' )
|
||||
),
|
||||
'convertPrivateMessageReplies' => array(
|
||||
'table' => 'privatemessages',
|
||||
'where' => NULL,
|
||||
'where' => array( 'fromid<>uid' ),
|
||||
),
|
||||
'convertProfanityFilters' => array(
|
||||
'table' => 'badwords',
|
||||
@@ -293,17 +296,20 @@ class _Mybb extends \IPS\convert\Software
|
||||
/**
|
||||
* Fix post data
|
||||
*
|
||||
* @param string raw post data
|
||||
* @return string parsed post data
|
||||
* @param string $post Raw post data
|
||||
* @return string Parsed post data
|
||||
*/
|
||||
public static function fixPostData( $post )
|
||||
{
|
||||
/* Replace align tags with left/right/center/justify */
|
||||
$post = preg_replace( '/\[align=(justify|left|right)\](.+?)\[\/align\]/i', '[$1]$2[/$1]', $post );
|
||||
$post = preg_replace( '/\[align=(justify|left|center|right)\](.+?)\[\/align\]/i', '[$1]$2[/$1]', $post );
|
||||
|
||||
/* remove justify, since we don't support it */
|
||||
$post = str_replace( array( '[justify]', '[/justify]' ), '', $post );
|
||||
|
||||
/* Quotes */
|
||||
$post = preg_replace("#\[quote=('|\")(.+?)('|\") pid='(\d+)' dateline='(\d+)'\]#i", "[quote name=\"$2\" timestamp=\"$5\"]", $post);
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
@@ -544,12 +550,12 @@ class _Mybb extends \IPS\convert\Software
|
||||
'pf_desc' => $row['description'],
|
||||
'pf_content' => $options,
|
||||
'pf_not_null' => $row['required'],
|
||||
'pf_member_hide' => $row['profile'],
|
||||
'pf_member_hide' => $row['profile'] ? 'all' : 'hide',
|
||||
'pf_max_input' => $row['maxlength'],
|
||||
'pf_position' => $row['disporder'],
|
||||
'pf_show_on_reg' => $row['registration'],
|
||||
'pf_input_format' => '/' . $row['regex'] . '/i',
|
||||
'pf_admin_only' => ( $row['editableby'] == -1 ) ? 0 : 1, # MyBB allows you to define which groups can edit, so if this value is anything other than -1, assume it's admin only
|
||||
'pf_member_edit' => ( $row['editableby'] == -1 ) ? 1 : 0, # MyBB allows you to define which groups can edit, so if this value is anything other than -1, assume it's admin only
|
||||
'pf_multiple' => ( $theirType == 'multiselect' ) ? 1 : 0
|
||||
);
|
||||
|
||||
@@ -564,7 +570,7 @@ class _Mybb extends \IPS\convert\Software
|
||||
/**
|
||||
* Maps a MyBB Profile Field type to IPS
|
||||
*
|
||||
* @param string MyBB Type
|
||||
* @param string $type MyBB Type
|
||||
* @return string IPS Type
|
||||
*/
|
||||
protected function _fieldMap( $type )
|
||||
@@ -621,7 +627,7 @@ class _Mybb extends \IPS\convert\Software
|
||||
switch( $promotion['requirements'] )
|
||||
{
|
||||
case 'postcount':
|
||||
if ( !in_array( $promotion['posttype'], array( '>', '>=', '=' ) ) )
|
||||
if ( !\in_array( $promotion['posttype'], array( '>', '>=', '=' ) ) )
|
||||
{
|
||||
/* Bubble up */
|
||||
throw new \UnderflowException;
|
||||
@@ -631,7 +637,7 @@ class _Mybb extends \IPS\convert\Software
|
||||
break;
|
||||
|
||||
case 'timeregistered':
|
||||
if ( !in_array( $promotion['registeredtype'], array( '>', '>=', '=' ) ) )
|
||||
if ( !\in_array( $promotion['registeredtype'], array( '>', '>=', '=' ) ) )
|
||||
{
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
@@ -685,7 +691,7 @@ class _Mybb extends \IPS\convert\Software
|
||||
}
|
||||
|
||||
/* Now check for group promotions */
|
||||
if( count( $libraryClass->groupPromotions ) )
|
||||
if( \count( $libraryClass->groupPromotions ) )
|
||||
{
|
||||
foreach( $libraryClass->groupPromotions as $groupPromotion )
|
||||
{
|
||||
@@ -794,7 +800,7 @@ class _Mybb extends \IPS\convert\Software
|
||||
|
||||
$info = array(
|
||||
'member_id' => $row['uid'],
|
||||
'name' => $row['username'],
|
||||
'name' => html_entity_decode( $row['username'], \ENT_QUOTES | \ENT_HTML5, 'UTF-8' ),
|
||||
'email' => $row['email'],
|
||||
'password' => $row['password'],
|
||||
'password_extra' => $row['salt'],
|
||||
@@ -806,7 +812,7 @@ class _Mybb extends \IPS\convert\Software
|
||||
'restrict_post' => $restrict_post,
|
||||
'bday_day' => str_pad( $bday_day, 2, '0', STR_PAD_LEFT ),
|
||||
'bday_month' => str_pad( $bday_month, 2, '0', STR_PAD_LEFT ),
|
||||
'bday_year' => $bday_year ? intval( $bday_year ) : NULL,
|
||||
'bday_year' => $bday_year ? \intval( $bday_year ) : NULL,
|
||||
'msg_count_new' => $row['unreadpms'],
|
||||
'msg_count_total' => $row['totalpms'],
|
||||
'msg_show_notification' => $row['pmnotify'],
|
||||
@@ -833,11 +839,20 @@ class _Mybb extends \IPS\convert\Software
|
||||
);
|
||||
|
||||
$pfields = array();
|
||||
foreach( $this->db->select( '*', 'userfields', array( "ufid=?", $row['uid'] ) ) AS $key => $field )
|
||||
try
|
||||
{
|
||||
$key = str_replace( 'fid', '', $key );
|
||||
$pfields[ $key ] = $field;
|
||||
foreach ( $this->db->select( '*', 'userfields', array( "ufid=?", $row['uid'] ) )->first() AS $key => $field )
|
||||
{
|
||||
if ( $key == 'ufid' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = str_replace( 'fid', '', $key );
|
||||
$pfields[ $key ] = $field;
|
||||
}
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
|
||||
foreach( array( 'website', 'icq', 'aim', 'yahoo', 'skype', 'google' ) AS $pseudo )
|
||||
{
|
||||
@@ -875,21 +890,14 @@ class _Mybb extends \IPS\convert\Software
|
||||
/* Photo */
|
||||
$filename = NULL;
|
||||
$filepath = NULL;
|
||||
switch( $row['avatartype'] )
|
||||
if( $row['avatartype'] == 'upload' )
|
||||
{
|
||||
case 'gravatar':
|
||||
$info['pp_gravatar'] = $row['email'];
|
||||
$info['pp_photo_type'] = 'gravatar';
|
||||
break;
|
||||
|
||||
case 'upload':
|
||||
$info['pp_photo_type'] = 'custom';
|
||||
|
||||
$avatar = trim( '.', $row['avatar'] );
|
||||
$filepath = explode( '/', $avatar );
|
||||
$filename = array_pop( $filepath );
|
||||
$filepath = rtrim( $this->app->_session['more_info']['convertMembers']['photo_location'], '/' ) . implode( '/', $filepath );
|
||||
break;
|
||||
$info['pp_photo_type'] = 'custom';
|
||||
|
||||
$avatar = trim( $row['avatar'], '.' );
|
||||
$filepath = explode( '/', $avatar );
|
||||
$filename = parse_url( array_pop( $filepath ), PHP_URL_PATH );
|
||||
$filepath = rtrim( $this->app->_session['more_info']['convertMembers']['photo_location'], '/' ) . implode( '/', $filepath );
|
||||
}
|
||||
|
||||
$libraryClass->convertMember( $info, $pfields, $filename, $filepath );
|
||||
@@ -899,7 +907,7 @@ class _Mybb extends \IPS\convert\Software
|
||||
{
|
||||
$libraryClass->convertFollow( array(
|
||||
'follow_app' => 'core',
|
||||
'follow_area' => 'members',
|
||||
'follow_area' => 'member',
|
||||
'follow_rel_id' => $buddy,
|
||||
'follow_rel_id_type' => 'core_members',
|
||||
'follow_member_id' => $row['uid'],
|
||||
@@ -981,24 +989,29 @@ class _Mybb extends \IPS\convert\Software
|
||||
|
||||
$libraryClass::setKey( 'pmid' );
|
||||
|
||||
foreach( $this->fetch( 'privatemessages', 'pmid' ) AS $row )
|
||||
foreach( $this->fetch( 'privatemessages', 'pmid', array( 'fromid<>uid' ) ) AS $row )
|
||||
{
|
||||
/* My hands are kind of tied here... every individual message is stored separately, rather than grouped into conversations. In this instance, we'll bring over each individual message as it's own topic for archival purposes. */
|
||||
$recipients = \unserialize( $row['recipients'] );
|
||||
/* In MyBB, replies to messages are stored as full conversations, and there is a row for both the sender and the recipient. We'll bring over every reply for archival purposes, but if the fromid == uid, skip because otherwise we end up with duplicates. */
|
||||
|
||||
$topic = array(
|
||||
'mt_id' => $row['pmid'],
|
||||
'mt_date' => $row['dateline'],
|
||||
'mt_title' => $row['subject'],
|
||||
'mt_starter_id' => $row['uid'],
|
||||
'mt_starter_id' => $row['fromid'],
|
||||
'mt_start_time' => $row['dateline'],
|
||||
'mt_last_post_time' => $row['dateline'],
|
||||
'mt_to_count' => 1,
|
||||
);
|
||||
|
||||
$maps = array();
|
||||
$maps[$row['uid']] = array(
|
||||
'map_user_id' => $row['uid'],
|
||||
$maps[$row['fromid']] = array(
|
||||
'map_user_id' => $row['fromid'],
|
||||
'map_read_time' => $row['readtime'],
|
||||
'map_is_starter' => true
|
||||
);
|
||||
|
||||
$maps[$row['toid']] = array(
|
||||
'map_user_id' => $row['toid'],
|
||||
'map_read_time' => $row['readtime'],
|
||||
);
|
||||
|
||||
@@ -1019,14 +1032,14 @@ class _Mybb extends \IPS\convert\Software
|
||||
|
||||
$libraryClass::setKey( 'pmid' );
|
||||
|
||||
foreach( $this->fetch( 'privatemessages', 'pmid' ) AS $row )
|
||||
foreach( $this->fetch( 'privatemessages', 'pmid', array( 'fromid<>uid' ) ) AS $row )
|
||||
{
|
||||
$libraryClass->convertPrivateMessageReply( array(
|
||||
'msg_id' => $row['pmid'],
|
||||
'msg_topic_id' => $row['pmid'],
|
||||
'msg_date' => $row['dateline'],
|
||||
'msg_post' => $row['message'],
|
||||
'msg_author_id' => $row['uid'],
|
||||
'msg_author_id' => $row['fromid'],
|
||||
'msg_ip_address' => $row['ipaddress'],
|
||||
) );
|
||||
|
||||
|
||||
Reference in new issue
Block a user