summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorTimothy Warren <tim@timshomepage.net>2012-06-12 13:45:45 +0200
committerTimothy Warren <tim@timshomepage.net>2012-06-12 13:45:45 +0200
commitb30a7c0d53c5dae5dab2311f777d67f639a5cee4 (patch)
treed518bc938a5d8458a55277d9adaa7d8fdcc9f1d3 /system/helpers
parent3902e383b41c6c0ef77b65e95d451cb2ea3d85db (diff)
parent4e9538fe19b09c0dc588542cfb7f793348b83bf7 (diff)
Merge upstream
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/download_helper.php9
-rw-r--r--system/helpers/file_helper.php58
-rw-r--r--system/helpers/form_helper.php15
-rw-r--r--system/helpers/path_helper.php2
-rw-r--r--system/helpers/security_helper.php3
5 files changed, 25 insertions, 62 deletions
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 9c390a7f7..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'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
- }
- elseif (is_file(APPPATH.'config/mimes.php'))
- {
- include(APPPATH.'config/mimes.php');
- }
+ $mimes =& get_mimes();
// Only change the default MIME if we can find one
if (isset($mimes[$extension]))
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 0061c4285..be616f62d 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -44,38 +44,15 @@ if ( ! function_exists('read_file'))
*
* Opens the file specfied in the path and returns it as a string.
*
+ * This function is DEPRECATED and should be removed in
+ * CodeIgniter 3.1+. Use file_get_contents() instead.
+ *
* @param string path to file
* @return string
*/
function read_file($file)
{
- if ( ! file_exists($file))
- {
- return FALSE;
- }
-
- if (function_exists('file_get_contents'))
- {
- return file_get_contents($file);
- }
-
- if ( ! $fp = @fopen($file, FOPEN_READ))
- {
- return FALSE;
- }
-
- flock($fp, LOCK_SH);
-
- $data = '';
- if (filesize($file) > 0)
- {
- $data =& fread($fp, filesize($file));
- }
-
- flock($fp, LOCK_UN);
- fclose($fp);
-
- return $data;
+ return @file_get_contents($file);
}
}
@@ -349,36 +326,23 @@ if ( ! function_exists('get_mime_by_extension'))
{
$extension = strtolower(substr(strrchr($file, '.'), 1));
- global $mimes;
+ static $mimes;
if ( ! is_array($mimes))
{
- if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
- {
- include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
- }
- elseif (is_file(APPPATH.'config/mimes.php'))
- {
- include(APPPATH.'config/mimes.php');
- }
+ $mimes =& get_mimes();
- if ( ! is_array($mimes))
+ if (empty($mimes))
{
return FALSE;
}
}
- if (array_key_exists($extension, $mimes))
+ if (isset($mimes[$extension]))
{
- if (is_array($mimes[$extension]))
- {
- // Multiple mime types, just give the first one
- return current($mimes[$extension]);
- }
- else
- {
- return $mimes[$extension];
- }
+ return is_array($mimes[$extension])
+ ? current($mimes[$extension]) // Multiple mime types, just give the first one
+ : $mimes[$extension];
}
return FALSE;
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 410972187..984634315 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -325,7 +325,10 @@ if ( ! function_exists('form_dropdown'))
$selected = array($_POST[$name]);
}
- if ($extra !== '') $extra = ' '.$extra;
+ if ($extra != '')
+ {
+ $extra = ' '.$extra;
+ }
$multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
@@ -378,7 +381,7 @@ if ( ! function_exists('form_checkbox'))
{
$checked = $data['checked'];
- if ($checked === FALSE)
+ if ($checked == FALSE)
{
unset($data['checked']);
}
@@ -388,7 +391,7 @@ if ( ! function_exists('form_checkbox'))
}
}
- if ($checked === TRUE)
+ if ($checked == TRUE)
{
$defaults['checked'] = 'checked';
}
@@ -702,7 +705,7 @@ if ( ! function_exists('set_select'))
return '';
}
}
- elseif (($field === '' OR $value === '') OR ($field !== $value))
+ elseif (($field == '' OR $value == '') OR $field !== $value)
{
return '';
}
@@ -753,7 +756,7 @@ if ( ! function_exists('set_checkbox'))
return '';
}
}
- elseif (($field === '' OR $value === '') OR ($field !== $value))
+ elseif (($field == '' OR $value == '') OR $field !== $value)
{
return '';
}
@@ -806,7 +809,7 @@ if ( ! function_exists('set_radio'))
}
else
{
- if (($field === '' OR $value === '') OR ($field !== $value))
+ if (($field == '' OR $value == '') OR $field !== $value)
{
return '';
}
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php
index 13410545c..fec4a1a10 100644
--- a/system/helpers/path_helper.php
+++ b/system/helpers/path_helper.php
@@ -55,7 +55,7 @@ if ( ! function_exists('set_realpath'))
}
// Resolve the path
- if (function_exists('realpath') && @realpath($path) !== FALSE)
+ if (@realpath($path) !== FALSE)
{
$path = realpath($path);
}
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index 6187a4a7a..3e6e91435 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -77,6 +77,9 @@ if ( ! function_exists('do_hash'))
/**
* Hash encode a string
*
+ * This function is DEPRECATED and should be removed in
+ * CodeIgniter 3.1+. Use hash() instead.
+ *
* @param string
* @param string
* @return string