2 /************************************************************************
\r
3 * MXChange v0.2.1 Start: 10/13/2003 *
\r
4 * =============== Last change: 08/23/2004 *
\r
6 * -------------------------------------------------------------------- *
\r
7 * File : what-confirm.php *
\r
8 * -------------------------------------------------------------------- *
\r
9 * Short description : Stuff around the confirmation link *
\r
10 * -------------------------------------------------------------------- *
\r
11 * Kurzbeschreibung : Alles um den Best�tigungslink *
\r
12 * -------------------------------------------------------------------- *
\r
14 * -------------------------------------------------------------------- *
\r
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
\r
16 * For more information visit: http://www.mxchange.org *
\r
18 * This program is free software; you can redistribute it and/or modify *
\r
19 * it under the terms of the GNU General Public License as published by *
\r
20 * the Free Software Foundation; either version 2 of the License, or *
\r
21 * (at your option) any later version. *
\r
23 * This program is distributed in the hope that it will be useful, *
\r
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
\r
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
\r
26 * GNU General Public License for more details. *
\r
28 * You should have received a copy of the GNU General Public License *
\r
29 * along with this program; if not, write to the Free Software *
\r
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
\r
31 * MA 02110-1301 USA *
\r
32 ************************************************************************/
\r
34 // Some security stuff...
\r
35 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
\r
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
\r
40 // Add description as navigation point
\r
41 ADD_DESCR("guest", basename(__FILE__));
\r
43 OPEN_TABLE("100%", "guest_content_align", "");
\r
44 if (!empty($_GET['hash']))
\r
46 // Initialize the user ID
\r
49 // Search for an unconfirmed or confirmed account
\r
50 $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",
\r
51 array($_GET['hash']), __FILE__, __LINE__);
\r
52 if (SQL_NUMROWS($result) == 1)
\r
54 // Ok, he want's to confirm now so we load some data
\r
55 list ($uid, $email, $rid) = SQL_FETCHROW($result);
\r
57 // Unlock his account (but only when it is on UNCONFIRMED!)
\r
58 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='CONFIRMED', ref_payout='%s' WHERE user_hash='%s' AND status='UNCONFIRMED' LIMIT 1",
\r
59 array($CONFIG['ref_payout'], $_GET['hash']), __FILE__, __LINE__);
\r
60 if (SQL_AFFECTEDROWS($link, __FILE__, __LINE__) == 1)
\r
62 $msg = LOAD_EMAIL_TEMPLATE("confirm-member", "", bigintval($uid));
\r
64 // And send him right away the confirmation mail
\r
65 SEND_EMAIL($email, GUEST_THANX_CONFIRM, $msg);
\r
67 // Maybe he got "referraled"?
\r
68 if (($rid > 0) && ($rid != $uid))
\r
70 // Select the referral userid
\r
71 $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",
\r
72 array(bigintval($rid)), __FILE__, __LINE__);
\r
73 if (SQL_NUMROWS($result) == 1)
\r
75 // Update ref counter...
\r
76 UPDATE_REF_COUNTER($rid);
\r
78 // Ok, write the ref-points to this user and his parent-ref
\r
81 // Shall I "pay" the referral points imidiately?
\r
82 if ($CONFIG['ref_payout'] == "0")
\r
84 // Yes, "pay" it now
\r
89 // No, "pay" it later
\r
93 // If version matches add ref bonus to refid's account
\r
94 if ((GET_EXT_VERSION("bonus") >= "0.4.4") && ($CONFIG['bonus_active'] == "Y"))
\r
96 // Add points (directly only!)
\r
97 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET bonus_ref=bonus_ref+%s WHERE userid=%d LIMIT 1",
\r
98 array($CONFIG['bonus_ref'], bigintval($rid)), __FILE__, __LINE__);
\r
100 // Subtract points from system
\r
101 BONUS_POINTS_HANDLER($CONFIG['bonus_ref']);
\r
104 // Add one-time referral bonus over referral system or directly
\r
105 ADD_POINTS_REFSYSTEM($rid, $CONFIG['points_ref'], true, bigintval($uid), $locked, $CONFIG['reg_points_mode']);
\r
109 if (EXT_IS_ACTIVE("rallye")) {
\r
110 // Add user to rallye (or not?)
\r
111 RALLYE_AUTOADD_USER(bigintval($uid));
\r
114 // Account confirmed!
\r
115 if (defined('LEAD_CODE_ENABLED') && defined('LEAD_EXPIRY_TIME')) {
\r
116 // Set special lead cookie
\r
117 setcookie("lead_uid", bigintval($uid), (time() + LEAD_EXPIRY_TIME), COOKIE_PATH);
\r
118 $_COOKIE['lead_uid'] = bigintval($uid);
\r
120 // Lead-Code mode enabled
\r
121 LOAD_URL(URL."/lead-confirm.php");
\r
123 define('__CONFIRM_MSG', GUEST_CONFIRMED_DONE);
\r
124 define('__UID', bigintval($uid));
\r
125 LOAD_TEMPLATE("guest_confirm_table");
\r
127 } elseif (defined('LEAD_CODE_ENABLED') && defined('LEAD_EXPIRY_TIME')) {
\r
128 // Set special lead cookie
\r
129 setcookie("lead_uid", bigintval($uid), (time() + LEAD_EXPIRY_TIME), COOKIE_PATH);
\r
130 $_COOKIE['lead_uid'] = bigintval($uid);
\r
132 // Lead-Code mode enabled
\r
133 LOAD_URL(URL."/lead-confirm.php");
\r
135 // Nobody was found unter this hash key... or our new member want's to confirm twice?
\r
136 define('__CONFIRM_MSG', GUEST_CONFIRMED_TWICE);
\r
137 define('__UID', "0");
\r
138 LOAD_TEMPLATE("guest_confirm_table");
\r
141 // Nobody was found unter this hash key... or our new member want's to confirm twice?
\r
142 define('__CONFIRM_MSG', GUEST_CONFIRMED_TWICE);
\r
143 define('__UID', "0");
\r
144 LOAD_TEMPLATE("guest_confirm_table");
\r
147 elseif ((isset($_POST['ok'])) && (!empty($_POST['email'])))
\r
149 // Confirmation link requested 0 1 2
\r
150 $result = SQL_QUERY_ESC("SELECT userid, status, user_hash FROM "._MYSQL_PREFIX."_user_data WHERE email='%s' LIMIT 1",
\r
151 array($_POST['email']), __FILE__, __LINE__);
\r
152 if (SQL_NUMROWS($result) == 1)
\r
154 // Email address found
\r
155 $DATA = SQL_FETCHROW($result);
\r
158 case "UNCONFIRMED": // Account not confirmed
\r
159 $msg = LOAD_EMAIL_TEMPLATE("guest_request_confirm", "", $DATA[0]);
\r
160 SEND_EMAIL($_POST['email'], REQUEST_CONFIRM_LINK_SUBJ, $msg);
\r
161 $content = CONFIRM_LINK_SENT;
\r
164 case "CONFIRMED": // Account already confirmed
\r
165 $content = LOGIN_ID_CONFIRMED;
\r
168 case "LOCKED": // Account is locked
\r
169 $content = LOGIN_ID_LOCKED;
\r
175 // Email address not registered
\r
176 $content = EMAIL_ADDY_404;
\r
179 define('__CONFIRM_MSG', $content);
\r
180 LOAD_TEMPLATE("guest_confirm_table");
\r
184 // No hash found, the guest may want to enter his email address to re-get his confirmation link?
\r
185 LOAD_TEMPLATE("guest_confirm_link");
\r