2 /************************************************************************
\r
3 * MXChange v0.2.1 Start: 11/24/2004 *
\r
4 * ================ Last change: 11/26/2004 *
\r
6 * -------------------------------------------------------------------- *
\r
7 * File : what-top10.php *
\r
8 * -------------------------------------------------------------------- *
\r
9 * Short description : TOP logins / best earner etc. *
\r
10 * -------------------------------------------------------------------- *
\r
11 * Kurzbeschreibung : TOP-Logins / Bestverdiener usw. *
\r
12 * -------------------------------------------------------------------- *
\r
14 * -------------------------------------------------------------------- *
\r
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
\r
16 * For more information visit: http://www.mxchange.org *
\r
18 * This program is free software; you can redistribute it and/or modify *
\r
19 * it under the terms of the GNU General Public License as published by *
\r
20 * the Free Software Foundation; either version 2 of the License, or *
\r
21 * (at your option) any later version. *
\r
23 * This program is distributed in the hope that it will be useful, *
\r
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
\r
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
\r
26 * GNU General Public License for more details. *
\r
28 * You should have received a copy of the GNU General Public License *
\r
29 * along with this program; if not, write to the Free Software *
\r
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
\r
31 * MA 02110-1301 USA *
\r
32 ************************************************************************/
\r
34 // Some security stuff...
\r
35 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
\r
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
\r
40 elseif ((!EXT_IS_ACTIVE("top10")) && (!IS_ADMIN()))
\r
42 ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "top10");
\r
46 // Add description as navigation point
\r
47 ADD_DESCR("guest", basename(__FILE__));
\r
51 if (EXT_IS_ACTIVE("nickname")) $ADD = "nickname";
\r
52 $result = SQL_QUERY_ESC("SELECT userid, ".$ADD.", total_logins, last_online
\r
53 FROM "._MYSQL_PREFIX."_user_data
\r
54 WHERE total_logins>0 AND status='CONFIRMED' ORDER BY total_logins DESC LIMIT %s",
\r
55 array($CONFIG['top10_max']), __FILE__, __LINE__);
\r
57 $OUT = ""; $SW = 2; $cnt = 1;
\r
58 while(list($uid, $nick, $logins, $last) = SQL_FETCHROW($result))
\r
61 if (($nick != $uid) && (!empty($nick))) $nick2 = $nick;
\r
63 // Prepare data for template
\r
69 'logins' => $logins,
\r
70 'points' => TRANSLATE_COMMA(GET_TOTAL_DATA($uid, "user_points", "points")),
\r
71 'last' => MAKE_DATETIME($last, "3"),
\r
74 // Load row template
\r
75 $OUT .= LOAD_TEMPLATE("guest_top10_row_login", true, $content);
\r
77 // Switch colors and count one up
\r
78 $SW = 3 - $SW; $cnt++;
\r
80 if ($cnt < $CONFIG['top10_max'])
\r
82 // Add more "blank" rows
\r
83 for ($i = $cnt; $i <= $CONFIG['top10_max']; $i++)
\r
85 // Prepare data for template
\r
91 // Load row template
\r
92 $OUT .= LOAD_TEMPLATE("guest_top10_empty5", true, $content);
\r
96 define('__TOP_LOGINS_ROWS', $OUT);
\r
99 $result = SQL_QUERY_ESC("SELECT DISTINCT p.userid, d.".$ADD.", (SUM(p.points) - d.used_points) AS tpoints, d.last_online
\r
100 FROM "._MYSQL_PREFIX."_user_points AS p
\r
101 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
\r
102 ON p.userid=d.userid
\r
103 WHERE p.points > 0 AND d.status='CONFIRMED'
\r
105 ORDER BY tpoints DESC, d.last_online DESC
\r
107 array($CONFIG['top10_max']), __FILE__, __LINE__);
\r
109 $OUT = ""; $SW = 2; $cnt = 1;
\r
110 while(list($uid, $nick, $points, $last) = SQL_FETCHROW($result))
\r
113 if (($nick != $uid) && (!empty($nick))) $nick2 = $nick;
\r
115 // Prepare data for template
\r
119 'uid' => bigintval($uid),
\r
121 'points' => TRANSLATE_COMMA($points),
\r
122 'last' => MAKE_DATETIME($last, "3")
\r
125 // Load row template
\r
126 $OUT .= LOAD_TEMPLATE("guest_top10_row_earner", true, $content);
\r
128 // Switch colors and count one up
\r
129 $SW = 3 - $SW; $cnt++;
\r
131 if ($cnt < $CONFIG['top10_max'])
\r
133 // Add more "blank" rows
\r
134 for ($i = $cnt; $i <= $CONFIG['top10_max']; $i++)
\r
136 // Prepare data for template
\r
142 // Load row template
\r
143 $OUT .= LOAD_TEMPLATE("guest_top10_empty4", true, $content);
\r
147 define('__TOP_POINTS_ROWS', $OUT);
\r
149 //// TOP referral "hunter"
\r
150 $result = SQL_QUERY_ESC("SELECT DISTINCT r.userid, d.".$ADD.", SUM(r.counter) AS refs, d.last_online
\r
151 FROM "._MYSQL_PREFIX."_refsystem AS r
\r
152 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
\r
153 ON r.userid=d.userid
\r
154 WHERE r.counter > 0 AND d.status='CONFIRMED'
\r
156 ORDER BY refs DESC, d.last_online DESC
\r
158 array($CONFIG['top10_max']), __FILE__, __LINE__);
\r
160 $OUT = ""; $SW = 2; $cnt = 1;
\r
161 while(list($uid, $nick, $refs, $last) = SQL_FETCHROW($result))
\r
164 if (($nick != $uid) && (!empty($nick))) $nick2 = $nick;
\r
166 // Prepare data for template
\r
170 'uid' => bigintval($uid),
\r
173 'points' => TRANSLATE_COMMA(GET_TOTAL_DATA($uid, "user_points", "points")),
\r
174 'last' => MAKE_DATETIME($last, "3")
\r
177 // Load row template
\r
178 $OUT .= LOAD_TEMPLATE("guest_top10_row_refs", true, $content);
\r
180 // Switch colors and count one up
\r
181 $SW = 3 - $SW; $cnt++;
\r
183 if ($cnt < $CONFIG['top10_max'])
\r
185 // Add more "blank" rows
\r
186 for ($i = $cnt; $i <= $CONFIG['top10_max']; $i++)
\r
188 // Prepare data for template
\r
194 // Load row template
\r
195 $OUT .= LOAD_TEMPLATE("guest_top10_empty5", true, $content);
\r
199 define('__TOP_REFERRAL_ROWS', $OUT);
\r
201 // Remember other values in constants
\r
202 define('__TOP10_MAX', $CONFIG['top10_max']);
\r
204 // Load final template
\r
205 LOAD_TEMPLATE("guest_top10");
\r