$display_cat = ATTACHMENT_CATEGORY_NONE; } if ($mode == 'thumbnail') { $attachment['physical_filename'] = 'thumb_' . $attachment['physical_filename']; } else { if (($display_cat == ATTACHMENT_CATEGORY_NONE || $display_cat == ATTACHMENT_CATEGORY_IMAGE) && !$attachment['is_orphan']) { // Update download count $sql = 'UPDATE ' . BLOGS_ATTACHMENT_TABLE . ' SET download_count = download_count + 1 WHERE attach_id = ' . $attachment['attach_id']; $db->sql_query($sql); } } blog_plugins::plugin_do('download_before_send'); if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && strpos($attachment['mimetype'], 'image') === 0 && strpos(strtolower($user->browser), 'msie') !== false) { wrap_img_in_html(append_sid('./blog.' . $phpEx, 'page=download&id=' . $attachment['attach_id']), $attachment['real_filename']); } else { // Determine the 'presenting'-method if ($download_mode == PHYSICAL_LINK) { // This presenting method should no longer be used if (!@is_dir($phpbb_root_path . $config['upload_path'])) { trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']); } redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']); exit; } else { send_file_to_browser($attachment, $config['upload_path'] . '/blog_mod', $display_cat); exit; } } blog_plugins::plugin_do('download_end');
if (!$thumbnail) { // Update download count $sql = 'UPDATE ' . TITANIA_ATTACHMENTS_TABLE . ' SET download_count = download_count + 1 WHERE attachment_id = ' . $attachment['attachment_id']; phpbb::$db->sql_query($sql); // Update download count for the contrib object as well if ($attachment['object_type'] == TITANIA_CONTRIB) { $sql = 'UPDATE ' . TITANIA_CONTRIBS_TABLE . ' SET contrib_downloads = contrib_downloads + 1 WHERE contrib_id = ' . $attachment['object_id']; phpbb::$db->sql_query($sql); } } if (!$thumbnail && $mode === 'view' && strpos($attachment['mimetype'], 'image') === 0 && (strpos(strtolower(phpbb::$user->browser), 'msie') !== false && strpos(strtolower(phpbb::$user->browser), 'msie 8.0') === false)) { wrap_img_in_html(titania_url::build_url('download', array('id' => $attachment['attachment_id'])), $attachment['real_filename']); file_gc(); } else { send_file_to_browser($attachment, titania::$config->upload_path); file_gc(); } /** * Wraps an url into a simple html page. Used to display attachments in IE. * this is a workaround for now; might be moved to template system later * direct any complaints to 1 Microsoft Way, Redmond */ function wrap_img_in_html($src, $title) { echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd">'; echo '<html>'; echo '<head>';
if ($thumbnail) { $attachment['physical_filename'] = 'thumb_' . $attachment['physical_filename']; } else if (($display_cat == ATTACHMENT_CATEGORY_NONE || $display_cat == ATTACHMENT_CATEGORY_IMAGE) && !$attachment['is_orphan']) { // Update download count $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET download_count = download_count + 1 WHERE attach_id = ' . $attachment['attach_id']; $db->sql_query($sql); } if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && strpos(strtolower($user->browser), 'msie') !== false) { wrap_img_in_html(append_sid('./download.' . $phpEx, 'id=' . $attachment['attach_id']), $attachment['real_filename']); } else { // Determine the 'presenting'-method if ($download_mode == PHYSICAL_LINK) { // This presenting method should no longer be used if (!@is_dir($phpbb_root_path . $config['upload_path'])) { trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']); } redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']); exit; }
if ($display_cat == ATTACHMENT_CATEGORY_FLASH && !$user->optionget('viewflash')) { $display_cat = ATTACHMENT_CATEGORY_NONE; } if ($thumbnail) { $attachment['physical_filename'] = 'thumb_' . $attachment['physical_filename']; } else { if (($display_cat == ATTACHMENT_CATEGORY_NONE || $display_cat == ATTACHMENT_CATEGORY_IMAGE) && !$attachment['is_orphan']) { // Update download count $sql = 'UPDATE ' . ATTACHMENTS_TABLE . ' SET download_count = download_count + 1 WHERE attach_id = ' . $attachment['attach_id']; $db->sql_query($sql); } } if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && strpos($attachment['mimetype'], 'image') === 0 && (strpos(strtolower($user->browser), 'msie') !== false && strpos(strtolower($user->browser), 'msie 8.0') === false)) { wrap_img_in_html(append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'id=' . $attachment['attach_id']), $attachment['real_filename']); } else { // Determine the 'presenting'-method if ($download_mode == PHYSICAL_LINK) { // This presenting method should no longer be used if (!@is_dir($phpbb_root_path . $config['upload_path'])) { trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']); } redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']); file_gc(); } else { send_file_to_browser($attachment, $config['upload_path'], $display_cat); file_gc(); } } /**
/** * Output attachment browser. * * @param int $id Attachment id. * @param string $type Type of download (manual or composer) * @return \Symfony\Component\HttpFoundation\Response if error found. Otherwise method exits. */ public function file($id, $type) { $this->check_invalid_request(); $this->id = (int) $id; $this->type = $type; // If no download id is provided, check for legacy download. if (!$this->id) { $this->id = (int) $this->get_legacy_download_id(); } $mode = $this->request->variable('mode', ''); $thumbnail = $this->request->variable('thumb', false); $status = $this->load_file_data(); if ($status !== self::OK) { $error = array(self::NOT_FOUND => 'ERROR_NO_ATTACHMENT', self::FORBIDDEN => 'SORRY_AUTH_VIEW_ATTACH'); return $this->helper->error($error[$status], $status); } $directory = utf8_basename($this->file['attachment_directory']) . '/'; $base_filename = utf8_basename($this->file['physical_filename']); $is_image = strpos($this->file['mimetype'], 'image') === 0; $is_ie = strpos(strtolower($this->user->browser), 'msie') !== false; $display_cat = $is_image ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE; if ($thumbnail && $is_image) { $this->file['physical_filename'] = $directory . 'thumb_' . $base_filename; $display_cat = ATTACHMENT_CATEGORY_THUMB; } else { $this->file['physical_filename'] = $directory . $base_filename; $this->increase_download_count(); } if ($type === 'composer') { $composer_package = $this->file['physical_filename'] . '.composer'; if (!file_exists($this->ext_config->upload_path . $composer_package)) { $this->generate_composer_package($composer_package); } $this->file['physical_filename'] = $composer_package; } if (!$thumbnail && $mode === 'view' && $is_image && $is_ie && !phpbb_is_greater_ie_version($this->user->browser, 7)) { $file_url = $this->helper->route('phpbb.titania.download', array('id' => $this->id)); wrap_img_in_html($file_url, $this->file['real_filename']); file_gc(); } else { $filename = $this->ext_config->upload_path . $this->file['physical_filename']; return $this->send_file_to_browser($this->file, $filename, $display_cat); } }