diff options
author | Aleksander Machniak <alec@alec.pl> | 2013-11-07 14:46:25 +0100 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2013-11-07 14:46:25 +0100 |
commit | d1a17029a3eff704fd00c0f1f1d219869944fcc9 (patch) | |
tree | a76ca7916676e76cabfd4e5cc813429e9b1477bb /program/steps/mail | |
parent | 884e1ecce94a41e705856b0cae6540a171f53461 (diff) |
Better handling of fopen() errors
Diffstat (limited to 'program/steps/mail')
-rw-r--r-- | program/steps/mail/get.inc | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc index e0c4e2911..ae48307e3 100644 --- a/program/steps/mail/get.inc +++ b/program/steps/mail/get.inc @@ -84,17 +84,18 @@ else if ($_GET['_thumb']) { // render thumbnail image if not done yet if (!is_file($cache_file)) { - $fp = fopen(($orig_name = $cache_basename . '.orig.' . $ext), 'w'); - $MESSAGE->get_part_content($part->mime_id, $fp); - fclose($fp); - - $image = new rcube_image($orig_name); - if ($imgtype = $image->resize($thumbnail_size, $cache_file, true)) { - $mimetype = 'image/' . $imgtype; - unlink($orig_name); - } - else { - rename($orig_name, $cache_file); + if ($fp = fopen(($orig_name = $cache_basename . '.orig.' . $ext), 'w')) { + $MESSAGE->get_part_content($part->mime_id, $fp); + fclose($fp); + + $image = new rcube_image($orig_name); + if ($imgtype = $image->resize($thumbnail_size, $cache_file, true)) { + $mimetype = 'image/' . $imgtype; + unlink($orig_name); + } + else { + rename($orig_name, $cache_file); + } } } |