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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2008 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
43 } elseif ((!EXT_IS_ACTIVE("top10")) && (!IS_ADMIN())) {
44 addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "top10");
48 // Add description as navigation point
49 ADD_DESCR("guest", __FILE__);
52 $result = SQL_QUERY_ESC("
54 userid, total_logins, last_online
56 {!_MYSQL_PREFIX!}_user_data
63 array(getConfig('top10_max')), __FILE__, __LINE__);
65 $OUT = ""; $SW = 2; $cnt = 1;
66 while ($content = SQL_FETCHARRAY($result)) {
68 $content['nickname'] = "---";
71 if (EXT_IS_ACTIVE("nickname")) $content['nickname'] = NICKNAME_GET_NICK($content['userid']);
73 // Prepare data for template
74 // @TODO Rewritings: uid->userid,nick->nickname,logins->total_logins in template
78 'uid' => $content['userid'],
79 'nick' => $content['nickname'],
80 'logins' => $content['total_logins'],
81 'points' => TRANSLATE_COMMA(GET_TOTAL_DATA($content['userid'], "user_points", "points")),
82 'last' => MAKE_DATETIME($content['last_online'], "3"),
86 $OUT .= LOAD_TEMPLATE("guest_top10_row_login", true, $content);
88 // Switch colors and count one up
89 $SW = 3 - $SW; $cnt++;
92 if ($cnt < getConfig('top10_max')) {
93 // Add more "blank" rows
94 for ($i = $cnt; $i <= getConfig('top10_max'); $i++) {
95 // Prepare data for template
102 $OUT .= LOAD_TEMPLATE("guest_top10_empty5", true, $content);
107 // @TODO Rewrite this constant
108 define('__TOP_LOGINS_ROWS', $OUT);
111 SQL_FREERESULT($result);
114 $result = SQL_QUERY_ESC("
117 (SUM(p.points) - d.used_points) AS tpoints,
120 `{!_MYSQL_PREFIX!}_user_data` AS d
122 {!_MYSQL_PREFIX!}_user_points AS p
127 d.`status`='CONFIRMED'
134 array(getConfig('top10_max')), __FILE__, __LINE__);
136 $OUT = ""; $SW = 2; $cnt = 1;
137 while ($content = SQL_FETCHARRAY($result)) {
139 $content['nickname'] = "---";
142 if (EXT_IS_ACTIVE("nickname")) $content['nickname'] = NICKNAME_GET_NICK($content['userid']);
144 // Prepare data for template
145 // @TODO Rewritings: nick->nickname,uid->userid in template
149 'uid' => $content['userid'],
150 'nick' => $content['nickname'],
151 'points' => TRANSLATE_COMMA($content['points']),
152 'last' => MAKE_DATETIME($content['last_online'], "3")
156 $OUT .= LOAD_TEMPLATE("guest_top10_row_earner", true, $content);
158 // Switch colors and count one up
159 $SW = 3 - $SW; $cnt++;
162 if ($cnt < getConfig('top10_max')) {
163 // Add more "blank" rows
164 for ($i = $cnt; $i <= getConfig('top10_max'); $i++) {
165 // Prepare data for template
172 $OUT .= LOAD_TEMPLATE("guest_top10_empty4", true, $content);
177 // @TODO Rewrite this constant
178 define('__TOP_POINTS_ROWS', $OUT);
181 SQL_FREERESULT($result);
183 //// TOP referal "hunter"
184 $result = SQL_QUERY_ESC("
187 SUM(r.counter) AS refs,
190 `{!_MYSQL_PREFIX!}_user_data` AS d
192 {!_MYSQL_PREFIX!}_refsystem AS r
197 d.`status`='CONFIRMED'
204 array(getConfig('top10_max')), __FILE__, __LINE__);
206 $OUT = ""; $SW = 2; $cnt = 1;
207 while ($content = SQL_FETCHARRAY($result)) {
209 $content['nickname'] = "---";
212 if (EXT_IS_ACTIVE("nickname")) $content['nickname'] = NICKNAME_GET_NICK($content['userid']);
214 // Prepare data for template
215 // @TODO Rewritings: nick->nickname,uid->userid in template
219 'uid' => $content['userid'],
220 'refs' => $content['refs'],
221 'nick' => $content['nickname'],
222 'points' => TRANSLATE_COMMA(GET_TOTAL_DATA($content['userid'], "user_points", "points")),
223 'last' => MAKE_DATETIME($content['last_online'], "3")
227 $OUT .= LOAD_TEMPLATE("guest_top10_row_refs", true, $content);
229 // Switch colors and count one up
230 $SW = 3 - $SW; $cnt++;
233 if ($cnt < getConfig('top10_max')) {
234 // Add more "blank" rows
235 for ($i = $cnt; $i <= getConfig('top10_max'); $i++) {
236 // Prepare data for template
243 $OUT .= LOAD_TEMPLATE("guest_top10_empty5", true, $content);
248 // @TODO Rewrite this constant
249 define('__TOP_REFERRAL_ROWS', $OUT);
252 SQL_FREERESULT($result);
254 // Remember other values in constants
255 // @TODO Rewrite this constant
256 define('__TOP10_MAX', getConfig('top10_max'));
258 // Load final template
259 LOAD_TEMPLATE("guest_top10");