]> git.mxchange.org Git - mailer.git/blob - inc/modules/guest/what-mediadata.php
Extension ext-mediadata continued, wrapper function introduced:
[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  * $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://www.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 // Both ext-mediadata and ext-user must be there
47 if ((!isExtensionActive('mediadata')) && (!isAdmin())) {
48         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=mediadata%}');
49         return;
50 } elseif ((!isExtensionActive('user')) && (!isAdmin())) {
51         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=user%}');
52         return;
53 }
54
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']);
60
61 // Start of this exchange
62 $content['mt_start'] = generateDateTime(getConfig('mt_start'), 3);
63
64 // Project timestamp when number of members are reached
65 $PROJECTED = '0';
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'));
69 } // END - if
70
71 // Generate timestamp
72 $TEST = makeTime(0, 0, 0, $PROJECTED);
73
74 if ($TEST > time()) {
75         $content['projected'] = '{%message,USER_MT_PROJECTED=' . generateDateTime($PROJECTED, '3') . '%}';
76 } else {
77         $content['projected'] = getMaskedMessage('USER_MT_PROJECTED', '{--USER_PROJECTION_UNKNOWN--}');
78 }
79
80 // User who can receive mails
81 $content['user_max_mails'] = countSumTotalData('CONFIRMED', 'user_data', 'max_mails', 'status', true, " AND `max_mails` > 0");
82
83 // Users who can receive mails today
84 $content['user_max_rec'] = countSumTotalData('CONFIRMED', 'user_data', 'receive_mails', 'status', true, " AND `receive_mails` > 0");
85
86 // Max mails per day
87 $content['max'] = countSumTotalData('CONFIRMED', 'user_data', 'max_mails', 'status', false, " AND `max_mails` > 0");
88
89 // Max mails for this day
90 $content['rec'] = countSumTotalData('CONFIRMED', 'user_data', 'receive_mails', 'status', false, " AND `receive_mails` > 0");
91
92 // Initial lots of variables
93 $bmails = '0'; $sent = '0'; $max = '0'; $rec = '0'; $clicks = '0';
94
95 // Mail orders (only current)
96 $nmails = getMediadataEntry('normal_orders');
97 if (empty($nmails)) $nmails = '0';
98
99 // Mails sent so far
100 $clicks = getMediadataEntry('normal_clicks');
101 $sent   = getMediadataEntry('normal_send');
102 if (empty($sent))   $sent   = '0';
103 if (empty($clicks)) $clicks = '0';
104
105 // Bonus mails
106 if (isExtensionActive('bonus')) {
107         $bmails = getMediadataEntry('bonus_orders');
108         if (empty($bmails)) $bmails = '0';
109
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;
116 } // END - if
117
118 $content['user_stats'] = ($nmails + $bmails);
119 $content['sent']       = $sent;
120
121 // All clicks
122 $content['user_links'] = abs($sent - $clicks);
123
124 // Click rate
125 $content['click_rate'] = '0';
126 if ($sent > 0) {
127         $content['click_rate'] = $clicks / $sent * 100;
128 } // END - if
129
130 // Load jackpot
131 $jackpot = '0';
132 if (isExtensionActive('jackpot')) $jackpot = getJackpotPoints();
133
134 if (empty($jackpot)) $jackpot = '0';
135 $content['jackpot'] = $jackpot;
136
137 // Total referal link clicks, total logins
138 $result = SQL_QUERY('SELECT
139         SUM(d.ref_clicks), SUM(d.total_logins)
140 FROM
141         `{?_MYSQL_PREFIX?}_user_data` AS d', __FILE__, __LINE__);
142 list($ref, $logins) = SQL_FETCHROW($result);
143 SQL_FREERESULT($result);
144
145 // Get total points
146 $points = getMediadataEntry('total_points');
147
148 if (empty($points)) $points = '0';
149 if (empty($ref))    $ref    = '0';
150 if (empty($logins)) $logins = '0';
151
152 $content['total_points']    = $points;
153 $content['total_refclicks'] = $ref;
154 $content['total_logins']    = $logins;
155
156 // Referal banner
157 $total = countSumTotalData('Y', 'refbanner', 'id', 'visible', true);
158
159 // Total views and clicks
160 $result = SQL_QUERY("SELECT SUM(`counter`) AS cnt, SUM(`clicks`) AS clx FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
161 list($views, $clicks) = SQL_FETCHROW($result);
162 SQL_FREERESULT($result);
163
164 if (empty($total))  $total  = '0';
165 if (empty($views))  $views  = '0';
166 if (empty($clicks)) $clicks = '0';
167
168 $content['ref_total']  = $total;
169 $content['ref_views']  = $views;
170 $content['ref_clicks'] = $clicks;
171
172 //
173 // Extra mediadata depending on installed extensions
174 //
175
176 // Initialize Variables
177 $OUT_EXTRA   = '';
178 $OUT_POINTS  = '';
179 $OUT_USER    = '';
180 $OUT_SPECIAL = ''; // We don't need row count here
181
182 // @TODO Rewrite all these if-blocks to filters
183 if (isExtensionActive('beg')) {
184         // Clicks on beg links
185         $data = array(
186                 'lang'  => '{--MEDIA_BEG_CLICKS--}',
187                 'value' => countSumTotalData('0', 'user_data', 'beg_clicks', 'userid', false, ' AND `beg_clicks` > 0')
188         );
189         $OUT_EXTRA .= loadTemplate('mediadata_extra_row', true, $data);
190 } // END - if
191
192 if (isExtensionActive('doubler')) {
193         // Add header
194         $OUT_SPECIAL .= loadTemplate('mediadata_extra_hrow', true, '{--MEDIA_DOUBLER_HEADER--}');
195
196         // Add first line (count)
197         $data = array(
198                 'lang'  => '{--MEDIA_DOUBLER_COUNT--}',
199                 'value' => countSumTotalData('Y','doubler','id','completed', true, ' AND `points` > 0'),
200         );
201
202         // Add points
203         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row2', true, $data);
204         $data = array(
205                 'lang'  => '{--MEDIA_DOUBLER_CPOINTS--}',
206                 'value' => countSumTotalData('Y','doubler','id','completed', false, ' AND `points` > 0')
207         );
208         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
209         $data = array(
210                 'lang'  => '{--MEDIA_DOUBLER_WAITING--}',
211                 'value' => countSumTotalData('N','doubler','id','completed', true, ' AND `points` > 0')
212         );
213         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
214         $data = array(
215                 'lang'  => '{--MEDIA_DOUBLER_WPOINTS--}',
216                 'value' => countSumTotalData('N','doubler','id','completed', false, ' AND `points` > 0')
217         );
218         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
219 } // END - if
220
221 if (isExtensionActive('holiday')) {
222         // Total holiday requests
223         $result = SQL_QUERY("SELECT
224         COUNT(h.userid) AS count_holidays
225 FROM
226         `{?_MYSQL_PREFIX?}_user_holidays` AS h
227 LEFT JOIN
228         `{?_MYSQL_PREFIX?}_user_data` AS d
229 ON
230         h.userid=d.userid
231 WHERE
232         d.`holiday_active`='Y'",
233         __FILE__, __LINE__);
234         list($holiday) = SQL_FETCHROW($result);
235         SQL_FREERESULT($result);
236         if (empty($holiday)) $holiday = '0';
237         $data = array(
238                 'lang'  => '{--MEDIA_HOLIDAY_COUNT--}',
239                 'value' => $holiday
240         );
241         $OUT_USER .= loadTemplate('mediadata_extra_row', true, $data);
242 } // END - if
243
244 if (isExtensionActive('transfer')) {
245         // Statistics for points transfers
246         $result = SQL_QUERY("SELECT
247         COUNT(t.id) AS cnt, SUM(t.points) AS `points`
248 FROM
249         `{?_MYSQL_PREFIX?}_user_transfers_in` AS t
250 LEFT JOIN
251         `{?_MYSQL_PREFIX?}_user_data` AS d
252 ON
253         t.userid=d.userid",
254                 __FILE__, __LINE__);
255         list($count_in, $points_in) = SQL_FETCHROW($result);
256         SQL_FREERESULT($result);
257         if (empty($count_in))  $count_in  = '0';
258         if (empty($points_in)) $points_in = '0';
259
260         $result = SQL_QUERY("SELECT
261         COUNT(t.id), SUM(t.points)
262 FROM
263         `{?_MYSQL_PREFIX?}_user_transfers_out` AS t
264 LEFT JOIN
265         `{?_MYSQL_PREFIX?}_user_data` AS d
266 ON
267         t.userid=d.userid",
268         __FILE__, __LINE__);
269         list($count_out, $points_out) = SQL_FETCHROW($result);
270         SQL_FREERESULT($result);
271         if (empty($count_out))  $count_out  = '0';
272         if (empty($points_out)) $points_out = '0';
273
274         // Add header
275         $OUT_SPECIAL .= loadTemplate('mediadata_extra_hrow', true, '{--MEDIA_TRANSFER_HEADER--}');
276         $data = array(
277                 'lang'  => '{--MEDIA_TRANSFER_IN_COUNT--}',
278                 'value' => $count_in,
279         );
280         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row2', true, $data);
281         $data = array(
282                 'lang'  => '{--MEDIA_TRANSFER_IN_POINTS--}',
283                 'value' => $points_in
284         );
285         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
286         $data = array(
287                 'lang'  => '{--MEDIA_TRANSFER_OUT_COUNT--}',
288                 'value' => $count_out
289         );
290         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
291         $data = array(
292                 'lang'  => '{--MEDIA_TRANSFER_OUT_POINTS--}',
293                 'value' => $points_out
294         );
295         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', true, $data);
296 } // END - if
297
298 $content['out_extra']   = $OUT_EXTRA;
299 $content['out_points']  = $OUT_POINTS;
300 $content['out_user']    = $OUT_USER;
301 $content['out_special'] = $OUT_SPECIAL;
302
303 // Load template
304 loadTemplate('mediadata', false, $content);
305
306 // [EOF]
307 ?>