安全輔助函數(shù)
這個安全輔助函數(shù)文件包含一系列和安全相關(guān)的函數(shù)。
加載這個輔助函數(shù)
輔助函數(shù)可以使用如下代碼進行加載:
$this->load->helper('security');
可以使用下面的函數(shù):
xss_clean()
這個函數(shù)提供了 XSS 過濾,其實它是輸入類的一個別名,關(guān)于更多的信息可以到那里去查看。
sanitize_filename()
此函數(shù)對目錄遍歷提供保護. 其實它是 安全類(下$this->security->sanitize_filename() 譯者注)的一個別名. 更多信息可以到那里去查看.
do_hash()
允許你創(chuàng)建SHA1或者MD5加密. 可以參考如下例子:
$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()
這個函數(shù)可以刪除圖片的一些不必要字符,目的是讓圖片的url以文本的形式存在,提高了安全性.
$string = strip_image_tags($string);
encode_php_tags()
這個函數(shù)可以把PHP腳本標簽強制轉(zhuǎn)成實體對象. Note: 如果你使用了XSS過濾函數(shù)的話,會自動轉(zhuǎn)換.
$string = encode_php_tags($string);
?