Fix blocked.gif image usage with assets_dir set
| | |
| | | CHANGELOG Roundcube Webmail |
| | | =========================== |
| | | |
| | | - Fix blocked.gif image usage with assets_dir set |
| | | - Fix bug where max_group_members was ignored when adding a new contact (#1490214) |
| | | - Hide MDN and DSN options in compose if disabled by admin (#1490221) |
| | | - Fix checks based on window.ActiveXObject in IE > 10 |
| | |
| | | return $result; |
| | | } |
| | | |
| | | /** |
| | | * Get resource file content (with assets_dir support) |
| | | * |
| | | * @param string $name File name |
| | | */ |
| | | public function get_resource_content($name) |
| | | { |
| | | if (!strpos($name, '/')) { |
| | | $name = "program/resources/$name"; |
| | | } |
| | | |
| | | $assets_dir = $this->config->get('assets_dir'); |
| | | |
| | | if ($assets_dir) { |
| | | $path = slashify($assets_dir) . $name; |
| | | if (@file_exists($path)) { |
| | | $name = $path; |
| | | } |
| | | } |
| | | |
| | | return file_get_contents($name, false); |
| | | } |
| | | |
| | | |
| | | /************************************************************************ |
| | | ********* Deprecated methods (to be removed) ********* |
| | |
| | | unset($plugin); |
| | | |
| | | // add blocked.gif attachment (#1486516) |
| | | if ($isHtml && preg_match('#<img src="\./program/resources/blocked\.gif"#', $body)) { |
| | | if ($attachment = rcmail_save_image('program/resources/blocked.gif', 'image/gif')) { |
| | | if ($isHtml && preg_match('#<img src="program/resources/blocked\.gif"#', $body)) { |
| | | $content = $RCMAIL->get_resource_content('blocked.gif'); |
| | | if ($content && ($attachment = rcmail_save_image('blocked.gif', 'image/gif', $content))) { |
| | | $COMPOSE['attachments'][$attachment['id']] = $attachment; |
| | | $url = sprintf('%s&_id=%s&_action=display-attachment&_file=rcmfile%s', |
| | | $RCMAIL->comm_path, $COMPOSE['id'], $attachment['id']); |
| | | $body = preg_replace('#\./program/resources/blocked\.gif#', $url, $body); |
| | | $body = preg_replace('#program/resources/blocked\.gif#', $url, $body); |
| | | } |
| | | } |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | function rcmail_save_image($path, $mimetype='') |
| | | function rcmail_save_image($path, $mimetype = '', $data = null) |
| | | { |
| | | global $COMPOSE; |
| | | |
| | | // handle attachments in memory |
| | | if (empty($data)) { |
| | | $data = file_get_contents($path); |
| | | $is_file = true; |
| | | } |
| | | |
| | | $name = rcmail_basename($path); |
| | | |
| | | if (empty($mimetype)) { |
| | | if ($is_file) { |
| | | $mimetype = rcube_mime::file_content_type($path, $name); |
| | | } |
| | | else { |
| | | $mimetype = rcube_mime::file_content_type($data, $name, 'application/octet-stream', true); |
| | | } |
| | | } |
| | | |
| | | $attachment = array( |
| | | 'group' => $COMPOSE['id'], |
| | | 'name' => $name, |
| | | 'mimetype' => $mimetype ? $mimetype : rcube_mime::file_content_type($path, $name), |
| | | 'mimetype' => $mimetype, |
| | | 'data' => $data, |
| | | 'size' => strlen($data), |
| | | ); |
| | |
| | | $wash_opts = array( |
| | | 'show_washed' => false, |
| | | 'allow_remote' => $p['safe'], |
| | | 'blocked_src' => "./program/resources/blocked.gif", |
| | | 'blocked_src' => 'program/resources/blocked.gif', |
| | | 'charset' => RCUBE_CHARSET, |
| | | 'cid_map' => $cid_replaces, |
| | | 'html_elements' => array('body'), |
| | |
| | | // send blocked.gif for expected images |
| | | if (empty($_REQUEST['_mimewarning']) && strpos($mimetype, 'image/') === 0) { |
| | | // Do not cache. Failure might be the result of a misconfiguration, thus real content should be returned once fixed. |
| | | $content = $RCMAIL->get_resource_content('blocked.gif'); |
| | | $OUTPUT->nocacheing_headers(); |
| | | header("Content-Type: image/gif"); |
| | | header("Content-Transfer-Encoding: binary"); |
| | | readfile(INSTALL_PATH . 'program/resources/blocked.gif'); |
| | | header("Content-Length: " . strlen($content)); |
| | | echo $content; |
| | | } |
| | | else { // html warning with a button to load the file anyway |
| | | $OUTPUT = new rcmail_html_page(); |