Changeset 472197
- Timestamp:
- 12/07/2011 09:36:25 PM (14 years ago)
- Location:
- bbconverter/trunk
- Files:
-
- 8 edited
-
bbc-convert/Example.php (modified) (1 diff)
-
bbc-convert/Invision.php (modified) (3 diffs)
-
bbc-convert/Standalonebbpress.php (modified) (3 diffs)
-
bbc-convert/Vbulletin.php (modified) (3 diffs)
-
bbc-includes/bbc-converter-class.php (modified) (15 diffs)
-
bbc-includes/bbc-settings.php (modified) (2 diffs)
-
bbconverter.php (modified) (6 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bbconverter/trunk/bbc-convert/Example.php
r444891 r472197 5 5 Description: Convert Example forum software into bbpress. 6 6 Author: Adam Ellis 7 Version: 1. 17 Version: 1.2 8 8 Author URI: http://www.bbconverter.com/ 9 9 */ -
bbconverter/trunk/bbc-convert/Invision.php
r444891 r472197 5 5 Description: Convert Invision Power Board forum software into bbpress. 6 6 Author: Adam Ellis 7 Version: 1. 17 Version: 1.2 8 8 Author URI: http://www.bbconverter.com/ 9 9 */ … … 106 106 'translate_method' => 'translate_userid' 107 107 ); 108 109 // Topic content. 110 $this->field_map[] = array( 111 'from_tablename' => 'posts', 'from_fieldname' => 'post', 112 'join_tablename' => 'topics', 'join_type' => 'INNER', 'join_expression' => 'ON(topics.tid = posts.topic_id) WHERE posts.new_topic = 1', 113 'to_type' => 'topic', 'to_fieldname' => 'post_content', 114 'translate_method' => 'translate_html' 115 ); 108 116 109 117 // Topic title. … … 168 176 // Post id. Stores in postmeta. 169 177 $this->field_map[] = array( 170 'from_tablename' => 'posts', 'from_fieldname' => 'pid', 178 'from_tablename' => 'posts', 'from_fieldname' => 'pid', 'from_expression' => 'WHERE posts.new_topic = 1', 171 179 'to_type' => 'reply', 'to_fieldname' => '_bbc_post_id' 172 180 ); -
bbconverter/trunk/bbc-convert/Standalonebbpress.php
r444891 r472197 5 5 Description: Convert bbPress Stand Alone forum software into bbpress plugin. 6 6 Author: Adam Ellis 7 Version: 1. 17 Version: 1.2 8 8 Author URI: http://www.bbconverter.com/ 9 9 */ … … 107 107 ); 108 108 109 // Topic content. 110 $this->field_map[] = array( 111 'from_tablename' => 'posts', 'from_fieldname' => 'post_text', 112 'join_tablename' => 'topics', 'join_type' => 'INNER', 'join_expression' => 'USING (topic_id) WHERE posts.post_position = 1', 113 'to_type' => 'topic', 'to_fieldname' => 'post_content', 114 'translate_method' => 'translate_html' 115 ); 116 109 117 // Topic title. 110 118 $this->field_map[] = array( … … 172 180 // Post id. Stores in postmeta. 173 181 $this->field_map[] = array( 174 'from_tablename' => 'posts', 'from_fieldname' => 'post_id', 182 'from_tablename' => 'posts', 'from_fieldname' => 'post_id', 'from_expression' => 'WHERE posts.post_position != 1', 175 183 'to_type' => 'reply', 'to_fieldname' => '_bbc_post_id' 176 184 ); -
bbconverter/trunk/bbc-convert/Vbulletin.php
r444891 r472197 5 5 Description: Convert vBulletin forum software into bbpress. 6 6 Author: Adam Ellis 7 Version: 1. 17 Version: 1.2 8 8 Author URI: http://www.bbconverter.com/ 9 9 */ … … 106 106 'translate_method' => 'translate_userid' 107 107 ); 108 108 109 // Topic content. 110 $this->field_map[] = array( 111 'from_tablename' => 'post', 'from_fieldname' => 'pagetext', 112 'join_tablename' => 'thread', 'join_type' => 'INNER', 'join_expression' => 'USING (threadid) WHERE post.parentid = 0', 113 'to_type' => 'topic', 'to_fieldname' => 'post_content', 114 'translate_method' => 'translate_html' 115 ); 116 109 117 // Topic title. 110 118 $this->field_map[] = array( … … 169 177 // Post id. Stores in postmeta. 170 178 $this->field_map[] = array( 171 'from_tablename' => 'post', 'from_fieldname' => 'postid', 179 'from_tablename' => 'post', 'from_fieldname' => 'postid', 'from_expression' => 'WHERE post.parentid != 0', 172 180 'to_type' => 'reply', 'to_fieldname' => '_bbc_post_id' 173 181 ); -
bbconverter/trunk/bbc-includes/bbc-converter-class.php
r444891 r472197 5 5 Description: bbConverter Class 6 6 Author: Adam Ellis 7 Version: 1. 17 Version: 1.2 8 8 Author URI: http://www.bbconverter.com/ 9 9 */ … … 87 87 */ 88 88 private $map_userid = array(); 89 89 90 /** 91 * @var str This is the charset for your wp database. 92 */ 93 public $charset; 94 95 /** 96 * @var boolean Sync table available. 97 */ 98 public $sync_table = false; 99 100 /** 101 * @var str Sync table name. 102 */ 103 public $sync_table_name; 104 90 105 /** 91 106 * This is the constructor and it connects to the platform databases. … … 106 121 $this->opdb = new wpdb( $_POST['_bbc_dbuser'], $_POST['_bbc_dbpass'], $_POST['_bbc_dbname'], $_POST['_bbc_dbserver'] ); 107 122 $this->opdb->prefix = $_POST['_bbc_dbprefix']; 123 124 /** 125 * Error Reporting 126 */ 108 127 $this->wpdb->show_errors(); 109 128 $this->opdb->show_errors(); 110 129 130 /** 131 * Syncing 132 */ 133 $this->sync_table_name = $this->wpdb->prefix . "bbconverter_translator"; 134 if( $this->wpdb->get_var( "SHOW TABLES LIKE '" . $this->sync_table_name . "'" ) == $this->sync_table_name ) 135 { 136 $this->sync_table = true; 137 } 138 else 139 { 140 $this->sync_table = false; 141 } 142 143 /** 144 * Charset 145 */ 146 if( empty( $this->wpdb->charset ) ) 147 { 148 $this->charset = "UTF8"; 149 } 150 else 151 { 152 $this->charset = $this->wpdb->charset; 153 } 154 111 155 /** 112 156 * Default mapping. … … 247 291 public function convert_table( $to_type, $start ) 248 292 { 293 if( $this->wpdb->get_var( "SHOW TABLES LIKE '" . $this->sync_table_name . "'" ) == $this->sync_table_name ) 294 { 295 $this->sync_table = true; 296 } 297 else 298 { 299 $this->sync_table = false; 300 } 249 301 $has_insert = false; 250 302 $from_tablename = ''; … … 273 325 if( !in_array( $item['from_tablename'], $from_tables ) && in_array( $item['join_tablename'], $from_tables ) ) 274 326 { 275 $from_tablename .= ' ' . $item['join_type'] . ' JOIN ' . $this->opdb->prefix . $item['from_tablename'] . ' ' . $item['join_expression'];327 $from_tablename .= ' ' . $item['join_type'] . ' JOIN ' . $this->opdb->prefix . $item['from_tablename'] . ' AS ' . $item['from_tablename'] . ' ' . $item['join_expression']; 276 328 } 277 329 } 278 330 else 279 331 { 280 $from_tablename = $item['from_tablename']; 281 } 332 $from_tablename = $item['from_tablename'] . ' AS ' . $item['from_tablename']; 333 } 334 if( $item['from_expression'] ) 335 { 336 if( stripos( $from_tablename, "WHERE" ) === FALSE ) 337 { 338 $from_tablename .= ' ' . $item['from_expression']; 339 } 340 else 341 { 342 $from_tablename .= ' ' . str_replace( "WHERE", "AND", $item['from_expression'] ); 343 } 344 } 282 345 $from_tables[] = $item['from_tablename']; 283 $field_list[] = 'convert(' . $item['from_ fieldname'] . ' USING "UTF8") AS ' . $item['from_fieldname'];346 $field_list[] = 'convert(' . $item['from_tablename'] . '.' . $item['from_fieldname'] . ' USING "' . $this->charset . '") AS ' . $item['from_fieldname']; 284 347 } 285 348 } … … 360 423 foreach( $insert_postmeta as $key => $value ) 361 424 { 362 add_user_meta( $post_id, $key, $value, true ); 425 //add_user_meta( $post_id, $key, $value, true ); 426 if( substr( $key, -3 ) == "_id" && $this->sync_table === true ) 427 { 428 $this->wpdb->insert( $this->sync_table_name, array( 'value_type' => 'user', 'value_id' => $post_id, 'meta_key' => $key, 'meta_value' => $value ) ); 429 } 430 else 431 { 432 add_user_meta( $post_id, $key, $value, true ); 433 } 363 434 } 364 435 } … … 373 444 foreach( $insert_postmeta as $key => $value ) 374 445 { 375 add_post_meta( $post_id, $key, $value, true ); 446 //add_post_meta( $post_id, $key, $value, true ); 447 if( substr( $key, -3 ) == "_id" && $this->sync_table === true ) 448 { 449 $this->wpdb->insert( $this->sync_table_name, array( 'value_type' => 'post', 'value_id' => $post_id, 'meta_key' => $key, 'meta_value' => $value ) ); 450 } 451 else 452 { 453 add_post_meta( $post_id, $key, $value, true ); 454 } 376 455 } 377 456 } … … 384 463 return !$has_insert; 385 464 } 386 465 387 466 public function convert_forum_parents( $start ) 388 467 { 389 468 $has_update = false; 390 $forum_array = $this->wpdb->get_results( 'SELECT post_id, meta_value FROM ' . $this->wpdb->postmeta . 391 ' WHERE meta_key = "_bbc_parent_id" AND meta_value > 0 LIMIT ' . $start . ', ' . $this->max_rows ); 469 if( $this->sync_table ) 470 { 471 $forum_array = $this->wpdb->get_results( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . 472 ' WHERE meta_key = "_bbc_parent_id" AND meta_value > 0 LIMIT ' . $start . ', ' . $this->max_rows ); 473 } 474 else 475 { 476 $forum_array = $this->wpdb->get_results( 'SELECT post_id AS value_id, meta_value FROM ' . $this->wpdb->postmeta . 477 ' WHERE meta_key = "_bbc_parent_id" AND meta_value > 0 LIMIT ' . $start . ', ' . $this->max_rows ); 478 } 392 479 foreach( $forum_array as $row ) 393 480 { 394 481 $parent_id = $this->translate_forumid( $row->meta_value ); 395 482 $this->wpdb->query( 'UPDATE ' . $this->wpdb->posts . ' SET post_parent = "' . 396 $parent_id . '" WHERE ID = "' . $row-> post_id . '" LIMIT 1' );483 $parent_id . '" WHERE ID = "' . $row->value_id . '" LIMIT 1' ); 397 484 $has_update = true; 398 485 } … … 409 496 /** Delete bbconverter topics/forums/posts ****************************/ 410 497 411 $bbconverter = $this->wpdb->get_results( 'SELECT post_id FROM ' . $this->wpdb->postmeta . ' WHERE meta_key LIKE "_bbc_%" GROUP BY post_id LIMIT ' . $this->max_rows, ARRAY_A ); 498 if( $this->sync_table === true ) 499 { 500 $bbconverter = $this->wpdb->get_results( 'SELECT value_id FROM ' . $this->sync_table_name . ' INNER JOIN ' . $this->wpdb->posts . ' ON(value_id = ID)WHERE meta_key LIKE "_bbc_%" AND value_type = "post" GROUP BY value_id ORDER BY value_id DESC LIMIT ' . $this->max_rows, ARRAY_A ); 501 } 502 else 503 { 504 $bbconverter = $this->wpdb->get_results( 'SELECT post_id as value_id FROM ' . $this->wpdb->postmeta . ' WHERE meta_key LIKE "_bbc_%" GROUP BY post_id ORDER BY post_id DESC LIMIT ' . $this->max_rows, ARRAY_A ); 505 } 506 412 507 if( $bbconverter ) 413 508 { 414 509 foreach( $bbconverter as $value ) 415 510 { 416 wp_delete_post( $value[' post_id'], true );511 wp_delete_post( $value['value_id'], true ); 417 512 } 418 513 $has_delete = true; … … 420 515 421 516 /** Delete bbconverter users ******************************************/ 422 423 $bbconverter = $this->wpdb->get_results( 'SELECT user_id FROM ' . $this->wpdb->usermeta . ' WHERE meta_key = "_bbc_user_id" LIMIT ' . $this->max_rows, ARRAY_A ); 517 518 if( $this->sync_table === true ) 519 { 520 $bbconverter = $this->wpdb->get_results( 'SELECT value_id FROM ' . $this->sync_table_name . ' INNER JOIN ' . $this->wpdb->users . ' ON(value_id = ID) WHERE meta_key = "_bbc_user_id" AND value_type = "user" LIMIT ' . $this->max_rows, ARRAY_A ); 521 } 522 else 523 { 524 $bbconverter = $this->wpdb->get_results( 'SELECT user_id as value_id FROM ' . $this->wpdb->usermeta . ' WHERE meta_key = "_bbc_user_id" LIMIT ' . $this->max_rows, ARRAY_A ); 525 } 526 424 527 if( $bbconverter ) 425 528 { 426 529 foreach( $bbconverter as $value ) 427 530 { 428 wp_delete_user( $value[' user_id'] );531 wp_delete_user( $value['value_id'] ); 429 532 } 430 533 $has_delete = true; 431 534 } 535 432 536 return !$has_delete; 433 537 } … … 527 631 if( !isset( $this->map_forumid[$field] ) ) //This is a mini cache system to reduce database calls. 528 632 { 529 $row = $this->wpdb->get_row( 'SELECT post_id FROM ' . $this->wpdb->postmeta . 530 ' WHERE meta_key = "_bbc_forum_id" AND meta_value = "' . $field . 531 '" LIMIT 1' ); 633 if( $this->sync_table ) 634 { 635 $row = $this->wpdb->get_row( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . 636 ' WHERE meta_key = "_bbc_forum_id" AND meta_value = "' . $field . 637 '" LIMIT 1' ); 638 } 639 else 640 { 641 $row = $this->wpdb->get_row( 'SELECT post_id AS value_id FROM ' . $this->wpdb->postmeta . 642 ' WHERE meta_key = "_bbc_forum_id" AND meta_value = "' . $field . 643 '" LIMIT 1' ); 644 } 532 645 if( !is_null( $row ) ) 533 646 { 534 $this->map_forumid[$field] = $row-> post_id;647 $this->map_forumid[$field] = $row->value_id; 535 648 } 536 649 else … … 546 659 if( !isset( $this->map_topicid[$field] ) ) //This is a mini cache system to reduce database calls. 547 660 { 548 $row = $this->wpdb->get_row( 'SELECT post_id FROM ' . $this->wpdb->postmeta . 549 ' WHERE meta_key = "_bbc_topic_id" AND meta_value = "' . $field . 550 '" LIMIT 1' ); 661 if( $this->sync_table ) 662 { 663 $row = $this->wpdb->get_row( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . 664 ' WHERE meta_key = "_bbc_topic_id" AND meta_value = "' . $field . 665 '" LIMIT 1' ); 666 } 667 else 668 { 669 $row = $this->wpdb->get_row( 'SELECT post_id AS value_id FROM ' . $this->wpdb->postmeta . 670 ' WHERE meta_key = "_bbc_topic_id" AND meta_value = "' . $field . 671 '" LIMIT 1' ); 672 } 551 673 if( !is_null( $row ) ) 552 674 { 553 $this->map_topicid[$field] = $row-> post_id;675 $this->map_topicid[$field] = $row->value_id; 554 676 } 555 677 else … … 565 687 if( !isset( $this->map_userid[$field] ) ) //This is a mini cache system to reduce database calls. 566 688 { 567 $row = $this->wpdb->get_row( 'SELECT user_id FROM ' . $this->wpdb->usermeta . 568 ' WHERE meta_key = "_bbc_user_id" AND meta_value = "' . $field . 569 '" LIMIT 1' ); 689 if( $this->sync_table ) 690 { 691 $row = $this->wpdb->get_row( 'SELECT value_id, meta_value FROM ' . $this->sync_table_name . 692 ' WHERE meta_key = "_bbc_user_id" AND meta_value = "' . $field . 693 '" LIMIT 1' ); 694 } 695 else 696 { 697 $row = $this->wpdb->get_row( 'SELECT user_id AS value_id FROM ' . $this->wpdb->usermeta . 698 ' WHERE meta_key = "_bbc_user_id" AND meta_value = "' . $field . 699 '" LIMIT 1' ); 700 } 570 701 if( !is_null( $row ) ) 571 702 { 572 $this->map_userid[$field] = $row-> user_id;703 $this->map_userid[$field] = $row->value_id; 573 704 } 574 705 else … … 590 721 { 591 722 $topicid = $this->translate_topicid( $field ); 592 if( !isset( $this->map_topicid_to_forumid[$field] ) ) //This is a mini cache system to reduce database calls. 723 if( $topicid == 0 ) 724 { 725 $this->map_topicid_to_forumid[$topicid] = 0; 726 } 727 else if( !isset( $this->map_topicid_to_forumid[$topicid] ) ) //This is a mini cache system to reduce database calls. 593 728 { 594 729 $row = $this->wpdb->get_row( … … 597 732 if( !is_null( $row ) ) 598 733 { 599 $this->map_topicid_to_forumid[$ field] = $row->post_parent;734 $this->map_topicid_to_forumid[$topicid] = $row->post_parent; 600 735 } 601 736 else 602 737 { 603 $this->map_topicid_to_forumid[$ field] = 0;604 } 605 } 606 return $this->map_topicid_to_forumid[$ field];738 $this->map_topicid_to_forumid[$topicid] = 0; 739 } 740 } 741 return $this->map_topicid_to_forumid[$topicid]; 607 742 } 608 743 -
bbconverter/trunk/bbc-includes/bbc-settings.php
r444891 r472197 5 5 Description: bbConverter Admin Settings 6 6 Author: Adam Ellis 7 Version: 1. 17 Version: 1.2 8 8 Author URI: http://www.bbconverter.com/ 9 9 */ … … 233 233 <div class="bbc-note"> 234 234 <h3>Note:</h3> 235 For NON bbpress 1x conversions:<br/> 235 236 It is not possible to convert passwords during the conversion process. You must leave the conversion plugin active to convert passwords as people log in. It will validate using their old password and convert to wordpress encryption. 236 237 </div> -
bbconverter/trunk/bbconverter.php
r444891 r472197 5 5 Description: bbConverter is a system that allows you to convert from many different forum software into bbpress. 6 6 Author: Adam Ellis 7 Version: 1. 17 Version: 1.2 8 8 Author URI: http://www.bbconverter.com/ 9 9 */ … … 23 23 * @public string bbConverter version 24 24 */ 25 public $version = '1. 1';25 public $version = '1.2'; 26 26 27 27 /** Paths *****************************************************************/ … … 136 136 137 137 // Add link to settings page 138 add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 ); 138 add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 ); 139 139 } 140 140 … … 427 427 update_option( '_bbc_step', $bbconverter_step + 1 ); 428 428 update_option( '_bbc_start', 0 ); 429 $this->sync_table(); 430 429 431 if( !$bbconverter_start ) 430 432 { 431 echo 'No data to clean'; 433 echo 'No data to clean'; 432 434 } 433 435 } … … 442 444 update_option( '_bbc_step', $bbconverter_step + 1 ); 443 445 update_option( '_bbc_start', 0 ); 444 echo 'Not Cleaning Data'; 446 echo 'Not Cleaning Data'; 445 447 } 446 448 } … … 624 626 } 625 627 } 628 629 /** 630 * Create Tables for fast syncing 631 */ 632 public function sync_table( $drop = false ) 633 { 634 global $wpdb; 635 636 $table_name = $wpdb->prefix . "bbconverter_translator"; 637 if( $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name ) 638 { 639 $wpdb->query("DROP TABLE $table_name"); 640 } 641 if( !$drop ) 642 { 643 require_once( ABSPATH . '/wp-admin/includes/upgrade.php' ); 644 645 if( !empty( $wpdb->charset ) ) 646 { 647 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 648 } 649 if( !empty( $wpdb->collate ) ) 650 { 651 $charset_collate .= " COLLATE $wpdb->collate"; 652 } 653 654 //------ Translator ----------------------------------------------- 655 $sql = "CREATE TABLE " . $table_name . " ( 656 meta_id mediumint(8) unsigned not null auto_increment, 657 value_type varchar(25) null, 658 value_id bigint(20) unsigned not null default '0', 659 meta_key varchar(25) null, 660 meta_value varchar(25) null, 661 PRIMARY KEY (meta_id), 662 KEY value_id (value_id), 663 KEY meta_join (meta_key, meta_value) 664 ) $charset_collate;"; 665 dbDelta($sql); 666 } 667 } 626 668 } 627 669 -
bbconverter/trunk/readme.txt
r444910 r472197 5 5 Requires at least: 3.2.1 6 6 Tested up to: 3.2.1 7 Stable tag: 1. 17 Stable tag: 1.2 8 8 9 9 bbConverter is used to convert other forums to the new bbPress 2x plugin. … … 31 31 5. Choose the platform you want to convert from and fill in the database information. Click start 32 32 6. Once the conversion has completed, visit the WordPress Admin 'Tools' section and click 'Recount' 33 7. Do NOT deactivate the plugin once it is finished as it is needed for user password management .33 7. Do NOT deactivate the plugin once it is finished as it is needed for user password management unless your coming from bbpress 1x. 34 34 35 35 == Frequently Asked Questions == … … 49 49 == Changelog == 50 50 51 = 1.2 = 52 * Fixed Cleaning slow down. 53 * Much Faster importing now if mysql table editing is available. 54 * Fixed duplicate first post/reply on topics 55 * Fixed Issue with Different charset from UTF-8 56 * Added more info messages 57 51 58 = 1.1 = 52 59 * VBulletin 3x and 4x support added. … … 60 67 == Upgrade Notice == 61 68 62 = 1. 1=63 In addition to Vbulletin support, a number of changes have been made under the hood.69 = 1.2 = 70 Much faster now highly recomend updating.
Note: See TracChangeset
for help on using the changeset viewer.