Пример #1
0
     $stmt->bind_result($intUserID_DB, $Email_DB, $Phone_DB, $strName, $strWalletAddress);
     //bind results
     $stmt->fetch();
     //fetch the value
     //mysqli_stmt_store_result($stmt);
     //$intTotalRowsFound = mysqli_stmt_num_rows($stmt);
     //echo "totalrows: $intTotalRowsFound <br>";
     $stmt->close();
     //Close statement
 } else {
     echo "Prepare failed: (" . $DB_MYSQLI->errno . ") " . $DB_MYSQLI->error;
 }
 $strWalletAddress = trim($strWalletAddress);
 $strWalletLabel = $intUserID_DB . "|" . $Email_DB . "|" . $Phone_DB . "|" . $strName;
 //echo "making wallet address for ... ".$strWalletLabel."<br>";
 $strWalletAddress = funct_Billing_NewWalletAddress($strWalletLabel);
 if ($strWalletAddress) {
     //update database with new wallet hash code
     //$query="UPDATE " . TBL_USERS . " SET wallet_btc='".$strWalletAddress."' WHERE id=".$intUserID_DB ;
     //echo "SQL STMNT = " . $query .  "<br>";
     //mysqli_query($DB_LINK, $query) or die(mysqli_error());
     if ($DB_MYSQLI->connect_errno) {
         echo "Failed to connect to MySQL: (" . $DB_MYSQLI->connect_errno . ") " . $DB_MYSQLI->connect_error;
     }
     if (!($stmt = $DB_MYSQLI->prepare("UPDATE " . TBL_USERS . " SET wallet_btc = ? WHERE id = ? "))) {
         echo "Prepare failed: (" . $DB_MYSQLI->errno . ") " . $DB_MYSQLI->error;
     }
     if (!$stmt->bind_param('si', $strWalletAddress, $intUserID_DB)) {
         echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
     }
     if (!$stmt->execute()) {
function funct_MakeWalletAddressUpdate($intUserID, $strCrypto_Code)
{
    //create a new wallet address
    global $DB_LINK;
    //Allows Function to Access variable defined in constants.php ( database link )
    //get info from database for member with hash get their id
    $query = "SELECT * FROM " . TBL_USERS . " WHERE id= '" . $intUserID . "' ";
    //echo "SQL STMNT = " . $query .  "<br>";
    $rs = mysqli_query($DB_LINK, $query);
    // or die(mysqli_error());
    if (mysqli_num_rows($rs) > 0) {
        $row = mysqli_fetch_array($rs);
        $strNameFirst = $row["first_name"];
        //important
        $strNameLast = $row["last_name"];
        //important
        $strEmail = $row["email"];
        //important
        $strPhone = $row["cellphone"];
        //important
        $intCountryID = $row["country_id"];
        $intCountryPhoneCode = $row["country_phonecode"];
        //$strWalletAddress_BTC=		$row["wallet_btc"]; 		//their own personal wallet to forward btc to
        $intBalance = $row["balance"];
        //important
        $intBalanceBTC_old = $row["balance_btc"];
        $intEarnedTotal = $row["total_earned"];
        $strName = $strNameFirst . " " . $strNameLast;
    }
    /* make wallet receiving address or full wallet */
    //get their custom wallet address - Blockchain.info  or local bitcoin qt json rpc
    $strWalletLabel = AlphaNumericOnly_RepaceWithSpace($strEmail);
    //create the new wallet address via json rpc
    //https://github.com/goethewins/EzBit-BitCoin-API--Wallet
    $strWallet_Address = funct_Billing_NewWalletAddress($strEmail);
    if ($strWallet_Address) {
        //update database with new wallet hash code
        $query = "UPDATE " . TBL_USERS . " SET " . $strSQLUpdate . " wallet_receive_on = 1 ,  " . " wallet_address= '{$strWallet_Address}' " . " WHERE id=" . $intUserID;
        //echo "SQL STMNT = " . $query .  "<br>";
        mysqli_query($DB_LINK, $query);
        // or die(mysqli_error());
        //add record to wallet addresses table TBL_WALLET_ADDRESSES
        $query = "INSERT INTO " . TBL_WALLET_ADDRESSES . " ( user_id, \twallet_address,\t \t\tdate_created ) VALUES " . " ( {$intUserID},\t'{$strWallet_Address}',\tNOW() \t  ) ";
        //echo "SQL STMNT = " . $query .  "<br>";
        mysqli_query($DB_LINK, $query);
        //$intWalletID = mysqli_insert_id($DB_LINK);
        //add record to balances table - must only be on record per crypto type
        //this record is needed only if their is multiple crypto alt coin support
        //first see if there is already a record for this crypto type in the database
        $query = "SELECT * FROM " . TBL_WALLET_BALANCES . " WHERE currency_code= '" . $strCrypto . "' AND userid=" . $intUserID . "";
        //echo "Rate Select SQL = " . $query .  "<br>";
        $rs = mysqli_query($DB_LINK, $query) or die(mysqli_error());
        if (mysqli_num_rows($rs) > 0) {
            $row = mysqli_fetch_array($rs);
            //record found
        }
        if (!$strCrypto_Code) {
            $strCrypto_Code = "btc";
        }
        $query = "INSERT INTO " . TBL_WALLET_BALANCES . " ( user_id, \tcurrency_type, \tcurrency_code,\t    balance\t) VALUES " . " ( {$intUserID},\t'crypto',\t    '{$strCrypto_Code}',  0 ) ";
        //echo "SQL STMNT = " . $query .  "<br>";
        mysqli_query($DB_LINK, $query);
        //$intWalletID = mysqli_insert_id($DB_LINK);
        //make QR Code and save to their directory - google, phpapi
        if ($strWallet_Address) {
            $strQRcodeIMG = PATH_QRCODES . $strWallet_Address . ".png";
            $strError = funct_Billing_GetQRCodeImage($strWallet_Address, $strQRcodeIMG);
            //save img to disk
        }
        //update database with successful code creation
        $query = "UPDATE " . TBL_USERS . " SET flag_qrcodeimg=1 WHERE id=" . $intUserID;
        //echo "SQL STMNT = " . $query .  "<br>";
        mysqli_query($DB_LINK, $query);
        // or die(mysqli_error());
    }
    return $strWallet_Address;
}