1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5 * An open source application development framework for PHP 4.3.2 or newer
8 * @author ExpressionEngine Dev Team
9 * @copyright Copyright (c) 2008 - 2009, EllisLab, Inc.
10 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
16 // ------------------------------------------------------------------------
19 * CodeIgniter Security Helpers
21 * @package CodeIgniter
24 * @author ExpressionEngine Dev Team
25 * @link http://codeigniter.com/user_guide/helpers/security_helper.html
28 // ------------------------------------------------------------------------
35 * @param bool whether or not the content is an image file
38 if ( ! function_exists('xss_clean'))
40 function xss_clean($str, $is_image = FALSE)
42 $CI =& get_instance();
43 return $CI->input->xss_clean($str, $is_image);
47 // --------------------------------------------------------------------
50 * Hash encode a string
56 if ( ! function_exists('dohash'))
58 function dohash($str, $type = 'sha1')
62 if ( ! function_exists('sha1'))
64 if ( ! function_exists('mhash'))
66 require_once(BASEPATH.'libraries/Sha1'.EXT);
68 return $SH->generate($str);
72 return bin2hex(mhash(MHASH_SHA1, $str));
87 // ------------------------------------------------------------------------
96 if ( ! function_exists('strip_image_tags'))
98 function strip_image_tags($str)
100 $str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str);
101 $str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str);
107 // ------------------------------------------------------------------------
110 * Convert PHP tags to entities
116 if ( ! function_exists('encode_php_tags'))
118 function encode_php_tags($str)
120 return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('<?php', '<?PHP', '<?', '?>'), $str);
125 /* End of file security_helper.php */
126 /* Location: ./system/helpers/security_helper.php */