MyBB 1.8
ElkArte 1.0
/inc/config.php
`{$config['database']['database']}`.{$config['database']['table_prefix']}
{$from_prefix}users
Importing Members
{$from_prefix}users
{$to_prefix}members
TRUNCATE {$to_prefix}members;
ALTER TABLE {$to_prefix}members
CHANGE COLUMN password_salt password_salt varchar(16) NOT NULL default '';
if (!preg_match('/\d{4}-\d{2}-\d{2}/', $row['birthdate']))
$row['birthdate'] = '0001-01-01';
if (strpos($row['avatar'],'http') == false)
$row['avatar'] = '';
SELECT
uid AS id_member, SUBSTRING(username, 1, 255) AS member_name,
SUBSTRING(username, 1, 255) AS real_name, email AS email_address,
SUBSTRING(password, 1, 64) AS passwd, SUBSTRING(salt, 1, 8) AS password_salt,
postnum AS posts, SUBSTRING(usertitle, 1, 255) AS usertitle,
lastvisit AS last_login, IF(usergroup = 4, 1, 0) AS id_group,
regdate AS date_registered, SUBSTRING(website, 1, 255) AS website_url,
SUBSTRING(website, 1, 255) AS website_title, '' AS message_labels,
SUBSTRING(signature, 1, 65534) AS signature, hideemail AS hide_email,
SUBSTRING(buddylist, 1, 255) AS buddy_list, '' AS ignore_boards,
SUBSTRING(regip, 1, 255) AS member_ip, SUBSTRING(regip, 1, 255) AS member_ip2,
SUBSTRING(ignorelist, 1, 255) AS pm_ignore_list, avatar,
timeonline AS total_time_logged_in, birthday AS birthdate
FROM {$from_prefix}users;
Importing Categories
{$from_prefix}forums
{$to_prefix}categories
TRUNCATE {$to_prefix}categories;
SELECT fid AS id_cat, SUBSTRING(name, 1, 255) AS name, disporder AS cat_order
FROM {$from_prefix}forums
WHERE type = 'c';
Importing Boards
{$from_prefix}forums
{$to_prefix}boards
TRUNCATE {$to_prefix}boards;
DELETE FROM {$to_prefix}board_permissions WHERE id_profile > 4;
query("
SELECT id_cat
FROM {$to_prefix}categories");
while ($cats = $db->fetch_assoc($request))
{
if (!in_array($row['id_cat'], $cats))
$row['id_parent'] = $row['id_cat'];
}
]]>
SELECT
fid AS id_board, SUBSTRING(name, 1, 255) AS name,
SUBSTRING(description, 1, 65534) AS description, disporder AS board_order,
posts AS num_posts, threads AS num_topics, pid AS id_cat,
usepostcounts != 'yes' AS count_posts, '-1,0' AS member_groups
FROM {$from_prefix}forums
WHERE type = 'f';
Importing Topics
{$from_prefix}threads
{$to_prefix}topics
TRUNCATE {$to_prefix}topics;
TRUNCATE {$to_prefix}log_topics;
TRUNCATE {$to_prefix}log_boards;
TRUNCATE {$to_prefix}log_mark_read;
SELECT
t.tid AS id_topic, t.fid AS id_board, t.sticky AS is_sticky,
t.poll AS id_poll, t.views AS num_views, IFNULL(t.uid, 0) AS id_member_started,
IFNULL(ul.uid, 0) AS id_member_updated, t.replies AS num_replies,
CASE
WHEN (t.closed = '1') THEN 1
ELSE 0
END AS locked,
MIN(p.pid) AS id_first_msg, MAX(p.pid) AS id_last_msg
FROM {$from_prefix}threads AS t
INNER JOIN {$from_prefix}posts AS p
LEFT JOIN {$from_prefix}users AS ul ON (BINARY ul.username = t.lastposter)
WHERE p.tid = t.tid
GROUP BY t.tid
HAVING id_first_msg != 0
AND id_last_msg != 0;
Importing Messages
{$from_prefix}posts
{$to_prefix}messages
TRUNCATE {$to_prefix}messages;
true
100
SELECT
p.pid AS id_msg, p.tid AS id_topic, t.fid AS id_board, p.uid AS id_member,
SUBSTRING(p.username, 1, 255) AS poster_name, p.dateline AS poster_time,
SUBSTRING(p.ipaddress, 1, 255) AS poster_ip,
SUBSTRING(IF(p.subject = '', t.subject, p.subject), 1, 255) AS subject,
SUBSTRING(IF(p.uid > 0, u.email, ''), 1, 255) AS poster_email,
p.smilieoff = 'no' AS smileys_enabled,
SUBSTRING(IF(p.edituid > 0, edit_u.username, 0), 1, 255) AS modified_name,
p.edittime AS modified_time, SUBSTRING(p.message, 1, 65534) AS body, 'xx' AS icon
FROM {$from_prefix}posts AS p
INNER JOIN {$from_prefix}threads AS t
LEFT JOIN {$from_prefix}users AS u ON (u.uid = p.uid)
LEFT JOIN {$from_prefix}users AS edit_u ON (edit_u.uid = p.edituid)
WHERE t.tid = p.tid;
Importing polls
{$from_prefix}polls
{$to_prefix}polls
TRUNCATE {$to_prefix}polls;
TRUNCATE {$to_prefix}poll_choices;
TRUNCATE {$to_prefix}log_polls;
SELECT
p.pid AS id_poll, SUBSTRING(p.question, 1, 255) AS question, p.closed AS voting_locked,
t.uid AS id_member, IF(p.timeout = 0, 0, p.dateline + p.timeout * 86400) AS expire_time,
SUBSTRING(t.username, 1, 255) AS poster_name
FROM {$from_prefix}polls AS p
LEFT JOIN {$from_prefix}threads AS t ON (t.tid = p.tid);
Importing poll choices
{$from_prefix}polls
{$to_prefix}poll_choices
true
$id_poll,
'id_choice' => ($i + 1),
'label' => '"'. addslashes($options[$i]). '"',
'votes' => @$votes[$i],
));
}
$no_add = true;
]]>
SELECT pid AS id_poll, options AS opt, votes
FROM {$from_prefix}polls;
Importing poll votes
{$from_prefix}pollvotes
{$to_prefix}log_polls
SELECT pid AS id_poll, uid AS id_member, voteoption AS id_choice
FROM {$from_prefix}pollvotes;
Importing personal messages
{$from_prefix}privatemessages
{$to_prefix}personal_messages
TRUNCATE {$to_prefix}personal_messages;
TRUNCATE {$to_prefix}pm_recipients;
if(empty($row['from_name']))
$row['from_name'] = 'Guest';
SELECT
pm.pmid AS id_pm, pm.fromid AS id_member_from, pm.dateline AS msgtime,
SUBSTRING(uf.username, 1, 255) AS from_name, SUBSTRING(pm.subject, 1, 255) AS subject,
SUBSTRING(pm.message, 1, 65534) AS body
FROM {$from_prefix}privatemessages AS pm
LEFT JOIN {$from_prefix}users AS uf ON (uf.uid = pm.fromid)
WHERE pm.folder != 2;
Importing pm recipients
{$from_prefix}privatemessages
{$to_prefix}pm_recipients
SELECT pmid AS id_pm, toid AS id_member, readtime != 0 AS is_read, '-1' AS labels
FROM {$from_prefix}privatemessages
WHERE folder != 2;
Importing topic notifications
{$from_prefix}threadsubscriptions
{$to_prefix}log_notify
true
TRUNCATE {$to_prefix}log_notify;
SELECT uid AS id_member, tid AS id_topic
FROM {$from_prefix}threadsubscriptions;
Importing board notifications
{$from_prefix}forumsubscriptions
{$to_prefix}log_notify
true
SELECT uid AS id_member, fid AS id_board
FROM {$from_prefix}forumsubscriptions;
Importing attachments
{$from_prefix}attachments
{$to_prefix}attachments
true
TRUNCATE {$to_prefix}attachments;
$keys = array('id_attach', 'size', 'filename', 'file_hash', 'id_msg', 'downloads', 'width', 'height');
$no_add = true;
if (!isset($mybb_attachment_dir))
{
$result = $db->query("
SELECT value
FROM {$from_prefix}settings
WHERE name = 'uploadspath'
LIMIT 1");
list ($mybb_attachment_dir) = $db->fetch_row($result);
$db->free_result($result);
$mybb_attachment_dir = $_POST['path_from'] . ltrim($mybb_attachment_dir, '.');
}
//create some useful shortcuts, we start with images..
$ext = strtolower(substr(strrchr($row['filename'], '.'), 1));
if (!in_array($ext, array('jpg', 'jpeg', 'gif', 'png')))
$ext = '';
$source = $mybb_attachment_dir . '/' . $row['attachname'];
$file_hash = createAttachmentFileHash($row['filename']);
$destination = $attachmentUploadDir . '/' . $id_attach . '_' . $file_hash . '.elk';
$width = 0;
$height = 0;
copy_file($source, $destination);
// Is image? we need a thumbnail
if (!empty($ext))
{
list ($width, $height) = getimagesize($destination);
if(empty($width))
{
$width = 0;
$height = 0;
}
}
//prepare our insert
$rows[] = implode(', ', array(
'id_attach' => $id_attach,
'size' => filesize($destination),
'filename' => '\'' . $row['filename'] . '\'',
'file_hash' => '\'' . $file_hash . '\'',
'id_msg' => $row['id_msg'],
'downloads' => $row['downloads'],
'width' => $width,
'height' => $height,
));
$id_attach++;
SELECT pid AS id_msg, downloads, filename, filesize, attachname
FROM {$from_prefix}attachments;
Importing avatars
{$from_prefix}users
{$to_prefix}attachments
true
$keys = array('id_attach', 'size', 'filename', 'file_hash', 'id_member');
$no_add = true;
//create some useful shortcuts
$source = $_POST['path_from'] . strtok(ltrim($row['filename'], '.'), '?');
$filename = preg_replace('~avatar_(.+?)\?dateline=\d*~is', 'avatar_$1', $row['filename']);
$file = strrchr($filename, "/");
$file_hash = createAttachmentFileHash($filename);
$destination = $attachmentUploadDir . '/' . $id_attach . '_' . $file_hash . '.elk';
copy_file($source, $destination);
$rows[] = implode(', ', array(
'id_attach' => $id_attach,
'size' => file_exists($destination) ? filesize($destination) : '',
'filename' => '\'' . $file . '\'',
'file_hash' => '\'' . $file_hash . '\'',
'id_member' => $row['id_member'],
));
$id_attach++;
SELECT uid AS id_member, avatar AS filename
FROM {$from_prefix}users
WHERE avatartype = 'upload'
OR avatartype = 'gallery';