]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/wernis_functions.php
It is Bitcoins, not BitCoins
[mailer.git] / inc / libs / wernis_functions.php
index 46c12509670ca8bca834c46afd089c256f5ede2b..0c64af809eff91ccdefabad3ac666073139d8c68 100644 (file)
@@ -53,7 +53,7 @@ function GET_WERNIS_ERROR_MESSAGE () {
                return $GLOBALS['wernis_data']['message'];
        } elseif (isset($GLOBALS['wernis_data']['status'])) {
                // Fall-back to status
-               return getMaskedMessage('WERNIS_ERROR_STATUS', $GLOBALS['wernis_data']['status']);
+               return '{%message,WERNIS_ERROR_STATUS=' . $GLOBALS['wernis_data']['status'] . '%}';
        } else {
                // Something bad happend
                return '{--WERNIS_UNKNOWN_ERROR--}';
@@ -111,11 +111,11 @@ function WERNIS_SEND_REQUEST ($scriptName, $requestData =  array()) {
        $response = sendPostRequest($requestString, $requestData);
 
        // Check the response header if all is fine
-       if (strpos($response[0], '200') === false) {
+       if (!isInString('200', $response[0])) {
                // Something bad happend... :(
                return array(
                        'status'  => 'request_error',
-                       'message' => getMaskedMessage('WERNIS_API_REQUEST_ERROR', $response[0])
+                       'message' => '{%message,WERNIS_API_REQUEST_ERROR=' . $response[0] . '%}'
                );
        } // END - if
 
@@ -193,7 +193,7 @@ function WERNIS_SEND_REQUEST ($scriptName, $requestData =  array()) {
                                logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown error %s from WDS66 API received.", $data[1]));
                                $return = array(
                                        'status'  => 'request_failed',
-                                       'message' => getMaskedMessage('WERNIS_API_REQUEST_FAILED', $data[1])
+                                       'message' => '{%message,WERNIS_API_REQUEST_FAILED=' . $data[1] . '%}'
                                );
                                break;
                }
@@ -222,7 +222,7 @@ function WERNIS_TEST_API () {
                // All fine!
                $result = true;
        } else {
-               // Status failture text
+               // Status failure text
                WERNIS_STATUS_MESSAGE($return['message'], $return['status']);
        }
 
@@ -264,9 +264,9 @@ function WERNIS_EXECUTE_WITHDRAW ($wdsId, $userMd5, $amount) {
                $result = true;
 
                // Log the transfer
-               WERNIS_LOG_TRANSFER($wdsId, $amount, 'IN');
+               WERNIS_LOG_TRANSFER($wdsId, $amount, 'WITHDRAW');
        } else {
-               // Status failture text
+               // Status failure text
                WERNIS_STATUS_MESSAGE($return['message'], $return['status']);
 
                // Log the transfer
@@ -301,9 +301,9 @@ function WERNIS_EXECUTE_PAYOUT ($wdsId, $amount) {
                $result = true;
 
                // Log the transfer
-               WERNIS_LOG_TRANSFER($wdsId, $amount, 'OUT');
+               WERNIS_LOG_TRANSFER($wdsId, $amount, 'PAYOUT');
        } else {
-               // Status failture text
+               // Status failure text
                WERNIS_STATUS_MESSAGE($return['message'], $return['status']);
 
                // Log the transfer
@@ -316,23 +316,17 @@ function WERNIS_EXECUTE_PAYOUT ($wdsId, $amount) {
 
 // Translate the status IN/OUT
 function translateWernisTransferStatus ($status) {
-       // Default status
-       $return = getMaskedMessage('WERNIS_STATUS_UNKNWOWN', $status);
+       // Default status is unknown
+       $return = '{%message,WERNIS_STATUS_UNKNWOWN=' . $status . '%}';
 
-       // Which status?
-       switch ($status) {
-               case 'IN': // Withdraw
-                       $return = '{--WERNIS_STATUS_WITHDRAW--}';
-                       break;
-
-               case 'OUT': // Payout
-                       $return = '{--WERNIS_STATUS_PAYOUT--}';
-                       break;
+       // Construct message id
+       $messageId = 'WERNIS_STATUS_' . $status;
 
-               case 'FAILED': // Payout
-                       $return = '{--WERNIS_STATUS_FAILED--}';
-                       break;
-       } // END - switch
+       // Is it there?
+       if (isMessageIdValid($messageId)) {
+               // Then use it as message string
+               $return = '{--' . $messageId . '--}';
+       } // END - if
 
        // Return the status
        return $return;
@@ -355,10 +349,10 @@ function WERNIS_LOG_TRANSFER ($wdsId, $amount, $type = 'FAILED', $message = '',
 // Take fees and factor
 function WERNIS_TAKE_FEE ($points, $mode) {
        // Payout or withdraw are allowed modes!
-       //* DEBUG: */ debugOutput('mode='.$mode.',points='.$points);
+       //* DEBUG: */ debugOutput('mode=' . $mode . ',points=' . $points);
        if (!in_array($mode, array('payout', 'withdraw'))) {
                // Log error and abort
-               logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . getMemberId() . ',mode=' . $mode . ',points=' . $points);
+               logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . getMemberId() . ',mode=' . $mode . ',points=' . $points . ' - unknown mode detected.');
                return false;
        } // END - if
 
@@ -400,9 +394,9 @@ function WERNIS_ADD_WITHDRAW_FEE ($points) {
        return $points;
 }
 
-// ---------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
 //                             Wrapper functions
-// ---------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
 
 // Wrapper function for 'wernis_refid'
 function getWernisRefid () {