-
Notifications
You must be signed in to change notification settings - Fork 2
/
mybb16_to_wedge.xml
362 lines (345 loc) · 11.6 KB
/
mybb16_to_wedge.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<?xml version="1.0"?>
<importer xmlns="http://wedge.org/xml/importer" xmlns:smf="http://wedge.org/">
<general>
<name>MyBB 1.6</name>
<version>Wedge 0.1</version>
<settings>/inc/config.php</settings>
<from_prefix>`{$config['database']['database']}`.{$config['database']['table_prefix']}</from_prefix>
<table_test>{$from_prefix}users</table_test>
<ip_to_ipv6>member_ip, member_ip2</ip_to_ipv6>
<ip_to_pointer>poster_ip</ip_to_pointer>
</general>
<step type="mandatory">
<title>Importing Members</title>
<detect>{$from_prefix}users</detect>
<destination>{$to_prefix}members</destination>
<presql>
TRUNCATE {$to_prefix}members;
ALTER TABLE {$to_prefix}members
CHANGE COLUMN password_salt password_salt varchar(16) NOT NULL default '';
</presql>
<preparsecode>
if (!preg_match('/\d{4}-\d{2}-\d{2}/', $row['birthdate']))
$row['birthdate'] = '0001-01-01';
// data field is used temporary to dertermine the type of avatar
if ($row['data'] != 'remote')
$row['avatar'] = '';
$row['data'] = '';
</preparsecode>
<query>
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, avatartype AS data
FROM {$from_prefix}users;
</query>
</step>
<step>
<title>Importing Categories</title>
<detect>{$from_prefix}forums</detect>
<destination>{$to_prefix}categories</destination>
<presql>TRUNCATE {$to_prefix}categories;</presql>
<query>
SELECT fid AS id_cat, SUBSTRING(name, 1, 255) AS name, disporder AS cat_order
FROM {$from_prefix}forums
WHERE type = 'c';
</query>
</step>
<step>
<title>Importing Boards</title>
<detect>{$from_prefix}forums</detect>
<destination>{$to_prefix}boards</destination>
<presql>
TRUNCATE {$to_prefix}boards;
DELETE FROM {$to_prefix}board_permissions WHERE id_profile > 4;
</presql>
<preparsecode>
$row['url'] = substr($this->boardurl, strpos($this->boardurl, '://') + 3) . '/board' . $row['url'];
$row['urllen'] = strlen($row['url']);
if (!empty($row['member_groups']))
{
$permissions = explode(',', $row['member_groups']);
foreach ($permissions as $allowed)
$db->query("
REPLACE INTO {$to_prefix}board_groups
(id_group, id_board, view_perm, enter_perm)
VALUES ('$allowed', $row[id_board], 'allow', 'allow')
");
}
</preparsecode>
<query>
SELECT
fid AS id_board, SUBSTRING(name, 1, 255) AS name, fid AS url,
SUBSTRING(description, 1, 65534) AS description, disporder AS board_order,
posts AS num_posts, threads AS num_topics, pid AS id_cat,
usepostcounts AS count_posts, '-1,0' AS member_groups
FROM {$from_prefix}forums
WHERE type = 'f';
</query>
</step>
<step>
<title>Importing Topics</title>
<detect>{$from_prefix}threads</detect>
<destination>{$to_prefix}topics</destination>
<presql>
TRUNCATE {$to_prefix}topics;
TRUNCATE {$to_prefix}log_topics;
TRUNCATE {$to_prefix}log_mark_read;
</presql>
<query>
SELECT
t.tid AS id_topic, t.fid AS id_board, t.sticky AS is_pinned,
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;
</query>
</step>
<step>
<title>Importing Messages</title>
<detect> {$from_prefix}posts</detect>
<destination>{$to_prefix}messages</destination>
<presql>TRUNCATE {$to_prefix}messages;</presql>
<options>
<slashes>true</slashes>
<limit>100</limit>
</options>
<query>
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;
</query>
</step>
<step>
<title>Importing polls</title>
<detect>{$from_prefix}polls</detect>
<destination>{$to_prefix}polls</destination>
<presql>
TRUNCATE {$to_prefix}polls;
TRUNCATE {$to_prefix}poll_choices;
TRUNCATE {$to_prefix}log_polls;
</presql>
<query>
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);
</query>
</step>
<step>
<title>Importing poll choices</title>
<detect>{$from_prefix}polls</detect>
<destination>{$to_prefix}poll_choices</destination>
<options>
<no_add>true</no_add>
</options>
<preparsecode><![CDATA[
$keys = array('id_poll', 'id_choice', 'label', 'votes');
$options = explode('||~|~||', $row['opt']);
$votes = explode('||~|~||', $row['votes']);
$id_poll = $row['id_poll'];
for ($i = 0, $n = count($options); $i < $n; $i++)
{
$rows[] = implode(', ', array(
'id_poll' => $id_poll,
'id_choice' => ($i + 1),
'label' => '"'. addslashes($options[$i]). '"',
'votes' => @$votes[$i],
));
}
]]></preparsecode>
<query>
SELECT pid AS id_poll, options AS opt, votes
FROM {$from_prefix}polls;
</query>
</step>
<step>
<title>Importing poll votes</title>
<detect>{$from_prefix}pollvotes</detect>
<destination>{$to_prefix}log_polls</destination>
<query>
SELECT pid AS id_poll, uid AS id_member, voteoption AS id_choice
FROM {$from_prefix}pollvotes;
</query>
</step>
<step>
<title>Importing personal messages</title>
<detect>{$from_prefix}privatemessages</detect>
<destination>{$to_prefix}personal_messages</destination>
<presql>
TRUNCATE {$to_prefix}personal_messages;
TRUNCATE {$to_prefix}pm_recipients;
</presql>
<preparsecode>
if(empty($row['from_name']))
$row['from_name'] = 'Guest';
</preparsecode>
<query>
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;
</query>
</step>
<step>
<title>Importing pm recipients</title>
<detect>{$from_prefix}privatemessages</detect>
<destination>{$to_prefix}pm_recipients</destination>
<query>
SELECT pmid AS id_pm, toid AS id_member, readtime != 0 AS is_read, '-1' AS labels
FROM {$from_prefix}privatemessages
WHERE folder != 2;
</query>
</step>
<step>
<title>Importing topic notifications</title>
<detect>{$from_prefix}threadsubscriptions</detect>
<destination>{$to_prefix}log_notify</destination>
<options>
<ignore>true</ignore>
</options>
<presql>
TRUNCATE {$to_prefix}log_notify;
</presql>
<query>
SELECT uid AS id_member, tid AS id_topic
FROM {$from_prefix}threadsubscriptions;
</query>
</step>
<step>
<title>Importing board notifications</title>
<detect>{$from_prefix}forumsubscriptions</detect>
<destination>{$to_prefix}log_notify</destination>
<options>
<ignore>true</ignore>
</options>
<query>
SELECT uid AS id_member, fid AS id_board
FROM {$from_prefix}forumsubscriptions;
</query>
</step>
<step>
<title>Importing attachments</title>
<detect>{$from_prefix}attachments</detect>
<destination>{$to_prefix}attachments</destination>
<options>
<no_add>true</no_add>
</options>
<preparsecode>
$keys = array('id_attach', 'size', 'filename', 'file_hash', 'id_msg', 'downloads', 'width', 'height');
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 = helper::createAttachmentFileHash($row['filename']);
$destination = $attachmentUploadDir . '/' . $id_attach . '_' . $file_hash . '.ext';
$width = 0;
$height = 0;
helper::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++;
</preparsecode>
<query>
SELECT pid AS id_msg, downloads, filename, filesize, attachname
FROM {$from_prefix}attachments;
</query>
</step>
<step>
<title>Importing avatars</title>
<detect>{$from_prefix}users</detect>
<destination>{$to_prefix}attachments</destination>
<options>
<no_add>true</no_add>
</options>
<preparsecode>
$keys = array('id_attach', 'size', 'filename', 'file_hash', 'id_member');
//create some useful shortcuts
$source = $_POST['path_from'] . strtok(ltrim($row['filename'], '.'), '?');
$filename = preg_replace('~avatar_(.+?)\?~is', 'avatar_$1', $row['filename']);
$file_hash = helper::createAttachmentFileHash($filename);
$destination = $attachmentUploadDir . '/' . $id_attach . '_' . $file_hash . '.ext';
helper::copy_file($source, $destination);
$rows[] = implode(', ', array(
'id_attach' => $id_attach,
'size' => filesize($destination),
'filename' => '\'' . $row['filename'] . '\'',
'file_hash' => '\'' . $file_hash . '\'',
'id_member' => $row['id_member'],
));
$id_attach++;
</preparsecode>
<query>
SELECT uid AS id_member, avatar AS filename
FROM {$from_prefix}users
WHERE avatartype = 'upload'
OR avatartype = 'gallery';
</query>
</step>
</importer>