From b943cf0cd2dd8ef0f36283fbb288f6bd2bed6d31 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 29 Jan 2011 17:52:25 +0000 Subject: [PATCH] New wrapper function getTransferCode() introduced, double-quotes to single-quotes converted --- inc/libs/transfer_functions.php | 16 ++++++++++++++++ inc/modules/member/what-transfer.php | 12 ++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/inc/libs/transfer_functions.php b/inc/libs/transfer_functions.php index e91581f03f..ea23ae765c 100644 --- a/inc/libs/transfer_functions.php +++ b/inc/libs/transfer_functions.php @@ -80,5 +80,21 @@ function autoPurgeTransfers ($max, $age) { } // END - if } +// --------------------------------------------------------------------------- +// Wrapper functions +// --------------------------------------------------------------------------- + +// Wrapper function for transfer_code +function getTransferCode () { + // Is cache set? + if (!isset($GLOBALS[__FUNCTION__])) { + // Get config entry + $GLOBALS[__FUNCTION__] = getConfig('transfer_code'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + // [EOF] ?> diff --git a/inc/modules/member/what-transfer.php b/inc/modules/member/what-transfer.php index 10cc4218b6..0bdd10de82 100644 --- a/inc/modules/member/what-transfer.php +++ b/inc/modules/member/what-transfer.php @@ -71,9 +71,9 @@ switch ($mode) { if (isFormSent()) { // Add new transfer - if (getConfig('transfer_code') > 0) { + if (getTransferCode() > 0) { // Check for code - $code = generateRandomCode(getConfig('transfer_code'), postRequestParameter('code_chk'), getMemberId(), $content['max_transferable']); + $code = generateRandomCode(getTransferCode(), postRequestParameter('code_chk'), getMemberId(), $content['max_transferable']); $valid_code = ($code == postRequestParameter('code')); } else { // Zero length (= disabled) is always valid! @@ -250,12 +250,12 @@ switch ($mode) { $content['userid_selection'] = $OUT; // Generate Code - if (getConfig('transfer_code') > 0) { + if (getTransferCode() > 0) { // Generate random number $rand = mt_rand(0, 99999); // Generate CAPTCHA code - $code = generateRandomCode(getConfig('transfer_code'), $rand, getMemberId(), $content['max_transferable']); + $code = generateRandomCode(getTransferCode(), $rand, getMemberId(), $content['max_transferable']); // Generate image (HTML code) $img = generateImageOrCode($code, false); @@ -289,14 +289,14 @@ switch ($mode) { $nothingMessage = ''; switch ($mode) { case 'list_in': - $sql = "SELECT `trans_id`, `from_userid` AS party_userid, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `userid`=%s ORDER BY `time_trans` DESC LIMIT {?transfer_max?}"; + $sql = 'SELECT `trans_id`, `from_userid` AS party_userid, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `userid`=%s ORDER BY `time_trans` DESC LIMIT {?transfer_max?}'; $nothingMessage = '{--TRANSFER_NO_INCOMING_TRANSFERS--}'; $content['balance'] = '{--TRANSFER_TOTAL_INCOMING--}'; $content['title'] = '{--TRANSFER_LIST_INCOMING--}'; break; case 'list_out': - $sql = "SELECT `trans_id`, `to_userid` AS party_userid, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `userid`=%s ORDER BY `time_trans` DESC LIMIT {?transfer_max?}"; + $sql = 'SELECT `trans_id`, `to_userid` AS party_userid, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `userid`=%s ORDER BY `time_trans` DESC LIMIT {?transfer_max?}'; $nothingMessage = '{--TRANSFER_NO_OUTGOING_TRANSFERS--}'; $content['balance'] = '{--TRANSFER_TOTAL_OUTGOING--}'; $content['title'] = '{--TRANSFER_LIST_OUTGOING--}'; -- 2.39.5