Make WordPress Core

Ticket #2234: dotclear.2.php

File dotclear.2.php, 22.2 KB (added by thomasq, 21 years ago)

Improved version (fixes extended entry markup insertion)

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