security_helper.php
Go to the documentation of this file.00001 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 if ( ! function_exists('xss_clean'))
00039 {
00040 function xss_clean($str, $charset = 'ISO-8859-1')
00041 {
00042 $CI =& get_instance();
00043 return $CI->input->xss_clean($str, $charset);
00044 }
00045 }
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 if ( ! function_exists('dohash'))
00057 {
00058 function dohash($str, $type = 'sha1')
00059 {
00060 if ($type == 'sha1')
00061 {
00062 if ( ! function_exists('sha1'))
00063 {
00064 if ( ! function_exists('mhash'))
00065 {
00066 require_once(BASEPATH.'libraries/Sha1'.EXT);
00067 $SH = new CI_SHA;
00068 return $SH->generate($str);
00069 }
00070 else
00071 {
00072 return bin2hex(mhash(MHASH_SHA1, $str));
00073 }
00074 }
00075 else
00076 {
00077 return sha1($str);
00078 }
00079 }
00080 else
00081 {
00082 return md5($str);
00083 }
00084 }
00085 }
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 if ( ! function_exists('strip_image_tags'))
00097 {
00098 function strip_image_tags($str)
00099 {
00100 $str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?>#", "\\1", $str);
00101 $str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?>#", "\\1", $str);
00102
00103 return $str;
00104 }
00105 }
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 if ( ! function_exists('encode_php_tags'))
00117 {
00118 function encode_php_tags($str)
00119 {
00120 return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('<?php', '<?PHP', '<?', '?>'), $str);
00121 }
00122 }
00123
00124
00125
00126