mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-03-22 13:10:41 +08:00
simplify logic, fullfills the unit test
This commit is contained in:
parent
07a6e3094d
commit
0efe6f7a8e
|
@ -102,29 +102,10 @@ class Configuration
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$config = array();
|
$config = array();
|
||||||
$basePath = PATH . 'cfg' . DIRECTORY_SEPARATOR;
|
$basePath = (getenv('CONFIG_PATH') !== false ? getenv('CONFIG_PATH') : PATH . 'cfg') . DIRECTORY_SEPARATOR;
|
||||||
$configIni = $basePath . 'conf.ini';
|
$configIni = $basePath . 'conf.ini';
|
||||||
$configFile = $basePath . 'conf.php';
|
$configFile = $basePath . 'conf.php';
|
||||||
|
|
||||||
if (getenv('CONFIG_PATH') !== false) {
|
|
||||||
$configFile = getenv('CONFIG_PATH');
|
|
||||||
$configFilePhp = substr($configFile, 0, -3) . 'php';
|
|
||||||
|
|
||||||
// Rename INI files to avoid configuration leakage
|
|
||||||
if (
|
|
||||||
strtolower(substr($configFile, -3, 3)) == 'ini' &&
|
|
||||||
is_readable($configFile) &&
|
|
||||||
is_writable(dirname($configFile))
|
|
||||||
) {
|
|
||||||
DataStore::prependRename($configFile, $configFilePhp, ';');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rename successful? Already renamed? use that file
|
|
||||||
if (is_readable($configFilePhp)) {
|
|
||||||
$configFile = $configFilePhp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rename INI files to avoid configuration leakage
|
// rename INI files to avoid configuration leakage
|
||||||
if (is_readable($configIni)) {
|
if (is_readable($configIni)) {
|
||||||
DataStore::prependRename($configIni, $configFile, ';');
|
DataStore::prependRename($configIni, $configFile, ';');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user