X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-list_payouts.php;h=be043aceac4c6b3f2e5828de868aa42fd2436be8;hb=4f7df133f736da124e6f7bd02008b9093f736451;hp=9b21491ad153bc0d0ad79827b23228b8246841e7;hpb=09f5758c42a33a56bdd461c946ffe759a59c54aa;p=mailer.git diff --git a/inc/modules/admin/what-list_payouts.php b/inc/modules/admin/what-list_payouts.php index 9b21491ad1..be043aceac 100644 --- a/inc/modules/admin/what-list_payouts.php +++ b/inc/modules/admin/what-list_payouts.php @@ -14,12 +14,10 @@ * $Date:: $ * * $Tag:: 0.2.1-FINAL $ * * $Author:: $ * - * Needs to be in all Files and every File needs "svn propset * - * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009, 2010 by Mailer Developer Team * - * For more information visit: http://www.mxchange.org * + * Copyright (c) 2009 - 2012 by Mailer Developer Team * + * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -43,203 +41,220 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { } // END - if // Add description as navigation point -addMenuDescription('admin', __FILE__); +addYouAreHereLink('admin', __FILE__); -if (isGetRequestParameterSet(('pid'))) { +if (isGetRequestElementSet('pid')) { // First let's get the member's id - $result = SQL_QUERY_ESC("SELECT userid, target_account, payout_total, payout_timestamp, password FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `id`=%s LIMIT 1", - array(getRequestParameter('pid')), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT `userid`, `target_account`, `payout_total`, `payout_timestamp`, `password` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `id`=%s LIMIT 1", + array(getRequestElement('pid')), __FILE__, __LINE__); list($userid, $tuserid, $points, $tstamp, $tpass) = SQL_FETCHROW($result); SQL_FREERESULT($result); // Obtain some data - if (!isGetRequestParameterSet(('task')) && (!empty($userid)) && ($userid > 0)) { + if (!isGetRequestElementSet('task') && (!empty($userid)) && (isValidId($userid))) { // Get task id from database - $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `userid`=%s AND `task_type`='PAYOUT_REQUEST' AND task_created='".$tstamp."' LIMIT 1", - array(bigintval($userid)), __FILE__, __LINE__); - list($task) = SQL_FETCHROW($result); + $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `userid`=%s AND `task_type`='PAYOUT_REQUEST' AND `task_created`=%s LIMIT 1", + array(bigintval($userid), bigintval($tstamp)), __FILE__, __LINE__); + list($taskId) = SQL_FETCHROW($result); SQL_FREERESULT($result); - if (empty($task)) $task = '0'; - } elseif ((empty($userid)) || ($userid == '0')) { + if (empty($taskId)) $taskId = '0'; + } elseif (!isValidId($userid)) { // Cannot obtain member id! - loadTemplate('admin_settings_saved', false, getMessage('PAYOUT_FAILED_OBTAIN_USERID')); + displayMessage('{--ADMIN_PAYOUT_FAILED_OBTAIN_USERID--}'); } else { // Get task id from URL - $task = getRequestParameter('task'); + $taskId = getRequestElement('task'); } - if ((!empty($task)) && (!empty($userid)) && ($userid > 0)) { + if ((!empty($taskId)) && (!empty($userid)) && (isValidId($userid))) { // Load user's data if (!fetchUserData($userid)) { // Abort here because it is not valid! - debug_report_bug('No user account ' . $userid . ' found.'); + reportBug(__FILE__, __LINE__, 'No user account ' . $userid . ' found.'); } // END - if - if ((getRequestParameter('do') == 'accept') && (!empty(getUserData('email')))) { + if ((getRequestElement('do') == 'accept') && (getUserData('email') != '')) { // Ok, now we can output the form or execute accepting if (isFormSent()) { // Obtain payout type and other data $result = SQL_QUERY_ESC("SELECT `payout_id` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `id`=%s LIMIT 1", - array(bigintval(getRequestParameter('pid'))), __FILE__, __LINE__); + array(bigintval(getRequestElement('pid'))), __FILE__, __LINE__); + + // Load ptype (id) list($ptype) = SQL_FETCHROW($result); + + // Free result SQL_FREERESULT($result); if (!empty($ptype)) { // Obtain data from payout type - $result = SQL_QUERY_ESC("SELECT `from_account`, `from_pass`, `engine_url`, `engine_ret_ok`, `engine_ret_failed`, `pass_enc`, `allow_url` + $result = SQL_QUERY_ESC("SELECT + `from_account`, + `from_pass`, + `engine_url`, + `engine_ret_ok`, + `engine_ret_failed`, + `pass_enc`, + `allow_url` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1", array(bigintval($ptype)), __FILE__, __LINE__); - list($fuserid, $fpass, $eurl, $eok, $failed, $eenc, $allow) = SQL_FETCHROW($result); + + // Load data + $data = SQL_FETCHARRAY($result); + + // Free result SQL_FREERESULT($result); - if (!empty($eurl)) { + if (!empty($data['engine_url'])) { // Ok, run URL... - switch ($eenc) { + switch ($data['pass_enc']) { case 'md5': - $fpass = md5($fpass); + $data['from_pass'] = md5($data['from_pass']); $tpass = md5($tpass); break; case 'base64': - $fpass = base64_encode($fpass); + $data['from_pass'] = base64_encode($data['from_pass']); $tpass = base64_encode($tpass); break; - } + } // END - switch // Transfer variables... - $eval = "\$URL = \"".$eurl."\";"; - $reason = encodeString(getMessage('PAYOUT_REASON_PAYOUT'), false); - - // Run code... - // @TODO Do we need this time-consuming eval() here? - eval($eval); + $reason = encodeString(getMessage('ADMIN_PAYOUT_REASON'), FALSE); // Execute transfer - $ret = sendGetRequest($URL); + $ret = sendHttpGetRequest($data['engine_url']); } else { // No URL to run - $ret[0] = $eok; + $ret[0] = $data['engine_ret_ok']; } - if ($ret[0] == $eok) { + if ($ret[0] == $data['engine_ret_ok']) { // Clear task - if ($task > 0) { - runFilterChain('solve_task', $task); - } + if (isValidId($taskId)) { + runFilterChain('solve_task', $taskId); + } // END - if // Clear payout request SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_payouts` SET `status`='ACCEPTED' WHERE `id`=%s LIMIT 1", - array(bigintval(getRequestParameter('pid'))), __FILE__, __LINE__); + array(bigintval(getRequestElement('pid'))), __FILE__, __LINE__); // Send out mail - $message = loadEmailTemplate('member_payout_accepted', postRequestParameter('text'), $userid); + $message = loadEmailTemplate('member_payout_accepted', postRequestElement('text'), $userid); // Output message - if ($allow == 'Y') { + if ($data['allow_url'] == 'Y') { // Banner / Textlink request - loadTemplate('admin_settings_saved', false, getMessage('PAYOUT_BANNER_ACCEPTED_NOTIFIED')); + displayMessage('{--ADMIN_PAYOUT_BANNER_ACCEPTED_NOTIFIED--}'); } else { // Normal request - loadTemplate('admin_settings_saved', false, getMessage('PAYOUT_ACCEPTED_NOTIFIED')); + displayMessage('{--ADMIN_PAYOUT_ACCEPTED_NOTIFIED--}'); } // Finally send mail - sendEmail(getUserData('email'), getMessage('PAYOUT_ACCEPTED_SUBJECT'), $message); + sendEmail(getUserData('userid'), '{--MEMBER_PAYOUT_ACCEPTED_SUBJECT--}', $message); } else { // Something goes wrong... :-( - $content = implode("
", $ret); - loadTemplate('admin_payout_failed_transfer', false, $content); + $content = implode('
', $ret); + loadTemplate('admin_payout_failed_transfer', FALSE, $content); } } else { // Cannot load payout id - loadTemplate('admin_settings_saved', false, '
{--PAYOUT_FAILED_OBTAIN_PAYOUT_ID--}
'); + loadTemplate('admin_settings_unsaved', FALSE, '{--ADMIN_PAYOUT_FAILED_OBTAIN_PAYOUT_ID--}'); } } else { // Prepare content $content = array( - 'task' => $task, - 'pid' => bigintval(getRequestParameter('pid')), - 'user' => '' . translateGender(getUserData('gender')) . ' ' . getUserData('surname') . ' ' . getUserData('family') . '', + 'task' => $taskId, + 'pid' => bigintval(getRequestElement('pid')), + 'user' => '{%pipe,translateGender=' . getUserData('gender') . '%} ' . getUserData('surname') . ' ' . getUserData('family') . '', ); // Load template - loadTemplate('admin_payout_accept_form', false, $content); + loadTemplate('admin_payout_accept_form', FALSE, $content); } - } elseif ((getRequestParameter('do') == 'reject') && (!empty(getUserData('email')))) { + } elseif ((getRequestElement('do') == 'reject') && (getUserData('email') != '')) { // Ok, now we can output the form or execute rejecting if (isFormSent()) { - if ($task > 0) { + if (isValidId($taskId)) { // Clear task - runFilterChain('solve_task', $task); + runFilterChain('solve_task', $taskId); } // END - if // Clear payout request SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_payouts` SET `status`='REJECTED' WHERE `id`=%s LIMIT 1", - array(bigintval(getRequestParameter('pid'))), __FILE__, __LINE__); + array(bigintval(getRequestElement('pid'))), __FILE__, __LINE__); // Send out mail - $message = loadEmailTemplate('member_payout_rejected', postRequestParameter('text'), $userid); + $message = loadEmailTemplate('member_payout_rejected', postRequestElement('text'), $userid); // Output message - loadTemplate('admin_settings_saved', false, getMessage('PAYOUT_REJECTED_NOTIFIED')); + displayMessage('{--ADMIN_PAYOUT_REJECTED_NOTIFIED--}'); // Finally send mail - sendEmail(getUserData('email'), getMessage('PAYOUT_REJECTED_SUBJECT'), $message); + sendEmail(getUserData('userid'), '{--MEMBER_PAYOUT_REJECTED_SUBJECT--}', $message); } else { // Prepare content $content = array( - 'task' => $task, - 'pid' => bigintval(getRequestParameter('pid')), - 'user' => '' . translateGender(getUserData('gender')) . ' ' . getUserData('surname') . ' ' . getUserData('family') . '', + 'task' => $taskId, + 'pid' => bigintval(getRequestElement('pid')), + 'user' => '{%pipe,translateGender=' . getUserData('gender') . '%} ' . getUserData('surname') . ' ' . getUserData('family') . '', ); // Load template - loadTemplate('admin_payout_reject_form', false, $content); + loadTemplate('admin_payout_reject_form', FALSE, $content); } } else { // Cannot load user data - loadTemplate('admin_settings_saved', false, getMessage('PAYOUT_FAILED_OBTAIN_USERDATA')); + displayMessage('{--ADMIN_PAYOUT_FAILED_OBTAIN_USERDATA--}'); } - } elseif ((empty($task)) || ($task == '0')) { + } elseif (!isValidId($taskId)) { // Failed loading task id - loadTemplate('admin_settings_saved', false, getMessage('PAYOUT_FAILED_OBTAIN_TASK_ID')); + displayMessage('{--ADMIN_PAYOUT_FAILED_OBTAIN_TASK_ID--}'); } } else { - if (getRequestParameter('do') == 'delete') { + if (getRequestElement('do') == 'delete') { // Delete all requests $result = SQL_QUERY("TRUNCATE `{?_MYSQL_PREFIX?}_user_payouts`", __FILE__, __LINE__); } // END - if // Search for payouts - $result = SQL_QUERY("SELECT - p.id, p.userid, p.payout_total, p.target_account, - p.target_bank, t.type, p.payout_timestamp, p.status, - t.allow_url AS allow, p.target_url AS url, p.link_text AS alt, - p.banner_url AS banner + $result = SQL_QUERY('SELECT + `p`.`id`, + `p`.`userid`, + `p`.`payout_total`, + `p`.`target_account`, + `p`.`target_bank`, + `t`.`type`, + `p`.`payout_timestamp`, + `p`.`status`, + `t`.`allow_url` AS `allow`, + `p`.`target_url` AS `url`, + `p`.`link_text` AS `alt`, + `p`.`banner_url` AS `banner` FROM - `{?_MYSQL_PREFIX?}_user_payouts` AS p + `{?_MYSQL_PREFIX?}_user_payouts` AS `p` LEFT JOIN - `{?_MYSQL_PREFIX?}_payout_types` AS t + `{?_MYSQL_PREFIX?}_payout_types` AS `t` ON - p.payout_id=t.id + `p`.`payout_id`=`t`.`id` ORDER BY - p.payout_timestamp DESC", __FILE__, __LINE__); + `p`.`payout_timestamp` DESC', __FILE__, __LINE__); - if (SQL_NUMROWS($result) > 0) { + if (!SQL_HASZERONUMS($result)) { // List found payouts - $OUT = ''; $SW = 2; + $OUT = ''; while ($content = SQL_FETCHARRAY($result)) { if ($content['status'] == 'NEW') { // Generate links for direct accepting and rejecting - $content['status'] = '{--PAYOUT_ACCEPT_PAYOUT--} | {--PAYOUT_REJECT_PAYOUT--}'; + $content['status'] = '{--ADMIN_PAYOUT_ACCEPT_PAYOUT--}|{--ADMIN_PAYOUT_REJECT_PAYOUT--}'; } else { // Translate status - $content['status'] = getMessage('PAYOUT_STATUS_'.strtoupper($content['status']).''); - $content['status'] = '
' . $content['status'] . '
'; + $content['status'] = translatePayoutStatus($content['status']); } // Nothing entered must be secured in member/what-payputs.php ! @@ -247,44 +262,31 @@ ORDER BY // Banner/Textlink views/clicks request if (!empty($content['banner'])) { // Load template for the banner - $content['target_account'] = loadTemplate('admin_list_payouts_banner', true, $content); + $content['target_account'] = loadTemplate('admin_list_payouts_banner', TRUE, $content); } else { // Textlink - $content['target_account'] = loadTemplate('admin_list_payouts_txt', true, $content); + $content['target_account'] = loadTemplate('admin_list_payouts_txt', TRUE, $content); } // Admins can addionally test the URL for framekillers $content['target_bank'] = '{--CLICK_HERE--}'; - } else { - // e-currency payout request - if (empty($content['target_account'])) $content['target_account'] = '---'; - if (empty($content['target_bank'])) $content['target_bank'] = '---'; - } + } // END - if - // Remember data in array for the template - $content = array( - 'sw' => $SW, - 'ulink' => generateUserProfileLink($content['userid']), - 'ptype' => translateComma($content['payout_total']) . ' ' . $content['type'], - 'account' => $content['target_account'], - 'bank' => $content['target_bank'], - 'tstamp' => generateDateTime($content['payout_timestamp'], 2), - 'status' => $content['status'], - ); + // Add/Translate some data + $content['payout_timestamp'] = generateDateTime($content['payout_timestamp'], 2); // Add row and switch color - $OUT .= loadTemplate('admin_list_payouts_row', true, $content); - $SW = 3 - $SW; + $OUT .= loadTemplate('admin_list_payouts_row', TRUE, $content); } // END - while // Free memory SQL_FREERESULT($result); // Load final template - loadTemplate('admin_list_payouts', false, $OUT); + loadTemplate('admin_list_payouts', FALSE, $OUT); } else { // No payout requests are sent so far - loadTemplate('admin_settings_saved', false, getMessage('PAYOUT_ADMIN_NO_REQUESTS_FOUND')); + displayMessage('{--ADMIN_PAYOUT_NO_REQUESTS_FOUND--}'); } }