One more found
[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://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'] = '0';
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(getRequestElement('userid'));
59
60 // Only allow numbers here...
61 $chk = bigintval(getRequestElement('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(getRequestElement('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                 initReferralSystem();
94                 addPointsThroughReferralSystem('birthday_confirm', $userid, $data['points']);
95
96                 // Remove entry from table
97                 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_birthday` WHERE `userid`=%s AND `chk_value`='%s' LIMIT 1",
98                         array($userid, $chk), __FILE__, __LINE__);
99
100                 // Load message from template
101                 $content['message'] = loadTemplate('birthday_msg', true, $data);
102         } else {
103                 // Unconfirmed / locked accounts cannot get points
104                 $content['message'] = '{%message,MEMBER_BIRTHDAY_CANNOT_STATUS=' . $data['status'] . '%}';
105         }
106 } else {
107         // Cannot load data!
108         $content['message'] = '{--MEMBER_BIRTHDAY_CANNOT_LOAD_DATA--}';
109 }
110
111 // Free memory
112 SQL_FREERESULT($result);
113
114 // Set this because we have no module in URI
115 $GLOBALS['__module'] = 'birthday_confirm';
116
117 // Include header
118 loadIncludeOnce('inc/header.php');
119
120 // Load birthday header template (for your banners, e.g.?)
121 $content['header'] =  loadTemplate('birthday_header', true);
122
123 // Load birthday footer template (for your banners, e.g.?)
124 $content['footer'] =  loadTemplate('birthday_footer', true);
125
126 // Load final template and output it
127 loadTemplate('birthday_confirm', false, $content);
128
129 // Include footer
130 loadIncludeOnce('inc/footer.php');
131
132 // [EOF]
133 ?>