Delphi forums to phpBB – Part One

Most of my work is pretty much the same: upgrades and updates to existing phpBB boards. Lately though I’ve been tackling some unusual projects. One of these is to move a Delphi board to phpBB.

Delphi forums are proprietary and are available only on their website. I understand it has no official way to export a Delphi forum. A board there has twenty years of conversations they did not want to lose. A clever user though has figured out how to export the board using YAML.

Example of YAML file for importing

After looking at it, I figured it was cost prohibitive to do. I did a proof of concept for them, demonstrating that I could read the YAML file and get basic user, forum, topic and post information from it, and display it neatly in HTML. I explained that this would be custom work and that it would take a lot of labor, even at my nonprofit rate. I estimated $2000 – $3000 and assumed it was cost prohibitive.

Proof of concept to display user information from YAML file

That was back in February but I was recently given the go ahead to start this project. Which raises the question: how on earth to do something like this?

What convertors from other forum solutions to phpBB that do exist tend to be for phpBB 3.0, and we’re now on phpBB 3.3. And no one has written a Delphi forums converter because it has no export capability. Since then phpBB has evolved, and due to the way post text is now encoded, it’s very challenging to write any new convertor.

Which is why I said if it can be done I would want to populate an old phpBB 2 forum with its data, and convert that to phpBB 3.3. There’s a convertor built into phpBB that does just this. But phpBB 2 became obsolete 13 years ago. However, its database is relatively simple so it should be straightforward to populate from data elsewhere.

But phpBB 2 was built for versions 4 and 5 of PHP, versions now obsolete and dangerous to use, or even acquire. It’s hard to even stand up a PHP 5 environment now. Most web hosting won’t support PHP 5, and mine doesn’t. So I’d have to roll my own development environment with PHP 5.

There are two ways to do this:

  • Via a virtual machine
  • Via a separate machine

I’ve used VitualBox on my Mac for years for standing up virtual machines. While it works, it doesn’t work well on a Mac. It’s a pain to use, particularly if you need to move files between the Mac and the VM.

Because I need PHP 5 for clients generally at least once a month, I decided a separate machine was more practical. So I bought a Raspberry Pi 4 (4GB) for less than $100. The actual machine is about $35 but I added a keyboard, mouse and a book. It took some help online to figure out how to install a web server and PHP 5 for it. The Pi is cheap because it uses RISC-based processors, so it’s not Intel compatible. Also, I could use FTP to move files to it, and using a free VNC viewer, I could work on it from my Mac desktop.

Processing the YAML turned out not to be easy. I tried various things, including PHP’s PECL YAML class, which I couldn’t get to work. I was able to eventually get Symfony’s YAML class to work.

Given the go ahead, I created a phpBB 2 board on my Pi with PHP 5.6 installed. While this worked great, my script wouldn’t run there. Symfony requires PHP 7.2. So I exported the phpBB 2 database and imported it into my Mac where I run PHP 7.4. I would have to populate the database from the YAML files I was given there, and eventually move it back to the Pi when it was time to try to upgrade the database.

Loading the phpbb_users table was not too challenging. A few fields needed to be escaped using mysqli_escape_string so the data could be loaded into the table. Some fields had to be trimmed to fit inside the maximum field length.

phpBB 2 places user data in a number of tables. Topics and posts haven’t been created yet, but there is a phpbb_user_group table. Each user had to belong to a group. Creating a test user on phpBB 2, I learned that it will create a new personal group. Then I had to write some SQL to put all 600+ users into this table. I also needed to populate a number of other columns in the phpbb_users_table. Each should have a new password, but since these users were added in bulk, they share the same password for now. All share the same bogus email address too, since I didn’t have that in the YAML. They will have to change both after the board is converted. Back in the old days, the password was encrypted with a simple md5 hash.

But the customer’s thread YAML wasn’t 100% clean. It wasn’t a major issue, but 22 threads (which amount to topics) wouldn’t parse. Even the good threads though had some issues. Some threads have no name to them. I will have to create a synthetic topic name for them. Some don’t have a forum name either, so those have to go into some sort of catch all forum.

There is a major issue is that the YAML’s attachment information provided a file upload name, but the name is not in the /files folder provided with the YAML. Files seem to have some sort of hash name. This may mean that attachments cannot be imported. If I want to import any attachments, I will have to install the old phpBB 2 attachment mod.

But at least this approach looks viable, if tedious. More learning experiences ahead.

Why you need to upgrade phpBB to version 3.2

A lot of forum owners are procrastinators. The current version of phpBB (as of this writing) is phpBB 3.2.3. If you are not on the phpBB 3.2 you should upgrade. Why?

Because in two months the group that manages the PHP programming language (which phpBB is written in) will stop supporting versions of PHP 5 with security fixes. This means after January 2019 you may be vulnerable to new exploits found in PHP 5, used by phpBB 3.1 and earlier versions.

It’s understandable why you might not want to upgrade your forum from your current version, generally phpBB 3.0 or 3.1. As most of my work is upgrading forums I see all the time why forum owners drag their feet. Reasons include:

  • Their forum has lots of mods and custom changes made over the years. With modifications not supported in phpBB 3.1 and higher, they have to figure out how to move forward. Many modifications do not have the equivalent available as extensions. So they either have to give up the functionality of the mod (which often makes forum users unhappy) or just procrastinate as long as possible. Procrastination is the easier approach.
  • Their forum has a style with lots of changes. Perhaps a logo has been integrated that is nonstandard, or they’ve made major changes to the templates and the stylesheets. Lots of styles haven’t been migrated to phpBB 3.2 either, so this is another issue they will have to deal with if they upgrade.
  • They know just enough PHP to be dangerous, so they’ve tweaked the code here and there to do special things. That would go away with an upgrade, or at least the cost of making changes to the base code gets more expensive. It’s heavily discouraged and makes upgrading or updating phpBB a pain, because you often have to reapply these changes. Custom changes can be done by writing a custom extension, but it’s a complicated thing to do. You need to be a very experienced PHP programmer to write an extension, and heavily study phpBB’s architecture and coding requirements.
  • Having someone like me upgrade your forum costs money.

Now that push has come to shove though, unless you are willing to bear the security risks, it’s time to finally make the upgrade. phpBB 3.1 users are not off the hook either, because this version of phpBB does not support PHP 7, the latest major version of PHP. I helped a client migrate their forum just yesterday to PHP 7. PHP 7 was installed on their new server. Certain things stopped working or created PHP notices.

Note that versions of PHP before 5.6 are already not patched for security issues. So if you are using an earlier version of PHP like PHP 5.2 (popular for phpBB 3.0 and 2.0) or PHP 5.3, 5.4 or 5.5 you are already at risk. You really can’t upgrade to PHP 7.0 as you will experience errors. Some phpBB 2.0 and 3.0 users have issues running PHP 5.6.

So now may be the time to take the plunge. Of course I can help you in this process. You may want to read my upgrade page. In addition to running the latest version of phpBB, I think you will find that once you are there it is worth the hassle. The extensions architecture of PHP 3.1 and higher is very nice, almost as nice as using WordPress plugins. The themes are responsive, so they look great on mobile devices. In addition, PHP 7 is about 50% faster than PHP 5, which is another great incentive to upgrade, particularly if you have performance issues with your forum.

You can send me a query if you want to discuss upgrading your forum.