How-To: Extract PHP-Nuke Articles from an SQL INSERT Statement in Python

I found an old SQL dump of this r3dux.org site yesterday which I thought was lost to time. The site ran php-nuke back then, and rather than importing the SQL into a database and fiddling with it to export all the old articles I thought I’d take the python hammer to it. It’s a bit of a bodge/hack – but it seems to work well enough.

The idea is you copy JUST the insert statement which deals with “stories” (nuke’s word for articles / posts) from the SQL dump and put it in a file (mine’s called “nuke_stories.sql”), then run the parse_nuke_stories python script and it’ll dump out all the articles into separate files with filenames like “Article_ID_YEAR_MONTH_DAY.html” and such.

Here’s the top few lines of my SQL insert statement:

Here’s what it’ll dump out into a file called Article_001_2004_09_10.html if this was all that was there:

Article ID : 1
Author : r3duxAdmin
Title : W00t! The site it be a-changin’…
Date : 2004-09-10 12:35:06

Well, PHP-Nuke seems to be up and running, so now it’s time to mess w/ it in a huge way and configure all the millions of options needed to make it just the way I want.

Daunted? Me? Er, yeah. You could say that…

And here’s the actual python (version 3) code to parse the SQL file:

As mentioned, it’s a complete hack – but if you need to do something similar it may work as a starter to get you going…

Downtime

r3dux.org was down for a day or two because I’d started but not enabled the DHCPCD service so enp0s3 wasn’t getting an IP on reboot – and then I forgot to remove a test ‘index.html’ in the server root.

While this was why it was down, the reason it stayed down is that I’m trying to finish my PhD at the moment while also working full time – so as you might imagine, this hobbyist website is one of the last fires to put out when everything is on fire.

Normal service (of old content) is now resumed.

On the upside, my new research paper “SoniFight: Software to provide additional sonification cues to video games for visually impaired players.” (DOI: 10.1007/s40869-018-0059-6) should be published soon in The Computer Games Journal special issue on accessibility.

If you’d like to know more then please feel free to hit up the SoniFight Github repo.

How To: Convert Day Number to Month and Day

I needed to convert the day number, that is, what day it is between 1 and 365, into a month and day without using Calendar / DateTime classes and such today, so I knocked up a few simple functions that work assuming it’s not a leap year (i.e. that February has 28 days).

Here they are if they’re of any use to you:

A touch cheap, but it gets the job done.