// Handle earning id
function doMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') {
- // Does the user already have this earning?
- $result = SQL_QUERY_ESC("SELECT COUNT(`id`) AS `cnt` FROM `{?_MYSQL_PREFIX?}_user_earning` WHERE `earning_id`=%s AND `earning_userid`=%s LIMIT 1",
- array(
- bigintval($earningId),
- getMemberId()
- ), __FUNCTION__, __LINE__);
-
- // Get the count
- list($count) = SQL_FETCHROW($result);
-
// Does the user have this?
- if ($count == 1) {
+ if (countSumTotalData(bigintval($earningId), 'user_earning', 'id', 'earning_id', TRUE, ' AND `earning_userid`=' . getMemberId()) == 1) {
// Then update it
$status = updateMemberEarning($earningId, $dailyAmount, $isActive);
} else {
$status = insertMemberEarning($earningId, $dailyAmount, $isActive);
}
- // Free result
- SQL_FREERESULT($result);
-
// Return status
return $status;
}
// Order number placed, is he also logged in?
if (isMember()) {
// Ok, test passed... :)
- $result = SQL_QUERY_ESC("SELECT `subject`, `url` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s AND `sender`=%s AND `data_type`='TEMP' LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT `url` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s AND `sender`=%s AND `data_type`='TEMP' LIMIT 1",
array(bigintval(getRequestElement('order')), getMemberId()), __FILE__, __LINE__);
// Finally is the entry valid?
if (SQL_NUMROWS($result) == 1) {
// Load subject and URL (but forwhat do we need the subject line here???
- list($sub, $url) = SQL_FETCHROW($result);
+ list($url) = SQL_FETCHROW($result);
// This fixes a white page
setPostRequestElement('url', $url);
$total = countSumTotalData('Y', 'refbanner', 'id', 'visible', TRUE);
// Total views and clicks
-$result = SQL_QUERY("SELECT SUM(`counter`) AS `cnt`, SUM(`clicks`) AS `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
+$result = SQL_QUERY("SELECT SUM(`counter`) AS `views`, SUM(`clicks`) AS `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
list($views, $clicks) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
foreach ($levelArray as $refid) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',level=' . $level . ',refid=' . $refid);
// Query the user_refs table
- list($count) = SQL_FETCHROW(SQL_QUERY_ESC('SELECT COUNT(`id`) AS `count` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level`=%s AND `refid`=%s LIMIT 1',
- array(
- $userid,
- $level,
- $refid
- ), __FUNCTION__, __LINE__));
+ $count = countSumTotalData(bigintval($userid), 'user_refs', 'id', 'userid', TRUE, ' AND `level`=' . bigintval($level) . ' AND `refid`=' . bigintval($refid));
// Is there no entry?
if ($count == 0) {