add new featurs like gamination
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
function generateUniqueCode($con, $length = 7) {
|
||||
function generateUniqueCode($con) {
|
||||
while (true) {
|
||||
$letters = substr(str_shuffle("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 4);
|
||||
$numbers = substr(str_shuffle("0123456789"), 0, 3);
|
||||
$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 = ?");
|
||||
@@ -38,7 +38,7 @@ if ($checkStmt->rowCount() > 0) {
|
||||
// تحديث الدعوة الحالية
|
||||
$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('+1 hour'));
|
||||
$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);
|
||||
@@ -59,7 +59,7 @@ if ($checkStmt->rowCount() > 0) {
|
||||
} else {
|
||||
// إنشاء دعوة جديدة
|
||||
$inviteCode = generateUniqueCode($con);
|
||||
$expirationTime = date('Y-m-d H:i:s', strtotime('+1 hour'));
|
||||
$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)";
|
||||
|
||||
Reference in New Issue
Block a user