[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/src/includes/admin/converters/ -> phpBB.php (source)

   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')
 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')
 150          );
 151          $this->field_map[] = array(
 152              'to_type'      => 'forum',
 153              'to_fieldname' => 'post_modified',
 154              'default'      => date('Y-m-d H:i:s')
 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')
 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 $hash 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          $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
 741          $pass_array = unserialize( $serialized_pass );
 742          if ( strlen( $pass_array['hash'] ) == 34 ) {
 743              return ( $this->_hash_crypt_private( $password, $pass_array['hash'], $itoa64 ) === $pass_array['hash'] ) ? true : false;
 744          }
 745  
 746          return ( md5( $password ) === $pass_array['hash'] ) ? true : false;
 747      }
 748  
 749      /**
 750       * The crypt function/replacement
 751       */
 752  	private function _hash_crypt_private( $password, $setting, &$itoa64 ) {
 753          $output = '*';
 754  
 755          // Check for correct hash
 756          if ( substr( $setting, 0, 3 ) != '$H$' ) {
 757              return $output;
 758          }
 759  
 760          $count_log2 = strpos( $itoa64, $setting[3] );
 761  
 762          if ( $count_log2 < 7 || $count_log2 > 30 ) {
 763              return $output;
 764          }
 765  
 766          $count = 1 << $count_log2;
 767          $salt  = substr( $setting, 4, 8 );
 768  
 769          if ( strlen( $salt ) != 8 ) {
 770              return $output;
 771          }
 772  
 773          /**
 774           * We're kind of forced to use MD5 here since it's the only
 775           * cryptographic primitive available in all versions of PHP
 776           * currently in use.  To implement our own low-level crypto
 777           * in PHP would result in much worse performance and
 778           * consequently in lower iteration counts and hashes that are
 779           * quicker to crack (by non-PHP code).
 780           */
 781          if ( floatval( phpversion() ) >= 5 ) {
 782              $hash = md5( $salt . $password, true );
 783              do {
 784                  $hash = md5( $hash . $password, true );
 785              }
 786              while ( --$count );
 787          } else {
 788              $hash = pack( 'H*', md5( $salt . $password ) );
 789              do {
 790                  $hash = pack( 'H*', md5( $hash . $password ) );
 791              }
 792              while ( --$count );
 793          }
 794  
 795          $output = substr($setting, 0, 12);
 796          $output .= $this->_hash_encode64($hash, 16, $itoa64);
 797  
 798          return $output;
 799      }
 800  
 801      /**
 802       * Encode hash
 803       */
 804  	private function _hash_encode64( $input, $count, &$itoa64 ) {
 805          $output = '';
 806          $i = 0;
 807  
 808          do {
 809              $value = ord( $input[ $i++ ] );
 810              $output .= $itoa64[ $value & 0x3f ];
 811  
 812              if ($i < $count) {
 813                  $value |= ord( $input[ $i ] ) << 8;
 814              }
 815  
 816              $output .= $itoa64[( $value >> 6 ) & 0x3f];
 817  
 818              if ( $i++ >= $count ) {
 819                  break;
 820              }
 821  
 822              if ( $i < $count ) {
 823                  $value |= ord( $input[ $i ] ) << 16;
 824              }
 825  
 826              $output .= $itoa64[( $value >> 12 ) & 0x3f];
 827  
 828              if ( $i++ >= $count ) {
 829                  break;
 830              }
 831  
 832              $output .= $itoa64[( $value >> 18 ) & 0x3f];
 833          } while ( $i < $count );
 834  
 835          return $output;
 836      }
 837  
 838      /**
 839       * Translate the forum type from phpBB v3.x numerics to WordPress's strings.
 840       *
 841       * @param int $status phpBB v3.x numeric forum type
 842       * @return string WordPress safe
 843       */
 844  	public function callback_forum_type( $status = 1 ) {
 845          switch ( $status ) {
 846              case 0 :
 847                  $status = 'category';
 848                  break;
 849  
 850              case 1  :
 851              default :
 852                  $status = 'forum';
 853                  break;
 854          }
 855          return $status;
 856      }
 857  
 858      /**
 859       * Translate the forum status from phpBB v3.x numerics to WordPress's strings.
 860       *
 861       * @param int $status phpBB v3.x numeric forum status
 862       * @return string WordPress safe
 863       */
 864  	public function callback_forum_status( $status = 0 ) {
 865          switch ( $status ) {
 866              case 1 :
 867                  $status = 'closed';
 868                  break;
 869  
 870              case 0  :
 871              default :
 872                  $status = 'open';
 873                  break;
 874          }
 875          return $status;
 876      }
 877  
 878      /**
 879       * Translate the topic status from phpBB v3.x numerics to WordPress's strings.
 880       *
 881       * @param int $status phpBB v3.x numeric topic status
 882       * @return string WordPress safe
 883       */
 884  	public function callback_topic_status( $status = 0 ) {
 885          switch ( $status ) {
 886              case 1 :
 887                  $status = 'closed';
 888                  break;
 889  
 890              case 0 :
 891              default :
 892                  $status = 'publish';
 893                  break;
 894          }
 895          return $status;
 896      }
 897  
 898      /**
 899       * Translate the topic sticky status type from phpBB 3.x numerics to WordPress's strings.
 900       *
 901       * @param int $status phpBB 3.x numeric forum type
 902       * @return string WordPress safe
 903       */
 904  	public function callback_sticky_status( $status = 0 ) {
 905          switch ( $status ) {
 906              case 3 :
 907                  $status = 'super-sticky'; // phpBB Global Sticky 'topic_type = 3'
 908                  break;
 909  
 910              case 2 :
 911                  $status = 'super-sticky'; // phpBB Announcement Sticky 'topic_type = 2'
 912                  break;
 913  
 914              case 1 :
 915                  $status = 'sticky';       // phpBB Sticky 'topic_type = 1'
 916                  break;
 917  
 918              case 0  :
 919              default :
 920                  $status = 'normal';       // phpBB normal topic 'topic_type = 0'
 921                  break;
 922          }
 923          return $status;
 924      }
 925  
 926      /**
 927       * Verify the topic reply count.
 928       *
 929       * @param int $count phpBB v3.x reply count
 930       * @return string WordPress safe
 931       */
 932  	public function callback_topic_reply_count( $count = 1 ) {
 933          $count = absint( (int) $count - 1 );
 934          return $count;
 935      }
 936  
 937      /**
 938       * This callback processes any custom parser.php attributes and custom code with preg_replace
 939       */
 940  	protected function callback_html( $field ) {
 941  
 942          // Strips custom phpBB 'magic_url' and 'bbcode_uid' first from $field before parsing $field to parser.php
 943          $phpbb_uid = $field;
 944          $phpbb_uid = html_entity_decode( $phpbb_uid );
 945  
 946          // Replace '[b:XXXXXXX]' with '<strong>'
 947          $phpbb_uid = preg_replace( '/\[b:(.*?)\]/',   '<strong>',  $phpbb_uid );
 948          // Replace '[/b:XXXXXXX]' with '</strong>'
 949          $phpbb_uid = preg_replace( '/\[\/b:(.*?)\]/', '</strong>', $phpbb_uid );
 950  
 951          // Replace '[i:XXXXXXX]' with '<em>'
 952          $phpbb_uid = preg_replace( '/\[i:(.*?)\]/',   '<em>',      $phpbb_uid );
 953          // Replace '[/i:XXXXXXX]' with '</em>'
 954          $phpbb_uid = preg_replace( '/\[\/i:(.*?)\]/', '</em>',     $phpbb_uid );
 955  
 956          // Replace '[u:XXXXXXX]' with '<u>'
 957          $phpbb_uid = preg_replace( '/\[u:(.*?)\]/',   '<u>',       $phpbb_uid );
 958          // Replace '[/u:XXXXXXX]' with '</u>'
 959          $phpbb_uid = preg_replace( '/\[\/u:(.*?)\]/', '</u>',      $phpbb_uid );
 960  
 961          // Replace '[quote:XXXXXXX]' with '<blockquote>'
 962          $phpbb_uid = preg_replace( '/\[quote:(.*?)\]/',          '<blockquote>',                   $phpbb_uid );
 963          // Replace '[quote="$1"]' with '<em>$1 wrote:</em><blockquote>"
 964          $phpbb_uid = preg_replace( '/\[quote="(.*?)":(.*?)\]/', '<em>@$1 wrote:</em><blockquote>', $phpbb_uid );
 965          // Replace '[/quote:XXXXXXX]' with '</blockquote>'
 966          $phpbb_uid = preg_replace( '/\[\/quote:(.*?)\]/',       '</blockquote>',                   $phpbb_uid );
 967  
 968          // Replace '[img:XXXXXXX]' with '<img src="'
 969          $phpbb_uid = preg_replace( '/\[img:(.*?)\]/',   '<img src="', $phpbb_uid );
 970          // Replace '[/img:XXXXXXX]' with ' alt="">'
 971          $phpbb_uid = preg_replace( '/\[\/img:(.*?)\]/', '" alt="">',  $phpbb_uid );
 972  
 973          // Replace '<!-- s$1 --><img src=\"{SMILIES_PATH}$2 -->' with '$1'
 974          $phpbb_uid = preg_replace( '/<!-- s(.*?) --><img src=\"{SMILIES_PATH}(.*?)-->/', '$1', $phpbb_uid );
 975  
 976          // Replace '<!-- m --><a class="postlink" href="$1">$1</a><!-- m -->' with '$1'
 977          $phpbb_uid = preg_replace( '/\<!-- m --\>\<a class="postlink" href="([^\[]+?)"\>([^\[]+?)\<\/a\>\<!-- m --\>/', '$1', $phpbb_uid );
 978  
 979          // Replace '[url:XXXXXXX]$1[/url:XXXXXXX]' with '<a href="http://$1">$1</a>'
 980          $phpbb_uid = preg_replace( '/\[url:(?:[^\]]+)\]([^\[]+?)\[\/url:(?:[^\]]+)\]/',       '<a href="http://$1">$1</a>',  $phpbb_uid );
 981          // Replace '[url=http://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>'
 982          $phpbb_uid = preg_replace( '/\[url\=http\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i',  '<a href="http://$1">$3</a>',  $phpbb_uid );
 983          // Replace '[url=https://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>'
 984          $phpbb_uid = preg_replace( '/\[url\=https\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i', '<a href="https://$1">$3</a>', $phpbb_uid );
 985  
 986          // Replace '[email:XXXXXXX]' with '<a href="mailto:$2">$2</a>'
 987          $phpbb_uid = preg_replace( '/\[email:(.*?)\](.*?)\[\/email:(.*?)\]/', '<a href="mailto:$2">$2</a>', $phpbb_uid );
 988          // Replace '<!-- e -->no.one@domain.adr<!-- e -->' with '$1'
 989          $phpbb_uid = preg_replace( '/\<!-- e --\>(.*?)\<!-- e --\>/', '$1', $phpbb_uid );
 990  
 991          // Replace '[code:XXXXXXX]' with '<pre><code>'
 992          $phpbb_uid = preg_replace( '/\[code:(.*?)\]/',   '<pre><code>',   $phpbb_uid );
 993          // Replace '[/code:XXXXXXX]' with '</code></pre>'
 994          $phpbb_uid = preg_replace( '/\[\/code:(.*?)\]/', '</code></pre>', $phpbb_uid );
 995  
 996          // Replace '[color=$1:XXXXXXXX]' with '<span style="color:$1">'
 997          $phpbb_uid = preg_replace( '/\[color=(.*?)\:(.*?)\]/', '<span style="color: $1">', $phpbb_uid );
 998          // Replace '[/color:XXXXXXX]' with '</span>'
 999          $phpbb_uid = preg_replace( '/\[\/color:(.*?)\]/',      '</span>',                  $phpbb_uid );
1000  
1001          // Replace '[size=$1:XXXXXXXX]' with '<span style="font-size:$1%;">$3</span>'
1002          $phpbb_uid = preg_replace( '/\[size=(.*?):(.*?)\]/', '<span style="font-size:$1%;">', $phpbb_uid );
1003          // Replace '[/size:XXXXXXX]' with ''
1004          $phpbb_uid = preg_replace( '/\[\/size:(.*?)\]/',     '</span>',                       $phpbb_uid );
1005  
1006          // Replace '[list:XXXXXXX]' with '<ul>'
1007          $phpbb_uid = preg_replace( '/\[list:(.*?)\]/',     '<ul>',          $phpbb_uid );
1008          // Replace '[list=a:XXXXXXX]' with '<ol type="a">'
1009          $phpbb_uid = preg_replace( '/\[list=a:(.*?)\]/',   '<ol type="a">', $phpbb_uid );
1010          // Replace '[list=1:XXXXXXX]' with '<ol>'
1011          $phpbb_uid = preg_replace( '/\[list=1:(.*?)\]/',   '<ol>',          $phpbb_uid );
1012          // Replace '[*:XXXXXXX]' with '<li>'
1013          $phpbb_uid = preg_replace( '/\[\*:(.*?)\]/',       '<li>',          $phpbb_uid );
1014          // Replace '[/*:m:XXXXXXX]' with '</li>'
1015          $phpbb_uid = preg_replace( '/\[\/\*:m:(.*?)\]/',   '</li>',         $phpbb_uid );
1016          // Replace '[/list:u:XXXXXXX]' with '</ul>'
1017          $phpbb_uid = preg_replace( '/\[\/list:u:(.*?)\]/', '</ul>',         $phpbb_uid );
1018          // Replace '[/list:o:XXXXXXX]' with '</ol>'
1019          $phpbb_uid = preg_replace( '/\[\/list:o:(.*?)\]/', '</ol>',         $phpbb_uid );
1020  
1021          // Now that phpBB's 'magic_url' and 'bbcode_uid' have been stripped put the cleaned HTML back in $field
1022          $field = $phpbb_uid;
1023  
1024          // Parse out any bbCodes in $field with the BBCode 'parser.php'
1025          return parent::callback_html( $field );
1026      }
1027  }


Generated: Sat Dec 21 01:00:52 2024 Cross-referenced by PHPXref 0.7.1