* $Author:: $ *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team *
+ * Copyright (c) 2009 - 2015 by Mailer Developer Team *
* For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
$valid_code = ($code == postRequestElement('code'));
} else {
// Zero length (= disabled) is always valid!
- $valid_code = true;
+ $valid_code = TRUE;
}
// Test password
$valid_reason = (isPostRequestElementSet('reason'));
// Test if a recipient is selected
- $valid_recipient = isValidUserId(postRequestElement('to_userid'));
+ $valid_recipient = isValidId(postRequestElement('to_userid'));
// Re-check receivers and own personal data
- $result = SQL_QUERY_ESC("SELECT `userid`,`gender`,`surname`,`family`,`email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid` IN ('%s','%s') AND `status`='CONFIRMED'" . runFilterChain('user_exclusion_sql', ' ') . " LIMIT 2",
+ $result = sqlQueryEscaped("SELECT `userid`, `gender`, `surname`, `family`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid` IN ('%s','%s') AND `status`='CONFIRMED'" . runFilterChain('user_exclusion_sql', ' ') . " LIMIT 2",
array(
getMemberId(),
bigintval(postRequestElement('to_userid'))
), __FILE__, __LINE__);
// Is there two entries?
- $valid_data = (SQL_NUMROWS($result) == 2);
+ $valid_data = (sqlNumRows($result) == 2);
// Final check if all is fine
if ($valid_code && $valid_data && $valid_pass && $valid_amount && $valid_reason && $valid_recipient) {
// Let's start the transfer and load user data
- $content['sender'] = SQL_FETCHARRAY($result);
- $content['recipient'] = SQL_FETCHARRAY($result);
+ $content['sender'] = sqlFetchArray($result);
+ $content['recipient'] = sqlFetchArray($result);
// Is the nickname extension not installed?
if (!isExtensionActive('nickname')) {
$content['trans_id'] = bigintval(generateRandomCode('10', getRandomTan(), getMemberId(), postRequestElement('reason')));
// Add entries to both tables
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_transfers_in` (`userid`,`from_userid`,`points`,`reason`,`time_trans`,`trans_id`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(),%s)",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_transfers_in` (`userid`, `from_userid`, `points`, `reason`, `time_trans`, `trans_id`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(),%s)",
array(
bigintval(postRequestElement('to_userid')),
getMemberId(),
postRequestElement('reason'),
$content['trans_id']
), __FILE__, __LINE__);
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_transfers_out` (`userid`,`to_userid`,`points`,`reason`,`time_trans`,`trans_id`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(),%s)",
+ sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_transfers_out` (`userid`, `to_userid`, `points`, `reason`, `time_trans`, `trans_id`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(),%s)",
array(
getMemberId(),
bigintval(postRequestElement('to_userid')),
sendEmail($content['sender']['userid'], '{--TRANSFER_MEMBER_SENDER_SUBJECT--}' . ': ' . $RECIPIENT, $message);
// At last send admin mail(s)
- $adminSubject = sprintf("%s (%s->%s)", '{--ADMIN_TRANSFER_SUBJECT--}', $SENDER, $RECIPIENT);
+ $adminSubject = sprintf('%s (%s->%s)', '{--ADMIN_TRANSFER_SUBJECT--}', $SENDER, $RECIPIENT);
sendAdminNotification($adminSubject, 'admin_transfer_points', $content);
// Transfer is completed
displayMessage('<div>{--MEMBER_TRANSFER_COMPLETED--}' . '</div><div><a href="{%url=modules.php?module=login&what=transfer%}">{--MEMBER_TRANSFER_CONTINUE_OVERVIEW--}</a></div>');
- } elseif ($valid_code === false) {
+ } elseif ($valid_code === FALSE) {
// Invalid Touring code!
- loadTemplate('admin_settings_unsaved', false, '{--MEMBER_TRANSFER_INVALID_CODE--}');
+ displayErrorMessage('{--MEMBER_TRANSFER_INVALID_CODE--}');
unsetPostRequestElement('ok');
- } elseif ($valid_pass === false) {
+ } elseif ($valid_pass === FALSE) {
// Wrong password entered
- loadTemplate('admin_settings_unsaved', false, '{--MEMBER_TRANSFER_INVALID_PASSWORD--}');
+ displayErrorMessage('{--MEMBER_TRANSFER_INVALID_PASSWORD--}');
unsetPostRequestElement('ok');
- } elseif ($valid_amount === false) {
+ } elseif ($valid_amount === FALSE) {
// Too much points entered
- loadTemplate('admin_settings_unsaved', false, '{--MEMBER_TRANSFER_INVALID_POINTS--}');
+ displayErrorMessage('{--MEMBER_TRANSFER_INVALID_POINTS--}');
unsetPostRequestElement('ok');
- } elseif ($valid_reason === false) {
+ } elseif ($valid_reason === FALSE) {
// No transfer reason entered
- loadTemplate('admin_settings_unsaved', false, '{--MEMBER_TRANSFER_INVALID_REASON--}');
+ displayErrorMessage('{--MEMBER_TRANSFER_INVALID_REASON--}');
unsetPostRequestElement('ok');
- } elseif ($valid_recipient === false) {
+ } elseif ($valid_recipient === FALSE) {
// No recipient selected
- loadTemplate('admin_settings_unsaved', false, '{--MEMBER_TRANSFER_INVALID_RECIPIENT--}');
+ displayErrorMessage('{--MEMBER_TRANSFER_INVALID_RECIPIENT--}');
unsetPostRequestElement('ok');
- } elseif ($valid_data === false) {
+ } elseif ($valid_data === FALSE) {
// No recipient/sender selected
- loadTemplate('admin_settings_unsaved', false, '{--MEMBER_TRANSFER_INVALID_DATA--}');
+ displayErrorMessage('{--MEMBER_TRANSFER_INVALID_DATA--}');
unsetPostRequestElement('ok');
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} // END - if
if (!isFormSent()) {
// Load member list
- $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED'" . runFilterChain('user_exclusion_sql', ' ') . " AND `opt_in`='Y' AND `userid` != '%s' ORDER BY `userid` ASC",
+ $result = sqlQueryEscaped("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED'" . runFilterChain('user_exclusion_sql', ' ') . " AND `opt_in`='Y' AND `userid` != '%s' ORDER BY `userid` ASC",
array(getMemberId()), __FILE__, __LINE__);
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNumRows($result)) {
// Load list
$OUT = '<select name="to_userid" size="1" class="form_select">
<option value="0">{--SELECT_NONE--}</option>';
- while (list($userid) = SQL_FETCHROW($result)) {
+ while (list($userid) = sqlFetchRow($result)) {
$OUT .= ' <option value="' . $userid . '"';
if ((isPostRequestElementSet('to_userid')) && (postRequestElement('to_userid') == $userid)) {
$OUT .= ' selected="selected"';
$content['to_disabled'] = '';
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// No one else is opt-in
- $OUT = displayMessage('{--MEMBER_TRANSFER_NO_ONE_ELSE_OPT_IN--}', true);
+ $OUT = returnMessage('{--MEMBER_TRANSFER_NO_ONE_ELSE_OPT_IN--}');
$content['to_disabled'] = ' disabled="disabled"';
}
$code = generateRandomCode(getTransferCode(), $rand, getMemberId(), $content['max_transferable']);
// Generate image (HTML code)
- $img = generateImageOrCode($code, false);
+ $img = generateImageOrCode($code, FALSE);
// Add all and hidden field
$content['captcha_code'] = '<input type="hidden" name="code_chk" value="' . $rand . '" /><input type="text" name="code" class="form_field" size="5" maxlength="7"' . $content['to_disabled'] . ' /> ' . $img;
} else {
$code = '00000';
- $content['captcha_code'] = displayMessage('{--MEMBER_TRANSFER_NO_CODE--}', true);
+ $content['captcha_code'] = returnMessage('{--MEMBER_TRANSFER_NO_CODE--}');
}
// Init points/reason
} // END - if
// Output form
- loadTemplate('member_transfer_new', false, $content);
+ loadTemplate('member_transfer_new', FALSE, $content);
} // END - if
break;
$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 = '{--MEMBER_TRANSFER_NO_INCOMING_TRANSFERS--}';
$content['balance'] = '{--MEMBER_TRANSFER_TOTAL_INCOMING--}';
$content['title'] = '{--MEMBER_LIST_INCOMING_TRANSFER_TITLE--}';
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 = '{--MEMBER_TRANSFER_NO_OUTGOING_TRANSFERS--}';
$content['balance'] = '{--TRANSFER_TOTAL_OUTGOING--}';
$content['title'] = '{--MEMBER_LIST_OUTGOING_TRANSFER_TITLE--}';
// Run the SQL command and set total points to zero
$totalPoints = '0';
- $result = SQL_QUERY_ESC($sql, array(getMemberId()), __FILE__, __LINE__);
+ $result = sqlQueryEscaped($sql, array(getMemberId()), __FILE__, __LINE__);
// Are there entries?
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNumRows($result)) {
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Rewrite points, out is subtracted
if ($type == 'OUT') {
$content['points'] = $content['points'] * -1;
$$content['time_trans'] = generateDateTime($content['time_trans'], 3);
// Load row template
- $OUT .= loadTemplate('member_transfer_row2', true, $content);
+ $OUT .= loadTemplate('member_transfer_row2', TRUE, $content);
// Add points and switch color
$totalPoints += $content['points'];
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
} else {
// Nothing for in or out
$OUT = '<tr>
<td colspan="5" align="center" class="bottom">
- ' . displayMessage($nothingMessage, true) . '
+ ' . displayMessage($nothingMessage, TRUE) . '
</td>
</tr>';
}
$content['total_points'] = $totalPoints;
// Load final template
- loadTemplate('member_transfer_list', false, $content);
+ loadTemplate('member_transfer_list', FALSE, $content);
break;
case 'list_all': // List all transactions
*/
// First of all create the per-user temporary table
- $result = SQL_QUERY_ESC("CREATE TEMPORARY TABLE `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (
+ $result = sqlQueryEscaped("CREATE TEMPORARY TABLE `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (
`trans_id` VARCHAR(12) NOT NULL DEFAULT '',
`party_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
`points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
) ENGINE = HEAP COMMENT = 'Temporary transfer table'", array(getMemberId()), __FILE__, __LINE__);
// Let's begin with the incoming list
- $result = SQL_QUERY_ESC("SELECT `trans_id`,`from_userid`,`points`,`reason`,`time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `userid`=%s ORDER BY `id` ASC LIMIT {?transfer_max?}",
+ $result = sqlQueryEscaped("SELECT `trans_id`, `from_userid`, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `userid`=%s ORDER BY `id` ASC LIMIT {?transfer_max?}",
array(getMemberId()), __FILE__, __LINE__);
- while ($content = SQL_FETCHROW($result)) {
+ while ($content = sqlFetchRow($result)) {
array_push($content, 'IN');
$content = implode("','", $content);
- $res_temp = SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (`trans_id`,`party_userid`,`points`,`reason`,`time_trans`,`trans_type`) VALUES ('" . $content . "')", array(getMemberId()), __FILE__, __LINE__);
+ $res_temp = sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (`trans_id`, `party_userid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('" . $content . "')", array(getMemberId()), __FILE__, __LINE__);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// As the last table transfer data from outgoing table to temporary
- $result = SQL_QUERY_ESC("SELECT `trans_id`,`to_userid`,`points`,`reason`,`time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `userid`=%s ORDER BY `id` LIMIT {?transfer_max?}",
+ $result = sqlQueryEscaped("SELECT `trans_id`, `to_userid`, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `userid`=%s ORDER BY `id` LIMIT {?transfer_max?}",
array(getMemberId()), __FILE__, __LINE__);
- while ($content = SQL_FETCHROW($result)) {
+ while ($content = sqlFetchRow($result)) {
array_push($content, 'OUT');
$content = implode("','", $content);
- $res_temp = SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (`trans_id`,`party_userid`,`points`,`reason`,`time_trans`,`trans_type`) VALUES ('" . $content . "')", array(getMemberId()), __FILE__, __LINE__);
+ $res_temp = sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (`trans_id`, `party_userid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('" . $content . "')", array(getMemberId()), __FILE__, __LINE__);
} // END - while
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Search for entries
- $result = SQL_QUERY_ESC("SELECT `party_userid`,`trans_id`,`points`,`reason`,`time_trans`,`trans_type` FROM `{?_MYSQL_PREFIX?}_%s_transfers_tmp` ORDER BY `time_trans` DESC",
+ $result = sqlQueryEscaped("SELECT `party_userid`, `trans_id`, `points`, `reason`, `time_trans`, `trans_type` FROM `{?_MYSQL_PREFIX?}_%s_transfers_tmp` ORDER BY `time_trans` DESC",
array(getMemberId()), __FILE__, __LINE__);
$total = '0';
- if (!SQL_HASZERONUMS($result)) {
+ if (!ifSqlHasZeroNumRows($result)) {
// Output rows
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($content = sqlFetchArray($result)) {
// Rewrite points if OUT
if ($content['trans_type'] == 'OUT') {
$content['points'] = $content['points'] * -1;
$content['time'] = generateDateTime($content['time_trans'], 3);
// Load row template
- $OUT .= loadTemplate('member_transfer_row', true, $content);
+ $OUT .= loadTemplate('member_transfer_row', TRUE, $content);
// Add points and switch color
$total += $content['points'];
// Nothing for in and out
$OUT = '<tr>
<td colspan="5" align="center" class="bottom">
- ' . displayMessage('{--TRANSFER_NO_INOUT_TRANSFERS--}', true) . '
+ ' . displayMessage('{--TRANSFER_NO_INOUT_TRANSFERS--}', TRUE) . '
</td>
</tr>';
}
// Free memory
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// ... and add them to a constant for the template
- $content['rows'] = $OUT;
+ $content['rows'] = $OUT;
// Remeber total amount
$content['total_points'] = $total;
$content['balance'] = '{--TRANSFER_TOTAL_BALANCE--}';
// At the end we don't need a temporary table in memory
- $result = SQL_QUERY_ESC("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_%s_transfers_tmp`", array(getMemberId()), __FILE__, __LINE__);
+ $result = sqlQueryEscaped("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_%s_transfers_tmp`", array(getMemberId()), __FILE__, __LINE__);
// Load final template
- loadTemplate('member_transfer_list', false, $content);
+ loadTemplate('member_transfer_list', FALSE, $content);
// Free some memory...
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
break;
default: // Overview page
// Check incoming transfers
- $totalIn = countSumTotalData(getMemberId(), 'user_transfers_in', 'id', 'userid', true);
+ $totalIn = countSumTotalData(getMemberId(), 'user_transfers_in', 'id', 'userid', TRUE);
$content['in_link'] = $totalIn;
if ($totalIn > 0) {
$content['in_link'] = '<a href="{%url=modules.php?module=login&what=transfer&do=list_in%}">' . $totalIn . '</a>';
} // END - if
// Check outgoing transfers
- $totalOut = countSumTotalData(getMemberId(), 'user_transfers_out', 'id', 'userid', true);
+ $totalOut = countSumTotalData(getMemberId(), 'user_transfers_out', 'id', 'userid', TRUE);
$content['out_link'] = $totalOut;
if ($totalOut > 0) {
if (isFormSent()) {
// Save settings
- SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `opt_in`='%s' WHERE `userid`=%s LIMIT 1",
+ sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `opt_in`='%s' WHERE `userid`=%s LIMIT 1",
array(postRequestElement('opt_in'), getMemberId()), __FILE__, __LINE__);
// "Settings saved..."
} // END - switch
// Check for latest out-transfers
- $result = SQL_QUERY_ESC("SELECT
+ $result = sqlQueryEscaped("SELECT
`time_trans`
FROM
`{?_MYSQL_PREFIX?}_user_transfers_out`
), __FILE__, __LINE__);
// Is there an entry?
- if (SQL_NUMROWS($result) == 1) {
+ if (sqlNumRows($result) == 1) {
// Load newest transaction
- list($newest) = SQL_FETCHROW($result);
+ list($newest) = sqlFetchRow($result);
$content['settings'] = '{%message,MEMBER_TRANSFER_LATEST_IS=' . generateDateTime($newest, '3') . '%}';
} else {
// Load template
- $content['settings'] = loadTemplate('member_transfer_settings', true, $content);
+ $content['settings'] = loadTemplate('member_transfer_settings', TRUE, $content);
}
// Free result
- SQL_FREERESULT($result);
+ sqlFreeResult($result);
// Load template
- loadTemplate('member_transfer_overview', false, $content);
+ loadTemplate('member_transfer_overview', FALSE, $content);
break;
} // END - switch