]> git.mxchange.org Git - mailer.git/blob - inc/gen_mediadata.php
Added some missing wrapper functions
[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  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Init array/varriable
44 $bcount = '0';
45 $content = array(
46         'normal_send'   => 0,
47         'normal_clicks' => 0,
48         'bonus_send'    => 0,
49         'bonus_clicks'  => 0
50 );
51
52 // Check for normal mails
53 $result_media = SQL_QUERY('SELECT
54         SUM(`max_rec`) AS `normal_send`,
55         SUM(`clicks`) AS `normal_clicks`
56 FROM
57         `{?_MYSQL_PREFIX?}_user_stats`', __FILE__, __LINE__);
58
59 // Merge data together
60 $content = merge_array($content, SQL_FETCHARRAY($result_media));
61
62 // Free memory
63 SQL_FREERESULT($result_media);
64
65 // Check for bonus extension
66 if (isExtensionActive('bonus')) {
67         // Count bonus mails
68         $bcount = countSumTotalData('', 'bonus', 'id', '', TRUE);
69
70         // Check for bonus mails
71         $result_media = SQL_QUERY('SELECT
72         SUM(`mails_send`) AS `bonus_send`,
73         SUM(`clicks`) AS `bonus_clicks`
74 FROM
75         `{?_MYSQL_PREFIX?}_bonus`
76 LIMIT 1', __FILE__, __LINE__);
77
78         // Merge data together
79         $content = merge_array($content, SQL_FETCHARRAY($result_media));
80
81         // Free memory
82         SQL_FREERESULT($result_media);
83 } // END - if
84
85 // Load (maybe) missing file
86 loadIncludeOnce('inc/libs/mediadata_functions.php');
87
88 // Insert info to database
89 updateMediadataEntry(array('total_send'  , 'normal_send')  , 'init', $content['normal_send']);
90 updateMediadataEntry(array('total_clicks', 'normal_clicks'), 'init', $content['normal_clicks']);
91 updateMediadataEntry(array('total_orders', 'normal_orders'), 'init', countSumTotalData('', 'user_stats', 'id', '', TRUE));
92 updateMediadataEntry(array('total_send'  , 'bonus_send' )  , 'init', $content['bonus_send']);
93 updateMediadataEntry(array('total_clicks', 'bonus_clicks') , 'init', $content['bonus_clicks']);
94 updateMediadataEntry(array('total_orders', 'bonus_orders') , 'init', $bcount);
95
96 // Aquire total used points
97 $used = countSumTotalData('', 'user_data', 'used_points', '');
98
99 // ... and total points
100 $points = countSumTotalData('', 'user_points', 'points', '');
101
102 // Update database
103 updateMediadataEntry(array('total_points'), 'init', ($points - $used));
104
105 // [EOF]
106 ?>