X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fmember%2Fwhat-wernis.php;h=181603bab545bdc82b203d3b6db0fe80c0057236;hb=c45b1827a16928c65ecc1aea6a9d7a504c4874d4;hp=691c9d17fcc87b9c5696bcbe74f74bebef3010ca;hpb=ed8c755a84537d8558eb73b83046765a2dea3d12;p=mailer.git diff --git a/inc/modules/member/what-wernis.php b/inc/modules/member/what-wernis.php index 691c9d17fc..181603bab5 100644 --- a/inc/modules/member/what-wernis.php +++ b/inc/modules/member/what-wernis.php @@ -63,7 +63,7 @@ if ((!isset($_GET['mode'])) || ($_GET['mode'] == "choose")) { $content['refid'] = bigintval($_CONFIG['wernis_refid']); // Get WDS66 id - $result = SQL_QUERY_ESC("SELECT wernis_userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1", + $result = SQL_QUERY_ESC("SELECT wernis_userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__); // Are there some entries? @@ -81,7 +81,7 @@ if ((!isset($_GET['mode'])) || ($_GET['mode'] == "choose")) { $_GET['mode'] = "list"; // And load all rows! - $result = SQL_QUERY_ESC("SELECT `id`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type` FROM "._MYSQL_PREFIX."_user_wernis WHERE `userid` = %d ORDER BY `wernis_timestamp` DESC", + $result = SQL_QUERY_ESC("SELECT `id`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type` FROM "._MYSQL_PREFIX."_user_wernis WHERE `userid` = %s ORDER BY `wernis_timestamp` DESC", array($GLOBALS['userid']), __FILE__, __LINE__); // Load all rows @@ -89,11 +89,12 @@ if ((!isset($_GET['mode'])) || ($_GET['mode'] == "choose")) { while ($data = SQL_FETCHARRAY($result)) { // Prepare data for output $rowContent = array( - 'stamp' => MAKE_DATETIME($data['wernis_timestamp'], "2"), - 'points' => TRANSLATE_COMMA($data['wernis_amount']), - 'acc' => bigintval($data['wernis_account']), - 'status' => WERNIS_TRANSFER_STATUS($data['wernis_type']), - 'sw' => $SW, + 'stamp' => MAKE_DATETIME($data['wernis_timestamp'], "2"), + 'points' => TRANSLATE_COMMA($data['wernis_amount']), + 'acc' => bigintval($data['wernis_account']), + 'status' => WERNIS_TRANSFER_STATUS($data['wernis_type']), + 'raw_type' => strtolower($data['wernis_type']), + 'sw' => $SW, ); // Load row template @@ -115,6 +116,9 @@ if ((!isset($_GET['mode'])) || ($_GET['mode'] == "choose")) { $points = explode(".", $points); $points = bigintval($points[0]); + // Remove the registration fee + $points = $points - $_CONFIG['points_register']; + // Is this enougth for a payout? if ($points < $_CONFIG['wernis_min_payout']) { // No, then abort here @@ -128,7 +132,7 @@ if ((!isset($_GET['mode'])) || ($_GET['mode'] == "choose")) { // Get WDS66 id $content['wds66_id'] = ""; - $result = SQL_QUERY_ESC("SELECT wernis_userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1", + $result = SQL_QUERY_ESC("SELECT wernis_userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__); // Are there some entries? @@ -145,11 +149,11 @@ if ((!isset($_GET['mode'])) || ($_GET['mode'] == "choose")) { // Prepare data for the template $content['points'] = TRANSLATE_COMMA($points); - $content['min_points'] = TRANSLATE_COMMA($_CONFIG['wernis_min_payout']); + $content['min_points'] = TRANSLATE_COMMA($_CONFIG['wernis_min_withdraw']); $content['wds66_id'] = ""; // Get WDS66 id - $result = SQL_QUERY_ESC("SELECT wernis_userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1", + $result = SQL_QUERY_ESC("SELECT wernis_userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__); // Are there some entries? @@ -192,33 +196,20 @@ if ((isset($_POST['ok'])) && (isset($_GET['mode']))) { // Only numbers in amount! LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_MEMBER_INVALID_AMOUNT); OUTPUT_HTML("
"); - } elseif ($_POST['amount'] < $_CONFIG['wernis_min_payout']) { + } elseif ($_POST['amount'] < $_CONFIG['wernis_min_withdraw']) { // Not enougth entered! - LOAD_TEMPLATE("admin_settings_saved", false, sprintf(WERNIS_MEMBER_AMOUNT_SMALLER_MIN, bigintval($_CONFIG['wernis_min_payout']))); + LOAD_TEMPLATE("admin_settings_saved", false, sprintf(WERNIS_MEMBER_AMOUNT_SMALLER_MIN, bigintval($_CONFIG['wernis_min_withdraw']))); OUTPUT_HTML("
"); } else { // All is fine here so do the withdraw $success = WERNIS_EXECUTE_WITHDRAW($_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; - } - // Add it to this amount $DEPTH = 0; - ADD_POINTS_REFSYSTEM($GLOBALS['userid'], bigintval($_POST['amount']), false, 0, $locked, "direct"); - - // Register this wernis movement - $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_wernis (`userid`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type`) VALUES(%d, %d, %d, UNIX_TIMESTAMP(), 'IN')", - array($GLOBALS['userid'], bigintval($_POST['wds66_id']), bigintval($_POST['amount'])), __FILE__, __LINE__); + ADD_POINTS_REFSYSTEM($GLOBALS['userid'], bigintval($_POST['amount']), false, 0, false, "direct"); // Update the user data as well.. - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `wernis_userid`=%d WHERE userid=%d LIMIT 1", + $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `wernis_userid`=%s WHERE userid=%s LIMIT 1", array(bigintval($_POST['wds66_id']), $GLOBALS['userid']), __FILE__, __LINE__); // All done! @@ -280,19 +271,11 @@ if ((isset($_POST['ok'])) && (isset($_GET['mode']))) { } // Remove the points from the account - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `points_used` = `points_used` + %d WHERE userid=%d LIMIT 1", - array(bigintval($_POST['amount']), $GLOBALS['userid']), __FILE__, __LINE__); - - // Register this wernis movement - $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_wernis (`userid`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type`) VALUES(%d, %d, %d, UNIX_TIMESTAMP(), 'OUT')", - array($GLOBALS['userid'], bigintval($_POST['wds66_id']), bigintval($_POST['amount'])), __FILE__, __LINE__); - - // Update the user data as well.. - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `wernis_userid`=%d WHERE userid=%d LIMIT 1", - array(bigintval($_POST['wds66_id']), $GLOBALS['userid']), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `used_points` = `used_points` + %s, `wernis_userid`=%s WHERE userid=%s LIMIT 1", + array(bigintval($_POST['amount']), bigintval($_POST['wds66_id']), $GLOBALS['userid']), __FILE__, __LINE__); // All done! - LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_MEMBER_WITHDRAW_DONE); + LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_MEMBER_PAYOUT_DONE); return; } elseif ((GET_WERNIS_ERROR_CODE() == "user_failed") || (GET_WERNIS_ERROR_CODE() == "own_failed") || (GET_WERNIS_ERROR_CODE() == "amount_failed") || (GET_WERNIS_ERROR_CODE() == "api_amount_failed")) { // Wrong login data