Removed deprecated 'hidden' column from mod_reg table.
[mailer.git] / inc / gen_mediadata.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/08/2005 *
4  * ===================                          Last change: 01/01/2006 *
5  *                                                                      *
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 - 2013 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         die();
36 } // END - if
37
38 // Init array/varriable
39 $bcount = '0';
40 $content = array(
41         'normal_send'   => 0,
42         'normal_clicks' => 0,
43         'bonus_send'    => 0,
44         'bonus_clicks'  => 0
45 );
46
47 // Check for normal mails
48 $result_media = sqlQuery('SELECT
49         SUM(`max_rec`) AS `normal_send`,
50         SUM(`clicks`) AS `normal_clicks`
51 FROM
52         `{?_MYSQL_PREFIX?}_user_stats`', __FILE__, __LINE__);
53
54 // Merge data together
55 $content = merge_array($content, sqlFetchArray($result_media));
56
57 // Free memory
58 sqlFreeResult($result_media);
59
60 // Check for bonus extension
61 if (isExtensionActive('bonus')) {
62         // Count bonus mails
63         $bcount = countSumTotalData('', 'bonus', 'id', '', TRUE);
64
65         // Check for bonus mails
66         $result_media = sqlQuery('SELECT
67         SUM(`mails_send`) AS `bonus_send`,
68         SUM(`clicks`) AS `bonus_clicks`
69 FROM
70         `{?_MYSQL_PREFIX?}_bonus`
71 LIMIT 1', __FILE__, __LINE__);
72
73         // Merge data together
74         $content = merge_array($content, sqlFetchArray($result_media));
75
76         // Free memory
77         sqlFreeResult($result_media);
78 } // END - if
79
80 // Load (maybe) missing file
81 loadIncludeOnce('inc/libs/mediadata_functions.php');
82
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);
90
91 // Aquire total used points
92 $used = countSumTotalData('', 'user_data', 'used_points', '');
93
94 // ... and total points
95 $points = countSumTotalData('', 'user_points', 'points', '');
96
97 // Update database
98 updateMediadataEntry(array('total_points'), 'init', ($points - $used));
99
100 // [EOF]
101 ?>