Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 禁用特定变量的全局筛选_Php_Codeigniter - Fatal编程技术网

Php 禁用特定变量的全局筛选

Php 禁用特定变量的全局筛选,php,codeigniter,Php,Codeigniter,在配置文件中,我已将全局xss_筛选设置为TRUE。可以对特定数据禁用xss筛选吗?假设我想对'title'post变量禁用xss筛选 有可能做到吗?好吧,据我所知,你可以做一些小改动。 转到输入类(system/core/input.php)并更改$xss_clean参数的默认值。 本机设置为FALSE,因此您可以选择通过将TRUE传递给$this->input->post()或get()来更改它 例如post()(在input.php的第128行),但您还需要应用于get /** *

在配置文件中,我已将全局xss_筛选设置为TRUE。可以对特定数据禁用xss筛选吗?假设我想对'title'post变量禁用xss筛选


有可能做到吗?

好吧,据我所知,你可以做一些小改动。 转到输入类(system/core/input.php)并更改$xss_clean参数的默认值。 本机设置为FALSE,因此您可以选择通过将TRUE传递给$this->input->post()或get()来更改它

例如post()(在input.php的第128行),但您还需要应用于get

/**
    * Fetch an item from the POST array
    *
    * @access   public
    * @param    string
    * @param    bool
    * @return   string
    */
    function post($index = NULL, $xss_clean = TRUE)   // <-- Here I changed the default from FALSE to TRUE)
    {
        // Check if a field has been provided
        if ($index === NULL AND ! empty($_POST))
        {
            $post = array();

            // Loop through the full _POST array and return it
            foreach (array_keys($_POST) as $key)
            {
                $post[$key] = $this->_fetch_from_array($_POST, $key, $xss_clean);
            }
            return $post;
        }

        return $this->_fetch_from_array($_POST, $index, $xss_clean);
    }
它应该以同样的方式工作,并且您不需要每次更改核心文件时都对其进行黑客攻击
阅读手册上的页面以获得更好的信息

class MY_Input extends CI_Input {

    function __construct()
    {
       parent::__construct();
    }

    //........

    function get($index = NULL, $xss_clean = TRUE)
    {
        return parent::get($index, $xss_clean);
    }

    //...........

    function post($index = NULL , $xss_clean = TRUE)
    {
        return parent::post($index, $xss_clean);
    }

}