Some language strings fixed, renamed. Copyright notice updated
[mailer.git] / inc / modules / guest / what-top10.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 11/24/2004 *
4  * ===================                          Last change: 11/26/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-top10.php                                   *
8  * -------------------------------------------------------------------- *
9  * Short description : TOP logins / best earner etc.                    *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : TOP-Logins / Bestverdiener usw.                  *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('guest', __FILE__);
45
46 if ((!isExtensionActive('top10')) && (!isAdmin())) {
47         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('top10'));
48         return;
49 } // END - if
50
51 // Init array
52 $rows = array();
53
54 //// TOP logins
55 $result = SQL_QUERY("SELECT
56         `userid`, `total_logins`, `last_online`
57 FROM
58         `{?_MYSQL_PREFIX?}_user_data`
59 WHERE
60         `total_logins` > 0 AND
61         `status`='CONFIRMED'
62 ORDER BY
63         `total_logins` DESC
64 LIMIT {?top10_max?}", __FILE__, __LINE__);
65
66 $OUT = ''; $count = 1;
67 while ($content = SQL_FETCHARRAY($result)) {
68         // Init nickname
69         $content['nickname'] = '';
70
71         // Get nickname
72         if (isExtensionActive('nickname')) $content['nickname'] = getNickname($content['userid']);
73
74         // Prepare data for template
75         $content = array(
76                 'cnt'          => $count,
77                 'userid'       => $content['userid'],
78                 'nickname'     => $content['nickname'],
79                 'total_logins' => $content['total_logins'],
80                 'points'       => getTotalPoints($content['userid']),
81                 'last_online'  => generateDateTime($content['last_online'], 3),
82         );
83
84         // Load row template
85         $OUT .= loadTemplate('guest_top10_row_login', true, $content);
86
87         // Count one up
88         $count++;
89 } // END - while
90
91 if ($count < getConfig('top10_max')) {
92         // Add more "blank" rows
93         for ($i = $count; $i <= getConfig('top10_max'); $i++) {
94                 // Prepare data for template
95                 $content = array(
96                         'index' => $i
97                 );
98
99                 // Load row template
100                 $OUT .= loadTemplate('guest_top10_empty5', true, $content);
101         } // END - for
102 } // END - if
103
104 // Remember the rows in array
105 $rows['logins_out'] = $OUT;
106
107 // Free result
108 SQL_FREERESULT($result);
109
110 //// TOP earners
111 $result = SQL_QUERY("SELECT
112         d.userid,
113         (SUM(p.points) - d.used_points) AS points,
114         d.last_online
115 FROM
116         `{?_MYSQL_PREFIX?}_user_data` AS d
117 LEFT JOIN
118         {?_MYSQL_PREFIX?}_user_points AS p
119 ON
120         p.userid=d.userid
121 WHERE
122         p.points > 0 AND
123         d.`status`='CONFIRMED'
124 GROUP BY
125         p.userid
126 ORDER BY
127         points DESC,
128         d.last_online DESC
129 LIMIT {?top10_max?}", __FILE__, __LINE__);
130
131 $OUT = ''; $count = 1;
132 while ($content = SQL_FETCHARRAY($result)) {
133         // Init nickname
134         $content['nickname'] = '';
135
136         // Get nickname
137         if (isExtensionActive('nickname')) $content['nickname'] = getNickname($content['userid']);
138
139         // Prepare data for template
140         $content = array(
141                 'cnt'         => $count,
142                 'userid'      => $content['userid'],
143                 'nickname'    => $content['nickname'],
144                 'points'      => $content['points'],
145                 'last_online' => generateDateTime($content['last_online'], 3)
146         );
147
148         // Load row template
149         $OUT .= loadTemplate('guest_top10_row_earner', true, $content);
150
151         // Count one up
152         $count++;
153 } // END - while
154
155 if ($count < getConfig('top10_max')) {
156         // Add more "blank" rows
157         for ($i = $count; $i <= getConfig('top10_max'); $i++) {
158                 // Prepare data for template
159                 $content = array(
160                         'index' => $i
161                 );
162
163                 // Load row template
164                 $OUT .= loadTemplate('guest_top10_empty4', true, $content);
165         } // END - for
166 } // END - if
167
168 // Remember the rows in array
169 $rows['points_out'] = $OUT;
170
171 // Free result
172 SQL_FREERESULT($result);
173
174 //// TOP referal "hunter"
175 $result = SQL_QUERY("SELECT
176         d.userid,
177         SUM(r.counter) AS refs,
178         d.last_online
179 FROM
180         `{?_MYSQL_PREFIX?}_user_data` AS d
181 LEFT JOIN
182         {?_MYSQL_PREFIX?}_refsystem AS r
183 ON
184         r.userid=d.userid
185 WHERE
186         r.counter > 0 AND
187         d.`status`='CONFIRMED'
188 GROUP BY
189         r.userid
190 ORDER BY
191         refs DESC,
192         d.last_online DESC
193 LIMIT {?top10_max?}", __FILE__, __LINE__);
194
195 $OUT = ''; $count = 1;
196 while ($content = SQL_FETCHARRAY($result)) {
197         // Init nickname
198         $content['nickname'] = '';
199
200         // Get nickname
201         if (isExtensionActive('nickname')) $content['nickname'] = getNickname($content['userid']);
202
203         // Prepare data for template
204         $content = array(
205                 'cnt'         => $count,
206                 'userid'      => $content['userid'],
207                 'refs'        => $content['refs'],
208                 'nickname'    => $content['nickname'],
209                 'points'      => getTotalPoints($content['userid']),
210                 'last_online' => generateDateTime($content['last_online'], 3)
211         );
212
213         // Load row template
214         $OUT .= loadTemplate('guest_top10_row_refs', true, $content);
215
216         // Count one up
217         $count++;
218 } // END - while
219
220 if ($count < getConfig('top10_max')) {
221         // Add more "blank" rows
222         for ($i = $count; $i <= getConfig('top10_max'); $i++) {
223                 // Prepare data for template
224                 $content = array(
225                         'index' => $i
226                 );
227
228                 // Load row template
229                 $OUT .= loadTemplate('guest_top10_empty5', true, $content);
230         } // END - for
231 } // END - if
232
233 // Remember the rows in array
234 $rows['referals_out'] = $OUT;
235
236 // Free result
237 SQL_FREERESULT($result);
238
239 // Load final template
240 loadTemplate('guest_top10', false, $rows);
241
242 // [EOF]
243 ?>