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 - 2008 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')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
45 // Add description as navigation point
46 ADD_DESCR('guest', __FILE__);
48 if (REQUEST_ISSET_GET('hash')) {
49 // Initialize the user ID
52 // Search for an unconfirmed or confirmed account
53 $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",
54 array(REQUEST_GET('hash')), __FILE__, __LINE__);
55 if (SQL_NUMROWS($result) == 1) {
56 // Ok, he want's to confirm now so we load some data
57 list ($uid, $email, $rid) = SQL_FETCHROW($result);
59 // Unlock his account (but only when it is on UNCONFIRMED!)
60 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `status`='CONFIRMED', ref_payout=%s, user_hash=NULL WHERE user_hash='%s' AND `status`='UNCONFIRMED' LIMIT 1",
61 array(getConfig('ref_payout'), REQUEST_GET('hash')), __FILE__, __LINE__);
62 if (SQL_AFFECTEDROWS() == 1) {
63 $message = LOAD_EMAIL_TEMPLATE("confirm-member", array('points' => getConfig('points_register')), bigintval($uid));
65 // And send him right away the confirmation mail
66 sendEmail($email, getMessage('GUEST_THANX_CONFIRM'), $message);
68 // Maybe he got "referaled"?
69 if (($rid > 0) && ($rid != $uid)) {
70 // Select the referal userid
71 $result = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
72 array(bigintval($rid)), __FILE__, __LINE__);
73 if (SQL_NUMROWS($result) == 1) {
74 // Update ref counter...
75 updateReferalCounter($rid);
77 // Ok, write the ref-points to this user and his parent-ref
78 unset($GLOBALS['ref_level']);
80 // Shall I 'pay' the referal points imidiately?
81 if (getConfig('ref_payout') == '0') {
89 // If version matches add ref bonus to refid's account
90 if ((GET_EXT_VERSION('bonus') >= '0.4.4') && (getConfig('bonus_active') == 'Y')) {
91 // Add points (directly only!)
92 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET bonus_ref=bonus_ref+%s WHERE userid=%s LIMIT 1",
93 array(getConfig('bonus_ref'), bigintval($rid)), __FILE__, __LINE__);
95 // Subtract points from system
96 BONUS_POINTS_HANDLER(getConfig('bonus_ref'));
99 // Add one-time referal bonus over referal system or directly
100 unset($GLOBALS['ref_level']);
101 ADD_POINTS_REFSYSTEM('referal_bonus', $rid, getConfig('points_ref'), true, bigintval($uid), $locked, getConfig('reg_points_mode'));
105 if (EXT_IS_ACTIVE('rallye')) {
106 // Add user to rallye (or not?)
107 RALLYE_AUTOADD_USER(bigintval($uid));
110 // Account confirmed!
111 if (EXT_IS_ACTIVE('lead')) {
112 // Set special lead cookie
113 setSession('lead_uid', bigintval($uid));
115 // Lead-Code mode enabled
116 redirectToUrl('lead-confirm.php');
118 define('__CONFIRM_MSG', getMessage('GUEST_CONFIRMED_DONE'));
119 define('__UID', bigintval($uid));
120 LOAD_TEMPLATE('guest_confirm_table');
122 } elseif (EXT_IS_ACTIVE('lead')) {
123 // Set special lead cookie
124 setSession('lead_uid', bigintval($uid));
126 // Lead-Code mode enabled
127 redirectToUrl('lead-confirm.php');
129 // Nobody was found unter this hash key... or our new member want's to confirm twice?
130 define('__CONFIRM_MSG', getMessage('GUEST_CONFIRMED_TWICE'));
131 define('__UID', '0');
132 LOAD_TEMPLATE('guest_confirm_table');
135 // Nobody was found unter this hash key... or our new member want's to confirm twice?
136 define('__CONFIRM_MSG', getMessage('GUEST_CONFIRMED_TWICE'));
137 define('__UID', '0');
138 LOAD_TEMPLATE('guest_confirm_table');
140 } elseif ((isFormSent()) && (REQUEST_ISSET_POST('email'))) {
141 // Confirmation link requested 0 1 2
142 $result = SQL_QUERY_ESC("SELECT `userid`, `status`, `user_hash` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `email`='%s' LIMIT 1",
143 array(REQUEST_POST('email')), __FILE__, __LINE__);
144 if (SQL_NUMROWS($result) == 1) {
145 // Email address found
146 $DATA = SQL_FETCHROW($result);
148 case 'UNCONFIRMED': // Account not confirmed
149 $message = LOAD_EMAIL_TEMPLATE('guest_request_confirm', array('hash' => $DATA[2]), $DATA[0]);
150 sendEmail(REQUEST_POST('email'), getMessage('REQUEST_CONFIRM_LINK_SUBJ'), $message);
151 $content = getMessage('CONFIRM_LINK_SENT');
154 case 'CONFIRMED': // Account already confirmed
155 $content = getMessage('LOGIN_ID_CONFIRMED');
158 case 'LOCKED': // Account is locked
159 $content = getMessage('LOGIN_ID_LOCKED');
163 // Email address not registered
164 $content = getMessage('EMAIL_ADDY_404');
167 define('__CONFIRM_MSG', $content);
168 LOAD_TEMPLATE('guest_confirm_table');
170 // No hash found, the guest may want to enter his email address to re-get his confirmation link?
171 LOAD_TEMPLATE('guest_confirm_link');