|| ||

Mambo patching - a brief interlude

| 5 Comments

So one of my many hats involves helping out running the Arisia website. We changed the site over to being managed by Mambo several months ago, and have been 'mostly' happy with it, though it has its quirks.

One quirk raised its head today. We couldn't upload files via the media manager other than graphics and pdfs. One of the users wanted to punch up a preformatted HTML page, and the system was not allowing it.

After digging around the code, I found the culprit. The system was hardcoded to only accept certain extensions, and I have to admit, the code that did it was... er... painful:

if ((strcasecmp(substr($file['name'],-4),".gif")) && (strcasecmp(substr($file['name'],-4),".jpg")) && (strcasecmp(substr($file['name'],-4),".png")) && (strcasecmp(substr($file['name'],-4),".bmp")) &&(strcasecmp(substr($file['name'],-4),".doc")) && (strcasecmp(substr($file['name'],-4),".xls")) && (strcasecmp(substr($file['name'],-4),".ppt")) && (strcasecmp(substr($file['name'],-4),".swf")) && (strcasecmp(substr($file['name'],-4),".pdf"))) {

Ew. Just. Ew. Bleah. Ick. In the immortal words of Tim Allen... "So I rewired it!" :

# The valid file extension list is:
$validList="fluff|gif|jpg|png|bmp|doc|xls|ppt|swf|html|htm|rtf|";
$fileInfo = pathinfo($file['name']);
if (! strpos($validList,$fileInfo['extension'] . '|')) {

Muuuuch better. This patch goes around line 139 of admin.media.php, if folks are looking for an update.


5 Comments

That's almost worthy of a Daily WTF.

I was gonna say the same thing. Send it in!

Okay, FINE! I did! It's now pending in WTF's queue.

But you should add PDF to the valid list (unless you just missed typing it, or I'm not reading the code correctly). I know Art Show uses them, and I might (Dealers) as well. Also, some of the dealer files are in Corel Draw, but I can convert them. It might be useful to post the valid file extension list somewhere on the Staff page. Also, some sort of database format (Access or CSV) would be good.

I did in fact add PDF to the list, thanks lisa :)

Leave a comment

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.23-en

Twitter

Sponsors!

About this Entry

This page contains a single entry by dbs published on September 15, 2005 12:39 PM.

The Fake Dr. Pepper Collection was the previous entry in this blog.

What is up with Garison Keillor? is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.