summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-11-07 14:46:25 +0100
committerAleksander Machniak <alec@alec.pl>2013-11-07 14:46:25 +0100
commitd1a17029a3eff704fd00c0f1f1d219869944fcc9 (patch)
treea76ca7916676e76cabfd4e5cc813429e9b1477bb
parent884e1ecce94a41e705856b0cae6540a171f53461 (diff)
Better handling of fopen() errors
-rw-r--r--program/steps/mail/get.inc23
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);
+ }
}
}