Compare commits
No commits in common. "c2f0fe6793effbdb5c4cec104aaaab02c69ea0c9" and "ed0baf18d308aba654eb848515926121b406dcd2" have entirely different histories.
c2f0fe6793
...
ed0baf18d3
|
@ -1,27 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Core;
|
|
||||||
|
|
||||||
class ConfigLoader
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Load configuration array from a set of possible file locations.
|
|
||||||
*
|
|
||||||
* @param string[] $locations
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function loadConfig(array $locations): array
|
|
||||||
{
|
|
||||||
$configFile = null;
|
|
||||||
foreach ($locations as $location) {
|
|
||||||
if (file_exists($location)) {
|
|
||||||
$configFile = $location;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$configFile) {
|
|
||||||
die('Config file not found');
|
|
||||||
}
|
|
||||||
return require $configFile;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -111,16 +111,29 @@ $allowed_urls = [
|
||||||
// Let plugins filter/extend allowed_urls
|
// Let plugins filter/extend allowed_urls
|
||||||
$allowed_urls = filter_allowed_urls($allowed_urls);
|
$allowed_urls = filter_allowed_urls($allowed_urls);
|
||||||
|
|
||||||
require_once __DIR__ . '/../app/core/ConfigLoader.php';
|
// cnfig file
|
||||||
use App\Core\ConfigLoader;
|
// possible locations, in order of preference
|
||||||
|
$config_file_locations = [
|
||||||
// Load configuration
|
|
||||||
$config = ConfigLoader::loadConfig([
|
|
||||||
__DIR__ . '/../app/config/jilo-web.conf.php',
|
__DIR__ . '/../app/config/jilo-web.conf.php',
|
||||||
__DIR__ . '/../jilo-web.conf.php',
|
__DIR__ . '/../jilo-web.conf.php',
|
||||||
'/srv/jilo-web/jilo-web.conf.php',
|
'/srv/jilo-web/jilo-web.conf.php',
|
||||||
'/opt/jilo-web/jilo-web.conf.php',
|
'/opt/jilo-web/jilo-web.conf.php'
|
||||||
]);
|
];
|
||||||
|
$config_file = null;
|
||||||
|
// try to find the config file
|
||||||
|
foreach ($config_file_locations as $location) {
|
||||||
|
if (file_exists($location)) {
|
||||||
|
$config_file = $location;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if found, use it
|
||||||
|
if ($config_file) {
|
||||||
|
$localConfigPath = str_replace(__DIR__ . '/..', '', $config_file);
|
||||||
|
$config = require $config_file;
|
||||||
|
} else {
|
||||||
|
die('Config file not found');
|
||||||
|
}
|
||||||
|
|
||||||
$app_root = $config['folder'];
|
$app_root = $config['folder'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue