]> git.mxchange.org Git - mailer.git/blob - inc/modules/guest/what-top10.php
More code parts could take advantage of previously improved fixEmptyContentToDashes():
[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         displayMessage(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         // Prepare data for template
69         $content = array(
70                 'cnt'          => $count,
71                 'userid'       => $content['userid'],
72                 'nickname'     => $content['nickname'],
73                 'total_logins' => $content['total_logins'],
74                 'points'       => getTotalPoints($content['userid']),
75                 'last_online'  => generateDateTime($content['last_online'], 3),
76         );
77
78         // Load row template
79         $OUT .= loadTemplate('guest_top10_row_login', true, $content);
80
81         // Count one up
82         $count++;
83 } // END - while
84
85 if ($count < getConfig('top10_max')) {
86         // Add more "blank" rows
87         for ($i = $count; $i <= getConfig('top10_max'); $i++) {
88                 // Prepare data for template
89                 $content = array(
90                         'index' => $i
91                 );
92
93                 // Load row template
94                 $OUT .= loadTemplate('guest_top10_empty5', true, $content);
95         } // END - for
96 } // END - if
97
98 // Remember the rows in array
99 $rows['logins_out'] = $OUT;
100
101 // Free result
102 SQL_FREERESULT($result);
103
104 // TOP earners
105 $result = SQL_QUERY("SELECT
106         d.userid,
107         (SUM(p.points) - d.used_points) AS `points`,
108         d.last_online
109 FROM
110         `{?_MYSQL_PREFIX?}_user_data` AS d
111 LEFT JOIN
112         {?_MYSQL_PREFIX?}_user_points AS p
113 ON
114         p.userid=d.userid
115 WHERE
116         p.points > 0 AND
117         d.`status`='CONFIRMED'
118 GROUP BY
119         p.userid
120 ORDER BY
121         points DESC,
122         d.last_online DESC
123 LIMIT {?top10_max?}", __FILE__, __LINE__);
124
125 $OUT = ''; $count = 1;
126 while ($content = SQL_FETCHARRAY($result)) {
127         // Prepare data for template
128         $content = array(
129                 'cnt'         => $count,
130                 'userid'      => $content['userid'],
131                 'nickname'    => $content['nickname'],
132                 'points'      => $content['points'],
133                 'last_online' => generateDateTime($content['last_online'], 3)
134         );
135
136         // Load row template
137         $OUT .= loadTemplate('guest_top10_row_earner', true, $content);
138
139         // Count one up
140         $count++;
141 } // END - while
142
143 if ($count < getConfig('top10_max')) {
144         // Add more "blank" rows
145         for ($i = $count; $i <= getConfig('top10_max'); $i++) {
146                 // Prepare data for template
147                 $content = array(
148                         'index' => $i
149                 );
150
151                 // Load row template
152                 $OUT .= loadTemplate('guest_top10_empty4', true, $content);
153         } // END - for
154 } // END - if
155
156 // Remember the rows in array
157 $rows['points_out'] = $OUT;
158
159 // Free result
160 SQL_FREERESULT($result);
161
162 // TOP referal "hunter"
163 $result = SQL_QUERY("SELECT
164         d.userid,
165         SUM(r.counter) AS refs,
166         d.last_online
167 FROM
168         `{?_MYSQL_PREFIX?}_user_data` AS d
169 LEFT JOIN
170         {?_MYSQL_PREFIX?}_refsystem AS r
171 ON
172         r.userid=d.userid
173 WHERE
174         r.counter > 0 AND
175         d.`status`='CONFIRMED'
176 GROUP BY
177         r.userid
178 ORDER BY
179         refs DESC,
180         d.last_online DESC
181 LIMIT {?top10_max?}", __FILE__, __LINE__);
182
183 $OUT = ''; $count = 1;
184 while ($content = SQL_FETCHARRAY($result)) {
185         // Prepare data for template
186         $content = array(
187                 'cnt'         => $count,
188                 'userid'      => $content['userid'],
189                 'refs'        => $content['refs'],
190                 'nickname'    => $content['nickname'],
191                 'last_online' => generateDateTime($content['last_online'], 3)
192         );
193
194         // Load row template
195         $OUT .= loadTemplate('guest_top10_row_refs', true, $content);
196
197         // Count one up
198         $count++;
199 } // END - while
200
201 if ($count < getConfig('top10_max')) {
202         // Add more "blank" rows
203         for ($i = $count; $i <= getConfig('top10_max'); $i++) {
204                 // Prepare data for template
205                 $content = array(
206                         'index' => $i
207                 );
208
209                 // Load row template
210                 $OUT .= loadTemplate('guest_top10_empty5', true, $content);
211         } // END - for
212 } // END - if
213
214 // Remember the rows in array
215 $rows['referals_out'] = $OUT;
216
217 // Free result
218 SQL_FREERESULT($result);
219
220 // Load final template
221 loadTemplate('guest_top10', false, $rows);
222
223 // [EOF]
224 ?>