<?php

/* class general
{
    public $mainWalletAddress = 'TGjWxnfBdABoJy8KrR24bpfQSJxRs5t78r';


    function checkTransactionStatus($transactionHash, $price, $db)
    {
     //return 'ok';
        if ($db->checkHash($transactionHash) != 'ok') {
            return 'no';
        }
        $ch = curl_init("https://apilist.tronscan.org/api/transaction-info?hash=$transactionHash");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // curl_setopt($ch, CURLOPT_POST, 1);
        $result = curl_exec($ch);
        print('result ' . $result);
        $data = json_decode($result, true);
        print("<hr /><hr /><hr />");

        print_r($data);

        print("<hr /><hr /><hr />");

        print_r($data['tokenTransferInfo']);


        $actualPrice = $data['tokenTransferInfo']['amount_str'] / pow(10, $data['tokenTransferInfo']['decimals']);



        if ($data['tokenTransferInfo']['symbol'] == 'USDT' && $data['tokenTransferInfo']['to_address'] == $this->mainWalletAddress && $actualPrice == $price) {
            return 'ok';
        } else {
            return 'no';
        }

    }

    function checkAllowdedPhone($db, $phone)
    {
        $sql = "select * from phones where phone='" . $phone . "' ";
        $stmt = $db->conn->prepare($sql);
        $stmt->execute();
        $stmt->setFetchMode(PDO::FETCH_ASSOC);
        $getter = $stmt->fetchAll();
        $numrowfusers = $stmt->rowCount();

        if ($numrowfusers == 0) {
            return 'empty';
        } elseif ($getter[0]['status'] == 'deactive') {
            return 'deactive';
        }



        $sql = "update phones set status='deactive' where phone='" . $phone . "' ";
        $db->conn->exec($sql);
        return 'ok';
    }



} */



class general
{
    //public $mainWalletAddress = 'TFFzgNDLFLSQ5kBBLTNXJCSGLJCFvZFoTN';
    public $mainWalletAddress = 'TF91crGHzAzqFVijPCEmiTyj5JHRGsdME2';
    

    function checkTransactionStatus($transactionHash, $price, $db)
    {

        if ($db->checkHash($transactionHash) != 'ok') {
            return 'no';
        }
        $ch = curl_init("https://apilist.tronscan.org/api/transaction-info?hash=$transactionHash");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // curl_setopt($ch, CURLOPT_POST, 1);
        $result = curl_exec($ch);
        print('result ' . $result);
        $data = json_decode($result, true);
        print("<hr /><hr /><hr />");

        print_r($data);

        print("<hr /><hr /><hr />");

        print_r($data['tokenTransferInfo']);


        $actualPrice = $data['tokenTransferInfo']['amount_str'] / pow(10, $data['tokenTransferInfo']['decimals']);



        if ($data['tokenTransferInfo']['symbol'] == 'USDT' && $data['tokenTransferInfo']['to_address'] == $this->mainWalletAddress && $actualPrice == $price) {
            return 'ok';
        } else {
            return 'no';
        }

    }




}

?>