We ran into a weird problem at work today. We use CodeIgniter for our web site, and due to some configuration (which, frankly, astounded me when I heard about it), we generate 404s on pages if we get unknown query string parameters. We're testing integration with other systems, and some of them automatically add additional query string parameters when returning to our pages.
A solution was mooted that involved using a standalone PHP file that used file_get_contents with an HTTP URL to strip out the query string parameters. Which is not the solution we want when we're trying to make sure we don't have performance-restricting aspects to our service — it would double up HTTP requests.
Normally, mod_rewrite doesn't interact with query strings — it maps the incoming resource to another resource, and query string parameters aren't part of the resource. But hidden in the mod_rewrite documentation is this:
Modifying the Query String
By default, the query string is passed through unchanged. You can, however, create URLs in the substitution string containing a query string part. Simply use a question mark inside the substitution string to indicate that the following text should be re-injected into the query string. When you want to erase an existing query string, end the substitution string with just a question mark. To combine new and old query strings, use the [QSA] flag.
In our case, we just added a question mark to the right-hand-side of the rewrite rule, and we saved ourself an HTTP request.
Over the weekend, I did the first PHP programming I've done this year, on a whim project to write a Amazon S3 storage manager for KnowledgeTree.
In KnowledgeTree, a storage manager describes where to and how to store and otherwise manage the files attached to documents in KT. S3 is a remote storage web service from Amazon, allowing reliable, scalable, and net-speed-quick storage for data. Most of the code ended up being around configuration - particularly in terms of making it easy to check whether the S3 storage manager is properly configured.
This starts with a status dashlet (a dashboard "portlet" - a little bundle of information on the "front page"), which makes it hard to miss if you haven't configured things yet:

(It also tells you if you haven't told KnowledgeTree to use the S3 storage manager.)
The S3 Storage adds an administration page, allowing through-the-web configuration of the plugin. One of the things I'm sorry I never got around to was getting configuration in KT pushed more into the database - the constant push for "cool" features meant the basics that affect actual users never got any time. Before configuration, the page looks like this:

The "No" next to testing reminds administrators whether they've done a test of the settings they've entered. The "Test now" makes it easy to see if the settings are correct without trying to add a document.
The Amazon Web Services settings are quite boring, since they can't be detected. But, for the S3 configuration, we can query the available storage buckets and present the information to the user:

Once you've set it up, it's actually quite sad how it "just works". There's no difference in terms of using KnowledgeTree to add, bulk add, or delete documents (except that it's a bit slower for those poor South Africans with not-so-wonderful connectivity). Downloading is fast, since the files are cached locally.
The entire storage manager is only 250 lines of code, most of which is caused by the immaturity in the storage manager framework, because pretty much the only non-standard storage manager that we wrote was a in-database storage manager (which was quite slow, and thus was forgotten). The admin page, status dashlet, and so forth come to 500 lines of code. You can download the plugin in ZIP and tar.gz formats.
KnowledgeTree moving on up
14 Feb
It seems KT's doing well - they were invited to attend the Olliance Group's Open Source Think Tank event later this year. (Nice venue! The Californian winelands have long been the #1 location I'd love to visit in the US, even before becoming even more enamoured after watching Sideways)
And (belatedly), they seem to be looking for developers again - if you can stand programming in PHP and want to be paid to work on an open source project in beautiful Cape Town, why not apply?
Beta 3 out
16 Dec
KnowledgeTree contract
21 Jul
KnowledgeTree 2.0.4
25 May
