]> git.mxchange.org Git - mailer.git/blob - inc/modules/guest/what-top10.php
mailer project continued:
[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 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://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         exit();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('guest', __FILE__);
45
46 if ((!isExtensionActive('top10')) && (!isAdmin())) {
47         displayMessage('{%pipe,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`,`last_online`
57 FROM
58         `{?_MYSQL_PREFIX?}_user_data`
59 WHERE
60         `total_logins` > 0 AND
61         `status`='CONFIRMED'
62         " . runFilterChain('user_exclusion_sql', ' ') . "
63 ORDER BY
64         `total_logins` DESC
65 LIMIT {?top10_max?}", __FILE__, __LINE__);
66
67 $OUT = ''; $count = 1;
68 while ($content = SQL_FETCHARRAY($result)) {
69         // Prepare data for template
70         $content = array(
71                 'count'        => $count,
72                 'userid'       => $content['userid'],
73                 'last_online'  => generateDateTime($content['last_online'], '3'),
74         );
75
76         // Load row template
77         $OUT .= loadTemplate('guest_top10_row_login', true, $content);
78
79         // Count one up
80         $count++;
81 } // END - while
82
83 if ($count < getConfig('top10_max')) {
84         // Add more "blank" rows
85         for ($i = $count; $i <= getConfig('top10_max'); $i++) {
86                 // Prepare data for template
87                 $content = array(
88                         'index' => $i
89                 );
90
91                 // Load row template
92                 $OUT .= loadTemplate('guest_top10_empty5', true, $content);
93         } // END - for
94 } // END - if
95
96 // Remember the rows in array
97 $rows['logins_out'] = $OUT;
98
99 // Free result
100 SQL_FREERESULT($result);
101
102 // TOP earners
103 $result = SQL_QUERY("SELECT
104         d.userid,
105         (SUM(p.points) - d.used_points) AS `points`,
106         d.last_online
107 FROM
108         `{?_MYSQL_PREFIX?}_user_data` AS d
109 LEFT JOIN
110         {?_MYSQL_PREFIX?}_user_points AS p
111 ON
112         p.userid=d.userid
113 WHERE
114         p.points > 0 AND
115         d.`status`='CONFIRMED'
116         " . runFilterChain('user_exclusion_sql', ' ') . "
117 GROUP BY
118         p.userid
119 ORDER BY
120         points DESC,
121         d.last_online DESC
122 LIMIT {?top10_max?}", __FILE__, __LINE__);
123
124 $OUT = ''; $count = 1;
125 while ($content = SQL_FETCHARRAY($result)) {
126         // Prepare data for template
127         $content['count']       = $count;
128         $content['last_online'] = generateDateTime($content['last_online'], '3');
129
130         // Load row template
131         $OUT .= loadTemplate('guest_top10_row_earner', true, $content);
132
133         // Count one up
134         $count++;
135 } // END - while
136
137 if ($count < getConfig('top10_max')) {
138         // Add more "blank" rows
139         for ($i = $count; $i <= getConfig('top10_max'); $i++) {
140                 // Prepare data for template
141                 $content = array(
142                         'index' => $i
143                 );
144
145                 // Load row template
146                 $OUT .= loadTemplate('guest_top10_empty4', true, $content);
147         } // END - for
148 } // END - if
149
150 // Remember the rows in array
151 $rows['points_out'] = $OUT;
152
153 // Free result
154 SQL_FREERESULT($result);
155
156 // TOP referral "hunter"
157 $result = SQL_QUERY("SELECT
158         d.userid,
159         SUM(r.counter) AS refs,
160         d.last_online
161 FROM
162         `{?_MYSQL_PREFIX?}_user_data` AS d
163 LEFT JOIN
164         {?_MYSQL_PREFIX?}_refsystem AS r
165 ON
166         r.userid=d.userid
167 WHERE
168         r.counter > 0 AND
169         d.`status`='CONFIRMED'
170         " . runFilterChain('user_exclusion_sql', ' ') . "
171 GROUP BY
172         r.userid
173 ORDER BY
174         refs DESC,
175         d.last_online DESC
176 LIMIT {?top10_max?}", __FILE__, __LINE__);
177
178 $OUT = ''; $count = 1;
179 while ($content = SQL_FETCHARRAY($result)) {
180         // Prepare data for template
181         $content = array(
182                 'count'       => $count,
183                 'userid'      => $content['userid'],
184                 'refs'        => $content['refs'],
185                 'last_online' => generateDateTime($content['last_online'], '3')
186         );
187
188         // Load row template
189         $OUT .= loadTemplate('guest_top10_row_refs', true, $content);
190
191         // Count one up
192         $count++;
193 } // END - while
194
195 if ($count < getConfig('top10_max')) {
196         // Add more "blank" rows
197         for ($i = $count; $i <= getConfig('top10_max'); $i++) {
198                 // Prepare data for template
199                 $content = array(
200                         'index' => $i
201                 );
202
203                 // Load row template
204                 $OUT .= loadTemplate('guest_top10_empty5', true, $content);
205         } // END - for
206 } // END - if
207
208 // Remember the rows in array
209 $rows['referrals_out'] = $OUT;
210
211 // Free result
212 SQL_FREERESULT($result);
213
214 // Load final template
215 loadTemplate('guest_top10', false, $rows);
216
217 // [EOF]
218 ?>