=== LOGIN FLOW (1340-1480) === deleteUserSession($userId); $mp = getUserMadeline($userId); $mp->phoneLogin($phone); $user['step'] = 'awaiting_code'; saveUser($user); $codePrompt = "کد ارسال شده توسط تلگرام را با فرمت زیر ارسال نمایید:\n
x x x x"; $kb = [ 'inline_keyboard' => [ [['text' => '🔙 انصراف و بازگشت به منو', 'callback_data' => 'menu:main']] ] ]; sendMessage($chatId, $codePrompt, $kb); } catch (\Throwable $e) { $err = $e->getMessage(); if (str_contains($err, 'FLOOD_WAIT')) { sendMessage($chatId, "⚠️ تلگرام ارسال کد را موقتاً محدود کرده است. لطفاً کمی بعد تلاش کنید. خطا: {$err}", getMainMenu($userId)); } else { sendMessage($chatId, "⚠️ خطا در ارسال کد از طرف تلگرام:
{$err}
لطفاً شماره را بررسی و مجدداً تلاش کنید.", getMainMenu($userId));
}
$user['step'] = null;
saveUser($user);
}
exit;
}
// دریافت کد تایید تلگرام
if (($user['step'] ?? '') === 'awaiting_code') {
$cleanCode = preg_replace('/[^0-9]/', '', $text);
if (strlen($cleanCode) < 4) {
$kb = [
'inline_keyboard' => [
[['text' => '🔙 انصراف و بازگشت', 'callback_data' => 'menu:main']]
]
];
sendMessage($chatId, "⚠️ لطفاً کد ارسال شده توسط تلگرام را با فرمت زیر ارسال نمایید:\nx x x x", $kb); exit; } try { $mp = getUserMadeline($userId); $res = $mp->completePhoneLogin($cleanCode); // بررسی آیا رمز دومرحلهای (2FA) فعال است if (is_array($res) && ($res['_'] ?? '') === 'account.password') { $user['step'] = 'awaiting_2fa'; saveUser($user); $kb = [ 'inline_keyboard' => [ [['text' => '🔙 انصراف و بازگشت', 'callback_data' => 'menu:main']] ] ]; sendMessage($chatId, "🔐 تایید هویت دو مرحلهای (2FA): اکانت شما دارای رمز عبور ابری (Cloud Password) است. === ACTIVATE/DEACTIVATE (lines 140-200) === ':referral_count' => $u['referral_count'] ?? 0, ]); } // ساخت انتیتی MadelineProto برای یک کاربر // توابع مدیریت نشست و پروسس کاربر function isUserSessionLoggedIn(int $userId): bool { $sessDir = "/home/in8wswn/selfbot_php/session/user_{$userId}"; $safeFile = $sessDir . '/selfbot.madeline/safe.php'; if (file_exists($safeFile) && filesize($safeFile) > 50000) { return true; } return false; } function stopUserRunner(int $userId): void { $sessDir = "/home/in8wswn/selfbot_php/session/user_{$userId}"; $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); } @unlink($sessDir . '/cron_runner.lock'); @unlink($sessDir . '/selfbot.madeline/lock'); foreach ((array) glob($sessDir . '/selfbot.madeline/*.lock') as $l) { @unlink($l); } if (function_exists('posix_kill')) { $pids = (array) glob('/proc/[0-9]*'); foreach ($pids as $p) { $pid = (int) basename($p); if ($pid === getmypid()) continue; $cmd = @file_get_contents($p . '/cmdline'); if ($cmd && strpos($cmd, 'run_user.php') !== false && strpos($cmd, (string)$userId) !== false) { @posix_kill($pid, 9); } } } } function triggerUserRunner(int $userId): void { $cmd = "/opt/cpanel/ea-php83/root/usr/bin/php -q /home/in8wswn/selfbot_php/run_user.php {$userId} >> /home/in8wswn/selfbot_php/cron.log 2>&1 &"; $desc = [ 0 => ['pipe', 'r'], 1 => ['file', '/dev/null', 'w'], 2 => ['file', '/dev/null', 'w'] ]; $proc = @proc_open($cmd, $desc, $pipes); if (is_resource($proc)) { @proc_close($proc); } } function deleteUserSession(int $userId): void { stopUserRunner($userId); $sessDir = "/home/in8wswn/selfbot_php/session/user_{$userId}";