Files
Siro/backend/load_env.php
T

29 lines
1.1 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// ‏نفس الاسم معرّف أيضاً في core/helpers.php بتوقيع مختلف. أي ملف يُحمِّل
// ‏bootstrap.php (ومنه helpers.php) ثم يصل إلى هنا كان ينهار بـ
// ‏"Cannot redeclare loadEnvironment()" — وهو ما أسقط blacklist_manager.php.
// ‏الحارس يُبقي أول تعريف محمَّل ويتجاهل الثاني، والسلوك متوافق بينهما.
if (!function_exists('loadEnvironment')) {
function loadEnvironment($env_file) {
if (!file_exists($env_file)) {
error_log("❌ .env not found: $env_file");
return false;
}
$lines = file($env_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
$line = trim($line);
if (empty($line) || strpos($line, '#') === 0) continue;
$parts = explode('=', $line, 2);
if (count($parts) === 2) {
[$keyName, $value] = $parts;
$value = trim($value, "\"'");
putenv("$keyName=$value");
$_ENV[$keyName] = $value;
}
}
return true;
}
}