
<?php
ob_start();
error_reporting(0);
//BOT CONFIG
//▪▪▪▪▪▪▪▪▪▪▪▪//
$token = "8428714051:AAGtWa0_gSYnsihUfzEJ_Qhdht2Z0mnaXfc";
$apinumberland="numberland";
$apicalino="5406269799:phIm7kfvaNFsk51jaWgAjLTMsxr8a70fnv1Fw0fFfDef";
//DATABASE CONFIG
$servername = "localhost";

$username = "daykfs_number"; 

$password = "JB8O4knZYy9waVNS"; 

$dbname = "daykfs_number";
$connect = mysqli_connect($servername, $username, $password, $dbname);
    $connect->set_charset("utf8mb4");
define ('API_KEY',$token);
//------------------------------------------------------------------------------
function bot($method,$datas=[]){ // فانکشن اصلی ربات
    $url = "https://api.telegram.org/bot".API_KEY."/".$method;
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLOPT_POSTFIELDS,$datas);
    $res = curl_exec($ch);
    if(curl_error($ch)){
        var_dump(curl_error($ch));
    }else{
        return json_decode($res,true);
    }
}function deleteMessage($chatid,$msgid){ //فانکشن ارسال پیام
	return bot('deleteMessage',[
	'chat_id'=>$chatid,
	'message_id'=>$msgid,
	]);
	}
//▪▪▪▪▪▪▪▪▪▪▪▪//
function SendMessage($chatid,$text,$keyboard=null,$pars='html'){ //فانکشن ارسال پیام
	return bot('sendMessage',[
	'chat_id'=>$chatid,
	'text'=>$text,
	'reply_markup'=>$keyboard,
	'parse_mode'=>$pars,
	'disable_web_page_preview'=>true 
	]);
	}
	function editMessageText($chat_id, $message_id, $text, $keyboard = null, $pars = 'html') {
    return bot('editMessageText', [
        'chat_id' => $chat_id,
        'message_id' => $message_id,
        'text' => $text,
        'reply_markup' => $keyboard,
        'parse_mode' => $pars,
        'disable_web_page_preview' => true
    ]);
}
	function editMessageCaption($chat_id, $message_id, $text, $keyboard = null, $pars = 'html') {
    return bot('editMessageCaption', [
        'chat_id' => $chat_id,
        'message_id' => $message_id,
        'caption' => $text,
        'reply_markup' => $keyboard,
        'parse_mode' => $pars,
        'disable_web_page_preview' => true
    ]);
}
function updateVlessLink(string $originalLink, string $newUuid, string $newRemark): string {
    // حذف vless:// از اول لینک
    $linkWithoutScheme = substr($originalLink, 8); // حذف vless://

    // جدا کردن بخش‌های اصلی: [uuid@host:port]?[params]#[remark]
    $parts = explode('#', $linkWithoutScheme, 2);
    $beforeHash = $parts[0];
    $oldRemark = $parts[1] ?? '';

    // حالا uuid رو جدا کنیم: uuid@host:port
    $atParts = explode('@', $beforeHash, 2);
    if (count($atParts) < 2) {
        return "لینک نامعتبر است.";
    }

    $newBeforeHash = $newUuid . '@' . $atParts[1];

    // لینک نهایی رو دوباره می‌سازیم
    $updatedLink = 'vless://' . $newBeforeHash . '#' . urlencode($newRemark);

    return $updatedLink;
}

//▪▪▪▪▪▪▪▪▪▪▪▪//
function ForwardMessage($chatid,$from_chat,$message_id){ //فانکشن فروارد پیام
	bot('ForwardMessage',[
	'chat_id'=>$chatid,
	'from_chat_id'=>$from_chat,
	'message_id'=>$message_id
	]);
	}
//▪▪▪▪▪▪▪▪▪▪▪▪//
function SendPhoto($chat_id, $photo, $caption = null, $reply_markup = null){ // فانکشن ارسال عکس
	bot('SendPhoto',[
	'chat_id'=>$chat_id,
	'photo'=>$photo,
	'caption'=>$caption,
	'reply_markup'=>$reply_markup
	]);
	}function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}
function getsv($url){
    $curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
return $response;
}
	//▪▪▪▪▪▪▪▪▪▪▪▪//
function gen_uuid() {
    return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
        // 32 bits for "time_low"
        mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),

        // 16 bits for "time_mid"
        mt_rand( 0, 0xffff ),

        // 16 bits for "time_hi_and_version",
        // four most significant bits holds version number 4
        mt_rand( 0, 0x0fff ) | 0x4000,

        // 16 bits, 8 bits for "clk_seq_hi_res",
        // 8 bits for "clk_seq_low",
        // two most significant bits holds zero and one for variant DCE1.1
        mt_rand( 0, 0x3fff ) | 0x8000,

        // 48 bits for "node"
        mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
    );
}


//-----------------------------------------------------------------------------
$update = json_decode(file_get_contents('php://input'));
$update2 = json_decode(file_get_contents('php://input'),true);
$message = $update->message;
$from_id = $message->from->id;
$chat_id = $message->chat->id;
$membercall = $update->callback_query->id;
$message_id = $message->message_id;
$name = $message->from->first_name;
$naeme2 = $update->callback_query->from->first_name;
$last_name = $message->from->last_name;
$username = $message->from->username;
$tc = $message->chat->type;
$contact = $update->message->contact;
$text = $message->text;
$caption = $message->caption;
$forward_chat_username = $update->message->forward_from_chat->username;
$chatid = $update->callback_query->message->chat->id;
$data = $update->callback_query->data;
$messageid = $update->callback_query->message->message_id;
$fromid = $update->inline_query->from->id;
$inline_query = $update->inline_query;
$queryid = $inline_query->id;
$messup = $update->message->message_id;
$rpto = $update->message->reply_to_message->forward_from->id;
if(isset($update2['message']['photo'])){
$photoid = $update2['message']['photo'][count($update2['message']['photo'])-1]['file_id'];
}
$contact = $message->contact;
$contactid = $contact->user_id;
$contactnum = $contact->phone_number;
$user = mysqli_fetch_assoc(mysqli_query($connect,"SELECT * FROM user WHERE id = '$from_id' LIMIT 1"));
$user2 = mysqli_fetch_assoc(mysqli_query($connect,"SELECT * FROM user WHERE id = '$chatid' LIMIT 1"));
	function join1($chat){
     $truechannel = json_decode(file_get_contents("https://api.telegram.org/bot".API_KEY."/getChatMember?chat_id=@netify_vip&user_id=".$chat));
     $tch = $truechannel->result->status;
     if($tch != 'creator' && $tch != '5406269799' && $tch != 'member'){}else{ return true;}
}
$channelink="https://t.me/idchannel";
$services = [
    '💎 تلگرام - پنل اختصاصی' => [
        'text' => 'تلگرام',
        'callback' => 'checknumber_telegram',
        'icon_custom_emoji_id' => '5933924170453749947'
    ],
    'whatsapp' => [
        'text' => 'واتساپ',
        'callback' => 'checknumber_whatsapp',
        'icon_custom_emoji_id' => '5935973359480213803'
    ],
    'instagram' => [
        'text' => 'اینستاگرام',
        'callback' => 'checknumber_instagram',
        'icon_custom_emoji_id' => '5935998223045889696'
    ],
    'google' => [
        'text' => 'گوگل',
        'callback' => 'checknumber_google',
        'icon_custom_emoji_id' => '5172411981948257819'
    ],
    'facebook' => [
        'text' => 'فیسبوک',
        'callback' => 'checknumber_facebook',
        'icon_custom_emoji_id' => '5972069063499714633'
    ],
    'imo' => [
        'text' => 'ایمو',
        'callback' => 'checknumber_imo',
        'icon_custom_emoji_id' => '5798847333030436063'
    ],
    'wechat' => [
        'text' => 'وی‌چت',
        'callback' => 'checknumber_wechat',
        'icon_custom_emoji_id' => '5798732726123109920'
    ],
    'twitter' => [
        'text' => 'ایکس',
        'callback' => 'checknumber_twitter',
        'icon_custom_emoji_id' => '5935996655382827633'
    ],
    'tiktok' => [
        'text' => 'تیک تاک',
        'callback' => 'checknumber_tiktok',
        'icon_custom_emoji_id' => '5170196405888746564'
    ],
    'likee' => [
        'text' => 'لایکی',
        'callback' => 'checknumber_likee',
        'icon_custom_emoji_id' => '4904490590583915726'
    ],
    'tinder' => [
        'text' => 'تیندر',
        'callback' => 'checknumber_tinder',
        'icon_custom_emoji_id' => '5801047271114022712'
    ],
    'signal' => [
        'text' => 'سینگال',
        'callback' => 'checknumber_signal',
        'icon_custom_emoji_id' => '5798390773711903802'
    ],
    'yahoo' => [
        'text' => 'یاهو',
        'callback' => 'checknumber_yahoo',
        'icon_custom_emoji_id' => '4904952819259278041'
    ],
    'webmoney' => [
        'text' => 'وبمانی',
        'callback' => 'checknumber_webmoney',
        'icon_custom_emoji_id' => '5801185191103831266'
    ],
    'chatgpt' => [
        'text' => 'چت جی پی تی',
        'callback' => 'checknumber_chatgpt',
        'icon_custom_emoji_id' => '5172418755111682918'
    ],
    'steam' => [
        'text' => 'استیم',
        'callback' => 'checknumber_steam',
        'icon_custom_emoji_id' => '5172794328526882122'
    ],
    'paypal' => [
        'text' => 'پیپال',
        'callback' => 'checknumber_paypal',
        'icon_custom_emoji_id' => '5172783303345833009'
    ],
    'netflix' => [
        'text' => 'نتفیلیکس',
        'callback' => 'checknumber_netflix',
        'icon_custom_emoji_id' => '5936178658916964051'
    ],
    'uber' => [
        'text' => 'اوبر',
        'callback' => 'checknumber_uber',
        'icon_custom_emoji_id' => '5798791300887094771'
    ],
    'line' => [
        'text' => 'لاین',
        'callback' => 'checknumber_line',
        'icon_custom_emoji_id' => '4904936433959044521'
    ],
    'microsoft' => [
        'text' => 'ماکروسافت',
        'callback' => 'checknumber_microsoft',
        'icon_custom_emoji_id' => '5170575204824384531'
    ],
    'discord' => [
        'text' => 'دیسکورد',
        'callback' => 'checknumber_discord',
        'icon_custom_emoji_id' => '4904863844716774415'
    ],
    'amazon' => [
        'text' => 'آمازون',
        'callback' => 'checknumber_amazon',
        'icon_custom_emoji_id' => '4902401149123953709'
    ],
    'alibaba' => [
        'text' => 'علی بابا',
        'callback' => 'checknumber_alibaba',
        'icon_custom_emoji_id' => '5170241872412542749'
    ],
    'ebay' => [
        'text' => 'ای‌بای',
        'callback' => 'checknumber_ebay',
        'icon_custom_emoji_id' => '4902481645401015245'
    ],
    'apple' => [
        'text' => 'اپل',
        'callback' => 'checknumber_apple',
        'icon_custom_emoji_id' => '5172427022923728363'
    ],
    'aliexpress' => [
        'text' => 'اکسپرس',
        'callback' => 'checknumber_aliexpress',
        'icon_custom_emoji_id' => '5172874047414862844'
    ],
    'Reddit' => [
        'text' => 'ردیت',
        'callback' => 'checknumber_Reddit',
        'icon_custom_emoji_id' => '4904611665711989601'
    ],
    'canva' => [
        'text' => 'کنوا',
        'callback' => 'checknumber_canva',
        'icon_custom_emoji_id' => '5172496068817978600'
    ]
];
$services2 = [
    "telegram" => "1",
    "whatsapp" => "3",
    "instagram" => "2",
    "google" => "6",
    "facebook" => "7",
    "imo" => "18",
    "wechat" => "5",
    "twitter" => "8",
    "tiktok" => "33",
    "likee" => "60",
    "tinder" => "17",
    "signal" => "45",
    "yahoo" => "11",
    "webmoney" => "19",
    "chatgpt" => "72",
    "steam" => "24",
    "paypal" => "15",
    "netflix" => "23",
    "uber" => "147",
    "line" => "10",
    "microsoft" => "9",
    "discord" => "25",
    "amazon" => "21",
    "alibaba" => "41",
    "ebay" => "51",
    "apple" => "26",
    "aliexpress" => "46",
    "Reddit" => "105",
    "canva" => "134"
];
$countries = [
    
    "ایران 🇮🇷"=>"98",
    "بنگلادش 🇧🇩" => "880",
    "آمریکا 🇺🇸" => "1",
    "نیجریه 🇳🇬" => "234",
    "پاکستان 🇵🇰" => "92",
    "هند 🇮🇳" => "91",
    "آنگولا 🇦🇴" => "244",
    "زامبیا 🇿🇲" => "260",
    "الجزایر 🇩🇿" => "213",
    "زیمبابوه 🇿🇼" => "263",
    "غنا 🇬🇭" => "233",
    "فیلیپین 🇵🇭" => "63",
    "تونس 🇹🇳" => "216",
    "موزامبیک 🇲🇿" => "258",
    "مصر 🇪🇬" => "20",
    "مالزی 🇲🇾" => "60",
    "افغانستان 🇦🇫" => "93",
    "آرژانتین 🇦🇷" => "54",
    "ازبکستان 🇺🇿" => "998",
    "لهستان 🇵🇱" => "48",
    "سریلانکا 🇱🇰" => "94",
    "🇾🇪 یمن" => "967",
    "سوازیلند 🇸🇿" => "268",
    "نپال🇳🇵" => "977",
    "تانزانیا 🇹🇿" => "255",
    "فیجی 🇫🇯" => "679",
    "نامیبیا 🇳🇦" => "264",
    "لائوس ‏🇱🇦" => "856",
    "لیبی 🇱🇾" => "218",
    "🇹🇭 تایلند" => "66",
    "ماداگاسکار 🇲🇬" => "261",
    "🇨🇫 آفریقا مرکزی" => "236",
    "گابن 🇬🇦" => "241",
    "مالی 🇲🇱" => "223",
    "اسرائیل 🇮🇱" => "972",
    "ماکائو 🇲🇴" => "853",
    "پاناما 🇵🇦" => "507",
    "سوریه 🇸🇾" => "963",
    "بلاروس 🇧🇾" => "375",
    "تیمور شرقی🇹🇱" => "670",
    "ساحل عاج 🇨🇮" => "225",
    "انگلستان 🏴" => "44",
    "🇵🇸 فلسطین" => "970",
    "پاپوآ گینه نو‏🇵🇬" => "675",
    "مونته نگرو 🇲🇪" => "382",
    "رومانی 🇷🇴" => "40",
    "ترکیه 🇹🇷" => "90",
    "بوسنی 🇧🇦" => "387",
    "کوزوو 🇽🇰" => "383",
    "سومالی 🇸🇴" => "252",
    "چین ‏🇨🇳" => "86",
    "اتریش 🇦🇹" => "43",
    "برزیل 🇧🇷" => "55",
    "تاجیکستان 🇹🇯" => "992",
    "قرقیزستان 🇰🇬" => "996",
    "عمان 🇴🇲" => "968",
    "عراق 🇮🇶" => "964",
    "هنگ کنگ 🇭🇰" => "852",
    "لبنان 🇱🇧" => "961",
    "🇳🇱 هلند" => "31",
    "آذربایجان 🇦🇿" => "994",
    "بلیز 🇧🇿" => "501",
    "گرینلند 🇬🇱" => "299",
    "گوادلوپ 🇬🇵" => "590",
    "مقدونیه شمالی 🇲🇰" => "389",
    "گرجستان ‏🇬🇪" => "995",
    "ارمنستان 🇦🇲" => "374",
    "بوتان 🇧🇹" => "975",
    "نیوکالدونیا 🇳🇨" => "687",
    "لاتویا 🇱🇻" => "371",
    "اسپانیا 🇪🇸" => "34",
    "سورینام 🇸🇷" => "597",
    "ایتالیا 🇮🇹" => "39",
    "مالدیو 🇲🇻" => "960",
    "عربستان 🇸🇦" => "966",
    "اوکراین 🇺🇦" => "380",
    "آلبانیا 🇦🇱" => "355",
    "استرالیا 🇦🇺" => "61",
    "تایوان 🇹🇼" => "886",
    "مارتینیک 🇲🇶" => "596",
    "گویان فرانسه🇬🇫" => "594",
    "مالت 🇲🇹" => "356",
    "ژاپن 🇯🇵" => "81",
    "نائورو 🇳🇷" => "674",
    "مولداوی ‏🇲🇩" => "373",
    "آلمان 🇩🇪" => "49",
    "موریتانی 🇲🇷" => "222",
    "کویت 🇰🇼" => "965",
    "امارات 🇦🇪" => "971",
    "جبل الطارق 🇬🇮" => "350",
    "برونئی 🇧🇳" => "673",
    "جزایر کوک 🇨🇰" => "682",
    "کره جنوبی 🇰🇷" => "82",
];
$countries2 = [
    
    "ایران 🇮🇷"=>"98",
    "بنگلادش 🇧🇩" => "70",
    "آمریکا 🇺🇸" => "16",
    "نیجریه 🇳🇬" => "31",
    "پاکستان 🇵🇰" => "63",
    "هند 🇮🇳" => "35",
    "آنگولا 🇦🇴" => "94",
    "زامبیا 🇿🇲" => "62",
    "الجزایر 🇩🇿" => "54",
    "زیمبابوه 🇿🇼" => "142",
    "غنا 🇬🇭" => "42",
    "فیلیپین 🇵🇭" => "5",
    "تونس 🇹🇳" => "100",
    "موزامبیک 🇲🇿" => "80",
    "مصر 🇪🇬" => "34",
    "مالزی 🇲🇾" => "8",
    "افغانستان 🇦🇫" => "82",
    "آرژانتین 🇦🇷" => "44",
    "ازبکستان 🇺🇿" => "73",
    "لهستان 🇵🇱" => "25",
    "سریلانکا 🇱🇰" => "72",
    "🇾🇪 یمن" => "41",
    "سوازیلند 🇸🇿" => "147", // اسواتینی توی JSON
    "نپال🇳🇵" => "88",
    "تانزانیا 🇻🇹" => "10",
    "نامیبیا 🇳🇦" => "143",
    "لائوس ‏🇱🇦" => "39",
    "لیبی 🇱🇾" => "135",
    "🇹🇭 تایلند" => "64",
    "ماداگاسکار 🇲🇬" => "29",
    "گابن 🇬🇦" => "90",
    "مالی 🇲🇱" => "69",
    "اسرائیل 🇮🇱" => "20", // فلسطین توی JSON
    "ماکائو 🇲🇴" => "22", // ماکائـو توی JSON
    "پاناما 🇵🇦" => "33",
    "سوریه 🇸🇾" => "114",
    "بلاروس 🇧🇾" => "57",
    "تیمور شرقی🇹🇱" => "158", // تمیور شرقی توی JSON
    "ساحل عاج 🇨🇮" => "37",
    "انگلستان 🏴" => "12",
    "پاپوآ گینه نو‏🇵🇬" => "67",
    "رومانی 🇷🇴" => "14",
    "ترکیه 🇹🇷" => "48",
    "بوسنی 🇧🇦" => "92", // بوسنی و هرزگوین توی JSON
    "سومالی 🇸🇴" => "141",
    "چین ‏🇨🇳" => "4",
    "اتریش 🇦🇹" => "50",
    "برزیل 🇧🇷" => "24",
    "تاجیکستان 🇹🇯" => "156",
    "قرقیزستان 🇰🇬" => "18",
    "عمان 🇴🇲" => "130",
    "عراق 🇮🇶" => "45",
    "هنگ کنگ 🇭🇰" => "23",
    "🇳🇱 هلند" => "27",
    "آذربایجان 🇦🇿" => "103",
    "گوادلوپ 🇬🇵" => "149",
    "گرجستان ‏🇬🇪" => "60",
    "ارمنستان 🇦🇲" => "125",
    "بوتان 🇧🇹" => "128",
    "لاتویا 🇱🇻" => "13",
    "اسپانیا 🇪🇸" => "53",
    "ایتالیا 🇮🇹" => "98",
    "مالدیو 🇲🇻" => "134",
    "عربستان 🇸🇦" => "51",
    "اوکراین 🇺🇦" => "2",
    "استرالیا 🇦🇺" => "84",
    "تایوان 🇹🇼" => "65",
    "مارتینیک 🇲🇶" => "107",
    "مولداوی ‏🇲🇩" => "79",
    "آلمان 🇩🇪" => "46",
    "موریتانی 🇲🇷" => "136",
    "کویت 🇰🇼" => "102",
    "امارات 🇦🇪" => "85",
    "جبل الطارق 🇬🇮" => "163",
    "کره جنوبی 🇰🇷" => "161",
    "ژاپن 🇯🇵" => "165",
    "لبنان 🇱🇧" => "164"
];
//-----------------------------------------------------------------------------
$start = json_encode(["keyboard"=>[
[['text'=>"♻️ استعلام شماره ها"],['text'=>"🛍 خرید شماره مجازی"]],
[['text'=>"👤 حساب کاربری"],['text'=>"➕ افزایش موجودی"]],
[['text'=>"☎️ پشتیبانی"],['text'=>"❓راهنما"],['text'=>"💸 انتقال موجودی"]],
],'resize_keyboard'=>true]);

//▪▪▪▪▪▪▪▪▪▪▪▪//
$back=json_encode(['keyboard'=>[
    [['text'=>"🔙 منو اصلی"]],
   ],'resize_keyboard'=>true]);
   $backp=json_encode(['keyboard'=>[
    [['text'=>"بازگشت"]],
   ],'resize_keyboard'=>true]);
   $panel=json_encode(['keyboard'=>[
       
       [['text'=>"آمار"],['text'=>"پیام همگانی"]],
       [['text'=>"تعیین درصد سود"]],
      [['text'=>"کاهش موجودی"],['text'=>"افزایش موجودی"]],
    [['text'=>"🔙 منو اصلی"]],
   ],'resize_keyboard'=>true]); 
   $join=json_encode(['inline_keyboard'=>[
    [['text'=>'📪 عضویت در کانال','url'=>"$channelink"]],
    [['text'=>'✅ عضو شدم','callback_data'=>'joined']],
    ]]);