Converting bBlog 0.76 to Wordpress 2.0 (Import/Export) Script
I had this hanging around for a while so I thought I may aswell publish it.
I tried quite a few import scripts to get my posts and comments from my old bBlog install over to my new Wordpress 2.0.1 installation, but none of them worked properly.
I found one in php which worked for Wordpress 1.5.2 and tweaked until it worked on 2.0.x series, it also imports some extra info like commentors IP addresses. (I suggest this one for 1.5.x)
It took me a long time to get it to update the comment count on Wordpress properly.
Imports categories properly, simplified it and I straightened up the workflow a bit.

If you have a newer version of bBlog it should be pretty trivial to get it to work.
The original came from here:
So here you go, an easy to use and reliable bBlog to Wordpress import script!
You can download my bBlog to Wordpress 2.0 converter here.
16 commentsPHP File buffer
Ok, so it has been said that normal posts here are “techy DIY” so I'll give that a go. Recently I have been working on a template engine, its not just varable replacement, its more for the back end and controls the way the site is built, not just the way it looks.
There are some quirks with the PHP 4 object model that make the job a little bit ugly, mainly the missing property access methods. But to parse the template file we can basicly use a cascading object tree, passing a file buffer down a tree as its built.
The reason for using the buffer is speed, its quicker to just read the whole file in to memory, and then just pop along it. Using an object means we don't also have to pass the index with the buffer as well as being just hand for adding short functions.
Any way, as I am still working on the main parser part, or at least the latest version there of. I'll go with the file buffer. It a fairly straight forward object.
<? // filebuffer.class.php
require_once('base.class.php') ;
//error codes ;
define("_FILEBUFFER_ERROR_MISSING_FILE_", -10001) ;
class baseBufferClass extends baseClass {
var $buffer ;
var $bufferSize ;
var $bufferPointer ;
function baseBufferClass() {
parent::baseClass() ;
$this->buffer = "" ;
$this->bufferSize = 0 ;
$this->bufferPointer = 0 ;
}
function readChar() {
$result = false ;
$this->bufferSize = strLen($this->buffer) ;
if ($this->bufferSize > 0) {
if ($this->bufferPointer < $this->bufferSize) {
$result = $this->buffer[$this->bufferPointer] ;
$this->bufferPointer = $this->bufferPointer + 1 ;
}
}
return $result ;
}
}
class fileBuffer extends baseBufferClass {
var $fileName ;
var $fileOpen ;
var $error ;
var $fileHandle ;
function fileBuffer($fileName="") {
parent::baseBufferClass() ;
$this->fileOpen = false ;
$this->fileName = "" ;
$this->fileBuffer = "" ;
$this->bufferSize = 0 ;
$this->filePointer = 0 ;
if (strLen($fileName) >0) {
$this->fileName = $fileName ;
$this->openFile() ;
}
}
function openFile($fileName="") {
if ($this->fileOpen) {
$this->closeFile() ;
}
if (strLen($fileName) >0) {
$this->fileName = $fileName ;
}
if (file_Exists($this->fileName)) {
$this->buffer = file_get_contents($this->fileName) ;
$this->bufferSize = strLen($this->buffer) ;
$this->fileOpen = true ;
}
else {
$this->error = _FILEBUFFER_ERROR_MISSING_FILE_ ;
$result = false ;
}
}
function closeFile() {
$this->fileBuffer = "" ;
$this->bufferSize = 0 ;
$this->filePointer = 0 ;
$this->fileOpen = false ;
}
}
?>
The base class in this case doesn't do any thing, I just use it as good style.
BaseBufferClass is used as a basic buffer, this can then be passed around as a slightly lighter buffer in the parser objects. It maintains the storage and pointer.
The file buffer class then extends the baseBufferClass to add file access. This is mainly done by the use of the constructor and openFile methods. When a file name is passed in the constructor openFile is then called to load the data from the file. If the file name is not passed, then openFile can be called directly.
Its not the worlds most complicated bit of code, but it fairly handy.
2 commentsSearch/Find and Replace Using phpMyAdmin and MySQL
I've had to do this quite a few times lately seen as though I moved from bBlog to Wordpress, there were some things I wanted to change, for example all posts that references /contact.php I wanted to change to /contact/ to fit the new permalink structure.
So for example in that case go to Cpanel (assuming you are using it) which will give you access to phpMyAdmin.
First you need to login to Cpanel with the username/password provided to you by your host, following that find the MySQL Databases link and click that.

Then at the bottom you'll see a link to phpMyAdmin, this is a web based management system for MySQL databases.

At the top left you can then select your database.

After that click the small SQL icon and a window should pop-up like this:

There you can enter your SQL statement.
To update something it's in the form of:
update table_name set field_name = replace(field_name,'replace_this','with_this');
So the example I used above for Wordpress would be:
update wp_posts set post_content = replace(post_content,'/contact.php','/contact/');
Pretty useful for general housekeeping or during a conversion/update.
3 comments














