2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 12/09/2003 *
4 * =================== Last change: 02/12/2006 *
6 * -------------------------------------------------------------------- *
7 * File : what-mediadata.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Media data *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Mediendaten *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
43 // Add description as navigation point
44 addYouAreHereLink('guest', __FILE__);
46 // Both ext-mediadata and ext-user must be there
47 if ((!isExtensionActive('mediadata')) && (!isAdmin())) {
48 displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=mediadata%}');
50 } elseif ((!isExtensionActive('user')) && (!isAdmin())) {
51 displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=user%}');
55 // Get total confirmed user ids...
56 $content['user_confirmed'] = getTotalConfirmedUser();
57 $content['user_unconfirmed'] = getTotalUnconfirmedUser();
58 $content['user_locked'] = getTotalLockedUser();
59 $content['user_count'] = ($content['user_confirmed'] + $content['user_unconfirmed'] + $content['user_locked']);
61 // Start of this exchange
62 $content['mt_start'] = generateDateTime(getConfig('mt_start'), 3);
64 // Project timestamp when number of members are reached
66 if ($content['user_count'] > 0) {
67 // @TODO Find a better formular than this one
68 $PROJECTED = round((time() - getConfig('mt_start')) / $content['user_count'] * getConfig('mt_stage') + getConfig('mt_start'));
72 $TEST = makeTime(0, 0, 0, $PROJECTED);
75 $content['projected'] = '{%message,USER_MT_PROJECTED=' . generateDateTime($PROJECTED, '3') . '%}';
77 $content['projected'] = getMaskedMessage('USER_MT_PROJECTED', '{--USER_PROJECTION_UNKNOWN--}');
80 // User who can receive mails
81 $content['user_max_mails'] = countSumTotalData('CONFIRMED', 'user_data', 'max_mails', 'status', true, " AND `max_mails` > 0");
83 // Users who can receive mails today
84 $content['user_max_rec'] = countSumTotalData('CONFIRMED', 'user_data', 'receive_mails', 'status', true, " AND `receive_mails` > 0");
87 $content['max'] = countSumTotalData('CONFIRMED', 'user_data', 'max_mails', 'status', false, " AND `max_mails` > 0");
89 // Max mails for this day
90 $content['rec'] = countSumTotalData('CONFIRMED', 'user_data', 'receive_mails', 'status', false, " AND `receive_mails` > 0");
92 // Initial lots of variables
93 $bmails = '0'; $sent = '0'; $max = '0'; $rec = '0'; $clicks = '0';
95 // Mail orders (only current)
96 $nmails = getMediadataEntry('normal_orders');
97 if (empty($nmails)) $nmails = '0';
100 $clicks = getMediadataEntry('normal_clicks');
101 $sent = getMediadataEntry('normal_send');
102 if (empty($sent)) $sent = '0';
103 if (empty($clicks)) $clicks = '0';
106 if (isExtensionActive('bonus')) {
107 $bmails = getMediadataEntry('bonus_orders');
108 if (empty($bmails)) $bmails = '0';
110 // Count bonus mails clicks / sent mails
111 $dmy = getMediadataEntry('bonus_clicks');
112 $dmy2 = getMediadataEntry('bonus_send');
113 if (empty($dmy)) $dmy = '0';
114 if (empty($dmy2)) $dmy2 = '0';
115 $sent += $dmy2; $clicks += $dmy;
118 $content['user_stats'] = ($nmails + $bmails);
119 $content['sent'] = $sent;
122 $content['user_links'] = abs($sent - $clicks);
125 if ($sent > 0) $clr = $clicks / $sent * 100;
126 $content['_clr'] = $clr;
130 if (isExtensionActive('jackpot')) $jackpot = getJackpotPoints();
132 if (empty($jackpot)) $jackpot = '0';
133 $content['jackpot'] = $jackpot;
135 // Total referal link clicks, total logins
136 $result = SQL_QUERY('SELECT
137 SUM(d.ref_clicks), SUM(d.total_logins)
139 `{?_MYSQL_PREFIX?}_user_data` AS d', __FILE__, __LINE__);
140 list($ref, $logins) = SQL_FETCHROW($result);
141 SQL_FREERESULT($result);
144 $points = getMediadataEntry('total_points');
146 if (empty($points)) $points = '0';
147 if (empty($ref)) $ref = '0';
148 if (empty($logins)) $logins = '0';
150 $content['total_points'] = $points;
151 $content['total_refclicks'] = $ref;
152 $content['total_logins'] = $logins;
155 $total = countSumTotalData('Y', 'refbanner', 'id', 'visible', true);
157 // Total views and clicks
158 $result = SQL_QUERY("SELECT SUM(`counter`) AS cnt, SUM(`clicks`) AS clx FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
159 list($views, $clicks) = SQL_FETCHROW($result);
160 SQL_FREERESULT($result);
162 if (empty($total)) $total = '0';
163 if (empty($views)) $views = '0';
164 if (empty($clicks)) $clicks = '0';
166 $content['ref_total'] = $total;
167 $content['ref_views'] = $views;
168 $content['ref_clicks'] = $clicks;
171 // Extra mediadata depending on installed extensions
174 // Initialize Variables
178 $OUT_SPECIAL = ''; // We don't need row count here
180 // @TODO Rewrite all these if-blocks to filters
181 if (isExtensionActive('beg')) {
182 // Clicks on beg links
184 'lang' => '{--MEDIA_BEG_CLICKS--}',
185 'value' => countSumTotalData('0', 'user_data', 'beg_clicks', 'userid', false, ' AND `beg_clicks` > 0')
187 $OUT_EXTRA .= loadTemplate('mediadata_extra_row', true, $data);
190 if (isExtensionActive('doubler')) {
192 $OUT_SPECIAL .= loadTemplate('mediadata_extra_hrow', true, '{--MEDIA_DOUBLER_HEADER--}');
194 // Add first line (count)
196 'lang' => '{--MEDIA_DOUBLER_COUNT--}',
197 'value' => countSumTotalData('Y','doubler','id','completed', true, ' AND `points` > 0'),
201 $OUT_SPECIAL .= loadTemplate('mediadata_extra_row2', true, $data);
203 'lang' => '{--MEDIA_DOUBLER_CPOINTS--}',
204 'value' => countSumTotalData('Y','doubler','id','completed', false, ' AND `points` > 0')
206 $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
208 'lang' => '{--MEDIA_DOUBLER_WAITING--}',
209 'value' => countSumTotalData('N','doubler','id','completed', true, ' AND `points` > 0')
211 $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
213 'lang' => '{--MEDIA_DOUBLER_WPOINTS--}',
214 'value' => countSumTotalData('N','doubler','id','completed', false, ' AND `points` > 0')
216 $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
219 if (isExtensionActive('holiday')) {
220 // Total holiday requests
221 $result = SQL_QUERY("SELECT
222 COUNT(h.userid) AS count_holidays
224 `{?_MYSQL_PREFIX?}_user_holidays` AS h
226 `{?_MYSQL_PREFIX?}_user_data` AS d
230 d.`holiday_active`='Y'",
232 list($holiday) = SQL_FETCHROW($result);
233 SQL_FREERESULT($result);
234 if (empty($holiday)) $holiday = '0';
236 'lang' => '{--MEDIA_HOLIDAY_COUNT--}',
239 $OUT_USER .= loadTemplate('mediadata_extra_row', true, $data);
242 if (isExtensionActive('transfer')) {
243 // Statistics for points transfers
244 $result = SQL_QUERY("SELECT
245 COUNT(t.id) AS cnt, SUM(t.points) AS `points`
247 `{?_MYSQL_PREFIX?}_user_transfers_in` AS t
249 `{?_MYSQL_PREFIX?}_user_data` AS d
253 list($count_in, $points_in) = SQL_FETCHROW($result);
254 SQL_FREERESULT($result);
255 if (empty($count_in)) $count_in = '0';
256 if (empty($points_in)) $points_in = '0';
258 $result = SQL_QUERY("SELECT
259 COUNT(t.id), SUM(t.points)
261 `{?_MYSQL_PREFIX?}_user_transfers_out` AS t
263 `{?_MYSQL_PREFIX?}_user_data` AS d
267 list($count_out, $points_out) = SQL_FETCHROW($result);
268 SQL_FREERESULT($result);
269 if (empty($count_out)) $count_out = '0';
270 if (empty($points_out)) $points_out = '0';
273 $OUT_SPECIAL .= loadTemplate('mediadata_extra_hrow', true, '{--MEDIA_TRANSFER_HEADER--}');
275 'lang' => '{--MEDIA_TRANSFER_IN_COUNT--}',
276 'value' => $count_in,
278 $OUT_SPECIAL .= loadTemplate('mediadata_extra_row2', true, $data);
280 'lang' => '{--MEDIA_TRANSFER_IN_POINTS--}',
281 'value' => $points_in
283 $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
285 'lang' => '{--MEDIA_TRANSFER_OUT_COUNT--}',
286 'value' => $count_out
288 $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
290 'lang' => '{--MEDIA_TRANSFER_OUT_POINTS--}',
291 'value' => $points_out
293 $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
296 $content['out_extra'] = $OUT_EXTRA;
297 $content['out_points'] = $OUT_POINTS;
298 $content['out_user'] = $OUT_USER;
299 $content['out_special'] = $OUT_SPECIAL;
302 $content['patch_ctime'] = generateDateTime(getConfig('patch_ctime'), 2);
305 loadTemplate('mediadata', false, $content);