TODOs.txt updated
[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  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.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 // Load security stuff here
39 require('inc/libs/security_functions.php');
40
41 // Init start time
42 $GLOBALS['startTime'] = microtime(true);
43
44 // Set module
45 $GLOBALS['module'] = 'birthday_confirm';
46 $GLOBALS['output_mode'] = -1;
47
48 // Load the required file(s)
49 require('inc/config-global.php');
50
51 // Set content type
52 setContentType('text/html');
53
54 // Is the 'birthday' extension active?
55 redirectOnUninstalledExtension('birthday');
56
57 // Script is installed so let's check for his confirmation link...
58 $userid = bigintval(getRequestParameter('userid'));
59
60 // Only allow numbers here...
61 $chk = bigintval(getRequestParameter('check'), false);
62
63 // Check if link is not clicked so far
64 $result = SQL_QUERY_ESC("SELECT
65         b.`points`, d.`userid`, d.`gender`, d.`surname`, d.`family`, d.`status`, d.`ref_payout`
66 FROM
67         `{?_MYSQL_PREFIX?}_user_birthday` AS b
68 INNER JOIN
69         `{?_MYSQL_PREFIX?}_user_data` AS d
70 ON
71         b.`userid`=d.`userid`
72 WHERE
73         b.`userid`=%s AND
74         b.`chk_value`='%s'
75 LIMIT 1",
76         array(
77                 $userid,
78                 $chk
79         ), __FILE__, __LINE__);
80 //* DEBUG: */ debugOutput("userid=".$userid.",chk=".$chk." (".strlen($chk).'/'.strlen(getRequestParameter('check')).'/'.SQL_NUMROWS($result) . ')');
81
82 // Prepare content
83 $content = array();
84
85 // Is an entry there?
86 if (SQL_NUMROWS($result) == 1) {
87         // Ok, congratulation again! Here's your gift from us...
88         $data = SQL_FETCHARRAY($result, false);
89
90         // Is the account confirmed?
91         if ($data['status'] == 'CONFIRMED') {
92                 // Add points to account
93                 // @TODO Try to rewrite the following unset()
94                 unset($GLOBALS['ref_level']);
95                 addPointsThroughReferalSystem('birthday_confirm', $userid, $data['points'], false, 0, strtolower(getConfig('birthday_mode')));
96
97                 // Remove entry from table
98                 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_birthday` WHERE `userid`=%s AND `chk_value`='%s' LIMIT 1",
99                         array($userid, $chk), __FILE__, __LINE__);
100
101                 // Load message from template
102                 $content['message'] = loadTemplate('birthday_msg', true, $data);
103         } else {
104                 // Unconfirmed / locked accounts cannot get points
105                 $content['message'] = getMaskedMessage('MEMBER_BIRTHDAY_CANNOT_STATUS', translateUserStatus($data['status']));
106         }
107 } else {
108         // Cannot load data!
109         $content['message'] = '{--MEMBER_BIRTHDAY_CANNOT_LOAD_DATA--}';
110 }
111
112 // Free memory
113 SQL_FREERESULT($result);
114
115 // Set this because we have no module in URI
116 $GLOBALS['module'] = 'birthday_confirm';
117
118 // Include header
119 loadIncludeOnce('inc/header.php');
120
121 // Load birthday header template (for your banners, e.g.?)
122 $content['header'] =  loadTemplate('birthday_header', true);
123
124 // Load birthday footer template (for your banners, e.g.?)
125 $content['footer'] =  loadTemplate('birthday_footer', true);
126
127 // Load final template and output it
128 loadTemplate('birthday_confirm', false, $content);
129
130 // Include footer
131 loadIncludeOnce('inc/footer.php');
132
133 // [EOF]
134 ?>