2 /************************************************************************
3 * MXChange v0.2.1 Start: 11/24/2004 *
4 * ================ Last change: 11/26/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-top10.php *
8 * -------------------------------------------------------------------- *
9 * Short description : TOP logins / best earner etc. *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : TOP-Logins / Bestverdiener usw. *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38 } elseif ((!EXT_IS_ACTIVE("top10")) && (!IS_ADMIN())) {
39 addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "top10");
43 // Add description as navigation point
44 ADD_DESCR("guest", __FILE__);
47 $result = SQL_QUERY_ESC("
49 userid, total_logins, last_online
51 {!_MYSQL_PREFIX!}_user_data
58 array(getConfig('top10_max')), __FILE__, __LINE__);
60 $OUT = ""; $SW = 2; $cnt = 1;
61 while ($content = SQL_FETCHARRAY($result)) {
63 $content['nickname'] = "---";
66 if (EXT_IS_ACTIVE("nickname")) $content['nickname'] = NICKNAME_GET_NICK($content['userid']);
68 // Prepare data for template
69 // @TODO Rewritings: uid->userid,nick->nickname,logins->total_logins in template
73 'uid' => $content['userid'],
74 'nick' => $content['nickname'],
75 'logins' => $content['total_logins'],
76 'points' => TRANSLATE_COMMA(GET_TOTAL_DATA($content['userid'], "user_points", "points")),
77 'last' => MAKE_DATETIME($content['last_online'], "3"),
81 $OUT .= LOAD_TEMPLATE("guest_top10_row_login", true, $content);
83 // Switch colors and count one up
84 $SW = 3 - $SW; $cnt++;
87 if ($cnt < getConfig('top10_max')) {
88 // Add more "blank" rows
89 for ($i = $cnt; $i <= getConfig('top10_max'); $i++) {
90 // Prepare data for template
97 $OUT .= LOAD_TEMPLATE("guest_top10_empty5", true, $content);
102 // @TODO Rewrite this constant
103 define('__TOP_LOGINS_ROWS', $OUT);
106 SQL_FREERESULT($result);
109 $result = SQL_QUERY_ESC("
112 (SUM(p.points) - d.used_points) AS tpoints,
115 `{!_MYSQL_PREFIX!}_user_data` AS d
117 {!_MYSQL_PREFIX!}_user_points AS p
122 d.`status`='CONFIRMED'
129 array(getConfig('top10_max')), __FILE__, __LINE__);
131 $OUT = ""; $SW = 2; $cnt = 1;
132 while ($content = SQL_FETCHARRAY($result)) {
134 $content['nickname'] = "---";
137 if (EXT_IS_ACTIVE("nickname")) $content['nickname'] = NICKNAME_GET_NICK($content['userid']);
139 // Prepare data for template
140 // @TODO Rewritings: nick->nickname,uid->userid in template
144 'uid' => $content['userid'],
145 'nick' => $content['nickname'],
146 'points' => TRANSLATE_COMMA($content['points']),
147 'last' => MAKE_DATETIME($content['last_online'], "3")
151 $OUT .= LOAD_TEMPLATE("guest_top10_row_earner", true, $content);
153 // Switch colors and count one up
154 $SW = 3 - $SW; $cnt++;
157 if ($cnt < getConfig('top10_max')) {
158 // Add more "blank" rows
159 for ($i = $cnt; $i <= getConfig('top10_max'); $i++) {
160 // Prepare data for template
167 $OUT .= LOAD_TEMPLATE("guest_top10_empty4", true, $content);
172 // @TODO Rewrite this constant
173 define('__TOP_POINTS_ROWS', $OUT);
176 SQL_FREERESULT($result);
178 //// TOP referal "hunter"
179 $result = SQL_QUERY_ESC("
182 SUM(r.counter) AS refs,
185 `{!_MYSQL_PREFIX!}_user_data` AS d
187 {!_MYSQL_PREFIX!}_refsystem AS r
192 d.`status`='CONFIRMED'
199 array(getConfig('top10_max')), __FILE__, __LINE__);
201 $OUT = ""; $SW = 2; $cnt = 1;
202 while ($content = SQL_FETCHARRAY($result)) {
204 $content['nickname'] = "---";
207 if (EXT_IS_ACTIVE("nickname")) $content['nickname'] = NICKNAME_GET_NICK($content['userid']);
209 // Prepare data for template
210 // @TODO Rewritings: nick->nickname,uid->userid in template
214 'uid' => $content['userid'],
215 'refs' => $content['refs'],
216 'nick' => $content['nickname'],
217 'points' => TRANSLATE_COMMA(GET_TOTAL_DATA($content['userid'], "user_points", "points")),
218 'last' => MAKE_DATETIME($content['last_online'], "3")
222 $OUT .= LOAD_TEMPLATE("guest_top10_row_refs", true, $content);
224 // Switch colors and count one up
225 $SW = 3 - $SW; $cnt++;
228 if ($cnt < getConfig('top10_max')) {
229 // Add more "blank" rows
230 for ($i = $cnt; $i <= getConfig('top10_max'); $i++) {
231 // Prepare data for template
238 $OUT .= LOAD_TEMPLATE("guest_top10_empty5", true, $content);
243 // @TODO Rewrite this constant
244 define('__TOP_REFERRAL_ROWS', $OUT);
247 SQL_FREERESULT($result);
249 // Remember other values in constants
250 // @TODO Rewrite this constant
251 define('__TOP10_MAX', getConfig('top10_max'));
253 // Load final template
254 LOAD_TEMPLATE("guest_top10");