// @DEPRECATED Try to rewrite the if() condition
if ($template == 'member_support_form') {
// Support request of a member
- $result = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
array(getUserId()), __FUNCTION__, __LINE__);
// Is content an array?
if (EXT_IS_ACTIVE('nickname')) {
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NICKNAME!<br />\n";
// Load nickname
- $result = SQL_QUERY_ESC("SELECT surname, family, gender, email, nickname FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(bigintval($UID)), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email`, `nickname` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+ array(bigintval($UID)), __FUNCTION__, __LINE__);
} else {
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NO-NICK!<br />\n";
/// Load normal data
- $result = SQL_QUERY_ESC("SELECT surname, family, gender, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(bigintval($UID)), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+ array(bigintval($UID)), __FUNCTION__, __LINE__);
}
// Fetch and merge data
} // END - if
// Three different debug ways...
- //* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
+ /* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, $URL);
//* DEBUG: */ die($URL);
$EMAIL = generateAdminEmailLink($email);
} elseif ((EXT_IS_ACTIVE('user')) && (GET_EXT_VERSION('user') >= '0.3.3') && ($table == 'user_data')) {
// Create email link for contacting a member within admin area (or later in other areas, too?)
- $EMAIL = generateEmailLink($email, 'user_data');
+ $EMAIL = generateUserEmailLink($email, 'admin');
} elseif ((EXT_IS_ACTIVE('sponsor')) && ($table == 'sponsor_data')) {
// Create email link to contact sponsor within admin area (or like the link above?)
- $EMAIL = generateEmailLink($email, 'sponsor_data');
+ $EMAIL = generateSponsorEmailLink($email, 'sponsor_data');
}
// Shall I close the link when there is no admin?
SQL_FREERESULT($result_media);
// Count mail orders
-$result_media = SQL_QUERY('SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_user_stats`', __FILE__, __LINE__);
-list($ncount) = SQL_FETCHROW($result_media);
-SQL_FREERESULT($result_media);
+$ncount = GET_TOTAL_DATA('', 'user_stats', 'id', '', true);
// Check for bonus extension
if (EXT_IS_ACTIVE('bonus')) {
// Count bonus mails
- $result_media = SQL_QUERY('SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_bonus`', __FILE__, __LINE__);
- list($bcount) = SQL_FETCHROW($result_media);
- SQL_FREERESULT($result_media);
+ $bcount = GET_TOTAL_DATA('', 'bonus', 'id', '', true);
// Check for bonus mails
$result_media = SQL_QUERY('SELECT SUM(mails_sent) AS bonus_sent, SUM(clicks) AS bonus_clicks
define('HAS_JOINED', "Beigetreten am");
define('TOTAL_POINTS', "{!POINTS!} gesamt");
define('TOTAL_REFERRALS', "Referals gesamt");
+define('TOTAL_REFS', "Refs gesamt");
define('ADMIN_MEMBER_FUNCTIONS', "Administrative Funktionen");
define('ADMIN_DEL_USER', "Löschen");
define('ADMIN_LOCK_USER', "Sperren");
// Is begging rallye active?
if (getConfig('beg_rallye') == 'Y') {
// Add points to rallye account
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET beg_points=beg_points+%s WHERE userid=%s LIMIT 1",
- array($points, $uid), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `beg_points`=`beg_points`+%s WHERE `userid`=%s LIMIT 1",
+ array($points, $uid), __FUNCTION__, __LINE__);
} else {
// Add points to account
unset($GLOBALS['ref_level']);
} // END - if
// Check for entry
- $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt FROM `{!_MYSQL_PREFIX!}_bonus_turbo` WHERE userid=%s AND %s=%s LIMIT 1",
- array($uid, $column, $mid), __FUNCTION__, __LINE__);
-
- // Load clicks from table as current rank
- list($rank) = SQL_FETCHROW($result);
-
- // Add one line
- $rank++;
-
- // Free result
- SQL_FREERESULT($result);
+ $rank = GET_TOTAL_DATA($uid, 'bonus_turbo', 'id', 'userid', true, sprintf(" AND `%s`=%s", $column, $mid)) + 1;
// Which rank?
if ($rank == 1) {
$points = $test[$rank - 2];
} else {
// Level not found!
- $points = "0.00000";
+ $points = '0.00000';
}
}
// Add points to his account directly
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET turbo_bonus=turbo_bonus+".$points." WHERE userid=%s LIMIT 1",
- array(bigintval($uid)), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `turbo_bonus`=`turbo_bonus`+%s WHERE `userid`=%s LIMIT 1",
+ array(bigintval($uid), $points), __FUNCTION__, __LINE__);
// Rember this whole data for displaying ranking list
- SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_bonus_turbo` (userid, mail_id, bonus_id, level, points, timemark) VALUES ('%s', '%s', '%s', '%s', '%s', UNIX_TIMESTAMP())",
- array(bigintval($uid), bigintval($mail), bigintval($bonus), $rank, $points), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_bonus_turbo` (`userid`, `mail_id`, `bonus_id`, `level`, `points`, `timemark`) VALUES (%s, %s, %s, %s, %s, UNIX_TIMESTAMP())",
+ array(
+ bigintval($uid),
+ bigintval($mail),
+ bigintval($bonus),
+ $rank,
+ $points
+ ), __FUNCTION__, __LINE__);
if ((GET_EXT_VERSION('bonus') >= '0.3.5') && (getConfig('bonus_mode') != "ADD") && ($points > 0)) BONUS_POINTS_HANDLER($points);
}
$ranks = count(explode(';', getConfig('turbo_rates'))) + 1;
// Load current user's data
- $result = SQL_QUERY_ESC("SELECT level, points, timemark FROM `{!_MYSQL_PREFIX!}_bonus_turbo` WHERE %s=%s AND `userid`=%s LIMIT 1",
- array($type, $data, $uid), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `level`, `points`, `timemark` FROM `{!_MYSQL_PREFIX!}_bonus_turbo` WHERE `%s`=%s AND `userid`=%s LIMIT 1",
+ array($type, $data, $uid), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load data
list($rank, $points, $mark) = SQL_FETCHROW($result);
//
function HOLIDAY_STOP_HOLIDAYS () {
// Let's find some expired holiday requests...
- $result_stop = SQL_QUERY("SELECT userid, holiday_start, holiday_end, comments
-FROM `{!_MYSQL_PREFIX!}_user_holidays`
-WHERE holiday_end <= UNIX_TIMESTAMP()
-ORDER BY `userid` ASC", __FUNCTION__, __LINE__);
+ $result_stop = SQL_QUERY("SELECT
+ `userid`, `holiday_start`, `holiday_end`, `comments`
+FROM
+ `{!_MYSQL_PREFIX!}_user_holidays`
+WHERE
+ `holiday_end` <= UNIX_TIMESTAMP()
+ORDER BY
+ `userid` ASC", __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result_stop) > 0) {
// We foud at least one
$admin = '';
// Process all found entries
while ($content = SQL_FETCHARRAY($result_stop)) {
// Stop holiday
- ADD_SQL(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_holidays` WHERE userid=%s LIMIT 1",
- array(bigintval($content['userid'])), __FUNCTION__, __LINE__, false));
+ ADD_SQL(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_holidays` WHERE `userid`=%s LIMIT 1",
+ array(bigintval($content['userid'])), __FUNCTION__, __LINE__, false));
// Unlock account
- ADD_SQL(SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data`
-SET `holiday_active`='N', `holiday_activated`=0
-WHERE `userid`=%s
-LIMIT 1", array(bigintval($content['userid'])), __FUNCTION__, __LINE__, false));
+ ADD_SQL(SQL_QUERY_ESC("UPDATE
+ `{!_MYSQL_PREFIX!}_user_data`
+SET
+ `holiday_active`='N', `holiday_activated`=0
+WHERE
+ `userid`=%s
+LIMIT 1",
+ array(bigintval($content['userid'])), __FUNCTION__, __LINE__, false));
// Prepare array
$content = array(
);
// Send mail to user
- $message = LOAD_EMAIL_TEMPLATE("member_holiday_unlock", $content, $content['userid']);
+ $message = LOAD_EMAIL_TEMPLATE('member_holiday_unlock', $content, $content['userid']);
sendEmail($content['userid'], getMessage('HOLIDAY_MEMBER_UNLOCK_SUBJ'), $message);
// Remember userid for admin
} // END - if
// Send mail to admins
- sendAdminNotification(getMessage('HOLIDAY_ADMIN_UNLOCK_SUBJ'), "admin_holiday_unlock", $admin, '0');
+ sendAdminNotification(getMessage('HOLIDAY_ADMIN_UNLOCK_SUBJ'), 'admin_holiday_unlock', $admin, '0');
// Run all SQLs
runFilterChain('run_sqls');
require($INC);
}
-//
// Part taken from admin optimize module of PHPNuke (http://www.phpnuke.org)
-//
-function REPAIR_OPTIMIZE_DB()
-{
+function REPAIR_OPTIMIZE_DB () {
$ret = array();
$tot_data = 0; $tabs = 0; $opts = 0;
$tot_idx = 0; $total_gain = 0;
$tot_all = 0;
- $result = @SQL_QUERY("SHOW TABLE STATUS FROM ".__DB_NAME, __FUNCTION__, __LINE__);
- $tabs = @SQL_NUMROWS($result);
+ $result = SQL_QUERY_ESC("SHOW TABLE STATUS FROM `%s`", array(constant('__DB_NAME')), __FUNCTION__, __LINE__);
+ $tabs = SQL_NUMROWS($result);
$ret['total_size'] = 0;
$ret['total_tabs'] = $tabs;
$ret['tables'] = array();
- if ($tabs > 0)
- {
- while ($row = SQL_FETCHARRAY($result))
- {
+ if ($tabs > 0) {
+ while ($row = SQL_FETCHARRAY($result)) {
$tot_data = $row['Data_length'];
$tot_idx = $row['Index_length'];
$total = $tot_data + $tot_idx;
$gain = round ($gain, 3);
// Repair table
- $result1 = SQL_QUERY("REPAIR TABLE ".$row['Name'], __FUNCTION__, __LINE__);
+ $result1 = SQL_QUERY_ESC("REPAIR TABLE `%s`",
+ array($row['Name']), __FUNCTION__, __LINE__);
$rep = SQL_FETCHARRAY($result1);
// Optimize table
- $result1 = SQL_QUERY("OPTIMIZE TABLE ".$row['Name'], __FUNCTION__, __LINE__);
+ $result1 = SQL_QUERY_ESC("OPTIMIZE TABLE `%s`",
+ array($row['Name']), __FUNCTION__, __LINE__);
$opt = SQL_FETCHARRAY($result1);
// Add data to array
$ret['total_gain'] = $total_gain;
// Insert new row
- $result = SQL_QUERY("INSERT INTO `{!_MYSQL_PREFIX!}_optimize_gain` (gain) VALUES ('".$total_gain."')", __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_optimize_gain` (`gain`) VALUES (%s)",
+ array($total_gain), __FUNCTION__, __LINE__);
// Get total runs and total optimization count
- $result = SQL_QUERY("SELECT COUNT(id) AS rows, SUM(gain) AS opti FROM `{!_MYSQL_PREFIX!}_optimize_gain`", __FUNCTION__, __LINE__);
+ $result = SQL_QUERY("SELECT COUNT(`id`) AS rows, SUM(`gain`) AS opti FROM `{!_MYSQL_PREFIX!}_optimize_gain`", __FUNCTION__, __LINE__);
list($total_rows, $total_opti) = SQL_FETCHROW($result);
// Free memory
// Return array
return $ret;
}
-//
+
+// [EOF]
?>
//
function RALLYE_LIST_WINNERS ($rallye, $default=0) {
// First check how many prices are set
- $result_prices = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_rallye_prices` WHERE rallye_id=%s ORDER BY price_level",
- array(bigintval($rallye)), __FUNCTION__, __LINE__);
+ $result_prices = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_rallye_prices` WHERE `rallye_id`=%s ORDER BY `price_level` ASC",
+ array(bigintval($rallye)), __FUNCTION__, __LINE__);
$prices = SQL_NUMROWS($result_prices);
SQL_FREERESULT($result_prices);
$DATA = RALLYE_LOAD_USERS_ARRAY($rallye);
// Generate table
- $OUT = LOAD_TEMPLATE("guest_rallye_expired_header", true);
+ $OUT = LOAD_TEMPLATE('guest_rallye_expired_header', true);
$SW = 2;
for ($idx = 0; $idx < $prices; $idx++) {
// Check status
// active = 1: account is still confirmed
// active = 0: account is deleted or locked
- $result_active = SQL_QUERY_ESC("SELECT COUNT(userid) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND `status`='CONFIRMED' LIMIT 1",
- array(bigintval($DATA['uid'][$idx])), __FUNCTION__, __LINE__);
- list($active) = SQL_FETCHROW($result_active);
- SQL_FREERESULT($result_active);
+ $active = GET_TOTAL_DATA($DATA['uid'][$idx], 'user_data', 'userid', 'userid', true, " AND `status`='CONFIRMED'");
if (empty($DATA['uid'][$idx])) $DATA['uid'][$idx] = '---';
if ((empty($DATA['ref'][$idx])) || ($DATA['ref'][$idx] == 0) || ($active == 0) || ("".round($DATA['cpoints'][$idx])."" == '0') || (empty($DATA['cpoints'][$idx]))) {
$DATA['infos'][$idx] = $DATA['info'][$idx];
} else {
// Take ppints
- $DATA['infos'][$idx] = $DATA['points'][$idx]." {!POINTS!}";
+ $DATA['infos'][$idx] = $DATA['points'][$idx] . ' {!POINTS!}';
}
// Add row
$return = $points;
// Get all ref levels
- $result_refs = SQL_QUERY("SELECT level, percents FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE level > 0 ORDER BY level ASC",
- __FUNCTION__, __LINE__);
+ $result_refs = SQL_QUERY("SELECT `level`, `percents` FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE `level` > 0 ORDER BY `level` ASC",
+ __FUNCTION__, __LINE__);
// "Walk" through all level
while ($content = SQL_FETCHARRAY($result_refs)) {
$refback = $points * ($content['percents'] / 100) * ($percents / 100);
// Update refback table ("refid" and "uid" must be exchanged!)
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_refs` SET points=points+%s WHERE userid=%s AND refid=%s LIMIT 1",
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_refs` SET points=points+%s WHERE `userid`=%s AND refid=%s LIMIT 1",
array($refback, $refid, $uid), __FUNCTION__, __LINE__);
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):refback={$refback},uid={$uid},refid={$refid} - UPDATE! (".SQL_AFFECTEDROWS().")<br />\n";
$percents = 0;
// Get percents from database
- $result = SQL_QUERY_ESC("SELECT refback FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE userid=%s AND refid=%s LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT refback FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE `userid`=%s AND refid=%s LIMIT 1",
array($ref, $uid), __FUNCTION__, __LINE__);
// Entry found? (Should be!)
$userIds = array();
// Look for all
- $result = SQL_QUERY_ESC("SELECT userid
-FROM `{!_MYSQL_PREFIX!}_user_refs`
-WHERE refid=%s AND level=%s
-ORDER BY userid ASC",
- array($rid,$level), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT
+ `userid`
+FROM
+ `{!_MYSQL_PREFIX!}_user_refs`
+WHERE
+ `refid=`%s AND `level`=%s
+ORDER BY
+ `userid` ASC",
+ array($rid,$level), __FUNCTION__, __LINE__);
// Entries found?
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):numRows=".SQL_NUMROWS($result)."<br />\n";
$old = 0; $minus = 0;
// Check for his referal
- $result_refid = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s ORDER BY userid ASC",
- array(bigintval($uid)), __FUNCTION__, __LINE__);
+ $result_refid = SQL_QUERY_ESC("SELECT `userid` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `refid`=%s ORDER BY `userid` ASC",
+ array(bigintval($uid)), __FUNCTION__, __LINE__);
// When no entry was updated then we have to create it here
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):found=".SQL_NUMROWS($result_refid)."<br />\n";
} // END - if
// Check existence
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE userid=%s AND level='%s' AND refid=%s LIMIT 1",
- array(bigintval($uid), $GLOBALS['cache_array']['back_level'], bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE `userid`=%s AND `level`='%s' AND `refid`=%s LIMIT 1",
+ array(bigintval($uid), $GLOBALS['cache_array']['back_level'], bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
// Do we have no entry?
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},level={$GLOBALS['cache_array']['back_level']},ref={$GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']]},minus={$minus},numRows=".SQL_NUMROWS($result)." - FOUND!<br />\n";
if (SQL_NUMROWS($result) == 0) {
// Insert this level
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},level={$GLOBALS['cache_array']['back_level']},ref={$GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']]} - ADD!<br />\n";
- SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_refs` (userid,level,refid) VALUES (%s,%s,%s)",
- array(bigintval($uid), $GLOBALS['cache_array']['back_level'], bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_refs` (`userid`,`level`,`refid`) VALUES (%s,%s,%s)",
+ array(bigintval($uid), $GLOBALS['cache_array']['back_level'], bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
// Move to next referal level and count his counter one up!
$GLOBALS['cache_array']['back_level']++; updateRefbackTable($GLOBALS['cache_array']['up_refid'][($GLOBALS['cache_array']['back_level'] - 1)]);
$uid = $old;
// Shall we add this as well?
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE userid=%s AND level='%s' AND refid=%s LIMIT 1",
- array(bigintval($uid), ($GLOBALS['cache_array']['back_level']-$minus), bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE `userid`=%s AND `level`='%s' AND `refid`=%s LIMIT 1",
+ array(bigintval($uid), ($GLOBALS['cache_array']['back_level']-$minus), bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
// Do we have no entry?
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},level=".($GLOBALS['cache_array']['back_level']-$minus).",ref={$GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']]},numRows=".SQL_NUMROWS($result)." - BACK!<br />\n";
if (SQL_NUMROWS($result) == 0) {
// Insert this level
- SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_refs` (userid,level,refid) VALUES (%s,%s,%s)",
- array(bigintval($uid), ($GLOBALS['cache_array']['back_level']-$minus), bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_refs` (`userid`,`level`,`refid`) VALUES (%s,%s,%s)",
+ array(bigintval($uid), ($GLOBALS['cache_array']['back_level']-$minus), bigintval($GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']])), __FUNCTION__, __LINE__);
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},level=".($GLOBALS['cache_array']['back_level']-$minus).",ref={$GLOBALS['cache_array']['up_refid'][$GLOBALS['cache_array']['back_level']]} - RETURNED!<br />\n";
} // END - if
} // END - if
} // END - if
// Get refs from database
- $result = SQL_QUERY_ESC("SELECT r.id, r.refid, r.refback, r.points, d.status".$add."
-FROM `{!_MYSQL_PREFIX!}_user_refs` AS r
-LEFT JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
-ON r.refid=d.userid
-WHERE r.userid=%s AND r.level=%s
-ORDER BY r.refid ASC",
- array(bigintval($uid), bigintval($level)), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT
+ r.id,
+ r.refid,
+ r.refback,
+ r.points,
+ d.status".$add."
+FROM
+ `{!_MYSQL_PREFIX!}_user_refs` AS r
+LEFT JOIN
+ `{!_MYSQL_PREFIX!}_user_data` AS d
+ON
+ r.refid=d.userid
+WHERE
+ r.userid=%s AND r.level=%s
+ORDER BY
+ r.refid ASC",
+ array(bigintval($uid), bigintval($level)), __FUNCTION__, __LINE__);
// Are there some entries?
if (SQL_NUMROWS($result) > 0) {
$id = bigintval($id);
// Get entry from database
- $result = SQL_QUERY_ESC("SELECT id, refid, refback, level FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE `id`=%s AND `userid`=%s LIMIT 1",
- array($id, getUserId()), __FUNCTION__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `id`, `refid`, `refback`, `level` FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE `id`=%s AND `userid`=%s LIMIT 1",
+ array($id, getUserId()), __FUNCTION__, __LINE__);
// Is there an entry?
if (SQL_NUMROWS($result) == 1) {
}
// Save sponsor?
- if ($SAVE) {
+ if ($SAVE === true) {
// Default is no force even when a guest want to abuse this force switch
if ((empty($POST['force'])) || (!IS_ADMIN())) $POST['force'] = 0;
// Return status
return $ret;
}
+
//
-function GENERATE_SPONSOR_MENU($current)
-{
+function GENERATE_SPONSOR_MENU ($current) {
$OUT = '';
$WHERE = " AND active='Y'";
if (IS_ADMIN()) $WHERE = '';
// Saving data was completed... ufff...
switch (getWhat())
{
- case "account": // Change account data
+ case 'account': // Change account data
if ($EMAIL === true) {
$message = getMessage('SPONSOR_ACCOUNT_EMAIL_CHANGED');
- $templ = "admin_sponsor_change_email";
+ $templ = 'admin_sponsor_change_email';
$subj = getMessage('ADMIN_SPONSOR_ACC_EMAIL_SUBJ');
} else {
$message = getMessage('SPONSOR_ACCOUNT_DATA_SAVED');
- $templ = "admin_sponsor_change_data";
+ $templ = 'admin_sponsor_change_data';
$subj = getMessage('ADMIN_SPONSOR_ACC_DATA_SUBJ');
}
break;
- case "settings": // Change settings
+ case 'settings': // Change settings
// Translate some data
$content['receive'] = translateYesNo($content['receive_warnings']);
$content['interval'] = createFancyTime($content['warning_interval']);
// Set message template and subject for admin
$message = getMessage('SPONSOR_SETTINGS_SAVED');
- $templ = "admin_sponsor_settings";
+ $templ = 'admin_sponsor_settings';
$subj = getMessage('ADMIN_SPONSOR_SETTINGS_SUBJ');
break;
$DATA = $POST;
// Change some data
- if (isset($content['gender'])) $content['gender'] = translateGender($content['gender']);
- if (isset($DATA['gender'])) $DATA['gender'] = translateGender($DATA['gender']);
+ if (isset($content['gender'])) $content['gender'] = translateGender($content['gender']);
+ if (isset($DATA['gender'])) $DATA['gender'] = translateGender($DATA['gender']);
if (isset($content['receive_warnings'])) $DATA['receive'] = translateYesNo($POST['receive_warnings']);
if (isset($content['warning_interval'])) $DATA['interval'] = createFancyTime($POST['warning_interval']);
// First to old address
switch (getWhat())
{
- case "account": // Change account data
- $email_msg = LOAD_EMAIL_TEMPLATE("sponsor_change_data", $content);
+ case 'account': // Change account data
+ $email_msg = LOAD_EMAIL_TEMPLATE('sponsor_change_data', $content);
sendEmail($content['email'], getMessage('SPONSOR_ACC_DATA_SUBJ'), $email_msg);
if ($EMAIL === true) {
$content['hash'] = $HASH;
// Second mail goes to the new address
- $email_msg = LOAD_EMAIL_TEMPLATE("sponsor_change_email", $content);
+ $email_msg = LOAD_EMAIL_TEMPLATE('sponsor_change_email', $content);
sendEmail($content['email'], getMessage('SPONSOR_ACC_EMAIL_SUBJ'), $email_msg);
}
break;
- case "settings": // Change settings
+ case 'settings': // Change settings
// Send email
- $email_msg = LOAD_EMAIL_TEMPLATE("sponsor_settings", $content);
+ $email_msg = LOAD_EMAIL_TEMPLATE('sponsor_settings', $content);
sendEmail($content['email'], getMessage('SPONSOR_SETTINGS_SUBJ'), $email_msg);
break;
}
SURFBAR_NOTIFY_USER('low_points', $content);
// Update last notified
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET surfbar_low_notified=NOW() WHERE userid=%s LIMIT 1",
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET surfbar_low_notified=NOW() WHERE `userid`=%s LIMIT 1",
array($uid), __FUNCTION__, __LINE__);
} // END - if
} // END - foreach
} // END - if
// Ask the database
- $result = SQL_QUERY_ESC("SELECT COUNT(l.id) AS cnt FROM `{!_MYSQL_PREFIX!}_surfbar_locks` AS l
-INNER JOIN `{!_MYSQL_PREFIX!}_surfbar_urls` AS u
-ON u.id=l.url_id
-WHERE l.userid=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(l.last_surfed) AND (((UNIX_TIMESTAMP(l.last_surfed) - u.fixed_reload) < 0 AND u.fixed_reload > 0) OR u.fixed_reload = 0)
+ $result = SQL_QUERY_ESC("SELECT
+ COUNT(l.id) AS cnt
+FROM
+ `{!_MYSQL_PREFIX!}_surfbar_locks` AS l
+INNER JOIN
+ `{!_MYSQL_PREFIX!}_surfbar_urls` AS u
+ON
+ u.id=l.url_id
+WHERE
+ l.userid=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(l.last_surfed) AND (((UNIX_TIMESTAMP(l.last_surfed) - u.fixed_reload) < 0 AND u.fixed_reload > 0) OR u.fixed_reload = 0)
LIMIT 1",
- array(getUserId()), __FUNCTION__, __LINE__
+ array(getUserId()), __FUNCTION__, __LINE__
);
// Fetch row
// Is the status set?
if (is_array($status)) {
// Only URLs with these status
- $add = sprintf(" AND status IN('%s')", implode("','", $status));
+ $add = sprintf(" AND `status` IN('%s')", implode("','", $status));
} elseif (!empty($status)) {
// Only URLs with this status
$add = sprintf(" AND `status`='%s'", $status);
} elseif (is_array($exclude)) {
// Exclude URLs with these status
- $add = sprintf(" AND status NOT IN('%s')", implode("','", $exclude));
+ $add = sprintf(" AND `status` NOT IN('%s')", implode("','", $exclude));
} elseif (!empty($exclude)) {
// Exclude URLs with this status
- $add = sprintf(" AND status != '%s'", $exclude);
+ $add = sprintf(" AND `status` != '%s'", $exclude);
}
// Get amount from database
- $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
-FROM `{!_MYSQL_PREFIX!}_surfbar_urls`
-WHERE `userid`=%s".$add."
-LIMIT %s",
- array($uid, getConfig('surfbar_max_order')), __FUNCTION__, __LINE__
- );
-
- // Fetch row
- list($cnt) = SQL_FETCHROW($result);
-
- // Free result
- SQL_FREERESULT($result);
+ $cnt = GET_TOTAL_DATA($uid, 'surfbar_urls', 'id', 'userid', true, $add);
// Return result
return $cnt;
function SURFBAR_CHECK_RELOAD_LOCK ($urlId) {
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "id={$urlId}", false);
// Ask the database
- $result = SQL_QUERY_ESC("SELECT COUNT(id) AS cnt
-FROM `{!_MYSQL_PREFIX!}_surfbar_locks`
-WHERE userid=%s AND url_id=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(last_surfed)
-ORDER BY last_surfed ASC
+ $result = SQL_QUERY_ESC("SELECT COUNT(`id`) AS cnt
+FROM
+ `{!_MYSQL_PREFIX!}_surfbar_locks`
+WHERE
+ `userid`=%s AND `url_id`=%s AND (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(`last_surfed`)
+ORDER BY
+ `last_surfed` ASC
LIMIT 1",
- array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__
+ array(getUserId(), bigintval($urlId)), __FUNCTION__, __LINE__
);
// Fetch counter
}
// Create email link to user's account
-function generateUserEmailLink($email, $mod='admin') {
+function generateUserEmailLink($email, $mod = 'admin') {
// Show contact link only if user is confirmed by default
$locked = " AND `status`='CONFIRMED'";
// But admins shall always see it
if (IS_ADMIN()) $locked = '';
- $result = SQL_QUERY_ESC("SELECT `userid`
-FROM `{!_MYSQL_PREFIX!}_user_data`
-WHERE `email`='%s'" . $locked." LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT
+ `userid`
+FROM
+ `{!_MYSQL_PREFIX!}_user_data`
+WHERE
+ `email`='%s'" . $locked."
+LIMIT 1",
array($email), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load userid
$uid = bigintval(REQUEST_GET('uid'));
// Check if the user already exists
- $result_user = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($uid), __FILE__, __LINE__);
+ $result_user = SQL_QUERY_ESC("SELECT `userid` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+ array($uid), __FILE__, __LINE__);
+
+ // Fix missing variable
+ $result_levels = false;
// User found?
if (SQL_NUMROWS($result_user) == 1) {
- // Is the refback extension installed?
- if (EXT_IS_ACTIVE('refback')) {
- // Load all referal levels
- $result_levels = SQL_QUERY("SELECT level, percents
-FROM `{!_MYSQL_PREFIX!}_refdepths`
-WHERE level > 0
-ORDER BY level ASC", __FILE__, __LINE__);
- } else {
- // Loads surname, family's name and the email address
- $result = SQL_QUERY_ESC("SELECT COUNT(*) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s",
- array($uid), __FILE__, __LINE__);
- $result_lck = SQL_QUERY_ESC("SELECT COUNT(*) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s AND status != 'CONFIRMED' ORDER BY `userid` ASC",
- array($uid), __FILE__, __LINE__);
- $menge = SQL_RESULT($result , 0, 0);
- $menge_lck = SQL_RESULT($result_lck, 0, 0);
-
- // Free memory
- SQL_FREERESULT($result);
- SQL_FREERESULT($result_lck);
-
- // Query for refs
- $result_levels = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email, status, joined FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s ORDER BY userid ASC",
- array($uid), __FILE__, __LINE__);
-
- // Output info message
- LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink(REQUEST_GET('uid')), $menge, $menge_lck));
- }
+ // Get total refs
+ $menge = GET_TOTAL_DATA($uid, 'user_data', 'userid', 'refid', true);
+ $menge_lck = GET_TOTAL_DATA($uid, 'user_data', 'userid', 'refid', true, " AND `status` != 'CONFIRMED'");
+
+ // Output info message
+ LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink(REQUEST_GET('uid')), $menge, $menge_lck));
+
+ // Load all referal levels
+ $result_levels = SQL_QUERY("SELECT
+ `level`, `percents`
+FROM
+ `{!_MYSQL_PREFIX!}_refdepths`
+WHERE
+ `level` > 0
+ORDER BY
+ `level` ASC", __FILE__, __LINE__);
// Are there some levels (VERY BAD IF NONE!)
if (SQL_NUMROWS($result_levels) > 0) {
// Is the refback still active? ;-)
if (EXT_IS_ACTIVE('refback')) {
// Load all refs of this user
- $result_refs = SQL_QUERY_ESC("SELECT refid FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE userid=%s AND level='%s' ORDER BY refid ASC",
- array($uid, $levels['level']), __FILE__, __LINE__);
+ $result_refs = SQL_QUERY_ESC("SELECT `refid` FROM `{!_MYSQL_PREFIX!}_user_refs` WHERE `userid`=%s AND `level`='%s' ORDER BY refid ASC",
+ array($uid, $levels['level']), __FILE__, __LINE__);
//* DEBUG: */ echo $uid.'/'.$levels['level'].'/'.SQL_NUMROWS($result_refs)."<br />\n";
// Do we have levels?
if (SQL_NUMROWS($result_refs) > 0) {
- // Loads surname, family's name and the email address
- $result = SQL_QUERY_ESC("SELECT COUNT(*) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s",
- array($uid), __FILE__, __LINE__);
- $result_lck = SQL_QUERY_ESC("SELECT COUNT(*) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s AND status != 'CONFIRMED' ORDER BY `userid` ASC",
- array($uid), __FILE__, __LINE__);
- $menge = SQL_RESULT($result , 0, 0);
- $menge_lck = SQL_RESULT($result_lck, 0, 0);
-
- // Free memory
- SQL_FREERESULT($result);
- SQL_FREERESULT($result_lck);
+ // Count entries
+ $menge = GET_TOTAL_DATA($uid, 'user_data', 'userid', 'refid', true);
+ $menge_lck = GET_TOTAL_DATA($uid, 'user_data', 'userid', 'refid', true, " AND `status` != 'CONFIRMED'");
// Output info message
$levels['info'] = sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink($uid), $menge, $menge_lck);
// Load all refs
while ($content = SQL_FETCHARRAY($result_refs)) {
// Query for data
- $result_user = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email, status, joined FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($content['refid']), __FILE__, __LINE__);
+ $result_user = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email`, `status`, `joined` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
+ array($content['refid']), __FILE__, __LINE__);
// Is the data there?
if (SQL_NUMROWS($result_user) == 1) {
$data = SQL_FETCHARRAY($result_user);
// Check for referals
- $result_cnt = SQL_QUERY_ESC("SELECT COUNT(userid) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s",
- array($content['refid']), __FILE__, __LINE__);
-
- // Load refs
- $refs_cnt = SQL_RESULT($result_cnt, 0, 0);
-
- // Free result
- SQL_FREERESULT($result_cnt);
+ $refs_cnt = GET_TOTAL_DATA($data['userid'], 'refsystem', 'counter');
// Prepare data for the template
$content = array(
if ($refs_cnt > 0) $content['refs_link'] = generateUserProfileLink($data['userid'], $refs_cnt, "list_refs");
// Load template for level one
- $OUT_REFS .= LOAD_TEMPLATE("admin_list_refs_row", true, $content);
+ $OUT_REFS .= LOAD_TEMPLATE('admin_list_refs_row', true, $content);
} else {
// No refs found
- $OUT_REFS = LOAD_TEMPLATE("admin_list_refs_nodata", true, $content['refid']);
+ $OUT_REFS = LOAD_TEMPLATE('admin_list_refs_nodata', true, $content['refid']);
}
// Free result
$levels['info'] = sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink($uid), '0', '0');
// No refs found
- $levels['rows'] = LOAD_TEMPLATE("admin_list_refs_norefs", true, array('uid' => $uid));
+ $levels['rows'] = LOAD_TEMPLATE('admin_list_refs_norefs', true, array('uid' => $uid));
}
// Free result
SQL_FREERESULT($result_refs);
// Load level template
- $OUT .= LOAD_TEMPLATE("admin_list_refs_level", true, $levels);
+ $OUT .= LOAD_TEMPLATE('admin_list_refs_level', true, $levels);
} else {
// Check for referals
- $result_refs = SQL_QUERY_ESC("SELECT COUNT(userid) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s",
- array(bigintval($levels['userid'])), __FILE__, __LINE__);
- $refs_cnt = SQL_RESULT($result_refs, 0, 0);
- SQL_FREERESULT($result_refs);
+ $refs_cnt = GET_TOTAL_DATA($levels['userid'], 'user_data', 'userid', 'refid', true);
// Prepare data for the template
$content = array(
ADD_MEMBER_SELECTION_BOX();
}
-//
+// [EOF]
?>
case "norefs": // Users w/o refs
if (!empty($whereStatement)) {
// Add AND statement
- $whereStatement .= " AND refid=0";
+ $whereStatement .= " AND `refid`=0";
} else {
// Add WHERE statement
- $whereStatement = " WHERE refid=0";
+ $whereStatement = " WHERE `refid`=0";
}
break;
}
} // END = if
+ // Generate master query string
+ $sql = sprintf("SELECT `userid`, `gender`, `surname`, `family`, `email`, `REMOTE_ADDR`, `refid`, `status`, `emails_sent`, `mails_confirmed`, `emails_received`".$MORE." FROM `{!_MYSQL_PREFIX!}_user_data`".$whereStatement." ORDER BY `%s` ASC",
+ REQUEST_GET('sortby')
+ );
+
// Prepare SQL and run it
- $sql = "SELECT userid, gender, surname, family, email, REMOTE_ADDR, refid, status, emails_sent, mails_confirmed, emails_received".$MORE." FROM `{!_MYSQL_PREFIX!}_user_data`".$whereStatement." ORDER BY ".REQUEST_GET('sortby');
$result_master = SQL_QUERY($sql, __FILE__, __LINE__);
// Calculate page count (0.5 fixes a bug with page count)
$sql .= " LIMIT ".(REQUEST_GET('offset') * REQUEST_GET('page') - REQUEST_GET('offset')).", ".REQUEST_GET('offset');
$result = SQL_QUERY($sql, __FILE__, __LINE__);
- $result_user = SQL_QUERY("SELECT emails_sent FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED'", __FILE__, __LINE__);
+ $result_user = SQL_QUERY("SELECT `emails_sent` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED'", __FILE__, __LINE__);
$user_count = SQL_NUMROWS($result_user);
SQL_FREERESULT($result_user);
$content['locked'] = translateComma(GET_TOTAL_DATA($content['userid'], 'user_points', 'locked_points'));
$content['lock_timestamp'] = generateDateTime($content['lock_timestamp'], '2');
$content['status'] = translateUserStatus($content['status']);
+ $content['refs'] = 0;
+
+ // Get total refs
+ $refs = GET_TOTAL_DATA($content['userid'], 'refsystem', 'counter');
+ if ($refs > 0) $content['refs'] = $base."&what=list_refs&uid=".$content['userid']."\">".$refs."</a>]";
// Is the lock reason not set?
if (!isset($content['lock_reason'])) $content['lock_reason'] = '---';
}
// Load row template and switch colors
- $OUT .= LOAD_TEMPLATE("admin_list_user_row", true, $content);
+ $OUT .= LOAD_TEMPLATE('admin_list_user_row', true, $content);
$SW = 3 - $SW;
} // END - while
define('__USER_ROWS', $OUT);
// Load main template
- LOAD_TEMPLATE("admin_list_user");
+ LOAD_TEMPLATE('admin_list_user');
// Free some memory
SQL_FREERESULT($result_master);
}
}
-//
+// [EOF]
?>
// Add one-time referal bonus over referal system or directly
unset($GLOBALS['ref_level']);
- ADD_POINTS_REFSYSTEM("referal_bonus", $rid, getConfig('points_ref'), true, bigintval($uid), $locked, getConfig('reg_points_mode'));
+ ADD_POINTS_REFSYSTEM('referal_bonus', $rid, getConfig('points_ref'), true, bigintval($uid), $locked, getConfig('reg_points_mode'));
} // END - if
} // END - if
}
// User who can receive mails
-$result_max = SQL_QUERY("SELECT COUNT(max_mails) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED' AND max_mails > 0", __FILE__, __LINE__);
-list($dummy) = SQL_FETCHROW($result_max);
-SQL_FREERESULT($result_max);
-define('user_max_mails', $dummy);
+define('user_max_mails', GET_TOTAL_DATA('CONFIRMED', 'user_data' 'max_mails', 'status', true, " AND `max_mails` > 0"));
// Users who can receive mails today
-$result_rec = SQL_QUERY("SELECT COUNT(receive_mails) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED' AND receive_mails > 0", __FILE__, __LINE__);
-list($dummy) = SQL_FETCHROW($result_rec);
-SQL_FREERESULT($result_rec);
-define('user_max_rec', $dummy);
+define('user_max_rec', GET_TOTAL_DATA('CONFIRMED', 'user_data', 'receive_mails', 'status', true, " AND `receive_mails` > 0"));
// Max mails per day
define('max', GET_TOTAL_DATA('CONFIRMED', 'user_data', 'max_mails', 'status', false, " AND `max_mails` > 0"));
define('_clr', translateComma($clr).'%');
// Load jackpot
-$result = SQL_QUERY("SELECT points FROM `{!_MYSQL_PREFIX!}_jackpot` WHERE ok='ok' LIMIT 1", __FILE__, __LINE__);
+$result = SQL_QUERY("SELECT `points` FROM `{!_MYSQL_PREFIX!}_jackpot` WHERE `ok`='ok' LIMIT 1", __FILE__, __LINE__);
list($jackpot) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
if (empty($jackpot)) $jackpot = 0;
define('__TOTAL_LOGINS' , $logins);
// Referal banner
-$result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
-list($total) = SQL_FETCHROW($result);
-SQL_FREERESULT($result);
-$result = SQL_QUERY("SELECT SUM(counter), SUM(clicks) FROM `{!_MYSQL_PREFIX!}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
+$total = GET_TOTAL_DATA('Y', 'refbanner', 'id', 'visible', true);
+
+// Total views and clicks
+$result = SQL_QUERY("SELECT SUM(`counter`) AS cnt, SUM(`clicks`) AS clx FROM `{!_MYSQL_PREFIX!}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
list($views, $clicks) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
'lang' => getMessage('MEDIA_DOUBLER_COUNT'),
'value' => $count1,
'rows' => '4'
- );
- // Add points
- $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row2', true, $content);
- $content = array(
+ );
+
+ // Add points
+ $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row2', true, $content);
+ $content = array(
'lang' => getMessage('MEDIA_DOUBLER_CPOINTS'),
'value' => translateComma($points1)
- );
- $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
- $content = array(
+ );
+ $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
+ $content = array(
'lang' => getMessage('MEDIA_DOUBLER_WAITING'),
'value' => translateComma($count2)
- );
- $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
+ );
+ $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
$content = array(
'lang' => getMessage('MEDIA_DOUBLER_WPOINTS'),
'value' => translateComma($points2)
- );
- $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
+ );
+ $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
}
if (EXT_IS_ACTIVE('holiday')) {
WHERE d.`holiday_active`='Y'",
__FILE__, __LINE__);
list($holiday) = SQL_FETCHROW($result);
+ SQL_FREERESULT($result);
if (empty($holiday)) $holiday = 0;
$content = array(
'lang' => getMessage('MEDIA_HOLIDAY_COUNT'),
ON t.userid=d.userid",
__FILE__, __LINE__);
list($count_in, $points_in) = SQL_FETCHROW($result);
+ SQL_FREERESULT($result);
if (empty($count_in)) $count_in = 0;
if (empty($points_in)) $points_in = 0;
ON t.userid=d.userid",
__FILE__, __LINE__);
list($count_out, $points_out) = SQL_FETCHROW($result);
+ SQL_FREERESULT($result);
if (empty($count_out)) $count_out = 0;
if (empty($points_out)) $points_out = 0;
'lang' => getMessage('MEDIA_TRANSFER_IN_COUNT'),
'value' => $count_in,
'rows' => '4'
- );
- $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row2', true, $content);
- $content = array(
+ );
+ $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row2', true, $content);
+ $content = array(
'lang' => getMessage('MEDIA_TRANSFER_IN_POINTS'),
'value' => translateComma($points_in)
- );
- $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
- $content = array(
+ );
+ $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
+ $content = array(
'lang' => getMessage('MEDIA_TRANSFER_OUT_COUNT'),
'value' => $count_out
- );
- $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
- $content = array(
+ );
+ $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
+ $content = array(
'lang' => getMessage('MEDIA_TRANSFER_OUT_POINTS'),
'value' => translateComma($points_out)
- );
- $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
-}
+ );
+ $OUT_SPECIAL .= LOAD_TEMPLATE('mediadata_extra_row', true, $content);
+} // END - if
define('__EXTRA_MEDIADATA' , $OUT_EXTRA);
define('__POINTS_MEDIADATA' , $OUT_POINTS);
ADD_DESCR('guest', __FILE__);
// Count referal levels
-$result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE level>0", __FILE__, __LINE__);
+$result = SQL_QUERY("SELECT COUNT(`id`) FROM `{!_MYSQL_PREFIX!}_refdepths` WHERE `level` > 0", __FILE__, __LINE__);
// Fetch rows
list($cnt) = SQL_FETCHROW($result);
// Module not found we don't add it to the database
$ret = '404';
}
- } elseif ($ret == 'cache_miss') {
+ } elseif (($ret == 'cache_miss') && (getOutputMode() > -1)) {
// Rebuild the cache files
rebuildCacheFiles('modreg', 'modreg');
} elseif ($found === false) {
$hash = generatePassString($hashDB);
if (($hash == getSession('u_hash')) || (REQUEST_POST('pass1') == REQUEST_POST('pass2'))) {
// Load user's data
- $result = SQL_QUERY_ESC("SELECT gender, surname, family, street_nr, country, zip, city, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND password='%s' LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT gender, surname, family, street_nr, country, zip, city, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s AND password='%s' LIMIT 1",
array(getUserId(), $hashDB), __FUNCTION__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Load the data
if ($locked) $data = 'locked_points';
// Check user account
- $result_user = SQL_QUERY_ESC("SELECT refid, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s AND `status`='CONFIRMED' LIMIT 1",
+ $result_user = SQL_QUERY_ESC("SELECT refid, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s AND `status`='CONFIRMED' LIMIT 1",
array(bigintval($uid)), __FUNCTION__, __LINE__);
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):uid={$uid},numRows=".SQL_NUMROWS($result_user).",points={$points}<br />\n";
} // END - if
// Update points...
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_points` SET %s=%s+%s WHERE userid=%s AND ref_depth='%s' LIMIT 1",
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_points` SET %s=%s+%s WHERE `userid`=%s AND ref_depth='%s' LIMIT 1",
array($data, $data, $ref_points, bigintval($uid), bigintval($GLOBALS['ref_level'])), __FUNCTION__, __LINE__);
//* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):data={$data},ref_points={$ref_points},uid={$uid},depth={$GLOBALS['ref_level']},mode={$add_mode} - UPDATE! (".SQL_AFFECTEDROWS().")<br />\n";
list($points) = SQL_FETCHROW($result);
// Delete points entries as well
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_points` WHERE userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_points` WHERE `userid`=%s", array(bigintval($uid)), __FUNCTION__, __LINE__);
// Update mediadata as well
if (GET_EXT_VERSION('mediadata') >= '0.0.4') {
SQL_FREERESULT($result);
// Delete category selections as well...
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE userid=%s",
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE `userid`=%s",
array(bigintval($uid)), __FUNCTION__, __LINE__);
// Remove from rallye if found
if (EXT_IS_ACTIVE('rallye')) {
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_rallye_users` WHERE userid=%s",
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_rallye_users` WHERE `userid`=%s",
array(bigintval($uid)), __FUNCTION__, __LINE__);
} // END - if
sendEmail($uid, getMessage('ADMIN_DEL_ACCOUNT'), $message);
// Ok, delete the account!
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(bigintval($uid)), __FUNCTION__, __LINE__);
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1", array(bigintval($uid)), __FUNCTION__, __LINE__);
}
// Generates meta description for given module and 'what' value
// Subtract points from database and mediadata cache
function SUB_POINTS ($subject, $uid, $points) {
// Add points to used points
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `used_points`=`used_points`+%s WHERE userid=%s LIMIT 1",
+ SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `used_points`=`used_points`+%s WHERE `userid`=%s LIMIT 1",
array($points, bigintval($uid)), __FUNCTION__, __LINE__);
// Insert booking record
$uid_cnt = 0;
// @TODO Rewrite this to $content = SQL_FETCHARRAY()
while (list($ucat) = SQL_FETCHROW($result_uids)) {
- $result_ver = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data`
-WHERE userid=%s AND `status`='CONFIRMED' AND receive_mails > 0".PREPARE_SQL_HTML_HOLIDAY($mode)." LIMIT 1",
- array(bigintval($ucat)), __FUNCTION__, __LINE__);
+ $result_ver = SQL_QUERY_ESC("SELECT
+ `userid`
+FROM
+ `{!_MYSQL_PREFIX!}_user_data`
+WHERE
+ `userid`=%s AND `status`='CONFIRMED' AND receive_mails > 0".PREPARE_SQL_HTML_HOLIDAY($mode)."
+LIMIT 1",
+ array(bigintval($ucat)), __FUNCTION__, __LINE__);
// Add user count
$uid_cnt += SQL_NUMROWS($result_ver);
<td align="center" class="right2 switch_sw$content[sw]"><strong>{--MAILS_SENT--}:</strong></td>
<td align="center" class="right2 switch_sw$content[sw]"><strong>{--CLICK_RATE--}:</strong></td>
<td align="center" class="right2 switch_sw$content[sw]"><strong>{--POINTS_LOCKED--}:</strong></td>
- <td align="center" class="switch_sw$content[sw]"><strong>{--__UNUSED--}:</strong></td>
+ <td align="center" class="switch_sw$content[sw]"><strong>{--TOTAL_REFS--}:</strong></td>
</tr>
<tr>
<td class="switch_sw$content[sw] seperator bottom2" width="5"> </td>
<td align="center" class="right2 switch_sw$content[sw] bottom2">$content[emails_sent]</td>
<td align="center" class="right2 switch_sw$content[sw] bottom2">$content[rate]%</td>
<td align="center" class="right2 switch_sw$content[sw] bottom2">$content[locked] {!POINTS!}</td>
- <td align="center" class="switch_sw$content[sw] bottom2">---</td>
+ <td align="center" class="switch_sw$content[sw] bottom2">$content[refs]</td>
</tr>
<tr>
<td width="5" class="switch_sw$content[sw] seperator"> </td>
<div class="guest_table dashed">
- <div style="text-align:center;height:40px" class="guest_done">{!__CONFIRM_MSG!}</div>
+ <div style="text-align:center" class="guest_done">{!__CONFIRM_MSG!}</div>
</div>