| | |
| | | | program/steps/mail/attachments.inc | |
| | | | | |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2005-2009, The Roundcube Dev Team | |
| | | | Copyright (C) 2005-2013, The Roundcube Dev Team | |
| | | | | |
| | | | Licensed under the GNU General Public License version 3 or | |
| | | | any later version with exceptions for skins & plugins. | |
| | |
| | | |
| | | |
| | | // remove an attachment |
| | | if ($RCMAIL->action=='remove-attachment') |
| | | { |
| | | if ($RCMAIL->action=='remove-attachment') { |
| | | $id = 'undefined'; |
| | | if (preg_match('/^rcmfile(\w+)$/', $_POST['_file'], $regs)) |
| | | |
| | | if (preg_match('/^rcmfile(\w+)$/', $_POST['_file'], $regs)) { |
| | | $id = $regs[1]; |
| | | if ($attachment = $COMPOSE['attachments'][$id]) |
| | | } |
| | | |
| | | if ($attachment = $COMPOSE['attachments'][$id]) { |
| | | $attachment = $RCMAIL->plugins->exec_hook('attachment_delete', $attachment); |
| | | } |
| | | |
| | | if ($attachment['status']) { |
| | | if (is_array($COMPOSE['attachments'][$id])) { |
| | | $RCMAIL->session->remove($SESSION_KEY.'.attachments.'.$id); |
| | |
| | | exit; |
| | | } |
| | | |
| | | if ($RCMAIL->action=='display-attachment') |
| | | { |
| | | if ($RCMAIL->action=='display-attachment') { |
| | | $id = 'undefined'; |
| | | if (preg_match('/^rcmfile(\w+)$/', $_GET['_file'], $regs)) |
| | | |
| | | if (preg_match('/^rcmfile(\w+)$/', $_GET['_file'], $regs)) { |
| | | $id = $regs[1]; |
| | | if ($attachment = $COMPOSE['attachments'][$id]) |
| | | } |
| | | |
| | | if ($attachment = $COMPOSE['attachments'][$id]) { |
| | | $attachment = $RCMAIL->plugins->exec_hook('attachment_display', $attachment); |
| | | } |
| | | |
| | | if ($attachment['status']) { |
| | | if (empty($attachment['size'])) |
| | | if (empty($attachment['size'])) { |
| | | $attachment['size'] = $attachment['data'] ? strlen($attachment['data']) : @filesize($attachment['path']); |
| | | } |
| | | |
| | | header('Content-Type: ' . $attachment['mimetype']); |
| | | header('Content-Length: ' . $attachment['size']); |
| | | |
| | | if ($attachment['data']) |
| | | if ($attachment['data']) { |
| | | echo $attachment['data']; |
| | | else if ($attachment['path']) |
| | | } |
| | | else if ($attachment['path']) { |
| | | readfile($attachment['path']); |
| | | } |
| | | } |
| | | |
| | | exit; |
| | | } |
| | | |
| | |
| | | $err = $_FILES['_attachments']['error'][$i]; |
| | | |
| | | if (!$err) { |
| | | $attachment = array( |
| | | $attachment = $RCMAIL->plugins->exec_hook('attachment_upload', array( |
| | | 'path' => $filepath, |
| | | 'size' => $_FILES['_attachments']['size'][$i], |
| | | 'name' => $_FILES['_attachments']['name'][$i], |
| | | 'mimetype' => rcube_mime::file_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i]), |
| | | 'group' => $COMPOSE_ID, |
| | | ); |
| | | |
| | | $attachment = $RCMAIL->plugins->exec_hook('attachment_upload', $attachment); |
| | | )); |
| | | } |
| | | |
| | | if (!$err && $attachment['status'] && !$attachment['abort']) { |
| | |
| | | else if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
| | | // if filesize exceeds post_max_size then $_FILES array is empty, |
| | | // show filesizeerror instead of fileuploaderror |
| | | if ($maxsize = ini_get('post_max_size')) |
| | | $msg = $RCMAIL->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $RCMAIL->show_bytes(parse_bytes($maxsize))))); |
| | | else |
| | | if ($maxsize = ini_get('post_max_size')) { |
| | | $msg = $RCMAIL->gettext(array( |
| | | 'name' => 'filesizeerror', |
| | | 'vars' => array('size' => $RCMAIL->show_bytes(parse_bytes($maxsize))) |
| | | )); |
| | | } |
| | | else { |
| | | $msg = $RCMAIL->gettext('fileuploaderror'); |
| | | } |
| | | |
| | | $OUTPUT->command('display_message', $msg, 'error'); |
| | | $OUTPUT->command('remove_from_attachment_list', $uploadid); |
| | | } |
| | |
| | | // send html page with JS calls as response |
| | | $OUTPUT->command('auto_save_start', false); |
| | | $OUTPUT->send('iframe'); |
| | | |