summaryrefslogtreecommitdiffstats
path: root/system/helpers/security_helper.php
diff options
context:
space:
mode:
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