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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Load security stuff here
40 require('inc/libs/security_functions.php');
43 $GLOBALS['startTime'] = microtime(true);
45 // Tell everyone we are in this module
46 $GLOBALS['module'] = 'mailid';
47 $GLOBALS['output_mode'] = -1;
50 // Load the required file(s)
51 require('inc/config-global.php');
54 setContentType('text/html');
56 // Is the extension active?
57 redirectOnUninstalledExtension('mailid');
65 if (isGetRequestElementSet('userid')) $url_userid = bigintval(getRequestElement('userid'));
66 if (isGetRequestElementSet('mailid')) $url_mid = bigintval(getRequestElement('mailid'));
67 if (isGetRequestElementSet('bonusid')) $url_bid = bigintval(getRequestElement('bonusid'));
69 // 01 1 12 2 2 21 1 22 10
70 if (($url_userid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErrors() == 0)) {
74 // Maybe he wants to confirm an email?
77 $result_link = SQL_QUERY_ESC("SELECT `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1",
78 array($url_mid, $url_userid), __FILE__, __LINE__);
79 $type = 'mailid'; $urlId = $url_mid;
80 } elseif ($url_bid > 0) {
82 $result_link = SQL_QUERY_ESC("SELECT `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1",
83 array($url_bid, $url_userid), __FILE__, __LINE__);
84 $type = 'bonusid'; $urlId = $url_bid;
86 // Problem: No id entered
87 redirectToUrl('index.php');
90 if (SQL_NUMROWS($result_link) == 1) {
92 list($ltype) = SQL_FETCHROW($result_link);
94 // @TODO Rewrite this to a filter
97 // Is the stats id valid?
98 $result = SQL_QUERY_ESC("SELECT `pool_id`, `url`, `subject` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
99 array($url_mid), __FILE__, __LINE__);
103 // Is the bonus extension active?
104 redirectOnUninstalledExtension('bonus');
107 $result = SQL_QUERY_ESC("SELECT id, url, subject FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
108 array($url_bid), __FILE__, __LINE__);
111 default: // Invalid mail type
112 debug_report_bug('Invalid mail type ' . $ltype . ' detected.');
116 if (SQL_NUMROWS($result) == 1) {
118 list($pool, $URL, $title) = SQL_FETCHROW($result);
121 SQL_FREERESULT($result);
124 setExtraTitle($title);
126 // Is the user's id unlocked?
127 if (fetchUserData($url_userid)) {
128 // Status must be CONFIRMED
129 if (getUserData('status') == 'CONFIRMED') {
130 // Update last activity
131 updateLastActivity($url_userid);
133 // User has confirmed his account so we can procede...
134 // @TODO Rewrite this to a filter
137 $result = SQL_QUERY_ESC("SELECT `payment_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
138 array(bigintval($pool)), __FILE__, __LINE__);
139 if (SQL_NUMROWS($result) == 1) {
140 list($pay) = SQL_FETCHROW($result);
141 $time = getPaymentPoints($pay, 'time');
142 $payment = getPaymentPoints($pay, 'payment');
147 SQL_FREERESULT($result);
151 $result = SQL_QUERY_ESC("SELECT `points`, `time` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
152 array($url_bid), __FILE__, __LINE__);
153 if (SQL_NUMROWS($result) == 1) {
154 list($points, $time) = SQL_FETCHROW($result);
155 $payment = '0.00000';
160 SQL_FREERESULT($result);
163 default: // Invalid mail type
164 debug_report_bug('Invalid mail type ' . $ltype . ' detected.');
169 loadIncludeOnce('inc/header.php');
171 // Was that mail a valid one?
172 if ($isValid === true) {
173 // If time is zero seconds we have a sponsor mail. 1 Second shall be set to avoid problems
174 if (($time == 0) && ($payment > 0)) { $URL = getConfig('URL'); $time = 1; }
175 if (($time > 0) && (($payment > 0) || ($points > 0))) {
176 // Export data into constants for the template
178 'userid' => $url_userid,
181 'url' => generateDerefererUrl($URL)
185 loadTemplate('mailid_frames', false, $content);
187 $errorCode = getCode('DATA_INVALID');
190 $errorCode = getCode('POSSIBLE_INVALID');
193 $errorCode = getCode('ACCOUNT_' . getUserData('status'));
196 $errorCode = getCode('USER_404');
199 $errorCode = getCode('STATS_404');
202 $errorCode = getCode('ALREADY_CONFIRMED');
206 SQL_FREERESULT($result_link);
209 $errorCode = getCode('ERROR_MAILID');
212 // Error code is set?
213 if (!empty($errorCode)) {
214 // @TODO Rewrite this to a dynamic include or so
215 switch (getConfig('mailid_error_redirect')) {
216 case 'INDEX': // Redirect to index page
217 redirectToUrl('modules.php?module=index&code=' . $errorCode . '&ext=mailid');
220 case 'REJECT': // Redirect to rejection page
221 if (isExtensionActive('other')) {
222 // Redirect to configured URL
223 redirectToConfiguredUrl('reject_url');
226 redirectToUrl('index.php');
231 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown status %s detected in mailid_error_redirect.", getConfig('mailid_error_redirect')));
232 redirectToUrl('modules.php?module=index&code=' . getCode('UNKNOWN_STATUS') . '&ext=mailid');
238 loadIncludeOnce('inc/footer.php');