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