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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 elseif ((!EXT_IS_ACTIVE("top10")) && (!IS_ADMIN()))
42 ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "top10");
46 // Add description as navigation point
47 ADD_DESCR("guest", basename(__FILE__));
51 if (EXT_IS_ACTIVE("nickname")) $ADD = "nickname";
52 $result = SQL_QUERY_ESC("SELECT userid, ".$ADD.", total_logins, last_online
53 FROM "._MYSQL_PREFIX."_user_data
54 WHERE total_logins>0 AND status='CONFIRMED' ORDER BY total_logins DESC LIMIT %s",
55 array($_CONFIG['top10_max']), __FILE__, __LINE__);
57 $OUT = ""; $SW = 2; $cnt = 1;
58 while(list($uid, $nick, $logins, $last) = SQL_FETCHROW($result))
61 if (($nick != $uid) && (!empty($nick))) $nick2 = $nick;
63 // Prepare data for template
70 'points' => TRANSLATE_COMMA(GET_TOTAL_DATA($uid, "user_points", "points")),
71 'last' => MAKE_DATETIME($last, "3"),
75 $OUT .= LOAD_TEMPLATE("guest_top10_row_login", true, $content);
77 // Switch colors and count one up
78 $SW = 3 - $SW; $cnt++;
80 if ($cnt < $_CONFIG['top10_max'])
82 // Add more "blank" rows
83 for ($i = $cnt; $i <= $_CONFIG['top10_max']; $i++)
85 // Prepare data for template
92 $OUT .= LOAD_TEMPLATE("guest_top10_empty5", true, $content);
96 define('__TOP_LOGINS_ROWS', $OUT);
99 $result = SQL_QUERY_ESC("SELECT DISTINCT p.userid, d.".$ADD.", (SUM(p.points) - d.used_points) AS tpoints, d.last_online
100 FROM "._MYSQL_PREFIX."_user_points AS p
101 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
103 WHERE p.points > 0 AND d.status='CONFIRMED'
105 ORDER BY tpoints DESC, d.last_online DESC
107 array($_CONFIG['top10_max']), __FILE__, __LINE__);
109 $OUT = ""; $SW = 2; $cnt = 1;
110 while(list($uid, $nick, $points, $last) = SQL_FETCHROW($result))
113 if (($nick != $uid) && (!empty($nick))) $nick2 = $nick;
115 // Prepare data for template
119 'uid' => bigintval($uid),
121 'points' => TRANSLATE_COMMA($points),
122 'last' => MAKE_DATETIME($last, "3")
126 $OUT .= LOAD_TEMPLATE("guest_top10_row_earner", true, $content);
128 // Switch colors and count one up
129 $SW = 3 - $SW; $cnt++;
131 if ($cnt < $_CONFIG['top10_max'])
133 // Add more "blank" rows
134 for ($i = $cnt; $i <= $_CONFIG['top10_max']; $i++)
136 // Prepare data for template
143 $OUT .= LOAD_TEMPLATE("guest_top10_empty4", true, $content);
147 define('__TOP_POINTS_ROWS', $OUT);
149 //// TOP referral "hunter"
150 $result = SQL_QUERY_ESC("SELECT DISTINCT r.userid, d.".$ADD.", SUM(r.counter) AS refs, d.last_online
151 FROM "._MYSQL_PREFIX."_refsystem AS r
152 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
154 WHERE r.counter > 0 AND d.status='CONFIRMED'
156 ORDER BY refs DESC, d.last_online DESC
158 array($_CONFIG['top10_max']), __FILE__, __LINE__);
160 $OUT = ""; $SW = 2; $cnt = 1;
161 while(list($uid, $nick, $refs, $last) = SQL_FETCHROW($result))
164 if (($nick != $uid) && (!empty($nick))) $nick2 = $nick;
166 // Prepare data for template
170 'uid' => bigintval($uid),
173 'points' => TRANSLATE_COMMA(GET_TOTAL_DATA($uid, "user_points", "points")),
174 'last' => MAKE_DATETIME($last, "3")
178 $OUT .= LOAD_TEMPLATE("guest_top10_row_refs", true, $content);
180 // Switch colors and count one up
181 $SW = 3 - $SW; $cnt++;
183 if ($cnt < $_CONFIG['top10_max'])
185 // Add more "blank" rows
186 for ($i = $cnt; $i <= $_CONFIG['top10_max']; $i++)
188 // Prepare data for template
195 $OUT .= LOAD_TEMPLATE("guest_top10_empty5", true, $content);
199 define('__TOP_REFERRAL_ROWS', $OUT);
201 // Remember other values in constants
202 define('__TOP10_MAX', $_CONFIG['top10_max']);
204 // Load final template
205 LOAD_TEMPLATE("guest_top10");