【CI】阅读源码整理(四)input

在控制器直接继承 CI_Controller 的情况下,打印$this,

[input] => CI_Input Object
        (
            [ip_address:protected] => 
            [_allow_get_array:protected] => 1
            [_standardize_newlines:protected] => 
            [_enable_xss:protected] => 
            [_enable_csrf:protected] => 
            [headers:protected] => Array
                (
                )

            [_raw_input_stream:protected] => 
            [_input_stream:protected] => 
            [security:protected] => CI_Security Object
                (
                    [filename_bad_chars] => Array
                        (
                            [0] => ../
                            [1] => 
                            [3] => <
                            [4] => >
                            [5] => '
                            [6] => "
                            [7] => &
                            [8] => $
                            [9] => #
                            [10] => {
                            [11] => }
                            [12] => [
                            [13] => ]
                            [14] => =
                            [15] => ;
                            [16] => ?
                            [17] => %20
                            [18] => %22
                            [19] => %3c
                            [20] => %253c
                            [21] => %3e
                            [22] => %0e
                            [23] => %28
                            [24] => %29
                            [25] => %2528
                            [26] => %26
                            [27] => %24
                            [28] => %3f
                            [29] => %3b
                            [30] => %3d
                        )

                    [charset] => UTF-8
                    [_xss_hash:protected] => 
                    [_csrf_hash:protected] => 
                    [_csrf_expire:protected] => 7200
                    [_csrf_token_name:protected] => ci_csrf_token
                    [_csrf_cookie_name:protected] => ci_csrf_token
                    [_never_allowed_str:protected] => Array
                        (
                            [document.cookie] => [removed]
                            [document.write] => [removed]
                            [.parentNode] => [removed]
                            [.innerHTML] => [removed]
                            [-moz-binding] => [removed]
                            [] => -->
                            [ <![CDATA[
                            [] => <comment>
                            [<%] => <%
                        )

                    [_never_allowed_regex:protected] => Array
                        (
                            [0] => javascript\s*:
                            [1] => (document|(document\.)?window)\.(location|on\w*)
                            [2] => expression\s*(\(|&\#40;)
                            [3] => vbscript\s*:
                            [4] => wscript\s*:
                            [5] => jscript\s*:
                            [6] => vbs\s*:
                            [7] => Redirect\s+30\d
                            [8] => (["'])?data\s*:[^\1]*?base64[^\1]*?,[^\1]*?\1?
                        )

                )

            [uni:protected] => CI_Utf8 Object
                (
                )

        )

可以看到有input的相关信息,只能猜测在Loader.php加载的时候进行的加载

在Input中会先获取以下参数,(注:这几个参数在application\config\config.php 中进行配置)

allow_get_array                    ======》   官方说明【Allow $_GET array】

global_xss_filtering               ======》    官方说明【Global XSS Filtering】

csrf_protection                    ======》    官方说明【Cross Site Request Forgery】

standardize_newlines               ======》    官方说明【Standardize newlines】

注:这四个参数是有关安全的一些设置,如xss(跨站点攻击)、csrf(跨站伪造请求)等

然后加载Security类,根据相关参数值相应处理。

Input类提供了以下方法

get                    ====》    获取get请求的参数值

post                   ====》    获取post请求的参数值

post_get               ====》    判断是否为post请求,如果是以post获取请求参数值,否则以get获取

get_post               ====》    判断是否为get请求,如果是以以get获取请求参数值,否则以post获取

cookie                 ====》    获取cookie值

server                 ====》    获取$_SERVER值,(注:服务端信息)

input_stream           ====》    获取 php://input 的参数值

set_cookie             ====》    设置cookie值

ip_address             ====》    获取客户端IP

valid_ip               ====》    验证IP是否合法

user_agent             ====》    获取UA

request_headers        ====》    设置header参数

get_request_header     ====》    获取header参数

is_ajax_request        ====》    判断是否为ajax请求

is_cli_request         ====》    是否为命令行模式

method                 ====》    将请求数据转化为大写/小写

转载于:https://my.oschina.net/u/3268486/blog/3029636

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值