Update: 2026-08-01 18:52:11

This commit is contained in:
Hamza-Ayed
2026-08-01 18:52:12 +03:00
parent b30fe7e96d
commit 86b5666595
6 changed files with 21 additions and 11 deletions
+2 -2
View File
@@ -100,7 +100,7 @@ try {
try { try {
// Fetch ride data from remote/local DB for server-side calculation // Fetch ride data from remote/local DB for server-side calculation
$stmtRideData = $con->prepare(" $stmtRideData = $con->prepare("
SELECT id, price AS quoted_price, car_type, SELECT id, price AS quoted_price, carType,
distance AS planned_distance, passenger_id, driver_id, price_for_driver distance AS planned_distance, passenger_id, driver_id, price_for_driver
FROM ride WHERE id = ? AND driver_id = ? FROM ride WHERE id = ? AND driver_id = ?
LIMIT 1 LIMIT 1
@@ -115,7 +115,7 @@ try {
$quotedPrice = floatval($rideData['quoted_price'] ?? 0); $quotedPrice = floatval($rideData['quoted_price'] ?? 0);
$kazanPercent = floatval($countryPricing['kazanPercent'] ?? $countryPricing['kazan'] ?? 10); // 🆕 من جدول kazan (kazanPercent هو الاسم الجديد) $kazanPercent = floatval($countryPricing['kazanPercent'] ?? $countryPricing['kazan'] ?? 10); // 🆕 من جدول kazan (kazanPercent هو الاسم الجديد)
$carType = $rideData['car_type'] ?? 'Fixed Price'; $carType = $rideData['carType'] ?? 'Fixed Price';
// 🔥 [Fix Driver Commission] عند عرض السعر (pricing/get.php) قد تُطبَّق نسبة // 🔥 [Fix Driver Commission] عند عرض السعر (pricing/get.php) قد تُطبَّق نسبة
// خصم عمولة خاصة بالمنطقة (kazanDiscountFactor من surge:kazan_discounts) // خصم عمولة خاصة بالمنطقة (kazanDiscountFactor من surge:kazan_discounts)
@@ -14,7 +14,7 @@ try {
status, status,
start_location, start_location,
end_location, end_location,
car_type AS carType, carType,
driver_id,distance, driver_id,distance,
price, price,
created_at created_at
+2 -2
View File
@@ -38,12 +38,12 @@ try {
// 🆕 Immutable Fare Lock: Save agreed fixed price in Redis // 🆕 Immutable Fare Lock: Save agreed fixed price in Redis
try { try {
$stmtRideInfo = $con->prepare("SELECT price, car_type FROM ride WHERE id = ? LIMIT 1"); $stmtRideInfo = $con->prepare("SELECT price, carType FROM ride WHERE id = ? LIMIT 1");
$stmtRideInfo->execute([$ride_id]); $stmtRideInfo->execute([$ride_id]);
$rideInfo = $stmtRideInfo->fetch(PDO::FETCH_ASSOC); $rideInfo = $stmtRideInfo->fetch(PDO::FETCH_ASSOC);
if ($rideInfo) { if ($rideInfo) {
$agreedPrice = floatval($rideInfo['price']); $agreedPrice = floatval($rideInfo['price']);
$carTypeStr = $rideInfo['car_type'] ?? 'Fixed Price'; $carTypeStr = $rideInfo['carType'] ?? 'Fixed Price';
$fixedPriceTypes = ['Speed', 'Fixed Price', 'Awfar Car']; $fixedPriceTypes = ['Speed', 'Fixed Price', 'Awfar Car'];
if (in_array($carTypeStr, $fixedPriceTypes)) { if (in_array($carTypeStr, $fixedPriceTypes)) {
global $redis; global $redis;
+2
View File
@@ -17,6 +17,8 @@ function getInternalKey(): string {
} }
function getRedisPass(): ?string { function getRedisPass(): ?string {
$envPass = getenv('REDIS_MAIN_PASSWORD') ?: ($_ENV['REDIS_MAIN_PASSWORD'] ?? (getenv('REDIS_PASSWORD') ?: ($_ENV['REDIS_PASSWORD'] ?? null)));
if ($envPass) return trim($envPass);
$path = getenv('REDIS_PASS_KEY_PATH'); $path = getenv('REDIS_PASS_KEY_PATH');
if ($path && 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/.reds_pass_key')) return trim((string)@file_get_contents('/keys/.reds_pass_key')); if (file_exists('/keys/.reds_pass_key')) return trim((string)@file_get_contents('/keys/.reds_pass_key'));
+8 -3
View File
@@ -90,19 +90,24 @@ function getJwtSecret(): string {
// Redis password: try env var, then Docker keys, then legacy path, then null (Docker Redis has no password) // Redis password: try env var, then Docker keys, then legacy path, then null (Docker Redis has no password)
$redisPass = null; $redisPass = null;
$redisPassPaths = [ $redisPassPaths = [
getenv('REDIS_PASS_KEY_PATH') ?: '', __DIR__ . '/../loction-keys/.reds_pass_key',
'/keys/.reds_pass_key', '/keys/.reds_pass_key',
'/home/location/.reds_pass_key', '/home/location/.reds_pass_key'
]; ];
foreach ($redisPassPaths as $rpp) { foreach ($redisPassPaths as $rpp) {
if (!empty($rpp) && file_exists($rpp)) { if (file_exists($rpp)) {
$redisPass = trim((string) @file_get_contents($rpp)); $redisPass = trim((string) @file_get_contents($rpp));
break; break;
} }
} }
if (empty($redisPass)) {
$redisPass = getenv('REDIS_MAIN_PASSWORD') ?: ($_ENV['REDIS_MAIN_PASSWORD'] ?? (getenv('REDIS_PASSWORD') ?: ($_ENV['REDIS_PASSWORD'] ?? null)));
}
if (empty($INTERNAL_KEY)) logMsg('⚠️ Internal key not found (non-critical in Docker)'); if (empty($INTERNAL_KEY)) logMsg('⚠️ Internal key not found (non-critical in Docker)');
if (empty($redisPass)) logMsg('ℹ️ Redis password not set (OK for Docker — no auth required)'); if (empty($redisPass)) logMsg('ℹ️ Redis password not set (OK for Docker — no auth required)');
else logMsg('✅ Redis password loaded successfully');
// ============================================================ // ============================================================
// 🗄️ Redis Singleton // 🗄️ Redis Singleton
+6 -3
View File
@@ -75,9 +75,12 @@ function getLocationRedis(): ?\Redis {
catch (\Exception $_) { $_locationRedis = null; } catch (\Exception $_) { $_locationRedis = null; }
} }
try { try {
$redisPass = ''; $redisPass = getenv('REDIS_MAIN_PASSWORD') ?: ($_ENV['REDIS_MAIN_PASSWORD'] ?? (getenv('REDIS_PASSWORD') ?: ($_ENV['REDIS_PASSWORD'] ?? null)));
foreach ([getenv('REDIS_PASS_KEY_PATH') ?: '', '/keys/.reds_pass_key', '/home/location/.reds_pass_key'] as $p) { $keys = [getenv('REDIS_PASS_KEY_PATH') ?: '', '/keys/.reds_pass_key', '/home/location/.reds_pass_key'];
if (!empty($p) && file_exists($p)) { $redisPass = trim((string)@file_get_contents($p)); break; } if (!$redisPass) {
foreach ($keys as $p) {
if (!empty($p) && file_exists($p)) { $redisPass = trim((string)@file_get_contents($p)); break; }
}
} }
$host = getenv('REDIS_HOST') ?: (file_exists('/.dockerenv') ? 'redis' : '127.0.0.1'); $host = getenv('REDIS_HOST') ?: (file_exists('/.dockerenv') ? 'redis' : '127.0.0.1');
$r = new \Redis(); $r = new \Redis();