PluginProbe
bbPress / trunk
bbPress vtrunk
trunk 2.0 2.0-beta-1 2.0-beta-2b 2.0-beta-3 2.0-beta-3b 2.0-rc-2 2.0-rc-3 2.0-rc-4 2.0-rc-5 2.0.1 2.0.2 2.0.3 2.1 2.1-beta-1 2.1-rc1 2.1-rc2 2.1-rc3 2.1-rc4 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.2.2 All 71 releases
bbpress / includes / admin / converters / phpBB.php

phpBB.php in bbPress trunk, at includes/admin/converters/phpBB.php

1,039 lines 30.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * bbPress phpBB 3.x Converter
5 *
6 * @package bbPress
7 * @subpackage Converters
8 */
9
10 /**
11 * Implementation of phpBB v3 Converter.
12 *
13 * @since 2.3.0 bbPress (r4689)
14 *
15 * @link Codex Docs https://codex.bbpress.org/import-forums/phpbb
16 */
17 class phpBB extends BBP_Converter_Base {
18
19 /**
20 * Sets up the field mappings
21 */
22 public function setup_globals() {
23
24 // Setup smiley URL & path
25 $this->bbcode_parser_properties = array(
26 'smiley_url' => false,
27 'smiley_dir' => false
28 );
29
30 /** Forum Section *****************************************************/
31
32 // Old forum id (Stored in postmeta)
33 $this->field_map[] = array(
34 'from_tablename' => 'forums',
35 'from_fieldname' => 'forum_id',
36 'to_type' => 'forum',
37 'to_fieldname' => '_bbp_old_forum_id'
38 );
39
40 // Forum parent id (If no parent, then 0, Stored in postmeta)
41 $this->field_map[] = array(
42 'from_tablename' => 'forums',
43 'from_fieldname' => 'parent_id',
44 'to_type' => 'forum',
45 'to_fieldname' => '_bbp_old_forum_parent_id'
46 );
47
48 // Forum topic count (Stored in postmeta)
49 $this->field_map[] = array(
50 'from_tablename' => 'forums',
51 'from_fieldname' => 'forum_topics_approved',
52 'to_type' => 'forum',
53 'to_fieldname' => '_bbp_topic_count'
54 );
55
56 // Forum reply count (Stored in postmeta)
57 $this->field_map[] = array(
58 'from_tablename' => 'forums',
59 'from_fieldname' => 'forum_posts_approved',
60 'to_type' => 'forum',
61 'to_fieldname' => '_bbp_reply_count'
62 );
63
64 // Forum total topic count (Includes unpublished topics, Stored in postmeta)
65 $this->field_map[] = array(
66 'from_tablename' => 'forums',
67 'from_fieldname' => 'forum_topics_approved',
68 'to_type' => 'forum',
69 'to_fieldname' => '_bbp_total_topic_count'
70 );
71
72 // Forum total reply count (Includes unpublished replies, Stored in postmeta)
73 $this->field_map[] = array(
74 'from_tablename' => 'forums',
75 'from_fieldname' => 'forum_posts_approved',
76 'to_type' => 'forum',
77 'to_fieldname' => '_bbp_total_reply_count'
78 );
79
80 // Forum title.
81 $this->field_map[] = array(
82 'from_tablename' => 'forums',
83 'from_fieldname' => 'forum_name',
84 'to_type' => 'forum',
85 'to_fieldname' => 'post_title'
86 );
87
88 // Forum slug (Clean name to avoid conflicts)
89 $this->field_map[] = array(
90 'from_tablename' => 'forums',
91 'from_fieldname' => 'forum_name',
92 'to_type' => 'forum',
93 'to_fieldname' => 'post_name',
94 'callback_method' => 'callback_slug'
95 );
96
97 // Forum description.
98 $this->field_map[] = array(
99 'from_tablename' => 'forums',
100 'from_fieldname' => 'forum_desc',
101 'to_type' => 'forum',
102 'to_fieldname' => 'post_content',
103 'callback_method' => 'callback_null'
104 );
105
106 // Forum display order (Starts from 1)
107 $this->field_map[] = array(
108 'from_tablename' => 'forums',
109 'from_fieldname' => 'left_id',
110 'to_type' => 'forum',
111 'to_fieldname' => 'menu_order'
112 );
113
114 // Forum type (Category = 0 or Forum = 1, Stored in postmeta)
115 $this->field_map[] = array(
116 'from_tablename' => 'forums',
117 'from_fieldname' => 'forum_type',
118 'to_type' => 'forum',
119 'to_fieldname' => '_bbp_forum_type',
120 'callback_method' => 'callback_forum_type'
121 );
122
123 // Forum status (Unlocked = 0 or Locked = 1, Stored in postmeta)
124 $this->field_map[] = array(
125 'from_tablename' => 'forums',
126 'from_fieldname' => 'forum_status',
127 'to_type' => 'forum',
128 'to_fieldname' => '_bbp_status',
129 'callback_method' => 'callback_forum_status'
130 );
131
132 // Forum dates.
133 $this->field_map[] = array(
134 'to_type' => 'forum',
135 'to_fieldname' => 'post_date',
136 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore
137 );
138 $this->field_map[] = array(
139 'to_type' => 'forum',
140 'to_fieldname' => 'post_date_gmt',
141 'default' => gmdate( 'Y-m-d H:i:s' )
142 );
143 $this->field_map[] = array(
144 'to_type' => 'forum',
145 'to_fieldname' => 'post_modified',
146 'default' => date( 'Y-m-d H:i:s' ) // phpcs:ignore
147 );
148 $this->field_map[] = array(
149 'to_type' => 'forum',
150 'to_fieldname' => 'post_modified_gmt',
151 'default' => gmdate( 'Y-m-d H:i:s' )
152 );
153
154 /** Forum Subscriptions Section ***************************************/
155
156 // Subscribed forum ID (Stored in usermeta)
157 $this->field_map[] = array(
158 'from_tablename' => 'forums_watch',
159 'from_fieldname' => 'forum_id',
160 'to_type' => 'forum_subscriptions',
161 'to_fieldname' => '_bbp_forum_subscriptions'
162 );
163
164 // Subscribed user ID (Stored in usermeta)
165 $this->field_map[] = array(
166 'from_tablename' => 'forums_watch',
167 'from_fieldname' => 'user_id',
168 'to_type' => 'forum_subscriptions',
169 'to_fieldname' => 'user_id',
170 'callback_method' => 'callback_userid'
171 );
172
173 /** Topic Section *****************************************************/
174
175 // Old topic id (Stored in postmeta)
176 $this->field_map[] = array(
177 'from_tablename' => 'topics',
178 'from_fieldname' => 'topic_id',
179 'to_type' => 'topic',
180 'to_fieldname' => '_bbp_old_topic_id'
181 );
182
183 // Topic reply count (Stored in postmeta)
184 $this->field_map[] = array(
185 'from_tablename' => 'topics',
186 'from_fieldname' => 'topic_posts_approved',
187 'to_type' => 'topic',
188 'to_fieldname' => '_bbp_reply_count',
189 'callback_method' => 'callback_topic_reply_count'
190 );
191
192 // Topic total reply count (Includes unpublished replies, Stored in postmeta)
193 $this->field_map[] = array(
194 'from_tablename' => 'topics',
195 'from_fieldname' => 'topic_posts_approved',
196 'to_type' => 'topic',
197 'to_fieldname' => '_bbp_total_reply_count',
198 'callback_method' => 'callback_topic_reply_count'
199 );
200
201 // Topic parent forum id (If no parent, then 0. Stored in postmeta)
202 $this->field_map[] = array(
203 'from_tablename' => 'topics',
204 'from_fieldname' => 'forum_id',
205 'to_type' => 'topic',
206 'to_fieldname' => '_bbp_forum_id',
207 'callback_method' => 'callback_forumid'
208 );
209
210 // Topic author.
211 $this->field_map[] = array(
212 'from_tablename' => 'topics',
213 'from_fieldname' => 'topic_poster',
214 'to_type' => 'topic',
215 'to_fieldname' => 'post_author',
216 'callback_method' => 'callback_userid'
217 );
218
219 // Topic author name (Stored in postmeta as _bbp_anonymous_name)
220 $this->field_map[] = array(
221 'from_tablename' => 'topics',
222 'from_fieldname' => 'topic_first_poster_name',
223 'to_type' => 'topic',
224 'to_fieldname' => '_bbp_old_topic_author_name_id'
225 );
226
227 // Is the topic anonymous (Stored in postmeta)
228 $this->field_map[] = array(
229 'from_tablename' => 'topics',
230 'from_fieldname' => 'topic_poster',
231 'to_type' => 'topic',
232 'to_fieldname' => '_bbp_old_is_topic_anonymous_id',
233 'callback_method' => 'callback_check_anonymous'
234 );
235
236 // Topic Author ip (Stored in postmeta)
237 $this->field_map[] = array(
238 'from_tablename' => 'posts',
239 'from_fieldname' => 'poster_ip',
240 'join_tablename' => 'topics',
241 'join_type' => 'INNER',
242 'join_expression' => 'USING (topic_id) WHERE posts.post_id = topics.topic_first_post_id',
243 'to_type' => 'topic',
244 'to_fieldname' => '_bbp_author_ip'
245 );
246
247 // Topic content.
248 // Note: We join the 'posts' table because 'topics' does not include topic content.
249 $this->field_map[] = array(
250 'from_tablename' => 'posts',
251 'from_fieldname' => 'post_text',
252 'join_tablename' => 'topics',
253 'join_type' => 'INNER',
254 'join_expression' => 'USING (topic_id) WHERE posts.post_id = topics.topic_first_post_id',
255 'to_type' => 'topic',
256 'to_fieldname' => 'post_content',
257 'callback_method' => 'callback_html'
258 );
259
260 // Topic title.
261 $this->field_map[] = array(
262 'from_tablename' => 'topics',
263 'from_fieldname' => 'topic_title',
264 'to_type' => 'topic',
265 'to_fieldname' => 'post_title'
266 );
267
268 // Topic slug (Clean name to avoid conflicts)
269 $this->field_map[] = array(
270 'from_tablename' => 'topics',
271 'from_fieldname' => 'topic_title',
272 'to_type' => 'topic',
273 'to_fieldname' => 'post_name',
274 'callback_method' => 'callback_slug'
275 );
276
277 // Topic status (Open or Closed)
278 $this->field_map[] = array(
279 'from_tablename' => 'topics',
280 'from_fieldname' => 'topic_status',
281 'to_type' => 'topic',
282 'to_fieldname' => '_bbp_old_closed_status_id',
283 'callback_method' => 'callback_topic_status'
284 );
285
286 // Topic parent forum id (If no parent, then 0)
287 $this->field_map[] = array(
288 'from_tablename' => 'topics',
289 'from_fieldname' => 'forum_id',
290 'to_type' => 'topic',
291 'to_fieldname' => 'post_parent',
292 'callback_method' => 'callback_forumid'
293 );
294
295 // Sticky status (Stored in postmeta)
296 $this->field_map[] = array(
297 'from_tablename' => 'topics',
298 'from_fieldname' => 'topic_type',
299 'to_type' => 'topic',
300 'to_fieldname' => '_bbp_old_sticky_status_id',
301 'callback_method' => 'callback_sticky_status'
302 );
303
304 // Topic dates.
305 $this->field_map[] = array(
306 'from_tablename' => 'topics',
307 'from_fieldname' => 'topic_time',
308 'to_type' => 'topic',
309 'to_fieldname' => 'post_date',
310 'callback_method' => 'callback_datetime'
311 );
312 $this->field_map[] = array(
313 'from_tablename' => 'topics',
314 'from_fieldname' => 'topic_time',
315 'to_type' => 'topic',
316 'to_fieldname' => 'post_date_gmt',
317 'callback_method' => 'callback_datetime'
318 );
319 $this->field_map[] = array(
320 'from_tablename' => 'topics',
321 'from_fieldname' => 'topic_time',
322 'to_type' => 'topic',
323 'to_fieldname' => 'post_modified',
324 'callback_method' => 'callback_datetime'
325 );
326 $this->field_map[] = array(
327 'from_tablename' => 'topics',
328 'from_fieldname' => 'topic_time',
329 'to_type' => 'topic',
330 'to_fieldname' => 'post_modified_gmt',
331 'callback_method' => 'callback_datetime'
332 );
333 $this->field_map[] = array(
334 'from_tablename' => 'topics',
335 'from_fieldname' => 'topic_last_post_time',
336 'to_type' => 'topic',
337 'to_fieldname' => '_bbp_last_active_time',
338 'callback_method' => 'callback_datetime'
339 );
340
341 /** Tags Section ******************************************************/
342
343 /**
344 * phpBB Forums do not support topic tags
345 */
346
347 /** Topic Subscriptions Section ***************************************/
348
349 // Subscribed topic ID (Stored in usermeta)
350 $this->field_map[] = array(
351 'from_tablename' => 'topics_watch',
352 'from_fieldname' => 'topic_id',
353 'to_type' => 'topic_subscriptions',
354 'to_fieldname' => '_bbp_subscriptions'
355 );
356
357 // Subscribed user ID (Stored in usermeta)
358 $this->field_map[] = array(
359 'from_tablename' => 'topics_watch',
360 'from_fieldname' => 'user_id',
361 'to_type' => 'topic_subscriptions',
362 'to_fieldname' => 'user_id',
363 'callback_method' => 'callback_userid'
364 );
365
366 /** Favorites Section *************************************************/
367
368 // Favorited topic ID (Stored in usermeta)
369 $this->field_map[] = array(
370 'from_tablename' => 'bookmarks',
371 'from_fieldname' => 'topic_id',
372 'to_type' => 'favorites',
373 'to_fieldname' => '_bbp_favorites'
374 );
375
376 // Favorited user ID (Stored in usermeta)
377 $this->field_map[] = array(
378 'from_tablename' => 'bookmarks',
379 'from_fieldname' => 'user_id',
380 'to_type' => 'favorites',
381 'to_fieldname' => 'user_id',
382 'callback_method' => 'callback_userid'
383 );
384
385 /** Reply Section *****************************************************/
386
387 // Old reply id (Stored in postmeta)
388 $this->field_map[] = array(
389 'from_tablename' => 'posts',
390 'from_fieldname' => 'post_id',
391 'to_type' => 'reply',
392 'to_fieldname' => '_bbp_old_reply_id'
393 );
394
395 // Setup reply section table joins
396 $this->field_map[] = array(
397 'from_tablename' => 'topics',
398 'from_fieldname' => 'topic_id',
399 'join_tablename' => 'posts',
400 'join_type' => 'LEFT',
401 'join_expression' => 'USING (topic_id) WHERE posts.post_id != topics.topic_first_post_id',
402 'to_type' => 'reply'
403 );
404
405 // Reply parent forum id (If no parent, then 0. Stored in postmeta)
406 $this->field_map[] = array(
407 'from_tablename' => 'posts',
408 'from_fieldname' => 'forum_id',
409 'to_type' => 'reply',
410 'to_fieldname' => '_bbp_forum_id',
411 'callback_method' => 'callback_forumid'
412 );
413
414 // Reply parent topic id (If no parent, then 0. Stored in postmeta)
415 $this->field_map[] = array(
416 'from_tablename' => 'posts',
417 'from_fieldname' => 'topic_id',
418 'to_type' => 'reply',
419 'to_fieldname' => '_bbp_topic_id',
420 'callback_method' => 'callback_topicid'
421 );
422
423 // Reply author ip (Stored in postmeta)
424 $this->field_map[] = array(
425 'from_tablename' => 'posts',
426 'from_fieldname' => 'poster_ip',
427 'to_type' => 'reply',
428 'to_fieldname' => '_bbp_author_ip'
429 );
430
431 // Reply author.
432 $this->field_map[] = array(
433 'from_tablename' => 'posts',
434 'from_fieldname' => 'poster_id',
435 'to_type' => 'reply',
436 'to_fieldname' => 'post_author',
437 'callback_method' => 'callback_userid'
438 );
439
440 // Reply author name (Stored in postmeta as _bbp_anonymous_name)
441 $this->field_map[] = array(
442 'from_tablename' => 'posts',
443 'from_fieldname' => 'post_username',
444 'to_type' => 'reply',
445 'to_fieldname' => '_bbp_old_reply_author_name_id'
446 );
447
448 // Is the reply anonymous (Stored in postmeta)
449 $this->field_map[] = array(
450 'from_tablename' => 'posts',
451 'from_fieldname' => 'poster_id',
452 'to_type' => 'reply',
453 'to_fieldname' => '_bbp_old_is_reply_anonymous_id',
454 'callback_method' => 'callback_check_anonymous'
455 );
456
457 // Reply content.
458 $this->field_map[] = array(
459 'from_tablename' => 'posts',
460 'from_fieldname' => 'post_text',
461 'to_type' => 'reply',
462 'to_fieldname' => 'post_content',
463 'callback_method' => 'callback_html'
464 );
465
466 // Reply parent topic id (If no parent, then 0)
467 $this->field_map[] = array(
468 'from_tablename' => 'posts',
469 'from_fieldname' => 'topic_id',
470 'to_type' => 'reply',
471 'to_fieldname' => 'post_parent',
472 'callback_method' => 'callback_topicid'
473 );
474
475 // Reply dates.
476 $this->field_map[] = array(
477 'from_tablename' => 'posts',
478 'from_fieldname' => 'post_time',
479 'to_type' => 'reply',
480 'to_fieldname' => 'post_date',
481 'callback_method' => 'callback_datetime'
482 );
483 $this->field_map[] = array(
484 'from_tablename' => 'posts',
485 'from_fieldname' => 'post_time',
486 'to_type' => 'reply',
487 'to_fieldname' => 'post_date_gmt',
488 'callback_method' => 'callback_datetime'
489 );
490 $this->field_map[] = array(
491 'from_tablename' => 'posts',
492 'from_fieldname' => 'post_time',
493 'to_type' => 'reply',
494 'to_fieldname' => 'post_modified',
495 'callback_method' => 'callback_datetime'
496 );
497 $this->field_map[] = array(
498 'from_tablename' => 'posts',
499 'from_fieldname' => 'post_time',
500 'to_type' => 'reply',
501 'to_fieldname' => 'post_modified_gmt',
502 'callback_method' => 'callback_datetime'
503 );
504
505 /** User Section ******************************************************/
506
507 // Store old user id (Stored in usermeta)
508 // Don't import users with id 2, these are phpBB bot/crawler accounts
509 $this->field_map[] = array(
510 'from_tablename' => 'users',
511 'from_fieldname' => 'user_id',
512 'to_type' => 'user',
513 'to_fieldname' => '_bbp_old_user_id'
514 );
515
516 // Store old user password (Stored in usermeta serialized with salt)
517 $this->field_map[] = array(
518 'from_tablename' => 'users',
519 'from_fieldname' => 'user_password',
520 'to_type' => 'user',
521 'to_fieldname' => '_bbp_password',
522 'callback_method' => 'callback_savepass'
523 );
524
525 // Store old user salt (This is only used for the SELECT row info for the above password save)
526 $this->field_map[] = array(
527 'from_tablename' => 'users',
528 'from_fieldname' => 'user_form_salt',
529 'to_type' => 'user',
530 'to_fieldname' => ''
531 );
532
533 // User password verify class (Stored in usermeta for verifying password)
534 $this->field_map[] = array(
535 'to_type' => 'user',
536 'to_fieldname' => '_bbp_class',
537 'default' => 'phpBB'
538 );
539
540 // User name.
541 $this->field_map[] = array(
542 'from_tablename' => 'users',
543 'from_fieldname' => 'username',
544 'to_type' => 'user',
545 'to_fieldname' => 'user_login'
546 );
547
548 // User email.
549 $this->field_map[] = array(
550 'from_tablename' => 'users',
551 'from_fieldname' => 'user_email',
552 'to_type' => 'user',
553 'to_fieldname' => 'user_email'
554 );
555
556 // User homepage.
557 $this->field_map[] = array(
558 'from_tablename' => 'profile_fields_data',
559 'from_fieldname' => 'pf_phpbb_website',
560 'join_tablename' => 'users',
561 'join_type' => 'LEFT',
562 'join_expression' => 'USING (user_id) WHERE users.user_type !=2',
563 'to_type' => 'user',
564 'to_fieldname' => 'user_url'
565 );
566
567 // User registered.
568 $this->field_map[] = array(
569 'from_tablename' => 'users',
570 'from_fieldname' => 'user_regdate',
571 'to_type' => 'user',
572 'to_fieldname' => 'user_registered',
573 'callback_method' => 'callback_datetime'
574 );
575
576 // User AOL/AIM (Stored in usermeta)
577 $this->field_map[] = array(
578 'from_tablename' => 'profile_fields_data',
579 'from_fieldname' => 'pf_phpbb_aol',
580 'to_type' => 'user',
581 'to_fieldname' => '_bbp_phpbb_user_aim'
582 );
583
584 // User Yahoo (Stored in usermeta)
585 $this->field_map[] = array(
586 'from_tablename' => 'profile_fields_data',
587 'from_fieldname' => 'pf_phpbb_yahoo',
588 'to_type' => 'user',
589 'to_fieldname' => '_bbp_phpbb_user_yim'
590 );
591
592 // Store ICQ (Stored in usermeta)
593 $this->field_map[] = array(
594 'from_tablename' => 'profile_fields_data',
595 'from_fieldname' => 'pf_phpbb_icq',
596 'to_type' => 'user',
597 'to_fieldname' => '_bbp_phpbb_user_icq'
598 );
599
600 // Store MSN/WLM (Stored in usermeta)
601 $this->field_map[] = array(
602 'from_tablename' => 'profile_fields_data',
603 'from_fieldname' => 'pf_phpbb_wlm',
604 'to_type' => 'user',
605 'to_fieldname' => '_bbp_phpbb_user_msnm'
606 );
607
608 // Store Facebook (Stored in usermeta)
609 $this->field_map[] = array(
610 'from_tablename' => 'profile_fields_data',
611 'from_fieldname' => 'pf_phpbb_facebook',
612 'to_type' => 'user',
613 'to_fieldname' => '_bbp_phpbb_user_facebook'
614 );
615
616 // Store Google+ (Stored in usermeta)
617 $this->field_map[] = array(
618 'from_tablename' => 'profile_fields_data',
619 'from_fieldname' => 'pf_phpbb_googleplus',
620 'to_type' => 'user',
621 'to_fieldname' => '_bbp_phpbb_user_googleplus'
622 );
623
624 // Store Skype (Stored in usermeta)
625 $this->field_map[] = array(
626 'from_tablename' => 'profile_fields_data',
627 'from_fieldname' => 'pf_phpbb_skype',
628 'to_type' => 'user',
629 'to_fieldname' => '_bbp_phpbb_user_skype'
630 );
631
632 // Store Twitter (Stored in usermeta)
633 $this->field_map[] = array(
634 'from_tablename' => 'profile_fields_data',
635 'from_fieldname' => 'pf_phpbb_twitter',
636 'to_type' => 'user',
637 'to_fieldname' => '_bbp_phpbb_user_twitter'
638 );
639
640 // Store Youtube (Stored in usermeta)
641 $this->field_map[] = array(
642 'from_tablename' => 'profile_fields_data',
643 'from_fieldname' => 'pf_phpbb_youtube',
644 'to_type' => 'user',
645 'to_fieldname' => '_bbp_phpbb_user_youtube'
646 );
647
648 // Store Jabber
649 $this->field_map[] = array(
650 'from_tablename' => 'users',
651 'from_fieldname' => 'user_jabber',
652 'to_type' => 'user',
653 'to_fieldname' => '_bbp_phpbb_user_jabber'
654 );
655
656 // Store Occupation (Stored in usermeta)
657 $this->field_map[] = array(
658 'from_tablename' => 'profile_fields_data',
659 'from_fieldname' => 'pf_phpbb_occupation',
660 'to_type' => 'user',
661 'to_fieldname' => '_bbp_phpbb_user_occ'
662 );
663
664 // Store Interests (Stored in usermeta)
665 $this->field_map[] = array(
666 'from_tablename' => 'profile_fields_data',
667 'from_fieldname' => 'pf_phpbb_interests',
668 'to_type' => 'user',
669 'to_fieldname' => '_bbp_phpbb_user_interests'
670 );
671
672 // Store Signature (Stored in usermeta)
673 $this->field_map[] = array(
674 'from_tablename' => 'users',
675 'from_fieldname' => 'user_sig',
676 'to_type' => 'user',
677 'to_fieldname' => '_bbp_phpbb_user_sig',
678 'callback_method' => 'callback_html'
679 );
680
681 // Store Location (Stored in usermeta)
682 $this->field_map[] = array(
683 'from_tablename' => 'profile_fields_data',
684 'from_fieldname' => 'pf_phpbb_location',
685 'to_type' => 'user',
686 'to_fieldname' => '_bbp_phpbb_user_from'
687 );
688
689 // Store Avatar Filename (Stored in usermeta)
690 $this->field_map[] = array(
691 'from_tablename' => 'users',
692 'from_fieldname' => 'user_avatar',
693 'to_type' => 'user',
694 'to_fieldname' => '_bbp_phpbb_user_avatar'
695 );
696
697 // Store old role (Stored in usermeta)
698 }
699
700 /**
701 * This method allows us to indicates what is or is not converted for each
702 * converter.
703 */
704 public function info() {
705 return '';
706 }
707
708 /**
709 * This method is to save the salt and password together. That
710 * way when we authenticate it we can get it out of the database
711 * as one value.
712 */
713 public function callback_savepass( $field, $row ) {
714 return array(
715 'hash' => $field,
716 'salt' => $row['user_form_salt']
717 );
718 }
719
720 /**
721 * Check for correct password
722 *
723 * @param string $password The password in plain text
724 * @param string $serialized_pass The stored password hash
725 *
726 * @link Original source for password functions http://openwall.com/phpass/
727 * @link phpass is now included in WP Core https://core.trac.wordpress.org/browser/trunk/wp-includes/class-phpass.php
728 *
729 * @return bool Returns true if the password is correct, false if not.
730 */
731 public function authenticate_pass( $password, $serialized_pass ) {
732
733 // Unserialize the password, with safeguards
734 $pass_array = unserialize(
735 $serialized_pass,
736 array(
737 'allowed_classes' => false,
738 'max_depth' => 1,
739 )
740 );
741
742 // Encrypted
743 if ( strlen( $pass_array['hash'] ) === 34 ) {
744
745 // ASCII
746 $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
747
748 // Compare using private crypt
749 return hash_equals(
750 $this->hash_crypt_private( $password, $pass_array['hash'], $itoa64 ),
751 $pass_array['hash']
752 );
753 }
754
755 // Unencrypted
756 return hash_equals(
757 md5( $password ),
758 $pass_array['hash']
759 );
760 }
761
762 /**
763 * The crypt function/replacement
764 */
765 private function hash_crypt_private( $password, $setting, &$itoa64 ) {
766 $output = '*';
767
768 // Check for correct hash
769 if ( substr( $setting, 0, 3 ) !== '$H$' ) {
770 return $output;
771 }
772
773 $count_log2 = strpos( $itoa64, $setting[3] );
774
775 if ( $count_log2 < 7 || $count_log2 > 30 ) {
776 return $output;
777 }
778
779 $count = 1 << $count_log2;
780 $salt = substr( $setting, 4, 8 );
781
782 if ( strlen( $salt ) !== 8 ) {
783 return $output;
784 }
785
786 /**
787 * We're kind of forced to use MD5 here since it's the only
788 * cryptographic primitive available in all versions of PHP
789 * currently in use. To implement our own low-level crypto
790 * in PHP would result in much worse performance and
791 * consequently in lower iteration counts and hashes that are
792 * quicker to crack (by non-PHP code).
793 */
794 if ( floatval( phpversion() ) >= 5 ) {
795 $hash = md5( $salt . $password, true );
796 do {
797 $hash = md5( $hash . $password, true );
798 } while ( --$count );
799 } else {
800 $hash = pack( 'H*', md5( $salt . $password ) );
801 do {
802 $hash = pack( 'H*', md5( $hash . $password ) );
803 } while ( --$count );
804 }
805
806 $output = substr( $setting, 0, 12 );
807 $output .= $this->hash_encode64( $hash, 16, $itoa64 );
808
809 return $output;
810 }
811
812 /**
813 * Encode hash
814 */
815 private function hash_encode64( $input, $count, &$itoa64 ) {
816 $output = '';
817 $i = 0;
818
819 do {
820 $value = ord( $input[ $i++ ] );
821 $output .= $itoa64[ $value & 0x3f ];
822
823 if ( $i < $count ) {
824 $value |= ord( $input[ $i ] ) << 8;
825 }
826
827 $output .= $itoa64[ ( $value >> 6 ) & 0x3f ];
828
829 if ( $i++ >= $count ) {
830 break;
831 }
832
833 if ( $i < $count ) {
834 $value |= ord( $input[ $i ] ) << 16;
835 }
836
837 $output .= $itoa64[ ( $value >> 12 ) & 0x3f ];
838
839 if ( $i++ >= $count ) {
840 break;
841 }
842
843 $output .= $itoa64[ ( $value >> 18 ) & 0x3f ];
844 } while ( $i < $count );
845
846 return $output;
847 }
848
849 /**
850 * Translate the forum type from phpBB v3.x numerics to WordPress's strings.
851 *
852 * @param int $status phpBB v3.x numeric forum type
853 * @return string WordPress safe
854 */
855 public function callback_forum_type( $status = 1 ) {
856 switch ( $status ) {
857 case 0 :
858 $status = 'category';
859 break;
860
861 case 1 :
862 default :
863 $status = 'forum';
864 break;
865 }
866 return $status;
867 }
868
869 /**
870 * Translate the forum status from phpBB v3.x numerics to WordPress's strings.
871 *
872 * @param int $status phpBB v3.x numeric forum status
873 * @return string WordPress safe
874 */
875 public function callback_forum_status( $status = 0 ) {
876 switch ( $status ) {
877 case 1 :
878 $status = 'closed';
879 break;
880
881 case 0 :
882 default :
883 $status = 'open';
884 break;
885 }
886 return $status;
887 }
888
889 /**
890 * Translate the topic status from phpBB v3.x numerics to WordPress's strings.
891 *
892 * @param int $status phpBB v3.x numeric topic status
893 * @return string WordPress safe
894 */
895 public function callback_topic_status( $status = 0 ) {
896 switch ( $status ) {
897 case 1 :
898 $status = 'closed';
899 break;
900
901 case 0 :
902 default :
903 $status = 'publish';
904 break;
905 }
906 return $status;
907 }
908
909 /**
910 * Translate the topic sticky status type from phpBB 3.x numerics to WordPress's strings.
911 *
912 * @param int $status phpBB 3.x numeric forum type
913 * @return string WordPress safe
914 */
915 public function callback_sticky_status( $status = 0 ) {
916 switch ( $status ) {
917 case 3 :
918 $status = 'super-sticky'; // phpBB Global Sticky 'topic_type = 3'
919 break;
920
921 case 2 :
922 $status = 'super-sticky'; // phpBB Announcement Sticky 'topic_type = 2'
923 break;
924
925 case 1 :
926 $status = 'sticky'; // phpBB Sticky 'topic_type = 1'
927 break;
928
929 case 0 :
930 default :
931 $status = 'normal'; // phpBB normal topic 'topic_type = 0'
932 break;
933 }
934 return $status;
935 }
936
937 /**
938 * Verify the topic reply count.
939 *
940 * @param int $count phpBB v3.x reply count
941 * @return string WordPress safe
942 */
943 public function callback_topic_reply_count( $count = 1 ) {
944 $count = absint( (int) $count - 1 );
945 return $count;
946 }
947
948 /**
949 * This callback processes any custom parser.php attributes and custom code with preg_replace
950 */
951 protected function callback_html( $field ) {
952
953 // Strips custom phpBB 'magic_url' and 'bbcode_uid' first from $field before parsing $field to parser.php
954 $phpbb_uid = $field;
955 $phpbb_uid = html_entity_decode( $phpbb_uid );
956
957 // Replace '[b:XXXXXXX]' with '<strong>'
958 $phpbb_uid = preg_replace( '/\[b:(.*?)\]/', '<strong>', $phpbb_uid );
959 // Replace '[/b:XXXXXXX]' with '</strong>'
960 $phpbb_uid = preg_replace( '/\[\/b:(.*?)\]/', '</strong>', $phpbb_uid );
961
962 // Replace '[i:XXXXXXX]' with '<em>'
963 $phpbb_uid = preg_replace( '/\[i:(.*?)\]/', '<em>', $phpbb_uid );
964 // Replace '[/i:XXXXXXX]' with '</em>'
965 $phpbb_uid = preg_replace( '/\[\/i:(.*?)\]/', '</em>', $phpbb_uid );
966
967 // Replace '[u:XXXXXXX]' with '<u>'
968 $phpbb_uid = preg_replace( '/\[u:(.*?)\]/', '<u>', $phpbb_uid );
969 // Replace '[/u:XXXXXXX]' with '</u>'
970 $phpbb_uid = preg_replace( '/\[\/u:(.*?)\]/', '</u>', $phpbb_uid );
971
972 // Replace '[quote:XXXXXXX]' with '<blockquote>'
973 $phpbb_uid = preg_replace( '/\[quote:(.*?)\]/', '<blockquote>', $phpbb_uid );
974 // Replace '[quote="$1"]' with '<em>$1 wrote:</em><blockquote>"
975 $phpbb_uid = preg_replace( '/\[quote="(.*?)":(.*?)\]/', '<em>@$1 wrote:</em><blockquote>', $phpbb_uid );
976 // Replace '[/quote:XXXXXXX]' with '</blockquote>'
977 $phpbb_uid = preg_replace( '/\[\/quote:(.*?)\]/', '</blockquote>', $phpbb_uid );
978
979 // Replace '[img:XXXXXXX]' with '<img src="'
980 $phpbb_uid = preg_replace( '/\[img:(.*?)\]/', '<img src="', $phpbb_uid );
981 // Replace '[/img:XXXXXXX]' with ' alt="">'
982 $phpbb_uid = preg_replace( '/\[\/img:(.*?)\]/', '" alt="">', $phpbb_uid );
983
984 // Replace '<!-- s$1 --><img src=\"{SMILIES_PATH}$2 -->' with '$1'
985 $phpbb_uid = preg_replace( '/<!-- s(.*?) --><img src=\"{SMILIES_PATH}(.*?)-->/', '$1', $phpbb_uid );
986
987 // Replace '<!-- m --><a class="postlink" href="$1">$1</a><!-- m -->' with '$1'
988 $phpbb_uid = preg_replace( '/\<!-- m --\>\<a class="postlink" href="([^\[]+?)"\>([^\[]+?)\<\/a\>\<!-- m --\>/', '$1', $phpbb_uid );
989
990 // Replace '[url:XXXXXXX]$1[/url:XXXXXXX]' with '<a href="http://$1">$1</a>'
991 $phpbb_uid = preg_replace( '/\[url:(?:[^\]]+)\]([^\[]+?)\[\/url:(?:[^\]]+)\]/', '<a href="http://$1">$1</a>', $phpbb_uid );
992 // Replace '[url=http://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>'
993 $phpbb_uid = preg_replace( '/\[url\=http\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i', '<a href="http://$1">$3</a>', $phpbb_uid );
994 // Replace '[url=https://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>'
995 $phpbb_uid = preg_replace( '/\[url\=https\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i', '<a href="https://$1">$3</a>', $phpbb_uid );
996
997 // Replace '[email:XXXXXXX]' with '<a href="mailto:$2">$2</a>'
998 $phpbb_uid = preg_replace( '/\[email:(.*?)\](.*?)\[\/email:(.*?)\]/', '<a href="mailto:$2">$2</a>', $phpbb_uid );
999 // Replace '<!-- e -->no.one@domain.adr<!-- e -->' with '$1'
1000 $phpbb_uid = preg_replace( '/\<!-- e --\>(.*?)\<!-- e --\>/', '$1', $phpbb_uid );
1001
1002 // Replace '[code:XXXXXXX]' with '<pre><code>'
1003 $phpbb_uid = preg_replace( '/\[code:(.*?)\]/', '<pre><code>', $phpbb_uid );
1004 // Replace '[/code:XXXXXXX]' with '</code></pre>'
1005 $phpbb_uid = preg_replace( '/\[\/code:(.*?)\]/', '</code></pre>', $phpbb_uid );
1006
1007 // Replace '[color=$1:XXXXXXXX]' with '<span style="color:$1">'
1008 $phpbb_uid = preg_replace( '/\[color=(.*?)\:(.*?)\]/', '<span style="color: $1">', $phpbb_uid );
1009 // Replace '[/color:XXXXXXX]' with '</span>'
1010 $phpbb_uid = preg_replace( '/\[\/color:(.*?)\]/', '</span>', $phpbb_uid );
1011
1012 // Replace '[size=$1:XXXXXXXX]' with '<span style="font-size:$1%;">$3</span>'
1013 $phpbb_uid = preg_replace( '/\[size=(.*?):(.*?)\]/', '<span style="font-size:$1%;">', $phpbb_uid );
1014 // Replace '[/size:XXXXXXX]' with ''
1015 $phpbb_uid = preg_replace( '/\[\/size:(.*?)\]/', '</span>', $phpbb_uid );
1016
1017 // Replace '[list:XXXXXXX]' with '<ul>'
1018 $phpbb_uid = preg_replace( '/\[list:(.*?)\]/', '<ul>', $phpbb_uid );
1019 // Replace '[list=a:XXXXXXX]' with '<ol type="a">'
1020 $phpbb_uid = preg_replace( '/\[list=a:(.*?)\]/', '<ol type="a">', $phpbb_uid );
1021 // Replace '[list=1:XXXXXXX]' with '<ol>'
1022 $phpbb_uid = preg_replace( '/\[list=1:(.*?)\]/', '<ol>', $phpbb_uid );
1023 // Replace '[*:XXXXXXX]' with '<li>'
1024 $phpbb_uid = preg_replace( '/\[\*:(.*?)\]/', '<li>', $phpbb_uid );
1025 // Replace '[/*:m:XXXXXXX]' with '</li>'
1026 $phpbb_uid = preg_replace( '/\[\/\*:m:(.*?)\]/', '</li>', $phpbb_uid );
1027 // Replace '[/list:u:XXXXXXX]' with '</ul>'
1028 $phpbb_uid = preg_replace( '/\[\/list:u:(.*?)\]/', '</ul>', $phpbb_uid );
1029 // Replace '[/list:o:XXXXXXX]' with '</ol>'
1030 $phpbb_uid = preg_replace( '/\[\/list:o:(.*?)\]/', '</ol>', $phpbb_uid );
1031
1032 // Now that phpBB's 'magic_url' and 'bbcode_uid' have been stripped put the cleaned HTML back in $field
1033 $field = $phpbb_uid;
1034
1035 // Parse out any bbCodes in $field with the BBCode 'parser.php'
1036 return parent::callback_html( $field );
1037 }
1038 }
1039