dotclear.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 742 行 · 第 1/2 页
PHP
742 行
'post_content' => $post_content, 'post_excerpt' => $post_excerpt, 'post_status' => $post_status, 'post_name' => $post_titre_url, 'comment_status' => $comment_status_map[$post_open_comment], 'ping_status' => $comment_status_map[$post_open_tb], 'comment_count' => $post_nb_comment + $post_nb_trackback) ); } else { $ret_id = wp_insert_post(array( 'post_author' => $authorid, 'post_date' => $post_dt, 'post_date_gmt' => $post_dt, 'post_modified' => $post_modified_gmt, 'post_modified_gmt' => $post_modified_gmt, 'post_title' => $Title, 'post_content' => $post_content, 'post_excerpt' => $post_excerpt, 'post_status' => $post_status, 'post_name' => $post_titre_url, 'comment_status' => $comment_status_map[$post_open_comment], 'ping_status' => $comment_status_map[$post_open_tb], 'comment_count' => $post_nb_comment + $post_nb_trackback) ); } $dcposts2wpposts[$post_id] = $ret_id; // Make Post-to-Category associations $cats = array(); if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; } if(!empty($cats)) { wp_set_post_cats('', $ret_id, $cats); } } } // Store ID translation for later use add_option('dcposts2wpposts',$dcposts2wpposts); echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>'; return true; } function comments2wp($comments='') { // General Housekeeping global $wpdb; $count = 0; $dccm2wpcm = array(); $postarr = get_option('dcposts2wpposts'); // Magic Mojo if(is_array($comments)) { echo '<p>'.__('Importing Comments...').'<br /><br /></p>'; foreach($comments as $comment) { $count++; extract($comment); // WordPressify Data $comment_ID = ltrim($comment_id, '0'); $comment_post_ID = $postarr[$post_id]; $comment_approved = "$comment_pub"; $name = $wpdb->escape(csc ($comment_auteur)); $email = $wpdb->escape($comment_email); $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_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) ); } 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) ); } $dccm2wpcm[$comment_ID] = $ret_id; } // Store Comment ID translation for future use add_option('dccm2wpcm', $dccm2wpcm); // Associate newly formed categories with posts get_comment_count($ret_id); echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>'; return true; } echo __('No Comments to Import!'); return false; } function links2wp($links='') { // General Housekeeping global $wpdb; $count = 0; // Deal with the links if(is_array($links)) { echo '<p>'.__('Importing Links...').'<br /><br /></p>'; foreach($links as $link) { $count++; extract($link); if ($title != "") { if ($cinfo = link_cat_exists (csc ($title))) { $category = $cinfo; } else { $wpdb->query ("INSERT INTO $wpdb->linkcategories (cat_name) VALUES ('". $wpdb->escape (csc ($title))."')"); $category = $wpdb->insert_id; } } else { $linkname = $wpdb->escape(csc ($label)); $description = $wpdb->escape(csc ($title)); if($linfo = link_exists($linkname)) { $ret_id = wp_insert_link(array( 'link_id' => $linfo, 'link_url' => $href, 'link_name' => $linkname, 'link_category' => $category, 'link_description' => $description) ); } else { $ret_id = wp_insert_link(array( 'link_url' => $url, 'link_name' => $linkname, 'link_category' => $category, 'link_description' => $description) ); } $dclinks2wplinks[$link_id] = $ret_id; } } add_option('dclinks2wplinks',$dclinks2wplinks); echo '<p>'; printf(__('Done! <strong>%s</strong> links or link categories imported'), $count); echo '<br /><br /></p>'; return true; } echo __('No Links to Import!'); return false; } function import_categories() { // Category Import $cats = $this->get_dc_cats(); $this->cat2wp($cats); add_option('dc_cats', $cats); echo '<form action="admin.php?import=dotclear&step=2" method="post">'; printf('<input type="submit" name="submit" value="%s" />', __('Import Users')); echo '</form>'; } function import_users() { // User Import $users = $this->get_dc_users(); $this->users2wp($users); echo '<form action="admin.php?import=dotclear&step=3" method="post">'; printf('<input type="submit" name="submit" value="%s" />', __('Import Posts')); echo '</form>'; } function import_posts() { // Post Import $posts = $this->get_dc_posts(); $this->posts2wp($posts); echo '<form action="admin.php?import=dotclear&step=4" method="post">'; printf('<input type="submit" name="submit" value="%s" />', __('Import Comments')); echo '</form>'; } function import_comments() { // Comment Import $comments = $this->get_dc_comments(); $this->comments2wp($comments); echo '<form action="admin.php?import=dotclear&step=5" method="post">'; printf('<input type="submit" name="submit" value="%s" />', __('Import Links')); echo '</form>'; } function import_links() { //Link Import $links = $this->get_dc_links(); $this->links2wp($links); add_option('dc_links', $links); echo '<form action="admin.php?import=dotclear&step=6" method="post">'; printf('<input type="submit" name="submit" value="%s" />', __('Finish')); echo '</form>'; } function cleanup_dcimport() { delete_option('tpre'); delete_option('dc_cats'); delete_option('dcid2wpid'); delete_option('dccat2wpcat'); delete_option('dcposts2wpposts'); delete_option('dccm2wpcm'); delete_option('dclinks2wplinks'); delete_option('dcuser'); delete_option('dcpass'); delete_option('dcname'); delete_option('dchost'); delete_option('dccharset'); $this->tips(); } function tips() { 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>'; echo '<h3>'.__('Users').'</h3>'; 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>'; echo '<h3>'.__('Preserving Authors').'</h3>'; 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>'; echo '<h3>'.__('Textile').'</h3>'; 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>'; echo '<h3>'.__('WordPress Resources').'</h3>'; echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>'; echo '<ul>'; echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>'; echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums').'</li>'; echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>'; echo '</ul>'; echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>'; } function db_form() { echo '<ul>'; printf('<li><label for="dbuser">%s</label> <input type="text" name="dbuser" id="dbuser" /></li>', __('Dotclear Database User:')); printf('<li><label for="dbpass">%s</label> <input type="password" name="dbpass" id="dbpass" /></li>', __('Dotclear Database Password:')); printf('<li><label for="dbname">%s</label> <input type="text" name="dbname" id="dbname" /></li>', __('Dotclear Database Name:')); printf('<li><label for="dbhost">%s</label> <input type="text" name="dbhost" id="dbhost" value="localhost" /></li>', __('Dotclear Database Host:')); /* printf('<li><label for="dbprefix">%s</label> <input type="text" name="dbprefix" /></li>', __('Dotclear Table prefix (if any):')); */ printf('<li><label for="dccharset">%s</label> <input type="text" id="dccharset" name="dccharset" value="ISO-8859-15"/></li>', __('Originating character set:')); echo '</ul>'; } function dispatch() { if (empty ($_GET['step'])) $step = 0; else $step = (int) $_GET['step']; $this->header(); if ( $step > 0 ) { if($_POST['dbuser']) { if(get_option('dcuser')) delete_option('dcuser'); add_option('dcuser',$_POST['dbuser']); } if($_POST['dbpass']) { if(get_option('dcpass')) delete_option('dcpass'); add_option('dcpass',$_POST['dbpass']); } if($_POST['dbname']) { if(get_option('dcname')) delete_option('dcname'); add_option('dcname',$_POST['dbname']); } if($_POST['dbhost']) { if(get_option('dchost')) delete_option('dchost'); add_option('dchost',$_POST['dbhost']); } if($_POST['dccharset']) { if(get_option('dccharset')) delete_option('dccharset'); add_option('dccharset',$_POST['dccharset']); } if($_POST['dbprefix']) { if(get_option('tpre')) delete_option('tpre'); add_option('tpre',$_POST['dbprefix']); } } switch ($step) { default: case 0 : $this->greet(); break; case 1 : $this->import_categories(); break; case 2 : $this->import_users(); break; case 3 : $this->import_posts(); break; case 4 : $this->import_comments(); break; case 5 : $this->import_links(); break; case 6 : $this->cleanup_dcimport(); break; } $this->footer(); } function Dotclear_Import() { // Nothing. }}$dc_import = new Dotclear_Import();register_importer('dotclear', 'Dotclear', __('Import posts from a Dotclear Blog'), array ($dc_import, 'dispatch'));?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?