04-29-2009, 10:29 AM
|
#8 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
TalkPHP is a very small forum, you knew that when signing up. We aren't the type of forum which posts 2,000 new topics a day just to appear active; we're just here for when people need us for anything.
That your topic hasn't got any meaningful replies in two days (wow two whole days!) isn't particularly worrying. I had a quick look at your script the other day, and shelved it as "too look at later". After another quick look today, there are a few comments:
- Your main (imgbrowz0r) class does pretty much everything. It is doing far too much, and should be split out into more useful discrete components. Your class mixes thumbnail generation, with HTML generation, with caching, etc.. In this sense, it isn't any more than procedural code wrapped up inside a class.
- You repeat identical code a number of times. An example being checking against a whitelist of file extensions. You do this three times, there is scope for those whitelists not correlating in the future, after a few edits.
- Thumbnails are name-based. What happens if I upload a new version of a file (keeping the same name). It doesn't appear as though the thumbnail will be regenerated. Will it?
- HTML generation: what if I want to use different HTML for my site? I have to edit the imgbrowz0r class to do that. This should not be the case.
- Making thumbnails. On line 354 you check to see if the cache directory is writable and it is not a directory (ie, a writable file). If not, you stop the execution with a contradictory error message. Also in this method (make_thumb), you don't destroy the $image GD resource.
- The get_ext method. This will not do its job properly if provided a file without an extension. File "agif" will return extension "gif" even though it does not really have an extension. Suggestion: use pathinfo($file_name, PATHINFO_EXTENSION) or at least check if the file does really have an extension (strrpos will return boolean false if it can't find the needle).
All in all, a fair start and I'm sure many people would find the imgbrowz0r more than suitable for them. The above are just some thoughts, you don't have to heed them.
|
|
|
|