Welcome Guest, Not a member yet? Register   Sign In
Trying to overwrite a Router function don't work
#1

[eluser]CI Samson[/eluser]
I want to overwrite the function _filter_uri of the Router class to avoid the error message "The URI you submitted has disallowed characters.". So I have created a file MY_Router.php in the libraries folder of my application with the following code:

Code:
class MY_Router extends CI_Router {

    function MY_Router()
    {
        parent::CI_Router();
    }
    
    function _filter_uri($str)
    {
        if ($this->config->item('permitted_uri_chars') != '')
        {
            if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", $str))
            {
                show_404();
                exit();
            }
        }    
        return $str;
    }
}

But it doesn't work, I see allays the same message.
Is it because the _filter_uri function is called in the constructor of the Router class ?
How can I do to show a not found page at the place of the error message without changing the core router class ?

Thank you for your help!


Messages In This Thread
Trying to overwrite a Router function don't work - by El Forum - 02-02-2008, 04:43 AM
Trying to overwrite a Router function don't work - by El Forum - 02-02-2008, 10:01 AM
Trying to overwrite a Router function don't work - by El Forum - 02-03-2008, 09:24 AM
Trying to overwrite a Router function don't work - by El Forum - 02-03-2008, 10:07 AM
Trying to overwrite a Router function don't work - by El Forum - 02-03-2008, 10:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB