function funct_die_and_Report($strMessage, $strUserMessage, $strMessageAdmin, $strPage, $intLogRecord) { //get error string, usermsg, admin msg and page -> then send email to admin and die if (!$strUserMessage) { $strUserMessage = $strMessage; } if (!$strPage) { $strPage = "merchantapi"; } //update log record if ($intLogRecord) { $query = "UPDATE " . $tbl_Logs . " SET " . "response='{$strMessage}' " . "WHERE log_id = {$intLogRecord} "; //echo "SQL STMNT = " . $query . "<br>"; $rs = mysqli_query($DB_LINK, $query); } if ($strMessageAdmin) { $strSubject = "Error Detected on: " . $strPage . " "; $strBody = " " . $strMessageAdmin . " \n " . $strMessage . " \n " . $strUserMessage . " \n " . $strPage; funct_Mail_simple(EMAIL_ADMIN, $strSubject, $strBody); } die($strUserMessage); }
if (SEND_THROUGH_WHICH_SYSTEM == "amsterdam") { $strSendReturn = funct_Billing_SendBTC_CoinCafe($strWalletHash, $intBTCamt, $strNote, $intMiningFee, $strWalletFrom, $strLabel, $strLabel2, $strLabel3); //web api } //parse return array $strSendArry = explode("|", $strSendReturn); $strSendMsg = $strSendArry[0]; // message $strSendErr = $strSendArry[1]; // error $strSendHash = $strSendArry[2]; // txid - IT ONLY RETURNS A HASH IF SUCCESSFUL //update que record $query = "UPDATE " . TBL_TRANSACTIONS_QUE . " SET status_id=1 , transaction_txid='{$strSendHash}' , transaction_address='{$strWalletHash}' WHERE id=" . $intQueID; //echo "SQL STMNT = " . $query . "<br>"; $strERRORUserMessage = "Database update que record Error. Admin has been informed " . $strError_send; $strERRORMessageAdmin = "{$strError_send} \n SQL statement failed - {$query} "; mysqli_query($DB_LINK, $query) or funct_die_with_grace(mysqli_error(), $strERRORUserMessage, $strERRORMessageAdmin, $strERRORPage); //update transaction $query = "UPDATE " . TBL_TRANSACTIONS . " SET hash_transaction='{$strSendHash}' WHERE transaction_id=" . $intTransactionID; //echo "SQL STMNT = " . $query . "<br>"; $strERRORUserMessage = "Database update transaction hash Error. Admin has been informed " . $strError_send; $strERRORMessageAdmin = "{$strError_send} \n SQL statement failed - {$query} "; mysqli_query($DB_LINK, $query) or funct_die_with_grace(mysqli_error(), $strERRORUserMessage, $strERRORMessageAdmin, $strERRORPage); $strStatus = 1; //email user and let them know that their transaction has officially gone through $strSubject = "Your {$intBTCamt} Bitcoins have been sent."; $strBody = "Thank you for using " . WEBSITENAME; funct_Mail_simple($strEmail_get, $strSubject, $strBody, '', $strEmail); echo "Bitcoins sent: Error= {$strSendErr} - MSG= {$strSendMsg} "; }
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 password = ? WHERE id = ? "))) { echo "Prepare failed: (" . $DB_MYSQLI->errno . ") " . $DB_MYSQLI->error; } if (!$stmt->bind_param('sd', $strPassword_hash, $intUserID)) { echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error; } if (!$stmt->execute()) { echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } //send the user an email $strSubject = "coincafe.com Password Reset for {$strEmailForgotForm}"; $strBody = "temp password: {$strPasswordTemp} \n " . "Please login here: " . WEBSITEFULLURLHTTPS . PAGE_SIGNIN . " \n " . "Change your password here after " . WEBSITEFULLURLHTTPS . PAGE_SETTINGS . " \n "; funct_Mail_simple($strEmailForgotForm, $strSubject, $strBody, '', SUPPORT_EMAIL); $errorMSG = "A temporary password has been sent to " . $strEmailForgotForm . " Please check your email. sigin with the temp password and then change it."; //No Such Email in Database } //fetch for multiple rows } $stmt->close(); //Close statement } else { echo "Prepare failed: (" . $DB_MYSQLI->errno . ") " . $DB_MYSQLI->error; } //echo "errorMSG=$errorMSG"; //refresh join page with msg header('Location: ' . PAGE_SIGNIN . '?error_forgot=' . $errorMSG); die; break;
//update transactions table so that user can see status in their wallet.php $query = "UPDATE " . TBL_TRANSACTIONS . " SET status={$status_id}, status_msg='" . $status_name . "' WHERE order_id=" . $intOrderID . " AND type='buy'"; //echo "SQL STMNT = " . $query . "<br>"; mysqli_query($DB_LINK, $query) or die(mysqli_error()); //update orders table with latest status of order $query = "UPDATE " . TBL_ORDERS . " SET status_id={$status_id}, status_text='" . $status_name . "' WHERE orderid=" . $intOrderID; //echo "SQL STMNT = " . $query . "<br>"; mysqli_query($DB_LINK, $query) or die(mysqli_error()); } //end if chest id specified /* */ if ($strFromPage == "id") { //send email to admin $strUploadSrc = PATH_KYC . $intUserID . "." . $strCopyExt; copy($uploaded_file, __ROOT__ . $strUploadSrc); //copy pic to recipets folder. latest overwrites newest //echo "uploadedfile=".$uploaded_file." copied=".$strUploadSrc."<br>"; //email admin $strSubject = "ID Upload " . $intUserID . " " . $strFirstName . " " . $strLastName . " " . $Email; $strBody = "ID File Uploaded: " . WEBSITEFULLURL . $strUploadSrc . " \n" . "Member Details: " . WEBSITEFULLURL . "/cp/member_details.php?id=" . $intUserID . " \n" . "{$Email} \n {$strPhone} \n" . "" . WEBSITEFULLURL . " "; funct_Mail_simple(EMAIL_ORDERS, $strSubject, $strBody); if ($intUserID) { $query = "UPDATE " . TBL_USERS . " SET verification_id= verification_id + 1 WHERE id=" . $intUserID; //echo "SQL STMNT = " . $query . "<br>"; mysqli_query($DB_LINK, $query); } } echo "ok"; break; } //End Switch Statement
if (EMAIL_USER_ON_RECEIVE) { $intFlag_email_onget = $intFlag_email_onget; } else { $intFlag_email_onget = EMAIL_USER_ON_RECEIVE; } //send email to merchant if ($strEmail and $intFlag_email_onget) { $strSubject = "You got Coin! {$crypto_amt} BTC (est. \$" . $intTotalUSD . ") " . WEBSITENAME; $strBody = "You just received {$crypto_amt} BTC into your " . WEBSITENAME . " account. \n\n" . " -Thank you "; $strError = $strError . " " . funct_Mail_simple($strEmail, $strSubject, $strBody); } if (EMAIL_ADMIN_ON_RECEIVE) { //send email to admin $strSubject = "{$intUserID} {$strNameFirst} {$strNameLast} received {$crypto_amt} btc \$" . $intTotalUSD; $strBody = "User: {$intUserID} {$strNameFirst} {$strNameLast} received {$crypto_amt} BTC\n\n\tUSD Equivalent: ({${$intTotalUSD}})\n\n\n\tOld balance: {$intBalanceBTC_old} BTC\n\n\tNew balance: {$intNewBalance} BTC\n\n\tintEarnedTotal: {$intEarnedTotal}\n\n\tEmail: {$strEmail}\n\n\tPhone: {$strPhone}\n\n\tMember Details: " . WEBSITEFULLURL . "/cp/member_details.php?id={$intUserID}\n\n\tStreet Address: {$strAddress}"; $strError = $strError . " " . funct_Mail_simple(EMAIL_WALLETSEND, $strSubject, $strBody, EMAIL_ORDERS); } if ($intFlag_sms_onget) { //send sms message to merchant IMPORTANT $strTxtMessage = '+ $' . $intTotalUSD . ' You got ' . $crypto_amt . ' Bitcoin '; $strError = $strError . " " . functSendSMSswitch($strPhone, $strTxtMessage, $intCountryPhoneCode); if ($intDebugFlag) { $strDebugSqlTxt = $strDebugSqlTxt . "sms error=" . $strError . "<br>"; } //echo "fone: ".$strPhone."<br>"; } if ($intNewCallBackID and ($strError or $strDebugSqlTxt)) { $query = "UPDATE " . TBL_ORDERS_CALLBACKS . " SET " . " errorcode='{$strError} {$strDebugSqlTxt}' " . " WHERE callback_id=" . $intNewCallBackID; if ($intDebugFlag) { echo "SQL STMNT = " . $query . "<br>"; }
if (!$strStatus) { $strStatus = 0; } //if internal send protect db update //update transaction table with status, message and hash if it exists //need to update - balance_crypto_old balance_crypto_new crypto_total_outflow $query = "UPDATE " . TBL_TRANSACTIONS . " SET " . " status={$strStatus}," . " status_msg= '" . $strSendErr . " " . $strSendMsg . "', " . " hash_transaction= '" . $strSendHash . "' " . " WHERE transaction_id= " . $intNewOrderID; //echo "SQL STMNT = " . $query . "<br>"; $strERRORUserMessage = "Database transaction update Error. Admin has been informed"; $strERRORMessageAdmin = "{$strError_send} \n SQL statement failed - {$query} "; $strERRORPage = "/mods/sendcrypto.php"; mysqli_query($DB_LINK, $query) or funct_die_with_grace(mysqli_error(), $strERRORUserMessage, $strERRORMessageAdmin, $strERRORPage); //update user count_externalsends total_sentout $intBTCamt = number_format($intBTCamt, 8); $intBalanceCrypto = number_format($intBalanceCrypto, 8); //send email to admin informing of a new Send by a user $strSubject = "{$strNetwork} Send ({$intBTCamt} {$strCrypto}) \$" . number_format($intUSDamt, 2) . " USD by {$intUserID} " . $strFirstName . " " . $strLastName; $strBody = "amt: {$intBTCamt} {$strCrypto} \n new balance: {$intBalanceCrypto} {$strCrypto} \n usd: \$ {$intUSDamt} \n " . "strSendMsg: {$strSendMsg} \n phone: {$strPhone} \n ip address: {$strIPAddress} \n Label: {$strLabel} \n " . "Member Details: " . WEBSITEFULLURL . "/cp/member_details.php?id={$intUserID}\n" . "email: {$strEmail} \n strSendErr: {$strSendErr} \n strSendHash: {$strSendHash} "; funct_Mail_simple(EMAIL_WALLETSEND, $strSubject, $strBody, '', $strEmail); if ($strStatus) { // no errors so it went thru $intErrorCode = 1; $strError_send = "SUCCESS. COIN SENT " . $strError_send; $intBalanceUSD = number_format($intBalanceCrypto * $intRate, 2); } else { $intErrorCode = 0; $strError_send = $strError_send . " " . $strSendErr; } //header( 'Location: '. $Form_PageFrom.'?error_send='.$strError ); die(); echo $intErrorCode . "," . $strError_send . "," . $intBalanceCrypto . "," . $intBalanceUSD; }
function funct_SendEmailCode($intUserID) { global $DB_LINK; //Allows Function to Access variable defined in constants.php ( database link ) //generate unique code $intCode = createRandomKey_Num(12); //update member record $query = "UPDATE " . TBL_USERS . " SET emailcode='{$intCode}' WHERE id = {$intUserID} "; //echo "SQL STMNT = " . $query . "<br>"; $rs = mysqli_query($DB_LINK, $query) or die(mysqli_error()); //get email $query = "SELECT * FROM " . TBL_USERS . " WHERE id = {$intUserID} "; //echo "SQL STMNT = " . $query . "<br>"; $rs = mysqli_query($DB_LINK, $query) or die(mysqli_error()); $row = mysqli_fetch_array($rs); $strEmail = $row["email"]; $strEmailLink = WEBSITEFULLURLHTTPS . CODE_DO . "?do=confirmemailcode&emailcode=" . $intCode; //send email $strSubject = WEBSITENAME . " Verification Code " . $intCode; $strBody = "Your " . WEBSITENAME . " Verification Code is \n " . $intCode . " \n " . $strEmailLink; funct_Mail_simple($strEmail, $strSubject, $strBody); //$name=EMAIL_FROM_NAME ; $strFromName=WEBSITENAME ; $strFromEmail=EMAIL_FROM_ADDR ; //$strError = functSendEmail($strEmail, $strSubject, $strBody, $name, $strFromName, $strFromEmail); return $strError; }