11b24eee014c0b6fb583c62edef108bc1d9729eb
[mailer.git] / birthday_confirm.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Load security stuff here
41 require('inc/libs/security_functions.php');
42
43 // Init start time
44 $GLOBALS['startTime'] = microtime(true);
45
46 // Set module
47 $GLOBALS['module'] = 'birthday_confirm';
48 $GLOBALS['output_mode'] = -1;
49
50 // Load the required file(s)
51 require('inc/config-global.php');
52
53 // Set content type
54 setContentType('text/html');
55
56 // Is the 'birthday' extension active?
57 redirectOnUninstalledExtension('birthday');
58
59 // Script is installed so let's check for his confirmation link...
60 $userid = bigintval(getRequestParameter('userid'));
61
62 // Only allow numbers here...
63 $chk = bigintval(getRequestParameter('check'), false);
64
65 // Check if link is not clicked so far
66 $result = SQL_QUERY_ESC("SELECT b.points, d.gender, d.surname, d.family, d.status, d.ref_payout
67 FROM
68         `{?_MYSQL_PREFIX?}_user_birthday` AS b
69 INNER JOIN
70         `{?_MYSQL_PREFIX?}_user_data` AS d
71 ON
72         b.userid=d.userid
73 WHERE
74         b.userid=%s AND b.chk_value='%s'
75 LIMIT 1",
76         array($userid, $chk), __FILE__, __LINE__);
77 //* DEBUG: */ outputHtml("userid=".$userid.",chk=".$chk." (".strlen($chk).'/'.strlen(getRequestParameter('check')).'/'.SQL_NUMROWS($result).")<br />");
78
79 // Prepare content
80 $content = array();
81
82 // Is an entry there?
83 if (SQL_NUMROWS($result) == 1) {
84         // Ok, congratulation again! Here's your gift from us...
85         $data = SQL_FETCHARRAY($result, false);
86
87         // Is the account confirmed?
88         if ($data['status'] == 'CONFIRMED') {
89                 // Set mode depending on how many mails the member has to confirm
90                 $locked = false;
91                 if (($data['ref_payout'] > 0) && (getConfig('allow_direct_pay') != 'Y')) $locked = true;
92
93                 // Add points to account
94                 // @TODO Try to rewrite the following unset()
95                 unset($GLOBALS['ref_level']);
96                 addPointsThroughReferalSystem('birthday_confirm', $userid, $data['points'], false, 0, $locked, strtolower(getConfig('birthday_mode')));
97
98                 // Remove entry from table
99                 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_birthday` WHERE `userid`=%s AND `chk_value`='%s' LIMIT 1",
100                         array($userid, $chk), __FILE__, __LINE__);
101
102                 // "Translate" some data
103                 $data['gender'] = translateGender($data['gender']);
104                 $data['points'] = translateComma($data['points']);
105
106                 // Load message from template
107                 $content['message'] = loadTemplate('birthday_msg', true, $data);
108         } else {
109                 // Unconfirmed / locked accounts cannot get points
110                 $content['message'] = getMaskedMessage('BIRTHDAY_CANNOT_STATUS', translateUserStatus($data['status']));
111         }
112 } else {
113         // Cannot load data!
114         $content['message'] = getMessage('BIRTHDAY_CANNOT_LOAD_DATA');
115 }
116
117 // Free memory
118 SQL_FREERESULT($result);
119
120 // Set this because we have no module in URI
121 $GLOBALS['module'] = 'birthday_confirm';
122
123 // Include header
124 loadIncludeOnce('inc/header.php');
125
126 // Load birthday header template (for your banners, e.g.?)
127 $content['header'] =  loadTemplate('birthday_header', true);
128
129 // Load birthday footer template (for your banners, e.g.?)
130 $content['footer'] =  loadTemplate('birthday_footer', true);
131
132 // Load final template and output it
133 loadTemplate('birthday_confirm', false, $content);
134
135 // Include footer
136 loadIncludeOnce('inc/footer.php');
137
138 // [EOF]
139 ?>