Merge branch 'ticket/10820' into ticket/10820-develop

* ticket/10820:
  [ticket/10820] Inject IE version in function

Conflicts:
	phpBB/download/file.php
This commit is contained in:
Dhruv 2013-06-05 00:27:32 +05:30
commit e6d521df29
2 changed files with 9 additions and 8 deletions

View file

@ -279,7 +279,7 @@ else if ($download_id)
phpbb_increment_downloads($db, $attachment['attach_id']); phpbb_increment_downloads($db, $attachment['attach_id']);
} }
if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && !phpbb_is_greater_ie7($user->browser)) if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && !phpbb_is_greater_ie_version($user->browser, 7))
{ {
wrap_img_in_html(append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'id=' . $attachment['attach_id']), $attachment['real_filename']); wrap_img_in_html(append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'id=' . $attachment['attach_id']), $attachment['real_filename']);
file_gc(); file_gc();

View file

@ -46,7 +46,7 @@ function send_avatar_to_browser($file, $browser)
$image_data = @getimagesize($file_path); $image_data = @getimagesize($file_path);
header('Content-Type: ' . image_type_to_mime_type($image_data[2])); header('Content-Type: ' . image_type_to_mime_type($image_data[2]));
if (!phpbb_is_greater_ie7($browser)) if (!phpbb_is_greater_ie_version($browser, 7))
{ {
header('Content-Disposition: attachment; ' . header_filename($file)); header('Content-Disposition: attachment; ' . header_filename($file));
@ -176,7 +176,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
// Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer. // Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer.
header('Content-Type: ' . $attachment['mimetype']); header('Content-Type: ' . $attachment['mimetype']);
if (phpbb_is_greater_ie7($user->browser)) if (phpbb_is_greater_ie_version($user->browser, 7))
{ {
header('X-Content-Type-Options: nosniff'); header('X-Content-Type-Options: nosniff');
} }
@ -188,7 +188,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
} }
else else
{ {
if (empty($user->browser) || !phpbb_is_greater_ie7($user->browser)) if (empty($user->browser) || !phpbb_is_greater_ie_version($user->browser, 7))
{ {
header('Content-Disposition: attachment; ' . header_filename(htmlspecialchars_decode($attachment['real_filename']))); header('Content-Disposition: attachment; ' . header_filename(htmlspecialchars_decode($attachment['real_filename'])));
if (empty($user->browser) || (strpos(strtolower($user->browser), 'msie 6.0') !== false)) if (empty($user->browser) || (strpos(strtolower($user->browser), 'msie 6.0') !== false))
@ -199,7 +199,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
else else
{ {
header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename']))); header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename'])));
if (phpbb_is_greater_ie7($user->browser) && (strpos($attachment['mimetype'], 'image') !== 0)) if (phpbb_is_greater_ie_version($user->browser, 7) && (strpos($attachment['mimetype'], 'image') !== 0))
{ {
header('X-Download-Options: noopen'); header('X-Download-Options: noopen');
} }
@ -410,7 +410,7 @@ function set_modified_headers($stamp, $browser)
// let's see if we have to send the file at all // 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; $last_load = $request->header('Modified-Since') ? strtotime(trim($request->header('Modified-Since'))) : false;
if (strpos(strtolower($browser), 'msie 6.0') === false && !phpbb_is_greater_ie7($browser)) if (strpos(strtolower($browser), 'msie 6.0') === false && !phpbb_is_greater_ie_version($browser, 7))
{ {
if ($last_load !== false && $last_load >= $stamp) if ($last_load !== false && $last_load >= $stamp)
{ {
@ -726,15 +726,16 @@ function phpbb_download_clean_filename($filename)
* Check if the browser is internet explorer version 7+ * Check if the browser is internet explorer version 7+
* *
* @param string $user_agent User agent HTTP header * @param string $user_agent User agent HTTP header
* @param int $version IE version to check against
* *
* @return bool true if internet explorer version is greater than 7 * @return bool true if internet explorer version is greater than 7
*/ */
function phpbb_is_greater_ie7($user_agent) function phpbb_is_greater_ie_version($user_agent, $version)
{ {
if (preg_match('/msie (\d+)/', strtolower($user_agent), $matches)) if (preg_match('/msie (\d+)/', strtolower($user_agent), $matches))
{ {
$ie_version = (int) $matches[1]; $ie_version = (int) $matches[1];
return ($ie_version > 7); return ($ie_version > $version);
} }
else else
{ {