aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_download.php
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2013-04-27 22:01:13 +0200
committerAndreas Fischer <bantu@phpbb.com>2013-04-27 23:04:46 +0200
commitcba5dde0ee0a2f4c2197959f45c5b53389798837 (patch)
tree76cc6f9042da1fd1abd208d35afd6b0de129e229 /phpBB/includes/functions_download.php
parentc182ab0e7b2739ff70fb18611af5e1baa02d81a2 (diff)
parentb39e6e01b291f7a20a143ae3aea1a9582b0c4cad (diff)
downloadforums-cba5dde0ee0a2f4c2197959f45c5b53389798837.tar
forums-cba5dde0ee0a2f4c2197959f45c5b53389798837.tar.gz
forums-cba5dde0ee0a2f4c2197959f45c5b53389798837.tar.bz2
forums-cba5dde0ee0a2f4c2197959f45c5b53389798837.tar.xz
forums-cba5dde0ee0a2f4c2197959f45c5b53389798837.zip
Merge remote-tracking branch 'dhruvgoel92/ticket/10820' into ticket/10820-develop
* dhruvgoel92/ticket/10820: [ticket/10820] remove unnecessary parentheses [ticket/10820] fix docblock [ticket/10820] add param and return to function [ticket/10820] simplify regex and escape dot [ticket/10820] Use singular return [ticket/10820] remove unnecessary condition checks [ticket/10820] add function docblock [ticket/10820] fix IE check function [ticket/10820] proper usage of global and local variable browser [ticket/10820] Image downloader recognize new version of ie Conflicts: phpBB/download/file.php
Diffstat (limited to 'phpBB/includes/functions_download.php')
-rw-r--r--phpBB/includes/functions_download.php24
1 files changed, 18 insertions, 6 deletions
diff --git a/phpBB/includes/functions_download.php b/phpBB/includes/functions_download.php
index 9ae647d806..949c47487b 100644
--- a/phpBB/includes/functions_download.php
+++ b/phpBB/includes/functions_download.php
@@ -46,7 +46,7 @@ function send_avatar_to_browser($file, $browser)
$image_data = @getimagesize($file_path);
header('Content-Type: ' . image_type_to_mime_type($image_data[2]));
- if (strpos(strtolower($browser), 'msie') !== false && strpos(strtolower($browser), 'msie 8.0') === false)
+ if (!phpbb_is_greater_ie7($browser))
{
header('Content-Disposition: attachment; ' . header_filename($file));
@@ -174,10 +174,9 @@ function send_file_to_browser($attachment, $upload_dir, $category)
header('Pragma: public');
// Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer.
- $is_ie8 = (strpos(strtolower($user->browser), 'msie 8.0') !== false);
header('Content-Type: ' . $attachment['mimetype']);
- if ($is_ie8)
+ if (phpbb_is_greater_ie7($user->browser))
{
header('X-Content-Type-Options: nosniff');
}
@@ -189,7 +188,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
}
else
{
- if (empty($user->browser) || (!$is_ie8 && (strpos(strtolower($user->browser), 'msie') !== false)))
+ if (empty($user->browser) || !phpbb_is_greater_ie7($user->browser))
{
header('Content-Disposition: attachment; ' . header_filename(htmlspecialchars_decode($attachment['real_filename'])));
if (empty($user->browser) || (strpos(strtolower($user->browser), 'msie 6.0') !== false))
@@ -200,7 +199,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
else
{
header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename'])));
- if ($is_ie8 && (strpos($attachment['mimetype'], 'image') !== 0))
+ if (phpbb_is_greater_ie7($user->browser) && (strpos($attachment['mimetype'], 'image') !== 0))
{
header('X-Download-Options: noopen');
}
@@ -410,7 +409,8 @@ function set_modified_headers($stamp, $browser)
// 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) && (strpos(strtolower($browser), 'msie 8.0') === false))
+
+ if (strpos(strtolower($browser), 'msie 6.0') === false && !phpbb_is_greater_ie7($browser))
{
if ($last_load !== false && $last_load >= $stamp)
{
@@ -721,3 +721,15 @@ function phpbb_download_clean_filename($filename)
return $filename;
}
+
+/**
+* Check if the browser is internet explorer version 7+
+*
+* @param string $user_agent User agent HTTP header
+*
+* @return bool true if internet explorer version is greater than 7
+*/
+function phpbb_is_greater_ie7($user_agent)
+{
+ return (bool) preg_match('/msie [^67]+\\.*;/', strtolower($user_agent));
+}