CodeIgniter 使用手冊版本 2.1.4


Security 輔助函數

Security 輔助函數的檔案包含安全相關的函數。

載入輔助函數

載入輔助函數使用下列的程式碼:

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

底下的函數就可以開始使用:

xss_clean()

提供跨網站攻擊程式的過濾,此函數是Input 類別的其中的一個別名。

sanitize_filename()

Provides protection against directory traversal. This function is an alias to the one in the Security class. More info can be found there.

do_hash()

允取建立單向 SHA1 或是 MD5 表來供作加密密碼。預設建立 SHA1。範例:

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

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

Note: This function was formerly named dohash(), which has been deprecated in favour of do_hash().

strip_image_tags()

這是安全性的功能,將會去掉字串中的影像標籤。它會把影像的 URL 視為普通文字。

$string = strip_image_tags($string);

encode_php_tags()

這是安全性函數,用來將 PHP 標籤轉換成實體。注意: 若使用 XSS 過濾功能的話,這個函數則會自動啟動。

$string = encode_php_tags($string);