Reorder project path and project root defines (#6787)

* reorder the project_root and project_path define so isset is called
before the config key project.root is used

* ensure project path begins with a '/'

* rewrite for empty string in project_path

* Update require.php
This commit is contained in:
frytimo 2023-10-17 00:54:56 -03:00 committed by GitHub
parent dd1ba159ab
commit 77e4bb9865
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 16 deletions

View File

@ -40,11 +40,8 @@
}
}
//check if the config file exists
$config_exists = !empty($config_file) ? true : false;
//config.conf file not found re-direct the request to the install
if (!$config_exists) {
if (empty($config_file)) {
header("Location: /core/install/install.php");
exit;
}
@ -55,19 +52,26 @@
//set the include path
set_include_path($conf['document.root']);
//set the server variables and define project path constant
$_SERVER["DOCUMENT_ROOT"] = $conf['document.root'];
$_SERVER["PROJECT_ROOT"] = $conf['document.root'];
$_SERVER["PROJECT_PATH"] = $conf['project.path'];
if (isset($conf['project.path'])) {
$_SERVER["PROJECT_ROOT"] = $conf['document.root'].'/'.$conf['project.path'];
if (!defined('PROJECT_ROOT')) { define("PROJECT_ROOT", $conf['document.root'].'/'.$conf['project.path']); }
if (!defined('PROJECT_PATH')) { define("PROJECT_PATH", $conf['project.path']); }
}
else {
if (!defined('PROJECT_ROOT')) { define("PROJECT_ROOT", $conf['document.root']); }
if (!defined('PROJECT_PATH')) { define("PROJECT_PATH", ''); }
//set document root
$_SERVER["DOCUMENT_ROOT"] = substr($conf['document.root'], -1) === '/' ? substr($conf['document.root'], 0, -1) : $conf['document.root'];
//set project path
if (isset($conf['project.path']) && !defined('PROJECT_PATH')) {
if (substr($conf['project.path'], 0, 1) === '/') {
define("PROJECT_PATH", $conf['project.path']);
} else {
if (!empty($conf['project.path'])) {
define("PROJECT_PATH", '/' . $conf['project.path']);
} else {
define("PROJECT_PATH", '');
}
}
}
$_SERVER["PROJECT_PATH"] = PROJECT_PATH;
//set project root using project path
if (!defined('PROJECT_ROOT')) { define("PROJECT_ROOT", $conf['document.root'] . PROJECT_PATH); }
$_SERVER["PROJECT_ROOT"] = PROJECT_ROOT;
//set the error reporting
ini_set('display_errors', '1');