Filters should be executed even when sql_patches is out-dated
[mailer.git] / birthday_confirm.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/03/2004 *
4  * ===============                              Last change: 10/03/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : birthday_confirm.php                             *
8  * -------------------------------------------------------------------- *
9  * Short description : Birthday bonus confirmation link                 *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Geburtstagsgutschrift bestaetigen                *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
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.                                  *
27  *                                                                      *
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.                         *
32  *                                                                      *
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,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Load security stuff here
40 require('inc/libs/security_functions.php');
41
42 // Init start time
43 $GLOBALS['startTime'] = microtime(true);
44
45 // Set module
46 $GLOBALS['module'] = 'birthday_confirm';
47 $GLOBALS['output_mode'] = -1;
48
49 // Load the required file(s)
50 require('inc/config-global.php');
51
52 // Is the 'birthday' extension active?
53 redirectOnUninstalledExtension('birthday');
54
55 // Is the script installed?
56 if (!isInstalled()) {
57         // You have to install first!
58         redirectToUrl('install.php');
59 } // END - if
60
61 // Script is installed so let's check for his confirmation link...
62 $uid = bigintval(REQUEST_GET('uid'));
63
64 // Only allow numbers here...
65 $chk = bigintval(REQUEST_GET('check'), false);
66
67 // Check if link is not clicked so far
68 $result = SQL_QUERY_ESC("SELECT b.points, d.gender, d.surname, d.family, d.status, d.ref_payout
69 FROM `{!_MYSQL_PREFIX!}_user_birthday` AS b
70 INNER JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
71 ON b.userid=d.userid
72 WHERE b.userid=%s AND b.chk_value='%s' LIMIT 1",
73 array($uid, $chk), __FILE__, __LINE__);
74 //* DEBUG: */ echo "uid=".$uid.",chk=".$chk." (".strlen($chk).'/'.strlen(REQUEST_GET('check')).'/'.SQL_NUMROWS($result).")<br />\n";
75
76 // Prepare content
77 $content = array();
78
79 // Is an entry there?
80 if (SQL_NUMROWS($result) == 1) {
81         // Ok, congratulation again! Here's your gift from us...
82         $data = SQL_FETCHARRAY($result, false);
83
84         // Is the account confirmed?
85         if ($data['status'] == 'CONFIRMED') {
86                 // Set mode depending on how many mails the member has to confirm
87                 $locked = false;
88                 if (($data['ref_payout'] > 0) && (getConfig('allow_direct_pay') != 'Y')) $locked = true;
89
90                 // Add points to account
91                 unset($GLOBALS['ref_level']);
92                 ADD_POINTS_REFSYSTEM('birthday_confirm', $uid, $data['points'], false, '0', $locked, strtolower(getConfig('birthday_mode')));
93
94                 // Update mediadata if version is 0.0.4 or newer
95                 if (GET_EXT_VERSION('mediadata') >= '0.0.4') {
96                         // Update database
97                         MEDIA_UPDATE_ENTRY(array('total_points'), 'add', $data['points']);
98                 } // END - if
99
100                 // Remove entry from table
101                 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_birthday` WHERE userid=%s AND chk_value='%s' LIMIT 1",
102                         array($uid, $chk), __FILE__, __LINE__);
103
104                 // "Translate" some data
105                 $data['gender'] = translateGender($data['gender']);
106                 $data['points'] = translateComma($data['points']);
107
108                 // Load message from template
109                 $content['msg'] = LOAD_TEMPLATE('birthday_msg', true, $data);
110         } else {
111                 // Unconfirmed / locked accounts cannot get points
112                 $content['msg'] = sprintf(getMessage('BIRTHDAY_CANNOT_STATUS'), translateUserStatus($data['status']));
113         }
114 } else {
115         // Cannot load data!
116         $content['msg'] = getMessage('BIRTHDAY_CANNOT_LOAD_DATA');
117 }
118
119 // Free memory
120 SQL_FREERESULT($result);
121
122 // Set this because we have no module in URI
123 $GLOBALS['module'] = 'birthday_confirm';
124
125 // Include header
126 loadIncludeOnce('inc/header.php');
127
128 // Load birthday header template (for your banners, e.g.?)
129 $content['header'] =  LOAD_TEMPLATE('birthday_header', true);
130
131 // Load birthday footer template (for your banners, e.g.?)
132 $content['footer'] =  LOAD_TEMPLATE('birthday_footer', true);
133
134 // Load final template and output it
135 LOAD_TEMPLATE('birthday_confirm', false, $content);
136
137 // Include footer
138 loadIncludeOnce('inc/footer.php');
139
140 // [EOF]
141 ?>