Ticket #1944: textpattern.diff
| File textpattern.diff, 11.9 KB (added by technosailor, 6 years ago) |
|---|
-
textpattern.php
1 1 <?php 2 3 /*4 This Import Script is written by Aaron Brazell of Technosailor.com5 6 It was developed using a large blog running Textpattern 4.0.2 and7 successfully imported nearly 3000 records at a time. Higher8 scalability is uncertain.9 10 BACKUP YOUR DATABASE PRIOR TO RUNNING THIS IMPORT SCRIPT11 */12 13 // BEGIN EDITING14 15 // $txpconfig options can be found in the Textpattern %textpattern%/config.php file16 $txpcfg['db'] = 'textpattern';17 $txpcfg['user'] = 'root';18 $txpcfg['pass'] = '';19 $txpcfg['host'] = 'localhost';20 $txpcfg['table_prefix'] = '';21 22 // STOP EDITING23 24 2 /** 25 3 Add These Functions to make our lives easier 26 4 **/ … … 60 38 **/ 61 39 class Textpattern_Import { 62 40 63 var $posts = array ();64 var $file;65 66 41 function header() 67 42 { 68 43 echo '<div class="wrap">'; 69 44 echo '<h2>'.__('Import Textpattern').'</h2>'; 45 echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.</p>'); 70 46 } 71 47 72 48 function footer() … … 76 52 77 53 function greet() 78 54 { 79 global $txpcfg;80 81 55 _e('<p>Howdy! This importer allows you to extract posts from any Textpattern 4.0.2+ into your blog. This has not been tested on previous versions of Textpattern. Mileage may vary.</p>'); 82 56 _e('<p>Your Textpattern Configuration settings are as follows:</p>'); 83 _e('<ul><li><strong>Textpattern Database Name:</strong> '.$txpcfg['db'].'</li>');84 _e('<li><strong>Textpattern Database User:</strong> '.$txpcfg['user'].'</li>');85 _e('<li><strong>Textpattern Database Password:</strong> '.$txpcfg['pass'].'</li>');86 _e('<li><strong>Textpattern Database Host:</strong> '.$txpcfg['host'].'</li>');87 _e('</ul>');88 _e('<p>If this is incorrect, please modify settings in wp-admin/import/textpattern.php</p>');89 57 _e('<form action="admin.php?import=textpattern&step=1" method="post">'); 58 $this->db_form(); 90 59 _e('<input type="submit" name="submit" value="Import Categories" />'); 91 60 _e('</form>'); 92 61 } … … 94 63 function get_txp_links() 95 64 { 96 65 //General Housekeeping 97 global $txpdb;66 $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); 98 67 set_magic_quotes_runtime(0); 99 68 $prefix = get_option('tpre'); 100 69 … … 107 76 description 108 77 FROM '.$prefix.'txp_link', 109 78 ARRAY_A); 110 echo'SELECT111 id,112 date,113 category,114 url,115 linkname,116 description117 FROM '.$prefix.'txp_link';118 79 } 119 80 120 81 function get_txp_cats() 121 82 { 122 83 global $wpdb; 123 84 // General Housekeeping 124 global $txpdb;85 $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); 125 86 set_magic_quotes_runtime(0); 126 87 $prefix = get_option('tpre'); 127 88 … … 135 96 ARRAY_A); 136 97 } 137 98 99 function get_txp_users() 100 { 101 global $wpdb; 102 // General Housekeeping 103 $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); 104 set_magic_quotes_runtime(0); 105 $prefix = get_option('tpre'); 106 107 // Get Users 108 109 return $txpdb->get_results('SELECT 110 user_id, 111 name, 112 RealName, 113 email, 114 privs 115 FROM '.$prefix.'txp_users', ARRAY_A); 116 } 117 138 118 function get_txp_posts() 139 119 { 140 120 // General Housekeeping 141 global $txpdb;121 $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); 142 122 set_magic_quotes_runtime(0); 143 123 $prefix = get_option('tpre'); 144 124 … … 165 145 166 146 function get_txp_comments() 167 147 { 148 global $wpdb; 168 149 // General Housekeeping 169 global $txpdb;150 $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); 170 151 set_magic_quotes_runtime(0); 171 152 $prefix = get_option('tpre'); 172 153 … … 174 155 return $txpdb->get_results('SELECT * FROM '.$prefix.'txp_discuss', ARRAY_A); 175 156 } 176 157 177 function get_txp_users()178 {179 // General Housekeeping180 global $txpdb;181 set_magic_quotes_runtime(0);182 $prefix = get_option('tpre');183 184 // Get Users185 $users = $txpdb->get_results('SELECT186 user_id,187 name,188 RealName,189 email,190 privs191 FROM '.$prefix.'txp_users', ARRAY_A);192 return $users;193 }194 158 195 159 function links2wp($links='') 196 160 { … … 239 203 echo __('<p>Done! <strong>'.$count.'</strong> Links imported.<br /><br /></p>'); 240 204 return true; 241 205 } 242 echo 'No Links to Import!';206 echo __('No Links to Import!'); 243 207 return false; 244 208 } 245 209 … … 312 276 return true; 313 277 }// End if(is_array($users) 314 278 315 echo 'No Users to Import!';279 echo __('No Users to Import!'); 316 280 return false; 317 281 318 282 }// End function user2wp() … … 323 287 global $wpdb; 324 288 $count = 0; 325 289 $txpcat2wpcat = array(); 326 327 290 // Do the Magic 328 291 if(is_array($categories)) 329 292 { … … 354 317 echo __('<p>Done! <strong>'.$count.'</strong> categories imported.<br /><br /></p>'); 355 318 return true; 356 319 } 357 echo 'No Categories to Import!';320 echo __('No Categories to Import!'); 358 321 return false; 359 322 360 323 } … … 504 467 echo __('<p>Done! <strong>'.$count.'</strong> comments imported.<br /><br /></p>'); 505 468 return true; 506 469 } 507 echo 'No Comments to Import!';470 echo __('No Comments to Import!'); 508 471 return false; 509 472 } 510 473 … … 577 540 delete_option('txpposts2wpposts'); 578 541 delete_option('txpcm2wpcm'); 579 542 delete_option('txplinks2wplinks'); 543 delete_option('txpuser'); 544 delete_option('txppass'); 545 delete_option('txpname'); 546 delete_option('txphost'); 580 547 $this->tips(); 581 548 } 582 549 583 550 function tips() 584 551 { 585 echo '<p>Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from Textpattern, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.</p>';586 echo '<h3>Users</h3>';587 echo '<p>You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn\'t have that login in Textpattern, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> This includes you. So <a href="/wp-login.php">Login</a> and change it.</p>';588 echo '<h3>Preserving Authors</h3>';589 echo '<p>Secondly, we have attempted to preserve post authors. If you are the only author or contributor to your blog, then you are safe. In most cases, we are successful in this preservation endeavor. However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.</p>';590 echo '<h3>Textile</h3>';591 echo '<p>Also, since you\'re coming from Textpattern, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/2004/04/19/wordpress-plugin-textile-20/">Textile for WordPress</a>. Trust me... You\'ll want it.</p>';592 echo '<h3>WordPress Resources</h3>';593 echo '<p>Finally, there are numerous WordPress resources around the internet. Some of them are:</p>';594 echo '<ul>';595 echo '<li><a href="http://www.wordpress.org">The official WordPress site</a></li>';596 echo '<li><a href="http://wordpress.org/support/">The WordPress support forums</li>';597 echo '<li><a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a></li>';598 echo '</ul>';599 echo '<p>That\'s it! What are you waiting for? Go <a href="/wp-login.php">login</a>!</p>';552 echo __('<p>Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from Textpattern, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.</p>'); 553 echo __('<h3>Users</h3>'); 554 echo __('<p>You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn\'t have that login in Textpattern, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> So <a href="/wp-login.php">Login</a> and change it.</p>'); 555 echo __('<h3>Preserving Authors</h3>'); 556 echo __('<p>Secondly, we have attempted to preserve post authors. If you are the only author or contributor to your blog, then you are safe. In most cases, we are successful in this preservation endeavor. However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.</p>'); 557 echo __('<h3>Textile</h3>'); 558 echo __('<p>Also, since you\'re coming from Textpattern, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/2004/04/19/wordpress-plugin-textile-20/">Textile for WordPress</a>. Trust me... You\'ll want it.</p>'); 559 echo __('<h3>WordPress Resources</h3>'); 560 echo __('<p>Finally, there are numerous WordPress resources around the internet. Some of them are:</p>'); 561 echo __('<ul>'); 562 echo __('<li><a href="http://www.wordpress.org">The official WordPress site</a></li>'); 563 echo __('<li><a href="http://wordpress.org/support/">The WordPress support forums</li>'); 564 echo __('<li><a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a></li>'); 565 echo __('</ul>'); 566 echo __('<p>That\'s it! What are you waiting for? Go <a href="/wp-login.php">login</a>!</p>'); 600 567 } 601 568 569 function db_form() 570 { 571 _e('<ul>'); 572 _e('<li><label for="dbuser">Textpattern Database User:</label> <input type="text" name="dbuser" /></li>'); 573 _e('<li><label for="dbpass">Textpattern Database Password:</label> <input type="password" name="dbpass" /></li>'); 574 _e('<li><label for="dbname">Textpattern Database Name:</label> <input type="text" name="dbname" /></li>'); 575 _e('<li><label for="dbhost">Textpattern Database Host:</label> <input type="text" name="dbhost" value="localhost" /></li>'); 576 _e('<li><label for="dbprefix">Textpattern Table prefix (if any)t:</label> <input type="text" name="dbprefix" /></li>'); 577 _e('</ul>'); 578 } 579 602 580 function dispatch() 603 581 { 604 global $txpdb, $txpcfg;605 582 606 583 if (empty ($_GET['step'])) 607 584 $step = 0; 608 585 else 609 586 $step = (int) $_GET['step']; 610 611 587 $this->header(); 612 588 613 if ( $step > 0 ) { 614 add_option('tpre',$txpcfg['table_prefix']); 615 $txpdb = new wpdb($txpcfg['user'], $txpcfg['pass'], $txpcfg['db'], $txpcfg['host']); 589 if ( $step == 1 ) 590 { 591 if(false !== get_option('txpuser')) {add_option('txpuser',$_POST['dbuser']); } 592 if(false !== get_option('txppass')) {add_option('txppass',$_POST['dbpass']); } 593 if(false !== get_option('txpname')) {add_option('txpname',$_POST['dbname']); } 594 if(false !== get_option('txphost')) {add_option('txphost',$_POST['dbhost']); } 595 if(false !== get_option('tpre')) { add_option('tpre', $tpre); } 596 616 597 } 617 598 618 599 switch ($step) … … 652 633 653 634 $txp_import = new Textpattern_Import(); 654 635 register_importer('textpattern', 'Textpattern', __('Import posts from a Textpattern Blog'), array ($txp_import, 'dispatch')); 655 ?> 636 ?> 637 No newline at end of file
