Changeset 4703
- Timestamp:
- 01/22/2013 05:09:51 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/admin/converters/phpBB.php
r4627 r4703 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(); … … 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', … … 21 33 'to_fieldname' => '_bbp_forum_id' 22 34 ); 23 24 // Forum parent id . If no parent, than 0. Stored in postmeta.35 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' 30 ); 31 41 'to_fieldname' => '_bbp_forum_parent_id' 42 ); 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( … … 37 73 'to_fieldname' => 'post_title' 38 74 ); 39 40 // Forum slug . Clean name.75 76 // Forum slug (Clean name to avoid conflicts) 41 77 $this->field_map[] = array( 42 78 'from_tablename' => 'forums', … … 46 82 'callback_method' => 'callback_slug' 47 83 ); 48 84 49 85 // Forum description. 50 86 $this->field_map[] = array( … … 55 91 'callback_method' => 'callback_null' 56 92 ); 57 58 // Forum display order . Starts from 1.93 94 // Forum display order (Starts from 1) 59 95 $this->field_map[] = array( 60 96 'from_tablename' => 'forums', … … 63 99 'to_fieldname' => 'menu_order' 64 100 ); 65 66 // Forum date update. 67 $this->field_map[] = array( 68 'to_type' => 'forums', 69 'to_fieldname' => 'forum_last_post_time', 101 102 // Forum status (Locked =1 Unlocked =0, Stored in postmeta) 103 $this->field_map[] = array( 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 ); … … 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', … … 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', … … 104 166 'callback_method' => 'callback_forumid' 105 167 ); 106 168 107 169 // Topic author. 108 170 $this->field_map[] = array( … … 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', … … 124 187 'to_fieldname' => 'post_content', 125 188 'callback_method' => 'callback_html' 126 ); 189 ); 127 190 128 191 // Topic title. … … 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', … … 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', … … 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) … … 190 260 'callback_method' => 'callback_topic_status' 191 261 ); 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 192 275 193 276 /** Tags Section ******************************************************/ … … 201 284 'callback_method' => 'callback_topicid' 202 285 ); 203 286 204 287 // Tags text. 205 288 $this->field_map[] = array( … … 211 294 'to_type' => 'tags', 212 295 'to_fieldname' => 'name' 213 ); 296 ); 214 297 */ 215 216 /** Post Section ******************************************************/217 218 // Post id . Stored in postmeta.298 299 /** Reply Section *****************************************************/ 300 301 // Post id (Stored in postmeta) 219 302 $this->field_map[] = array( 220 303 'from_tablename' => 'posts', … … 223 306 'to_fieldname' => '_bbp_post_id' 224 307 ); 225 308 226 309 // Topic content. 227 310 $this->field_map[] = array( … … 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', … … 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', … … 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', … … 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', … … 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', … … 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', … … 285 368 'callback_method' => 'callback_slug' 286 369 ); 287 370 288 371 // Post content. 289 372 $this->field_map[] = array( … … 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', … … 304 387 ); 305 388 306 // Topic date update.389 // Reply dates. 307 390 $this->field_map[] = array( 308 391 'from_tablename' => 'posts', … … 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', … … 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', … … 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', … … 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', … … 367 450 'default' => 'phpBB' 368 451 ); 369 452 370 453 // User name. 371 454 $this->field_map[] = array( … … 375 458 'to_fieldname' => 'user_login' 376 459 ); 377 460 378 461 // User email. 379 462 $this->field_map[] = array( … … 383 466 'to_fieldname' => 'user_email' 384 467 ); 385 468 386 469 // User homepage. 387 470 $this->field_map[] = array( … … 391 474 'to_fieldname' => 'user_url' 392 475 ); 393 476 394 477 // User registered. 395 478 $this->field_map[] = array( … … 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', … … 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', … … 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) 418 568 } 419 569 … … 432 582 */ 433 583 public function callback_savepass( $field, $row ) { 434 $pass_array = array('hash' => $field, 'salt' => $row['salt']); 435 return $pass_array; 436 } 437 584 return array( 585 'hash' => $field, 586 'salt' => $row['salt'] 587 ); 588 } 589 438 590 /** 439 591 * Check for correct password … … 442 594 * @param string $hash The stored password hash 443 595 * 596 * @link Original source for password functions http://openwall.com/phpass/ 597 * @link phpass is now included in WP Core http://core.trac.wordpress.org/browser/trunk/wp-includes/class-phpass.php 598 * 444 599 * @return bool Returns true if the password is correct, false if not. 445 600 */ 446 public function authenticate_pass( $password, $serialized_pass) {601 public function authenticate_pass( $password, $serialized_pass ) { 447 602 $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; 448 $pass_array = unserialize( $serialized_pass);449 if ( strlen($pass_array['hash']) == 34) {450 return ( $this->_hash_crypt_private($password, $pass_array['hash'], $itoa64) === $pass_array['hash']) ? true : false;603 $pass_array = unserialize( $serialized_pass ); 604 if ( strlen( $pass_array['hash'] ) == 34 ) { 605 return ( $this->_hash_crypt_private( $password, $pass_array['hash'], $itoa64 ) === $pass_array['hash'] ) ? true : false; 451 606 } 452 453 return ( md5($password) === $pass_array['hash']) ? true : false;454 } 455 607 608 return ( md5( $password ) === $pass_array['hash'] ) ? true : false; 609 } 610 456 611 /** 457 612 * The crypt function/replacement 458 613 */ 459 private function _hash_crypt_private( $password, $setting, &$itoa64) {614 private function _hash_crypt_private( $password, $setting, &$itoa64 ) { 460 615 $output = '*'; 461 616 462 617 // Check for correct hash 463 if ( substr($setting, 0, 3) != '$H$') {618 if ( substr( $setting, 0, 3 ) != '$H$' ) { 464 619 return $output; 465 620 } 466 467 $count_log2 = strpos( $itoa64, $setting[3]);468 469 if ( $count_log2 < 7 || $count_log2 > 30) {621 622 $count_log2 = strpos( $itoa64, $setting[3] ); 623 624 if ( $count_log2 < 7 || $count_log2 > 30 ) { 470 625 return $output; 471 626 } 472 627 473 628 $count = 1 << $count_log2; 474 $salt = substr($setting, 4, 8);475 476 if ( strlen($salt) != 8) {629 $salt = substr( $setting, 4, 8 ); 630 631 if ( strlen( $salt ) != 8 ) { 477 632 return $output; 478 633 } 479 634 480 635 /** 481 636 * We're kind of forced to use MD5 here since it's the only … … 486 641 * quicker to crack (by non-PHP code). 487 642 */ 488 if ( floatval(phpversion()) >= 5) {489 $hash = md5( $salt . $password, true);643 if ( floatval( phpversion() ) >= 5 ) { 644 $hash = md5( $salt . $password, true ); 490 645 do 491 646 { 492 $hash = md5( $hash . $password, true);647 $hash = md5( $hash . $password, true ); 493 648 } 494 while ( --$count);649 while ( --$count ); 495 650 } else { 496 $hash = pack( 'H*', md5($salt . $password));651 $hash = pack( 'H*', md5( $salt . $password ) ); 497 652 do { 498 $hash = pack( 'H*', md5($hash . $password));653 $hash = pack( 'H*', md5( $hash . $password ) ); 499 654 } 500 while ( --$count);655 while ( --$count ); 501 656 } 502 657 503 658 $output = substr($setting, 0, 12); 504 659 $output .= $this->_hash_encode64($hash, 16, $itoa64); 505 660 506 661 return $output; 507 662 } 508 663 509 664 /** 510 665 * Encode hash 511 666 */ 512 private function _hash_encode64( $input, $count, &$itoa64) {667 private function _hash_encode64( $input, $count, &$itoa64 ) { 513 668 $output = ''; 514 669 $i = 0; 515 670 516 671 do { 517 $value = ord( $input[$i++]);672 $value = ord( $input[$i++] ); 518 673 $output .= $itoa64[$value & 0x3f]; 519 674 520 675 if ($i < $count) { 521 $value |= ord( $input[$i]) << 8;676 $value |= ord( $input[$i] ) << 8; 522 677 } 523 524 $output .= $itoa64[( $value >> 6) & 0x3f];525 526 if ( $i++ >= $count) {678 679 $output .= $itoa64[( $value >> 6 ) & 0x3f]; 680 681 if ( $i++ >= $count ) { 527 682 break; 528 683 } 529 530 if ( $i < $count) {531 $value |= ord( $input[$i]) << 16;684 685 if ( $i < $count ) { 686 $value |= ord( $input[$i] ) << 16; 532 687 } 533 534 $output .= $itoa64[( $value >> 12) & 0x3f];535 536 if ( $i++ >= $count) {688 689 $output .= $itoa64[( $value >> 12 ) & 0x3f]; 690 691 if ( $i++ >= $count ) { 537 692 break; 538 693 } 539 694 540 695 $output .= $itoa64[($value >> 18) & 0x3f]; 541 } 542 while ($i < $count); 543 696 } while ( $i < $count ); 697 544 698 return $output; 545 699 } … … 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 */ … … 564 718 return $status; 565 719 } 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 } 566 826 }
Note: See TracChangeset
for help on using the changeset viewer.