chore: استيراد أولي من سيرو (ecfe7568) — بلا أي تعديل
نسخة كاملة من مستودع سيرو عند ecfe7568 لتكون أساس تطبيق «انطلق». نُسخ المتعقَّب في git فقط (12,509 ملفاً / 302 م.ب) بـ git archive، لا `cp -r` — فاستُثنيت تلقائياً مخلفات البناء (build · node_modules · .dart_tool · .gradle · Pods ≈ 10.7 غ.ب) وكل ما يستثنيه .gitignore. هذا الكوميت **بلا أي تعديل عمداً** حتى يكون كل ما يليه فرقاً مقروءاً مقابل سيرو الأصلي. سيرو نفسه لم يُمسّ. ⚠️ لا يبني بعد: `.env` و`lib/env/env.g.dart` غير متعقَّبين في سيرو (وهذا صحيح — أسرار لكل مستأجر). كل تطبيق فلاتر هنا يحتاج .env خاصاً بانطلق ثم توليد env.g.dart عبر build_runner. لا تُنسخ أسرار سيرو. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
$id = filterRequest("id");
|
||||
|
||||
$sql = "SELECT * FROM `passengers` WHERE `id` = :id";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($result) {
|
||||
unset($result['password']); // إخفاء الباسورد
|
||||
|
||||
// فك تشفير الحقول الحساسة
|
||||
$fieldsToDecrypt = [
|
||||
'phone', 'email', 'gender', 'birthdate', 'site',
|
||||
'first_name', 'last_name', 'sosPhone',
|
||||
'education', 'employmentType', 'maritalStatus'
|
||||
];
|
||||
|
||||
foreach ($fieldsToDecrypt as $field) {
|
||||
if (isset($result[$field])) {
|
||||
$result[$field] = $encryptionHelper->decryptData($result[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"data" => $result
|
||||
]);
|
||||
} else {
|
||||
jsonError("Failed to retrieve passenger data");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php'; // يوفر $con و $encryptionHelper
|
||||
|
||||
$id = filterRequest("id");
|
||||
|
||||
$sql = "SELECT
|
||||
d.phone,
|
||||
d.email,
|
||||
d.gender,
|
||||
d.birthdate, -- مشفّر
|
||||
d.site,
|
||||
d.first_name,
|
||||
d.last_name,
|
||||
d.accountBank,
|
||||
d.created_at AS driver_created_at,
|
||||
d.updated_at AS driver_updated_at,
|
||||
v.id AS vehicle_id,
|
||||
v.driverID,
|
||||
v.make,
|
||||
v.model,
|
||||
v.car_plate,
|
||||
v.year,
|
||||
v.expiration_date,
|
||||
v.vin,
|
||||
v.color,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
FROM ratingDriver rd
|
||||
WHERE rd.driver_id = d.id
|
||||
) AS ratingCount,
|
||||
(
|
||||
SELECT ROUND(AVG(rd.rating), 2)
|
||||
FROM ratingDriver rd
|
||||
WHERE rd.driver_id = d.id
|
||||
) AS ratingDriver
|
||||
FROM driver d
|
||||
LEFT JOIN CarRegistration v
|
||||
ON d.id = v.driverID
|
||||
WHERE d.id = :id";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$result) {
|
||||
jsonError("Failed to retrieve driver data");
|
||||
exit;
|
||||
}
|
||||
|
||||
// فك تشفير حقل birthdate أولاً لحساب العمر
|
||||
if (!empty($result['birthdate'])) {
|
||||
$result['birthdate'] = $encryptionHelper->decryptData($result['birthdate']);
|
||||
|
||||
try {
|
||||
$dob = new DateTime($result['birthdate']);
|
||||
$today = new DateTime();
|
||||
$age = $today->diff($dob)->y;
|
||||
} catch (Exception $e) {
|
||||
$age = null;
|
||||
}
|
||||
} else {
|
||||
$age = null;
|
||||
}
|
||||
$result['age'] = $age;
|
||||
|
||||
// فك تشفير بقية الحقول
|
||||
$driverFieldsToDecrypt = [
|
||||
'phone', 'email', 'gender', 'site',
|
||||
'first_name', 'last_name'
|
||||
];
|
||||
|
||||
foreach ($driverFieldsToDecrypt as $field) {
|
||||
if (!empty($result[$field])) {
|
||||
$result[$field] = $encryptionHelper->decryptData($result[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
// فك تشفير حقول السيارة
|
||||
$vehicleFieldsToDecrypt = ['vin', 'car_plate'];
|
||||
foreach ($vehicleFieldsToDecrypt as $field) {
|
||||
if (!empty($result[$field])) {
|
||||
$result[$field] = $encryptionHelper->decryptData($result[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
jsonSuccess($result);
|
||||
?>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
$id = filterRequest("id");
|
||||
|
||||
$fields = [];
|
||||
$params = [":id" => $id];
|
||||
|
||||
$encryptedFields = [
|
||||
"phone", "sosPhone", "birthdate", "site", "gender",
|
||||
"first_name", "last_name", "education", "employmentType", "maritalStatus"
|
||||
];
|
||||
|
||||
// أي تعديل على حقل مفهرس يجب أن يُحدّث فهرسه في نفس العبارة، وإلا بقي
|
||||
// الفهرس يشير إلى القيمة القديمة وأصبح البحث يعطي نتيجة خاطئة.
|
||||
global $blindIndex;
|
||||
$plain = [];
|
||||
|
||||
foreach ($encryptedFields as $field) {
|
||||
if (isset($_POST[$field]) && !empty($_POST[$field])) {
|
||||
$value = filterRequest($field);
|
||||
$plain[$field] = $value;
|
||||
$encryptedValue = $encryptionHelper->encryptData($value);
|
||||
$fields[] = "`$field` = :$field";
|
||||
$params[":$field"] = $encryptedValue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($blindIndex) {
|
||||
if (isset($plain['phone'])) {
|
||||
$fields[] = "`phone_bidx` = :phone_bidx";
|
||||
$params[':phone_bidx'] = $blindIndex->index('passengers.phone', $plain['phone']);
|
||||
}
|
||||
if (isset($plain['first_name']) || isset($plain['last_name'])) {
|
||||
// الاسم مركّب من عمودين: نقرأ الجزء غير المُعدَّل من السجل الحالي
|
||||
$current = $con->prepare("SELECT first_name, last_name FROM passengers WHERE id = :id");
|
||||
$current->execute([':id' => $id]);
|
||||
$row = $current->fetch(PDO::FETCH_ASSOC) ?: [];
|
||||
|
||||
$first = $plain['first_name'] ?? $encryptionHelper->decryptData($row['first_name'] ?? null) ?: '';
|
||||
$last = $plain['last_name'] ?? $encryptionHelper->decryptData($row['last_name'] ?? null) ?: '';
|
||||
|
||||
$fields[] = "`name_bidx` = :name_bidx";
|
||||
$params[':name_bidx'] = $blindIndex->index('passengers.name', trim("$first $last"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fields)) {
|
||||
$setClause = implode(", ", $fields);
|
||||
$sql = "UPDATE `passengers` SET $setClause WHERE `id` = :id";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
jsonSuccess(null, "Passenger data updated successfully");
|
||||
} else {
|
||||
jsonError("Failed to update passenger data");
|
||||
}
|
||||
} else {
|
||||
jsonError("No fields to update");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
$id = filterRequest("id");
|
||||
$email = filterRequest("email");
|
||||
|
||||
// التحقق من وجود البيانات
|
||||
if (empty($id) || empty($email)) {
|
||||
jsonError("Missing required parameters");
|
||||
exit;
|
||||
}
|
||||
|
||||
// تشفير الإيميل
|
||||
$encryptedEmail = $encryptionHelper->encryptData($email);
|
||||
|
||||
// تنفيذ التحديث
|
||||
$sql = "UPDATE driver SET email = :email WHERE id = :id";
|
||||
$stmt = $con->prepare($sql);
|
||||
$success = $stmt->execute([
|
||||
":email" => $encryptedEmail,
|
||||
":id" => $id
|
||||
]);
|
||||
|
||||
if ($success && $stmt->rowCount() > 0) {
|
||||
jsonSuccess(null, "Email updated successfully");
|
||||
} else {
|
||||
jsonError("Failed to update email");
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user