2 /************************************************************************
3 * MXChange v0.2.1 Start: 11/14/2003 *
4 * =============== Last change: 11/25/2004 *
6 * -------------------------------------------------------------------- *
8 * -------------------------------------------------------------------- *
9 * Short description : Confirmation file for emails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Bestaetigung von Mails *
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 // Load security stuff here (Oh, I hope this is not unsecure? Am I paranoia??? ;-) )
35 require("inc/libs/security_functions.php");
37 // Init "action" and "what"
38 $GLOBALS['what'] = "";
39 $GLOBALS['action'] = "";
41 // Tell everyone we are in this module
42 $GLOBALS['module'] = "mailid";
43 $GLOBALS['output_mode'] = -1;
45 // Load the required file(s)
46 require("inc/config.php");
48 if (isBooleanConstantAndTrue('mxchange_installed')) {
49 // Is the extension active?
50 REDIRECT_ON_UNINSTALLED_EXTENSION("mailid");
53 $url_uid = 0; $url_bid = 0; $url_mid = 0;
56 if (REQUEST_ISSET_GET(('uid'))) $url_uid = bigintval(REQUEST_GET('uid'));
57 if (REQUEST_ISSET_GET(('mailid'))) $url_mid = bigintval(REQUEST_GET('mailid'));
58 if (REQUEST_ISSET_GET(('bonusid'))) $url_bid = bigintval(REQUEST_GET('bonusid'));
60 // 01 1 12 3 32 21 1 22 10
61 if (($url_uid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErrors() == 0)) {
62 // Maybe he wants to confirm an email?
65 $result = SQL_QUERY_ESC("SELECT link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE stats_id=%s AND userid=%s LIMIT 1",
66 array($url_mid, $url_uid), __FILE__, __LINE__);
67 $type = "mailid"; $DATA = $url_mid;
68 } elseif ($url_bid > 0) {
70 $result = SQL_QUERY_ESC("SELECT link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE bonus_id=%s AND userid=%s LIMIT 1",
71 array($url_bid, $url_uid), __FILE__, __LINE__);
72 $type = "bonusid"; $DATA = $url_bid;
74 // Problem: No ID entered
75 LOAD_URL("index.php");
78 if (SQL_NUMROWS($result) == 1) {
80 list($ltype) = SQL_FETCHROW($result);
83 SQL_FREERESULT($result);
88 // Is the stats ID valid?
89 $result = SQL_QUERY_ESC("SELECT pool_id, url, subject FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE id=%s LIMIT 1",
90 array($url_mid), __FILE__, __LINE__);
94 // Is the bonus extension active?
95 REDIRECT_ON_UNINSTALLED_EXTENSION("bonus");
98 $result = SQL_QUERY_ESC("SELECT id, url, subject FROM `{!_MYSQL_PREFIX!}_bonus` WHERE id=%s LIMIT 1",
99 array($url_bid), __FILE__, __LINE__);
103 if (SQL_NUMROWS($result) == 1) {
105 list($pool, $URL, $EXTRA_TITLE) = SQL_FETCHROW($result);
108 SQL_FREERESULT($result);
110 // Compile extra title
111 $EXTRA_TITLE = COMPILE_CODE($EXTRA_TITLE);
113 // Is the user's ID unlocked?
114 $result = SQL_QUERY_ESC("SELECT status, gender, surname, family FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
115 array($url_uid), __FILE__, __LINE__);
116 if (SQL_NUMROWS($result) == 1) {
117 list($status, $gender, $sname, $fname) = SQL_FETCHROW($result);
118 SQL_FREERESULT($result);
119 if ($status == "CONFIRMED") {
120 // User has confirmed his account so we can procede...
124 $result = SQL_QUERY_ESC("SELECT payment_id FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE pool_id=%s LIMIT 1",
125 array(bigintval($pool)), __FILE__, __LINE__);
126 if (SQL_NUMROWS($result) == 1) {
127 list($pay) = SQL_FETCHROW($result);
128 $time = GET_PAY_POINTS($pay, "time");
129 $payment = GET_PAY_POINTS($pay, "payment");
134 SQL_FREERESULT($result);
138 $result = SQL_QUERY_ESC("SELECT points, time FROM `{!_MYSQL_PREFIX!}_bonus` WHERE id=%s LIMIT 1",
139 array($url_bid), __FILE__, __LINE__);
140 if (SQL_NUMROWS($result) == 1) {
141 list($points, $time) = SQL_FETCHROW($result);
142 $payment = "0.00000";
147 SQL_FREERESULT($result);
152 LOAD_INC_ONCE("inc/header.php");
154 // Was that mail a valid one?
156 // If time is zero seconds we have a sponsor mail. 1 Second shall be set to avoid problems
157 if (($time == "0") && ($payment > 0)) { $URL = constant('URL'); $time = "1"; }
158 if (($time > 0) && (($payment > 0) || ($points > 0))) {
159 // He can confirm this mail!
160 // Export data into constants for the template
161 define('_UID_VALUE' , $url_uid);
162 define('_TYPE_VALUE', $type);
163 define('_DATA_VALUE', $DATA);
164 define('_URL_VALUE' , DEREFERER($URL));
167 LOAD_TEMPLATE("mailid_frames");
169 $msg = constant('CODE_DATA_INVALID');
172 $msg = constant('CODE_POSSIBLE_INVALID');
175 $msg = constant('CODE_ACCOUNT_LOCKED');
178 SQL_FREERESULT($result);
179 $msg = constant('CODE_USER_404');
182 SQL_FREERESULT($result);
183 $msg = constant('CODE_STATS_404');
186 SQL_FREERESULT($result);
187 $msg = constant('CODE_ALREADY_CONFIRMED');
191 $msg = constant('CODE_ERROR_MAILID');
194 // Error code is set?
196 switch (getConfig('mailid_error_redirect')) {
197 case "INDEX": // Redirect to index page
198 LOAD_URL("modules.php?module=index&msg=".$msg."&ext=mailid");
201 case "REJECT": // Redirect to rejection page
202 LOAD_CONFIGURED_URL('reject_url');
206 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown status %s detected in mailid_error_redirect.", getConfig('mailid_error_redirect')));
207 LOAD_URL("modules.php?module=index&msg=".constant('CODE_UNKNOWN_STATUS')."&ext=mailid");
212 LOAD_INC_ONCE("inc/footer.php");
215 // You have to install first!
216 LOAD_URL("install.php");