Update: 2026-06-23 15:35:14
This commit is contained in:
@@ -57,9 +57,45 @@ if ($vendorPath) require_once $vendorPath;
|
|||||||
require_once __DIR__ . '/helpers.php';
|
require_once __DIR__ . '/helpers.php';
|
||||||
|
|
||||||
// تحديد مسار الـ .env بشكل ديناميكي
|
// تحديد مسار الـ .env بشكل ديناميكي
|
||||||
$envFile = getenv('ENV_FILE_PATH') ?: (__DIR__ . '/../.env');
|
$siteUser = get_current_user();
|
||||||
|
$homeDir = "/home/$siteUser";
|
||||||
|
if (!is_dir($homeDir)) {
|
||||||
|
$homeDir = realpath(__DIR__ . '/../../../'); // Fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
$envFile = getenv('ENV_FILE_PATH') ?: ($homeDir . '/.env');
|
||||||
|
if (!file_exists($envFile)) {
|
||||||
|
$envFile = __DIR__ . '/../.env';
|
||||||
|
}
|
||||||
loadEnvironment($envFile);
|
loadEnvironment($envFile);
|
||||||
|
|
||||||
|
// تعيين مسارات المفاتيح تلقائياً إذا لم تكن معرفة في الـ .env
|
||||||
|
if (!getenv('ENCRYPTION_KEY_PATH')) {
|
||||||
|
$encKeyDefault = "$homeDir/.enckey";
|
||||||
|
putenv("ENCRYPTION_KEY_PATH=$encKeyDefault");
|
||||||
|
$_ENV['ENCRYPTION_KEY_PATH'] = $encKeyDefault;
|
||||||
|
}
|
||||||
|
if (!getenv('SECRET_KEY_PATH')) {
|
||||||
|
$secKeyDefault = "$homeDir/.secret_key";
|
||||||
|
putenv("SECRET_KEY_PATH=$secKeyDefault");
|
||||||
|
$_ENV['SECRET_KEY_PATH'] = $secKeyDefault;
|
||||||
|
}
|
||||||
|
if (!getenv('SECRET_KEY_PAY_PATH')) {
|
||||||
|
$secPayKeyDefault = "$homeDir/.secret_key_pay";
|
||||||
|
putenv("SECRET_KEY_PAY_PATH=$secPayKeyDefault");
|
||||||
|
$_ENV['SECRET_KEY_PAY_PATH'] = $secPayKeyDefault;
|
||||||
|
}
|
||||||
|
if (!getenv('INTERNAL_SOCKET_KEY_PATH')) {
|
||||||
|
$sockKeyDefault = "$homeDir/.internal_socket_key";
|
||||||
|
putenv("INTERNAL_SOCKET_KEY_PATH=$sockKeyDefault");
|
||||||
|
$_ENV['INTERNAL_SOCKET_KEY_PATH'] = $sockKeyDefault;
|
||||||
|
}
|
||||||
|
if (!getenv('SERVICE_ACCOUNT_FILE_PATH')) {
|
||||||
|
$svcAcctDefault = "$homeDir/service-account.json";
|
||||||
|
putenv("SERVICE_ACCOUNT_FILE_PATH=$svcAcctDefault");
|
||||||
|
$_ENV['SERVICE_ACCOUNT_FILE_PATH'] = $svcAcctDefault;
|
||||||
|
}
|
||||||
|
|
||||||
// 4. Redis Connections (Dual Architecture)
|
// 4. Redis Connections (Dual Architecture)
|
||||||
$redis = null;
|
$redis = null;
|
||||||
$redisLocation = null;
|
$redisLocation = null;
|
||||||
|
|||||||
@@ -53,13 +53,19 @@ function loadEnvironment(string $filePath): void {
|
|||||||
logMsg('✅ Environment loaded.');
|
logMsg('✅ Environment loaded.');
|
||||||
}
|
}
|
||||||
|
|
||||||
loadEnvironment('/home/location/env/.env');
|
$siteUser = get_current_user();
|
||||||
|
$homeDir = "/home/$siteUser";
|
||||||
|
if (!is_dir($homeDir)) {
|
||||||
|
$homeDir = '/home/location'; // Fallback to original location
|
||||||
|
}
|
||||||
|
|
||||||
|
loadEnvironment(getenv('ENV_FILE_PATH') ?: ($homeDir . '/.env'));
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// 🔐 مفاتيح الأمان
|
// 🔐 مفاتيح الأمان
|
||||||
// ============================================================
|
// ============================================================
|
||||||
$INTERNAL_KEY = trim((string) @file_get_contents('/home/location/.internal_socket_key'));
|
$INTERNAL_KEY = trim((string) @file_get_contents(getenv('INTERNAL_SOCKET_KEY_PATH') ?: ($homeDir . '/.internal_socket_key')));
|
||||||
$redisPass = trim((string) @file_get_contents('/home/location/.reds_pass_key'));
|
$redisPass = trim((string) @file_get_contents(getenv('REDIS_PASS_KEY_PATH') ?: ($homeDir . '/.reds_pass_key')));
|
||||||
|
|
||||||
if (empty($INTERNAL_KEY)) logMsg('❌ CRITICAL: Internal key missing!');
|
if (empty($INTERNAL_KEY)) logMsg('❌ CRITICAL: Internal key missing!');
|
||||||
if (empty($redisPass)) logMsg('❌ CRITICAL: Redis password missing!');
|
if (empty($redisPass)) logMsg('❌ CRITICAL: Redis password missing!');
|
||||||
|
|||||||
@@ -4,9 +4,24 @@
|
|||||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||||
|
|
||||||
require_once 'load_env.php';
|
require_once 'load_env.php';
|
||||||
$env_file = getenv('ENV_FILE_PATH') ?: (__DIR__ . '/../../../env/.env');
|
$siteUser = get_current_user();
|
||||||
|
$homeDir = "/home/$siteUser";
|
||||||
|
if (!is_dir($homeDir)) {
|
||||||
|
$homeDir = realpath(__DIR__ . '/../../../'); // Fallback
|
||||||
|
}
|
||||||
|
|
||||||
|
$env_file = getenv('ENV_FILE_PATH') ?: ($homeDir . '/.env');
|
||||||
|
if (!file_exists($env_file)) {
|
||||||
|
$env_file = __DIR__ . '/../.env';
|
||||||
|
}
|
||||||
loadEnvironment($env_file);
|
loadEnvironment($env_file);
|
||||||
|
|
||||||
|
if (!getenv('ENCRYPTION_KEY_PATH')) {
|
||||||
|
$encKeyDefault = "$homeDir/.enckey";
|
||||||
|
putenv("ENCRYPTION_KEY_PATH=$encKeyDefault");
|
||||||
|
$_ENV['ENCRYPTION_KEY_PATH'] = $encKeyDefault;
|
||||||
|
}
|
||||||
|
|
||||||
// ✅ FIX C-02: استخدام getenv بدلاً من file_get_contents الثابت
|
// ✅ FIX C-02: استخدام getenv بدلاً من file_get_contents الثابت
|
||||||
$keyPath = getenv('ENCRYPTION_KEY_PATH');
|
$keyPath = getenv('ENCRYPTION_KEY_PATH');
|
||||||
$key = '';
|
$key = '';
|
||||||
|
|||||||
@@ -33,7 +33,13 @@ function socket_log($message, $data = null) {
|
|||||||
|
|
||||||
socket_log("=== STARTING PASSENGER SOCKET SERVER ===");
|
socket_log("=== STARTING PASSENGER SOCKET SERVER ===");
|
||||||
|
|
||||||
$INTERNAL_KEY = trim((string) @file_get_contents('/home/intaleq-rides/.internal_socket_key'));
|
$siteUser = get_current_user();
|
||||||
|
$homeDir = "/home/$siteUser";
|
||||||
|
if (!is_dir($homeDir)) {
|
||||||
|
$homeDir = '/home/intaleq-rides'; // Fallback to original location
|
||||||
|
}
|
||||||
|
|
||||||
|
$INTERNAL_KEY = trim((string) @file_get_contents(getenv('INTERNAL_SOCKET_KEY_PATH') ?: ($homeDir . '/.internal_socket_key')));
|
||||||
|
|
||||||
if (empty($INTERNAL_KEY)) {
|
if (empty($INTERNAL_KEY)) {
|
||||||
socket_log("[CRITICAL_ERROR] Internal key missing! Exiting.");
|
socket_log("[CRITICAL_ERROR] Internal key missing! Exiting.");
|
||||||
|
|||||||
Reference in New Issue
Block a user