so basicly, you want to rewrite the messages in your database with bbcode.
This is possible, let's see
I don't know how the HTML came into your forums, but I do hope there is an UID with all of the posts (check in your DB, phpbb_posts, bbcode_uid.
If this exists, it is possible to replace your content, but it would take a lot of time (step 1: fetch from the DB, step 2: convert every tag known, step 3: any unknown tags should become htmlentities so they don't harm your forum, step 4: replacing the original text from your DB.
As some of you have more then 20.000 posts, I think you might just want to use a limit, and a temp row containing info about updated/not, so you can just refresh your PHP page and the query will continiue.
I hope I gave some good suggestiond, at the moment I'm in the middle of examinations, so creating a script of this size won't be possible, but I do hope I gave other programmers an idea of how they should work.