[eluser]Pygon[/eluser]
The more I have to come back to this thing, the more annoyed I get.
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);
}
/*
|---------------------------------------------------------------
| DEFINE APPLICATION CONSTANTS
|---------------------------------------------------------------
|
| EXT - The file extension. Typically ".php"
| FCPATH - The full server path to THIS file
| SELF - The name of THIS file (typically "index.php)
| BASEPATH - The full server path to the "system" folder
| APPPATH - The full server path to the "application" folder
|
*/
define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
define('FCPATH', __FILE__);
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('BASEPATH', $system_folder.'/');
if (is_dir($application_folder))
{
define('APPPATH', $application_folder.'/');
}
else
{
if ($application_folder == '')
{
$application_folder = 'application';
}
define('APPPATH', BASEPATH.$application_folder.'/');
}
First and foremost, the APPPATH is defined as:
" APPPATH - The full server path to the "application" folder "
Unfortunately, this is untrue:
Code:
define('APPPATH', $application_folder.'/'); //relative path
and:
Code:
define('APPPATH', BASEPATH.$application_folder.'/'); //an "almost" absolute path.
Second:
There is some seriously terrible stuff going on with the setting of $system_folder, such as checking if realpath is a function (has been for a LONG time), using strpos('/') to determine if it's an "absolute" path ("./something" is not ABSOLUTE path...)
and using realpath(dirname()) (err why?)*.
Look, I'm not saying this code is terrible (I'm atleast not trying to be insulting by saying this), I'm wondering, why is this STILL like this?
I use this for real absolute paths:
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.
|
*/
$system_folder = str_replace('\\','/',realpath($system_folder));
if(!$system_folder)
{
//Try the default
$system_folder = str_replace('\\','/',realpath(__FILE__).'/system');
}
if(!is_dir($system_folder))
{
die('Invalid system folder specified. Please check your $system_folder setting.');
}
/*
|---------------------------------------------------------------
| SET THE APPLICATION PATH
|---------------------------------------------------------------
|
| Let's attempt to determine the full system path to the "application"
| folder in order to reduce the possibility of path problems.
|
*/
$application_folder = str_replace('\\','/',realpath($application_folder));
if(!$application_folder)
{
//Try the default
$application_folder = str_replace('\\','/',realpath(BASEPATH.'application'));
}
if(!is_dir($application_folder))
{
die('Invalid system folder specified. Please check your $system_folder setting.');
}
/*
|---------------------------------------------------------------
| DEFINE APPLICATION CONSTANTS
|---------------------------------------------------------------
|
| EXT - The file extension. Typically ".php"
| FCPATH - The full server path to THIS file
| SELF - The name of THIS file (typically "index.php)
| BASEPATH - The full server path to the "system" folder
| APPPATH - The full server path to the "application" folder
|
*/
define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
define('FCPATH', __FILE__);
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('BASEPATH', $system_folder.'/');
define('APPPATH',$application_folder.'/');
*inparo has pointed this out to be my error.