-
+ 9BCF079EC550633A2846CB4B8DBA0CC6BD939E4E282EE64D5E4A38A3F478CAB763722BD97E8ECC5452033B284A9D4592562E520639F3B4DA00251DFBBFEEF096
mp-wp/wp-admin/import/dotclear.php
(0 . 0)(1 . 835)
17733 <?php
17734 /**
17735 * DotClear Importer
17736 *
17737 * @package WordPress
17738 * @subpackage Importer
17739 * @author Thomas Quinot
17740 * @link http://thomas.quinot.org/
17741 */
17742
17743 /**
17744 Add These Functions to make our lives easier
17745 **/
17746
17747 if(!function_exists('get_comment_count'))
17748 {
17749 /**
17750 * Get the comment count for posts.
17751 *
17752 * @package WordPress
17753 * @subpackage Dotclear_Import
17754 *
17755 * @param int $post_ID Post ID
17756 * @return int
17757 */
17758 function get_comment_count($post_ID)
17759 {
17760 global $wpdb;
17761 return $wpdb->get_var( $wpdb->prepare("SELECT count(*) FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) );
17762 }
17763 }
17764
17765 if(!function_exists('link_exists'))
17766 {
17767 /**
17768 * Check whether link already exists.
17769 *
17770 * @package WordPress
17771 * @subpackage Dotclear_Import
17772 *
17773 * @param string $linkname
17774 * @return int
17775 */
17776 function link_exists($linkname)
17777 {
17778 global $wpdb;
17779 return $wpdb->get_var( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_name = %s", $linkname) );
17780 }
17781 }
17782
17783 /*
17784 Identify UTF-8 text
17785 Taken from http://www.php.net/manual/fr/function.mb-detect-encoding.php#50087
17786 */
17787 //
17788 // utf8 encoding validation developed based on Wikipedia entry at:
17789 // http://en.wikipedia.org/wiki/UTF-8
17790 //
17791 // Implemented as a recursive descent parser based on a simple state machine
17792 // copyright 2005 Maarten Meijer
17793 //
17794 // This cries out for a C-implementation to be included in PHP core
17795 //
17796
17797 /**
17798 * @package WordPress
17799 * @subpackage Dotclear_Import
17800 *
17801 * @param string $char
17802 * @return string
17803 */
17804 function valid_1byte($char) {
17805 if(!is_int($char)) return false;
17806 return ($char & 0x80) == 0x00;
17807 }
17808
17809 /**
17810 * @package WordPress
17811 * @subpackage Dotclear_Import
17812 *
17813 * @param string $char
17814 * @return string
17815 */
17816 function valid_2byte($char) {
17817 if(!is_int($char)) return false;
17818 return ($char & 0xE0) == 0xC0;
17819 }
17820
17821 /**
17822 * @package WordPress
17823 * @subpackage Dotclear_Import
17824 *
17825 * @param string $char
17826 * @return string
17827 */
17828 function valid_3byte($char) {
17829 if(!is_int($char)) return false;
17830 return ($char & 0xF0) == 0xE0;
17831 }
17832
17833 /**
17834 * @package WordPress
17835 * @subpackage Dotclear_Import
17836 *
17837 * @param string $char
17838 * @return string
17839 */
17840 function valid_4byte($char) {
17841 if(!is_int($char)) return false;
17842 return ($char & 0xF8) == 0xF0;
17843 }
17844
17845 /**
17846 * @package WordPress
17847 * @subpackage Dotclear_Import
17848 *
17849 * @param string $char
17850 * @return string
17851 */
17852 function valid_nextbyte($char) {
17853 if(!is_int($char)) return false;
17854 return ($char & 0xC0) == 0x80;
17855 }
17856
17857 /**
17858 * @package WordPress
17859 * @subpackage Dotclear_Import
17860 *
17861 * @param string $string
17862 * @return string
17863 */
17864 function valid_utf8($string) {
17865 $len = strlen($string);
17866 $i = 0;
17867 while( $i < $len ) {
17868 $char = ord(substr($string, $i++, 1));
17869 if(valid_1byte($char)) { // continue
17870 continue;
17871 } else if(valid_2byte($char)) { // check 1 byte
17872 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
17873 return false;
17874 } else if(valid_3byte($char)) { // check 2 bytes
17875 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
17876 return false;
17877 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
17878 return false;
17879 } else if(valid_4byte($char)) { // check 3 bytes
17880 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
17881 return false;
17882 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
17883 return false;
17884 if(!valid_nextbyte(ord(substr($string, $i++, 1))))
17885 return false;
17886 } // goto next char
17887 }
17888 return true; // done
17889 }
17890
17891 /**
17892 * @package WordPress
17893 * @subpackage Dotclear_Import
17894 *
17895 * @param string $s
17896 * @return string
17897 */
17898 function csc ($s) {
17899 if (valid_utf8 ($s)) {
17900 return $s;
17901 } else {
17902 return iconv(get_option ("dccharset"),"UTF-8",$s);
17903 }
17904 }
17905
17906 /**
17907 * @package WordPress
17908 * @subpackage Dotclear_Import
17909 *
17910 * @param string $s
17911 * @return string
17912 */
17913 function textconv ($s) {
17914 return csc (preg_replace ('|(?<!<br />)\s*\n|', ' ', $s));
17915 }
17916
17917 /**
17918 * Dotclear Importer class
17919 *
17920 * Will process the WordPress eXtended RSS files that you upload from the export
17921 * file.
17922 *
17923 * @package WordPress
17924 * @subpackage Importer
17925 *
17926 * @since unknown
17927 */
17928 class Dotclear_Import {
17929
17930 function header()
17931 {
17932 echo '<div class="wrap">';
17933 screen_icon();
17934 echo '<h2>'.__('Import DotClear').'</h2>';
17935 echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
17936 }
17937
17938 function footer()
17939 {
17940 echo '</div>';
17941 }
17942
17943 function greet()
17944 {
17945 echo '<div class="narrow"><p>'.__('Howdy! This importer allows you to extract posts from a DotClear database into your blog. Mileage may vary.').'</p>';
17946 echo '<p>'.__('Your DotClear Configuration settings are as follows:').'</p>';
17947 echo '<form action="admin.php?import=dotclear&step=1" method="post">';
17948 wp_nonce_field('import-dotclear');
17949 $this->db_form();
17950 echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.attribute_escape(__('Import Categories')).'" /></p>';
17951 echo '</form></div>';
17952 }
17953
17954 function get_dc_cats()
17955 {
17956 global $wpdb;
17957 // General Housekeeping
17958 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
17959 set_magic_quotes_runtime(0);
17960 $dbprefix = get_option('dcdbprefix');
17961
17962 // Get Categories
17963 return $dcdb->get_results('SELECT * FROM '.$dbprefix.'categorie', ARRAY_A);
17964 }
17965
17966 function get_dc_users()
17967 {
17968 global $wpdb;
17969 // General Housekeeping
17970 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
17971 set_magic_quotes_runtime(0);
17972 $dbprefix = get_option('dcdbprefix');
17973
17974 // Get Users
17975
17976 return $dcdb->get_results('SELECT * FROM '.$dbprefix.'user', ARRAY_A);
17977 }
17978
17979 function get_dc_posts()
17980 {
17981 // General Housekeeping
17982 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
17983 set_magic_quotes_runtime(0);
17984 $dbprefix = get_option('dcdbprefix');
17985
17986 // Get Posts
17987 return $dcdb->get_results('SELECT '.$dbprefix.'post.*, '.$dbprefix.'categorie.cat_libelle_url AS post_cat_name
17988 FROM '.$dbprefix.'post INNER JOIN '.$dbprefix.'categorie
17989 ON '.$dbprefix.'post.cat_id = '.$dbprefix.'categorie.cat_id', ARRAY_A);
17990 }
17991
17992 function get_dc_comments()
17993 {
17994 global $wpdb;
17995 // General Housekeeping
17996 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
17997 set_magic_quotes_runtime(0);
17998 $dbprefix = get_option('dcdbprefix');
17999
18000 // Get Comments
18001 return $dcdb->get_results('SELECT * FROM '.$dbprefix.'comment', ARRAY_A);
18002 }
18003
18004 function get_dc_links()
18005 {
18006 //General Housekeeping
18007 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
18008 set_magic_quotes_runtime(0);
18009 $dbprefix = get_option('dcdbprefix');
18010
18011 return $dcdb->get_results('SELECT * FROM '.$dbprefix.'link ORDER BY position', ARRAY_A);
18012 }
18013
18014 function cat2wp($categories='')
18015 {
18016 // General Housekeeping
18017 global $wpdb;
18018 $count = 0;
18019 $dccat2wpcat = array();
18020 // Do the Magic
18021 if(is_array($categories))
18022 {
18023 echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
18024 foreach ($categories as $category)
18025 {
18026 $count++;
18027 extract($category);
18028
18029 // Make Nice Variables
18030 $name = $wpdb->escape($cat_libelle_url);
18031 $title = $wpdb->escape(csc ($cat_libelle));
18032 $desc = $wpdb->escape(csc ($cat_desc));
18033
18034 if($cinfo = category_exists($name))
18035 {
18036 $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
18037 }
18038 else
18039 {
18040 $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
18041 }
18042 $dccat2wpcat[$id] = $ret_id;
18043 }
18044
18045 // Store category translation for future use
18046 add_option('dccat2wpcat',$dccat2wpcat);
18047 echo '<p>'.sprintf(__ngettext('Done! <strong>%1$s</strong> category imported.', 'Done! <strong>%1$s</strong> categories imported.', $count), $count).'<br /><br /></p>';
18048 return true;
18049 }
18050 echo __('No Categories to Import!');
18051 return false;
18052 }
18053
18054 function users2wp($users='')
18055 {
18056 // General Housekeeping
18057 global $wpdb;
18058 $count = 0;
18059 $dcid2wpid = array();
18060
18061 // Midnight Mojo
18062 if(is_array($users))
18063 {
18064 echo '<p>'.__('Importing Users...').'<br /><br /></p>';
18065 foreach($users as $user)
18066 {
18067 $count++;
18068 extract($user);
18069
18070 // Make Nice Variables
18071 $name = $wpdb->escape(csc ($name));
18072 $RealName = $wpdb->escape(csc ($user_pseudo));
18073
18074 if($uinfo = get_userdatabylogin($name))
18075 {
18076
18077 $ret_id = wp_insert_user(array(
18078 'ID' => $uinfo->ID,
18079 'user_login' => $user_id,
18080 'user_nicename' => $Realname,
18081 'user_email' => $user_email,
18082 'user_url' => 'http://',
18083 'display_name' => $Realname)
18084 );
18085 }
18086 else
18087 {
18088 $ret_id = wp_insert_user(array(
18089 'user_login' => $user_id,
18090 'user_nicename' => csc ($user_pseudo),
18091 'user_email' => $user_email,
18092 'user_url' => 'http://',
18093 'display_name' => $Realname)
18094 );
18095 }
18096 $dcid2wpid[$user_id] = $ret_id;
18097
18098 // Set DotClear-to-WordPress permissions translation
18099
18100 // Update Usermeta Data
18101 $user = new WP_User($ret_id);
18102 $wp_perms = $user_level + 1;
18103 if(10 == $wp_perms) { $user->set_role('administrator'); }
18104 else if(9 == $wp_perms) { $user->set_role('editor'); }
18105 else if(5 <= $wp_perms) { $user->set_role('editor'); }
18106 else if(4 <= $wp_perms) { $user->set_role('author'); }
18107 else if(3 <= $wp_perms) { $user->set_role('contributor'); }
18108 else if(2 <= $wp_perms) { $user->set_role('contributor'); }
18109 else { $user->set_role('subscriber'); }
18110
18111 update_usermeta( $ret_id, 'wp_user_level', $wp_perms);
18112 update_usermeta( $ret_id, 'rich_editing', 'false');
18113 update_usermeta( $ret_id, 'first_name', csc ($user_prenom));
18114 update_usermeta( $ret_id, 'last_name', csc ($user_nom));
18115 }// End foreach($users as $user)
18116
18117 // Store id translation array for future use
18118 add_option('dcid2wpid',$dcid2wpid);
18119
18120
18121 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
18122 return true;
18123 }// End if(is_array($users)
18124
18125 echo __('No Users to Import!');
18126 return false;
18127
18128 }// End function user2wp()
18129
18130 function posts2wp($posts='')
18131 {
18132 // General Housekeeping
18133 global $wpdb;
18134 $count = 0;
18135 $dcposts2wpposts = array();
18136 $cats = array();
18137
18138 // Do the Magic
18139 if(is_array($posts))
18140 {
18141 echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
18142 foreach($posts as $post)
18143 {
18144 $count++;
18145 extract($post);
18146
18147 // Set DotClear-to-WordPress status translation
18148 $stattrans = array(0 => 'draft', 1 => 'publish');
18149 $comment_status_map = array (0 => 'closed', 1 => 'open');
18150
18151 //Can we do this more efficiently?
18152 $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1;
18153 $authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ;
18154
18155 $Title = $wpdb->escape(csc ($post_titre));
18156 $post_content = textconv ($post_content);
18157 $post_excerpt = "";
18158 if ($post_chapo != "") {
18159 $post_excerpt = textconv ($post_chapo);
18160 $post_content = $post_excerpt ."\n<!--more-->\n".$post_content;
18161 }
18162 $post_excerpt = $wpdb->escape ($post_excerpt);
18163 $post_content = $wpdb->escape ($post_content);
18164 $post_status = $stattrans[$post_pub];
18165
18166 // Import Post data into WordPress
18167
18168 if($pinfo = post_exists($Title,$post_content))
18169 {
18170 $ret_id = wp_insert_post(array(
18171 'ID' => $pinfo,
18172 'post_author' => $authorid,
18173 'post_date' => $post_dt,
18174 'post_date_gmt' => $post_dt,
18175 'post_modified' => $post_upddt,
18176 'post_modified_gmt' => $post_upddt,
18177 'post_title' => $Title,
18178 'post_content' => $post_content,
18179 'post_excerpt' => $post_excerpt,
18180 'post_status' => $post_status,
18181 'post_name' => $post_titre_url,
18182 'comment_status' => $comment_status_map[$post_open_comment],
18183 'ping_status' => $comment_status_map[$post_open_tb],
18184 'comment_count' => $post_nb_comment + $post_nb_trackback)
18185 );
18186 if ( is_wp_error( $ret_id ) )
18187 return $ret_id;
18188 }
18189 else
18190 {
18191 $ret_id = wp_insert_post(array(
18192 'post_author' => $authorid,
18193 'post_date' => $post_dt,
18194 'post_date_gmt' => $post_dt,
18195 'post_modified' => $post_modified_gmt,
18196 'post_modified_gmt' => $post_modified_gmt,
18197 'post_title' => $Title,
18198 'post_content' => $post_content,
18199 'post_excerpt' => $post_excerpt,
18200 'post_status' => $post_status,
18201 'post_name' => $post_titre_url,
18202 'comment_status' => $comment_status_map[$post_open_comment],
18203 'ping_status' => $comment_status_map[$post_open_tb],
18204 'comment_count' => $post_nb_comment + $post_nb_trackback)
18205 );
18206 if ( is_wp_error( $ret_id ) )
18207 return $ret_id;
18208 }
18209 $dcposts2wpposts[$post_id] = $ret_id;
18210
18211 // Make Post-to-Category associations
18212 $cats = array();
18213 $category1 = get_category_by_slug($post_cat_name);
18214 $category1 = $category1->term_id;
18215
18216 if($cat1 = $category1) { $cats[1] = $cat1; }
18217
18218 if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
18219 }
18220 }
18221 // Store ID translation for later use
18222 add_option('dcposts2wpposts',$dcposts2wpposts);
18223
18224 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
18225 return true;
18226 }
18227
18228 function comments2wp($comments='')
18229 {
18230 // General Housekeeping
18231 global $wpdb;
18232 $count = 0;
18233 $dccm2wpcm = array();
18234 $postarr = get_option('dcposts2wpposts');
18235
18236 // Magic Mojo
18237 if(is_array($comments))
18238 {
18239 echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
18240 foreach($comments as $comment)
18241 {
18242 $count++;
18243 extract($comment);
18244
18245 // WordPressify Data
18246 $comment_ID = (int) ltrim($comment_id, '0');
18247 $comment_post_ID = (int) $postarr[$post_id];
18248 $comment_approved = "$comment_pub";
18249 $name = $wpdb->escape(csc ($comment_auteur));
18250 $email = $wpdb->escape($comment_email);
18251 $web = "http://".$wpdb->escape($comment_site);
18252 $message = $wpdb->escape(textconv ($comment_content));
18253
18254 if($cinfo = comment_exists($name, $comment_dt))
18255 {
18256 // Update comments
18257 $ret_id = wp_update_comment(array(
18258 'comment_ID' => $cinfo,
18259 'comment_post_ID' => $comment_post_ID,
18260 'comment_author' => $name,
18261 'comment_author_email' => $email,
18262 'comment_author_url' => $web,
18263 'comment_author_IP' => $comment_ip,
18264 'comment_date' => $comment_dt,
18265 'comment_date_gmt' => $comment_dt,
18266 'comment_content' => $message,
18267 'comment_approved' => $comment_approved)
18268 );
18269 }
18270 else
18271 {
18272 // Insert comments
18273 $ret_id = wp_insert_comment(array(
18274 'comment_post_ID' => $comment_post_ID,
18275 'comment_author' => $name,
18276 'comment_author_email' => $email,
18277 'comment_author_url' => $web,
18278 'comment_author_IP' => $comment_ip,
18279 'comment_date' => $comment_dt,
18280 'comment_date_gmt' => $comment_dt,
18281 'comment_content' => $message,
18282 'comment_approved' => $comment_approved)
18283 );
18284 }
18285 $dccm2wpcm[$comment_ID] = $ret_id;
18286 }
18287 // Store Comment ID translation for future use
18288 add_option('dccm2wpcm', $dccm2wpcm);
18289
18290 // Associate newly formed categories with posts
18291 get_comment_count($ret_id);
18292
18293
18294 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
18295 return true;
18296 }
18297 echo __('No Comments to Import!');
18298 return false;
18299 }
18300
18301 function links2wp($links='')
18302 {
18303 // General Housekeeping
18304 global $wpdb;
18305 $count = 0;
18306
18307 // Deal with the links
18308 if(is_array($links))
18309 {
18310 echo '<p>'.__('Importing Links...').'<br /><br /></p>';
18311 foreach($links as $link)
18312 {
18313 $count++;
18314 extract($link);
18315
18316 if ($title != "") {
18317 if ($cinfo = is_term(csc ($title), 'link_category')) {
18318 $category = $cinfo['term_id'];
18319 } else {
18320 $category = wp_insert_term($wpdb->escape (csc ($title)), 'link_category');
18321 $category = $category['term_id'];
18322 }
18323 } else {
18324 $linkname = $wpdb->escape(csc ($label));
18325 $description = $wpdb->escape(csc ($title));
18326
18327 if($linfo = link_exists($linkname)) {
18328 $ret_id = wp_insert_link(array(
18329 'link_id' => $linfo,
18330 'link_url' => $href,
18331 'link_name' => $linkname,
18332 'link_category' => $category,
18333 'link_description' => $description)
18334 );
18335 } else {
18336 $ret_id = wp_insert_link(array(
18337 'link_url' => $url,
18338 'link_name' => $linkname,
18339 'link_category' => $category,
18340 'link_description' => $description)
18341 );
18342 }
18343 $dclinks2wplinks[$link_id] = $ret_id;
18344 }
18345 }
18346 add_option('dclinks2wplinks',$dclinks2wplinks);
18347 echo '<p>';
18348 printf(__ngettext('Done! <strong>%s</strong> link or link category imported.', 'Done! <strong>%s</strong> links or link categories imported.', $count), $count);
18349 echo '<br /><br /></p>';
18350 return true;
18351 }
18352 echo __('No Links to Import!');
18353 return false;
18354 }
18355
18356 function import_categories()
18357 {
18358 // Category Import
18359 $cats = $this->get_dc_cats();
18360 $this->cat2wp($cats);
18361 add_option('dc_cats', $cats);
18362
18363
18364
18365 echo '<form action="admin.php?import=dotclear&step=2" method="post">';
18366 wp_nonce_field('import-dotclear');
18367 printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Users')));
18368 echo '</form>';
18369
18370 }
18371
18372 function import_users()
18373 {
18374 // User Import
18375 $users = $this->get_dc_users();
18376 $this->users2wp($users);
18377
18378 echo '<form action="admin.php?import=dotclear&step=3" method="post">';
18379 wp_nonce_field('import-dotclear');
18380 printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Posts')));
18381 echo '</form>';
18382 }
18383
18384 function import_posts()
18385 {
18386 // Post Import
18387 $posts = $this->get_dc_posts();
18388 $result = $this->posts2wp($posts);
18389 if ( is_wp_error( $result ) )
18390 return $result;
18391
18392 echo '<form action="admin.php?import=dotclear&step=4" method="post">';
18393 wp_nonce_field('import-dotclear');
18394 printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Comments')));
18395 echo '</form>';
18396 }
18397
18398 function import_comments()
18399 {
18400 // Comment Import
18401 $comments = $this->get_dc_comments();
18402 $this->comments2wp($comments);
18403
18404 echo '<form action="admin.php?import=dotclear&step=5" method="post">';
18405 wp_nonce_field('import-dotclear');
18406 printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Links')));
18407 echo '</form>';
18408 }
18409
18410 function import_links()
18411 {
18412 //Link Import
18413 $links = $this->get_dc_links();
18414 $this->links2wp($links);
18415 add_option('dc_links', $links);
18416
18417 echo '<form action="admin.php?import=dotclear&step=6" method="post">';
18418 wp_nonce_field('import-dotclear');
18419 printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Finish')));
18420 echo '</form>';
18421 }
18422
18423 function cleanup_dcimport()
18424 {
18425 delete_option('dcdbprefix');
18426 delete_option('dc_cats');
18427 delete_option('dcid2wpid');
18428 delete_option('dccat2wpcat');
18429 delete_option('dcposts2wpposts');
18430 delete_option('dccm2wpcm');
18431 delete_option('dclinks2wplinks');
18432 delete_option('dcuser');
18433 delete_option('dcpass');
18434 delete_option('dcname');
18435 delete_option('dchost');
18436 delete_option('dccharset');
18437 do_action('import_done', 'dotclear');
18438 $this->tips();
18439 }
18440
18441 function tips()
18442 {
18443 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>';
18444 echo '<h3>'.__('Users').'</h3>';
18445 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>';
18446 echo '<h3>'.__('Preserving Authors').'</h3>';
18447 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>';
18448 echo '<h3>'.__('Textile').'</h3>';
18449 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>';
18450 echo '<h3>'.__('WordPress Resources').'</h3>';
18451 echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>';
18452 echo '<ul>';
18453 echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>';
18454 echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>';
18455 echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
18456 echo '</ul>';
18457 echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '../wp-login.php').'</p>';
18458 }
18459
18460 function db_form()
18461 {
18462 echo '<table class="form-table">';
18463 printf('<tr><th><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('DotClear Database User:'));
18464 printf('<tr><th><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('DotClear Database Password:'));
18465 printf('<tr><th><label for="dbname">%s</label></th><td><input type="text" name="dbname" id="dbname" /></td></tr>', __('DotClear Database Name:'));
18466 printf('<tr><th><label for="dbhost">%s</label></th><td><input type="text" name="dbhost" id="dbhost" value="localhost" /></td></tr>', __('DotClear Database Host:'));
18467 printf('<tr><th><label for="dbprefix">%s</label></th><td><input type="text" name="dbprefix" id="dbprefix" value="dc_"/></td></tr>', __('DotClear Table prefix:'));
18468 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:'));
18469 echo '</table>';
18470 }
18471
18472 function dispatch()
18473 {
18474
18475 if (empty ($_GET['step']))
18476 $step = 0;
18477 else
18478 $step = (int) $_GET['step'];
18479 $this->header();
18480
18481 if ( $step > 0 )
18482 {
18483 check_admin_referer('import-dotclear');
18484
18485 if($_POST['dbuser'])
18486 {
18487 if(get_option('dcuser'))
18488 delete_option('dcuser');
18489 add_option('dcuser', sanitize_user($_POST['dbuser'], true));
18490 }
18491 if($_POST['dbpass'])
18492 {
18493 if(get_option('dcpass'))
18494 delete_option('dcpass');
18495 add_option('dcpass', sanitize_user($_POST['dbpass'], true));
18496 }
18497
18498 if($_POST['dbname'])
18499 {
18500 if(get_option('dcname'))
18501 delete_option('dcname');
18502 add_option('dcname', sanitize_user($_POST['dbname'], true));
18503 }
18504 if($_POST['dbhost'])
18505 {
18506 if(get_option('dchost'))
18507 delete_option('dchost');
18508 add_option('dchost', sanitize_user($_POST['dbhost'], true));
18509 }
18510 if($_POST['dccharset'])
18511 {
18512 if(get_option('dccharset'))
18513 delete_option('dccharset');
18514 add_option('dccharset', sanitize_user($_POST['dccharset'], true));
18515 }
18516 if($_POST['dbprefix'])
18517 {
18518 if(get_option('dcdbprefix'))
18519 delete_option('dcdbprefix');
18520 add_option('dcdbprefix', sanitize_user($_POST['dbprefix'], true));
18521 }
18522
18523
18524 }
18525
18526 switch ($step)
18527 {
18528 default:
18529 case 0 :
18530 $this->greet();
18531 break;
18532 case 1 :
18533 $this->import_categories();
18534 break;
18535 case 2 :
18536 $this->import_users();
18537 break;
18538 case 3 :
18539 $result = $this->import_posts();
18540 if ( is_wp_error( $result ) )
18541 echo $result->get_error_message();
18542 break;
18543 case 4 :
18544 $this->import_comments();
18545 break;
18546 case 5 :
18547 $this->import_links();
18548 break;
18549 case 6 :
18550 $this->cleanup_dcimport();
18551 break;
18552 }
18553
18554 $this->footer();
18555 }
18556
18557 function Dotclear_Import()
18558 {
18559 // Nothing.
18560 }
18561 }
18562
18563 $dc_import = new Dotclear_Import();
18564
18565 register_importer('dotclear', __('DotClear'), __('Import categories, users, posts, comments, and links from a DotClear blog.'), array ($dc_import, 'dispatch'));
18566
18567 ?>