summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/helpers/security_helper.rst
blob: b1bcf2b4aa8960dee7087274583dc34b9d33de11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
###############
Security Helper
###############

The Security Helper file contains security related functions.

.. contents:: Page Contents

Loading this Helper
===================

This helper is loaded using the following code

::

	$this->load->helper('security');

The following functions are available:

xss_clean()
===========

Provides Cross Site Script Hack filtering. This function is an alias to
the one in the :doc:`Input class <../libraries/input>`. More info can
be found there.

sanitize_filename()
===================

Provides protection against directory traversal. This function is an
alias to the one in the :doc:`Security class <../libraries/security>`.
More info can be found there.

do_hash()
=========

Permits you to create one way hashes suitable for encrypting
passwords. Will create SHA1 by default. See `hash_algos() <http://php.net/function.hash_algos>`_
for a full list of supported algorithms.

::

	$str = do_hash($str); // SHA1
	$str = do_hash($str, 'md5'); // MD5

.. note:: This function was formerly named dohash(), which has been
	removed in favor of `do_hash()`.

strip_image_tags()
==================

This is a security function that will strip image tags from a string. It
leaves the image URL as plain text.

::

	$string = strip_image_tags($string);

encode_php_tags()
=================

This is a security function that converts PHP tags to entities. Note: If
you use the XSS filtering function it does this automatically.

::

	$string = encode_php_tags($string);