Missed default value but had already closed editor :(
[mailer.git] / inc / modules / guest / what-mediadata.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 12/09/2003 *
4  * ===================                          Last change: 02/12/2006 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-mediadata.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : Media data                                       *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Mediendaten                                      *
12  * -------------------------------------------------------------------- *
13  *          mod_media - By Robert Niedziela                             *
14  *          (c)2003 www.megacomputing.net                               *
15  * -------------------------------------------------------------------- *
16  *           Rewritten by Roland Haeder, 2003 - 2009                    *
17  * -------------------------------------------------------------------- *
18  * $Revision::                                                        $ *
19  * $Date::                                                            $ *
20  * $Tag:: 0.2.1-FINAL                                                 $ *
21  * $Author::                                                          $ *
22  * -------------------------------------------------------------------- *
23  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
24  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
25  * For more information visit: http://www.mxchange.org                  *
26  *                                                                      *
27  * This program is free software; you can redistribute it and/or modify *
28  * it under the terms of the GNU General Public License as published by *
29  * the Free Software Foundation; either version 2 of the License, or    *
30  * (at your option) any later version.                                  *
31  *                                                                      *
32  * This program is distributed in the hope that it will be useful,      *
33  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
34  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
35  * GNU General Public License for more details.                         *
36  *                                                                      *
37  * You should have received a copy of the GNU General Public License    *
38  * along with this program; if not, write to the Free Software          *
39  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
40  * MA  02110-1301  USA                                                  *
41  ************************************************************************/
42
43 // Some security stuff...
44 if (!defined('__SECURITY')) {
45         die();
46 } // END - if
47
48 // Add description as navigation point
49 addYouAreHereLink('guest', __FILE__);
50
51 if ((!isExtensionActive('mediadata')) && (!isAdmin())) {
52         displayMessage(generateExtensionInactiveNotInstalledMessage('mediadata'));
53         return;
54 } // END - if
55
56 // Get total confirmed user ids...
57 $content['user_confirmed']   = getTotalConfirmedUser();
58 $content['user_unconfirmed'] = getTotalUnconfirmedUser();
59 $content['user_locked']      = getTotalLockedUser();
60 $content['user_count']       = ($content['user_confirmed'] + $content['user_unconfirmed'] + $content['user_locked']);
61
62 // Start of this exchange
63 $content['mt_start'] = generateDateTime(getConfig('mt_start'), 3);
64
65 // Project timestamp when number of members are reached
66 $PROJECTED = '0';
67 if ($content['user_count'] > 0) {
68         // @TODO Find a better formular than this one
69         $PROJECTED = round((time() - getConfig('mt_start')) / $content['user_count'] * getConfig('mt_stage') + getConfig('mt_start'));
70 } // END - if
71
72 // Generate timestamp
73 $TEST = makeTime(0, 0, 0, $PROJECTED);
74
75 if ($TEST > time()) {
76         $content['projected'] = getMaskedMessage('USER_MT_PROJECTED', generateDateTime($PROJECTED, 3));
77 } else {
78         $content['projected'] = getMaskedMessage('USER_MT_PROJECTED', '{--USER_PROJECTION_UNKNOWN--}');
79 }
80
81 // User who can receive mails
82 $content['user_max_mails'] = countSumTotalData('CONFIRMED', 'user_data', 'max_mails', 'status', true, " AND `max_mails` > 0");
83
84 // Users who can receive mails today
85 $content['user_max_rec'] = countSumTotalData('CONFIRMED', 'user_data', 'receive_mails', 'status', true, " AND `receive_mails` > 0");
86
87 // Max mails per day
88 $content['max'] = countSumTotalData('CONFIRMED', 'user_data', 'max_mails', 'status', false, " AND `max_mails` > 0");
89
90 // Max mails for this day
91 $content['rec'] = countSumTotalData('CONFIRMED', 'user_data', 'receive_mails', 'status', false, " AND `receive_mails` > 0");
92
93 // Initial lots of variables
94 $bmails = '0'; $sent = '0'; $max = '0'; $rec = '0'; $clicks = '0';
95
96 // Mail orders (only current)
97 $nmails = getMediadataEntry('normal_orders');
98 if (empty($nmails)) $nmails = '0';
99
100 // Mails sent so far
101 $clicks = getMediadataEntry('normal_clicks');
102 $sent   = getMediadataEntry('normal_send');
103 if (empty($sent))   $sent   = '0';
104 if (empty($clicks)) $clicks = '0';
105
106 // Bonus mails
107 if (isExtensionActive('bonus')) {
108         $bmails = getMediadataEntry('bonus_orders');
109         if (empty($bmails)) $bmails = '0';
110
111         // Count bonus mails clicks / sent mails
112         $dmy  = getMediadataEntry('bonus_clicks');
113         $dmy2 = getMediadataEntry('bonus_send');
114         if (empty($dmy))  $dmy  = '0';
115         if (empty($dmy2)) $dmy2 = '0';
116         $sent += $dmy2; $clicks += $dmy;
117 } // END - if
118
119 $content['user_stats'] = ($nmails + $bmails);
120 $content['sent']       = $sent;
121
122 // All clicks
123 $content['user_links'] = abs($sent - $clicks);
124
125 $clr = '0.00000';
126 if ($sent > 0) $clr = $clicks / $sent * 100;
127 $content['_clr'] = $clr;
128
129 // Load jackpot
130 $jackpot = '0';
131 if (isExtensionActive('jackpot')) $jackpot = getJackpotPoints();
132
133 if (empty($jackpot)) $jackpot = '0';
134 $content['jackpot'] = $jackpot;
135
136 // Total referal link clicks, total logins
137 $result = SQL_QUERY('SELECT
138         SUM(d.ref_clicks), SUM(d.total_logins)
139 FROM
140         `{?_MYSQL_PREFIX?}_user_data` AS d', __FILE__, __LINE__);
141 list($ref, $logins) = SQL_FETCHROW($result);
142 SQL_FREERESULT($result);
143
144 // Get total points
145 $points = getMediadataEntry('total_points');
146
147 if (empty($points)) $points = '0';
148 if (empty($ref))    $ref    = '0';
149 if (empty($logins)) $logins = '0';
150
151 $content['total_points']    = $points;
152 $content['total_refclicks'] = $ref;
153 $content['total_logins']    = $logins;
154
155 // Referal banner
156 $total = countSumTotalData('Y', 'refbanner', 'id', 'visible', true);
157
158 // Total views and clicks
159 $result = SQL_QUERY("SELECT SUM(`counter`) AS cnt, SUM(`clicks`) AS clx FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
160 list($views, $clicks) = SQL_FETCHROW($result);
161 SQL_FREERESULT($result);
162
163 if (empty($total))  $total  = '0';
164 if (empty($views))  $views  = '0';
165 if (empty($clicks)) $clicks = '0';
166
167 $content['ref_total']  = $total;
168 $content['ref_views']  = $views;
169 $content['ref_clicks'] = $clicks;
170
171 //
172 // Extra mediadata depending on installed extensions
173 //
174
175 // Initialize Variables
176 $OUT_EXTRA   = '';
177 $OUT_POINTS  = '';
178 $OUT_USER    = '';
179 $OUT_SPECIAL = ''; // We don't need row count here
180
181 // @TODO Rewrite all these if-blocks to filters
182 if (isExtensionActive('beg')) {
183         // Clicks on beg links
184         $data = array(
185                 'lang'  => '{--MEDIA_BEG_CLICKS--}',
186                 'value' => countSumTotalData('0', 'user_data', 'beg_clicks', 'userid', false, ' AND `beg_clicks` > 0')
187         );
188         $OUT_EXTRA .= loadTemplate('mediadata_extra_row', true, $data);
189 } // END - if
190
191 if (isExtensionActive('doubler')) {
192         // Add header
193         $OUT_SPECIAL .= loadTemplate('mediadata_extra_hrow', true, '{--MEDIA_DOUBLER_HEADER--}');
194
195         // Add first line (count)
196         $data = array(
197                 'lang'  => '{--MEDIA_DOUBLER_COUNT--}',
198                 'value' => countSumTotalData('Y','doubler','id','completed', true, ' AND `points` > 0'),
199         );
200
201         // Add points
202         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row2', true, $data);
203         $data = array(
204                 'lang'  => '{--MEDIA_DOUBLER_CPOINTS--}',
205                 'value' => countSumTotalData('Y','doubler','id','completed', false, ' AND `points` > 0')
206         );
207         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
208         $data = array(
209                 'lang'  => '{--MEDIA_DOUBLER_WAITING--}',
210                 'value' => countSumTotalData('N','doubler','id','completed', true, ' AND `points` > 0')
211         );
212         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
213         $data = array(
214                 'lang'  => '{--MEDIA_DOUBLER_WPOINTS--}',
215                 'value' => countSumTotalData('N','doubler','id','completed', false, ' AND `points` > 0')
216         );
217         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
218 } // END - if
219
220 if (isExtensionActive('holiday')) {
221         // Total holiday requests
222         $result = SQL_QUERY("SELECT
223         COUNT(h.userid) AS count_holidays
224 FROM
225         `{?_MYSQL_PREFIX?}_user_holidays` AS h
226 LEFT JOIN
227         `{?_MYSQL_PREFIX?}_user_data` AS d
228 ON
229         h.userid=d.userid
230 WHERE
231         d.`holiday_active`='Y'",
232         __FILE__, __LINE__);
233         list($holiday) = SQL_FETCHROW($result);
234         SQL_FREERESULT($result);
235         if (empty($holiday)) $holiday = '0';
236         $data = array(
237                 'lang'  => '{--MEDIA_HOLIDAY_COUNT--}',
238                 'value' => $holiday
239         );
240         $OUT_USER .= loadTemplate('mediadata_extra_row', true, $data);
241 } // END - if
242
243 if (isExtensionActive('transfer')) {
244         // Statistics for points transfers
245         $result = SQL_QUERY("SELECT
246         COUNT(t.id) AS cnt, SUM(t.points) AS `points`
247 FROM
248         `{?_MYSQL_PREFIX?}_user_transfers_in` AS t
249 LEFT JOIN
250         `{?_MYSQL_PREFIX?}_user_data` AS d
251 ON
252         t.userid=d.userid",
253                 __FILE__, __LINE__);
254         list($count_in, $points_in) = SQL_FETCHROW($result);
255         SQL_FREERESULT($result);
256         if (empty($count_in))  $count_in  = '0';
257         if (empty($points_in)) $points_in = '0';
258
259         $result = SQL_QUERY("SELECT
260         COUNT(t.id), SUM(t.points)
261 FROM
262         `{?_MYSQL_PREFIX?}_user_transfers_out` AS t
263 LEFT JOIN
264         `{?_MYSQL_PREFIX?}_user_data` AS d
265 ON
266         t.userid=d.userid",
267         __FILE__, __LINE__);
268         list($count_out, $points_out) = SQL_FETCHROW($result);
269         SQL_FREERESULT($result);
270         if (empty($count_out))  $count_out  = '0';
271         if (empty($points_out)) $points_out = '0';
272
273         // Add header
274         $OUT_SPECIAL .= loadTemplate('mediadata_extra_hrow', true, '{--MEDIA_TRANSFER_HEADER--}');
275         $data = array(
276                 'lang'  => '{--MEDIA_TRANSFER_IN_COUNT--}',
277                 'value' => $count_in,
278         );
279         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row2', true, $data);
280         $data = array(
281                 'lang'  => '{--MEDIA_TRANSFER_IN_POINTS--}',
282                 'value' => $points_in
283         );
284         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
285         $data = array(
286                 'lang'  => '{--MEDIA_TRANSFER_OUT_COUNT--}',
287                 'value' => $count_out
288         );
289         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
290         $data = array(
291                 'lang'  => '{--MEDIA_TRANSFER_OUT_POINTS--}',
292                 'value' => $points_out
293         );
294         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
295 } // END - if
296
297 $content['out_extra']   = $OUT_EXTRA;
298 $content['out_points']  = $OUT_POINTS;
299 $content['out_user']    = $OUT_USER;
300 $content['out_special'] = $OUT_SPECIAL;
301
302 // Patch timespamp
303 $content['patch_ctime'] = generateDateTime(getConfig('patch_ctime'), 2);
304
305 // Load template
306 loadTemplate('mediadata', false, $content);
307
308 // [EOF]
309 ?>