2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
45 // Add description as navigation point
46 addMenuDescription('guest', __FILE__);
48 if ((!isExtensionActive('top10')) && (!isAdmin())) {
49 loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('top10'));
57 $result = SQL_QUERY("SELECT
58 `userid`, `total_logins`, `last_online`
60 `{?_MYSQL_PREFIX?}_user_data`
62 `total_logins` > 0 AND
66 LIMIT {?top10_max?}", __FILE__, __LINE__);
68 $OUT = ''; $SW = 2; $cnt = 1;
69 while ($content = SQL_FETCHARRAY($result)) {
71 $content['nickname'] = '---';
74 if (isExtensionActive('nickname')) $content['nickname'] = getNickname($content['userid']);
76 // Prepare data for template
80 'userid' => $content['userid'],
81 'nickname' => $content['nickname'],
82 'total_logins' => $content['total_logins'],
83 'points' => translateComma(countSumTotalData($content['userid'], 'user_points', 'points')),
84 'last_online' => generateDateTime($content['last_online'], 3),
88 $OUT .= loadTemplate('guest_top10_row_login', true, $content);
90 // Switch colors and count one up
91 $SW = 3 - $SW; $cnt++;
94 if ($cnt < getConfig('top10_max')) {
95 // Add more "blank" rows
96 for ($i = $cnt; $i <= getConfig('top10_max'); $i++) {
97 // Prepare data for template
104 $OUT .= loadTemplate('guest_top10_empty5', true, $content);
109 // Remember the rows in array
110 $rows['logins_out'] = $OUT;
113 SQL_FREERESULT($result);
116 $result = SQL_QUERY("SELECT
118 (SUM(p.points) - d.used_points) AS points,
121 `{?_MYSQL_PREFIX?}_user_data` AS d
123 {?_MYSQL_PREFIX?}_user_points AS p
128 d.`status`='CONFIRMED'
134 LIMIT {?top10_max?}", __FILE__, __LINE__);
136 $OUT = ''; $SW = 2; $cnt = 1;
137 while ($content = SQL_FETCHARRAY($result)) {
139 $content['nickname'] = '---';
142 if (isExtensionActive('nickname')) $content['nickname'] = getNickname($content['userid']);
144 // Prepare data for template
148 'userid' => $content['userid'],
149 'nickname' => $content['nickname'],
150 'points' => translateComma($content['points']),
151 'last_online' => generateDateTime($content['last_online'], 3)
155 $OUT .= loadTemplate('guest_top10_row_earner', true, $content);
157 // Switch colors and count one up
158 $SW = 3 - $SW; $cnt++;
161 if ($cnt < getConfig('top10_max')) {
162 // Add more "blank" rows
163 for ($i = $cnt; $i <= getConfig('top10_max'); $i++) {
164 // Prepare data for template
171 $OUT .= loadTemplate('guest_top10_empty4', true, $content);
176 // Remember the rows in array
177 $rows['points_out'] = $OUT;
180 SQL_FREERESULT($result);
182 //// TOP referal "hunter"
183 $result = SQL_QUERY("SELECT
185 SUM(r.counter) AS refs,
188 `{?_MYSQL_PREFIX?}_user_data` AS d
190 {?_MYSQL_PREFIX?}_refsystem AS r
195 d.`status`='CONFIRMED'
201 LIMIT {?top10_max?}", __FILE__, __LINE__);
203 $OUT = ''; $SW = 2; $cnt = 1;
204 while ($content = SQL_FETCHARRAY($result)) {
206 $content['nickname'] = '---';
209 if (isExtensionActive('nickname')) $content['nickname'] = getNickname($content['userid']);
211 // Prepare data for template
215 'userid' => $content['userid'],
216 'refs' => $content['refs'],
217 'nickname' => $content['nickname'],
218 'points' => translateComma(countSumTotalData($content['userid'], 'user_points', 'points')),
219 'last_online' => generateDateTime($content['last_online'], 3)
223 $OUT .= loadTemplate('guest_top10_row_refs', true, $content);
225 // Switch colors and count one up
226 $SW = 3 - $SW; $cnt++;
229 if ($cnt < getConfig('top10_max')) {
230 // Add more "blank" rows
231 for ($i = $cnt; $i <= getConfig('top10_max'); $i++) {
232 // Prepare data for template
239 $OUT .= loadTemplate('guest_top10_empty5', true, $content);
244 // Remember the rows in array
245 $rows['referals_out'] = $OUT;
248 SQL_FREERESULT($result);
250 // Load final template
251 loadTemplate('guest_top10', false, $rows);