Update: 2026-07-22 00:48:30
This commit is contained in:
@@ -20,13 +20,13 @@ $destLng = filterRequest('destination_lng') ?? filterRequest('target_longitude'
|
|||||||
$destName = filterRequest('destination_name') ?? 'Destination';
|
$destName = filterRequest('destination_name') ?? 'Destination';
|
||||||
|
|
||||||
function notifySocketServerDestination($userId, $hasDestination, $destLat = '', $destLng = '', $destName = '') {
|
function notifySocketServerDestination($userId, $hasDestination, $destLat = '', $destLng = '', $destName = '') {
|
||||||
$url = getenv('LOCATION_SOCKET_URL');
|
$url = getenv('LOCATION_SOCKET_URL') ?: 'http://socket_driver:2021';
|
||||||
$internalKey = function_exists('getInternalSocketKey') ? getInternalSocketKey() : '';
|
if (strpos($url, 'localhost') !== false || strpos($url, '127.0.0.1') !== false) {
|
||||||
|
if (file_exists('/.dockerenv')) {
|
||||||
if (empty($url)) {
|
$url = str_replace(['localhost', '127.0.0.1'], 'socket_driver', $url);
|
||||||
error_log("[save_driver_destination] LOCATION_SOCKET_URL env variable not set");
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
$internalKey = function_exists('getInternalSocketKey') ? getInternalSocketKey() : '';
|
||||||
|
|
||||||
$postData = [
|
$postData = [
|
||||||
'action' => 'update_driver_destination',
|
'action' => 'update_driver_destination',
|
||||||
|
|||||||
@@ -21,8 +21,13 @@ $redisResultsMap = [];
|
|||||||
|
|
||||||
// 1. محاولة البحث عبر Redis
|
// 1. محاولة البحث عبر Redis
|
||||||
try {
|
try {
|
||||||
$locationServerUrl = getenv('LOCATION_SOCKET_URL');
|
$locationServerUrl = getenv('LOCATION_SOCKET_URL') ?: 'http://socket_driver:2021';
|
||||||
$INTERNAL_KEY = trim(file_get_contents(getenv('INTERNAL_SOCKET_KEY_PATH')));
|
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 = [
|
$postData = [
|
||||||
'action' => 'get_nearby_ride_ids',
|
'action' => 'get_nearby_ride_ids',
|
||||||
|
|||||||
@@ -46,13 +46,18 @@ function loadEnvironment(string $filePath): void {
|
|||||||
putenv(trim($name) . '=' . trim($value, "\"'"));
|
putenv(trim($name) . '=' . trim($value, "\"'"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
loadEnvironment(dirname(__DIR__) . '/docker/.env');
|
||||||
|
loadEnvironment(dirname(__DIR__) . '/backend/.env');
|
||||||
loadEnvironment('/home/intaleq-rides/env/.env');
|
loadEnvironment('/home/intaleq-rides/env/.env');
|
||||||
|
|
||||||
function getInternalSocketKey(): string {
|
function getInternalSocketKey(): string {
|
||||||
$key = getenv('INTERNAL_SOCKET_KEY');
|
$key = getenv('INTERNAL_SOCKET_KEY');
|
||||||
if ($key) return trim($key);
|
if ($key) return trim($key);
|
||||||
$path = getenv('INTERNAL_SOCKET_KEY_PATH') ?: '/home/intaleq-rides/.internal_socket_key';
|
$path = getenv('INTERNAL_SOCKET_KEY_PATH');
|
||||||
if (file_exists($path)) return trim((string) @file_get_contents($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 '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +68,10 @@ function getJwtSecret(): string {
|
|||||||
if ($keyPath && file_exists($keyPath)) {
|
if ($keyPath && file_exists($keyPath)) {
|
||||||
return trim(file_get_contents($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)) {
|
if (empty($INTERNAL_KEY)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user