[ Index ] |
|
Code source de WordPress 2.1.2 |
1 <?php 2 /* 3 * DotClear import plugin 4 * by Thomas Quinot - http://thomas.quinot.org/ 5 */ 6 7 /** 8 Add These Functions to make our lives easier 9 **/ 10 if(!function_exists('get_catbynicename')) 11 { 12 function get_catbynicename($category_nicename) 13 { 14 global $wpdb; 15 16 $cat_id -= 0; // force numeric 17 $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"'); 18 19 return $name; 20 } 21 } 22 23 if(!function_exists('get_comment_count')) 24 { 25 function get_comment_count($post_ID) 26 { 27 global $wpdb; 28 return $wpdb->get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID); 29 } 30 } 31 32 if(!function_exists('link_cat_exists')) 33 { 34 function link_cat_exists($catname) 35 { 36 global $wpdb; 37 return $wpdb->get_var('SELECT cat_id FROM '.$wpdb->linkcategories.' WHERE cat_name = "'.$wpdb->escape($catname).'"'); 38 } 39 } 40 41 if(!function_exists('link_exists')) 42 { 43 function link_exists($linkname) 44 { 45 global $wpdb; 46 return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$linkname.'"'); 47 } 48 } 49 50 /* 51 Identify UTF-8 text 52 Taken from http://www.php.net/manual/fr/function.mb-detect-encoding.php#50087 53 */ 54 // 55 // utf8 encoding validation developed based on Wikipedia entry at: 56 // http://en.wikipedia.org/wiki/UTF-8 57 // 58 // Implemented as a recursive descent parser based on a simple state machine 59 // copyright 2005 Maarten Meijer 60 // 61 // This cries out for a C-implementation to be included in PHP core 62 // 63 64 function valid_1byte($char) { 65 if(!is_int($char)) return false; 66 return ($char & 0x80) == 0x00; 67 } 68 69 function valid_2byte($char) { 70 if(!is_int($char)) return false; 71 return ($char & 0xE0) == 0xC0; 72 } 73 74 function valid_3byte($char) { 75 if(!is_int($char)) return false; 76 return ($char & 0xF0) == 0xE0; 77 } 78 79 function valid_4byte($char) { 80 if(!is_int($char)) return false; 81 return ($char & 0xF8) == 0xF0; 82 } 83 84 function valid_nextbyte($char) { 85 if(!is_int($char)) return false; 86 return ($char & 0xC0) == 0x80; 87 } 88 89 function valid_utf8($string) { 90 $len = strlen($string); 91 $i = 0; 92 while( $i < $len ) { 93 $char = ord(substr($string, $i++, 1)); 94 if(valid_1byte($char)) { // continue 95 continue; 96 } else if(valid_2byte($char)) { // check 1 byte 97 if(!valid_nextbyte(ord(substr($string, $i++, 1)))) 98 return false; 99 } else if(valid_3byte($char)) { // check 2 bytes 100 if(!valid_nextbyte(ord(substr($string, $i++, 1)))) 101 return false; 102 if(!valid_nextbyte(ord(substr($string, $i++, 1)))) 103 return false; 104 } else if(valid_4byte($char)) { // check 3 bytes 105 if(!valid_nextbyte(ord(substr($string, $i++, 1)))) 106 return false; 107 if(!valid_nextbyte(ord(substr($string, $i++, 1)))) 108 return false; 109 if(!valid_nextbyte(ord(substr($string, $i++, 1)))) 110 return false; 111 } // goto next char 112 } 113 return true; // done 114 } 115 116 function csc ($s) { 117 if (valid_utf8 ($s)) { 118 return $s; 119 } else { 120 return iconv(get_option ("dccharset"),"UTF-8",$s); 121 } 122 } 123 124 function textconv ($s) { 125 return csc (preg_replace ('|(?<!<br />)\s*\n|', ' ', $s)); 126 } 127 128 /** 129 The Main Importer Class 130 **/ 131 class Dotclear_Import { 132 133 function header() 134 { 135 echo '<div class="wrap">'; 136 echo '<h2>'.__('Import DotClear').'</h2>'; 137 echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>'; 138 } 139 140 function footer() 141 { 142 echo '</div>'; 143 } 144 145 function greet() 146 { 147 echo '<div class="narrow"><p>'.__('Howdy! This importer allows you to extract posts from a DotClear database into your blog. Mileage may vary.').'</p>'; 148 echo '<p>'.__('Your DotClear Configuration settings are as follows:').'</p>'; 149 echo '<form action="admin.php?import=dotclear&step=1" method="post">'; 150 $this->db_form(); 151 echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' »" /></p>'; 152 echo '</form></div>'; 153 } 154 155 function get_dc_cats() 156 { 157 global $wpdb; 158 // General Housekeeping 159 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); 160 set_magic_quotes_runtime(0); 161 $dbprefix = get_option('dcdbprefix'); 162 163 // Get Categories 164 return $dcdb->get_results('SELECT * FROM '.$dbprefix.'categorie', ARRAY_A); 165 } 166 167 function get_dc_users() 168 { 169 global $wpdb; 170 // General Housekeeping 171 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); 172 set_magic_quotes_runtime(0); 173 $dbprefix = get_option('dcdbprefix'); 174 175 // Get Users 176 177 return $dcdb->get_results('SELECT * FROM '.$dbprefix.'user', ARRAY_A); 178 } 179 180 function get_dc_posts() 181 { 182 // General Housekeeping 183 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); 184 set_magic_quotes_runtime(0); 185 $dbprefix = get_option('dcdbprefix'); 186 187 // Get Posts 188 return $dcdb->get_results('SELECT '.$dbprefix.'post.*, '.$dbprefix.'categorie.cat_libelle_url AS post_cat_name 189 FROM '.$dbprefix.'post INNER JOIN '.$dbprefix.'categorie 190 ON '.$dbprefix.'post.cat_id = '.$dbprefix.'categorie.cat_id', ARRAY_A); 191 } 192 193 function get_dc_comments() 194 { 195 global $wpdb; 196 // General Housekeeping 197 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); 198 set_magic_quotes_runtime(0); 199 $dbprefix = get_option('dcdbprefix'); 200 201 // Get Comments 202 return $dcdb->get_results('SELECT * FROM '.$dbprefix.'comment', ARRAY_A); 203 } 204 205 function get_dc_links() 206 { 207 //General Housekeeping 208 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); 209 set_magic_quotes_runtime(0); 210 $dbprefix = get_option('dcdbprefix'); 211 212 return $dcdb->get_results('SELECT * FROM '.$dbprefix.'link ORDER BY position', ARRAY_A); 213 } 214 215 function cat2wp($categories='') 216 { 217 // General Housekeeping 218 global $wpdb; 219 $count = 0; 220 $dccat2wpcat = array(); 221 // Do the Magic 222 if(is_array($categories)) 223 { 224 echo '<p>'.__('Importing Categories...').'<br /><br /></p>'; 225 foreach ($categories as $category) 226 { 227 $count++; 228 extract($category); 229 230 // Make Nice Variables 231 $name = $wpdb->escape($cat_libelle_url); 232 $title = $wpdb->escape(csc ($cat_libelle)); 233 $desc = $wpdb->escape(csc ($cat_desc)); 234 235 if($cinfo = category_exists($name)) 236 { 237 $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc)); 238 } 239 else 240 { 241 $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc)); 242 } 243 $dccat2wpcat[$id] = $ret_id; 244 } 245 246 // Store category translation for future use 247 add_option('dccat2wpcat',$dccat2wpcat); 248 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>'; 249 return true; 250 } 251 echo __('No Categories to Import!'); 252 return false; 253 } 254 255 function users2wp($users='') 256 { 257 // General Housekeeping 258 global $wpdb; 259 $count = 0; 260 $dcid2wpid = array(); 261 262 // Midnight Mojo 263 if(is_array($users)) 264 { 265 echo '<p>'.__('Importing Users...').'<br /><br /></p>'; 266 foreach($users as $user) 267 { 268 $count++; 269 extract($user); 270 271 // Make Nice Variables 272 $name = $wpdb->escape(csc ($name)); 273 $RealName = $wpdb->escape(csc ($user_pseudo)); 274 275 if($uinfo = get_userdatabylogin($name)) 276 { 277 278 $ret_id = wp_insert_user(array( 279 'ID' => $uinfo->ID, 280 'user_login' => $user_id, 281 'user_nicename' => $Realname, 282 'user_email' => $user_email, 283 'user_url' => 'http://', 284 'display_name' => $Realname) 285 ); 286 } 287 else 288 { 289 $ret_id = wp_insert_user(array( 290 'user_login' => $user_id, 291 'user_nicename' => csc ($user_pseudo), 292 'user_email' => $user_email, 293 'user_url' => 'http://', 294 'display_name' => $Realname) 295 ); 296 } 297 $dcid2wpid[$user_id] = $ret_id; 298 299 // Set DotClear-to-WordPress permissions translation 300 301 // Update Usermeta Data 302 $user = new WP_User($ret_id); 303 $wp_perms = $user_level + 1; 304 if(10 == $wp_perms) { $user->set_role('administrator'); } 305 else if(9 == $wp_perms) { $user->set_role('editor'); } 306 else if(5 <= $wp_perms) { $user->set_role('editor'); } 307 else if(4 <= $wp_perms) { $user->set_role('author'); } 308 else if(3 <= $wp_perms) { $user->set_role('contributor'); } 309 else if(2 <= $wp_perms) { $user->set_role('contributor'); } 310 else { $user->set_role('subscriber'); } 311 312 update_usermeta( $ret_id, 'wp_user_level', $wp_perms); 313 update_usermeta( $ret_id, 'rich_editing', 'false'); 314 update_usermeta( $ret_id, 'first_name', csc ($user_prenom)); 315 update_usermeta( $ret_id, 'last_name', csc ($user_nom)); 316 }// End foreach($users as $user) 317 318 // Store id translation array for future use 319 add_option('dcid2wpid',$dcid2wpid); 320 321 322 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>'; 323 return true; 324 }// End if(is_array($users) 325 326 echo __('No Users to Import!'); 327 return false; 328 329 }// End function user2wp() 330 331 function posts2wp($posts='') 332 { 333 // General Housekeeping 334 global $wpdb; 335 $count = 0; 336 $dcposts2wpposts = array(); 337 $cats = array(); 338 339 // Do the Magic 340 if(is_array($posts)) 341 { 342 echo '<p>'.__('Importing Posts...').'<br /><br /></p>'; 343 foreach($posts as $post) 344 { 345 $count++; 346 extract($post); 347 348 // Set DotClear-to-WordPress status translation 349 $stattrans = array(0 => 'draft', 1 => 'publish'); 350 $comment_status_map = array (0 => 'closed', 1 => 'open'); 351 352 //Can we do this more efficiently? 353 $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1; 354 $authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ; 355 356 $Title = $wpdb->escape(csc ($post_titre)); 357 $post_content = textconv ($post_content); 358 $post_excerpt = ""; 359 if ($post_chapo != "") { 360 $post_excerpt = textconv ($post_chapo); 361 $post_content = $post_excerpt ."\n<!--more-->\n".$post_content; 362 } 363 $post_excerpt = $wpdb->escape ($post_excerpt); 364 $post_content = $wpdb->escape ($post_content); 365 $post_status = $stattrans[$post_pub]; 366 367 // Import Post data into WordPress 368 369 if($pinfo = post_exists($Title,$post_content)) 370 { 371 $ret_id = wp_insert_post(array( 372 'ID' => $pinfo, 373 'post_author' => $authorid, 374 'post_date' => $post_dt, 375 'post_date_gmt' => $post_dt, 376 'post_modified' => $post_upddt, 377 'post_modified_gmt' => $post_upddt, 378 'post_title' => $Title, 379 'post_content' => $post_content, 380 'post_excerpt' => $post_excerpt, 381 'post_status' => $post_status, 382 'post_name' => $post_titre_url, 383 'comment_status' => $comment_status_map[$post_open_comment], 384 'ping_status' => $comment_status_map[$post_open_tb], 385 'comment_count' => $post_nb_comment + $post_nb_trackback) 386 ); 387 } 388 else 389 { 390 $ret_id = wp_insert_post(array( 391 'post_author' => $authorid, 392 'post_date' => $post_dt, 393 'post_date_gmt' => $post_dt, 394 'post_modified' => $post_modified_gmt, 395 'post_modified_gmt' => $post_modified_gmt, 396 'post_title' => $Title, 397 'post_content' => $post_content, 398 'post_excerpt' => $post_excerpt, 399 'post_status' => $post_status, 400 'post_name' => $post_titre_url, 401 'comment_status' => $comment_status_map[$post_open_comment], 402 'ping_status' => $comment_status_map[$post_open_tb], 403 'comment_count' => $post_nb_comment + $post_nb_trackback) 404 ); 405 } 406 $dcposts2wpposts[$post_id] = $ret_id; 407 408 // Make Post-to-Category associations 409 $cats = array(); 410 if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; } 411 412 if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); } 413 } 414 } 415 // Store ID translation for later use 416 add_option('dcposts2wpposts',$dcposts2wpposts); 417 418 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>'; 419 return true; 420 } 421 422 function comments2wp($comments='') 423 { 424 // General Housekeeping 425 global $wpdb; 426 $count = 0; 427 $dccm2wpcm = array(); 428 $postarr = get_option('dcposts2wpposts'); 429 430 // Magic Mojo 431 if(is_array($comments)) 432 { 433 echo '<p>'.__('Importing Comments...').'<br /><br /></p>'; 434 foreach($comments as $comment) 435 { 436 $count++; 437 extract($comment); 438 439 // WordPressify Data 440 $comment_ID = ltrim($comment_id, '0'); 441 $comment_post_ID = $postarr[$post_id]; 442 $comment_approved = "$comment_pub"; 443 $name = $wpdb->escape(csc ($comment_auteur)); 444 $email = $wpdb->escape($comment_email); 445 $web = "http://".$wpdb->escape($comment_site); 446 $message = $wpdb->escape(textconv ($comment_content)); 447 448 if($cinfo = comment_exists($name, $comment_dt)) 449 { 450 // Update comments 451 $ret_id = wp_update_comment(array( 452 'comment_ID' => $cinfo, 453 'comment_post_ID' => $comment_post_ID, 454 'comment_author' => $name, 455 'comment_author_email' => $email, 456 'comment_author_url' => $web, 457 'comment_author_IP' => $comment_ip, 458 'comment_date' => $comment_dt, 459 'comment_date_gmt' => $comment_dt, 460 'comment_content' => $message, 461 'comment_approved' => $comment_approved) 462 ); 463 } 464 else 465 { 466 // Insert comments 467 $ret_id = wp_insert_comment(array( 468 'comment_post_ID' => $comment_post_ID, 469 'comment_author' => $name, 470 'comment_author_email' => $email, 471 'comment_author_url' => $web, 472 'comment_author_IP' => $comment_ip, 473 'comment_date' => $comment_dt, 474 'comment_date_gmt' => $comment_dt, 475 'comment_content' => $message, 476 'comment_approved' => $comment_approved) 477 ); 478 } 479 $dccm2wpcm[$comment_ID] = $ret_id; 480 } 481 // Store Comment ID translation for future use 482 add_option('dccm2wpcm', $dccm2wpcm); 483 484 // Associate newly formed categories with posts 485 get_comment_count($ret_id); 486 487 488 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>'; 489 return true; 490 } 491 echo __('No Comments to Import!'); 492 return false; 493 } 494 495 function links2wp($links='') 496 { 497 // General Housekeeping 498 global $wpdb; 499 $count = 0; 500 501 // Deal with the links 502 if(is_array($links)) 503 { 504 echo '<p>'.__('Importing Links...').'<br /><br /></p>'; 505 foreach($links as $link) 506 { 507 $count++; 508 extract($link); 509 510 if ($title != "") { 511 if ($cinfo = link_cat_exists (csc ($title))) { 512 $category = $cinfo; 513 } else { 514 $wpdb->query ("INSERT INTO $wpdb->linkcategories (cat_name) VALUES ('". 515 $wpdb->escape (csc ($title))."')"); 516 $category = $wpdb->insert_id; 517 } 518 } else { 519 $linkname = $wpdb->escape(csc ($label)); 520 $description = $wpdb->escape(csc ($title)); 521 522 if($linfo = link_exists($linkname)) { 523 $ret_id = wp_insert_link(array( 524 'link_id' => $linfo, 525 'link_url' => $href, 526 'link_name' => $linkname, 527 'link_category' => $category, 528 'link_description' => $description) 529 ); 530 } else { 531 $ret_id = wp_insert_link(array( 532 'link_url' => $url, 533 'link_name' => $linkname, 534 'link_category' => $category, 535 'link_description' => $description) 536 ); 537 } 538 $dclinks2wplinks[$link_id] = $ret_id; 539 } 540 } 541 add_option('dclinks2wplinks',$dclinks2wplinks); 542 echo '<p>'; 543 printf(__('Done! <strong>%s</strong> links or link categories imported'), $count); 544 echo '<br /><br /></p>'; 545 return true; 546 } 547 echo __('No Links to Import!'); 548 return false; 549 } 550 551 function import_categories() 552 { 553 // Category Import 554 $cats = $this->get_dc_cats(); 555 $this->cat2wp($cats); 556 add_option('dc_cats', $cats); 557 558 559 560 echo '<form action="admin.php?import=dotclear&step=2" method="post">'; 561 printf('<input type="submit" name="submit" value="%s" />', __('Import Users')); 562 echo '</form>'; 563 564 } 565 566 function import_users() 567 { 568 // User Import 569 $users = $this->get_dc_users(); 570 $this->users2wp($users); 571 572 echo '<form action="admin.php?import=dotclear&step=3" method="post">'; 573 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts')); 574 echo '</form>'; 575 } 576 577 function import_posts() 578 { 579 // Post Import 580 $posts = $this->get_dc_posts(); 581 $this->posts2wp($posts); 582 583 echo '<form action="admin.php?import=dotclear&step=4" method="post">'; 584 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments')); 585 echo '</form>'; 586 } 587 588 function import_comments() 589 { 590 // Comment Import 591 $comments = $this->get_dc_comments(); 592 $this->comments2wp($comments); 593 594 echo '<form action="admin.php?import=dotclear&step=5" method="post">'; 595 printf('<input type="submit" name="submit" value="%s" />', __('Import Links')); 596 echo '</form>'; 597 } 598 599 function import_links() 600 { 601 //Link Import 602 $links = $this->get_dc_links(); 603 $this->links2wp($links); 604 add_option('dc_links', $links); 605 606 echo '<form action="admin.php?import=dotclear&step=6" method="post">'; 607 printf('<input type="submit" name="submit" value="%s" />', __('Finish')); 608 echo '</form>'; 609 } 610 611 function cleanup_dcimport() 612 { 613 delete_option('dcdbprefix'); 614 delete_option('dc_cats'); 615 delete_option('dcid2wpid'); 616 delete_option('dccat2wpcat'); 617 delete_option('dcposts2wpposts'); 618 delete_option('dccm2wpcm'); 619 delete_option('dclinks2wplinks'); 620 delete_option('dcuser'); 621 delete_option('dcpass'); 622 delete_option('dcname'); 623 delete_option('dchost'); 624 delete_option('dccharset'); 625 $this->tips(); 626 } 627 628 function tips() 629 { 630 echo '<p>'.__('Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from DotClear, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.').'</p>'; 631 echo '<h3>'.__('Users').'</h3>'; 632 echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn\'t have that login in DotClear, 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 DotClear 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="%1$s">Login</a> and change it.'), '/wp-login.php').'</p>'; 633 echo '<h3>'.__('Preserving Authors').'</h3>'; 634 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>'; 635 echo '<h3>'.__('Textile').'</h3>'; 636 echo '<p>'.__('Also, since you\'re coming from DotClear, 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/category/development/wordpress/textile/">Textile for WordPress</a>. Trust me... You\'ll want it.').'</p>'; 637 echo '<h3>'.__('WordPress Resources').'</h3>'; 638 echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>'; 639 echo '<ul>'; 640 echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>'; 641 echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>'; 642 echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>'; 643 echo '</ul>'; 644 echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '../wp-login.php').'</p>'; 645 } 646 647 function db_form() 648 { 649 echo '<table class="editform">'; 650 printf('<tr><th><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('DotClear Database User:')); 651 printf('<tr><th><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('DotClear Database Password:')); 652 printf('<tr><th><label for="dbname">%s</label></th><td><input type="text" name="dbname" id="dbname" /></td></tr>', __('DotClear Database Name:')); 653 printf('<tr><th><label for="dbhost">%s</label></th><td><input type="text" name="dbhost" nameid="dbhost" value="localhost" /></td></tr>', __('DotClear Database Host:')); 654 printf('<tr><th><label for="dbprefix">%s</label></th><td><input type="text" name="dbprefix" id="dbprefix" value="dc_"/></td></tr>', __('DotClear Table prefix:')); 655 printf('<tr><th><label for="dccharset">%s</label></th><td><input type="text" name="dccharset" id="dccharset" value="ISO-8859-15"/></td></tr>', __('Originating character set:')); 656 echo '</table>'; 657 } 658 659 function dispatch() 660 { 661 662 if (empty ($_GET['step'])) 663 $step = 0; 664 else 665 $step = (int) $_GET['step']; 666 $this->header(); 667 668 if ( $step > 0 ) 669 { 670 if($_POST['dbuser']) 671 { 672 if(get_option('dcuser')) 673 delete_option('dcuser'); 674 add_option('dcuser',$_POST['dbuser']); 675 } 676 if($_POST['dbpass']) 677 { 678 if(get_option('dcpass')) 679 delete_option('dcpass'); 680 add_option('dcpass',$_POST['dbpass']); 681 } 682 683 if($_POST['dbname']) 684 { 685 if(get_option('dcname')) 686 delete_option('dcname'); 687 add_option('dcname',$_POST['dbname']); 688 } 689 if($_POST['dbhost']) 690 { 691 if(get_option('dchost')) 692 delete_option('dchost'); 693 add_option('dchost',$_POST['dbhost']); 694 } 695 if($_POST['dccharset']) 696 { 697 if(get_option('dccharset')) 698 delete_option('dccharset'); 699 add_option('dccharset',$_POST['dccharset']); 700 } 701 if($_POST['dbprefix']) 702 { 703 if(get_option('dcdbprefix')) 704 delete_option('dcdbprefix'); 705 add_option('dcdbprefix',$_POST['dbprefix']); 706 } 707 708 709 } 710 711 switch ($step) 712 { 713 default: 714 case 0 : 715 $this->greet(); 716 break; 717 case 1 : 718 $this->import_categories(); 719 break; 720 case 2 : 721 $this->import_users(); 722 break; 723 case 3 : 724 $this->import_posts(); 725 break; 726 case 4 : 727 $this->import_comments(); 728 break; 729 case 5 : 730 $this->import_links(); 731 break; 732 case 6 : 733 $this->cleanup_dcimport(); 734 break; 735 } 736 737 $this->footer(); 738 } 739 740 function Dotclear_Import() 741 { 742 // Nothing. 743 } 744 } 745 746 $dc_import = new Dotclear_Import(); 747 register_importer('dotclear', __('DotClear'), __('Import categories, users, posts, comments, and links from a DotClear blog'), array ($dc_import, 'dispatch')); 748 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 30 19:41:27 2007 | par Balluche grâce à PHPXref 0.7 |