From 773ccc318f2769c9b7579630569b5d8ba47b114b Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:11:08 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/helpers --- 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 470b61ede..9c390a7f7 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -51,7 +51,7 @@ if ( ! function_exists('force_download')) */ function force_download($filename = '', $data = '', $set_mime = FALSE) { - if ($filename == '' OR $data == '') + if ($filename === '' OR $data === '') { return FALSE; } -- cgit v1.2.3-24-g4f1b From 39b1c11f5976104dce30fe83e1d3c6f9ed616122 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Mon, 4 Jun 2012 16:51:14 -0500 Subject: Direct return from mimes config, instead of using global $mimes; Global variables are generally a terrible idea, especially for something as simple as this. The mimes.php now returns an array instead of just injecting a variable name into the global namespace. --- system/helpers/download_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/helpers/download_helper.php') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 9c390a7f7..3c677055f 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -75,11 +75,11 @@ if ( ! function_exists('force_download')) // Load the mime types if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); + $mimes = include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); } elseif (is_file(APPPATH.'config/mimes.php')) { - include(APPPATH.'config/mimes.php'); + $mimes = include(APPPATH.'config/mimes.php'); } // Only change the default MIME if we can find one -- cgit v1.2.3-24-g4f1b From 6ef498b49946ba74d610b3805fb908b163a7f03a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 5 Jun 2012 22:01:58 +0300 Subject: Added get_mimes() function to system/core/Commons.php.The MIMEs array from config/mimes.php is used by multiple core classes, libraries and helpers and each of them has implemented an own way of getting it, which is not needed and is hard to maintain. This also fixes issue #1411 --- system/helpers/download_helper.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'system/helpers/download_helper.php') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 3c677055f..5efbc4930 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -73,14 +73,7 @@ if ( ! function_exists('force_download')) } // Load the mime types - if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) - { - $mimes = include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); - } - elseif (is_file(APPPATH.'config/mimes.php')) - { - $mimes = include(APPPATH.'config/mimes.php'); - } + $mimes =& get_mimes(); // Only change the default MIME if we can find one if (isset($mimes[$extension])) -- cgit v1.2.3-24-g4f1b From f512b73bc78760198a5409f2c4da71fe749b1301 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 16 Jun 2012 11:15:19 +0100 Subject: Spelling fixes - `wether` to `whether` Interestingly `wether` means a castrated ram in old English --- 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 5efbc4930..09c4de578 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -46,7 +46,7 @@ if ( ! function_exists('force_download')) * * @param string filename * @param mixed the data to be downloaded - * @param bool wether to try and send the actual file MIME type + * @param bool whether to try and send the actual file MIME type * @return void */ function force_download($filename = '', $data = '', $set_mime = FALSE) -- cgit v1.2.3-24-g4f1b From 28ff29272f4ac6815354878534493016ca31582a Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Tue, 14 Aug 2012 10:55:46 +0200 Subject: fix issue 1706 --- system/helpers/download_helper.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'system/helpers/download_helper.php') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 09c4de578..0232adfe4 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -95,7 +95,10 @@ if ( ! function_exists('force_download')) } // Clean output buffer - ob_clean(); + if (ob_get_level() !== 0) + { + ob_clean(); + } // Generate the server headers header('Content-Type: '.$mime); -- cgit v1.2.3-24-g4f1b