Errors

Hello,
First of all - thanks for this function.
Anyway - I figured out some errors/enhancements:
1. It is:
if (!in_array($size,$sizes)) {
should be:
if (!in_array($size,$allowed)) {

2. You should quit script on the first error - or the thumb will be generated no matter there is an error. I've created a function:
function exit_on_error($error) {
header("HTTP/1.0 404 Not Found");
echo 'Not Found';
echo '

The image you requested could not be found.

';
echo "

An error was triggered: $error

";
}
and you should use it on each error:
if (!$_GET['thumb']) {
die (exit_on_error('no thumb'));
}

3. And little more security on input:
// get the thumbnail from the URL
$thumb = strip_tags(htmlspecialchars($_GET['thumb']));

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <b> <br> <p> <a> <strong> <cite> <em> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • You may use [img:xx] tags to display uploaded files or images inline.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <css>, <diff>, <drupal5>, <html>, <javascript>, <php>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options