$display_cat = $extensions[$attachment['extension']]['display_cat']; if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !$user->optionget('viewimg')) { $display_cat = ATTACHMENT_CATEGORY_NONE; } 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 && !$attachment['is_orphan'] && !src_http_byte_range($attachment['filesize'])) { // Update download count src_increment_downloads($db, $attachment['attach_id']); } } if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && strpos($attachment['mimetype'], 'image') === 0 && strpos(strtolower($user->browser), 'msie') !== false && !src_is_greater_ie_version($user->browser, 7)) { wrap_img_in_html(append_sid($src_root_path . 'download/file.' . $phpEx, 'id=' . $attachment['attach_id']), $attachment['real_filename']); file_gc(); } else { // Determine the 'presenting'-method if ($download_mode == PHYSICAL_LINK) { // This presenting method should no longer be used if (!@is_dir($src_root_path . $config['upload_path'])) { send_status_line(500, 'Internal Server Error'); trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']); } redirect($src_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']); file_gc(); } else { send_file_to_browser($attachment, $config['upload_path'], $display_cat); file_gc();
/** * Check if the browser has the file already and set the appropriate headers- * @returns false if a resend is in order. */ function set_modified_headers($stamp, $browser) { global $request; // let's see if we have to send the file at all $last_load = $request->header('Modified-Since') ? strtotime(trim($request->header('Modified-Since'))) : false; if (strpos(strtolower($browser), 'msie 6.0') === false && !src_is_greater_ie_version($browser, 7)) { if ($last_load !== false && $last_load >= $stamp) { send_status_line(304, 'Not Modified'); // seems that we need those too ... browsers header('Cache-Control: public'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); return true; } else { header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stamp) . ' GMT'); } } return false; }