summaryrefslogtreecommitdiffstats
path: root/system/helpers/security_helper.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-05-17 14:43:09 +0200
committerAndrey Andreev <narf@bofh.bg>2012-05-17 14:43:09 +0200
commite30b3f7afafa2c016cf78cc8bb8a457c2dbcda8c (patch)
tree805c7d92c46d9f669a6eacda3cc7d36faab22116 /system/helpers/security_helper.php
parentae31eb5e75d914fc3ab622a7ac5c23eb1e6d9f9a (diff)
parent98fde46fb938694feb1f36e590c4cfa5c97c3261 (diff)
Merge pull request #1300 from timw4mail/patch
Fix rest of the helpers
Diffstat (limited to 'system/helpers/security_helper.php')
-rw-r--r--system/helpers/security_helper.php63
1 files changed, 32 insertions, 31 deletions
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index d6f134c9f..6187a4a7a 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -37,15 +37,15 @@
// ------------------------------------------------------------------------
-/**
- * XSS Filtering
- *
- * @param string
- * @param bool whether or not the content is an image file
- * @return string
- */
if ( ! function_exists('xss_clean'))
{
+ /**
+ * XSS Filtering
+ *
+ * @param string
+ * @param bool whether or not the content is an image file
+ * @return string
+ */
function xss_clean($str, $is_image = FALSE)
{
$CI =& get_instance();
@@ -55,14 +55,14 @@ if ( ! function_exists('xss_clean'))
// ------------------------------------------------------------------------
-/**
- * Sanitize Filename
- *
- * @param string
- * @return string
- */
if ( ! function_exists('sanitize_filename'))
{
+ /**
+ * Sanitize Filename
+ *
+ * @param string
+ * @return string
+ */
function sanitize_filename($filename)
{
$CI =& get_instance();
@@ -72,14 +72,15 @@ if ( ! function_exists('sanitize_filename'))
// --------------------------------------------------------------------
-/**
- * Hash encode a string
- *
- * @param string
- * @return string
- */
if ( ! function_exists('do_hash'))
{
+ /**
+ * Hash encode a string
+ *
+ * @param string
+ * @param string
+ * @return string
+ */
function do_hash($str, $type = 'sha1')
{
if ( ! in_array(strtolower($type), hash_algos()))
@@ -93,14 +94,14 @@ if ( ! function_exists('do_hash'))
// ------------------------------------------------------------------------
-/**
- * Strip Image Tags
- *
- * @param string
- * @return string
- */
if ( ! function_exists('strip_image_tags'))
{
+ /**
+ * Strip Image Tags
+ *
+ * @param string
+ * @return string
+ */
function strip_image_tags($str)
{
return preg_replace(array('#<img\s+.*?src\s*=\s*["\'](.+?)["\'].*?\>#', '#<img\s+.*?src\s*=\s*(.+?).*?\>#'), '\\1', $str);
@@ -109,14 +110,14 @@ if ( ! function_exists('strip_image_tags'))
// ------------------------------------------------------------------------
-/**
- * Convert PHP tags to entities
- *
- * @param string
- * @return string
- */
if ( ! function_exists('encode_php_tags'))
{
+ /**
+ * Convert PHP tags to entities
+ *
+ * @param string
+ * @return string
+ */
function encode_php_tags($str)
{
return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);