From 07c1ac830b4e98aa40f48baef3dd05fb68c0a836 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 9 Mar 2012 17:03:37 +0000 Subject: Bumped CodeIgniter's PHP requirement to 5.2.4. Yes I know PHP 5.4 just came out, and yes I know PHP 5.3 has lovely features, but there are plenty of corporate systems running on CodeIgniter and PHP 5.3 still is not widely supported enough. CodeIgniter is great for distributed applications, and this is the highest we can reasonably go without breaking support. PHP 5.3 will most likely happen in another year or so. Fingers crossed on that one anyway... --- system/helpers/download_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers/download_helper.php') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index a8c59c2c0..47d55dbf5 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * -- cgit v1.2.3-24-g4f1b From 4da9478ca00a9316c525b71001e0c6260d7d85fa Mon Sep 17 00:00:00 2001 From: dododedodonl Date: Sat, 10 Mar 2012 13:56:17 +0100 Subject: Removed quotes from the Content-Type header to support mime-type detection on android --- system/helpers/download_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers/download_helper.php') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 47d55dbf5..f3f0ff2ca 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -91,7 +91,7 @@ if ( ! function_exists('force_download')) } // Generate the server headers - header('Content-Type: "'.$mime.'"'); + header('Content-Type: '.$mime); header('Content-Disposition: attachment; filename="'.$filename.'"'); header('Expires: 0'); header('Content-Transfer-Encoding: binary'); -- cgit v1.2.3-24-g4f1b From fce2ed6d1d3026c485e79ce5bf236effc67981be Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 11 Mar 2012 22:04:48 +0200 Subject: Added an Android <= 2.1 specific check to force_download() --- system/helpers/download_helper.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'system/helpers/download_helper.php') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index f3f0ff2ca..34f9bc07d 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -60,19 +60,19 @@ if ( ! function_exists('force_download')) // Set the default MIME type to send $mime = 'application/octet-stream'; + $x = explode('.', $filename); + $extension = end($x); + if ($set_mime === TRUE) { - /* If we're going to detect the MIME type, - * we'll need a file extension. - */ - if (FALSE === strpos($filename, '.')) + if (count($x) === 1 OR $extension === '') { + /* If we're going to detect the MIME type, + * we'll need a file extension. + */ return FALSE; } - $extension = explode('.', $filename); - $extension = end($extension); - // Load the mime types if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { @@ -90,6 +90,18 @@ if ( ! function_exists('force_download')) } } + /* It was reported that browsers on Android 2.1 (and possibly older as well) + * need to have the filename extension upper-cased in order to be able to + * download it. + * + * Reference: http://digiblog.de/2011/04/19/android-and-the-download-file-headers/ + */ + if (count($x) !== 1 && isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/Android\s(1|2\.[12])/', $_SERVER['HTTP_USER_AGENT'])) + { + $x[count($x) - 1] = strtoupper($extension); + $filename = implode('.', $x); + } + // Generate the server headers header('Content-Type: '.$mime); header('Content-Disposition: attachment; filename="'.$filename.'"'); -- cgit v1.2.3-24-g4f1b From 3d933b6fad72d4b92f18187dd57f1d3c35f8936a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 11 Mar 2012 22:08:57 +0200 Subject: Fix erroneus regex from previous commit --- system/helpers/download_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers/download_helper.php') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 34f9bc07d..96ff29dec 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -96,7 +96,7 @@ if ( ! function_exists('force_download')) * * Reference: http://digiblog.de/2011/04/19/android-and-the-download-file-headers/ */ - if (count($x) !== 1 && isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/Android\s(1|2\.[12])/', $_SERVER['HTTP_USER_AGENT'])) + if (count($x) !== 1 && isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/Android\s(1|2\.[01])/', $_SERVER['HTTP_USER_AGENT'])) { $x[count($x) - 1] = strtoupper($extension); $filename = implode('.', $x); -- cgit v1.2.3-24-g4f1b From 627e172fd3ada0fc2b648a3fff10af4a0022378f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 20:53:47 +0300 Subject: Remove access description lines and cleanup the download, language, number, path & xml helpers --- system/helpers/download_helper.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'system/helpers/download_helper.php') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 96ff29dec..19192a147 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -42,7 +42,6 @@ * * Generates headers that force a download to happen * - * @access public * @param string filename * @param mixed the data to be downloaded * @param bool wether to try and send the actual file MIME type @@ -125,4 +124,4 @@ if ( ! function_exists('force_download')) } /* End of file download_helper.php */ -/* Location: ./system/helpers/download_helper.php */ +/* Location: ./system/helpers/download_helper.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From d52e3b19eb03bcd38f89ccbf5aae68364f715343 Mon Sep 17 00:00:00 2001 From: Sam Li Date: Mon, 23 Apr 2012 23:04:35 +0800 Subject: Added fix for issue: https://github.com/EllisLab/CodeIgniter/issues/1277 --- system/helpers/download_helper.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'system/helpers/download_helper.php') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 19192a147..18fe96223 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -100,6 +100,9 @@ if ( ! function_exists('force_download')) $x[count($x) - 1] = strtoupper($extension); $filename = implode('.', $x); } + + //Clean output buffer + ob_clean(); // Generate the server headers header('Content-Type: '.$mime); -- cgit v1.2.3-24-g4f1b From bbd9dd3df9d373fbac8560db926a9f70a5bde3b7 Mon Sep 17 00:00:00 2001 From: Sam Li Date: Mon, 23 Apr 2012 23:13:46 +0800 Subject: Tweak to comments to conform to style guide. --- system/helpers/download_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers/download_helper.php') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 18fe96223..8b87f8179 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -101,7 +101,7 @@ if ( ! function_exists('force_download')) $filename = implode('.', $x); } - //Clean output buffer + // Clean output buffer ob_clean(); // Generate the server headers -- cgit v1.2.3-24-g4f1b