diff --git a/backend/ride/location/add_batch.php b/backend/ride/location/add_batch.php deleted file mode 100755 index 4a4d107c..00000000 --- a/backend/ride/location/add_batch.php +++ /dev/null @@ -1,129 +0,0 @@ -prepare("SELECT created_at FROM car_tracks WHERE driver_id = ? ORDER BY created_at DESC LIMIT 1"); - $stmtLast->execute([$driver_id]); - $lastRow = $stmtLast->fetch(PDO::FETCH_ASSOC); - - if ($lastRow) { - $last_db_time = strtotime($lastRow['created_at']); - $diff_from_db = $first_point_time - $last_db_time; - - // إذا كان الفرق منطقياً (أقل من 5 دقائق) وموجباً، نحسبه - if ($diff_from_db > 0 && $diff_from_db < 300) { - $batch_added_seconds += $diff_from_db; - } - } - - // ج. حساب الفروقات داخل الباتش نفسه - $prev_time = $first_point_time; - - // نحدد تاريخ هذا الباتش (لنعرف أي يوم نحدث في الجدول اليومي) - $batch_date = date('Y-m-d', $first_point_time); - - foreach ($points as $key => $point) { - if ($key === 0) continue; // تخطي النقطة الأولى لأننا قارناها مع الداتابيز - - $current_time = strtotime($point['ts']); - $diff = $current_time - $prev_time; - - // تجاهل القفزات الكبيرة (أكثر من 5 دقائق) - if ($diff > 0 && $diff < 300) { - $batch_added_seconds += $diff; - } - $prev_time = $current_time; - } - - // --------------------------------------------------------- - // الجزء الثاني: إدخال التراكات (Bulk Insert) - كودك الأصلي - // --------------------------------------------------------- - - $values = []; - $placeholders = []; - - foreach ($points as $point) { - $lat = $point['lat'] ?? 0; - $lng = $point['lng'] ?? 0; - $spd = $point['spd'] ?? 0; - $head = $point['head'] ?? 0; - $dist = $point['dst'] ?? 0; - $stat = $point['st'] ?? 'off'; - $time = $point['ts'] ?? date('Y-m-d H:i:s'); - - $placeholders[] = "(?, ?, ?, ?, ?, ?, ?, ?)"; - array_push($values, $driver_id, $lat, $lng, $head, $spd, $dist, $stat, $time); - } - - $sql = "INSERT INTO `car_tracks` - (`driver_id`, `latitude`, `longitude`, `heading`, `speed`, `distance`, `status`, `created_at`) - VALUES " . implode(', ', $placeholders); - - $stmt = $con->prepare($sql); - $ok = $stmt->execute($values); - - // --------------------------------------------------------- - // الجزء الثالث: تحديث جدول الملخص اليومي (The Smart Update) - // --------------------------------------------------------- - - if ($ok && $batch_added_seconds > 0) { - // نستخدم ON DUPLICATE KEY UPDATE: - // إذا كان السائق موجوداً لهذا اليوم، أضف الثواني للرصيد الموجود - // إذا لم يكن موجوداً، أنشئ سجلاً جديداً - - $sqlSummary = "INSERT INTO `driver_daily_summary` (`driver_id`, `date`, `total_seconds`) - VALUES (?, ?, ?) - ON DUPLICATE KEY UPDATE `total_seconds` = `total_seconds` + VALUES(`total_seconds`)"; - - $stmtSum = $con->prepare($sqlSummary); - $stmtSum->execute([$driver_id, $batch_date, $batch_added_seconds]); - } - - if ($ok) { - echo json_encode(array( - "status" => "success", - "count" => count($points), - "added_seconds" => $batch_added_seconds // للتتبع فقط - )); - } else { - printFailure("Failed to insert batch"); - } - -} catch (PDOException $e) { - error_log("Batch insert error: " . $e->getMessage()); - printFailure("Database error"); -} catch (Throwable $e) { - printFailure("Server error"); -} -?> \ No newline at end of file diff --git a/loction_server/siro/functions.php b/loction_server/siro/functions.php index 550775d0..c2b7683c 100755 --- a/loction_server/siro/functions.php +++ b/loction_server/siro/functions.php @@ -44,9 +44,12 @@ $INTERNAL_KEY = trim(file_get_contents('/home/location/.internal_socket_key')); // }); function authenticateJWT() { - $secretKey = trim(file_get_contents('/home/location/.secret_key')); // Access secret key (ensure it's set in .env) + $secretKeyFile = file_exists(__DIR__ . '/../../loction-keys/.secret_key') + ? __DIR__ . '/../../loction-keys/.secret_key' + : (file_exists('/keys/.secret_key') ? '/keys/.secret_key' : '/home/location/.secret_key'); + $secretKey = trim((string) @file_get_contents($secretKeyFile)); // Access secret key (ensure it's set in .env) if (!$secretKey) { - error_log("SECRET_KEY not set in environment variables."); + error_log("SECRET_KEY not set in environment variables. Path checked: $secretKeyFile"); http_response_code(500); // Internal Server Error echo json_encode(['error' => 'Internal server configuration error.']); exit; diff --git a/siro_driver/lib/constant/links.dart b/siro_driver/lib/constant/links.dart index cbf06547..81c49aed 100755 --- a/siro_driver/lib/constant/links.dart +++ b/siro_driver/lib/constant/links.dart @@ -50,7 +50,7 @@ class AppLink { case 'Egypt': return 'https://location-egypt.siromove.com/siro/ride/location'; case 'Jordan': - return 'https://jordan-siro.intaleqapp.com/backend/ride/location'; + return 'https://jordan-siro.intaleqapp.com/loction_server/siro/ride/location'; default: return 'https://location-jordan.siromove.com/siro/ride/location'; }