]> git.mxchange.org Git - mailer.git/blob - inc/modules/guest/what-top10.php
Added update_year.sh (still not fully flexible) and updated all years with it.
[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  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
14  * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
15  * For more information visit: http://mxchange.org                      *
16  *                                                                      *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or    *
20  * (at your option) any later version.                                  *
21  *                                                                      *
22  * This program is distributed in the hope that it will be useful,      *
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
25  * GNU General Public License for more details.                         *
26  *                                                                      *
27  * You should have received a copy of the GNU General Public License    *
28  * along with this program; if not, write to the Free Software          *
29  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
30  * MA  02110-1301  USA                                                  *
31  ************************************************************************/
32
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
35         exit();
36 } // END - if
37
38 // Add description as navigation point
39 addYouAreHereLink('guest', __FILE__);
40
41 if ((!isExtensionActive('top10')) && (!isAdmin())) {
42         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=top10%}');
43         return;
44 } // END - if
45
46 // Init array
47 $rows = array();
48
49 // TOP logins
50 $result = sqlQuery("SELECT
51         `userid`,
52         `last_online`
53 FROM
54         `{?_MYSQL_PREFIX?}_user_data`
55 WHERE
56         `total_logins` > 0 AND
57         `status`='CONFIRMED'
58         " . runFilterChain('user_exclusion_sql', ' ') . "
59 ORDER BY
60         `total_logins` DESC
61 LIMIT {?top10_max?}", __FILE__, __LINE__);
62
63 $OUT = ''; $count = 1;
64 while ($content = sqlFetchArray($result)) {
65         // Prepare data for template
66         $content = array(
67                 'count'        => $count,
68                 'userid'       => $content['userid'],
69                 'last_online'  => generateDateTime($content['last_online'], '3'),
70         );
71
72         // Load row template
73         $OUT .= loadTemplate('guest_top10_row_login', TRUE, $content);
74
75         // Count one up
76         $count++;
77 } // END - while
78
79 if ($count < getTop10Max()) {
80         // Add more "blank" rows
81         for ($i = $count; $i <= getTop10Max(); $i++) {
82                 // Prepare data for template
83                 $content = array(
84                         'index' => $i
85                 );
86
87                 // Load row template
88                 $OUT .= loadTemplate('guest_top10_empty5', TRUE, $content);
89         } // END - for
90 } // END - if
91
92 // Remember the rows in array
93 $rows['logins_out'] = $OUT;
94
95 // Free result
96 sqlFreeResult($result);
97
98 // TOP earners
99 $result = sqlQuery("SELECT
100         `d`.`userid`,
101         SUM(`p`.`points` + `p`.`locked_points`) AS `points`,
102         `d`.`last_online`
103 FROM
104         `{?_MYSQL_PREFIX?}_user_data` AS `d`
105 LEFT JOIN
106         {?_MYSQL_PREFIX?}_user_points AS `p`
107 ON
108         `p`.`userid`=`d`.`userid`
109 WHERE
110         `p`.`points` > 0 AND
111         `d`.`status`='CONFIRMED'
112         " . runFilterChain('user_exclusion_sql', ' ') . "
113 GROUP BY
114         `p`.`userid`
115 ORDER BY
116         `points` DESC,
117         `d`.`last_online` DESC
118 LIMIT {?top10_max?}", __FILE__, __LINE__);
119
120 $OUT = ''; $count = 1;
121 while ($content = sqlFetchArray($result)) {
122         // Prepare data for template
123         $content['count']       = $count;
124         $content['last_online'] = generateDateTime($content['last_online'], '3');
125
126         // Load row template
127         $OUT .= loadTemplate('guest_top10_row_earner', TRUE, $content);
128
129         // Count one up
130         $count++;
131 } // END - while
132
133 if ($count < getTop10Max()) {
134         // Add more "blank" rows
135         for ($i = $count; $i <= getTop10Max(); $i++) {
136                 // Prepare data for template
137                 $content = array(
138                         'index' => $i
139                 );
140
141                 // Load row template
142                 $OUT .= loadTemplate('guest_top10_empty4', TRUE, $content);
143         } // END - for
144 } // END - if
145
146 // Remember the rows in array
147 $rows['points_out'] = $OUT;
148
149 // Free result
150 sqlFreeResult($result);
151
152 // TOP referral "hunter"
153 $result = sqlQuery("SELECT
154         `d`.`userid`,
155         SUM(`r`.`counter`) AS `refs`,
156         `d`.`last_online`
157 FROM
158         `{?_MYSQL_PREFIX?}_user_data` AS `d`
159 LEFT JOIN
160         {?_MYSQL_PREFIX?}_refsystem AS `r`
161 ON
162         `r`.`userid`=`d`.`userid`
163 WHERE
164         `r`.`counter` > 0 AND
165         `d`.`status`='CONFIRMED'
166         " . runFilterChain('user_exclusion_sql', ' ') . "
167 GROUP BY
168         `r`.`userid`
169 ORDER BY
170         `refs` DESC,
171         `d`.`last_online` DESC
172 LIMIT {?top10_max?}", __FILE__, __LINE__);
173
174 $OUT = ''; $count = 1;
175 while ($content = sqlFetchArray($result)) {
176         // Prepare data for template
177         $content = array(
178                 'count'       => $count,
179                 'userid'      => $content['userid'],
180                 'refs'        => $content['refs'],
181                 'last_online' => generateDateTime($content['last_online'], '3')
182         );
183
184         // Load row template
185         $OUT .= loadTemplate('guest_top10_row_refs', TRUE, $content);
186
187         // Count one up
188         $count++;
189 } // END - while
190
191 if ($count < getTop10Max()) {
192         // Add more "blank" rows
193         for ($i = $count; $i <= getTop10Max(); $i++) {
194                 // Prepare data for template
195                 $content = array(
196                         'index' => $i
197                 );
198
199                 // Load row template
200                 $OUT .= loadTemplate('guest_top10_empty5', TRUE, $content);
201         } // END - for
202 } // END - if
203
204 // Remember the rows in array
205 $rows['referrals_out'] = $OUT;
206
207 // Free result
208 sqlFreeResult($result);
209
210 // Load final template
211 loadTemplate('guest_top10', FALSE, $rows);
212
213 // [EOF]
214 ?>