Skip to content

Relative path issue & fix #23

Description

@AmitMY

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions