Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ############### |
| 2 | Security Helper |
| 3 | ############### |
| 4 | |
| 5 | The Security Helper file contains security related functions. |
| 6 | |
| 7 | .. contents:: Page Contents |
| 8 | |
| 9 | Loading this Helper |
| 10 | =================== |
| 11 | |
| 12 | This helper is loaded using the following code |
| 13 | |
| 14 | :: |
| 15 | |
| 16 | $this->load->helper('security'); |
| 17 | |
| 18 | The following functions are available: |
| 19 | |
| 20 | xss_clean() |
| 21 | =========== |
| 22 | |
| 23 | Provides Cross Site Script Hack filtering. This function is an alias to |
| 24 | the one in the :doc:`Input class <../libraries/input>`. More info can |
| 25 | be found there. |
| 26 | |
| 27 | sanitize_filename() |
| 28 | =================== |
| 29 | |
| 30 | Provides protection against directory traversal. This function is an |
| 31 | alias to the one in the :doc:`Security class <../libraries/security>`. |
| 32 | More info can be found there. |
| 33 | |
| 34 | do_hash() |
| 35 | ========= |
| 36 | |
freewil | 8840c96 | 2012-03-18 15:23:09 -0400 | [diff] [blame] | 37 | Permits you to create one way hashes suitable for encrypting |
| 38 | passwords. Will create SHA1 by default. See `hash_algos() <http://php.net/function.hash_algos>`_ |
| 39 | for a full list of supported algorithms. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 40 | |
| 41 | :: |
| 42 | |
| 43 | $str = do_hash($str); // SHA1 |
| 44 | $str = do_hash($str, 'md5'); // MD5 |
| 45 | |
Andrey Andreev | 0f0b769 | 2012-06-07 14:57:04 +0300 | [diff] [blame] | 46 | .. note:: This function was formerly named ``dohash()``, which has been |
| 47 | removed in favor of ``do_hash()``. |
| 48 | |
| 49 | .. note:: This function is DEPRECATED. Use the native ``hash()`` instead. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 50 | |
| 51 | strip_image_tags() |
| 52 | ================== |
| 53 | |
| 54 | This is a security function that will strip image tags from a string. It |
| 55 | leaves the image URL as plain text. |
| 56 | |
| 57 | :: |
| 58 | |
| 59 | $string = strip_image_tags($string); |
| 60 | |
| 61 | encode_php_tags() |
| 62 | ================= |
| 63 | |
| 64 | This is a security function that converts PHP tags to entities. Note: If |
| 65 | you use the XSS filtering function it does this automatically. |
| 66 | |
| 67 | :: |
| 68 | |
| 69 | $string = encode_php_tags($string); |
| 70 | |