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(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 (list($uid, $logins, $last) = SQL_FETCHROW($result)) {
65 if (EXT_IS_ACTIVE("nickname")) $nick2 = NICKNAME_GET_NICK($uid);
67 // Prepare data for template
74 'points' => TRANSLATE_COMMA(GET_TOTAL_DATA($uid, "user_points", "points")),
75 'last' => MAKE_DATETIME($last, "3"),
79 $OUT .= LOAD_TEMPLATE("guest_top10_row_login", true, $content);
81 // Switch colors and count one up
82 $SW = 3 - $SW; $cnt++;
85 if ($cnt < getConfig('top10_max')) {
86 // Add more "blank" rows
87 for ($i = $cnt; $i <= getConfig('top10_max'); $i++) {
88 // Prepare data for template
95 $OUT .= LOAD_TEMPLATE("guest_top10_empty5", true, $content);
99 define('__TOP_LOGINS_ROWS', $OUT);
102 SQL_FREERESULT($result);
105 $result = SQL_QUERY_ESC("
108 (SUM(p.points) - d.used_points) AS tpoints,
111 `"._MYSQL_PREFIX."_user_data` AS d
113 "._MYSQL_PREFIX."_user_points AS p
125 array(getConfig('top10_max')), __FILE__, __LINE__);
127 $OUT = ""; $SW = 2; $cnt = 1;
128 while (list($uid, $points, $last) = SQL_FETCHROW($result)) {
132 if (EXT_IS_ACTIVE("nickname")) $nick2 = NICKNAME_GET_NICK($uid);
134 // Prepare data for template
138 'uid' => bigintval($uid),
140 'points' => TRANSLATE_COMMA($points),
141 'last' => MAKE_DATETIME($last, "3")
145 $OUT .= LOAD_TEMPLATE("guest_top10_row_earner", true, $content);
147 // Switch colors and count one up
148 $SW = 3 - $SW; $cnt++;
151 if ($cnt < getConfig('top10_max')) {
152 // Add more "blank" rows
153 for ($i = $cnt; $i <= getConfig('top10_max'); $i++) {
154 // Prepare data for template
161 $OUT .= LOAD_TEMPLATE("guest_top10_empty4", true, $content);
165 define('__TOP_POINTS_ROWS', $OUT);
168 SQL_FREERESULT($result);
170 //// TOP referal "hunter"
171 $result = SQL_QUERY_ESC("
174 SUM(r.counter) AS refs,
177 `"._MYSQL_PREFIX."_user_data` AS d
179 "._MYSQL_PREFIX."_refsystem AS r
191 array(getConfig('top10_max')), __FILE__, __LINE__);
193 $OUT = ""; $SW = 2; $cnt = 1;
194 while (list($uid, $refs, $last) = SQL_FETCHROW($result)) {
198 if (EXT_IS_ACTIVE("nickname")) $nick2 = NICKNAME_GET_NICK($uid);
200 // Prepare data for template
204 'uid' => bigintval($uid),
207 'points' => TRANSLATE_COMMA(GET_TOTAL_DATA($uid, "user_points", "points")),
208 'last' => MAKE_DATETIME($last, "3")
212 $OUT .= LOAD_TEMPLATE("guest_top10_row_refs", true, $content);
214 // Switch colors and count one up
215 $SW = 3 - $SW; $cnt++;
218 if ($cnt < getConfig('top10_max')) {
219 // Add more "blank" rows
220 for ($i = $cnt; $i <= getConfig('top10_max'); $i++) {
221 // Prepare data for template
228 $OUT .= LOAD_TEMPLATE("guest_top10_empty5", true, $content);
232 define('__TOP_REFERRAL_ROWS', $OUT);
235 SQL_FREERESULT($result);
237 // Remember other values in constants
238 define('__TOP10_MAX', getConfig('top10_max'));
240 // Load final template
241 LOAD_TEMPLATE("guest_top10");