HerbIgniter User Guide Version 1.7.2


Security Helper

The Security Helper file contains security related functions.

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 Input class. More info can be found there.

dohash()

Permits you to create SHA1 or MD5 one way hashes suitable for encrypting passwords. Will create SHA1 by default. Examples:

$str = dohash($str); // SHA1

$str = dohash($str, 'md5'); // MD5

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);


inject_protect_sql( text )

Attempts to use preg_replace to stop SQL from being injected through an <INPUT> tag.

$string = inject_protect_sql($string);

inject_protect_email( text )

Validates an email address.

$string = inject_protect_email($string);

inject_protect_numbers( text )

Forces input to numerics only.

$string = inject_protect_numbers($string);

inject_protect_ssn( text )

Forces input to specifically SSN numbers.

$string = inject_protect_ssn($string);

inject_protect_CC ( text )

Forces input to specifically credit card numbers.

$string = inject_protect_CC($string);

inject_protect_zip ( text )

Forces input to specifically ZIP codes.

$string = inject_protect_zip($string);

inject_protect_punctuate( text )

Forces input to a specific set of punctuations and alphanumerics.

$string = inject_protect_punctuate($string);

keyED( txt, encrypt_key)

Encrypts some text by a key.

$string = keyED($string,"somekey");

decrypt( txt, key)

Decrypts some text by a key.

$string = decrypt($string,"somekey");