-$result = SQL_QUERY_ESC("SELECT DISTINCT p.userid, d.".$ADD.", (SUM(p.points) - d.used_points) AS tpoints, d.last_online
-FROM "._MYSQL_PREFIX."_user_points AS p
-LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
-ON p.userid=d.userid
-WHERE p.points > 0 AND d.status='CONFIRMED'
-GROUP BY p.userid
-ORDER BY tpoints DESC, d.last_online DESC
-LIMIT %s",
- array($_CONFIG['top10_max']), __FILE__, __LINE__);
-
-$OUT = ""; $SW = 2; $cnt = 1;
-while(list($uid, $nick, $points, $last) = SQL_FETCHROW($result))
-{
- $nick2 = "---";
- if (($nick != $uid) && (!empty($nick))) $nick2 = $nick;
+$result = SQL_QUERY("SELECT
+ d.userid,
+ (SUM(p.points) - d.used_points) AS points,
+ d.last_online
+FROM
+ `{?_MYSQL_PREFIX?}_user_data` AS d
+LEFT JOIN
+ {?_MYSQL_PREFIX?}_user_points AS p
+ON
+ p.userid=d.userid
+WHERE
+ p.points > 0 AND
+ d.`status`='CONFIRMED'
+GROUP BY
+ p.userid
+ORDER BY
+ points DESC,
+ d.last_online DESC
+LIMIT {?top10_max?}", __FILE__, __LINE__);
+
+$OUT = ''; $cnt = 1;
+while ($content = SQL_FETCHARRAY($result)) {
+ // Init nickname
+ $content['nickname'] = '';
+
+ // Get nickname
+ if (isExtensionActive('nickname')) $content['nickname'] = getNickname($content['userid']);