From: Roland Häder Date: Thu, 29 Oct 2009 17:16:26 +0000 (+0000) Subject: Wernis API now reconizes failed API responses X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7e500b4e3a3c25881e5d7da8ff77d86344ae4cd7;p=mailer.git Wernis API now reconizes failed API responses --- diff --git a/inc/language/wernis_de.php b/inc/language/wernis_de.php index 3d1384c278..41becd0d3f 100644 --- a/inc/language/wernis_de.php +++ b/inc/language/wernis_de.php @@ -86,6 +86,7 @@ addMessages(array( 'WERNIS_API_REQUEST_DATA_INVALID' => "Interner Fehler: Abfragedaten sind defekt!", 'WERNIS_API_REQUEST_DATA_MISSING' => "Interner Fehler: Abfragedaten sind nicht komplett!", 'WERNIS_API_REQUEST_ERROR' => "Abfragefehler: %s", + 'WERNIS_API_REQUEST_PROBLEM' => "Abfrageproblem: Status=%s, Rückmeldung=%s", 'WERNIS_API_REQUEST_FAILED' => "Unbekannter Fehler %s von API erhalten! Bitte im [Bug-Tracker posten], den Fehlercode nennen und wie es dazu gekommen ist.", 'WERNIS_API_REQUEST_FAILED_AUTH' => "Authorisierung an API fehlgeschlagen! Bitte API-ID und Key überprüfen. [Hier] direkt zum Export-Account. Sie benötigen Ihren Usernamen und Passwort!", 'WERNIS_API_REQUEST_FAILED_USER' => "Useraccount nicht gefunden oder Wernis-Passwort ist ungültig!", @@ -104,7 +105,7 @@ addMessages(array( 'MEMBER_WERNIS_MODE_CHOOSE2' => "Hier klicken um neue Überweisung zu starten...", 'WERNIS_MEMBER_NO_ACCOUNT' => "Noch kein WDS66-Account? Hier entlang!", 'WERNIS_MEMBER_API_DATA_MISSING' => "Diese Funktion kann derzeit nicht genutzt werden, da wir sie noch einrichten müssen.", - 'WERNIS_MEMBER_MIN_PAYOUT' => "Sie haben nicht genügend Wernis zum Auszahlen! Mindestens: %s Wernis.", + 'WERNIS_MEMBER_MIN_PAYOUT' => "Sie haben nicht genügend Wernis zum Auszahlen! Mindestens: %s, Ihr Guthaben: %s Wernis.", 'WERNIS_MEMBER_WITHDRAW_TITLE' => "Wernis bei {?MAIN_TITLE?} einzahlen:", 'WERNIS_MEMBER_WITHDRAW_POINTS_ACCOUNT' => "Wernis hier im Account:", 'WERNIS_MEMBER_WITHDRAW_MIN_POINTS' => "Mindest einzuzahlendes Wernis-Guthaben:", diff --git a/inc/libs/wernis_functions.php b/inc/libs/wernis_functions.php index 101c5b3606..4d86960d3c 100644 --- a/inc/libs/wernis_functions.php +++ b/inc/libs/wernis_functions.php @@ -112,22 +112,29 @@ function WERNIS_SEND_REQUEST ($scriptName, $requestData = array()) { } // END - if // All (maybe) fine so remove the response header from server + $responseLine = '*INVALID*'; for ($idx = (count($response) - 1); $idx > 1; $idx--) { $line = trim($response[$idx]); if (!empty($line)) { - $response = $line; + $responseLine = $line; break; - } - } + } // END - if + } // END - for - // Prepare the returning result for higher functions - if (substr($response, 0, 1) == '&') { - // Remove the leading & (which can be used in Flash) - $response = substr($response, 1); + // Is the response leaded by a & symbol? + if (substr($responseLine, 0, 1) != '&') { + // Something badly happened on server-side + return array( + 'status' => 'request_problem', + 'message' => sprintf(getMessage('WERNIS_API_REQUEST_PROBLEM'), $response[0], htmlentities($responseLine)) + ); } // END - if + // Remove the leading & (which can be used in Flash) + $responseLine = substr($responseLine, 1); + // Bring back the response - $data = explode('=', $response); + $data = explode('=', $responseLine); // Default return array (should not stay empty) $return = array(); @@ -186,7 +193,7 @@ function WERNIS_SEND_REQUEST ($scriptName, $requestData = array()) { // All fine here $return = array( 'status' => 'OK', - 'response' => $response + 'response' => $responseLine ); } @@ -236,9 +243,9 @@ function WERNIS_EXECUTE_WITHDRAW ($wdsId, $userMd5, $amount) { // Prepare the request data $requestData = array( 'sub_request' => 'receive', - 't_userid' => bigintval($wdsId), + 't_uid' => bigintval($wdsId), 't_md5' => $userMd5, - 'r_userid' => getConfig('wernis_refid'), + 'r_uid' => getConfig('wernis_refid'), 'amount' => bigintval($amount), 'purpose' => encodeString($purpose, false) ); @@ -276,9 +283,9 @@ function WERNIS_EXECUTE_PAYOUT ($wdsId, $amount) { // Prepare the request data $requestData = array( 'sub_request' => 'send', - 't_userid' => getConfig('wernis_refid'), + 't_uid' => getConfig('wernis_refid'), 't_md5' => getConfig('wernis_pass_md5'), - 'r_userid' => bigintval($wdsId), + 'r_uid' => bigintval($wdsId), 'amount' => bigintval($amount), 'purpose' => encodeString($purpose, false) ); diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index ae4a18e4d6..4cce611c95 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -534,7 +534,7 @@ function adminMenuSelectionBox_DEPRECATED ($mode, $default = '', $defid = '') { } // Wrapper for $_POST and adminSaveSettings -function adminSaveSettingsFromPostData ($tableName = "_config", $whereStatement = "config=0", $translateComma = array(), $alwaysAdd = false) { +function adminSaveSettingsFromPostData ($tableName = '_config', $whereStatement = 'config=0', $translateComma = array(), $alwaysAdd = false) { // Get the array $postData = postRequestArray(); @@ -543,7 +543,7 @@ function adminSaveSettingsFromPostData ($tableName = "_config", $whereStatement } // Save settings to the database -function adminSaveSettings (&$postData, $tableName = "_config", $whereStatement = "config=0", $translateComma = array(), $alwaysAdd = false) { +function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement = 'config=0', $translateComma = array(), $alwaysAdd = false) { // Prepare all arrays, variables $DATA = array(); $skip = false; diff --git a/inc/modules/admin/what-config_wernis.php b/inc/modules/admin/what-config_wernis.php index 51f3f15800..dbfd24dbbd 100644 --- a/inc/modules/admin/what-config_wernis.php +++ b/inc/modules/admin/what-config_wernis.php @@ -52,7 +52,7 @@ if (isFormSent()) { if (WERNIS_TEST_API()) { // Revert german commata foreach (array('payout_factor', 'withdraw_factor', 'payout_fee_percent', 'withdraw_fee_percent') as $revert) { - setRequestPostElement('wernis_'.$revert, convertCommaToDot(postRequestElement('wernis_'.$revert))); + setRequestPostElement('wernis_' . $revert, postRequestElement('wernis_' . $revert)); } // END - if // Hash the password and remove clear-text @@ -68,10 +68,6 @@ if (isFormSent()) { } else { // Prepare data for template output $content = array( - 'payout_factor' => translateComma(getConfig('wernis_payout_factor')), - 'withdraw_factor' => translateComma(getConfig('wernis_withdraw_factor')), - 'payout_fee_percent' => translateComma(getConfig('wernis_payout_fee_percent')), - 'withdraw_fee_percent' => translateComma(getConfig('wernis_withdraw_fee_percent')), 'wernis_payout_active_y' => '', 'wernis_payout_active_n' => '', 'wernis_withdraw_active_y' => '', diff --git a/inc/modules/member/what-wernis.php b/inc/modules/member/what-wernis.php index 56b201c875..33ffa15f14 100644 --- a/inc/modules/member/what-wernis.php +++ b/inc/modules/member/what-wernis.php @@ -143,7 +143,11 @@ if ((!isGetRequestElementSet('mode')) || (getRequestElement('mode') == 'choose') // Is this enougth for a payout? if ($points < getConfig('wernis_min_payout')) { // No, then abort here - loadTemplate('admin_settings_saved', false, sprintf(getMessage('WERNIS_MEMBER_MIN_PAYOUT'), translateComma(getConfig('wernis_min_payout')))); + loadTemplate('admin_settings_saved', false, sprintf( + getMessage('WERNIS_MEMBER_MIN_PAYOUT'), + translateComma(getConfig('wernis_min_payout')), + translateComma($points) + )); return; } // END - if @@ -222,10 +226,10 @@ if ((isFormSent()) && (isGetRequestElementSet('mode'))) { } else { // Check input data depending on the mode and execute the requested mode switch (getRequestElement('mode')) { - case "withdraw": // Widthdraws WDS66 -> This exchange + case 'withdraw': // Widthdraws WDS66 -> This exchange if (postRequestElement('amount') < getConfig('wernis_min_withdraw')) { // Not enougth entered! - loadTemplate('admin_settings_saved', false, sprintf(getMessage('WERNIS_MEMBER_AMOUNT_SMALLER_MIN'), getConfig(('wernis_min_withdraw')))); + loadTemplate('admin_settings_saved', false, sprintf(getMessage('WERNIS_MEMBER_AMOUNT_SMALLER_MIN'), translateComma(getConfig('wernis_min_withdraw')))); } else { // All is fine here so do the withdraw $success = WERNIS_EXECUTE_WITHDRAW(postRequestElement('wds66_id'), md5(postRequestElement('wds66_password')), postRequestElement('amount')); @@ -240,7 +244,7 @@ if ((isFormSent()) && (isGetRequestElementSet('mode'))) { // All done! loadTemplate('admin_settings_saved', false, getMessage('WERNIS_MEMBER_WITHDRAW_DONE')); return; - } elseif ((GET_WERNIS_ERROR_CODE() == "user_failed") || (GET_WERNIS_ERROR_CODE() == "own_failed") || (GET_WERNIS_ERROR_CODE() == "amount_failed")) { + } elseif ((GET_WERNIS_ERROR_CODE() == 'user_failed') || (GET_WERNIS_ERROR_CODE() == 'own_failed') || (GET_WERNIS_ERROR_CODE() == 'amount_failed')) { // Wrong login data loadTemplate('admin_settings_saved', false, GET_WERNIS_ERROR_MESSAGE()); } else { @@ -253,7 +257,7 @@ if ((isFormSent()) && (isGetRequestElementSet('mode'))) { case 'payout': // Payout this exchange -> WDS66 if (postRequestElement('amount') < getConfig('wernis_min_payout')) { // Not enougth entered! - loadTemplate('admin_settings_saved', false, sprintf(getMessage('WERNIS_MEMBER_AMOUNT_SMALLER_MIN'), getConfig(('wernis_min_payout')))); + loadTemplate('admin_settings_saved', false, sprintf(getMessage('WERNIS_MEMBER_AMOUNT_SMALLER_MIN'), translateComma(getConfig('wernis_min_payout')))); } elseif (postRequestElement('amount') > $points) { // Not enougth points left! loadTemplate('admin_settings_saved', false, sprintf(getMessage('WERNIS_MEMBER_PAYOUT_POINTS_DEPLETED'), bigintval(postRequestElement('amount')), bigintval($points)));