]> git.mxchange.org Git - mailer.git/blob - inc/modules/guest/what-mediadata.php
3190462f36af0ef6c4cdd59b74d4cdaab37b270d
[mailer.git] / inc / modules / guest / what-mediadata.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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 - 2008                    *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
19  * For more information visit: http://www.mxchange.org                  *
20  *                                                                      *
21  * This program is free software; you can redistribute it and/or modify *
22  * it under the terms of the GNU General Public License as published by *
23  * the Free Software Foundation; either version 2 of the License, or    *
24  * (at your option) any later version.                                  *
25  *                                                                      *
26  * This program is distributed in the hope that it will be useful,      *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
29  * GNU General Public License for more details.                         *
30  *                                                                      *
31  * You should have received a copy of the GNU General Public License    *
32  * along with this program; if not, write to the Free Software          *
33  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
34  * MA  02110-1301  USA                                                  *
35  ************************************************************************/
36
37 // Some security stuff...
38 if (!defined('__SECURITY')) {
39         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40         require($INC);
41 } elseif ((!EXT_IS_ACTIVE("mediadata")) && (!IS_ADMIN())) {
42         addFatalMessage(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "mediadata");
43         return;
44 }
45
46 // Add description as navigation point
47 ADD_DESCR("guest", __FILE__);
48
49 define('value', "value");
50 define('lang', "lang");
51 define('rows', "rows");
52
53 // Get total confirmed user IDs...
54 define('user_confirmed'  , round(GET_TOTAL_DATA("CONFIRMED"  , "user_data", "userid", "status", true)));
55 define('user_unconfirmed', round(GET_TOTAL_DATA("UNCONFIRMED", "user_data", "userid", "status", true)));
56 define('user_locked'     , round(GET_TOTAL_DATA("LOCKED"     , "user_data", "userid", "status", true)));
57 define('user_count'      , (user_confirmed + user_unconfirmed + user_locked));
58
59 // Start of this exchange
60 define('__MT_START', MAKE_DATETIME(getConfig('mt_start'), "3"));
61
62 // Projected number of members
63 define('__MT_STAGE', getConfig('mt_stage'));
64
65 // Project timestamp when number of members are reached
66 $PROJECTED = 0;
67 if (user_count > 0) {
68         $PROJECTED = round((time() - getConfig('mt_start')) / user_count * getConfig('mt_stage') + getConfig('mt_start'));
69 }
70
71 $YEAR = date('Y', $PROJECTED); $MONTH = date("m", $PROJECTED); $DAY = date("d", $PROJECTED);
72 $TEST = mktime(0, 0, 0, $MONTH, $DAY, $YEAR);
73 if ($TEST > time()) {
74         define('__MT_PROJECTED', MAKE_DATETIME($PROJECTED, "3"));
75 } else {
76         define('__MT_PROJECTED', USER_PROJECTION_UNKNOWN);
77 }
78
79 // User who can receive mails
80 $result_max = SQL_QUERY("SELECT COUNT(max_mails) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED' AND max_mails > 0", __FILE__, __LINE__);
81 list($dummy) = SQL_FETCHROW($result_max);
82 SQL_FREERESULT($result_max);
83 define('user_max_mails', $dummy);
84
85 // Users who can receive mails today
86 $result_rec = SQL_QUERY("SELECT COUNT(receive_mails) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `status`='CONFIRMED' AND receive_mails > 0", __FILE__, __LINE__);
87 list($dummy) = SQL_FETCHROW($result_rec);
88 SQL_FREERESULT($result_rec);
89 define('user_max_rec', $dummy);
90
91 // Max mails per day
92 define('max', GET_TOTAL_DATA("CONFIRMED", "user_data", "max_mails", "status", false, " AND `max_mails` > 0"));
93
94 // Max mails for this day
95 define('rec', GET_TOTAL_DATA("CONFIRMED", "user_data", "receive_mails", "status", false, " AND `receive_mails` > 0"));
96
97 // Initial lots of variables
98 $bmails = 0; $sent = 0; $max = 0; $rec = 0; $clicks = 0;
99
100 // Mail orders (only current)
101 $nmails = MEDIA_GET_ENTRY("normal_orders");
102 if (empty($nmails)) $nmails = 0;
103
104 // Mails sent so far
105 $clicks = MEDIA_GET_ENTRY("normal_clicks");
106 $sent   = MEDIA_GET_ENTRY("normal_send");
107 if (empty($sent))   $sent   = 0;
108 if (empty($clicks)) $clicks = 0;
109
110 // Bonus mails
111 if (EXT_IS_ACTIVE("bonus")) {
112         $bmails = MEDIA_GET_ENTRY("bonus_orders");
113         if (empty($bmails)) $bmails = 0;
114
115         // Count bonus mails clicks / sent mails
116         $dmy  = MEDIA_GET_ENTRY("bonus_clicks");
117         $dmy2 = MEDIA_GET_ENTRY("bonus_send");
118         if (empty($dmy))  $dmy  = 0;
119         if (empty($dmy2)) $dmy2 = 0;
120         $sent += $dmy2; $clicks += $dmy;
121 } // END - if
122
123 define('user_stats', ($nmails + $bmails));
124 define('sent'      , $sent);
125
126 // All clicks
127 define('user_links', abs($sent - $clicks));
128
129 $clr = "0.00000";
130 if ($sent > 0) $clr = $clicks / $sent * 100;
131 define('_clr', TRANSLATE_COMMA($clr)."%");
132
133 // Load jackpot
134 $result = SQL_QUERY("SELECT points FROM `{!_MYSQL_PREFIX!}_jackpot` WHERE ok='ok' LIMIT 1", __FILE__, __LINE__);
135 list($jackpot) = SQL_FETCHROW($result);
136 SQL_FREERESULT($result);
137 if (empty($jackpot)) $jackpot = 0;
138 define('jackpot', TRANSLATE_COMMA($jackpot));
139
140 // Total referal link clicks, total logins
141 $result = SQL_QUERY("SELECT DISTINCT SUM(d.ref_clicks), SUM(d.total_logins)
142 FROM `{!_MYSQL_PREFIX!}_user_data` AS d", __FILE__, __LINE__);
143 list($ref, $logins) = SQL_FETCHROW($result);
144 SQL_FREERESULT($result);
145
146 // Get total points
147 $points = MEDIA_GET_ENTRY("total_points");
148
149 if (empty($points)) $points = 0;
150 if (empty($ref))    $ref    = 0;
151 if (empty($logins)) $logins = 0;
152
153 define('__TOTAL_POINTS'   , TRANSLATE_COMMA($points));
154 define('__TOTAL_REFCLICKS', $ref);
155 define('__TOTAL_LOGINS'   , $logins);
156
157 // Referal banner
158 $result = SQL_QUERY("SELECT COUNT(id) FROM `{!_MYSQL_PREFIX!}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
159 list($total) = SQL_FETCHROW($result);
160 SQL_FREERESULT($result);
161 $result = SQL_QUERY("SELECT SUM(counter), SUM(clicks) FROM `{!_MYSQL_PREFIX!}_refbanner` WHERE `visible`='Y'", __FILE__, __LINE__);
162 list($views, $clicks) = SQL_FETCHROW($result);
163 SQL_FREERESULT($result);
164
165 if (empty($total))  $total  = 0;
166 if (empty($views))  $views  = 0;
167 if (empty($clicks)) $clicks = 0;
168
169 define('__REF_TOTAL' , $total);
170 define('__REF_VIEWS' , $views);
171 define('__REF_CLICKS', $clicks);
172
173 //
174 // Extra mediadata depending on installed extensions
175 //
176
177 // Initialize Variables
178 $OUT_EXTRA   = ""; $ROWS_EXTRA   = 2;
179 $OUT_POINTS  = ""; $ROWS_POINTS  = 2;
180 $OUT_USER    = ""; $ROWS_USER    = 6;
181 $OUT_SPECIAL = ""; // We don't need row count here
182
183 if (EXT_IS_ACTIVE("beg")) {
184         // Clicks on beg links
185         $result = SQL_QUERY("SELECT SUM(beg_clicks) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE beg_clicks>0", __FILE__, __LINE__);
186         list($extra) = SQL_FETCHROW($result);
187         SQL_FREERESULT($result);
188         if (empty($extra)) $extra = 0;
189         $content = array(
190                 'lang'  => MEDIA_BEG_CLICKS,
191                 'value' => $extra
192         );
193         $OUT_EXTRA .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
194         $ROWS_EXTRA++;
195 }
196
197 if (EXT_IS_ACTIVE("doubler")) {
198         // Total payed points
199         $result = SQL_QUERY("SELECT COUNT(id), SUM(points) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='Y' AND points > 0", __FILE__, __LINE__);
200         list($count1, $points1) = SQL_FETCHROW($result);
201         SQL_FREERESULT($result);
202         $result = SQL_QUERY("SELECT COUNT(id), SUM(points) FROM `{!_MYSQL_PREFIX!}_doubler` WHERE completed='N' AND points > 0", __FILE__, __LINE__);
203         list($count2, $points2) = SQL_FETCHROW($result);
204         SQL_FREERESULT($result);
205
206         if (empty($count1))  $count1  = 0;
207         if (empty($count2))  $count2  = 0;
208         if (empty($points1)) $points1 = 0;
209         if (empty($points2)) $points2 = 0;
210
211         // Add header
212         $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_hrow", true, MEDIA_DOUBLER_HEADER);
213
214         // Add first line (count)
215         $content = array(
216                 'lang'  => MEDIA_DOUBLER_COUNT,
217                 'value' => $count1,
218                 'rows'  => "4"
219         );
220         // Add points
221         $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row2", true, $content);
222         $content = array(
223                 'lang'  => MEDIA_DOUBLER_CPOINTS,
224                 'value' => TRANSLATE_COMMA($points1)
225         );
226         $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
227         $content = array(
228                 'lang'  => MEDIA_DOUBLER_WAITING,
229                 'value' => TRANSLATE_COMMA($count2)
230         );
231         $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
232         $content = array(
233                 'lang'  => MEDIA_DOUBLER_WPOINTS,
234                 'value' => TRANSLATE_COMMA($points2)
235         );
236         $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
237 }
238
239 if (EXT_IS_ACTIVE("holiday")) {
240         // Total holiday requests
241         $result = SQL_QUERY("SELECT DISTINCT COUNT(h.userid)
242 FROM `{!_MYSQL_PREFIX!}_user_holidays` AS h
243 LEFT JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
244 ON h.userid=d.userid
245 WHERE d.holiday_active='Y'",
246  __FILE__, __LINE__);
247         list($holiday) = SQL_FETCHROW($result);
248         if (empty($holiday)) $holiday = 0;
249         $content = array(
250                 'lang'  => MEDIA_HOLIDAY_COUNT,
251                 'value' => $holiday
252         );
253         $OUT_USER .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
254         $ROWS_USER++;
255 }
256
257 if (EXT_IS_ACTIVE("transfer")) {
258         // Statistics for points transfers
259         $result = SQL_QUERY("SELECT DISTINCT COUNT(t.id), SUM(t.points)
260 FROM `{!_MYSQL_PREFIX!}_user_transfers_in` AS t
261 LEFT JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
262 ON t.userid=d.userid",
263  __FILE__, __LINE__);
264         list($count_in, $points_in) = SQL_FETCHROW($result);
265         if (empty($count_in))  $count_in  = 0;
266         if (empty($points_in)) $points_in = 0;
267
268         $result = SQL_QUERY("SELECT DISTINCT COUNT(t.id), SUM(t.points)
269 FROM `{!_MYSQL_PREFIX!}_user_transfers_out` AS t
270 LEFT JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
271 ON t.userid=d.userid",
272  __FILE__, __LINE__);
273         list($count_out, $points_out) = SQL_FETCHROW($result);
274         if (empty($count_out))  $count_out  = 0;
275         if (empty($points_out)) $points_out = 0;
276
277         // Add header
278         $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_hrow", true, MEDIA_TRANSFER_HEADER);
279         $content = array(
280                 'lang'  => MEDIA_TRANSFER_IN_COUNT,
281                 'value' => $count_in,
282                 'rows'  => "4"
283         );
284         $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row2", true, $content);
285         $content = array(
286                 'lang'  => MEDIA_TRANSFER_IN_POINTS,
287                 'value' => TRANSLATE_COMMA($points_in)
288         );
289         $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
290         $content = array(
291                 'lang'  => MEDIA_TRANSFER_OUT_COUNT,
292                 'value' => $count_out
293         );
294         $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
295         $content = array(
296                 'lang'  => MEDIA_TRANSFER_OUT_POINTS,
297                 'value' => TRANSLATE_COMMA($points_out)
298         );
299         $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
300 }
301
302 define('__EXTRA_MEDIADATA'  , $OUT_EXTRA);
303 define('__POINTS_MEDIADATA' , $OUT_POINTS);
304 define('__USER_MEDIADATA'   , $OUT_USER);
305 define('__SPECIAL_MEDIADATA', $OUT_SPECIAL);
306 define('__ROWSPAN_EXTRA'    , $ROWS_EXTRA);
307 define('__ROWSPAN_POINTS'   , $ROWS_POINTS);
308 define('__ROWSPAN_USER'     , $ROWS_USER);
309
310 // Patch level and it's timespamp
311 define('__PATCH_LEVEL', getConfig('patch_level'));
312 define('__PATCH_CTIME', MAKE_DATETIME(getConfig('patch_ctime'), "2"));
313
314 // Load template
315 LOAD_TEMPLATE("mediadata");
316
317 //
318 ?>