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,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");
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user