Update: 2026-08-07 16:25:34
This commit is contained in:
@@ -2,16 +2,22 @@
|
||||
|
||||
require_once __DIR__ . '/../connect.php';
|
||||
|
||||
// Get the values from the request
|
||||
$driver_id = filterRequest("driver_id");
|
||||
$assured = filterRequest("assured"); // إذا كانت قيمة حساسة يجب تشفيرها
|
||||
$health_insurance_provider = filterRequest("health_insurance_provider"); // إذا كانت حساسة، شفرها
|
||||
// المسار القديم للتأمين الصحي. المسار الجديد (خطط، أهلية، أقساط) في
|
||||
// plans.php و subscribe.php و get.php — هذا يبقى لمن سُجّل هنا سابقاً.
|
||||
|
||||
// إذا تحتاج تشفير، فعّل التالي:
|
||||
// $assured = $encryptionHelper->encryptData($assured);
|
||||
// $health_insurance_provider = $encryptionHelper->encryptData($health_insurance_provider);
|
||||
// الهوية من الـJWT لا من الطلب. كان الملف يقرأ driver_id من المدخلات
|
||||
// بلا أي فحص، فأي حامل رمز صالح يكتب سجل تأمين باسم أي سائق.
|
||||
$driver_id = $user_id ?? '';
|
||||
if (empty($driver_id) || ($role ?? '') !== 'driver') {
|
||||
jsonError('Unauthorized', 401);
|
||||
}
|
||||
|
||||
// SQL using bind parameters
|
||||
$assured = filterRequest("assured");
|
||||
$health_insurance_provider = filterRequest("health_insurance_provider");
|
||||
|
||||
// upsert لا insert: العمود driver_id عليه مفتاح فريد، فأي حفظ ثانٍ
|
||||
// لنفس السائق كان يفشل بخرق المفتاح — والحفظ الثاني هو الحالة
|
||||
// الطبيعية (تعديل مزوّد التأمين) لا الاستثناء.
|
||||
$sql = "INSERT INTO `driver_health_assurance` (
|
||||
`driver_id`,
|
||||
`assured`,
|
||||
@@ -20,7 +26,10 @@ $sql = "INSERT INTO `driver_health_assurance` (
|
||||
:driver_id,
|
||||
:assured,
|
||||
:health_insurance_provider
|
||||
)";
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`assured` = VALUES(`assured`),
|
||||
`health_insurance_provider` = VALUES(`health_insurance_provider`)";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindParam(':driver_id', $driver_id);
|
||||
|
||||
Reference in New Issue
Block a user