Welcome Guest, Not a member yet? Register   Sign In
Setting the server path
#1

[eluser]helmutbjorg[/eluser]
Hi Guys,

This isn't really a bug but thought I might mention it.

In index.php when setting the $system_folder variable I noticed a slight problem. The realpath would not be determined if a relative address was given for the system folder. When entering '../system' (a relative address) into the $system_folder variable caused the system to assume it was an absolute address.

Here is the code in question from index.php
Code:
/*
|---------------------------------------------------------------
| SET THE SERVER PATH
|---------------------------------------------------------------
|
| Let's attempt to determine the full-server path to the "system"
| folder in order to reduce the possibility of path problems.
| Note: We only attempt this if the user hasn't specified a
| full server path.
|
*/
if (strpos($system_folder, '/') === FALSE)
{
    if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
    {
        $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
    }
}
else
{
    // Swap directory separators to Unix style for consistency
    $system_folder = str_replace("\\", "/", $system_folder);
}

Note how it says
Quote:Note: We only attempt this if the user hasn't specified a
| full server path.

and it determines that through
Code:
if (strpos($system_folder, '/') === FALSE)

I suggest changing this to
Code:
if (strpos($system_folder, '/') !== 0)

This change makes the system only assume an absolute address if the first character is a forward slash. Eg. /apps/system = absolute, ../system = relative. Which is more correct in my opinion. Not many folks would have a problem with this but it caught me out today.
#2

[eluser]helmutbjorg[/eluser]
Interesting thing that I noticed while browsing the new bitbucket repo for the next version of codeigniter is that they have changed it. Looks like it has been resolved with a code change. The path is resolved regardless of whether or not it is absolute.

Code:
/*
* ---------------------------------------------------------------
*  Resolve the system path for increased reliability
* ---------------------------------------------------------------
*/
    if (function_exists('realpath') AND @realpath($system_path) !== FALSE)
    {
        $system_path = realpath($system_path).'/';
    }
    
    // ensure there's a trailing slash
    $system_path = rtrim($system_path, '/').'/';

    // Is the sytsem path correct?
    if ( ! is_dir($system_path))
    {
        exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);    
    }

Keep up the good work guys! Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB