PluginProbe
bbPress / 2.6.17
bbPress v2.6.17
2.6.17 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 All 72 releases
bbpress / includes / admin / converters / phpBB.php

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

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