mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-10-01 01:26:10 -04:00
be more flexible with configuration paths
1. only consider CONFIG_PATH environment variable, if non-empty 2. fall back to search in PATH (defined in index.php), if CONFIG_PATH doesn't contain a readable configuration file
This commit is contained in:
parent
18972ae0fa
commit
eb10d4d35e
@ -101,10 +101,14 @@ class Configuration
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$config = array();
|
$config = $basePaths = array();
|
||||||
$basePath = (getenv('CONFIG_PATH') !== false ? getenv('CONFIG_PATH') : PATH . 'cfg') . DIRECTORY_SEPARATOR;
|
$configPath = getenv('CONFIG_PATH');
|
||||||
$configFile = $basePath . 'conf.php';
|
if ($configPath !== false && !empty($configPath)) {
|
||||||
|
$basePaths[] = $configPath;
|
||||||
|
}
|
||||||
|
$basePaths[] = PATH . 'cfg';
|
||||||
|
foreach ($basePaths as $basePath) {
|
||||||
|
$configFile = $basePath . DIRECTORY_SEPARATOR . 'conf.php';
|
||||||
if (is_readable($configFile)) {
|
if (is_readable($configFile)) {
|
||||||
$config = parse_ini_file($configFile, true);
|
$config = parse_ini_file($configFile, true);
|
||||||
foreach (array('main', 'model', 'model_options') as $section) {
|
foreach (array('main', 'model', 'model_options') as $section) {
|
||||||
@ -113,6 +117,7 @@ class Configuration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$opts = '_options';
|
$opts = '_options';
|
||||||
foreach (self::getDefaults() as $section => $values) {
|
foreach (self::getDefaults() as $section => $values) {
|
||||||
|
Loading…
Reference in New Issue
Block a user