X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/3e7fab96d7874067884348df10bbdcdefa4a89ad..9cd344f9b14dd8e0743c1417fdb379b1431c3988:/wp-admin/import/dotclear.php diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php index 1bf04860..fcde9b17 100644 --- a/wp-admin/import/dotclear.php +++ b/wp-admin/import/dotclear.php @@ -1,7 +1,11 @@ get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID); + return $wpdb->get_var( $wpdb->prepare("SELECT count(*) FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); } } if(!function_exists('link_exists')) { + /** + * Check whether link already exists. + * + * @package WordPress + * @subpackage Dotclear_Import + * + * @param string $linkname + * @return int + */ function link_exists($linkname) { global $wpdb; - return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$linkname.'"'); - } -} - -/* - Identify UTF-8 text - Taken from http://www.php.net/manual/fr/function.mb-detect-encoding.php#50087 -*/ -// -// utf8 encoding validation developed based on Wikipedia entry at: -// http://en.wikipedia.org/wiki/UTF-8 -// -// Implemented as a recursive descent parser based on a simple state machine -// copyright 2005 Maarten Meijer -// -// This cries out for a C-implementation to be included in PHP core -// - -function valid_1byte($char) { - if(!is_int($char)) return false; - return ($char & 0x80) == 0x00; -} - -function valid_2byte($char) { - if(!is_int($char)) return false; - return ($char & 0xE0) == 0xC0; -} - -function valid_3byte($char) { - if(!is_int($char)) return false; - return ($char & 0xF0) == 0xE0; -} - -function valid_4byte($char) { - if(!is_int($char)) return false; - return ($char & 0xF8) == 0xF0; -} - -function valid_nextbyte($char) { - if(!is_int($char)) return false; - return ($char & 0xC0) == 0x80; -} - -function valid_utf8($string) { - $len = strlen($string); - $i = 0; - while( $i < $len ) { - $char = ord(substr($string, $i++, 1)); - if(valid_1byte($char)) { // continue - continue; - } else if(valid_2byte($char)) { // check 1 byte - if(!valid_nextbyte(ord(substr($string, $i++, 1)))) - return false; - } else if(valid_3byte($char)) { // check 2 bytes - if(!valid_nextbyte(ord(substr($string, $i++, 1)))) - return false; - if(!valid_nextbyte(ord(substr($string, $i++, 1)))) - return false; - } else if(valid_4byte($char)) { // check 3 bytes - if(!valid_nextbyte(ord(substr($string, $i++, 1)))) - return false; - if(!valid_nextbyte(ord(substr($string, $i++, 1)))) - return false; - if(!valid_nextbyte(ord(substr($string, $i++, 1)))) - return false; - } // goto next char + return $wpdb->get_var( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_name = %s", $linkname) ); } - return true; // done } +/** + * Convert from dotclear charset to utf8 if required + * + * @package WordPress + * @subpackage Dotclear_Import + * + * @param string $s + * @return string + */ function csc ($s) { - if (valid_utf8 ($s)) { + if (seems_utf8 ($s)) { return $s; } else { return iconv(get_option ("dccharset"),"UTF-8",$s); } } +/** + * @package WordPress + * @subpackage Dotclear_Import + * + * @param string $s + * @return string + */ function textconv ($s) { return csc (preg_replace ('|(?)\s*\n|', ' ', $s)); } /** - The Main Importer Class -**/ + * Dotclear Importer class + * + * Will process the WordPress eXtended RSS files that you upload from the export + * file. + * + * @package WordPress + * @subpackage Importer + * + * @since unknown + */ class Dotclear_Import { function header() { echo '
'; + screen_icon(); echo '

'.__('Import DotClear').'

'; echo '

'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'

'; } @@ -128,7 +109,7 @@ class Dotclear_Import { echo '
'; wp_nonce_field('import-dotclear'); $this->db_form(); - echo '

'; + echo '

'; echo '
'; } @@ -225,7 +206,7 @@ class Dotclear_Import { // Store category translation for future use add_option('dccat2wpcat',$dccat2wpcat); - echo '

'.sprintf(__('Done! %1$s categories imported.'), $count).'

'; + echo '

'.sprintf(_n('Done! %1$s category imported.', 'Done! %1$s categories imported.', $count), $count).'

'; return true; } echo __('No Categories to Import!'); @@ -432,11 +413,7 @@ class Dotclear_Import { $web = "http://".$wpdb->escape($comment_site); $message = $wpdb->escape(textconv ($comment_content)); - if($cinfo = comment_exists($name, $comment_dt)) - { - // Update comments - $ret_id = wp_update_comment(array( - 'comment_ID' => $cinfo, + $comment = array( 'comment_post_ID' => $comment_post_ID, 'comment_author' => $name, 'comment_author_email' => $email, @@ -445,23 +422,16 @@ class Dotclear_Import { 'comment_date' => $comment_dt, 'comment_date_gmt' => $comment_dt, 'comment_content' => $message, - 'comment_approved' => $comment_approved) - ); - } - else - { + 'comment_approved' => $comment_approved); + $comment = wp_filter_comment($comment); + + if ( $cinfo = comment_exists($name, $comment_dt) ) { + // Update comments + $comment['comment_ID'] = $cinfo; + $ret_id = wp_update_comment($comment); + } else { // Insert comments - $ret_id = wp_insert_comment(array( - 'comment_post_ID' => $comment_post_ID, - 'comment_author' => $name, - 'comment_author_email' => $email, - 'comment_author_url' => $web, - 'comment_author_IP' => $comment_ip, - 'comment_date' => $comment_dt, - 'comment_date_gmt' => $comment_dt, - 'comment_content' => $message, - 'comment_approved' => $comment_approved) - ); + $ret_id = wp_insert_comment($comment); } $dccm2wpcm[$comment_ID] = $ret_id; } @@ -526,7 +496,7 @@ class Dotclear_Import { } add_option('dclinks2wplinks',$dclinks2wplinks); echo '

'; - printf(__('Done! %s links or link categories imported'), $count); + printf(_n('Done! %s link or link category imported.', 'Done! %s links or link categories imported.', $count), $count); echo '

'; return true; } @@ -545,7 +515,7 @@ class Dotclear_Import { echo '
'; wp_nonce_field('import-dotclear'); - printf('', attribute_escape(__('Import Users'))); + printf('

', esc_attr__('Import Users')); echo '
'; } @@ -558,7 +528,7 @@ class Dotclear_Import { echo '
'; wp_nonce_field('import-dotclear'); - printf('', attribute_escape(__('Import Posts'))); + printf('

', esc_attr__('Import Posts')); echo '
'; } @@ -572,7 +542,7 @@ class Dotclear_Import { echo '
'; wp_nonce_field('import-dotclear'); - printf('', attribute_escape(__('Import Comments'))); + printf('

', esc_attr__('Import Comments')); echo '
'; } @@ -584,7 +554,7 @@ class Dotclear_Import { echo '
'; wp_nonce_field('import-dotclear'); - printf('', attribute_escape(__('Import Links'))); + printf('

', esc_attr__('Import Links')); echo '
'; } @@ -597,7 +567,7 @@ class Dotclear_Import { echo '
'; wp_nonce_field('import-dotclear'); - printf('', attribute_escape(__('Finish'))); + printf('

', esc_attr__('Finish')); echo '
'; } @@ -615,6 +585,7 @@ class Dotclear_Import { delete_option('dcname'); delete_option('dchost'); delete_option('dccharset'); + do_action('import_done', 'dotclear'); $this->tips(); } @@ -622,11 +593,11 @@ class Dotclear_Import { { echo '

'.__('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.').'

'; echo '

'.__('Users').'

'; - echo '

'.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. Every user has the same username, but their passwords are reset to password123. So Login and change it.'), '/wp-login.php').'

'; + echo '

'.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. Every user has the same username, but their passwords are reset to password123. So Log in and change it.'), '/wp-login.php').'

'; echo '

'.__('Preserving Authors').'

'; echo '

'.__('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.').'

'; echo '

'.__('Textile').'

'; - echo '

'.__('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 Textile for WordPress. Trust me... You\'ll want it.').'

'; + echo '

'.__('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 Textile for WordPress. Trust me… You’ll want it.').'

'; echo '

'.__('WordPress Resources').'

'; echo '

'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'

'; echo ''; - echo '

'.sprintf(__('That\'s it! What are you waiting for? Go login!'), '../wp-login.php').'

'; + echo '

'.sprintf(__('That’s it! What are you waiting for? Go log in!'), '../wp-login.php').'

'; } function db_form() { - echo ''; + echo '
'; printf('', __('DotClear Database User:')); printf('', __('DotClear Database Password:')); printf('', __('DotClear Database Name:')); - printf('', __('DotClear Database Host:')); + printf('', __('DotClear Database Host:')); printf('', __('DotClear Table prefix:')); printf('', __('Originating character set:')); echo '
'; @@ -741,5 +712,7 @@ class Dotclear_Import { } $dc_import = new Dotclear_Import(); -register_importer('dotclear', __('DotClear'), __('Import categories, users, posts, comments, and links from a DotClear blog'), array ($dc_import, 'dispatch')); + +register_importer('dotclear', __('DotClear'), __('Import categories, users, posts, comments, and links from a DotClear blog.'), array ($dc_import, 'dispatch')); + ?>