2 /************************************************************************
3 * MXChange v0.2.1 Start: 10/08/2005 *
4 * =============== Last change: 01/01/2006 *
6 * -------------------------------------------------------------------- *
7 * File : gen_mediadata.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Checks for existing mail orders *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Prueft bestehende Mailbuchungen *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
45 $bsent = 0; $bclicks = 0; $bcount = 0;
47 // Check for normal mails
48 $result_media = SQL_QUERY('SELECT SUM(max_rec) AS max_rec, SUM(clicks) AS clicks
49 FROM `{?_MYSQL_PREFIX?}_user_stats`', __FILE__, __LINE__);
50 list($nsent, $nclicks) = SQL_FETCHROW($result_media);
51 if (empty($nsent)) $nsent = 0;
52 if (empty($nclicks)) $nclicks = 0;
55 SQL_FREERESULT($result_media);
58 $ncount = countSumTotalData('', 'user_stats', 'id', '', true);
60 // Check for bonus extension
61 if (isExtensionActive('bonus')) {
63 $bcount = countSumTotalData('', 'bonus', 'id', '', true);
65 // Check for bonus mails
66 $result_media = SQL_QUERY('SELECT SUM(mails_sent) AS bonus_sent, SUM(clicks) AS bonus_clicks
67 FROM `{?_MYSQL_PREFIX?}_bonus`', __FILE__, __LINE__);
68 list($bsent, $bclicks) = SQL_FETCHROW($result_media);
69 if (empty($bsent)) $bsent = 0;
70 if (empty($bclicks)) $bclicks = 0;
73 // Load (maybe) missing file
74 loadIncludeOnce('inc/libs/mediadata_functions.php');
76 // Insert info to database
77 updateMediadataEntry(array('total_send' , 'normal_send') , 'init', $nsent);
78 updateMediadataEntry(array('total_clicks', 'normal_clicks'), 'init', $nclicks);
79 updateMediadataEntry(array('total_orders', 'normal_orders'), 'init', $ncount);
80 updateMediadataEntry(array('total_send' , 'bonus_send' ) , 'init', $bsent);
81 updateMediadataEntry(array('total_clicks', 'bonus_clicks') , 'init', $bclicks);
82 updateMediadataEntry(array('total_orders', 'bonus_orders') , 'init', $bcount);
84 // Aquire total used points
85 $result = SQL_QUERY('SELECT SUM(used_points) AS used_points FROM `{?_MYSQL_PREFIX?}_user_data`', __FILE__, __LINE__);
86 list($used) = SQL_FETCHROW($result);
87 SQL_FREERESULT($result);
89 // ... and total points
90 $result = SQL_QUERY('SELECT SUM(points) AS points FROM `{?_MYSQL_PREFIX?}_user_points`', __FILE__, __LINE__);
91 list($points) = SQL_FETCHROW($result);
92 SQL_FREERESULT($result);
95 updateMediadataEntry(array('total_points'), 'init', ($points - $used));