prepare($sql); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); // ✅ فك التشفير للحقول الحساسة foreach ($result as &$row) { $fieldsToDecrypt = [ "phone", "email", "gender", "birthdate", "site", "first_name", "last_name", "sosPhone", "education", "employmentType", "maritalStatus", "passengerToken" ]; foreach ($fieldsToDecrypt as $field) { if (isset($row[$field]) && $row[$field] !== null) { $decrypted = $encryptionHelper->decryptData($row[$field]); if ($decrypted !== false) { $row[$field] = $decrypted; } else { // سجل أو تجاهل القيم التي فشل فك تشفيرها $row[$field] = null; // أو احتفظ بالقيمة المشفرة error_log("Failed to decrypt field '$field' for passenger ID: " . $row['id']); } } } } if ($stmt->rowCount() > 0) { jsonSuccess($data = $result); } else { jsonError("No records found"); } ?>