summaryrefslogtreecommitdiffstats
path: root/system/helpers/security_helper.php
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2008-01-28 22:00:20 +0100
committerDerek Jones <derek.jones@ellislab.com>2008-01-28 22:00:20 +0100
commit269b942a2bf7b022795e591d9b0ad04526ee7e09 (patch)
treef465bb5a700d4cc5d72ca6e55e251640a46b869b /system/helpers/security_helper.php
parenta25530f6594c7ba45b3faa9537fda9f807069759 (diff)
added ability to "extend" helpers
* modified Loader to check for prefixed helpers in application/helpers folder * surrounded provided helper functions with if (! function_exists('foo')) conditionals so the user's helper functions take precedent.
Diffstat (limited to 'system/helpers/security_helper.php')
-rw-r--r--system/helpers/security_helper.php66
1 files changed, 39 insertions, 27 deletions
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index 97c9a6ba6..7552fd89c 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -35,10 +35,13 @@
* @param string the character set of your data
* @return string
*/
-function xss_clean($str, $charset = 'ISO-8859-1')
+if (! function_exists('xss_clean'))
{
- $CI =& get_instance();
- return $CI->input->xss_clean($str, $charset);
+ function xss_clean($str, $charset = 'ISO-8859-1')
+ {
+ $CI =& get_instance();
+ return $CI->input->xss_clean($str, $charset);
+ }
}
// --------------------------------------------------------------------
@@ -49,32 +52,35 @@ function xss_clean($str, $charset = 'ISO-8859-1')
* @access public
* @param string
* @return string
- */
-function dohash($str, $type = 'sha1')
-{
- if ($type == 'sha1')
+ */
+if (! function_exists('dohash'))
+{
+ function dohash($str, $type = 'sha1')
{
- if ( ! function_exists('sha1'))
+ if ($type == 'sha1')
{
- if ( ! function_exists('mhash'))
- {
- require_once(BASEPATH.'libraries/Sha1'.EXT);
- $SH = new CI_SHA;
- return $SH->generate($str);
+ if ( ! function_exists('sha1'))
+ {
+ if ( ! function_exists('mhash'))
+ {
+ require_once(BASEPATH.'libraries/Sha1'.EXT);
+ $SH = new CI_SHA;
+ return $SH->generate($str);
+ }
+ else
+ {
+ return bin2hex(mhash(MHASH_SHA1, $str));
+ }
}
else
{
- return bin2hex(mhash(MHASH_SHA1, $str));
- }
+ return sha1($str);
+ }
}
else
{
- return sha1($str);
- }
- }
- else
- {
- return md5($str);
+ return md5($str);
+ }
}
}
@@ -87,12 +93,15 @@ function dohash($str, $type = 'sha1')
* @param string
* @return string
*/
-function strip_image_tags($str)
+if (! function_exists('strip_image_tags'))
{
- $str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str);
- $str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str);
+ function strip_image_tags($str)
+ {
+ $str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str);
+ $str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str);
- return $str;
+ return $str;
+ }
}
// ------------------------------------------------------------------------
@@ -104,9 +113,12 @@ function strip_image_tags($str)
* @param string
* @return string
*/
-function encode_php_tags($str)
+if (! function_exists('encode_php_tags'))
{
- return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
+ function encode_php_tags($str)
+ {
+ return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
+ }
}
?> \ No newline at end of file