Files
Hamza-AyedandClaude Opus 5 4d8414c96b feat: استيراد كود سيرو إلى تريبز (سيرو @ecfe7568) — بلا تعديل
قرار المالك 2026-07-27: باك إند سيرو PHP هو المعتمد، وتطبيقاته المجرّبة
ميدانياً تحل محل إعادة البناء المؤرشفة. سيرو نفسه لم يُمسّ.

الخريطة:
  backend · payment_server · loction_server · ride_server ·
  passenger_server · docker · dashboard · stress_test  → الجذر
  siro_rider  → apps/rider          siro_driver  → apps/driver
  siro_admin  → dashboards/admin    siro_service → dashboards/service
  android_bot → apps/android_bot    socialBot    → apps/socialBot

نُسخ المتعقَّب في git سيرو فقط عبر `git archive` (3,198 ملفاً / ~169 م.ب)
لا `cp -r` — فاستُثنيت مخلفات البناء تلقائياً. بلا أي تعديل محتوى عمداً:
كل ما يلي يصير فرقاً مقروءاً مقابل المصدر.

لم يُستورد وسببه: siromove.com (الموقع التسويقي يبقى marketing/ في تريبز،
سيرو فيه 8 ملفات) · docs و planning (تريبز له docs/ الخاص) · deploy.sh
(ليس نشراً على سيرفر بل `git add . && git push origin --all` — فخّ في
مستودع آخر) · transit_dashboard (بانتظار قرار مصير backend-transit و
dashboards/transit-web).

⚠️ لا يبني بعد — ثلاثة نواقص متوقعة ومقصودة:
1. `.env` و `lib/env/env.g.dart` غير متعقَّبين في سيرو (أسرار لكل مستأجر):
   كل تطبيق فلاتر يحتاج .env خاصاً ثم توليد env.g.dart بـ build_runner.
2. إعدادات Firebase (9 ملفات google-services.json و GoogleService-Info.plist)
   يستبعدها .gitignore تريبز — ولكل مستأجر مشروع Firebase خاص أصلاً.
3. apps/driver في سيرو يشير إلى `../../Intaleq/packages/get` خارج المستودع →
   يجب ضمّ الحزم داخله أسوة بـ apps/rider.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 05:14:13 +03:00

89 lines
3.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
require_once __DIR__ . '/../../connect.php';
// 🚀 تسجيل بداية العملية
error_log("🚀 [update.php] Request Started to update Ride Dynamic Data.");
$id = filterRequest("id");
if (!$id) {
error_log("❌ [update.php] Missing ID.");
jsonError("Missing ID");
exit;
}
$columnValues = [];
$params = [':id' => $id];
// قائمة الحقول القابلة للتحديث
$fields = [
"start_location", "end_location", "date", "time", "endtime", "price",
"passenger_id", "driver_id", "status", "created_at", "updated_at",
"rideTimeStart", "rideTimeFinish", "price_for_driver", "driverGoToPassengerTime",
"price_for_passenger", "distance"
];
// بناء الاستعلام ديناميكياً باستخدام filterRequest
foreach ($fields as $field) {
// نتحقق من وجود المفتاح في الـ POST
if (isset($_POST[$field])) {
// نستخدم دالة الفلترة الخاصة بك
$value = filterRequest($field);
$columnValues[] = "`$field` = :$field";
$params[":$field"] = $value;
}
}
// إذا لم يتم إرسال أي حقول للتحديث
if (empty($columnValues)) {
error_log("⚠️ [update.php] No data provided in request to update.");
jsonError("No data provided for update.");
exit;
}
// تجميع جملة SQL
$setClause = implode(", ", $columnValues);
$sql = "UPDATE `ride` SET $setClause WHERE `id` = :id";
try {
// ---------------------------------------------------------
// 1. التحديث على سيرفر التتبع (Remote DB) - هو الأساس
// ---------------------------------------------------------
error_log("🔄 [update.php] Attempting to update REMOTE Tracking DB for Ride ID: $id");
$stmtRemote = $con_ride->prepare($sql);
$stmtRemote->execute($params);
$count = $stmtRemote->rowCount();
error_log("ℹ️ [update.php] Remote DB Rows Affected: $count");
// التحقق: هل نجح التحديث هناك؟
if ($count > 0) {
// ---------------------------------------------------------
// 2. التحديث على السيرفر المحلي (Local DB) للمطابقة
// ---------------------------------------------------------
error_log("🔄 [update.php] Remote success. Updating LOCAL Main DB...");
$stmtLocal = $con->prepare($sql);
$stmtLocal->execute($params);
error_log("✅ [update.php] Update successful on both servers.");
// استخدام دالة النجاح الخاصة بك
jsonSuccess(null, "Ride data updated successfully");
} else {
// لم يتم التحديث (إما البيانات نفسها لم تتغير، أو المعرف غير موجود في السيرفر البعيد)
error_log("⚠️ [update.php] Remote Update returned 0 rows (Data same or ID not found).");
// استخدام دالة الفشل (يمكنك تغيير الرسالة لتكون success إذا كنت لا تعتبر عدم تغيير البيانات خطأ)
jsonError("No changes made (Remote DB affected 0 rows). Check ID or Data.");
}
} catch (PDOException $e) {
error_log("❌ [update.php] Database Error: " . $e->getMessage());
jsonError("Database Error");
}
?>