2 /************************************************************************
3 * MXChange v0.2.1 Start: 10/13/2003 *
4 * =============== Last change: 08/23/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-confirm.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Stuff around the confirmation link *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Alles um den Bestaetigungslink *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
44 // Add description as navigation point
45 addMenuDescription('guest', __FILE__);
49 'message' => getMessage('GUEST_CONFIRMED_FAILED'),
53 if (isGetRequestElementSet('hash')) {
54 // Initialize the user ID
57 // Search for an unconfirmed or confirmed account
58 $result = SQL_QUERY_ESC("SELECT `userid`, `email`, `refid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `user_hash`='%s' AND (`status`='UNCONFIRMED' OR `status`='CONFIRMED') LIMIT 1",
59 array(getRequestElement('hash')), __FILE__, __LINE__);
60 if (SQL_NUMROWS($result) == 1) {
61 // Ok, he want's to confirm now so we load some data
62 list ($userid, $email, $rid) = SQL_FETCHROW($result);
64 // Unlock his account (but only when it is on UNCONFIRMED!)
65 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='CONFIRMED', ref_payout={?ref_payout?}, `user_hash`=NULL WHERE `user_hash`='%s' AND `status`='UNCONFIRMED' LIMIT 1",
66 array(getRequestElement('hash')), __FILE__, __LINE__);
67 if (SQL_AFFECTEDROWS() == 1) {
68 $message = loadEmailTemplate('confirm-member', array('points' => getConfig('points_register')), bigintval($userid));
70 // And send him right away the confirmation mail
71 sendEmail($email, getMessage('GUEST_THANX_CONFIRM'), $message);
73 // Maybe he got "referaled"?
74 if (($rid > 0) && ($rid != $userid)) {
75 // Select the referal userid
76 $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
77 array(bigintval($rid)), __FILE__, __LINE__);
78 if (SQL_NUMROWS($result) == 1) {
79 // Update ref counter...
80 updateReferalCounter($rid);
82 // Shall I 'pay' the referal points imidiately?
83 if (getConfig('ref_payout') == 0) {
91 // If version matches add ref bonus to refid's account
92 if ((getExtensionVersion('bonus') >= '0.4.4') && (getConfig('bonus_active') == 'Y')) {
93 // Add points (directly only!)
94 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_ref`=`bonus_ref`+{?bonus_ref?} WHERE `userid`=%s LIMIT 1",
95 array(bigintval($rid)), __FILE__, __LINE__);
97 // Subtract points from system
98 handleBonusPoints(getConfig('bonus_ref'));
101 // Add one-time referal bonus over referal system or directly
102 // @TODO Try to rewrite the following unset()
103 unset($GLOBALS['ref_level']);
104 addPointsThroughReferalSystem('referal_bonus', $rid, getConfig('points_ref'), true, bigintval($userid), $locked, getConfig('reg_points_mode'));
108 if (isExtensionActive('rallye')) {
109 // Add user to rallye (or not?)
110 addUserToReferalRallye(bigintval($userid));
113 // Account confirmed!
114 if (isExtensionActive('lead')) {
115 // Set special lead cookie
116 setSession('lead_userid', bigintval($userid));
118 // Lead-Code mode enabled
119 redirectToUrl('lead-confirm.php');
121 $content['message'] = getMessage('GUEST_CONFIRMED_DONE');
122 $content['userid'] = bigintval($userid);
124 } elseif (isExtensionActive('lead')) {
125 // Set special lead cookie
126 setSession('lead_userid', bigintval($userid));
128 // Lead-Code mode enabled
129 redirectToUrl('lead-confirm.php');
131 // Nobody was found unter this hash key... or our new member want's to confirm twice?
132 $content['message'] = getMessage('GUEST_CONFIRMED_TWICE');
135 // Nobody was found unter this hash key... or our new member want's to confirm twice?
136 $content['message'] = getMessage('GUEST_CONFIRMED_TWICE');
140 loadTemplate('guest_confirm_table', false, $content);
141 } elseif ((isFormSent()) && (isPostRequestElementSet('email'))) {
142 // Confirmation link requested 0 1 2
143 $result = SQL_QUERY_ESC("SELECT `userid`, `status`, `user_hash` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `email`='%s' LIMIT 1",
144 array(postRequestElement('email')), __FILE__, __LINE__);
145 if (SQL_NUMROWS($result) == 1) {
146 // Email address found
147 $content = SQL_FETCHARRAY($result);
148 switch ($content['status']) {
149 case 'UNCONFIRMED': // Account not confirmed
150 // Load email template
151 $message = loadEmailTemplate('guest_request_confirm', array('hash' => $content['user_hash']), $content['userid']);
154 sendEmail(postRequestElement('email'), getMessage('REQUEST_CONFIRM_LINK_SUBJ'), $message);
157 $content['message'] = getMessage('CONFIRM_LINK_SENT');
160 case 'CONFIRMED': // Account already confirmed
161 $content['message'] = getMessage('LOGIN_ID_CONFIRMED');
164 case 'LOCKED': // Account is locked
165 $content['message'] = getMessage('LOGIN_ID_LOCKED');
169 // Email address not registered
170 $content['message'] = getMessage('EMAIL_ADDRESS_404');
174 loadTemplate('admin_settings_saved', false, $content['message']);
176 // No hash found, the guest may want to enter his email address to re-get his confirmation link?
177 loadTemplate('guest_confirm_link');