Python and phpBB integration

I’ve finally finished the pbpBB integration with the Fab Swingers codebase. You can result in our new Swinging Forums!

It turned out to be a hell of a lot of work! First, I’ve switched Fab Swingers over to using the phpBB session cookies and session tables. On examination the phpBB system was a little bit slower than my home grown system but was more secure and would also make it easier to use a cluster of servers so it is a bit more scalable.

There were a couple of things that were a bit tricky when I was importing my users to phpbb_users. To convert a password for use in the user_password row I did md5.new(password).hexdigest() which took me a while to work out. Also, to convert a Python DateTime object to the time format used by phpBB I used int(mktime(lastvisit.timetuple())) where lastvisit is a DateTime object. This also took quite a lot of swearing to get right!

Logging users in seemed really hard but in the end was quite straightforward. All you need to do is create an _sid cookie and an entry in the phpbb_sessions table. The only slightly tricky bit is the format of the user’s IP address in session_ip which is in hex. This bit of Python will give you what you want: ‘%02x%02x%02x%02x’ % tuple(map(int, ip.split(’.'))) where IP is a string like ‘127.0.0.1′.

I also went thru phpBB and changed every ‘profile’ and ‘pm’ button to take users to the main Fab Swingers site, the login now redirects to the Fab Swingers login page and I also removed quite a lot of the database intensive statistics from the homepage.

A forum is the heart of a community site and although the whole thing has been a complete pain in the ass I think it has been well worth doing.

Leave a Reply

You must be logged in to post a comment.