2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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 * -------------------------------------------------------------------- *
13 * Copyright (c) 2003 - 2009 by Roland Haeder *
14 * Copyright (c) 2009 - 2016 by Mailer Developer Team *
15 * For more information visit: http://mxchange.org *
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. *
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. *
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, *
31 ************************************************************************/
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
38 // Init array/varriable
47 // Check for normal mails
48 $result_media = sqlQuery('SELECT
49 SUM(`max_rec`) AS `normal_send`,
50 SUM(`clicks`) AS `normal_clicks`
52 `{?_MYSQL_PREFIX?}_user_stats`', __FILE__, __LINE__);
54 // Merge data together
55 $content = merge_array($content, sqlFetchArray($result_media));
58 sqlFreeResult($result_media);
60 // Check for bonus extension
61 if (isExtensionActive('bonus')) {
63 $bcount = countSumTotalData('', 'bonus', 'id', '', TRUE);
65 // Check for bonus mails
66 $result_media = sqlQuery('SELECT
67 SUM(`mails_send`) AS `bonus_send`,
68 SUM(`clicks`) AS `bonus_clicks`
70 `{?_MYSQL_PREFIX?}_bonus`
71 LIMIT 1', __FILE__, __LINE__);
73 // Merge data together
74 $content = merge_array($content, sqlFetchArray($result_media));
77 sqlFreeResult($result_media);
80 // Load (maybe) missing file
81 loadIncludeOnce('inc/libs/mediadata_functions.php');
83 // Insert info to database
84 updateMediadataEntry(array('total_send' , 'normal_send') , 'init', $content['normal_send']);
85 updateMediadataEntry(array('total_clicks', 'normal_clicks'), 'init', $content['normal_clicks']);
86 updateMediadataEntry(array('total_orders', 'normal_orders'), 'init', countSumTotalData('', 'user_stats', 'id', '', TRUE));
87 updateMediadataEntry(array('total_send' , 'bonus_send' ) , 'init', $content['bonus_send']);
88 updateMediadataEntry(array('total_clicks', 'bonus_clicks') , 'init', $content['bonus_clicks']);
89 updateMediadataEntry(array('total_orders', 'bonus_orders') , 'init', $bcount);
91 // Aquire total used points
92 $used = countSumTotalData('', 'user_data', 'used_points', '');
94 // ... and total points
95 $points = countSumTotalData('', 'user_points', 'points', '');
98 updateMediadataEntry(array('total_points'), 'init', ($points - $used));