if (SQL_HASZERONUMS($result_ref)) {
// Add userid and his ref count to table
$result_ref = SQL_QUERY_ESC("SELECT
- SUM(p.`points`) AS `points`
+ SUM(`p`.`points`) AS `points`
FROM
- `{?_MYSQL_PREFIX?}_user_points` AS p
+ `{?_MYSQL_PREFIX?}_user_points` AS `p`
LEFT JOIN
- `{?_MYSQL_PREFIX?}_user_data` AS d
+ `{?_MYSQL_PREFIX?}_user_data` AS `d`
ON
p.userid=d.userid
WHERE
- d.`status`='CONFIRMED'
+ `d`.`status`='CONFIRMED'
" . runFilterChain('user_exclusion_sql', ' ') . " AND
- d.`max_mails` > 0 AND
- d.`mails_confirmed` >= {?ref_payout?} AND
- p.`ref_depth`=1 AND
- p.`points` > 0 AND
- d.`userid`=%s",
+ `d`.`max_mails` > 0 AND
+ `d`.`mails_confirmed` >= {?ref_payout?} AND
+ `p`.`ref_depth`=1 AND
+ `p`.`points` > 0 AND
+ `d`.`userid`=%s",
array(bigintval($content['userid'])), __FUNCTION__, __LINE__);
// Get points
// And load only limited users
$result = SQL_QUERY_ESC("SELECT DISTINCT
- u.`userid`,
- u.`refs`,
- u.`curr_points`,
- rd.`min_users`,
- rd.`min_prices`
+ `u`.`userid`,
+ `u`.`refs`,
+ `u`.`curr_points`,
+ `rd`.`min_users`,
+ `rd`.`min_prices`
FROM
- `{?_MYSQL_PREFIX?}_rallye_users` AS u
+ `{?_MYSQL_PREFIX?}_rallye_users` AS `u`
INNER JOIN
- `{?_MYSQL_PREFIX?}_refsystem` AS r
+ `{?_MYSQL_PREFIX?}_refsystem` AS `r`
ON
u.userid=r.userid
INNER JOIN
- `{?_MYSQL_PREFIX?}_rallye_data` AS rd
+ `{?_MYSQL_PREFIX?}_rallye_data` AS `rd`
ON
- u.`rallye_id`=rd.`id`
+ `u`.`rallye_id`=r`d`.`id`
WHERE
- u.`rallye_id`=%s AND
- r.`counter` > 0
+ `u`.`rallye_id`=%s AND
+ `r`.`counter` > 0
ORDER BY
u.refs DESC",
array(bigintval($rallye)), __FUNCTION__, __LINE__);
// Points of ref's
$result_ref = SQL_QUERY_ESC("SELECT
- p.`points`
+ `p`.`points`
FROM
- `{?_MYSQL_PREFIX?}_user_points` AS p
+ `{?_MYSQL_PREFIX?}_user_points` AS `p`
LEFT JOIN
- `{?_MYSQL_PREFIX?}_user_data` AS d
+ `{?_MYSQL_PREFIX?}_user_data` AS `d`
ON
- p.`userid`=d.`userid`
+ `p`.`userid`=`d`.`userid`
WHERE
- d.`userid`=%s AND
- d.`status`='CONFIRMED'
+ `d`.`userid`=%s AND
+ `d`.`status`='CONFIRMED'
" . runFilterChain('user_exclusion_sql', ' ') . " AND
- p.`ref_depth`=1 AND
- d.`max_mails` > 0 AND
- d.`mails_confirmed` >= {?ref_payout?}
+ `p`.`ref_depth`=1 AND
+ `d`.`max_mails` > 0 AND
+ `d`.`mails_confirmed` >= {?ref_payout?}
LIMIT 1",
array(bigintval($row['userid'])), __FUNCTION__, __LINE__);
// Allow valid and active users with at least one ref
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'rallyeId=' . $rallyeId . ',userid=' . $userid . ',ref=' . $prices['ref'][$key] . ',cpoints=' . $prices['cpoints'][$key]);
- if ((isValidUserId($userid)) && ($prices['ref'][$key] > 0) && ($active == 1) && ($prices['cpoints'][$key] > 0)) {
+ if ((isValidId($userid)) && ($prices['ref'][$key] > 0) && ($active == 1) && ($prices['cpoints'][$key] > 0)) {
$GLOBALS[__FUNCTION__][$rallyeId]++;
} // END - if
} // END - foreach
$prices['active'][$key] = $active;
// Allow valid and active users with at least one ref to get points
- if ((isValidUserId($userid)) && ($prices['ref'][$key] > 0) && ($active == 1) && ($prices['cpoints'][$key] > 0)) {
+ if ((isValidId($userid)) && ($prices['ref'][$key] > 0) && ($active == 1) && ($prices['cpoints'][$key] > 0)) {
$total++;
} // END - if
} // END - foreach
// Run array through (by userid is the most important 2nd-level-array)
foreach ($prices['userid'] as $key => $userid) {
// Allow valid and active users with at least one ref to get points
- if ((isValidUserId($userid)) && ($prices['ref'][$key] > 0) && ($prices['active'][$key] == 1) && ($prices['cpoints'][$key] > 0)) {
+ if ((isValidId($userid)) && ($prices['ref'][$key] > 0) && ($prices['active'][$key] == 1) && ($prices['cpoints'][$key] > 0)) {
// Transfer data to array for the mail template
$content['level'] = $prices['level'][$key];
$content['points'] = $prices['points'][$key];
// Points of ref's
$result_ref = SQL_QUERY_ESC("SELECT
- SUM(p.`points`) AS `points`
+ SUM(`p`.`points`) AS `points`
FROM
- `{?_MYSQL_PREFIX?}_user_points` AS p
+ `{?_MYSQL_PREFIX?}_user_points` AS `p`
LEFT JOIN
- `{?_MYSQL_PREFIX?}_user_data` AS d
+ `{?_MYSQL_PREFIX?}_user_data` AS `d`
ON
- p.`userid`=d.`userid`
+ `p`.`userid`=`d`.`userid`
WHERE
- d.`status`='CONFIRMED'
+ `d`.`status`='CONFIRMED'
" . runFilterChain('user_exclusion_sql', ' ' ) . " AND
- d.`max_mails` > 0 AND
- d.`mails_confirmed` >= {?ref_payout?} AND
- p.`ref_depth`=1 AND
- p.`points` > 0 AND
- d.`userid`=%s
+ `d`.`max_mails` > 0 AND
+ `d`.`mails_confirmed` >= {?ref_payout?} AND
+ `p`.`ref_depth`=1 AND
+ `p`.`points` > 0 AND
+ `d`.`userid`=%s
LIMIT 1",
array(bigintval($content['userid'])), __FUNCTION__, __LINE__);
$result_ref = SQL_QUERY_ESC("SELECT
SUM(s.counter) AS `cnt`
FROM
- `{?_MYSQL_PREFIX?}_refsystem` AS s
+ `{?_MYSQL_PREFIX?}_refsystem` AS `s`
LEFT JOIN
- `{?_MYSQL_PREFIX?}_refdepths` AS d
+ `{?_MYSQL_PREFIX?}_refdepths` AS `d`
ON
- s.level=d.level
+ s.`level`=`d`.`level`
WHERE
- s.userid=%s AND
- s.level=1",
+ s.`userid`=%s AND
+ s.`level`=1",
array(
bigintval($userid)
), __FUNCTION__, __LINE__);