安全辅助函数¶
安全辅助函数文件包含了一些和安全相关的函数。
可用函数¶
该辅助函数有下列可用函数:
- xss_clean($str[, $is_image = FALSE])¶
- 参数: - $str (string) -- Input data
- $is_image (bool) -- Whether we're dealing with an image
 - 返回: - XSS-clean string - 返回类型: - string - 该函数提供了 XSS 攻击的过滤。 - 它是 CI_Input::xss_clean() 函数的别名,更多信息,请查阅 输入类 文档。 
- sanitize_filename($filename)¶
- 参数: - $filename (string) -- Filename
 - 返回: - Sanitized file name - 返回类型: - string - 该函数提供了 目录遍历 攻击的防护。 - 它是 CI_Security::sanitize_filename() 函数的别名,更多信息,请查阅 安全类 文档。 
- do_hash($str[, $type = 'sha1'])¶
- 参数: - $str (string) -- Input
- $type (string) -- Algorithm
 - 返回: - Hex-formatted hash - 返回类型: - string - 该函数可计算单向散列,一般用于对密码进行加密,默认使用 SHA1 。 - 你可以前往 hash_algos() 查看所有支持的算法清单。 - 举例: - $str = do_hash($str); // SHA1 $str = do_hash($str, 'md5'); // MD5 - 注解 - 这个函数前身为 dohash(),已废弃。 - 注解 - 这个函数也不建议使用,使用原生的 hash() 函数替代。 
- 参数: - $str (string) -- Input string
 - 返回: - The input string with no image tags - 返回类型: - string - 该安全函数从一个字符串中剥除 image 标签,它将 image 标签转为纯图片的 URL 文本。 - 举例: - $string = strip_image_tags($string); - 它是 CI_Security::strip_image_tags() 函数的别名,更多信息,请查阅 安全类 文档。 
- 参数: - $str (string) -- Input string
 - 返回: - Safely formatted string - 返回类型: - string - 该安全函数将 PHP 标签转换为实体对象。 - 注解 - 如果你使用函数 xss_clean() ,会自动转换。 - 举例: - $string = encode_php_tags($string);