Changeset 3240
- Timestamp:
- 11/30/2005 07:13:20 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/import/textpattern.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/textpattern.php
r3236 r3240 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 … … 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 … … 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>'); … … 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'); … … 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 123 // General Housekeeping 124 global $txpdb;83 global $wpdb; 84 // General Housekeeping 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'); … … 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'); … … 157 137 Keywords, 158 138 url_title, 159 comments_count, 160 ADDDATE(Posted, "INTERVAL '.get_settings('gmt_offset').' HOURS") AS post_date_gmt, 161 ADDDATE(LastMod, "INTERVAL '.get_settings('gmt_offset').' HOURS") AS post_modified_gmt 139 comments_count 162 140 FROM '.$prefix.'textpattern 163 141 ', ARRAY_A); … … 166 144 function get_txp_comments() 167 145 { 168 // General Housekeeping 169 global $txpdb; 146 global $wpdb; 147 // General Housekeeping 148 $txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost')); 170 149 set_magic_quotes_runtime(0); 171 150 $prefix = get_option('tpre'); … … 175 154 } 176 155 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 156 195 157 function links2wp($links='') … … 240 202 return true; 241 203 } 242 echo 'No Links to Import!';204 echo __('No Links to Import!'); 243 205 return false; 244 206 } … … 313 275 }// End if(is_array($users) 314 276 315 echo 'No Users to Import!';277 echo __('No Users to Import!'); 316 278 return false; 317 279 … … 324 286 $count = 0; 325 287 $txpcat2wpcat = array(); 326 327 288 // Do the Magic 328 289 if(is_array($categories)) … … 355 316 return true; 356 317 } 357 echo 'No Categories to Import!';318 echo __('No Categories to Import!'); 358 319 return false; 359 320 … … 505 466 return true; 506 467 } 507 echo 'No Comments to Import!';468 echo __('No Comments to Import!'); 508 469 return false; 509 470 } … … 578 539 delete_option('txpcm2wpcm'); 579 540 delete_option('txplinks2wplinks'); 541 delete_option('txpuser'); 542 delete_option('txppass'); 543 delete_option('txpname'); 544 delete_option('txphost'); 580 545 $this->tips(); 581 546 } … … 583 548 function tips() 584 549 { 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>'; 550 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>'); 551 echo __('<h3>Users</h3>'); 552 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>'); 553 echo __('<h3>Preserving Authors</h3>'); 554 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>'); 555 echo __('<h3>Textile</h3>'); 556 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>'); 557 echo __('<h3>WordPress Resources</h3>'); 558 echo __('<p>Finally, there are numerous WordPress resources around the internet. Some of them are:</p>'); 559 echo __('<ul>'); 560 echo __('<li><a href="http://www.wordpress.org">The official WordPress site</a></li>'); 561 echo __('<li><a href="http://wordpress.org/support/">The WordPress support forums</li>'); 562 echo __('<li><a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a></li>'); 563 echo __('</ul>'); 564 echo __('<p>That\'s it! What are you waiting for? Go <a href="/wp-login.php">login</a>!</p>'); 565 } 566 567 function db_form() 568 { 569 _e('<ul>'); 570 _e('<li><label for="dbuser">Textpattern Database User:</label> <input type="text" name="dbuser" /></li>'); 571 _e('<li><label for="dbpass">Textpattern Database Password:</label> <input type="password" name="dbpass" /></li>'); 572 _e('<li><label for="dbname">Textpattern Database Name:</label> <input type="text" name="dbname" /></li>'); 573 _e('<li><label for="dbhost">Textpattern Database Host:</label> <input type="text" name="dbhost" value="localhost" /></li>'); 574 _e('<li><label for="dbprefix">Textpattern Table prefix (if any)t:</label> <input type="text" name="dbprefix" /></li>'); 575 _e('</ul>'); 600 576 } 601 577 602 578 function dispatch() 603 579 { 604 global $txpdb, $txpcfg;605 580 606 581 if (empty ($_GET['step'])) … … 608 583 else 609 584 $step = (int) $_GET['step']; 610 611 585 $this->header(); 612 586 613 if ( $step > 0 ) { 614 add_option('tpre',$txpcfg['table_prefix']); 615 $txpdb = new wpdb($txpcfg['user'], $txpcfg['pass'], $txpcfg['db'], $txpcfg['host']); 587 if ( $step == 1 ) 588 { 589 if(false !== get_option('txpuser')) {add_option('txpuser',$_POST['dbuser']); } 590 if(false !== get_option('txppass')) {add_option('txppass',$_POST['dbpass']); } 591 if(false !== get_option('txpname')) {add_option('txpname',$_POST['dbname']); } 592 if(false !== get_option('txphost')) {add_option('txphost',$_POST['dbhost']); } 593 if(false !== get_option('tpre')) { add_option('tpre', $tpre); } 594 616 595 } 617 596
Note: See TracChangeset
for help on using the changeset viewer.