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 * -------------------------------------------------------------------- *
14 * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. March 2009) $ *
15 * $Tag:: 0.2.1-FINAL $ *
16 * $Author:: stelzi $ *
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 $msg = LOAD_EMAIL_TEMPLATE("confirm-member", array('points' => getConfig('points_register')), bigintval($uid));
65 // And send him right away the confirmation mail
66 SEND_EMAIL($email, getMessage('GUEST_THANX_CONFIRM'), $msg);
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 UPDATE_REF_COUNTER($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 (defined('LEAD_CODE_ENABLED') && defined('LEAD_EXPIRY_TIME')) {
112 // Set special lead cookie
113 set_session('lead_uid', bigintval($uid));
115 // Lead-Code mode enabled
116 LOAD_URL("lead-confirm.php");
118 define('__CONFIRM_MSG', getMessage('GUEST_CONFIRMED_DONE'));
119 define('__UID', bigintval($uid));
120 LOAD_TEMPLATE("guest_confirm_table");
122 } elseif (defined('LEAD_CODE_ENABLED') && defined('LEAD_EXPIRY_TIME')) {
123 // Set special lead cookie
124 set_session('lead_uid', bigintval($uid));
126 // Lead-Code mode enabled
127 LOAD_URL("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 ((IS_FORM_SENT()) && (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);
149 case "UNCONFIRMED": // Account not confirmed
150 $msg = LOAD_EMAIL_TEMPLATE("guest_request_confirm", array('hash' => $DATA[2]), $DATA[0]);
151 SEND_EMAIL(REQUEST_POST('email'), getMessage('REQUEST_CONFIRM_LINK_SUBJ'), $msg);
152 $content = getMessage('CONFIRM_LINK_SENT');
155 case "CONFIRMED": // Account already confirmed
156 $content = getMessage('LOGIN_ID_CONFIRMED');
159 case "LOCKED": // Account is locked
160 $content = getMessage('LOGIN_ID_LOCKED');
164 // Email address not registered
165 $content = getMessage('EMAIL_ADDY_404');
168 define('__CONFIRM_MSG', $content);
169 LOAD_TEMPLATE("guest_confirm_table");
171 // No hash found, the guest may want to enter his email address to re-get his confirmation link?
172 LOAD_TEMPLATE("guest_confirm_link");