Blosxconfig: PHP Tool To Configure blosxom Plugins

The most common complaints/questions on the blosxom developer’s mailing list all relate to difficulties with plugins, so I have been trying to think of a way to make them a little easier to work with for people. What I came up with is blosxconfig, a single PHP script which works with very basic configuration files to determine what variables a user should have access to and what format they should be in. It will also confirm the existence and readability of the plugin files, and write the modified variables directly into the plugin files.

Download blosxconfig BETA version now!

Here’s the details that I posted to the blosxom list;

WARNING: Back up all you plugins before saving changes via blosxconfig!!!

configure.php is a PHP script (duh!) so you’ll need PHP on your server to run it. You can pass a path to it to look for a specific config file via either a GET or POST request (GET use ?conf=path-to-conf.conf on the querystring, POST use variable name ‘conf’ with a value of a path to a config file). if you don’t pass a value, then blosxconfig will look for a file called blosxom.conf in the same directory as it, or die trying ๐Ÿ˜‰

The config files are very basic, and look a little bit like a Windows ini file, but it’s a custom style; The first line is similar to a unix ‘shebang’ line, and should look like this;

#@/path/to/plugins

where obviously the /path/to/plugins is the full path to where your plugins live – this should be the same as the $blosxom::plugin_dir variable configured in your blosxom cgi executable.

After that line, you have plugin sections which are defined using [plugin_name] – be careful that you use the *exact* name of the plugin, because the value is used for confirming the plugin’s existence ๐Ÿ™‚

Under each plugin section, you define definable variables on a line each, in this format;

variable_name|type|default

variable_name is the actual name of the variable (as written in the script), without the ‘$’ or ‘@’ (in the case of arrays)

type can be one of ‘string’, ‘boolean’ or ‘code’. Arrays should be defined as ‘code’. Strings are enclosed automatically in quotes (“) and all types are followed by a semi colon when written to file. Booleans are presented to the user as a Yes/No select box (0/1 passed as values) and other types are presented as simple text input fields.

default is a value to use by default. make sure this makes sense (so for a boolean make sure it’s 0/1, for a string it’s a string etc). You don’t need to wrap it in quotes or anything, this is handled automatically.


Now, assuming you have a valid config file and blosxconfig can find it, it will load the file, and present you with an interface where you should be able to modify all the values that you spcified as being editable in the config file. *hopefully* blosxconfig will also tell you at this point if plugin files are available (file exists in plugin dir) and if they are not readable or writeable. when you have made you changes – click ‘save’ and the following will happen;

WARNING: Back up all you plugins before saving changes via blosxconfig!!!

  1. All plugin files which are referenced in your config file will be MODIFIED – they will technically be overwritten entirely, since the contents of the file are processed, then the lines that look like they define the variables in question are replaced with new lines, with the new values.
  2. The config file will be updated with the new details that you specified and written back to file.
  3. blosxconfig will load again, with all your new values in place, and messages telling you what happened.

Assuming all goes well, you’ve just used an external interface to reach into your plugin files and modify certain details. The hope is that authors of plugins (or community-minded participants) can supply the simple, 1 – 10 lines worth of config required to add to this configuration file, which can then be distributed with this little application to help people configure their plugins.

Please be aware that I have *NOT* tested this extensively at all, it was hacked together and seemed to work for a couple of plugins that I was running (the ones in the config file included) on a Windows test box, other than that I can’t make any promises. I’d LOVE if some people could try it out on some other plugins, on other systems, and let me know (directly if
you like) how it goes. I’ll fix any problems and then release it as public so that other people can use it.

Hope it’s useful for someone out there, and can perhaps eventually make life easier for some newbies (and pro’s alike ๐Ÿ™‚

Oh yeah – did I mention; BACK UP YOUR PLUGINS BEFORE YOU TRY THIS!

On the suggestion of Andreas Banze, I’ve removed one small section which checked to make sure that the plugin files were executable, since as he pointed out, this is not necessary, they are just included in the main operation of the blosxom script, not executed individually.

Download blosxconfig BETA version now!