WordPress

Howdy! We’re about to begin the process to import all of your bBlog entries into WordPress. Before we get started, you need to edit this file (import-bblog.php) and change a few lines so we know where to find your bBlog database.

Look for the line that says:

define('BBLOG_DB', '');

and change it to

define('BBLOG_DB', 'my_database');

Do the same for the rest of the lines (Both BBLOG location and WP location).

If you've done that and you’re all ready, let's go! Remember that the import process may take a minute or so if you have a large number of entries and comments.

If for some reason the script doesn't complete the import, drop all wp_ tables, resintall and start again.

Import your bBlog posts to Wordpress! »

Check here for details.
' . mysql_error()); } if (!$db=mysql_select_db(BBLOG_DB)) {die('Error selecting database. Make sure your properly edited import-bblog.php. Check here for details.
' . mysql_error());} $sql="SELECT value FROM ".BBLOG_PREFIX."config where name='BLOGNAME'"; $result=mysql_query($sql); if (mysql_num_rows($result)<1) { die(BBLOG_DB.' does not seem to be a valid database name. Make sure you\'ve properly edited import-bblog.php.
'); } else { echo "Connected to database for blog ". mysql_result($result,0) ."

"; } $sql="SELECT postid, title, body, posttime, sections, commentcount FROM ".BBLOG_PREFIX."posts"; $result = mysql_query($sql); $postnum=-1; while ($row = mysql_fetch_assoc($result)) { $postnum++; $posts[$postnum]->id=$row["postid"]; $posts[$postnum]->posttime=$row["posttime"]; $posts[$postnum]->title=$row["title"]; $posts[$postnum]->body=$row["body"]; $posts[$postnum]->commentcount=$row["commentcount"]; $sections=explode(":",$row['sections']); foreach ($sections as $id) { if ($id=="") { continue; } else { //$posts[$postnum]->sections[]=$id; $sql="SELECT nicename FROM ".BBLOG_PREFIX."sections WHERE sectionid=$id"; $catres=mysql_query($sql); while ($catrow = mysql_fetch_array($catres)) { $posts[$postnum]->sections[]=$catrow[0]; } } } // Get Comments $sql="SELECT commentid, title, posttime, postername, posteremail, posterwebsite, pubemail, pubwebsite, commenttext, ip FROM ".BBLOG_PREFIX."comments WHERE postid=".$posts[$postnum]->id; $commentres=mysql_query($sql); while ($row = mysql_fetch_assoc($commentres)) { if (sizeof($row)>0) { //comment $posts[$postnum]->comments[]->commentid=$row['commentid']; $arrayid=sizeof($posts[$postnum]->comments)-1; $posts[$postnum]->comments[$arrayid]->parentid=$row['parentid']; $posts[$postnum]->comments[$arrayid]->title=mysql_escape_string($row['title']); $posts[$postnum]->comments[$arrayid]->posttime=$row['posttime']; $posts[$postnum]->comments[$arrayid]->postername=mysql_escape_string($row['postername']); $posts[$postnum]->comments[$arrayid]->commenttext=mysql_escape_string($row['commenttext']); $posts[$postnum]->comments[$arrayid]->ip=mysql_escape_string($row['ip']); if ($row['pubemail']=='1') { $posts[$postnum]->comments[$arrayid]->posteremail=$row['posteremail']; } if ($row['pubwebsite']=='1') { $posts[$postnum]->comments[$arrayid]->posterwebsite=$row['posterwebsite']; } } else { continue; } } } mysql_close($link); mysql_connect(WP_HOST,WP_USER,WP_PASS); mysql_select_db(WP_DB); foreach ($posts as $post) { if ($post->posttime) { $post_date=strftime("%G-%m-%d %T", $post->posttime); } $post_name = mysql_escape_string(sanitize_title($post->title)); unset($categories); foreach($post->sections as $section) { $categories[]=$section; } $title=mysql_escape_string($post->title); $body=mysql_escape_string($post->body); $commentcount=mysql_escape_string($post->commentcount); $wpdb->query("INSERT INTO $tableposts (post_author, post_date, post_date_gmt, post_content, post_title,post_status, comment_status, ping_status, post_name) VALUES ('$import_userid', '$post_date', '$post_date', '$body', '$title', 'publish', 'open', 'open', '$post_name')"); $post_id = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'"); $post_id = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'"); if (!$post_id) die("couldn't get post ID"); if (0 != count($categories)) : foreach ($categories as $post_category) : //$post_category = $post_category;//unhtmlentities($post_category); // See if the category exists yet $cat_id = $wpdb->get_var("SELECT cat_ID from $tablecategories WHERE cat_name = '$post_category'"); if (!$cat_id && '' != trim($post_category)) { $cat_nicename = sanitize_title($post_category); $wpdb->query("INSERT INTO $tablecategories (cat_name, category_nicename) VALUES ('$post_category', '$cat_nicename')"); $cat_id = $wpdb->get_var("SELECT cat_ID from $tablecategories WHERE cat_name = '$post_category'"); } if ('' == trim($post_category)) $cat_id = 1; // Double check it's not there already $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_id AND category_id = $cat_id"); if (!$exists) { $wpdb->query(" INSERT INTO $tablepost2cat (post_id, category_id) VALUES ($post_id, $cat_id) "); } endforeach; else: $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_id AND category_id = 1"); if (!$exists) $wpdb->query("INSERT INTO $tablepost2cat (post_id, category_id) VALUES ($post_id, 1) "); endif; if (0 != count($post->comments)) { foreach($post->comments as $comment) { $comment_post_date=strftime("%G-%m-%d %T", $comment->posttime); $author=$comment->postername; $author_email=$comment->posteremail; $author_www=$comment->posterwebsite; $text=$comment->commenttext; $title=$comment->title; $ip=$comment->ip; $sql="INSERT INTO $tablecomments (comment_post_id,comment_author,comment_author_email,comment_author_url,comment_date,comment_date_gmt,comment_content,comment_approved,comment_author_ip) VALUES('$post_id','$author','$author_email','$author_www','$comment_post_date','$comment_post_date','$text','1','$ip')"; $wpdb->query($sql); } } echo "
  • Inserted Post Title $title
  • "; echo "
  • Comment Count $commentcount
  • "; echo "
  • Post ID $post_id

  • "; $wpdb->query( "UPDATE $tableposts SET comment_count = '$commentcount' WHERE ID = '$post_id'" ); } ?>

    All done. Have fun!