From 521d76c4cf808523cfc5c6fe05a78745e4fc791e Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Wed, 22 Jul 2026 00:48:30 +0300 Subject: [PATCH] Update: 2026-07-22 00:48:30 --- backend/ride/location/save_driver_destination.php | 12 ++++++------ .../ride/notificationCaptain/getRideWaiting.php | 9 +++++++-- ride_server/passenger_socket.php | 14 +++++++++++--- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/backend/ride/location/save_driver_destination.php b/backend/ride/location/save_driver_destination.php index 260ef2a3..6e0838f3 100644 --- a/backend/ride/location/save_driver_destination.php +++ b/backend/ride/location/save_driver_destination.php @@ -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', diff --git a/backend/ride/notificationCaptain/getRideWaiting.php b/backend/ride/notificationCaptain/getRideWaiting.php index 5203d8da..0ff91638 100644 --- a/backend/ride/notificationCaptain/getRideWaiting.php +++ b/backend/ride/notificationCaptain/getRideWaiting.php @@ -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', diff --git a/ride_server/passenger_socket.php b/ride_server/passenger_socket.php index ed74e64b..0e6bf4ce 100755 --- a/ride_server/passenger_socket.php +++ b/ride_server/passenger_socket.php @@ -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)) {