]> git.mxchange.org Git - mailer.git/commitdiff
More misc fixes and rewrites (sorry, lame description)
authorRoland Häder <roland@mxchange.org>
Mon, 5 Oct 2009 20:55:08 +0000 (20:55 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 5 Oct 2009 20:55:08 +0000 (20:55 +0000)
20 files changed:
inc/functions.php
inc/gen_mediadata.php
inc/language/de.php
inc/libs/beg_functions.php
inc/libs/bonus_functions.php
inc/libs/holiday_functions.php
inc/libs/optimize_functions.php
inc/libs/rallye_functions.php
inc/libs/refback_functions.php
inc/libs/sponsor_functions.php
inc/libs/surfbar_functions.php
inc/libs/user_functions.php
inc/modules/admin/what-list_refs.php
inc/modules/admin/what-list_user.php
inc/modules/guest/what-confirm.php
inc/modules/guest/what-mediadata.php
inc/modules/guest/what-welcome.php
inc/mysql-manager.php
templates/de/html/admin/admin_list_user_row.tpl
templates/de/html/guest/guest_confirm_table.tpl

index 8ac91e556901e68696ead6e560043abac61bc4ca..010cad850080d80485c4f72b0e44db0ca4d2ecc9 100644 (file)
@@ -238,7 +238,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
        // @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?
@@ -799,13 +799,13 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
                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
@@ -922,7 +922,7 @@ function redirectToUrl ($URL) {
        } // 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);
 
@@ -2026,10 +2026,10 @@ function generateEmailLink ($email, $table = 'admins') {
                $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?
index 911cfa54b7274a1abf4f6c9ceaa4d5692cf7a7f0..e060e39fe5729921ca40440dccb7fa64c04fbd58 100644 (file)
@@ -56,16 +56,12 @@ if (empty($nclicks)) $nclicks = 0;
 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
index b48f6ee9b0a2b3761acab4cecec4bc683db07842..0b8a0af0a23ee2604c733ff095d23bd5bbf0e202 100644 (file)
@@ -512,6 +512,7 @@ define('MAILS_SENT', "Mails versendet");
 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&ouml;schen");
 define('ADMIN_LOCK_USER', "Sperren");
index f0208c5e0a938de1acb362648350f45d9913e369..d7a706b435567c577c5f81e9cf5554427021609d 100644 (file)
@@ -51,8 +51,8 @@ function BEG_ADD_POINTS ($uid, $points) {
        // 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']);
index a13aec9642ac2bec0e371ffb9c92c3284c2e7c2f..55aba4995f949096c806a830686e695ac2d2e772 100644 (file)
@@ -75,17 +75,7 @@ function BONUS_ADD_TURBO_POINTS ($mid, $uid, $type) {
        } // 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) {
@@ -99,17 +89,23 @@ function BONUS_ADD_TURBO_POINTS ($mid, $uid, $type) {
                        $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);
 }
@@ -121,8 +117,8 @@ function BONUS_MAKE_RANK_ROWS ($data, $type, $uid) {
        $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);
index fb901880261242ff57ed676adf1c55c5f0ab7f59..e23f772dd42fda387cad593560c43d5627de682f 100644 (file)
@@ -45,10 +45,14 @@ if (!defined('__SECURITY')) {
 //
 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 = '';
@@ -58,14 +62,18 @@ ORDER BY `userid` ASC", __FUNCTION__, __LINE__);
                // 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(
@@ -75,7 +83,7 @@ LIMIT 1", array(bigintval($content['userid'])), __FUNCTION__, __LINE__, false));
                        );
 
                        // 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
@@ -83,7 +91,7 @@ LIMIT 1", array(bigintval($content['userid'])), __FUNCTION__, __LINE__, false));
                } // 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');
index 3010e34f08c18da8c834c7dcb58f9d6751c383aa..59d142b907371444bcfd5a2e486adfef3a485fe2 100644 (file)
@@ -42,24 +42,19 @@ if (!defined('__SECURITY')) {
        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;
@@ -71,11 +66,13 @@ function REPAIR_OPTIMIZE_DB()
                        $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
@@ -90,10 +87,11 @@ function REPAIR_OPTIMIZE_DB()
        $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
@@ -106,5 +104,6 @@ function REPAIR_OPTIMIZE_DB()
        // Return array
        return $ret;
 }
-//
+
+// [EOF]
 ?>
index 3d3b2d3b12ea47659e26dd27508eecbbf280738e..998427c95fa76373a82ebf26db773e41c4edca54 100644 (file)
@@ -558,8 +558,8 @@ WHERE d.`status`='CONFIRMED' AND d.max_mails > 0 AND d.mails_confirmed >= %s AND
 //
 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);
 
@@ -567,16 +567,13 @@ function RALLYE_LIST_WINNERS ($rallye, $default=0) {
        $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]))) {
@@ -590,7 +587,7 @@ function RALLYE_LIST_WINNERS ($rallye, $default=0) {
                        $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
index 7106e7972c8cc9010fabe908129045f6c2d4f9a2..1ec422b90733aaf9dfa51f9e8471bdb787d1f729 100644 (file)
@@ -52,8 +52,8 @@ function ADD_REFBACK_POINTS ($uid, $ref, $points, $ref_points) {
        $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)) {
@@ -77,7 +77,7 @@ function ADD_REFBACK_POINTS ($uid, $ref, $points, $ref_points) {
                                $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";
 
@@ -117,7 +117,7 @@ function GET_REFBACK_PERCENTS ($uid, $ref) {
        $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!)
@@ -147,11 +147,15 @@ function GET_REFBACK_USERID_ARRAY ($rid, $level) {
        $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";
@@ -184,8 +188,8 @@ function updateRefbackTable ($uid) {
        $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";
@@ -208,16 +212,16 @@ function updateRefbackTable ($uid) {
                                } // 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)]);
@@ -229,15 +233,15 @@ function updateRefbackTable ($uid) {
                                        $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
@@ -279,13 +283,23 @@ function GET_USER_REFS ($uid, $level) {
        } // 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) {
@@ -314,8 +328,8 @@ function GET_USER_REF_ENTRY ($id) {
        $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) {
index 06c389a9950c1486e9719f5c1e7c998d3f194a54..fb8ac7bf8902071708d2ba1b0b49d5e4a2ae26b8 100644 (file)
@@ -120,7 +120,7 @@ function SPONSOR_HANDLE_SPONSOR (&$POST, $NO_UPDATE=false, $messageArray=array()
                }
 
                // 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;
 
@@ -277,9 +277,9 @@ LIMIT 1",
        // Return status
        return $ret;
 }
+
 //
-function GENERATE_SPONSOR_MENU($current)
-{
+function GENERATE_SPONSOR_MENU ($current) {
        $OUT = '';
        $WHERE = " AND active='Y'";
        if (IS_ADMIN()) $WHERE = '';
@@ -449,26 +449,26 @@ function SPONSOR_SAVE_DATA ($POST, $content) {
        // 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;
 
@@ -489,8 +489,8 @@ function SPONSOR_SAVE_DATA ($POST, $content) {
                        $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']);
 
@@ -505,8 +505,8 @@ function SPONSOR_SAVE_DATA ($POST, $content) {
                                // 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) {
@@ -514,14 +514,14 @@ function SPONSOR_SAVE_DATA ($POST, $content) {
                                                        $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;
                                }
index 35b8b1d199558fef113ce2c836885da85b983b21..932259cc4087a93641850e22ff85c106936f8a77 100644 (file)
@@ -518,7 +518,7 @@ function SURFBAR_HANDLE_LOW_POINTS () {
                        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
@@ -837,12 +837,18 @@ function SURFBAR_CHECK_RELOAD_FULL() {
        } // 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
@@ -919,31 +925,20 @@ function SURFBAR_GET_TOTAL_USER_URLS ($uid=0, $status = '',$exclude = '') {
        // 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;
@@ -1099,12 +1094,15 @@ function SURFBAR_UPDATE_SALT_STATS () {
 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
index 748d68db59ac9a9ce06376e1f49098f460efdd02..ec3958a6455f70468f6ed8815f4b6fe713056254 100644 (file)
@@ -189,16 +189,20 @@ function ADD_PAGENAV ($PAGES, $offset, $show_form, $colspan,$return=false) {
 }
 
 // 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
index 6f4155dd02e120359e802589770e385e74ff8930..8bfb68fe4b984454da7325f1ecb73ba0563a59f2 100644 (file)
@@ -51,38 +51,30 @@ if (REQUEST_ISSET_GET('uid')) {
        $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) {
@@ -95,23 +87,15 @@ ORDER BY level ASC", __FILE__, __LINE__);
                                // 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);
@@ -122,8 +106,8 @@ ORDER BY level ASC", __FILE__, __LINE__);
                                                // 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) {
@@ -131,14 +115,7 @@ ORDER BY level ASC", __FILE__, __LINE__);
                                                                $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(
@@ -157,10 +134,10 @@ ORDER BY level ASC", __FILE__, __LINE__);
                                                                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
@@ -177,20 +154,17 @@ ORDER BY level ASC", __FILE__, __LINE__);
                                                $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(
@@ -250,5 +224,5 @@ ORDER BY level ASC", __FILE__, __LINE__);
        ADD_MEMBER_SELECTION_BOX();
 }
 
-//
+// [EOF]
 ?>
index 57630cefba64ae463a0c359863e9d96f122761a7..d2a24f5073829bda93dd0b76c2de9f00899e40b3 100644 (file)
@@ -224,10 +224,10 @@ LIMIT 1",
                        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;
 
@@ -237,8 +237,12 @@ LIMIT 1",
                }
        } // 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)
@@ -257,7 +261,7 @@ LIMIT 1",
        $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);
 
@@ -329,6 +333,11 @@ LIMIT 1",
                        $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."&amp;what=list_refs&amp;uid=".$content['userid']."\">".$refs."</a>]";
 
                        // Is the lock reason not set?
                        if (!isset($content['lock_reason'])) $content['lock_reason'] = '---';
@@ -344,7 +353,7 @@ LIMIT 1",
                        }
 
                        // 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
 
@@ -354,7 +363,7 @@ LIMIT 1",
                define('__USER_ROWS', $OUT);
 
                // Load main template
-               LOAD_TEMPLATE("admin_list_user");
+               LOAD_TEMPLATE('admin_list_user');
 
                // Free some memory
                SQL_FREERESULT($result_master);
@@ -364,5 +373,5 @@ LIMIT 1",
        }
 }
 
-//
+// [EOF]
 ?>
index 5ba170c609cfbeae6af808404bda51b03797c228..12dace12c630e44d964ea8d149cca712a3d98042 100644 (file)
@@ -98,7 +98,7 @@ if (REQUEST_ISSET_GET('hash')) {
 
                                        // 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
 
index 2d6d3c0a531406bbe2aad051af998a48db496208..ac1b450fbd88624803c535930d26a0bf99842e95 100644 (file)
@@ -80,16 +80,10 @@ if ($TEST > time()) {
 }
 
 // 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"));
@@ -134,7 +128,7 @@ if ($sent > 0) $clr = $clicks / $sent * 100;
 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;
@@ -158,10 +152,10 @@ define('__TOTAL_REFCLICKS', $ref);
 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);
 
@@ -220,24 +214,25 @@ if (EXT_IS_ACTIVE('doubler')) {
                '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')) {
@@ -249,6 +244,7 @@ ON h.userid=d.userid
 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'),
@@ -266,6 +262,7 @@ LEFT JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
 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;
 
@@ -275,6 +272,7 @@ LEFT JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
 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;
 
@@ -284,24 +282,24 @@ ON t.userid=d.userid",
                '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);
index 5f1e1d30c6da468b72fa3c4d2d3d7ea6682c7320..dfb9c4e4d461d580ffd326f3fb03ffccc7b13a12 100644 (file)
@@ -46,7 +46,7 @@ if (!defined('__SECURITY')) {
 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);
index 76f6957921e860d40daed4920ea22c33a96a99ea..491bf296ffee12acb3e81cacc81c5a8297464957 100644 (file)
@@ -253,7 +253,7 @@ function checkModulePermissions ($mod) {
                        // 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) {
@@ -800,7 +800,7 @@ function sendModeMails ($mod, $modes) {
                $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
@@ -1225,7 +1225,7 @@ function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify = false, $r
        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";
@@ -1252,7 +1252,7 @@ function ADD_POINTS_REFSYSTEM ($subject, $uid, $points, $send_notify = false, $r
                        } // 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";
 
@@ -1634,7 +1634,7 @@ WHERE p.userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__);
                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') {
@@ -1650,12 +1650,12 @@ WHERE p.userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__);
        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
 
@@ -1664,7 +1664,7 @@ WHERE p.userid=%s", array(bigintval($uid)), __FUNCTION__, __LINE__);
        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
@@ -1763,7 +1763,7 @@ function getWhatFromModule ($modCheck) {
 // 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
@@ -1906,9 +1906,14 @@ function generateCategoryOptionsList ($mode) {
                        $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);
index af4806a17c0c183e7f69664e426d77edb8a5dd33..4acff5f7b6580c2b111e07f95e3271611ef4c5b1 100644 (file)
@@ -36,7 +36,7 @@
        <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">&nbsp;</td>
@@ -44,7 +44,7 @@
        <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">&nbsp;</td>
index 9ebb17d78e3d9970e93b77853cdf6d91f0221974..eaf26cd63780d3d70153399f605d07f926df0241 100644 (file)
@@ -1,3 +1,3 @@
 <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>