Update: 2026-05-03 18:12:07
This commit is contained in:
@@ -3,14 +3,24 @@
|
||||
* Simple .env Loader
|
||||
*/
|
||||
|
||||
if (file_exists(ROOT_PATH . '/.env')) {
|
||||
$lines = file(ROOT_PATH . '/.env', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
// Primary environment file path as requested
|
||||
$envFile = '/home/intaleqapp-musadaq/env/.env';
|
||||
|
||||
// Fallback for local development if the primary server path doesn't exist
|
||||
if (!file_exists($envFile)) {
|
||||
$envFile = ROOT_PATH . '/.env';
|
||||
}
|
||||
|
||||
if (file_exists($envFile)) {
|
||||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
foreach ($lines as $line) {
|
||||
if (str_starts_with(trim($line), '#')) continue;
|
||||
|
||||
list($name, $value) = explode('=', $line, 2);
|
||||
$name = trim($name);
|
||||
$value = trim($value, " \t\n\r\0\x0B\"'");
|
||||
$parts = explode('=', $line, 2);
|
||||
if (count($parts) !== 2) continue;
|
||||
|
||||
$name = trim($parts[0]);
|
||||
$value = trim($parts[1], " \t\n\r\0\x0B\"'");
|
||||
|
||||
if (!array_key_exists($name, $_SERVER) && !array_key_exists($name, $_ENV)) {
|
||||
putenv(sprintf('%s=%s', $name, $value));
|
||||
|
||||
Reference in New Issue
Block a user