]> git.mxchange.org Git - mailer.git/blob - inc/modules/guest/what-mediadata.php
Added update_year.sh (still not fully flexible) and updated all years with it.
[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  * 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 // Both ext-mediadata and ext-user must be there
42 if ((!isExtensionActive('mediadata')) && (!isAdmin())) {
43         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=mediadata%}');
44         return;
45 } elseif ((!isExtensionActive('user')) && (!isAdmin())) {
46         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=user%}');
47         return;
48 }
49
50 // Get total confirmed user ids...
51 $content['user_confirmed']   = getTotalConfirmedUser();
52 $content['user_unconfirmed'] = getTotalUnconfirmedUser();
53 $content['user_locked']      = getTotalLockedUser();
54 $content['user_count']       = ($content['user_confirmed'] + $content['user_unconfirmed'] + $content['user_locked']);
55
56 // Start of this exchange
57 $content['mt_start'] = generateDateTime(getMtStart(), '3');
58
59 // Project timestamp when number of members are reached
60 $PROJECTED = '0';
61 if ($content['user_count'] > 0) {
62         // @TODO Find a better formular than this one
63         $PROJECTED = round((time() - getMtStart()) / $content['user_count'] * getMtStage() + getMtStart());
64 } // END - if
65
66 // Generate timestamp
67 $TEST = makeTime(0, 0, 0, $PROJECTED);
68
69 if ($TEST > time()) {
70         $content['projected'] = '{%message,USER_MT_PROJECTED=' . generateDateTime($PROJECTED, '3') . '%}';
71 } else {
72         $content['projected'] = getMaskedMessage('USER_MT_PROJECTED', '{--USER_PROJECTION_UNKNOWN--}');
73 }
74
75 // User who can receive mails
76 $content['user_max_mails'] = countSumTotalData('CONFIRMED', 'user_data', 'max_mails', 'status', TRUE, runFilterChain('user_exclusion_sql', " AND `max_mails` > 0"));
77
78 // Users who can receive mails today
79 $content['user_max_rec'] = countSumTotalData('CONFIRMED', 'user_data', 'receive_mails', 'status', TRUE, runFilterChain('user_exclusion_sql', " AND `receive_mails` > 0"));
80
81 // Max mails per day
82 $content['max'] = countSumTotalData('CONFIRMED', 'user_data', 'max_mails', 'status', FALSE, runFilterChain('user_exclusion_sql', " AND `max_mails` > 0"));
83
84 // Max mails for this day
85 $content['rec'] = countSumTotalData('CONFIRMED', 'user_data', 'receive_mails', 'status', FALSE, runFilterChain('user_exclusion_sql', " AND `receive_mails` > 0"));
86
87 // Initial lots of variables
88 $bmails = '0';
89 $sent   = '0';
90 $max    = '0';
91 $rec    = '0';
92 $clicks = '0';
93
94 // Mail orders (only current)
95 $nmails = getMediadataEntry('normal_orders');
96 if (empty($nmails)) $nmails = '0';
97
98 // Mails sent so far
99 $clicks = getMediadataEntry('normal_clicks');
100 $sent   = getMediadataEntry('normal_send');
101 if (empty($sent))   $sent   = '0';
102 if (empty($clicks)) $clicks = '0';
103
104 // Bonus mails
105 if (isExtensionActive('bonus')) {
106         $bmails = getMediadataEntry('bonus_orders');
107         if (empty($bmails)) $bmails = '0';
108
109         // Count bonus mails clicks / sent mails
110         $dmy  = getMediadataEntry('bonus_clicks');
111         $dmy2 = getMediadataEntry('bonus_send');
112         if (empty($dmy))  $dmy  = '0';
113         if (empty($dmy2)) $dmy2 = '0';
114         $sent += $dmy2; $clicks += $dmy;
115 } // END - if
116
117 $content['user_stats'] = ($nmails + $bmails);
118 $content['sent']       = $sent;
119
120 // All clicks
121 $content['user_links'] = abs($sent - $clicks);
122
123 // Click rate
124 $content['click_rate'] = calculatePercentageRate($clicks, $sent);
125
126 // Load jackpot
127 $content['jackpot'] = '0';
128 if (isExtensionActive('jackpot')) $content['jackpot'] = getJackpotPoints();
129 if (empty($content['jackpot'])) $content['jackpot'] = '0';
130
131 // Total referral link clicks, total logins
132 $result = sqlQuery('SELECT
133         SUM(`d`.`ref_clicks`) AS `total_ref_clicks`,
134         SUM(`d`.`total_logins`) AS `total_logins`
135 FROM
136         `{?_MYSQL_PREFIX?}_user_data` AS `d`
137 ' . runFilterChain('user_exclusion_sql', ''), __FILE__, __LINE__);
138 list($ref, $logins) = sqlFetchRow($result);
139 sqlFreeResult($result);
140
141 // Get total points
142 $points = getMediadataEntry('total_points');
143
144 if (empty($points)) $points = '0';
145 if (empty($ref))    $ref    = '0';
146 if (empty($logins)) $logins = '0';
147
148 $content['total_points']    = $points;
149 $content['total_refclicks'] = $ref;
150 $content['total_logins']    = $logins;
151
152 // Referral banner
153 $total = countSumTotalData('Y', 'refbanner', 'id', 'visible', TRUE);
154
155 // Total views and clicks
156 $result = sqlQuery("SELECT SUM(`counter`) AS `views`, SUM(`clicks`) AS `clicks` FROM `{?_MYSQL_PREFIX?}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
157 list($views, $clicks) = sqlFetchRow($result);
158 sqlFreeResult($result);
159
160 if (empty($total))  $total  = '0';
161 if (empty($views))  $views  = '0';
162 if (empty($clicks)) $clicks = '0';
163
164 $content['ref_total']  = $total;
165 $content['ref_views']  = $views;
166 $content['ref_clicks'] = $clicks;
167
168 //
169 // Extra mediadata depending on installed extensions
170 //
171
172 // Initialize Variables
173 $OUT_EXTRA   = '';
174 $OUT_POINTS  = '';
175 $OUT_USER    = '';
176 $OUT_SPECIAL = ''; // We don't need row count here
177
178 // @TODO Rewrite all these if-blocks to filters
179 if (isExtensionActive('beg')) {
180         // Clicks on beg links
181         $data = array(
182                 'lang'  => '{--MEDIA_BEG_CLICKS--}',
183                 'value' => countSumTotalData('0', 'user_data', 'beg_clicks', 'userid', FALSE, ' WHERE `beg_clicks` > 0')
184         );
185         $OUT_EXTRA .= loadTemplate('mediadata_extra_row', TRUE, $data);
186 } // END - if
187
188 if (isExtensionActive('doubler')) {
189         // Add header
190         $OUT_SPECIAL .= loadTemplate('mediadata_extra_hrow', TRUE, '{--MEDIA_DOUBLER_HEADER--}');
191
192         // Add first line (count)
193         $data = array(
194                 'lang'  => '{--MEDIA_DOUBLER_COUNT--}',
195                 'value' => countSumTotalData('Y','doubler','id','completed', TRUE, ' AND `points` > 0'),
196         );
197
198         // Add points
199         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row2', TRUE, $data);
200         $data = array(
201                 'lang'  => '{--MEDIA_DOUBLER_CPOINTS--}',
202                 'value' => countSumTotalData('Y','doubler','id','completed', FALSE, ' AND `points` > 0')
203         );
204         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', TRUE, $data);
205         $data = array(
206                 'lang'  => '{--MEDIA_DOUBLER_WAITING--}',
207                 'value' => countSumTotalData('N','doubler','id','completed', TRUE, ' AND `points` > 0')
208         );
209         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', TRUE, $data);
210         $data = array(
211                 'lang'  => '{--MEDIA_DOUBLER_WPOINTS--}',
212                 'value' => countSumTotalData('N','doubler','id','completed', FALSE, ' AND `points` > 0')
213         );
214         $OUT_SPECIAL .= loadTemplate('mediadata_extra_row', TRUE, $data);
215 } // END - if
216
217 if (isExtensionActive('holiday')) {
218         // Total holiday requests
219         $result = sqlQuery("SELECT
220         COUNT(`h`.`userid`) AS `count_holidays`
221 FROM
222         `{?_MYSQL_PREFIX?}_user_holidays` AS `h`
223 LEFT JOIN
224         `{?_MYSQL_PREFIX?}_user_data` AS `d`
225 ON
226         `h`.`userid`=`d`.`userid`
227 WHERE
228         `d`.`holiday_active`='Y'
229 " . runFilterChain('user_exclusion_sql', ' '),
230         __FILE__, __LINE__);
231         list($holiday) = sqlFetchRow($result);
232         sqlFreeResult($result);
233         if (empty($holiday)) $holiday = '0';
234         $data = array(
235                 'lang'  => '{--MEDIA_HOLIDAY_COUNT--}',
236                 'value' => $holiday
237         );
238         $OUT_USER .= loadTemplate('mediadata_extra_row', TRUE, $data);
239 } // END - if
240
241 if (isExtensionActive('transfer')) {
242         // Statistics for points transfers
243         $result = sqlQuery("SELECT
244         COUNT(`t`.`id`) AS `cnt`,
245         SUM(`t`.`points`) AS `points`
246 FROM
247         `{?_MYSQL_PREFIX?}_user_transfers_in` AS `t`
248 LEFT JOIN
249         `{?_MYSQL_PREFIX?}_user_data` AS `d`
250 ON
251         `t`.`userid`=`d`.`userid`
252 " . runFilterChain('user_exclusion_sql', ''),
253                 __FILE__, __LINE__);
254         list($count_in, $points_in) = sqlFetchRow($result);
255         sqlFreeResult($result);
256         if (empty($count_in))  $count_in  = '0';
257         if (empty($points_in)) $points_in = '0';
258
259         $result = sqlQuery("SELECT
260         COUNT(`t`.`id`) AS `cnt`, SUM(`t`.`points`) AS `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 " . runFilterChain('user_exclusion_sql', ''),
268         __FILE__, __LINE__);
269         list($count_out, $points_out) = sqlFetchRow($result);
270         sqlFreeResult($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 ?>