Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative path issue & fix #23

Open
AmitMY opened this issue Oct 17, 2016 · 0 comments
Open

Relative path issue & fix #23

AmitMY opened this issue Oct 17, 2016 · 0 comments

Comments

@AmitMY
Copy link

AmitMY commented Oct 17, 2016

In core/Codeigniter.php lines 402, 408, there is a reference to this path:
APPPATH.'controllers/'.$RTR->directory.$class.'.php'
Normally, this works, but for users using custom loaders (like HVMC), it creates a problem on some machines.
It tries to access application/controllers/../modules/countries/controllers/Countries/index
Which on some machines translate correctly to application/modules/countries/controllers/Countries/index
And on some returns 404

A solution to that is using your own path resolver, something like:
Replace 402-408

function resolve_path($path) {
    $stack = [];
    foreach(explode('/', $path) as $segment)
        if($segment == "..")
            array_pop($stack);
        else
            $stack[] = $segment;
    return implode('/', $stack);
}
$controller_path = resolve_path(APPPATH.'controllers/'.$RTR->directory.$class.'.php');

if (empty($class) OR ! file_exists($controller_path))
{
    $e404 = TRUE;
}
else
{
    require_once($controller_path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant