-if ((isset($_POST['ok'])) && (isset($_GET['mode']))) {
- // Check input data depending on the mode and execute the requested mode
- switch ($_GET['mode']) {
- case "pay": // Payout this exchange -> WDS66
- // Is the user ID and password set?
- if (empty($_POST['wds66_id'])) {
- // Nothing entered in WDS66 user ID
- LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_MEMBER_EMPTY_USERNAME);
- OUTPUT_HTML("<br />");
- } elseif (empty($_POST['wds66_password'])) {
- // Nothing entered in WDS66 password
- LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_MEMBER_EMPTY_PASSWORD);
- OUTPUT_HTML("<br />");
- } elseif (empty($_POST['amount'])) {
- // Nothing entered in amount
- LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_MEMBER_EMPTY_AMOUNT);
- OUTPUT_HTML("<br />");
- } elseif ($_POST['wds66_id'] != bigintval($_POST['wds66_id'])) {
- // Only numbers in account ID!
- LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_MEMBER_INVALID_USERNAME);
- OUTPUT_HTML("<br />");
- } elseif ($_POST['amount'] != bigintval($_POST['amount'])) {
- // Only numbers in amount!
- LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_MEMBER_INVALID_AMOUNT);
- OUTPUT_HTML("<br />");
- } elseif ($_POST['amount'] < $_CONFIG['wernis_min_payout']) {
- // Not enougth entered!
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(WERNIS_MEMBER_AMOUNT_SMALLER_MIN, bigintval($_CONFIG['wernis_min_payout'])));
- OUTPUT_HTML("<br />");
- } elseif ($_POST['amount'] > $points) {
- // Not enougth points left!
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(WERNIS_MEMBER_PAYOUT_POINTS_DEPLETED, bigintval($_POST['amount']), bigintval($points)));
- OUTPUT_HTML("<br />");
- } else {
- // All is fine here so do the payout
- $success = WERNIS_EXECUTE_PAYOUT($_POST['wds66_id'], md5($_POST['wds66_password']), $_POST['amount']);
- if ($success) {
- // Default is locked!
- $locked = true;
-
- // Shall I "pay" the referral points imidiately?
- if ($_CONFIG['ref_payout'] == "0") {
- // Yes, "pay" it now
- $locked = false;
+if ((isFormSent()) && (isGetRequestParameterSet('mode'))) {
+ // Is the user id and password set?
+ if (!isPostRequestParameterSet('wernis_userid')) {
+ // Nothing entered in WDS66 user id
+ displayMessage('{--MEMBER_WERNIS_EMPTY_USERNAME--}');
+ } elseif (!isPostRequestParameterSet('wds66_password')) {
+ // Nothing entered in WDS66 password
+ displayMessage('{--MEMBER_WERNIS_EMPTY_PASSWORD--}');
+ } elseif (!isPostRequestParameterSet('amount')) {
+ // Nothing entered in amount
+ displayMessage('{--MEMBER_WERNIS_EMPTY_AMOUNT--}');
+ } elseif (postRequestParameter('wernis_userid') != bigintval(postRequestParameter('wernis_userid'))) {
+ // Only numbers in account id!
+ displayMessage('{--MEMBER_WERNIS_INVALID_USERNAME');
+ } elseif (postRequestParameter('amount') != bigintval(postRequestParameter('amount'))) {
+ // Only numbers in amount!
+ displayMessage('{--MEMBER_WERNIS_INVALID_AMOUNT--}');
+ } else {
+ // Check input data depending on the mode and execute the requested mode
+ switch (getRequestParameter('mode')) {
+ case 'withdraw': // Widthdraws WDS66 -> This exchange
+ if (postRequestParameter('amount') < getConfig('wernis_min_withdraw')) {
+ // Not enougth entered!
+ displayMessage('{--MEMBER_WERNIS_WITHDRAW_AMOUNT_SMALLER_MIN--}');
+ } else {
+ // All is fine here so do the withdraw
+ $success = WERNIS_EXECUTE_WITHDRAW(postRequestParameter('wernis_userid'), md5(postRequestParameter('wds66_password')), postRequestParameter('amount'));
+ if ($success === true) {
+ // Add it to this amount
+ addPointsDirectly('wernis_withdraw', getMemberId(), bigintval(postRequestParameter('amount')));
+
+ // Update the user data as well..
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `wernis_userid`=%s WHERE `userid`=%s LIMIT 1",
+ array(bigintval(postRequestParameter('wernis_userid')), getMemberId()), __FILE__, __LINE__);
+
+ // All done!
+ displayMessage('{--MEMBER_WERNIS_WITHDRAW_DONE--}');
+ return;
+ } elseif ((GET_WERNIS_ERROR_CODE() == 'user_failed') || (GET_WERNIS_ERROR_CODE() == 'own_failed') || (GET_WERNIS_ERROR_CODE() == 'amount_failed')) {
+ // Wrong login data
+ displayMessage(GET_WERNIS_ERROR_MESSAGE());
+ } else {
+ // Something went wrong
+ displayMessage(getMaskedMessage('MEMBER_WERNIS_WITHDRAW_FAILED', GET_WERNIS_ERROR_MESSAGE()));