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"))
39 ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "top10");
43 // Add description as navigation point
44 ADD_DESCR("guest", __FILE__);
48 if (EXT_IS_ACTIVE("nickname")) $ADD = "nickname";
49 $result = SQL_QUERY_ESC("SELECT userid, ".$ADD.", total_logins, last_online
50 FROM "._MYSQL_PREFIX."_user_data
51 WHERE total_logins>0 AND status='CONFIRMED' ORDER BY total_logins DESC LIMIT %s",
52 array($_CONFIG['top10_max']), __FILE__, __LINE__);
54 $OUT = ""; $SW = 2; $cnt = 1;
55 while(list($uid, $nick, $logins, $last) = SQL_FETCHROW($result))
58 if (($nick != $uid) && (!empty($nick))) $nick2 = $nick;
60 // Prepare data for template
67 'points' => TRANSLATE_COMMA(GET_TOTAL_DATA($uid, "user_points", "points")),
68 'last' => MAKE_DATETIME($last, "3"),
72 $OUT .= LOAD_TEMPLATE("guest_top10_row_login", true, $content);
74 // Switch colors and count one up
75 $SW = 3 - $SW; $cnt++;
77 if ($cnt < $_CONFIG['top10_max'])
79 // Add more "blank" rows
80 for ($i = $cnt; $i <= $_CONFIG['top10_max']; $i++)
82 // Prepare data for template
89 $OUT .= LOAD_TEMPLATE("guest_top10_empty5", true, $content);
93 define('__TOP_LOGINS_ROWS', $OUT);
96 $result = SQL_QUERY_ESC("SELECT DISTINCT p.userid, d.".$ADD.", (SUM(p.points) - d.used_points) AS tpoints, d.last_online
97 FROM "._MYSQL_PREFIX."_user_points AS p
98 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
100 WHERE p.points > 0 AND d.status='CONFIRMED'
102 ORDER BY tpoints DESC, d.last_online DESC
104 array($_CONFIG['top10_max']), __FILE__, __LINE__);
106 $OUT = ""; $SW = 2; $cnt = 1;
107 while(list($uid, $nick, $points, $last) = SQL_FETCHROW($result))
110 if (($nick != $uid) && (!empty($nick))) $nick2 = $nick;
112 // Prepare data for template
116 'uid' => bigintval($uid),
118 'points' => TRANSLATE_COMMA($points),
119 'last' => MAKE_DATETIME($last, "3")
123 $OUT .= LOAD_TEMPLATE("guest_top10_row_earner", true, $content);
125 // Switch colors and count one up
126 $SW = 3 - $SW; $cnt++;
128 if ($cnt < $_CONFIG['top10_max'])
130 // Add more "blank" rows
131 for ($i = $cnt; $i <= $_CONFIG['top10_max']; $i++)
133 // Prepare data for template
140 $OUT .= LOAD_TEMPLATE("guest_top10_empty4", true, $content);
144 define('__TOP_POINTS_ROWS', $OUT);
146 //// TOP referal "hunter"
147 $result = SQL_QUERY_ESC("SELECT DISTINCT r.userid, d.".$ADD.", SUM(r.counter) AS refs, d.last_online
148 FROM "._MYSQL_PREFIX."_refsystem AS r
149 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
151 WHERE r.counter > 0 AND d.status='CONFIRMED'
153 ORDER BY refs DESC, d.last_online DESC
155 array($_CONFIG['top10_max']), __FILE__, __LINE__);
157 $OUT = ""; $SW = 2; $cnt = 1;
158 while(list($uid, $nick, $refs, $last) = SQL_FETCHROW($result))
161 if (($nick != $uid) && (!empty($nick))) $nick2 = $nick;
163 // Prepare data for template
167 'uid' => bigintval($uid),
170 'points' => TRANSLATE_COMMA(GET_TOTAL_DATA($uid, "user_points", "points")),
171 'last' => MAKE_DATETIME($last, "3")
175 $OUT .= LOAD_TEMPLATE("guest_top10_row_refs", true, $content);
177 // Switch colors and count one up
178 $SW = 3 - $SW; $cnt++;
180 if ($cnt < $_CONFIG['top10_max'])
182 // Add more "blank" rows
183 for ($i = $cnt; $i <= $_CONFIG['top10_max']; $i++)
185 // Prepare data for template
192 $OUT .= LOAD_TEMPLATE("guest_top10_empty5", true, $content);
196 define('__TOP_REFERRAL_ROWS', $OUT);
198 // Remember other values in constants
199 define('__TOP10_MAX', $_CONFIG['top10_max']);
201 // Load final template
202 LOAD_TEMPLATE("guest_top10");