Ticket #1884: 1884.4.diff
File 1884.4.diff, 24.7 KB (added by , 10 years ago) |
---|
-
includes/admin/converters/phpBB.php
diff --git a/includes/admin/converters/phpBB.php b/includes/admin/converters/phpBB.php index 8f3a03c..70e1d0e 100644
a b 1 1 <?php 2 2 3 3 /** 4 * Implementation of phpBB converter. 4 * Implementation of phpBB v3 Converter. 5 * 6 * @since bbPress (r4689) 5 7 */ 6 8 class phpBB extends BBP_Converter_Base { 9 10 /** 11 * Main Constructor 12 * 13 * @uses phpBB::setup_globals() 14 */ 7 15 function __construct() { 8 16 parent::__construct(); 9 17 $this->setup_globals(); 10 18 } 11 19 20 /** 21 * Sets up the field mappings 22 */ 23 12 24 public function setup_globals() { 13 25 14 26 /** Forum Section ******************************************************/ 15 27 16 // Forum id . Stored in postmeta.28 // Forum id (Stored in postmeta) 17 29 $this->field_map[] = array( 18 30 'from_tablename' => 'forums', 19 31 'from_fieldname' => 'forum_id', … … class phpBB extends BBP_Converter_Base { 21 33 'to_fieldname' => '_bbp_forum_id' 22 34 ); 23 35 24 // Forum parent id . If no parent, than 0. Stored in postmeta.36 // Forum parent id (If no parent, than 0, Stored in postmeta) 25 37 $this->field_map[] = array( 26 38 'from_tablename' => 'forums', 27 39 'from_fieldname' => 'parent_id', 28 40 'to_type' => 'forum', 29 'to_fieldname' => '_bbp_ parent_id'41 'to_fieldname' => '_bbp_forum_parent_id' 30 42 ); 31 43 44 // Forum topic count (Stored in postmeta) 45 $this->field_map[] = array( 46 'from_tablename' => 'forums', 47 'from_fieldname' => 'forum_topics', 48 'to_type' => 'forum', 49 'to_fieldname' => '_bbp_topic_count' 50 ); 51 52 // Forum reply count (Stored in postmeta) 53 $this->field_map[] = array( 54 'from_tablename' => 'forums', 55 'from_fieldname' => 'forum_posts', 56 'to_type' => 'forum', 57 'to_fieldname' => '_bbp_reply_count' 58 ); 59 60 // Forum total topic count (Includes unpublished topics, Stored in postmeta) 61 $this->field_map[] = array( 62 'from_tablename' => 'forums', 63 'from_fieldname' => 'forum_topics_real', 64 'to_type' => 'forum', 65 'to_fieldname' => '_bbp_total_topic_count' 66 ); 67 32 68 // Forum title. 33 69 $this->field_map[] = array( 34 70 'from_tablename' => 'forums', … … class phpBB extends BBP_Converter_Base { 37 73 'to_fieldname' => 'post_title' 38 74 ); 39 75 40 // Forum slug . Clean name.76 // Forum slug (Clean name to avoid conflicts) 41 77 $this->field_map[] = array( 42 78 'from_tablename' => 'forums', 43 79 'from_fieldname' => 'forum_name', … … class phpBB extends BBP_Converter_Base { 55 91 'callback_method' => 'callback_null' 56 92 ); 57 93 58 // Forum display order . Starts from 1.94 // Forum display order (Starts from 1) 59 95 $this->field_map[] = array( 60 96 'from_tablename' => 'forums', 61 97 'from_fieldname' => 'display_on_index', 62 98 'to_type' => 'forum', 63 99 'to_fieldname' => 'menu_order' 64 100 ); 65 66 // Forum date update.101 102 // Forum status (Locked =1 Unlocked =0, Stored in postmeta) 67 103 $this->field_map[] = array( 68 'to_type' => 'forums', 69 'to_fieldname' => 'forum_last_post_time', 104 'from_tablename' => 'forums', 105 'from_fieldname' => 'forum_status', 106 'to_type' => 'forum', 107 'to_fieldname' => '_bbp_status' 108 ); 109 110 // Forum dates. 111 $this->field_map[] = array( 112 'to_type' => 'forum', 113 'to_fieldname' => 'post_date', 70 114 'default' => date('Y-m-d H:i:s') 71 115 ); 72 116 $this->field_map[] = array( 73 'to_type' => 'forum s',74 'to_fieldname' => ' forum_last_post_time',117 'to_type' => 'forum', 118 'to_fieldname' => 'post_date_gmt', 75 119 'default' => date('Y-m-d H:i:s') 76 120 ); 77 121 $this->field_map[] = array( 78 'to_type' => 'forum s',79 'to_fieldname' => ' forum_last_post_time',122 'to_type' => 'forum', 123 'to_fieldname' => 'post_modified', 80 124 'default' => date('Y-m-d H:i:s') 81 125 ); 82 126 $this->field_map[] = array( 83 'to_type' => 'forum s',84 'to_fieldname' => ' forum_last_post_time',127 'to_type' => 'forum', 128 'to_fieldname' => 'post_modified_gmt', 85 129 'default' => date('Y-m-d H:i:s') 86 130 ); 87 131 88 132 /** Topic Section ******************************************************/ 89 133 90 // Topic id . Stored in postmeta.134 // Topic id (Stored in postmeta) 91 135 $this->field_map[] = array( 92 136 'from_tablename' => 'topics', 93 137 'from_fieldname' => 'topic_id', 94 138 'to_type' => 'topic', 95 139 'to_fieldname' => '_bbp_topic_id' 96 140 ); 97 98 // Forum id. Stored in postmeta. 141 142 // Topic reply count (Stored in postmeta) 143 $this->field_map[] = array( 144 'from_tablename' => 'topics', 145 'from_fieldname' => 'topic_replies', 146 'to_type' => 'topic', 147 'to_fieldname' => '_bbp_reply_count', 148 'callback_method' => 'callback_topic_reply_count' 149 ); 150 151 // Topic total reply count (Includes unpublished replies, Stored in postmeta) 152 $this->field_map[] = array( 153 'from_tablename' => 'topics', 154 'from_fieldname' => 'topic_replies_real', 155 'to_type' => 'topic', 156 'to_fieldname' => '_bbp_total_reply_count', 157 'callback_method' => 'callback_topic_reply_count' 158 ); 159 160 // Topic forum id (Stored in postmeta) 99 161 $this->field_map[] = array( 100 162 'from_tablename' => 'topics', 101 163 'from_fieldname' => 'forum_id', … … class phpBB extends BBP_Converter_Base { 103 165 'to_fieldname' => '_bbp_forum_id', 104 166 'callback_method' => 'callback_forumid' 105 167 ); 106 168 107 169 // Topic author. 108 170 $this->field_map[] = array( 109 171 'from_tablename' => 'topics', … … class phpBB extends BBP_Converter_Base { 114 176 ); 115 177 116 178 // Topic content. 179 // Note: We join the posts table because topics do not have content. 117 180 $this->field_map[] = array( 118 181 'from_tablename' => 'posts', 119 182 'from_fieldname' => 'post_text', … … class phpBB extends BBP_Converter_Base { 123 186 'to_type' => 'topic', 124 187 'to_fieldname' => 'post_content', 125 188 'callback_method' => 'callback_html' 126 ); 189 ); 127 190 128 191 // Topic title. 129 192 $this->field_map[] = array( … … class phpBB extends BBP_Converter_Base { 132 195 'to_type' => 'topic', 133 196 'to_fieldname' => 'post_title' 134 197 ); 135 136 // Topic slug . Clean name.198 199 // Topic slug (Clean name to avoid conflicts) 137 200 $this->field_map[] = array( 138 201 'from_tablename' => 'topics', 139 202 'from_fieldname' => 'topic_title', … … class phpBB extends BBP_Converter_Base { 141 204 'to_fieldname' => 'post_name', 142 205 'callback_method' => 'callback_slug' 143 206 ); 144 145 // Forum id. If no parent, than 0.207 208 // Topic forum id (If no parent, than 0) 146 209 $this->field_map[] = array( 147 210 'from_tablename' => 'topics', 148 211 'from_fieldname' => 'forum_id', … … class phpBB extends BBP_Converter_Base { 180 243 'to_fieldname' => 'post_modified_gmt', 181 244 'callback_method' => 'callback_datetime' 182 245 ); 246 $this->field_map[] = array( 247 'from_tablename' => 'topics', 248 'from_fieldname' => 'topic_last_post_time', 249 'to_type' => 'topic', 250 'to_fieldname' => '_bbp_last_active_time', 251 'callback_method' => 'callback_datetime' 252 ); 183 253 184 254 // Topic status (Open or Closed) 185 255 $this->field_map[] = array( … … class phpBB extends BBP_Converter_Base { 190 260 'callback_method' => 'callback_topic_status' 191 261 ); 192 262 263 // Topic Author ip (Stored in postmeta) 264 $this->field_map[] = array( 265 'from_tablename' => 'posts', 266 'from_fieldname' => 'poster_ip', 267 'join_tablename' => 'topics', 268 'join_type' => 'INNER', 269 'join_expression' => 'USING (topic_id) WHERE posts.post_id = topics.topic_first_post_id', 270 'to_type' => 'topic', 271 'to_fieldname' => '_bbp_author_ip' 272 ); 273 274 // Sticky Status 275 193 276 /** Tags Section ******************************************************/ 194 277 /* 195 278 // Topic id. … … class phpBB extends BBP_Converter_Base { 213 296 ); 214 297 */ 215 298 216 /** Post Section ******************************************************/299 /** Reply Section *****************************************************/ 217 300 218 // Post id . Stored in postmeta.301 // Post id (Stored in postmeta) 219 302 $this->field_map[] = array( 220 303 'from_tablename' => 'posts', 221 304 'from_fieldname' => 'post_id', 222 305 'to_type' => 'reply', 223 306 'to_fieldname' => '_bbp_post_id' 224 307 ); 225 308 226 309 // Topic content. 227 310 $this->field_map[] = array( 228 311 'from_tablename' => 'topics', … … class phpBB extends BBP_Converter_Base { 231 314 'join_type' => 'LEFT', 232 315 'join_expression' => 'USING (topic_id) WHERE posts.post_id != topics.topic_first_post_id', 233 316 'to_type' => 'reply' 234 ); 235 236 // Forum id . Stored in postmeta.317 ); 318 319 // Forum id (Stored in postmeta) 237 320 $this->field_map[] = array( 238 321 'from_tablename' => 'posts', 239 322 'from_fieldname' => 'forum_id', … … class phpBB extends BBP_Converter_Base { 241 324 'to_fieldname' => '_bbp_forum_id', 242 325 'callback_method' => 'callback_topicid_to_forumid' 243 326 ); 244 245 // Topic id . Stored in postmeta.327 328 // Topic id (Stored in postmeta) 246 329 $this->field_map[] = array( 247 330 'from_tablename' => 'posts', 248 331 'from_fieldname' => 'topic_id', … … class phpBB extends BBP_Converter_Base { 250 333 'to_fieldname' => '_bbp_topic_id', 251 334 'callback_method' => 'callback_topicid' 252 335 ); 253 254 // Author ip. Stored in postmeta.336 337 // Reply author ip (Stored in postmeta) 255 338 $this->field_map[] = array( 256 339 'from_tablename' => 'posts', 257 340 'from_fieldname' => 'poster_ip', 258 341 'to_type' => 'reply', 259 342 'to_fieldname' => '_bbp_author_ip' 260 ); 261 262 // Postauthor.343 ); 344 345 // Reply author. 263 346 $this->field_map[] = array( 264 347 'from_tablename' => 'posts', 265 348 'from_fieldname' => 'poster_id', … … class phpBB extends BBP_Converter_Base { 267 350 'to_fieldname' => 'post_author', 268 351 'callback_method' => 'callback_userid' 269 352 ); 270 271 // Topic title .353 354 // Topic title (for reply title). 272 355 $this->field_map[] = array( 273 356 'from_tablename' => 'posts', 274 357 'from_fieldname' => 'post_subject', 275 358 'to_type' => 'reply', 276 359 'to_fieldname' => 'post_title' 277 360 ); 278 279 // Topic slug. Clean name.361 362 // Reply slug (Clean name to avoid conflicts) 280 363 $this->field_map[] = array( 281 364 'from_tablename' => 'posts', 282 365 'from_fieldname' => 'post_subject', … … class phpBB extends BBP_Converter_Base { 284 367 'to_fieldname' => 'post_name', 285 368 'callback_method' => 'callback_slug' 286 369 ); 287 370 288 371 // Post content. 289 372 $this->field_map[] = array( 290 373 'from_tablename' => 'posts', … … class phpBB extends BBP_Converter_Base { 293 376 'to_fieldname' => 'post_content', 294 377 'callback_method' => 'callback_html' 295 378 ); 296 297 // Topic id. If no parent, than 0.379 380 // Parent topic id (If no parent, than 0) 298 381 $this->field_map[] = array( 299 382 'from_tablename' => 'posts', 300 383 'from_fieldname' => 'topic_id', … … class phpBB extends BBP_Converter_Base { 303 386 'callback_method' => 'callback_topicid' 304 387 ); 305 388 306 // Topic date update.389 // Reply dates. 307 390 $this->field_map[] = array( 308 391 'from_tablename' => 'posts', 309 392 'from_fieldname' => 'post_time', … … class phpBB extends BBP_Converter_Base { 335 418 336 419 /** User Section ******************************************************/ 337 420 338 // Store old User id . Stored in usermeta.421 // Store old User id (Stored in usermeta) 339 422 $this->field_map[] = array( 340 423 'from_tablename' => 'users', 341 424 'from_fieldname' => 'user_id', 342 425 'to_type' => 'user', 343 426 'to_fieldname' => '_bbp_user_id' 344 427 ); 345 346 // Store old User password . Stored in usermeta serialized with salt.428 429 // Store old User password (Stored in usermeta serialized with salt) 347 430 $this->field_map[] = array( 348 431 'from_tablename' => 'users', 349 432 'from_fieldname' => 'user_password', … … class phpBB extends BBP_Converter_Base { 352 435 'callback_method' => 'callback_savepass' 353 436 ); 354 437 355 // Store old User Salt . This is only used for the SELECT row info for the above password save438 // Store old User Salt (This is only used for the SELECT row info for the above password save) 356 439 $this->field_map[] = array( 357 440 'from_tablename' => 'users', 358 441 'from_fieldname' => 'user_form_salt', 359 442 'to_type' => 'user', 360 443 'to_fieldname' => '' 361 444 ); 362 363 // User password verify class . Stored in usermeta for verifying password.445 446 // User password verify class (Stored in usermeta for verifying password) 364 447 $this->field_map[] = array( 365 448 'to_type' => 'user', 366 449 'to_fieldname' => '_bbp_class', 367 450 'default' => 'phpBB' 368 451 ); 369 452 370 453 // User name. 371 454 $this->field_map[] = array( 372 455 'from_tablename' => 'users', … … class phpBB extends BBP_Converter_Base { 374 457 'to_type' => 'user', 375 458 'to_fieldname' => 'user_login' 376 459 ); 377 460 378 461 // User email. 379 462 $this->field_map[] = array( 380 463 'from_tablename' => 'users', … … class phpBB extends BBP_Converter_Base { 382 465 'to_type' => 'user', 383 466 'to_fieldname' => 'user_email' 384 467 ); 385 468 386 469 // User homepage. 387 470 $this->field_map[] = array( 388 471 'from_tablename' => 'users', … … class phpBB extends BBP_Converter_Base { 390 473 'to_type' => 'user', 391 474 'to_fieldname' => 'user_url' 392 475 ); 393 476 394 477 // User registered. 395 478 $this->field_map[] = array( 396 479 'from_tablename' => 'users', … … class phpBB extends BBP_Converter_Base { 399 482 'to_fieldname' => 'user_registered', 400 483 'callback_method' => 'callback_datetime' 401 484 ); 402 403 // User aim.485 486 // User AIM (Stored in usermeta) 404 487 $this->field_map[] = array( 405 488 'from_tablename' => 'users', 406 489 'from_fieldname' => 'user_aim', 407 490 'to_type' => 'user', 408 491 'to_fieldname' => 'aim' 409 492 ); 410 411 // User yahoo.493 494 // User Yahoo (Stored in usermeta) 412 495 $this->field_map[] = array( 413 496 'from_tablename' => 'users', 414 497 'from_fieldname' => 'user_yim', 415 498 'to_type' => 'user', 416 499 'to_fieldname' => 'yim' 417 ); 500 ); 501 502 // Store ICQ (Stored in usermeta) 503 $this->field_map[] = array( 504 'from_tablename' => 'users', 505 'from_fieldname' => 'user_icq', 506 'to_type' => 'user', 507 'to_fieldname' => '_bbp_phpbb_user_icq' 508 ); 509 510 // Store MSN (Stored in usermeta) 511 $this->field_map[] = array( 512 'from_tablename' => 'users', 513 'from_fieldname' => 'user_msnm', 514 'to_type' => 'user', 515 'to_fieldname' => '_bbp_phpbb_user_msnm' 516 ); 517 518 // Store Jabber 519 $this->field_map[] = array( 520 'from_tablename' => 'users', 521 'from_fieldname' => 'user_jabber', 522 'to_type' => 'user', 523 'to_fieldname' => 'jabber' 524 ); 525 526 // Store Occupation (Stored in usermeta) 527 $this->field_map[] = array( 528 'from_tablename' => 'users', 529 'from_fieldname' => 'user_occ', 530 'to_type' => 'user', 531 'to_fieldname' => '_bbp_phpbb_user_occ' 532 ); 533 534 // Store Interests (Stored in usermeta) 535 $this->field_map[] = array( 536 'from_tablename' => 'users', 537 'from_fieldname' => 'user_interests', 538 'to_type' => 'user', 539 'to_fieldname' => '_bbp_phpbb_user_interests' 540 ); 541 542 // Store Signature (Stored in usermeta) 543 $this->field_map[] = array( 544 'from_tablename' => 'users', 545 'from_fieldname' => 'user_sig', 546 'to_type' => 'user', 547 'to_fieldname' => '_bbp_phpbb_user_sig', 548 'callback_method' => 'callback_html' 549 ); 550 551 // Store Location (Stored in usermeta) 552 $this->field_map[] = array( 553 'from_tablename' => 'users', 554 'from_fieldname' => 'user_from', 555 'to_type' => 'user', 556 'to_fieldname' => '_bbp_phpbb_user_from' 557 ); 558 559 // Store Avatar Filename (Stored in usermeta) 560 $this->field_map[] = array( 561 'from_tablename' => 'users', 562 'from_fieldname' => 'user_avatar', 563 'to_type' => 'user', 564 'to_fieldname' => '_bbp_phpbb_user_avatar' 565 ); 566 567 // Store old role (Stored in usermeta) 568 418 569 } 419 570 420 571 /** … … class phpBB extends BBP_Converter_Base { 441 592 * @param string $password The password in plain text 442 593 * @param string $hash The stored password hash 443 594 * 595 * @link Original source for password functions http://openwall.com/phpass/ 596 * @link phpass is now included in WP Core http://core.trac.wordpress.org/browser/trunk/wp-includes/class-phpass.php 597 * 444 598 * @return bool Returns true if the password is correct, false if not. 445 599 */ 446 600 public function authenticate_pass($password, $serialized_pass) { 447 601 $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; 448 602 $pass_array = unserialize($serialized_pass); 449 if (strlen($pass_array['hash']) == 34) { 603 if (strlen($pass_array['hash']) == 34) { 450 604 return ($this->_hash_crypt_private($password, $pass_array['hash'], $itoa64) === $pass_array['hash']) ? true : false; 451 605 } 452 606 453 607 return (md5($password) === $pass_array['hash']) ? true : false; 454 608 } 455 609 … … class phpBB extends BBP_Converter_Base { 458 612 */ 459 613 private function _hash_crypt_private($password, $setting, &$itoa64) { 460 614 $output = '*'; 461 615 462 616 // Check for correct hash 463 617 if (substr($setting, 0, 3) != '$H$') { 464 618 return $output; 465 619 } 466 620 467 621 $count_log2 = strpos($itoa64, $setting[3]); 468 622 469 623 if ($count_log2 < 7 || $count_log2 > 30) { 470 624 return $output; 471 625 } 472 626 473 627 $count = 1 << $count_log2; 474 628 $salt = substr($setting, 4, 8); 475 629 476 630 if (strlen($salt) != 8) { 477 631 return $output; 478 632 } 479 633 480 634 /** 481 635 * We're kind of forced to use MD5 here since it's the only 482 636 * cryptographic primitive available in all versions of PHP … … class phpBB extends BBP_Converter_Base { 502 656 503 657 $output = substr($setting, 0, 12); 504 658 $output .= $this->_hash_encode64($hash, 16, $itoa64); 505 659 506 660 return $output; 507 661 } 508 662 509 663 /** 510 664 * Encode hash 511 665 */ 512 666 private function _hash_encode64($input, $count, &$itoa64) { 513 667 $output = ''; 514 668 $i = 0; 515 669 516 670 do { 517 671 $value = ord($input[$i++]); 518 672 $output .= $itoa64[$value & 0x3f]; 519 673 520 674 if ($i < $count) { 521 675 $value |= ord($input[$i]) << 8; 522 676 } 523 677 524 678 $output .= $itoa64[($value >> 6) & 0x3f]; 525 679 526 680 if ($i++ >= $count) { 527 681 break; 528 682 } 529 683 530 684 if ($i < $count) { 531 685 $value |= ord($input[$i]) << 16; 532 686 } 533 687 534 688 $output .= $itoa64[($value >> 12) & 0x3f]; 535 689 536 690 if ($i++ >= $count) { 537 691 break; 538 692 } 539 693 540 694 $output .= $itoa64[($value >> 18) & 0x3f]; 541 695 } 542 696 while ($i < $count); 543 697 544 698 return $output; 545 699 } 546 700 547 701 /** 548 702 * Translate the post status from phpBB numeric's to WordPress's strings. 549 703 * 550 * @param int $status phpBB 3.x numeric topic status704 * @param int $status phpBB v3.x numeric topic status 551 705 * @return string WordPress safe 552 706 */ 553 707 public function callback_topic_status( $status = 0 ) { … … class phpBB extends BBP_Converter_Base { 563 717 } 564 718 return $status; 565 719 } 566 } 720 721 /** 722 * Verify the topic reply count. 723 * 724 * @param int $count phpBB v3.x reply count 725 * @return string WordPress safe 726 */ 727 public function callback_topic_reply_count( $count = 1 ) { 728 $count = absint( (int) $count - 1 ); 729 return $count; 730 } 731 732 /** 733 * This callback processes any custom parser.php attributes and custom code with preg_replace 734 */ 735 protected function callback_html( $field ) { 736 737 // Strips custom phpBB 'magic_url' and 'bbcode_uid' first from $field before parsing $field to parser.php 738 $phpbb_uid = $field; 739 $phpbb_uid = html_entity_decode ( $phpbb_uid ); 740 741 // Replace '[b:XXXXXXX]' with '<strong>' 742 $phpbb_uid = preg_replace ( '/\[b:(.*?)\]/' , '<strong>' , $phpbb_uid ); 743 // Replace '[/b:XXXXXXX]' with '</strong>' 744 $phpbb_uid = preg_replace ( '/\[\/b:(.*?)\]/' , '</strong>' , $phpbb_uid ); 745 746 // Replace '[i:XXXXXXX]' with '<em>' 747 $phpbb_uid = preg_replace ( '/\[i:(.*?)\]/' , '<em>' , $phpbb_uid ); 748 // Replace '[/i:XXXXXXX]' with '</em>' 749 $phpbb_uid = preg_replace ( '/\[\/i:(.*?)\]/' , '</em>' , $phpbb_uid ); 750 751 // Replace '[u:XXXXXXX]' with '<u>' 752 $phpbb_uid = preg_replace ( '/\[u:(.*?)\]/' , '<u>' , $phpbb_uid ); 753 // Replace '[/u:XXXXXXX]' with '</u>' 754 $phpbb_uid = preg_replace ( '/\[\/u:(.*?)\]/' , '</u>' , $phpbb_uid ); 755 756 // Replace '[quote:XXXXXXX]' with '<blockquote>' 757 $phpbb_uid = preg_replace ( '/\[quote:(.*?)\]/' , '<blockquote>' , $phpbb_uid ); 758 // Replace '[quote="$1"]' with '<em>$1 wrote:</em><blockquote>" 759 $phpbb_uid = preg_replace ( '/\[quote="(.*?)":(.*?)\]/' , '<em>@$1 wrote:</em><blockquote>' , $phpbb_uid ); 760 // Replace '[/quote:XXXXXXX]' with '</blockquote>' 761 $phpbb_uid = preg_replace ( '/\[\/quote:(.*?)\]/' , '</blockquote>' , $phpbb_uid ); 762 763 // Replace '[img:XXXXXXX]' with '<img src="' 764 $phpbb_uid = preg_replace ( '/\[img:(.*?)\]/' , '<img src="' , $phpbb_uid ); 765 // Replace '[/img:XXXXXXX]' with ' alt="">' 766 $phpbb_uid = preg_replace ( '/\[\/img:(.*?)\]/' , '" alt="">' , $phpbb_uid ); 767 768 // Replace '<!-- s$1 --><img src=\"{SMILIES_PATH}$2 -->' with '$1' 769 $phpbb_uid = preg_replace ( '/<!-- s(.*?) --><img src=\"{SMILIES_PATH}(.*?)-->/' , '$1' , $phpbb_uid ); 770 771 // Replace '<!-- m --><a class="postlink" href="$1">$1</a><!-- m -->' with '$1' 772 $phpbb_uid = preg_replace ( '/\<!-- m --\>\<a class="postlink" href="([^\[]+?)"\>([^\[]+?)\<\/a\>\<!-- m --\>/' , '$1' , $phpbb_uid ); 773 774 // Replace '[url:XXXXXXX]$1[/url:XXXXXXX]' with '<a href="http://$1">$1</a>' 775 $phpbb_uid = preg_replace ( '/\[url:(?:[^\]]+)\]([^\[]+?)\[\/url:(?:[^\]]+)\]/' , '<a href="http://$1">$1</a>' , $phpbb_uid ); 776 // Replace '[url=http://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>' 777 $phpbb_uid = preg_replace ( '/\[url\=http\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i' , '<a href="http://$1">$3</a>' , $phpbb_uid ); 778 // Replace '[url=https://$1:XXXXXXX]$3[/url:XXXXXXX]' with '<a href="http://$1">$3</a>' 779 $phpbb_uid = preg_replace ( '/\[url\=https\:\/\/(.*?)\:(.*?)\](.*?)\[\/url:(.*?)\]/i' , '<a href="https://$1">$3</a>' , $phpbb_uid ); 780 781 // Replace '[email:XXXXXXX]' with '<a href="mailto:$2">$2</a>' 782 $phpbb_uid = preg_replace ( '/\[email:(.*?)\](.*?)\[\/email:(.*?)\]/' , '<a href="mailto:$2">$2</a>' , $phpbb_uid ); 783 // Replace '<!-- e -->no.one@domain.adr<!-- e -->' with '$1' 784 $phpbb_uid = preg_replace ( '/\<!-- e --\>(.*?)\<!-- e --\>/' , '$1' , $phpbb_uid ); 785 786 // Replace '[code:XXXXXXX]' with '<pre><code>' 787 $phpbb_uid = preg_replace ( '/\[code:(.*?)\]/' , '<pre><code>' , $phpbb_uid ); 788 // Replace '[/code:XXXXXXX]' with '</code></pre>' 789 $phpbb_uid = preg_replace ( '/\[\/code:(.*?)\]/' , '</code></pre>' , $phpbb_uid ); 790 791 // Replace '[color=$1:XXXXXXXX]' with '<span style="color:$1">' 792 $phpbb_uid = preg_replace ( '/\[color=(.*?)\:(.*?)\]/' , '<span style="color: $1">' , $phpbb_uid ); 793 // Replace '[/color:XXXXXXX]' with '</span>' 794 $phpbb_uid = preg_replace ( '/\[\/color:(.*?)\]/' , '</span>' , $phpbb_uid ); 795 796 // Replace '[size=$1:XXXXXXXX]' with '<span style="font-size:$1%;">$3</span>' 797 $phpbb_uid = preg_replace ( '/\[size=(.*?):(.*?)\]/' , '<span style="font-size:$1%;">' , $phpbb_uid ); 798 // Replace '[/size:XXXXXXX]' with '' 799 $phpbb_uid = preg_replace ( '/\[\/size:(.*?)\]/' , '</span>' , $phpbb_uid ); 800 801 // Replace '[list:XXXXXXX]' with '<ul>' 802 $phpbb_uid = preg_replace ( '/\[list:(.*?)\]/' , '<ul>' , $phpbb_uid ); 803 // Replace '[list=a:XXXXXXX]' with '<ol type="a">' 804 $phpbb_uid = preg_replace ( '/\[list=a:(.*?)\]/' , '<ol type="a">' , $phpbb_uid ); 805 // Replace '[list=1:XXXXXXX]' with '<ol>' 806 $phpbb_uid = preg_replace ( '/\[list=1:(.*?)\]/' , '<ol>' , $phpbb_uid ); 807 // Replace '[*:XXXXXXX]' with '<li>' 808 $phpbb_uid = preg_replace ( '/\[\*:(.*?)\]/' , '<li>' , $phpbb_uid ); 809 // Replace '[/*:m:XXXXXXX]' with '</li>' 810 $phpbb_uid = preg_replace ( '/\[\/\*:m:(.*?)\]/' , '</li>' , $phpbb_uid ); 811 // Replace '[/list:u:XXXXXXX]' with '</ul>' 812 $phpbb_uid = preg_replace ( '/\[\/list:u:(.*?)\]/' , '</ul>' , $phpbb_uid ); 813 // Replace '[/list:o:XXXXXXX]' with '</ol>' 814 $phpbb_uid = preg_replace ( '/\[\/list:o:(.*?)\]/' , '</ol>' , $phpbb_uid ); 815 816 // Now that phpBB's 'magic_url' and 'bbcode_uid' have been stripped put the cleaned HTML back in $field 817 $field = $phpbb_uid; 818 819 // Parse out any bbCodes in $field with the BBCode 'parser.php' 820 require_once( bbpress()->admin->admin_dir . 'parser.php' ); 821 $bbcode = BBCode::getInstance(); 822 $bbcode->enable_smileys = false; 823 $bbcode->smiley_regex = false; 824 return html_entity_decode( $bbcode->Parse( $field ) ); 825 826 } 827 } 828 No newline at end of file