Improve ENV replacement

This commit is contained in:
RainLoop Team 2016-05-22 16:44:43 +03:00
parent 338f18d2af
commit 0f981a9e51
2 changed files with 19 additions and 10 deletions

View file

@ -66,15 +66,26 @@ class Application extends \RainLoop\Config\AbstractConfig
$sKey = \strtolower($sSection.'.'.$sName);
if (\in_array($sKey, $this->aReplaceEnv) && false !== strpos($mResult, '$'))
{
foreach ($_ENV as $sKey => $sValue)
{
$mResult = \str_replace('$'.$sKey, $sValue, $mResult);
}
$mResult = \preg_replace_callback('/\$([^\s]+)/', function($aMatch) {
foreach ($_SERVER as $sKey => $sValue)
{
$mResult = \str_replace('$'.$sKey, $sValue, $mResult);
}
if (!empty($aMatch[0]) && !empty($aMatch[1]))
{
if (!empty($_ENV[$aMatch[1]]))
{
return $_SERVER[$aMatch[1]];
}
if (!empty($_SERVER[$aMatch[1]]))
{
return $_SERVER[$aMatch[1]];
}
return $aMatch[0];
}
return '';
}, $mResult);
}
}