Finally I have used the following method:
- upgrade to 1.8
- parallel installation of a new forum 1.8 (fofov2)
- delete category and forum automatically created in this new forum
- merging these two forum (importing the updated one to fofov2)
- change the old admin to super admin and delete super admin of the new install
- tada !
However, I had some problem regarding the attachment merging.
In my forum the attachment names are on the following pattern: "201111/post_9_1321102841_e1277b1817f0bd78db546dc3ce4c0450.attach" and same for the thumbnail. In the mybb merging file for attachment, it is considering a name on this pattern: "201111/post_9_1321102841".attach" so I had some duplicate attachment names. It also did not keep the directory path.
So I manage to change the "merge\boards\mybb\attachments.php" file and the following code seems to give proper result:
<?php
/**
* MyBB 1.8 Merge System
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/download/merge-system/license/
*/
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
class MYBB_Converter_Module_Attachments extends Converter_Module_Attachments {
var $settings = array(
'friendly_name' => 'attachments',
'progress_column' => 'aid',
'default_per_screen' => 20,
);
function pre_setup()
{
global $import_session, $output, $mybb;
// Set uploads path
if(!isset($import_session['uploadspath']))
{
$query = $this->old_db->simple_select("settings", "value", "name = 'bburl'", array('limit' => 1));
$bburl = $this->old_db->fetch_field($query, 'value');
$this->old_db->free_result($query);
$query = $this->old_db->simple_select("settings", "value", "name = 'uploadspath'", array('limit' => 1));
$import_session['uploadspath'] = str_replace('./', $bburl.'/', $this->old_db->fetch_field($query, 'value'));
$this->old_db->free_result($query);
}
$this->check_attachments_dir_perms();
if($mybb->input['uploadspath'])
{
// Test our ability to read attachment files from the forum software
$this->test_readability("attachments", "attachname");
}
}
function import()
{
global $import_session;
$query = $this->old_db->simple_select("attachments", "*", "", array('limit_start' => $this->trackers['start_attachments'], 'limit' => $import_session['attachments_per_screen']));
while($attachment = $this->old_db->fetch_array($query))
{
$this->insert($attachment);
}
}
function convert_data($data)
{
global $db, $import_session, $mybb, $error_notice, $insert_data;
static $field_info;
if(!isset($field_info))
{
// Get columns so we avoid any 'unknown column' errors
$field_info = $db->show_fields_from("attachments");
}
$insert_data = array();
foreach($field_info as $key => $field)
{
if($field['Extra'] == 'auto_increment')
{
if($db->type != "sqlite")
{
unset($insert_data[$field['Field']]);
}
continue;
}
if(isset($data[$field['Field']]))
{
$insert_data[$field['Field']] = $data[$field['Field']];
}
}
// MyBB 1.8 values
$insert_data['import_aid'] = $data['aid'];
$insert_data['pid'] = $this->get_import->pid($data['pid']);
$insert_data['uid'] = $this->get_import->uid($data['uid']);
$arr = explode("/", $data['attachname']);
$first_path = $arr[0];
$second_name = $arr[1];
$attachname_array = explode('_', str_replace('.attach', '', $second_name));
$insert_data['attachname'] = $first_path.'/post_'.$this->get_import->uid($attachname_array[1]).'_'.$attachname_array[2].'_'.$attachname_array[3].'.attach';
if($data['thumbnail'])
{
$ext = get_extension($data['thumbnail']);
$insert_data['thumbnail'] = str_replace(".attach", "_thumb.$ext", $insert_data['attachname']);
}
return $insert_data;
}
function after_insert($data, $insert_data, $aid)
{
global $mybb, $db, $import_session, $lang;
$thumb_not_exists = $error_notice = "";
if($data['thumbnail'])
{
// Check if the thumbnail directory (YYYYMM) exists, if not, create it
$check_dir = explode("/", $insert_data['thumbnail']);
$directory = $check_dir[0];
$full_name = $check_dir[1];
if(!@is_dir($mybb->settings['uploadspath']."/".$directory))
{
@mkdir($mybb->settings['uploadspath']."/".$directory);
}
// Transfer attachment thumbnail
$attachment_thumbnail_file = merge_fetch_remote_file($import_session['uploadspath'].'/'.$insert_data['thumbnail']);
if(!empty($attachment_thumbnail_file))
{
$attachrs = @fopen($mybb->settings['uploadspath'].'/'.$insert_data['thumbnail'], 'w');
if($attachrs)
{
@fwrite($attachrs, $attachment_thumbnail_file);
}
else
{
$this->board->set_error_notice_in_progress($lang->sprintf($lang->module_attachment_thumbnail_error, $aid));
}
@fclose($attachrs);
@my_chmod($mybb->settings['uploadspath'].'/'.$insert_data['thumbnail'], '0777');
}
else
{
$this->board->set_error_notice_in_progress($lang->sprintf($lang->module_attachment_thumbnail_found, $aid));
}
}
// Check if the attachment directory (YYYYMM) exists, if not, create it
$check_dir_at = explode("/", $data['attachname']);
$dir_attachment = $check_dir_at[0];
$full_name_at = $check_dir_at[1];
if(!@is_dir($mybb->settings['uploadspath']."/".$dir_attachment))
{
@mkdir($mybb->settings['uploadspath']."/".$dir_attachment);
}
// Transfer attachment
$attachment_file = merge_fetch_remote_file($import_session['uploadspath'].'/'.$data['attachname']);
if(!empty($attachment_file))
{
$attachrs = @fopen($mybb->settings['uploadspath'].'/'.$insert_data['attachname'], 'w');
if($attachrs)
{
@fwrite($attachrs, $attachment_file);
@fclose($attachrs);
}
else
{
$this->board->set_error_notice_in_progress($lang->sprintf($lang->module_attachment_error, $aid));
}
@my_chmod($mybb->settings['uploadspath'].'/'.$insert_data['attachname'], '0777');
}
else
{
$this->board->set_error_notice_in_progress($lang->sprintf($lang->module_attachment_not_found, $aid));
}
// Restore connection
$query = $db->simple_select("posts", "message", "pid = '{$insert_data['pid']}'");
$message = $db->fetch_field($query, 'message');
$db->free_result($query);
$message = str_replace('[attachment='.$data['aid'].']', '[attachment='.$aid.']', $message);
}
function print_attachments_per_screen_page()
{
global $import_session, $lang;
echo '<tr>
<th colspan="2" class="first last">'.$lang->sprintf($lang->module_attachment_link, $this->plain_bbname).':</th>
</tr>
<tr>
<td><label for="uploadspath"> '.$lang->module_attachment_label.':</label></td>
<td width="50%"><input type="text" name="uploadspath" id="uploadspath" value="'.$import_session['uploadspath'].'" style="width: 95%;" /></td>
</tr>';
}
function fetch_total()
{
global $import_session;
// Get number of attachments
if(!isset($import_session['total_attachments']))
{
$query = $this->old_db->simple_select("attachments", "COUNT(*) as count");
$import_session['total_attachments'] = $this->old_db->fetch_field($query, 'count');
$this->old_db->free_result($query);
}
return $import_session['total_attachments'];
}
}
?>
The official code is the following:
<?php
/**
* MyBB 1.8 Merge System
* Copyright 2014 MyBB Group, All Rights Reserved
*
* Website: http://www.mybb.com
* License: http://www.mybb.com/download/merge-system/license/
*/
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
class MYBB_Converter_Module_Attachments extends Converter_Module_Attachments {
var $settings = array(
'friendly_name' => 'attachments',
'progress_column' => 'aid',
'default_per_screen' => 20,
);
function pre_setup()
{
global $import_session, $output, $mybb;
// Set uploads path
if(!isset($import_session['uploadspath']))
{
$query = $this->old_db->simple_select("settings", "value", "name = 'bburl'", array('limit' => 1));
$bburl = $this->old_db->fetch_field($query, 'value');
$this->old_db->free_result($query);
$query = $this->old_db->simple_select("settings", "value", "name = 'uploadspath'", array('limit' => 1));
$import_session['uploadspath'] = str_replace('./', $bburl.'/', $this->old_db->fetch_field($query, 'value'));
$this->old_db->free_result($query);
}
$this->check_attachments_dir_perms();
if($mybb->input['uploadspath'])
{
// Test our ability to read attachment files from the forum software
$this->test_readability("attachments", "attachname");
}
}
function import()
{
global $import_session;
$query = $this->old_db->simple_select("attachments", "*", "", array('limit_start' => $this->trackers['start_attachments'], 'limit' => $import_session['attachments_per_screen']));
while($attachment = $this->old_db->fetch_array($query))
{
$this->insert($attachment);
}
}
function convert_data($data)
{
global $db, $import_session, $mybb, $error_notice, $insert_data;
static $field_info;
if(!isset($field_info))
{
// Get columns so we avoid any 'unknown column' errors
$field_info = $db->show_fields_from("attachments");
}
$insert_data = array();
foreach($field_info as $key => $field)
{
if($field['Extra'] == 'auto_increment')
{
if($db->type != "sqlite")
{
unset($insert_data[$field['Field']]);
}
continue;
}
if(isset($data[$field['Field']]))
{
$insert_data[$field['Field']] = $data[$field['Field']];
}
}
// MyBB 1.8 values
$insert_data['import_aid'] = $data['aid'];
$insert_data['pid'] = $this->get_import->pid($data['pid']);
$insert_data['uid'] = $this->get_import->uid($data['uid']);
$attachname_array = explode('_', str_replace('.attach', '', $data['attachname']));
$insert_data['attachname'] = 'post_'.$this->get_import->uid($attachname_array[1]).'_'.$attachname_array[2].'.attach';
if($data['thumbnail'])
{
$ext = get_extension($data['thumbnail']);
$insert_data['thumbnail'] = str_replace(".attach", "_thumb.$ext", $insert_data['attachname']);
}
return $insert_data;
}
function after_insert($data, $insert_data, $aid)
{
global $mybb, $db, $import_session, $lang;
$thumb_not_exists = $error_notice = "";
if($data['thumbnail'])
{
// Transfer attachment thumbnail
$attachment_thumbnail_file = merge_fetch_remote_file($import_session['uploadspath'].'/'.$insert_data['thumbnail']);
if(!empty($attachment_thumbnail_file))
{
$attachrs = @fopen($mybb->settings['uploadspath'].'/'.$insert_data['thumbnail'], 'w');
if($attachrs)
{
@fwrite($attachrs, $attachment_thumbnail_file);
}
else
{
$this->board->set_error_notice_in_progress($lang->sprintf($lang->module_attachment_thumbnail_error, $aid));
}
@fclose($attachrs);
@my_chmod($mybb->settings['uploadspath'].'/'.$insert_data['thumbnail'], '0777');
}
else
{
$this->board->set_error_notice_in_progress($lang->sprintf($lang->module_attachment_thumbnail_found, $aid));
}
}
// Transfer attachment
$attachment_file = merge_fetch_remote_file($import_session['uploadspath'].'/'.$data['attachname']);
if(!empty($attachment_file))
{
$attachrs = @fopen($mybb->settings['uploadspath'].'/'.$insert_data['attachname'], 'w');
if($attachrs)
{
@fwrite($attachrs, $attachment_file);
@fclose($attachrs);
}
else
{
$this->board->set_error_notice_in_progress($lang->sprintf($lang->module_attachment_error, $aid));
}
@my_chmod($mybb->settings['uploadspath'].'/'.$insert_data['attachname'], '0777');
}
else
{
$this->board->set_error_notice_in_progress($lang->sprintf($lang->module_attachment_not_found, $aid));
}
// Restore connection
$query = $db->simple_select("posts", "message", "pid = '{$insert_data['pid']}'");
$message = $db->fetch_field($query, 'message');
$db->free_result($query);
$message = str_replace('[attachment='.$data['aid'].']', '[attachment='.$aid.']', $message);
}
function print_attachments_per_screen_page()
{
global $import_session, $lang;
echo '<tr>
<th colspan="2" class="first last">'.$lang->sprintf($lang->module_attachment_link, $this->plain_bbname).':</th>
</tr>
<tr>
<td><label for="uploadspath"> '.$lang->module_attachment_label.':</label></td>
<td width="50%"><input type="text" name="uploadspath" id="uploadspath" value="'.$import_session['uploadspath'].'" style="width: 95%;" /></td>
</tr>';
}
function fetch_total()
{
global $import_session;
// Get number of attachments
if(!isset($import_session['total_attachments']))
{
$query = $this->old_db->simple_select("attachments", "COUNT(*) as count");
$import_session['total_attachments'] = $this->old_db->fetch_field($query, 'count');
$this->old_db->free_result($query);
}
return $import_session['total_attachments'];
}
}
?>
Now I have a fresh forum without any file from old plugins or old modifications~
Edit: Just to mention, avatars images were not imported, a simple copy of the files and it's working fine.