قرار المالك 2026-07-27: باك إند سيرو PHP هو المعتمد، وتطبيقاته المجرّبة ميدانياً تحل محل إعادة البناء المؤرشفة. سيرو نفسه لم يُمسّ. الخريطة: backend · payment_server · loction_server · ride_server · passenger_server · docker · dashboard · stress_test → الجذر siro_rider → apps/rider siro_driver → apps/driver siro_admin → dashboards/admin siro_service → dashboards/service android_bot → apps/android_bot socialBot → apps/socialBot نُسخ المتعقَّب في git سيرو فقط عبر `git archive` (3,198 ملفاً / ~169 م.ب) لا `cp -r` — فاستُثنيت مخلفات البناء تلقائياً. بلا أي تعديل محتوى عمداً: كل ما يلي يصير فرقاً مقروءاً مقابل المصدر. لم يُستورد وسببه: siromove.com (الموقع التسويقي يبقى marketing/ في تريبز، سيرو فيه 8 ملفات) · docs و planning (تريبز له docs/ الخاص) · deploy.sh (ليس نشراً على سيرفر بل `git add . && git push origin --all` — فخّ في مستودع آخر) · transit_dashboard (بانتظار قرار مصير backend-transit و dashboards/transit-web). ⚠️ لا يبني بعد — ثلاثة نواقص متوقعة ومقصودة: 1. `.env` و `lib/env/env.g.dart` غير متعقَّبين في سيرو (أسرار لكل مستأجر): كل تطبيق فلاتر يحتاج .env خاصاً ثم توليد env.g.dart بـ build_runner. 2. إعدادات Firebase (9 ملفات google-services.json و GoogleService-Info.plist) يستبعدها .gitignore تريبز — ولكل مستأجر مشروع Firebase خاص أصلاً. 3. apps/driver في سيرو يشير إلى `../../Intaleq/packages/get` خارج المستودع → يجب ضمّ الحزم داخله أسوة بـ apps/rider. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
96 lines
3.7 KiB
PHP
96 lines
3.7 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../../connect.php';
|
|
|
|
function generateUniqueCode($con) {
|
|
while (true) {
|
|
$letters = substr(str_shuffle("ABCDEFGHJKLMNPQRSTUVWXYZ"), 0, 2); // Excluded I, O for clarity
|
|
$numbers = substr(str_shuffle("23456789"), 0, 3); // Excluded 0, 1 for clarity
|
|
$code = $letters . $numbers;
|
|
|
|
$stmt = $con->prepare("SELECT COUNT(*) FROM invites WHERE inviteCode = ?");
|
|
$stmt->execute([$code]);
|
|
|
|
if ($stmt->fetchColumn() == 0) {
|
|
return $code;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Force driverId from JWT — only drivers can manage invitations
|
|
if ($role !== 'driver') {
|
|
jsonError("Only drivers can create invitations");
|
|
exit;
|
|
}
|
|
$driverId = $user_id;
|
|
$inviterDriverPhone = filterRequest("inviterDriverPhone");
|
|
|
|
// 🔐 تشفير رقم الهاتف
|
|
$inviterDriverPhoneEncrypted = $encryptionHelper->encryptData($inviterDriverPhone);
|
|
|
|
// تحقق من وجود رقم الهاتف مسبقًا
|
|
$checkSql = "SELECT `id`, `inviteCode`, `isInstall` FROM `invites` WHERE `inviterDriverPhone` = :inviterDriverPhone";
|
|
$checkStmt = $con->prepare($checkSql);
|
|
$checkStmt->bindParam(':inviterDriverPhone', $inviterDriverPhoneEncrypted, PDO::PARAM_STR);
|
|
$checkStmt->execute();
|
|
|
|
if ($checkStmt->rowCount() > 0) {
|
|
$existingInvite = $checkStmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($existingInvite['isInstall'] == 1) {
|
|
jsonError($existingInvite['inviteCode']);
|
|
} else {
|
|
// تحديث الدعوة الحالية
|
|
$updateSql = "UPDATE `invites` SET `driverId` = :driverId, `expirationTime` = :expirationTime, `createdAt` = NOW() WHERE `id` = :id";
|
|
$updateStmt = $con->prepare($updateSql);
|
|
$expirationTime = date('Y-m-d H:i:s', strtotime('+24 hours'));
|
|
$updateStmt->bindParam(':driverId', $driverId, PDO::PARAM_INT);
|
|
$updateStmt->bindParam(':expirationTime', $expirationTime);
|
|
$updateStmt->bindParam(':id', $existingInvite['id'], PDO::PARAM_INT);
|
|
|
|
try {
|
|
$updateStmt->execute();
|
|
printSuccess([
|
|
"message" => "Invite updated successfully",
|
|
"inviteId" => $existingInvite['id'],
|
|
"inviteCode" => $existingInvite['inviteCode'],
|
|
"expirationTime" => $expirationTime
|
|
]);
|
|
} catch (PDOException $e) {
|
|
error_log("[invitor/add] DB Error: " . $e->getMessage());
|
|
jsonError("Database error occurred");
|
|
}
|
|
}
|
|
|
|
} else {
|
|
// إنشاء دعوة جديدة
|
|
$inviteCode = generateUniqueCode($con);
|
|
$expirationTime = date('Y-m-d H:i:s', strtotime('+24 hours'));
|
|
|
|
$sql = "INSERT INTO `invites` (`driverId`, `inviterDriverPhone`, `inviteCode`, `expirationTime`, `createdAt`, `isInstall`)
|
|
VALUES (:driverId, :inviterDriverPhone, :inviteCode, :expirationTime, NOW(), 0)";
|
|
$stmt = $con->prepare($sql);
|
|
$stmt->bindParam(':driverId', $driverId, PDO::PARAM_INT);
|
|
$stmt->bindParam(':inviterDriverPhone', $inviterDriverPhoneEncrypted, PDO::PARAM_STR);
|
|
$stmt->bindParam(':inviteCode', $inviteCode);
|
|
$stmt->bindParam(':expirationTime', $expirationTime);
|
|
|
|
try {
|
|
$stmt->execute();
|
|
if ($stmt->rowCount() > 0) {
|
|
$insertedID = $con->lastInsertId();
|
|
printSuccess([
|
|
"message" => "Invite created successfully",
|
|
"inviteId" => $insertedID,
|
|
"inviteCode" => $inviteCode,
|
|
"expirationTime" => $expirationTime
|
|
]);
|
|
} else {
|
|
jsonError("Failed to save invite data");
|
|
}
|
|
} catch (PDOException $e) {
|
|
error_log("[invitor/add] DB Error: " . $e->getMessage());
|
|
jsonError("Database error occurred");
|
|
}
|
|
}
|
|
?>
|