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 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // Add description as navigation point
41 ADD_DESCR("guest", basename(__FILE__));
43 if (!empty($_GET['hash']))
45 // Initialize the user ID
48 // Search for an unconfirmed or confirmed account
49 $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",
50 array($_GET['hash']), __FILE__, __LINE__);
51 if (SQL_NUMROWS($result) == 1)
53 // Ok, he want's to confirm now so we load some data
54 list ($uid, $email, $rid) = SQL_FETCHROW($result);
56 // Unlock his account (but only when it is on UNCONFIRMED!)
57 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='CONFIRMED', ref_payout='%s' WHERE user_hash='%s' AND status='UNCONFIRMED' LIMIT 1",
58 array($_CONFIG['ref_payout'], $_GET['hash']), __FILE__, __LINE__);
59 if (SQL_AFFECTEDROWS() == 1)
61 $msg = LOAD_EMAIL_TEMPLATE("confirm-member", "", bigintval($uid));
63 // And send him right away the confirmation mail
64 SEND_EMAIL($email, GUEST_THANX_CONFIRM, $msg);
66 // Maybe he got "referraled"?
67 if (($rid > 0) && ($rid != $uid))
69 // Select the referral userid
70 $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
71 array(bigintval($rid)), __FILE__, __LINE__);
72 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
80 // Shall I "pay" the referral points imidiately?
81 if ($_CONFIG['ref_payout'] == "0")
92 // If version matches add ref bonus to refid's account
93 if ((GET_EXT_VERSION("bonus") >= "0.4.4") && ($_CONFIG['bonus_active'] == "Y"))
95 // Add points (directly only!)
96 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET bonus_ref=bonus_ref+%s WHERE userid=%s LIMIT 1",
97 array($_CONFIG['bonus_ref'], bigintval($rid)), __FILE__, __LINE__);
99 // Subtract points from system
100 BONUS_POINTS_HANDLER($_CONFIG['bonus_ref']);
103 // Add one-time referral bonus over referral system or directly
105 ADD_POINTS_REFSYSTEM($rid, $_CONFIG['points_ref'], true, bigintval($uid), $locked, $_CONFIG['reg_points_mode']);
109 if (EXT_IS_ACTIVE("rallye")) {
110 // Add user to rallye (or not?)
111 RALLYE_AUTOADD_USER(bigintval($uid));
114 // Account confirmed!
115 if (defined('LEAD_CODE_ENABLED') && defined('LEAD_EXPIRY_TIME')) {
116 // Set special lead cookie
117 set_session("lead_uid", bigintval($uid));
119 // Lead-Code mode enabled
120 LOAD_URL("lead-confirm.php");
122 define('__CONFIRM_MSG', GUEST_CONFIRMED_DONE);
123 define('__UID', bigintval($uid));
124 LOAD_TEMPLATE("guest_confirm_table");
126 } elseif (defined('LEAD_CODE_ENABLED') && defined('LEAD_EXPIRY_TIME')) {
127 // Set special lead cookie
128 set_session("lead_uid", bigintval($uid));
130 // Lead-Code mode enabled
131 LOAD_URL("lead-confirm.php");
133 // Nobody was found unter this hash key... or our new member want's to confirm twice?
134 define('__CONFIRM_MSG', GUEST_CONFIRMED_TWICE);
135 define('__UID', "0");
136 LOAD_TEMPLATE("guest_confirm_table");
139 // Nobody was found unter this hash key... or our new member want's to confirm twice?
140 define('__CONFIRM_MSG', GUEST_CONFIRMED_TWICE);
141 define('__UID', "0");
142 LOAD_TEMPLATE("guest_confirm_table");
145 elseif ((isset($_POST['ok'])) && (!empty($_POST['email'])))
147 // Confirmation link requested 0 1 2
148 $result = SQL_QUERY_ESC("SELECT userid, status, user_hash FROM "._MYSQL_PREFIX."_user_data WHERE email='%s' LIMIT 1",
149 array($_POST['email']), __FILE__, __LINE__);
150 if (SQL_NUMROWS($result) == 1)
152 // Email address found
153 $DATA = SQL_FETCHROW($result);
156 case "UNCONFIRMED": // Account not confirmed
157 $msg = LOAD_EMAIL_TEMPLATE("guest_request_confirm", "", $DATA[0]);
158 SEND_EMAIL($_POST['email'], REQUEST_CONFIRM_LINK_SUBJ, $msg);
159 $content = CONFIRM_LINK_SENT;
162 case "CONFIRMED": // Account already confirmed
163 $content = LOGIN_ID_CONFIRMED;
166 case "LOCKED": // Account is locked
167 $content = LOGIN_ID_LOCKED;
173 // Email address not registered
174 $content = EMAIL_ADDY_404;
177 define('__CONFIRM_MSG', $content);
178 LOAD_TEMPLATE("guest_confirm_table");
182 // No hash found, the guest may want to enter his email address to re-get his confirmation link?
183 LOAD_TEMPLATE("guest_confirm_link");