Images with odd filenames

Report issues with Enuuk Auction Platform or Mods here - remember to raise a ticket with phpauction.net as well
Post Reply
RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Images with odd filenames

Post by RWAP » Fri Jan 24, 2014 8:24 pm

I have come across an issue where a user has managed to edit the filenames for images and in the process removed the dot character before the extension - so that

image1.jpg

was actually

image1jpg

The Enuuk platform allows the image to be uploaded and the thumbnail appears correctly, but unfortunately, when you use fancybox to view the full sized image, you see the code, rather than the image itself.

The answer to this is to amend class\Image.php. Find:

Code: Select all

        $exprAllowedTypes = "/.jpeg$|.jpg$|.gif$|.png$/";
        if(!preg_match($exprAllowedTypes,strtolower($file))){
            throw new Exception(_("Wrong file type. Allowed formats: GIF, JPG, PNG"), Error::BY_USER);
        }
Change this to read:

Code: Select all

        $exprExtensionIncluded = "/\.[0-9a-z]{3,4}$/i";
        if(!preg_match($exprExtensionIncluded,strtolower($file))){
            throw new Exception(_("'You cannot upload a file which lacks a supported file extension .jpg, .jpeg, .gif or .png"), Error::BY_USER);
        }

        $exprAllowedTypes = "/\.jpeg$|\.jpg$|\.gif$|\.png$/";
        if(!preg_match($exprAllowedTypes,strtolower($file))){
            throw new Exception(_("Wrong file type. Allowed formats: GIF, JPG, PNG"), Error::BY_USER);
        }

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest