Fixed broken german umlauts
[mailer.git] / 0.2.1 / inc / modules / guest / what-confirm.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/13/2003 *
4  * ===============                              Last change: 08/23/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-confirm.php                                 *
8  * -------------------------------------------------------------------- *
9  * Short description : Stuff around the confirmation link               *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Alles um den Bestaetigungslink                   *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
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.                                  *
22  *                                                                      *
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.                         *
27  *                                                                      *
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,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
36 {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40 // Add description as navigation point
41 ADD_DESCR("guest", basename(__FILE__));
42
43 OPEN_TABLE("100%", "guest_content_align", "");
44 if (!empty($_GET['hash']))
45 {
46         // Initialize the user ID
47         $uid = 0;
48
49         // Search for an unconfirmed or confirmed account
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",
51          array($_GET['hash']), __FILE__, __LINE__);
52         if (SQL_NUMROWS($result) == 1)
53         {
54                 // Ok, he want's to confirm now so we load some data
55                 list ($uid, $email, $rid) = SQL_FETCHROW($result);
56
57                 // Unlock his account (but only when it is on UNCONFIRMED!)
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",
59                  array($CONFIG['ref_payout'], $_GET['hash']), __FILE__, __LINE__);
60                 if (SQL_AFFECTEDROWS($link, __FILE__, __LINE__) == 1)
61                 {
62                         $msg = LOAD_EMAIL_TEMPLATE("confirm-member", "", bigintval($uid));
63
64                         // And send him right away the confirmation mail
65                         SEND_EMAIL($email, GUEST_THANX_CONFIRM, $msg);
66
67                         // Maybe he got "referraled"?
68                         if (($rid > 0) && ($rid != $uid))
69                         {
70                                 // Select the referral userid
71                                 $result = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",
72                                  array(bigintval($rid)), __FILE__, __LINE__);
73                                 if (SQL_NUMROWS($result) == 1)
74                                 {
75                                         // Update ref counter...
76                                         UPDATE_REF_COUNTER($rid);
77
78                                         // Ok, write the ref-points to this user and his parent-ref
79                                         unset($DEPTH);
80
81                                         // Shall I "pay" the referral points imidiately?
82                                         if ($CONFIG['ref_payout'] == "0")
83                                         {
84                                                 // Yes, "pay" it now
85                                                 $locked = false;
86                                         }
87                                          else
88                                         {
89                                                 // No, "pay" it later
90                                                 $locked = true;
91                                         }
92
93                                         // If version matches add ref bonus to refid's account
94                                         if ((GET_EXT_VERSION("bonus") >= "0.4.4") && ($CONFIG['bonus_active'] == "Y"))
95                                         {
96                                                 // Add points (directly only!)
97                                                 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET bonus_ref=bonus_ref+%s WHERE userid=%d LIMIT 1",
98                                                  array($CONFIG['bonus_ref'], bigintval($rid)), __FILE__, __LINE__);
99
100                                                 // Subtract points from system
101                                                 BONUS_POINTS_HANDLER($CONFIG['bonus_ref']);
102                                         }
103
104                                         // 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']);
106                                 }
107                         }
108
109                         if (EXT_IS_ACTIVE("rallye")) {
110                                 // Add user to rallye (or not?)
111                                 RALLYE_AUTOADD_USER(bigintval($uid));
112                         }
113
114                         // Account confirmed!
115                         if (defined('LEAD_CODE_ENABLED') && defined('LEAD_EXPIRY_TIME')) {
116                                 // Set special lead cookie
117                                 setcookie("lead_uid", bigintval($uid), (time() + LEAD_EXPIRY_TIME), COOKIE_PATH);
118                                 $_COOKIE['lead_uid'] = bigintval($uid);
119
120                                 // Lead-Code mode enabled
121                                 LOAD_URL(URL."/lead-confirm.php");
122                         } else {
123                                 define('__CONFIRM_MSG', GUEST_CONFIRMED_DONE);
124                                 define('__UID', bigintval($uid));
125                                 LOAD_TEMPLATE("guest_confirm_table");
126                         }
127                 } elseif (defined('LEAD_CODE_ENABLED') && defined('LEAD_EXPIRY_TIME')) {
128                         // Set special lead cookie
129                         setcookie("lead_uid", bigintval($uid), (time() + LEAD_EXPIRY_TIME), COOKIE_PATH);
130                         $_COOKIE['lead_uid'] = bigintval($uid);
131
132                         // Lead-Code mode enabled
133                         LOAD_URL(URL."/lead-confirm.php");
134                 } else {
135                         // Nobody was found unter this hash key... or our new member want's to confirm twice?
136                         define('__CONFIRM_MSG', GUEST_CONFIRMED_TWICE);
137                         define('__UID', "0");
138                         LOAD_TEMPLATE("guest_confirm_table");
139                 }
140         } else {
141                 // Nobody was found unter this hash key... or our new member want's to confirm twice?
142                 define('__CONFIRM_MSG', GUEST_CONFIRMED_TWICE);
143                 define('__UID', "0");
144                 LOAD_TEMPLATE("guest_confirm_table");
145         }
146 }
147  elseif ((isset($_POST['ok'])) && (!empty($_POST['email'])))
148 {
149         // Confirmation link requested      0     1         2
150         $result = SQL_QUERY_ESC("SELECT userid, status, user_hash FROM "._MYSQL_PREFIX."_user_data WHERE email='%s' LIMIT 1",
151          array($_POST['email']), __FILE__, __LINE__);
152         if (SQL_NUMROWS($result) == 1)
153         {
154                 // Email address found
155                 $DATA = SQL_FETCHROW($result);
156                 switch ($DATA[1])
157                 {
158                 case "UNCONFIRMED": // Account not confirmed
159                         $msg = LOAD_EMAIL_TEMPLATE("guest_request_confirm", "", $DATA[0]);
160                         SEND_EMAIL($_POST['email'], REQUEST_CONFIRM_LINK_SUBJ, $msg);
161                         $content = CONFIRM_LINK_SENT;
162                         break;
163
164                 case "CONFIRMED": // Account already confirmed
165                         $content = LOGIN_ID_CONFIRMED;
166                         break;
167
168                 case "LOCKED": // Account is locked
169                         $content = LOGIN_ID_LOCKED;
170                         break;
171                 }
172         }
173          else
174         {
175                 // Email address not registered
176                 $content = EMAIL_ADDY_404;
177         }
178
179         define('__CONFIRM_MSG', $content);
180         LOAD_TEMPLATE("guest_confirm_table");
181 }
182  else
183 {
184         // No hash found, the guest may want to enter his email address to re-get his confirmation link?
185         LOAD_TEMPLATE("guest_confirm_link");
186 }
187 CLOSE_TABLE();
188 //
189 ?>