SMF 2.0 on PHP 7.2

I recently changed my server from CentOS 6 to CentOS 7 and in the process decided that to avoid having to upgrade everything later, installing PHP 7.2 before migrating the sites would be a better option than staying with the default PHP 5.4.

This was a good idea – mostly. It forced me to upgrade a couple of mediawiki installs that hadn’t been touched in a while and those were migrated ok. When it came to migrating the Shartak Forum I was starting to think I should have gone for a slightly older version of PHP because SMF 1.1 (Simple Machines Forum) doesn’t work on such a recent version of PHP. It wasn’t just a minor issue, functions such as mysql_* that had been removed in PHP 7 were all over the place!

Time to take the plunge and upgrade to SMF 2.0 which had been stable for several years but there had never been a reason to upgrade before now. Looking at the large amount of spam user accounts and the upgrade process documentation, I decided it would be easier to start from scratch instead of trying to upgrade SMF 1.1 (with some custom tweaks) to 2.0.

I installed the SMF 2.0 code, configured the theme, found that only one of the old tweaks was really still needed and put it live. Then I checked the error logs in the SMF admin panel and found there were thousands of errors after just a few hours of it being live!

Function create_function() is deprecated

It turned out that SMF 2.0.15 only supports up to PHP 7.1 as PHP 7.2 is deprecating create_function() and this is used by the BBCode parser.

After some searching, I came across a message on the SMF forum that suggested adding an exception to the error handler to prevent it logging the deprecation warnings. The suggestion of comparing the version using the builtin PHP method version_compare() was taken into account and here is my version of the solution.

--- Sources/Errors.orig.php 2018-05-23 14:21:57.933367060 +0100
+++ Sources/Errors.php 2018-05-23 13:47:45.711567251 +0100
@@ -203,6 +203,10 @@
 {
 global $settings, $modSettings, $db_show_debug;

+ // Disable PHP 7.2 "Function create_function() is deprecated" errors from filling the forum error logs
+ if (defined('E_DEPRECATED') && $error_level == E_DEPRECATED && (version_compare(phpversion(), '7.2') >= 0) && strpos($error_string, 'Function create_function() is deprecated') !== false)
+ return;
+
 // Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.)
 if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && (empty($modSettings['enableErrorLogging']) || $modSettings['enableErrorLogging'] != 2)))
 return;

It’s not a perfect fix but it’ll do until SMF 2.1 is released. I hope this helps someone else searching for the same issue.

Shartak internals – speech and translation

Within Shartak there are two main factions – natives and outsiders. To make things somewhat realistic (and interesting), when they first start off there is quite a hefty language barrier in that a native can’t really understand an outsider and vice-versa. This situation can be improved by gaining the various language skills that help with reading/hearing the other language, and then for writing or speaking the other language.

There are three levels of comprehension – basic, advanced and expert language – followed by foreign writing and foreign speech. As far as the translation of language goes, we’re only interested in the first three skills. The foreign writing/speech skills simply allow things to work in reverse.

One of the players posted the results of a fairly detailed examination of the translation system on the Shartak forum and he was quite accurate with a some of the information. It’s not possible to accurately translate the garbled text back into the original text – this is intentional because otherwise it would only be a matter of time before someone wrote a Greasemonkey script to translate it and thus render 5 skills completely useless.

Both native and outsider speech work in the same way, all that changes are the character sequences associated with each letter. The sequences were deliberately chosen (with assistance from someone who knows about such things) such that the outsiders have a less harsh sound than the natives.

Natives have sounds like kam, rak, hok and uck where outsiders have kar, rar, hum and uh.

Trivia: the name of the cannibals home camp Rakmogak is actually a slight variation of the native translation of “Raw meat”!

Shartak internals – Maps and movement

The map for Shartak is held in a database table with over 140,000 rows in it. Each row corresponds to a single location on the map, also called a tile. The initial island map was generated automatically based on a simple bitmap image with varying colours for the different terrain types. Since 2005 there have been many changes to it, most of which are done by manually editing the table one row at a time. Bear in mind that this system is probably not the best way to do it, but it works for Shartak and allows for some interesting map layouts if I ever need them.

Continue reading

IPv6 and Shartak

Over the last couple of weeks I’ve been trying to figure out IPv6. Having worked through some of the IPv6 certification at http://ipv6.he.net/ I now have an IPv6 enabled web server and mail server as well as IPv6 connectivity at home via tunnelbroker.net

I thought I’d update Shartak to allow access via IPv6 as well as IPv4 – mostly nothing needed to be changed, however…

Continue reading

Shartak – now with added music

Before you start complaining, I didn’t go crazy and add a dodgy midi track to the Shartak website. I stumbled across a forum thread this evening and apparently Shartak players are forming their own record label.
Once finished, the Heads Down tracks will be available at a MySpace account – http://www.myspace.com/headsdownriot
*EDIT* URI of MySpace account changed – 3rd March 2007.

Continue reading