Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 1 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
| 2 | /**
|
| 3 | * CodeIgniter
|
| 4 | *
|
| 5 | * An open source application development framework for PHP 4.3.2 or newer
|
| 6 | *
|
| 7 | * @package CodeIgniter
|
Derek Allard | 3d879d5 | 2008-01-18 19:41:32 +0000 | [diff] [blame] | 8 | * @author ExpressionEngine Dev Team
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 9 | * @copyright Copyright (c) 2006, EllisLab, Inc.
|
Derek Jones | 7a9193a | 2008-01-21 18:39:20 +0000 | [diff] [blame^] | 10 | * @license http://codeigniter.com/user_guide/license.html
|
| 11 | * @link http://codeigniter.com
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 12 | * @since Version 1.0
|
| 13 | * @filesource
|
| 14 | */
|
| 15 |
|
| 16 | // ------------------------------------------------------------------------
|
| 17 |
|
| 18 | /**
|
| 19 | * CodeIgniter Security Helpers
|
| 20 | *
|
| 21 | * @package CodeIgniter
|
| 22 | * @subpackage Helpers
|
| 23 | * @category Helpers
|
Derek Allard | 3d879d5 | 2008-01-18 19:41:32 +0000 | [diff] [blame] | 24 | * @author ExpressionEngine Dev Team
|
Derek Jones | 7a9193a | 2008-01-21 18:39:20 +0000 | [diff] [blame^] | 25 | * @link http://codeigniter.com/user_guide/helpers/security_helper.html
|
Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 26 | */
|
| 27 |
|
| 28 | // ------------------------------------------------------------------------
|
| 29 |
|
| 30 | /**
|
| 31 | * XSS Filtering
|
| 32 | *
|
| 33 | * @access public
|
| 34 | * @param string
|
| 35 | * @param string the character set of your data
|
| 36 | * @return string
|
| 37 | */
|
| 38 | function xss_clean($str, $charset = 'ISO-8859-1')
|
| 39 | {
|
| 40 | $CI =& get_instance();
|
| 41 | return $CI->input->xss_clean($str, $charset);
|
| 42 | }
|
| 43 |
|
| 44 | // --------------------------------------------------------------------
|
| 45 |
|
| 46 | /**
|
| 47 | * Hash encode a string
|
| 48 | *
|
| 49 | * @access public
|
| 50 | * @param string
|
| 51 | * @return string
|
| 52 | */
|
| 53 | function dohash($str, $type = 'sha1')
|
| 54 | {
|
| 55 | if ($type == 'sha1')
|
| 56 | {
|
| 57 | if ( ! function_exists('sha1'))
|
| 58 | {
|
| 59 | if ( ! function_exists('mhash'))
|
| 60 | {
|
| 61 | require_once(BASEPATH.'libraries/Sha1'.EXT);
|
| 62 | $SH = new CI_SHA;
|
| 63 | return $SH->generate($str);
|
| 64 | }
|
| 65 | else
|
| 66 | {
|
| 67 | return bin2hex(mhash(MHASH_SHA1, $str));
|
| 68 | }
|
| 69 | }
|
| 70 | else
|
| 71 | {
|
| 72 | return sha1($str);
|
| 73 | }
|
| 74 | }
|
| 75 | else
|
| 76 | {
|
| 77 | return md5($str);
|
| 78 | }
|
| 79 | }
|
| 80 |
|
| 81 | // ------------------------------------------------------------------------
|
| 82 |
|
| 83 | /**
|
| 84 | * Strip Image Tags
|
| 85 | *
|
| 86 | * @access public
|
| 87 | * @param string
|
| 88 | * @return string
|
| 89 | */
|
| 90 | function strip_image_tags($str)
|
| 91 | {
|
| 92 | $str = preg_replace("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "\\1", $str);
|
| 93 | $str = preg_replace("#<img\s+.*?src\s*=\s*(.+?).*?\>#", "\\1", $str);
|
| 94 |
|
| 95 | return $str;
|
| 96 | }
|
| 97 |
|
| 98 | // ------------------------------------------------------------------------
|
| 99 |
|
| 100 | /**
|
| 101 | * Convert PHP tags to entities
|
| 102 | *
|
| 103 | * @access public
|
| 104 | * @param string
|
| 105 | * @return string
|
| 106 | */
|
| 107 | function encode_php_tags($str)
|
| 108 | {
|
| 109 | return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('<?php', '<?PHP', '<?', '?>'), $str);
|
| 110 | }
|
| 111 |
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 112 | ?> |