Mambo patching – a brief interlude

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.

About

A wandering geek. Toys, shiny things, pursuits and distractions.

View all posts by

5 thoughts on “Mambo patching – a brief interlude

  1. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.