Mambo patching – a brief interlude

15 09 2005

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:
$fileInfo = pathinfo($file['name']);
if (! strpos($validList,$fileInfo['extension'] . '|')) {

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




5 responses

15 09 2005

That’s almost worthy of a Daily WTF.

15 09 2005
Tim Pierce

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

15 09 2005

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

15 09 2005
Lisa Hertel

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.

9 10 2005

I did in fact add PDF to the list, thanks lisa đŸ™‚

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: