?
This document uses PHP Chinese website manual Release
安全幫助文件包含與安全相關(guān)的功能。
加載此助手
可用職能
使用以下代碼加載此助手:
$this->load->helper('security');
現(xiàn)有下列職能:
xss_clean($str[, $is_image = FALSE])
參數(shù): | $ str(string) - 輸入數(shù)據(jù)$ is_image(bool) - 是否處理圖像 |
---|---|
返回: | XSS干凈的字符串 |
返回類型: | 串 |
$ str(string) - 輸入數(shù)據(jù)
$ is_image(bool) - 我們是否正在處理圖像
Returns: XSS-clean string
Return type: string
Provides Cross Site Script Hack filtering.
這個(gè)函數(shù)是一個(gè)別名CI_Input::xss_clean()
。有關(guān)更多信息,請(qǐng)參閱輸入庫(kù)文檔。
sanitize_filename($filename)
參數(shù): | $ filename(字符串) - 文件名 |
---|---|
返回: | 消毒文件名稱 |
返回類型: | 串 |
$ filename(字符串) - 文件名返回:清理文件名返回類型:字符串提供針對(duì)目錄遍歷的保護(hù)。這個(gè)函數(shù)是一個(gè)別名CI_Security::sanitize_filename()
。有關(guān)更多信息,請(qǐng)參閱安全庫(kù)文檔。do_hash($str[, $type = 'sha1'])
參數(shù):$ str(string) - 輸入$ type(string) - AlgorithmReturns:十六進(jìn)制格式hashReturn類型:string
$ str(string) - 輸入
$ type(string) - 算法
Returns: Hex-formatted hash
Return type: string
Permits you to create one way hashes suitable for encrypting passwords. Will use SHA1 by default.
有關(guān)支持的算法的完整列表,請(qǐng)參閱hash_algos()。
例子:
$ str = do_hash($ str); // SHA1 $ str = do_hash($ str,'md5'); // MD5
注
這個(gè)函數(shù)以前被命名為dohash()
,它已被移除,以利于...do_hash()
...
注
這一功能已被廢棄。使用本機(jī)hash()
相反。
strip_image_tags($str)
參數(shù): | $ str(string) - 輸入字符串 |
---|---|
返回: | 沒(méi)有圖像標(biāo)簽的輸入字符串 |
返回類型: | 串 |
$ str(string) - 輸入字符串返回:沒(méi)有圖像標(biāo)簽的輸入字符串返回類型:字符串這是一個(gè)安全功能,將從字符串中去除圖像標(biāo)簽。它將圖像URL保留為純文本。例如:$ string = strip_image_tags($ string); 這個(gè)函數(shù)是一個(gè)別名CI_Security::strip_image_tags()
。有關(guān)更多信息,請(qǐng)參閱安全庫(kù)文檔。encode_php_tags($str)
參數(shù):$ str(string) - 輸入stringReturns:安全格式化的字符串返回類型:字符串
$ str(string) - 輸入字符串
Returns: Safely formatted string
Return type: string
This is a security function that converts PHP tags to entities.
注
xss_clean()
如果你用的話,這是自動(dòng)完成的。
例子:
$ string = encode_php_tags($ string);