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

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

[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加载的时候进行的加载php

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

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

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

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

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

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

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

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                 ====》    将请求数据转化为大写/小写
相关文章
相关标签/搜索