如何解决CI框架的Disallowed Key Characters错误提示

yipeiwu_com6年前PHP代码库
用CI框架时,有时候会遇到这么一个问题,打开网页,只显示 Disallowed Key Characters 错误提示。有人说 url 里有非法字符。但是确定 url 是纯英文的,问题还是出来了。但清空浏览器历史记录和cookies后。 刷新就没问题了。有时候。打开不同的浏览器。有的浏览器会有问题。有的就不会。

解决 CodeIgniter 框架应用中,出现Disallowed Key Characters错误提示的方法。找到/system/core文件夹下的Input文件,将下面的代码:
复制代码 代码如下:

function _clean_input_keys($str)
{
    if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
    {
        exit('Disallowed Key Characters.');
    }
    // Clean UTF-8 if supported
    if (UTF8_ENABLED === TRUE)
    {
        $str = $this->uni->clean_string($str);
    }
    return $str;
}

改为:
复制代码 代码如下:

function _clean_input_keys($str)  
{  
    $config = &get_config('config');  
    if ( ! preg_match("/^[".$config['permitted_uri_chars']."]+$/i", rawurlencode($str)))  
    {  
        exit('Disallowed Key Characters.');  
    }  

    // Clean UTF-8 if supported
    if (UTF8_ENABLED === TRUE)
    {
        $str = $this->uni->clean_string($str);
    }
    return $str;  
}

相关文章

PHP 文件上传源码分析(RFC1867)

你总不至于在用户要上传头像的时候告诉用户”请打开FTP客户端,上传文件到//www.jb51.net/uploads/中, 并以2dk433423l.jpg命名”吧? 而基于HTTP的...

深入理解ob_flush和flush的区别(ob_flush()与flush()使用方法)

有关php的ob_flush()与flush()使用方法 注意:ob_flush()和flush()这两个函数一般要一起使用,顺序是先ob_flush(),然后flush(),它们的作用...

用php来限制每个ip每天浏览页面数量的实现思路

实现思路:首先,创建一个表,比如下面的 复制代码 代码如下:   CREATE TABLE ip_log   (   ip_log_ip VARCHAR(40),   ip_log_da...

php实现数组按拼音顺序排序的方法 原创

本文实例讲述了php实现数组按拼音顺序排序的方法。分享给大家供大家参考,具体如下: 一、问题: 给定数组要求实现按照其汉字首字母排序: $pinyin = array( arra...

用php实现的获取网页中的图片并保存到本地的代码

复制代码 代码如下:<?php header("Content-type:image/jpeg"); function read_url($str) { $file=fopen($...