From 9955cbe6e80fa364e01d1cb29d14a587f48736f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 17 Mar 2008 12:04:04 +0000 Subject: [PATCH] Wernis extension added --- inc/extensions/ext-wernis.php | 4 ++- inc/language/wernis_de.php | 32 ++++++++++++------- inc/libs/wernis_functions.php | 32 ++++++++++++++++--- inc/modules/admin/what-list_wernis.php | 32 +++++++++++++++++++ inc/modules/member/what-wernis.php | 19 ++++------- .../member/member_wernis_mode_list_row.tpl | 8 ++--- 6 files changed, 92 insertions(+), 35 deletions(-) diff --git a/inc/extensions/ext-wernis.php b/inc/extensions/ext-wernis.php index cce98ab27b..013714a569 100644 --- a/inc/extensions/ext-wernis.php +++ b/inc/extensions/ext-wernis.php @@ -58,7 +58,9 @@ userid bigint(20) NOT NULL default '0', wernis_account varchar(255) NOT NULL default '', wernis_amount double(22,5) NOT NULL default '0.00000', wernis_timestamp varchar(10) NOT NULL default '0', -wernis_type ENUM('IN','OUT') NOT NULL default 'OUT', +wernis_type ENUM('IN','OUT', 'FAILED') NOT NULL default 'FAILED', +wernis_api_message TINYTEXT, +wernis_api_status varchar(255) NULL default NULL KEY(userid), PRIMARY KEY(id) ) TYPE=MyISAM"; diff --git a/inc/language/wernis_de.php b/inc/language/wernis_de.php index 7636c37284..fc61ac1acb 100644 --- a/inc/language/wernis_de.php +++ b/inc/language/wernis_de.php @@ -47,14 +47,22 @@ define('WERNIS_ADMIN_API_ID', "WDS66-API-ID (api_id=x)"); define('WERNIS_ADMIN_API_MD5', "WDS66-API-Key (api_md5=xxxxx; 32-stellig)"); define('WERNIS_ADMIN_API_URL', "Basis-URL der API-Skripte"); define('WERNIS_ADMIN_REFID', "Ihre Referral-ID bei WDS66-Portal (= Ihr Username!)"); -define('WERNIS_ADMIN_CONFIG_NOTE', "Hier können Sie schon für 5,00€=25.000 Abfragen ein API-Account beantragen (dazu ist ein kostenloses {!POINTS!}-Account dennoch nötig!) Geben Sie immer Ihren Usernamen von WDS66-Hauptaccount ein und überprüfen Sie diesen mehrmals! Er wird zum Überweisen von {!POINTS!}/Wernis benötigt."); -define('MEMBER_WERNIS_MODE_CHOOSE', "Möchten Sie {!POINTS!} zu Ihrem WDS66-Hauptaccount ausbezahlt bekommen oder Wernis hier einzahlen?"); +define('WERNIS_ADMIN_CONFIG_NOTE', "Hier können Sie schon für 5,00€=25.000 Abfragen ein API-Account beantragen (dazu ist ein kostenloses {!POINTS!}-Account dennoch nötig!) Geben Sie immer Ihren Usernamen von WDS66-Hauptaccount ein und überprüfen Sie diesen mehrmals! Er wird zum Überweisen von {!POINTS!}/{!POINTS!} benötigt."); +define('WERNIS_ADMIN_NO_TRANSFERS', "Derzeit keine {!POINTS!} transferiert!"); +define('WERNIS_ADMIN_WDS66_ACCOUNT', "Account bei WDS66-Portal"); +define('WERNIS_ADMIN_TRANSFERED', "{!POINTS!} transferiert"); +define('WERNIS_ADMIN_TIMESTAMP', "Zeitpunkt Überweisung"); +define('WERNIS_ADMIN_TYPE', "Überweisungsrichtung"); +define('WERNIS_ADMIN_API_MESSAGE', "Nachricht von WDS66-API"); +define('WERNIS_ADMIN_API_STATUS', "Status von WDS66-API"); +define('MEMBER_WERNIS_MODE_CHOOSE', "Möchten Sie {!POINTS!} zu Ihrem WDS66-Hauptaccount ausbezahlt bekommen oder {!POINTS!} hier einzahlen?"); define('MEMBER_WERNIS_MODE_CHOOSE2', "Hier klicken um neue Überweisung zu starten..."); -define('MEMBER_WERNIS_MODE_WITHDRAW', "Wernis einzahlen"); +define('MEMBER_WERNIS_MODE_WITHDRAW', "{!POINTS!} einzahlen"); define('MEMBER_WERNIS_MODE_PAYOUT', "{!POINTS!} auszahlen"); -define('WERNIS_STATUS_UNKNWOWN', "Wernis-Typ %s unbekannt."); +define('WERNIS_STATUS_UNKNWOWN', "{!POINTS!}-Typ %s unbekannt."); define('WERNIS_STATUS_WITHDRAW', "Einzahlung von WDS66"); define('WERNIS_STATUS_PAYOUT', "Auszahlung an WDS66"); +define('WERNIS_STATUS_FAILED', "Fehlgeschlagen"); define('WERNIS_TIMESTAMP', "Buchungszeitmarke"); define('WERNIS_ACCOUNT', "WDS66-Hauptaccount"); define('WERNIS_TOTAL_WERNIS', "Gesamt überwiesen"); @@ -66,7 +74,7 @@ define('WERNIS_API_REQUEST_DATA_MISSING', "Interner Fehler: Abfragedaten sind ni define('WERNIS_API_REQUEST_ERROR', "Abfragefehler: %s"); define('WERNIS_API_REQUEST_FAILED', "Unbekannter Fehler %s von API erhalten! Bitte im [Forum melden], den Fehlercode nennen und wie es dazu gekommen ist."); define('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!"); -define('WERNIS_API_REQUEST_FAILED_USER', "Useraccount nicht gefunden oder Wernis-Passwort ist ungültig!"); +define('WERNIS_API_REQUEST_FAILED_USER', "Useraccount nicht gefunden oder {!POINTS!}-Passwort ist ungültig!"); define('WERNIS_API_REQUEST_FAILED_OWN', "Überweisung an eigenes Account nicht möglich."); define('WERNIS_API_REQUEST_FAILED_AMOUNT', "Konto weist nicht genügend Deckung auf."); define('WERNIS_API_REQUEST_FAILED_API_AMOUNT', "API-Konto weist nicht genügend Deckung auf."); @@ -81,22 +89,22 @@ define('WERNIS_UNKNOWN_ERROR', "Unbekannter Fehler aufgetreten!"); define('WERNIS_MEMBER_NO_ACCOUNT', "Noch kein WDS66-Account? Hier entlang!"); define('WERNIS_MEMBER_API_DATA_MISSING', "Diese Funktion kann derzeit nicht genutzt werden, da wir sie noch einrichten müssen."); define('WERNIS_MEMBER_MIN_PAYOUT_PAYOUT', "Sie haben nicht genügend {!POINTS!} zum Auszahlen! Mindestens: %s {!POINTS!}."); -define('WERNIS_MEMBER_WITHDRAW_TITLE', "Wernis bei {!MAIN_TITLE!} einzahlen:"); +define('WERNIS_MEMBER_WITHDRAW_TITLE', "{!POINTS!} bei {!MAIN_TITLE!} einzahlen:"); define('WERNIS_MEMBER_WITHDRAW_POINTS_ACCOUNT', "{!POINTS!} hier im Account:"); -define('WERNIS_MEMBER_WITHDRAW_MIN_POINTS', "Mindest einzuzahlendes Wernis-Guthaben:"); +define('WERNIS_MEMBER_WITHDRAW_MIN_POINTS', "Mindest einzuzahlendes {!POINTS!}-Guthaben:"); define('WERNIS_MEMBER_WITHDRAW_SUBMIT', "{!POINTS!} jetzt einzahlen"); -define('WERNIS_MEMBER_WITHDRAW_NOTE', "Ihr Wernis-Passwort wird bei {!MAIN_TITLE!} nicht gespeichert. Bitte bei Wernis-Betrag nur gerade Beträge eingeben! Ihr WDS66-Konto sollte ausreichend Deckung aufweisen!"); -define('WERNIS_MEMBER_PAYOUT_TITLE', "Wernis auf Ihr WDS66-Hauptaccount auszahlen"); +define('WERNIS_MEMBER_WITHDRAW_NOTE', "Ihr {!POINTS!}-Passwort wird bei {!MAIN_TITLE!} nicht gespeichert. Bitte bei {!POINTS!}-Betrag nur gerade Beträge eingeben! Ihr WDS66-Konto sollte ausreichend Deckung aufweisen!"); +define('WERNIS_MEMBER_PAYOUT_TITLE', "{!POINTS!} auf Ihr WDS66-Hauptaccount auszahlen"); define('WERNIS_MEMBER_PAYOUT_POINTS', "Auszahlfähiges {!POINTS!}-Guthaben"); define('WERNIS_MEMBER_PAYOUT_MIN_POINTS', "Mindestens auszuzahlendes {!POINTS!}-Guthaben"); define('WERNIS_MEMBER_PAYOUT_SUBMIT', "Auszahlung durchführen"); -define('WERNIS_MEMBER_PAYOUT_NOTE', "Ihr Wernis-Passwort wird bei {!MAIN_TITLE!} nicht gespeichert. Bitte bei Wernis-Betrag nur gerade Beträge eingeben! Überprüfen Sie vor dem Absenden Ihren WDS66-Usernamen."); +define('WERNIS_MEMBER_PAYOUT_NOTE', "Ihr {!POINTS!}-Passwort wird bei {!MAIN_TITLE!} nicht gespeichert. Bitte bei {!POINTS!}-Betrag nur gerade Beträge eingeben! Überprüfen Sie vor dem Absenden Ihren WDS66-Usernamen."); define('WERNIS_MEMBER_WDS66_ID', "Username bei WDS66-Portal: [Vergessen?]"); -define('WERNIS_MEMBER_WDS66_PASSWORD', "Wernis-Passwort (nicht Accountpasswort!): [Vergessen?]"); +define('WERNIS_MEMBER_WDS66_PASSWORD', "{!POINTS!}-Passwort (nicht Accountpasswort!): [Vergessen?]"); define('WERNIS_MEMBER_WDS66_AMOUNT', "Zu überweisenden Betrag eingeben:"); define('WERNIS_MEMBER_MODE_INVALID', "Ungültiger Modus %s erkannt! Bitte links im Menü fortfahren."); define('WERNIS_MEMBER_EMPTY_USERNAME', "Sie haben Ihren WDS66-Usernamen nicht eingegeben."); -define('WERNIS_MEMBER_EMPTY_PASSWORD', "Sieh haben kein Wernis-Passwort eingegeben."); +define('WERNIS_MEMBER_EMPTY_PASSWORD', "Sieh haben kein {!POINTS!}-Passwort eingegeben."); define('WERNIS_MEMBER_EMPTY_AMOUNT', "Sie haben keine zu überweisende Betrag angegeben."); define('WERNIS_MEMBER_INVALID_USERNAME', "Bitte nur Zahlen für den WDS66-Usernamen eingeben!"); define('WERNIS_MEMBER_INVALID_AMOUNT', "Bitte nur Zahlen für den zu überweisenden Betrag eingeben!"); diff --git a/inc/libs/wernis_functions.php b/inc/libs/wernis_functions.php index 812fbf20ec..ae8ed57e56 100644 --- a/inc/libs/wernis_functions.php +++ b/inc/libs/wernis_functions.php @@ -209,7 +209,7 @@ function WERNIS_TEST_API () { } // Widthdraw this amount -function WERNIS_EXECUTE_WITHDRAW($userId, $userMd5, $amount) { +function WERNIS_EXECUTE_WITHDRAW ($wdsId, $userMd5, $amount) { global $_CONFIG; $result = false; @@ -220,7 +220,7 @@ function WERNIS_EXECUTE_WITHDRAW($userId, $userMd5, $amount) { // Prepare the request data $requestData = array( 'sub_request' => "receive", - 't_uid' => bigintval($userId), + 't_uid' => bigintval($wdsId), 't_md5' => $userMd5, 'r_uid' => $_CONFIG['wernis_refid'], 'amount' => bigintval($amount), @@ -233,9 +233,15 @@ function WERNIS_EXECUTE_WITHDRAW($userId, $userMd5, $amount) { if ($return['status'] == "OK") { // All fine! $result = true; + + // Log the transfer + WERNIS_LOG_TRANSFER($wdsId, $amount, 'IN'); } else { // Status failture text WERNIS_STATUS_MESSAGE($return['message'], $return['status']); + + // Log the transfer + WERNIS_LOG_TRANSFER($wdsId, $amount, 'FAILED', $return['message'], $return['status']); } // Return result @@ -244,7 +250,7 @@ function WERNIS_EXECUTE_WITHDRAW($userId, $userMd5, $amount) { // Payout this amount -function WERNIS_EXECUTE_PAYOUT($userId, $userMd5, $amount) { +function WERNIS_EXECUTE_PAYOUT ($wdsId, $userMd5, $amount) { global $_CONFIG; $result = false; @@ -255,7 +261,7 @@ function WERNIS_EXECUTE_PAYOUT($userId, $userMd5, $amount) { // Prepare the request data $requestData = array( 'sub_request' => "send", - 't_uid' => bigintval($userId), + 't_uid' => bigintval($wdsId), 't_md5' => $userMd5, 'r_uid' => $_CONFIG['wernis_refid'], 'amount' => bigintval($amount), @@ -268,9 +274,15 @@ function WERNIS_EXECUTE_PAYOUT($userId, $userMd5, $amount) { if ($return['status'] == "OK") { // All fine! $result = true; + + // Log the transfer + WERNIS_LOG_TRANSFER($wdsId, $amount, 'OUT'); } else { // Status failture text WERNIS_STATUS_MESSAGE($return['message'], $return['status']); + + // Log the transfer + WERNIS_LOG_TRANSFER($wdsId, $amount, 'FAILED', $return['message'], $return['status']); } // Return result @@ -278,7 +290,7 @@ function WERNIS_EXECUTE_PAYOUT($userId, $userMd5, $amount) { } // Translate the status IN/OUT -function WERNIS_TRANSFER_STATUS($status) { +function WERNIS_TRANSFER_STATUS ($status) { // Default status $return = sprintf(WERNIS_STATUS_UNKNWOWN, $status); switch ($status) { @@ -289,11 +301,21 @@ function WERNIS_TRANSFER_STATUS($status) { case "OUT": // Payout $return = WERNIS_STATUS_PAYOUT; break; + + case "FAILED": // Payout + $return = WERNIS_STATUS_FAILED; + break; } // Return the status return $return; } +function WERNIS_LOG_TRANSFER ($wdsId, $amount, $type = 'FAILED', $message = null, $status = null) { + // Register this wernis movement + $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_wernis (`userid`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type`, `wernis_api_message`, `wernis_api_status`) VALUES(%d, %d, %d, UNIX_TIMESTAMP(), '%s', '%s', '%s')", + array($GLOBALS['userid'], bigintval($wdsId), bigintval($amount), $type, $message, $status), __FILE__, __LINE__); +} + // ?> diff --git a/inc/modules/admin/what-list_wernis.php b/inc/modules/admin/what-list_wernis.php index b9e0521e4d..0997be5da5 100644 --- a/inc/modules/admin/what-list_wernis.php +++ b/inc/modules/admin/what-list_wernis.php @@ -40,5 +40,37 @@ if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) { // Add description as navigation point ADD_DESCR("admin", basename(__FILE__)); +// Check for entries +$result = SQL_QUERY("SELECT id, userid, wernis_account, wernis_amount, wernis_timestamp, wernis_type, wernis_api_message, wernis_api_status FROM "._MYSQL_PREFIX."_user_wernis ORDER BY wernis_timestamp DESC, id DESC", + __FILE__, __LINE__); + +// Are there some entries to display? +if (SQL_NUMROWS($result) > 0) { + // List all entries + $OUT = ""; $SW = 2; + while ($content = SQL_FETCHARRAY($result)) { + // Translate some data and add color + $content['sw'] = $SW; + $content['link'] = ADMIN_USER_PROFILE_LINK($content['userid']); + $content['wernis_amount'] = TRANSLATE_COMMA($content['wernis_amount']); + $content['wernis_timestamp'] = MAKE_DATETIME($content['wernis_timestamp'], "2"); + $content['raw_type'] = strtolower($content['wernis_type']); + $content['wernis_type'] = WERNIS_TRANSFER_STATUS($content['wernis_type']); + + // Append it and switch colors + $OUT .= LOAD_TEMPLATE("admin_list_wernis_row", true, $content); + $SW = 3 - $SW; + } + + // Load main template + LOAD_TEMPLATE("admin_list_wernis_main", false, $OUT); +} else { + // Nothing to display! + LOAD_TEMPLATE("admin_setting_saved", false, WERNIS_ADMIN_NO_TRANSFERS); +} + +// Free the result +SQL_FREERESULT($result); + // ?> diff --git a/inc/modules/member/what-wernis.php b/inc/modules/member/what-wernis.php index e0cd9f4eb7..f6ef2687f6 100644 --- a/inc/modules/member/what-wernis.php +++ b/inc/modules/member/what-wernis.php @@ -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 @@ -204,10 +205,6 @@ if ((isset($_POST['ok'])) && (isset($_GET['mode']))) { $DEPTH = 0; ADD_POINTS_REFSYSTEM($GLOBALS['userid'], bigintval($_POST['amount']), false, 0, false, "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__); - // 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__); @@ -274,10 +271,6 @@ if ((isset($_POST['ok'])) && (isset($_GET['mode']))) { $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `used_points` = `used_points` + %d, `wernis_userid`=%d WHERE userid=%d LIMIT 1", array(bigintval($_POST['amount']), bigintval($_POST['wds66_id']), $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__); - // All done! LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_MEMBER_PAYOUT_DONE); return; diff --git a/templates/de/html/member/member_wernis_mode_list_row.tpl b/templates/de/html/member/member_wernis_mode_list_row.tpl index 24ad219252..fd7cc2c4b0 100644 --- a/templates/de/html/member/member_wernis_mode_list_row.tpl +++ b/templates/de/html/member/member_wernis_mode_list_row.tpl @@ -1,6 +1,6 @@ - $content[points] {!POINTS!} - $content[acc] - $content[stamp] - $content[status] + $content[points] {!POINTS!} + $content[acc] + $content[stamp] + $content[status] -- 2.30.2