Initial commit with updated Auth and media ignored

This commit is contained in:
Hamza-Ayed
2026-04-28 13:04:27 +03:00
commit 67af97474c
477 changed files with 66444 additions and 0 deletions

89
ride/rides/update.php Executable file
View File

@@ -0,0 +1,89 @@
<?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: " . $e->getMessage());
}
?>