From fc52af24f1418d6590a2d37a0d8cc31b123e38f6 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli <thomas@roundcube.net> Date: Tue, 19 Aug 2014 12:08:35 -0400 Subject: [PATCH] Fix merge error that disabled contact drag'n'drop --- program/steps/addressbook/upload_photo.inc | 34 ++++++++++++++++++++-------------- 1 files changed, 20 insertions(+), 14 deletions(-) diff --git a/program/steps/addressbook/upload_photo.inc b/program/steps/addressbook/upload_photo.inc index 1ed71f8..035d67e 100644 --- a/program/steps/addressbook/upload_photo.inc +++ b/program/steps/addressbook/upload_photo.inc @@ -6,7 +6,10 @@ | | | This file is part of the Roundcube Webmail client | | Copyright (C) 2005-2011, The Roundcube Dev Team | - | Licensed under the GNU GPL | + | | + | Licensed under the GNU General Public License version 3 or | + | any later version with exceptions for skins & plugins. | + | See the README file for a full license statement. | | | | PURPOSE: | | Handles contact photo uploads | @@ -14,28 +17,30 @@ +-----------------------------------------------------------------------+ | Author: Thomas Bruederli <roundcube@gmail.com> | +-----------------------------------------------------------------------+ - - $Id$ - */ + +// Supported image format types +// ImageMagick works with other non-image types (e.g.pdf) we don't want here +$IMAGE_TYPES = explode(',', 'jpeg,jpg,jp2,tiff,tif,bmp,eps,gif,png,png8,png24,png32,svg,ico'); // clear all stored output properties (like scripts and env vars) $OUTPUT->reset(); -console($_FILES); + if ($filepath = $_FILES['_photo']['tmp_name']) { // check file type and resize image - $imageprop = rcmail::imageprops($_FILES['_photo']['tmp_name']); + $image = new rcube_image($_FILES['_photo']['tmp_name']); + $imageprop = $image->props(); - if ($imageprop['width'] && $imageprop['height']) { - $maxsize = intval($RCMAIL->config->get('contact_photo_size', 160)); - $tmpfname = tempnam($RCMAIL->config->get('temp_dir'), 'rcmImgConvert'); + if (in_array(strtolower($imageprop['type']), $IMAGE_TYPES) + && $imageprop['width'] && $imageprop['height'] + ) { + $maxsize = intval($RCMAIL->config->get('contact_photo_size', 160)); + $tmpfname = tempnam($RCMAIL->config->get('temp_dir'), 'rcmImgConvert'); $save_hook = 'attachment_upload'; // scale image to a maximum size - if (($imageprop['width'] > $maxsize || $imageprop['height'] > $maxsize) && - (rcmail::imageconvert(array('in' => $filepath, 'out' => $tmpfname, - 'size' => $maxsize.'x'.$maxsize, 'type' => $imageprop['type'])) !== false)) { - $filepath = $tmpfname; + if (($imageprop['width'] > $maxsize || $imageprop['height'] > $maxsize) && $image->resize($maxsize, $tmpfname)) { + $filepath = $tmpfname; $save_hook = 'attachment_save'; } @@ -48,8 +53,9 @@ 'group' => 'contact', )); } - else + else { $attachment['error'] = rcube_label('invalidimageformat'); + } if ($attachment['status'] && !$attachment['abort']) { $file_id = $attachment['id']; -- Gitblit v1.9.1