]> git.mxchange.org Git - mailer.git/blob - birthday_confirm.php
4039b7cb660f5f8f4c06985d9935f3d812ff6613
[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  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
14  * Copyright (c) 2009 - 2016 by Mailer Developer Team                   *
15  * For more information visit: http://mxchange.org                      *
16  *                                                                      *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or    *
20  * (at your option) any later version.                                  *
21  *                                                                      *
22  * This program is distributed in the hope that it will be useful,      *
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
25  * GNU General Public License for more details.                         *
26  *                                                                      *
27  * You should have received a copy of the GNU General Public License    *
28  * along with this program; if not, write to the Free Software          *
29  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
30  * MA  02110-1301  USA                                                  *
31  ************************************************************************/
32
33 // Load security stuff here
34 require('inc/libs/security_functions.php');
35
36 // Init start time
37 $GLOBALS['__start_time'] = microtime(TRUE);
38
39 // Set module
40 $GLOBALS['__module']      = 'birthday_confirm';
41 $GLOBALS['__output_mode'] = '0';
42
43 // Initialize application
44 require('inc/init.php');
45
46 // Set content type
47 setContentType('text/html');
48
49 // Is the 'birthday' extension active?
50 redirectOnUninstalledExtension('birthday');
51
52 // Script is installed so let's check for his confirmation link...
53 $userid = bigintval(getRequestElement('userid'));
54
55 // Only allow numbers here...
56 $chk = bigintval(getRequestElement('check'), FALSE);
57
58 // Check if link is not clicked so far
59 $result = sqlQueryEscaped("SELECT
60         `b`.`points`,
61         `d`.`userid`,
62         `d`.`sex`,
63         `d`.`surname`,
64         `d`.`family`,
65         `d`.`status`,
66         `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
75         `b`.`chk_value`='%s'
76 LIMIT 1",
77         array(
78                 $userid,
79                 $chk
80         ), __FILE__, __LINE__);
81 //* DEBUG: */ debugOutput("userid=".$userid.",chk=".$chk." (".strlen($chk).'/'.strlen(getRequestElement('check')).'/'.sqlNumRows($result) . ')');
82
83 // Prepare content
84 $content = [];
85
86 // Is an entry there?
87 if (sqlNumRows($result) == 1) {
88         // Ok, congratulation again! Here's your gift from us...
89         $data = sqlFetchArray($result, FALSE);
90
91         // Is the account confirmed?
92         if ($data['status'] == 'CONFIRMED') {
93                 // Add points to account
94                 initReferralSystem();
95                 addPointsThroughReferralSystem('birthday_confirm', $userid, $data['points']);
96
97                 // Remove entry from table
98                 sqlQueryEscaped("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'] = '{%message,MEMBER_BIRTHDAY_CANNOT_STATUS=' . $data['status'] . '%}';
106         }
107 } else {
108         // Cannot load data!
109         $content['message'] = '{--MEMBER_BIRTHDAY_CANNOT_LOAD_DATA--}';
110 }
111
112 // Free memory
113 sqlFreeResult($result);
114
115 // Set this because there is no module in URI
116 $GLOBALS['__module'] = 'birthday_confirm';
117
118 // Include header
119 loadPageHeader();
120
121 // Load final template and output it
122 loadTemplate('birthday_confirm', FALSE, $content);
123
124 // Include footer
125 loadPageFooter();
126
127 // [EOF]
128 ?>