fix: InfinityFree 500 error (putenv safety), mobile dark toggle inside side panel

This commit is contained in:
ssbg04 committed 2026-06-05 23:21:17 +08:00
1 parent 9eeb82ed89
commit 4685a6c3a2
4 files changed
+49 -35

No files matched your search

+4 -19
View File
@@ -1,21 +1,5 @@
<?php
// Load environment variables — PHP 7.x compatible
if (!function_exists('loadEnv')) {
function loadEnv($path) {
if (!file_exists($path)) return;
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($lines === false) return;
foreach ($lines as $line) {
$line = trim($line);
if ($line === '' || $line[0] === '#') continue;
$parts = explode('=', $line, 2);
if (count($parts) < 2) continue;
$key = trim($parts[0]); $value = trim($parts[1]);
if (!array_key_exists($key, $_ENV)) { $_ENV[$key] = $value; putenv("$key=$value"); }
}
}
}
loadEnv(__DIR__ . '/.env');
// db.php loads .env and connects to MySQL
require_once __DIR__ . '/config/db.php';
require_once __DIR__ . '/controllers/SettingsController.php';
@@ -36,8 +20,9 @@ if (!$settings) {
];
}
$recaptchaSiteKey = getenv('RECAPTCHA_SITE_KEY') ?: ($_ENV['RECAPTCHA_SITE_KEY'] ?? '');
$contactEmail = getenv('CONTACT_EMAIL') ?: ($_ENV['CONTACT_EMAIL'] ?? '');
// Prefer $_ENV (always set by loadEnv), fall back to getenv()
$recaptchaSiteKey = $_ENV['RECAPTCHA_SITE_KEY'] ?? getenv('RECAPTCHA_SITE_KEY') ?? '';
$contactEmail = $_ENV['CONTACT_EMAIL'] ?? getenv('CONTACT_EMAIL') ?? '';
?>
<!DOCTYPE html>
<html lang="en">