Update: 2026-07-22 00:48:30

This commit is contained in:
Hamza-Ayed
2026-07-22 00:48:30 +03:00
parent b613022169
commit 521d76c4cf
3 changed files with 24 additions and 11 deletions
@@ -20,13 +20,13 @@ $destLng = filterRequest('destination_lng') ?? filterRequest('target_longitude'
$destName = filterRequest('destination_name') ?? 'Destination';
function notifySocketServerDestination($userId, $hasDestination, $destLat = '', $destLng = '', $destName = '') {
$url = getenv('LOCATION_SOCKET_URL');
$internalKey = function_exists('getInternalSocketKey') ? getInternalSocketKey() : '';
if (empty($url)) {
error_log("[save_driver_destination] LOCATION_SOCKET_URL env variable not set");
return;
$url = getenv('LOCATION_SOCKET_URL') ?: 'http://socket_driver:2021';
if (strpos($url, 'localhost') !== false || strpos($url, '127.0.0.1') !== false) {
if (file_exists('/.dockerenv')) {
$url = str_replace(['localhost', '127.0.0.1'], 'socket_driver', $url);
}
}
$internalKey = function_exists('getInternalSocketKey') ? getInternalSocketKey() : '';
$postData = [
'action' => 'update_driver_destination',
@@ -21,8 +21,13 @@ $redisResultsMap = [];
// 1. محاولة البحث عبر Redis
try {
$locationServerUrl = getenv('LOCATION_SOCKET_URL');
$INTERNAL_KEY = trim(file_get_contents(getenv('INTERNAL_SOCKET_KEY_PATH')));
$locationServerUrl = getenv('LOCATION_SOCKET_URL') ?: 'http://socket_driver:2021';
if (strpos($locationServerUrl, 'localhost') !== false || strpos($locationServerUrl, '127.0.0.1') !== false) {
if (file_exists('/.dockerenv')) {
$locationServerUrl = str_replace(['localhost', '127.0.0.1'], 'socket_driver', $locationServerUrl);
}
}
$INTERNAL_KEY = function_exists('getInternalSocketKey') ? getInternalSocketKey() : '';
$postData = [
'action' => 'get_nearby_ride_ids',
+11 -3
View File
@@ -46,13 +46,18 @@ function loadEnvironment(string $filePath): void {
putenv(trim($name) . '=' . trim($value, "\"'"));
}
}
loadEnvironment(dirname(__DIR__) . '/docker/.env');
loadEnvironment(dirname(__DIR__) . '/backend/.env');
loadEnvironment('/home/intaleq-rides/env/.env');
function getInternalSocketKey(): string {
$key = getenv('INTERNAL_SOCKET_KEY');
if ($key) return trim($key);
$path = getenv('INTERNAL_SOCKET_KEY_PATH') ?: '/home/intaleq-rides/.internal_socket_key';
if (file_exists($path)) return trim((string) @file_get_contents($path));
$path = getenv('INTERNAL_SOCKET_KEY_PATH');
if ($path && file_exists($path)) return trim((string) @file_get_contents($path));
if (file_exists('/keys/internal_socket_key')) return trim((string) @file_get_contents('/keys/internal_socket_key'));
if (file_exists('/home/location/.internal_socket_key')) return trim((string) @file_get_contents('/home/location/.internal_socket_key'));
if (file_exists('/home/intaleq-rides/.internal_socket_key')) return trim((string) @file_get_contents('/home/intaleq-rides/.internal_socket_key'));
return '';
}
@@ -63,7 +68,10 @@ function getJwtSecret(): string {
if ($keyPath && file_exists($keyPath)) {
return trim(file_get_contents($keyPath));
}
return getenv('JWT_SECRET_KEY') ?: '';
if (file_exists('/keys/jwt_secret_key')) {
return trim(file_get_contents('/keys/jwt_secret_key'));
}
return getenv('JWT_SECRET_KEY') ?: (getenv('JWT_SECRET') ?: '');
}
if (empty($INTERNAL_KEY)) {