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 global $what, $action;
39 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
41 // Tell everyone we are in this module
42 $GLOBALS['module'] = "mailid"; $CSS = -1;
44 // Load the required file(s)
45 require("inc/config.php");
47 if (isBooleanConstantAndTrue('mxchange_installed')) {
48 // Is the extension active?
49 REDIRECT_ON_UNINSTALLED_EXTENSION("mailid");
52 $url_uid = 0; $url_bid = 0; $url_mid = 0;
55 if (!empty($_GET['uid'])) $url_uid = bigintval($_GET['uid']);
56 if (!empty($_GET['mailid'])) $url_mid = bigintval($_GET['mailid']);
57 if (!empty($_GET['bonusid'])) $url_bid = bigintval($_GET['bonusid']);
59 // 01 1 12 3 32 21 1 22 10
60 if (($url_uid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErrors() == 0)) {
61 // Maybe he wants to confirm an email?
64 $result = SQL_QUERY_ESC("SELECT link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE stats_id=%s AND userid=%s LIMIT 1",
65 array($url_mid, $url_uid), __FILE__, __LINE__);
66 $type = "mailid"; $DATA = $url_mid;
67 } elseif ($url_bid > 0) {
69 $result = SQL_QUERY_ESC("SELECT link_type FROM `{!_MYSQL_PREFIX!}_user_links` WHERE bonus_id=%s AND userid=%s LIMIT 1",
70 array($url_bid, $url_uid), __FILE__, __LINE__);
71 $type = "bonusid"; $DATA = $url_bid;
73 // Problem: No ID entered
74 LOAD_URL("index.php");
77 if (SQL_NUMROWS($result) == 1) {
79 list($ltype) = SQL_FETCHROW($result);
82 SQL_FREERESULT($result);
87 // Is the stats ID valid?
88 $result = SQL_QUERY_ESC("SELECT pool_id, url, subject FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE id=%s LIMIT 1",
89 array($url_mid), __FILE__, __LINE__);
93 // Is the bonus extension active?
94 REDIRECT_ON_UNINSTALLED_EXTENSION("bonus");
97 $result = SQL_QUERY_ESC("SELECT id, url, subject FROM `{!_MYSQL_PREFIX!}_bonus` WHERE id=%s LIMIT 1",
98 array($url_bid), __FILE__, __LINE__);
102 if (SQL_NUMROWS($result) == 1) {
104 list($pool, $URL, $EXTRA_TITLE) = SQL_FETCHROW($result);
107 SQL_FREERESULT($result);
109 // Compile extra title
110 $EXTRA_TITLE = COMPILE_CODE($EXTRA_TITLE);
112 // Is the user's ID unlocked?
113 $result = SQL_QUERY_ESC("SELECT status, gender, surname, family FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
114 array($url_uid), __FILE__, __LINE__);
115 if (SQL_NUMROWS($result) == 1) {
116 list($status, $gender, $sname, $fname) = SQL_FETCHROW($result);
117 SQL_FREERESULT($result);
118 if ($status == "CONFIRMED") {
119 // User has confirmed his account so we can procede...
123 $result = SQL_QUERY_ESC("SELECT payment_id FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE pool_id=%s LIMIT 1",
124 array(bigintval($pool)), __FILE__, __LINE__);
125 if (SQL_NUMROWS($result) == 1) {
126 list($pay) = SQL_FETCHROW($result);
127 $time = GET_PAY_POINTS($pay, "time");
128 $payment = GET_PAY_POINTS($pay, "payment");
133 SQL_FREERESULT($result);
137 $result = SQL_QUERY_ESC("SELECT points, time FROM `{!_MYSQL_PREFIX!}_bonus` WHERE id=%s LIMIT 1",
138 array($url_bid), __FILE__, __LINE__);
139 if (SQL_NUMROWS($result) == 1) {
140 list($points, $time) = SQL_FETCHROW($result);
141 $payment = "0.00000";
146 SQL_FREERESULT($result);
151 LOAD_INC_ONCE("inc/header.php");
153 // Was that mail a valid one?
155 // If time is zero seconds we have a sponsor mail. 1 Second shall be set to avoid problems
156 if (($time == "0") && ($payment > 0)) { $URL = constant('URL'); $time = "1"; }
157 if (($time > 0) && (($payment > 0) || ($points > 0))) {
158 // He can confirm this mail!
159 // Export data into constants for the template
160 define('_UID_VALUE' , $url_uid);
161 define('_TYPE_VALUE', $type);
162 define('_DATA_VALUE', $DATA);
163 define('_URL_VALUE' , DEREFERER($URL));
166 LOAD_TEMPLATE("mailid_frames");
168 $msg = constant('CODE_DATA_INVALID');
171 $msg = constant('CODE_POSSIBLE_INVALID');
174 $msg = constant('CODE_ACCOUNT_LOCKED');
177 SQL_FREERESULT($result);
178 $msg = constant('CODE_USER_404');
181 SQL_FREERESULT($result);
182 $msg = constant('CODE_STATS_404');
185 SQL_FREERESULT($result);
186 $msg = constant('CODE_ALREADY_CONFIRMED');
190 $msg = constant('CODE_ERROR_MAILID');
193 // Error code is set?
195 switch (getConfig('mailid_error_redirect')) {
196 case "INDEX": // Redirect to index page
197 LOAD_URL("modules.php?module=index&msg=".$msg."&ext=mailid");
200 case "REJECT": // Redirect to rejection page
201 LOAD_CONFIGURED_URL('reject_url');
205 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown status %s detected in mailid_error_redirect.", getConfig('mailid_error_redirect')));
206 LOAD_URL("modules.php?module=index&msg=".constant('CODE_UNKNOWN_STATUS')."&ext=mailid");
211 LOAD_INC_ONCE("inc/footer.php");
214 // You have to install first!
215 LOAD_URL("install.php");