mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
update for setEnvironmentValue function
This commit is contained in:
@@ -210,19 +210,23 @@ if (! function_exists('setEnvironmentValue')) {
|
|||||||
|
|
||||||
if (count($values) > 0) {
|
if (count($values) > 0) {
|
||||||
foreach ($values as $envKey => $envValue) {
|
foreach ($values as $envKey => $envValue) {
|
||||||
|
|
||||||
$str .= "\n"; // In case the searched variable is in the last line without \n
|
$str .= "\n"; // In case the searched variable is in the last line without \n
|
||||||
$keyPosition = strpos($str, "{$envKey}=");
|
$keyPosition = strpos($str, "{$envKey}=");
|
||||||
$endOfLinePosition = strpos($str, "\n", $keyPosition);
|
|
||||||
$oldLine = substr($str, $keyPosition, $endOfLinePosition - $keyPosition);
|
|
||||||
|
|
||||||
// If key does not exist, add it
|
if ($keyPosition) {
|
||||||
$str = str_replace($oldLine, "{$envKey}={$envValue}", $str);
|
$endOfLinePosition = strpos($str, "\n", $keyPosition);
|
||||||
|
$oldLine = substr($str, $keyPosition, $endOfLinePosition - $keyPosition);
|
||||||
|
$str = str_replace($oldLine, "{$envKey}={$envValue}", $str);
|
||||||
|
} else {
|
||||||
|
$str .= "\n$envKey=$envValue";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$str = substr($str, 0, -1);
|
$str = substr($str, 0, -1);
|
||||||
|
|
||||||
return ! (! file_put_contents($envFile, $str));
|
return file_put_contents($envFile, $str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user