WordPress 1.2 Import script * @author: James Sasitorn * @email camus@onegoodcookie.com * * This file should be put in wp-admin/ * * 1. I assume Nucleus and WordPress share the same mysql database * 2. It allows you to only import one nucleus blog at a time * 3. It imports users, posts, and comments based on unique titles. * 4. It doesnt correctly import blog settings (not a big deal) * 5. User names are imported as Nicknames (doesnt fill in First/last) * 6. It doesnt handle Nucleus karma. * * * 2005.02.14: added table prefix listed below $table_prefix for * nueclues table prefix.. Would be better to put this in the gui * * * also cleaned up a typo in the insertion of categories.. * * stopped that pesky 'We're done. have fun' from being on all screens * * stored blog_id from nucleus as session_var. * Should put table_prefix as a html option * * 2005.03.11: Integrate changes by Naoki Haga (kyodai.com) * * Changes improve user mapping and comment handling * * Story details includes both the excerpt \n\n and the content * * Set default user level to 0 */ if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. Double check that you updated wp-config-sample.php with the proper database connection information and renamed it to wp-config.php."); require_once('../wp-config.php'); require('upgrade-functions.php'); /* configuration.. nucleus table prefix.. blah_nucleus_.. */ //$tbl_prefix="ta_"; $tbl_prefix=""; $step = $_GET['step']; if (!$step) $step = 0; if (isset ($_POST['import_blog_id'])) { $import_blog_id = $_POST['import_blog_id']; session_register('import_blog_id'); } ?>
Welcome to WordPress. Since you’re upgrading from Nucelus thins will change a bit. Here are some notes on upgrading:
config.php
to wp-config.php file.Have you looked at the readme? If you’re all ready, let’s go!
Okay first we’re going to set up the links database. You will need to choose which blog you will be importing. We will import the categories, posts, members and comments from this blog. We will not import any blog settings. You will need to do that manually.
Checking for tables...
Select the blog to import.
'; $sql = "SELECT * from ${tbl_prefix}nucleus_blog order by bnumber"; $result = $wpdb->get_results($sql) or print ("Can't query ${tbl_prefix}nucleus_blogDeleting older posts...
$query = "TRUNCATE $tablecategories"; echo $query ."First we’re going to import categories.
get_results($sql); foreach ($result as $category) { // See if the category exists yet $category->cdesc = str_replace("'", "\\'", $category->cdesc); $cat_id = $wpdb->get_var("SELECT cat_ID from $tablecategories WHERE cat_name = '{$category->cname}'"); if ($cat_id) { echo ".. '{$category->cname}' already existsNext we’re going to import nucleus members.
$user_map[1] = 1; //map admin user $sql = "SELECT nucleus_member.* from ${tbl_prefix}nucleus_member as nucleus_member,${tbl_prefix}nucleus_team as nucleus_team WHERE " . " nucleus_team.tmember=nucleus_member.mnumber AND " . " nucleus_team.tblog={$import_blog_id} "; $result = $wpdb->get_results($sql); foreach ($result as $user) { // See if the category exists yet $user_id = $wpdb->get_var("SELECT ID from $tableusers WHERE user_login = '{$user->mname}'"); if ($user_id != 1) { //lowest is 1 and we auto map that to admin $user->mnotes = str_replace("'", "\\'", $user->mnotes); $query = "INSERT INTO $tableusers (user_login, user_nickname, user_pass,user_email, user_url, ". " user_description, user_domain, user_ip, user_level, user_idmode) VALUES ". " ('{$user->mname}', '{$user->mrealname}', '{$user->mpassword}','{$user->memail}', '{$user->murl}', ". " '{$user->mnotes}', '127.0.0.1','127.0.0.1', 0, 'nickname' )"; //echo $query ."Next we’re going to import nucleus posts.
$sql = "SELECT * from ${tbl_prefix}nucleus_item WHERE iblog=$import_blog_id order by inumber"; $result = $wpdb->get_results($sql); foreach ($result as $post) { $post_title = addslashes($post->ititle); $post_id = $wpdb->get_var("SELECT ID from $tableposts WHERE post_title = '$post_title'"); $post_category = $category_map[$post->icat]; if (!$post_id) { if (trim($post->imore) != "") { $post_excerpt = addslashes($post->ibody); $post_content = $post_excerpt ."\n\n". addslashes($post->imore); } else { $post_excerpt = ''; $post_content = addslashes($post->ibody); } $post_excerpt = str_replace("Looks like we are done now. Have fun!
"; } ?>