2 /************************************************************************
3 * MXChange v0.2.1 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 * -------------------------------------------------------------------- *
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 *
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. *
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. *
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, *
35 ************************************************************************/
37 // Some security stuff...
38 if (!defined('__SECURITY')) {
39 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
41 } elseif (!EXT_IS_ACTIVE("mediadata")) {
42 ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "mediadata");
46 // Add description as navigation point
47 ADD_DESCR("guest", basename(__FILE__));
49 define('value', "value");
50 define('lang', "lang");
51 define('rows', "rows");
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));
59 // Start of this exchange
60 define('__MT_START', MAKE_DATETIME($_CONFIG['mt_start'], "3"));
62 // Projected number of members
63 define('__MT_STAGE', $_CONFIG['mt_stage']);
65 // Project timestamp when number of members are reached
68 $PROJECTED = round((time() - $_CONFIG['mt_start']) / user_count * $_CONFIG['mt_stage'] + $_CONFIG['mt_start']);
71 $YEAR = date('Y', $PROJECTED); $MONTH = date("m", $PROJECTED); $DAY = date("d", $PROJECTED);
72 $TEST = mktime(0, 0, 0, $MONTH, $DAY, $YEAR);
74 define('__MT_PROJECTED', MAKE_DATETIME($PROJECTED, "3"));
76 define('__MT_PROJECTED', USER_PROJECTION_UNKNOWN);
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);
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);
92 $result_max = SQL_QUERY("SELECT SUM(max_mails) FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' AND max_mails > 0", __FILE__, __LINE__);
93 list($dmy) = SQL_FETCHROW($result_max);
94 SQL_FREERESULT($result_max);
97 // Max mails for this day
98 $result_rec = SQL_QUERY("SELECT SUM(receive_mails) FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' AND receive_mails > 0", __FILE__, __LINE__);
99 list($dummy) = SQL_FETCHROW($result_rec);
100 define('rec', $dummy);
101 SQL_FREERESULT($result_rec);
103 // Initial lots of variables
104 $bmails = 0; $sent = 0; $max = 0; $rec = 0; $clicks = 0;
106 // Mail orders (only current)
107 $nmails = MEDIA_GET_ENTRY("normal_orders");
108 if (empty($nmails)) $nmails = 0;
111 $clicks = MEDIA_GET_ENTRY("normal_clicks");
112 $sent = MEDIA_GET_ENTRY("normal_send");
113 if (empty($sent)) $sent = 0;
114 if (empty($clicks)) $clicks = 0;
117 if (EXT_IS_ACTIVE("bonus")) {
118 $bmails = MEDIA_GET_ENTRY("bonus_orders");
119 if (empty($bmails)) $bmails = 0;
121 // Count bonus mails clicks / sent mails
122 $dmy = MEDIA_GET_ENTRY("bonus_clicks");
123 $dmy2 = MEDIA_GET_ENTRY("bonus_send");
124 if (empty($dmy)) $dmy = 0;
125 if (empty($dmy2)) $dmy2 = 0;
126 $sent += $dmy2; $clicks += $dmy;
129 define('user_stats', ($nmails + $bmails));
130 define('sent' , $sent);
133 define('user_links', abs($sent - $clicks));
136 if ($sent > 0) $clr = $clicks / $sent * 100;
137 define('_clr', TRANSLATE_COMMA($clr)."%");
140 $result = SQL_QUERY("SELECT points FROM "._MYSQL_PREFIX."_jackpot WHERE ok='ok' LIMIT 1", __FILE__, __LINE__);
141 list($jackpot) = SQL_FETCHROW($result);
142 SQL_FREERESULT($result);
143 if (empty($jackpot)) $jackpot = 0;
144 define('jackpot', TRANSLATE_COMMA($jackpot));
146 // Total referral link clicks, total logins
147 $result = SQL_QUERY("SELECT DISTINCT SUM(d.ref_clicks), SUM(d.total_logins)
148 FROM "._MYSQL_PREFIX."_user_data AS d", __FILE__, __LINE__);
149 list($ref, $logins) = SQL_FETCHROW($result);
150 SQL_FREERESULT($result);
153 $points = MEDIA_GET_ENTRY("total_points");
155 if (empty($points)) $points = 0;
156 if (empty($ref)) $ref = 0;
157 if (empty($logins)) $logins = 0;
159 define('__TOTAL_POINTS' , TRANSLATE_COMMA($points));
160 define('__TOTAL_REFCLICKS', $ref);
161 define('__TOTAL_LOGINS' , $logins);
164 $result = SQL_QUERY("SELECT COUNT(id) FROM "._MYSQL_PREFIX."_refbanner WHERE visible='Y'", __FILE__, __LINE__);
165 list($total) = SQL_FETCHROW($result);
166 SQL_FREERESULT($result);
167 $result = SQL_QUERY("SELECT SUM(counter), SUM(clicks) FROM "._MYSQL_PREFIX."_refbanner WHERE visible='Y'", __FILE__, __LINE__);
168 list($views, $clicks) = SQL_FETCHROW($result);
169 SQL_FREERESULT($result);
171 if (empty($total)) $total = 0;
172 if (empty($views)) $views = 0;
173 if (empty($clicks)) $clicks = 0;
175 define('__REF_TOTAL' , $total);
176 define('__REF_VIEWS' , $views);
177 define('__REF_CLICKS', $clicks);
180 // Extra mediadata depending on installed extensions
183 // Initialize Variables
184 $OUT_EXTRA = ""; $rowNameS_EXTRA = 2;
185 $OUT_POINTS = ""; $rowNameS_POINTS = 2;
186 $OUT_USER = ""; $rowNameS_USER = 6;
187 $OUT_SPECIAL = ""; // We don't need row count here
189 if (EXT_IS_ACTIVE("beg")) {
190 // Clicks on beg links
191 $result = SQL_QUERY("SELECT SUM(beg_clicks) FROM "._MYSQL_PREFIX."_user_data WHERE beg_clicks>0", __FILE__, __LINE__);
192 list($extra) = SQL_FETCHROW($result);
193 SQL_FREERESULT($result);
194 if (empty($extra)) $extra = 0;
196 'lang' => MEDIA_BEG_CLICKS,
199 $OUT_EXTRA .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
203 if (EXT_IS_ACTIVE("doubler")) {
204 // Total payed points
205 $result = SQL_QUERY("SELECT COUNT(id), SUM(points) FROM "._MYSQL_PREFIX."_doubler WHERE completed='Y' AND points > 0", __FILE__, __LINE__);
206 list($count1, $points1) = SQL_FETCHROW($result);
207 SQL_FREERESULT($result);
208 $result = SQL_QUERY("SELECT COUNT(id), SUM(points) FROM "._MYSQL_PREFIX."_doubler WHERE completed='N' AND points > 0", __FILE__, __LINE__);
209 list($count2, $points2) = SQL_FETCHROW($result);
210 SQL_FREERESULT($result);
212 if (empty($count1)) $count1 = 0;
213 if (empty($count2)) $count2 = 0;
214 if (empty($points1)) $points1 = 0;
215 if (empty($points2)) $points2 = 0;
218 $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_hrow", true, MEDIA_DOUBLER_HEADER);
220 // Add first line (count)
222 'lang' => MEDIA_DOUBLER_COUNT,
227 $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row2", true, $content);
229 'lang' => MEDIA_DOUBLER_CPOINTS,
230 'value' => TRANSLATE_COMMA($points1)
232 $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
234 'lang' => MEDIA_DOUBLER_WAITING,
235 'value' => TRANSLATE_COMMA($count2)
237 $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
239 'lang' => MEDIA_DOUBLER_WPOINTS,
240 'value' => TRANSLATE_COMMA($points2)
242 $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
245 if (EXT_IS_ACTIVE("holiday")) {
246 // Total holiday requests
247 $result = SQL_QUERY("SELECT DISTINCT COUNT(h.userid)
248 FROM "._MYSQL_PREFIX."_user_holidays AS h
249 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
251 WHERE d.holiday_active='Y'",
253 list($holiday) = SQL_FETCHROW($result);
254 if (empty($holiday)) $holiday = 0;
256 'lang' => MEDIA_HOLIDAY_COUNT,
259 $OUT_USER .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
263 if (EXT_IS_ACTIVE("transfer")) {
264 // Statistics for points transfers
265 $result = SQL_QUERY("SELECT DISTINCT COUNT(t.id), SUM(t.points)
266 FROM "._MYSQL_PREFIX."_user_transfers_in AS t
267 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
268 ON t.userid=d.userid",
270 list($count_in, $points_in) = SQL_FETCHROW($result);
271 if (empty($count_in)) $count_in = 0;
272 if (empty($points_in)) $points_in = 0;
274 $result = SQL_QUERY("SELECT DISTINCT COUNT(t.id), SUM(t.points)
275 FROM "._MYSQL_PREFIX."_user_transfers_out AS t
276 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
277 ON t.userid=d.userid",
279 list($count_out, $points_out) = SQL_FETCHROW($result);
280 if (empty($count_out)) $count_out = 0;
281 if (empty($points_out)) $points_out = 0;
284 $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_hrow", true, MEDIA_TRANSFER_HEADER);
286 'lang' => MEDIA_TRANSFER_IN_COUNT,
287 'value' => $count_in,
290 $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row2", true, $content);
292 'lang' => MEDIA_TRANSFER_IN_POINTS,
293 'value' => TRANSLATE_COMMA($points_in)
295 $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
297 'lang' => MEDIA_TRANSFER_OUT_COUNT,
298 'value' => $count_out
300 $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
302 'lang' => MEDIA_TRANSFER_OUT_POINTS,
303 'value' => TRANSLATE_COMMA($points_out)
305 $OUT_SPECIAL .= LOAD_TEMPLATE("mediadata_extra_row", true, $content);
308 define('__EXTRA_MEDIADATA' , $OUT_EXTRA);
309 define('__POINTS_MEDIADATA' , $OUT_POINTS);
310 define('__USER_MEDIADATA' , $OUT_USER);
311 define('__SPECIAL_MEDIADATA', $OUT_SPECIAL);
312 define('__ROWSPAN_EXTRA' , $rowNameS_EXTRA);
313 define('__ROWSPAN_POINTS' , $rowNameS_POINTS);
314 define('__ROWSPAN_USER' , $rowNameS_USER);
316 // Patch level and it's timespamp
317 define('__PATCH_LEVEL', $_CONFIG['patch_level']);
318 define('__PATCH_CTIME', MAKE_DATETIME($_CONFIG['patch_ctime'], "2"));
321 LOAD_TEMPLATE("mediadata");