]> git.mxchange.org Git - mailer.git/blob - birthday_confirm.php
Several fixes for broken actions (sorry for lame text)
[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 best&auml;tigen                *
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  * 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 // Set content type
53 setContentType('text/html');
54
55 // Is the 'birthday' extension active?
56 redirectOnUninstalledExtension('birthday');
57
58 // Script is installed so let's check for his confirmation link...
59 $userid = bigintval(getRequestElement('userid'));
60
61 // Only allow numbers here...
62 $chk = bigintval(getRequestElement('check'), false);
63
64 // Check if link is not clicked so far
65 $result = SQL_QUERY_ESC("SELECT b.points, 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 b.chk_value='%s'
74 LIMIT 1",
75         array($userid, $chk), __FILE__, __LINE__);
76 //* DEBUG: */ outputHtml("userid=".$userid.",chk=".$chk." (".strlen($chk).'/'.strlen(getRequestElement('check')).'/'.SQL_NUMROWS($result).")<br />");
77
78 // Prepare content
79 $content = array();
80
81 // Is an entry there?
82 if (SQL_NUMROWS($result) == 1) {
83         // Ok, congratulation again! Here's your gift from us...
84         $data = SQL_FETCHARRAY($result, false);
85
86         // Is the account confirmed?
87         if ($data['status'] == 'CONFIRMED') {
88                 // Set mode depending on how many mails the member has to confirm
89                 $locked = false;
90                 if (($data['ref_payout'] > 0) && (getConfig('allow_direct_pay') != 'Y')) $locked = true;
91
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', $locked, 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                 // "Translate" some data
102                 $data['gender'] = translateGender($data['gender']);
103                 $data['points'] = translateComma($data['points']);
104
105                 // Load message from template
106                 $content['message'] = loadTemplate('birthday_msg', true, $data);
107         } else {
108                 // Unconfirmed / locked accounts cannot get points
109                 $content['message'] = sprintf(getMessage('BIRTHDAY_CANNOT_STATUS'), translateUserStatus($data['status']));
110         }
111 } else {
112         // Cannot load data!
113         $content['message'] = getMessage('BIRTHDAY_CANNOT_LOAD_DATA');
114 }
115
116 // Free memory
117 SQL_FREERESULT($result);
118
119 // Set this because we have no module in URI
120 $GLOBALS['module'] = 'birthday_confirm';
121
122 // Include header
123 loadIncludeOnce('inc/header.php');
124
125 // Load birthday header template (for your banners, e.g.?)
126 $content['header'] =  loadTemplate('birthday_header', true);
127
128 // Load birthday footer template (for your banners, e.g.?)
129 $content['footer'] =  loadTemplate('birthday_footer', true);
130
131 // Load final template and output it
132 loadTemplate('birthday_confirm', false, $content);
133
134 // Include footer
135 loadIncludeOnce('inc/footer.php');
136
137 // [EOF]
138 ?>