$upStmt = $db->prepare("UPDATE users SET diamonds = ?, last_billed = ? WHERE user_id = ?"); $upStmt->execute([$newDiamonds, $now, $uid]); } else { // اتمام موجودی -> خاموش کردن سلف $upStmt = $db->prepare("UPDATE users SET is_active = 0 WHERE user_id = ?"); $upStmt->execute([$uid]); // Kill user process $sessDir = "/home/in8wswn/selfbot_php/session/user_{$uid}"; $lockFile = $sessDir . '/runner.lock'; if (file_exists($lockFile)) { $pid = (int) @file_get_contents($lockFile); if ($pid > 0 && function_exists('posix_kill')) { posix_kill($pid, 9); } @unlink($lockFile); } botMsg($uid, "⚠️ موجودی دایمند شما به پایان رسید!\n\nسلف‌بات شما به دلیل اتمام موجودی موقتاً خاموش شد.\nبرای فعال‌سازی دوباره، از دکمه «💎 خرید دایمند» حساب خود را شارژ کنید."); // حذف از لیست اجرای زنده $activeUsers = array_diff($activeUsers, [$uid]); } } } } } catch (\Throwable $e) { echo "[" . date('Y-m-d H:i:s') . "] DB error in supervisor: " . $e->getMessage() . "\n"; } } // 2. چک کردن و بالا آوردن سلف تمام کاربران فعال foreach ($activeUsers as $uid) { $sessDir = __DIR__ . "/session/user_{$uid}"; // الف) اگر کاربر در محدودیت زمانی Flood Wait تلگرام است، اجرا نشود $floodFile = $sessDir . '/flood_wait.txt'; if (file_exists($floodFile)) { $until = (int) @file_get_contents($floodFile); if (time() < $until) { continue; // هنوز زمان فلود ویت تمام نشده } else { @unlink($floodFile); } } // ب) بررسی فایل نشست معتبر $safeFile = $sessDir . '/selfbot.madeline/safe.php'; if (!file_exists($safeFile) || filesize($safeFile) < 5000) { if (isset($db)) { $upStmt = $db->prepare("UPDATE users SET is_active = 0 WHERE user_id = ?"); $upStmt->execute([$uid]); } continue; } $lockFile = $sessDir . '/runner.lock'; $isRunning = false; if (file_exists($lockFile)) { $fpTest = @fopen($lockFile, 'c+');