CI框架源码阅读---------Security.php
[php]<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Security Class
* 本类包含一些方法,能帮助您创建安全的应用程序,对输入的数据进行安全方面的处理。
* CI官方手册本类的地址:http://codeigniter.org.cn/user_guide/libraries/security.html
* @package CodeIgniter
* @subpackage Libraries
* @category Security
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/security.html
*/
class CI_Security {
/**
* Random Hash for protecting URLs
* 为保护URL(跨站脚本攻击)的随机hash值
* @var string
* @access protected
*/
protected $_xss_hash = '';
/**
* Random Hash for Cross Site Request Forgery Protection Cookie
* 防止跨站请求伪造cookie的随机hash
* @var string
* @access protected
*/
protected $_csrf_hash = '';
/**
* Expiration time for Cross Site Request Forgery Protection Cookie
* Defaults to two hours (in seconds)
* 跨站请求保护Cookie的过期时间,默认是2小时(单位秒)
* @var int
* @access protected
*/
protected $_csrf_expire = 7200;
/**
* Token name for Cross Site Request Forgery 伪造 Protection Cookie
* 跨站请求伪造保护的Cookie令牌名
* @var string
* @access protected
*/
protected $_csrf_token_name = 'ci_csrf_token';
/**
* Cookie name for Cross Site Request Forgery Protection Cookie
* 跨站请求伪造保护的Cookie的Cookie名
* @var string
* @access protected
*/
protected $_csrf_cookie_name = 'ci_csrf_token';
/**
* List of never allowed strings
* 决不允许的字符串的列表
* @var array
* @access protected
*/
protected $_never_allowed_str = array(
'document.cookie' => '[removed]',
'document.write' => '[removed]',
'.parentNode' => '[removed]',
'.innerHTML' => '[removed]',
'window.location' => '[removed]',
'-moz-binding' => '[removed]',
'<!--' => '<!--',
'-->' => '-->',
'<![CDATA[' => '<![CDATA[',
'<comment>' => '<comment>'
);
/* never allowed, regex replacement */
/**
* List of never allowed regex replacement
* 不允许的正则替换字符串列表
* @var array
* @access protected
*/
protected $_never_allowed_regex = array(
'javascript\s*:',
'expression\s*(\(|&\#40;)', // CSS and IE
'vbscript\s*:', // IE, surprise!
'Redirect\s+302',
"([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?"
);
/**
* Constructor
*
* @return void
*/
public function __construct()
{
// Is CSRF protection enabled?
// csrf 是否开启
if (config_item('csrf_protection') === TRUE)
{
// CSRF config 读取CSRF 配置并赋值给本类下的对应的属性
foreach (array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key)
{
if (FALSE !== ($val = config_item($key)))
{
$this->{'_'.$key} = $val; &
补充:Web开发 , php ,
- 更多php疑问解答:
- php使用imagick将image图片转化为字符串模式
- php通过gd实现图片图片转换为字符图代码
- PHP把图片转base64代码,php把base64代码转换为图片并保存
- PHP把图片base64转换成图片并保存成文件
- wordpress问题<?php if(have_posts()) : ?>
- 建设一个搜索类网站php还是jsp,数据库那个好
- 没理由啊 php代码无法执行,貌似有语法错误。。。
- 关于PHP 和API 的一段代码不懂啊不懂,请高手指点! 这是淘宝API的
- php语言中,序列化到底在那里使用?它的优势是什么?劣势是什么?
- PHP函数等于或等于应该怎么表达
- 请教php高手,解决basename函数和mb_substr函数处理中文文件名称的解决方法,在上传文件时,总是出现乱码
- .NET,PHP,JAVA,JS优秀点分别是?
- 织梦cms 在环境监测的时候 wamp5 gd不支持 是为什么。;extension=php_gd2.dll这一句我删除了还是不显示?
- 我想学PHP。1.应安装什么编程工具? 2. 装LIUNX系统是装简易的还是?什么版本的?3.还应安装什么?
- <?php 和 <? 有什么区别