نسخة كاملة من مستودع سيرو عند 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>
46 lines
1.7 KiB
PHP
46 lines
1.7 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../../connect.php';
|
|
|
|
$token = filterRequest("token"); // نص عادي ➜ سيتم تشفيره
|
|
$captain_id = filterRequest("captain_id"); // ID
|
|
$fingerPrint = filterRequest("fingerPrint"); // مشفّر مسبقًا من Flutter
|
|
|
|
// تشفير التوكن فقط
|
|
$tokenEncrypted = $encryptionHelper->encryptData($token);
|
|
|
|
// التحقق مما إذا كان السجل موجودًا
|
|
$sqlCheck = "SELECT * FROM `driverToken` WHERE `captain_id` = :captain_id";
|
|
$stmtCheck = $con->prepare($sqlCheck);
|
|
$stmtCheck->bindParam(':captain_id', $captain_id);
|
|
$stmtCheck->execute();
|
|
|
|
$result = $stmtCheck->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($result) {
|
|
// تحديث السجل
|
|
$sqlUpdate = "UPDATE `driverToken` SET `token` = :token, `fingerPrint` = :fingerPrint WHERE `captain_id` = :captain_id";
|
|
$stmtUpdate = $con->prepare($sqlUpdate);
|
|
$stmtUpdate->bindParam(':token', $tokenEncrypted);
|
|
$stmtUpdate->bindParam(':fingerPrint', $fingerPrint); // بدون إعادة تشفير
|
|
$stmtUpdate->bindParam(':captain_id', $captain_id);
|
|
$stmtUpdate->execute();
|
|
|
|
jsonSuccess(null, "Token updated successfully");
|
|
|
|
} else {
|
|
// إدخال سجل جديد
|
|
$sqlInsert = "INSERT INTO `driverToken` (`token`, `captain_id`, `fingerPrint`) VALUES (:token, :captain_id, :fingerPrint)";
|
|
$stmtInsert = $con->prepare($sqlInsert);
|
|
$stmtInsert->bindParam(':token', $tokenEncrypted);
|
|
$stmtInsert->bindParam(':captain_id', $captain_id);
|
|
$stmtInsert->bindParam(':fingerPrint', $fingerPrint); // بدون إعادة تشفير
|
|
$stmtInsert->execute();
|
|
|
|
if ($stmtInsert->rowCount() > 0) {
|
|
jsonSuccess(null, "Token inserted successfully");
|
|
} else {
|
|
jsonError("Failed to insert token");
|
|
}
|
|
}
|
|
?>
|