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 - 2008 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 // You have to install first!
55 redirectToUrl('install.php');
58 // Is the extension active?
59 redirectOnUninstalledExtension('mailid');
67 if (REQUEST_ISSET_GET('uid')) $url_uid = bigintval(REQUEST_GET('uid'));
68 if (REQUEST_ISSET_GET('mailid')) $url_mid = bigintval(REQUEST_GET('mailid'));
69 if (REQUEST_ISSET_GET('bonusid')) $url_bid = bigintval(REQUEST_GET('bonusid'));
71 // 01 1 12 3 32 21 1 22 10
72 if (($url_uid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (getTotalFatalErrors() == 0)) {
73 // Maybe he wants to confirm an email?
76 $result = SQL_QUERY_ESC("SELECT `link_type` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1",
77 array($url_mid, $url_uid), __FILE__, __LINE__);
78 $type = 'mailid'; $urlId = $url_mid;
79 } elseif ($url_bid > 0) {
81 $result = SQL_QUERY_ESC("SELECT `link_type` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1",
82 array($url_bid, $url_uid), __FILE__, __LINE__);
83 $type = 'bonusid'; $urlId = $url_bid;
85 // Problem: No ID entered
86 redirectToUrl('index.php');
89 if (SQL_NUMROWS($result) == 1) {
91 list($ltype) = SQL_FETCHROW($result);
94 SQL_FREERESULT($result);
96 // @TODO Rewrite this to a filter
100 // Is the stats ID valid?
101 $result = SQL_QUERY_ESC("SELECT pool_id, url, subject FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE `id`=%s LIMIT 1",
102 array($url_mid), __FILE__, __LINE__);
106 // Is the bonus extension active?
107 redirectOnUninstalledExtension('bonus');
110 $result = SQL_QUERY_ESC("SELECT id, url, subject FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `id`=%s LIMIT 1",
111 array($url_bid), __FILE__, __LINE__);
114 default: // Invalid mail type
115 debug_report_bug('Invalid mail type ' . $ltype . ' detected.');
119 if (SQL_NUMROWS($result) == 1) {
121 list($pool, $URL, $title) = SQL_FETCHROW($result);
124 SQL_FREERESULT($result);
126 // Compile extra title
127 $title = COMPILE_CODE($title);
130 setExtraTitle($title);
132 // Is the user's ID unlocked?
133 $result = SQL_QUERY_ESC("SELECT `status`, `gender`, `surname`,` family` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
134 array($url_uid), __FILE__, __LINE__);
135 if (SQL_NUMROWS($result) == 1) {
136 list($status, $gender, $sname, $fname) = SQL_FETCHROW($result);
137 SQL_FREERESULT($result);
138 if ($status == 'CONFIRMED') {
139 // User has confirmed his account so we can procede...
140 // @TODO Rewrite this to a filter
144 $result = SQL_QUERY_ESC("SELECT payment_id FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE pool_id=%s LIMIT 1",
145 array(bigintval($pool)), __FILE__, __LINE__);
146 if (SQL_NUMROWS($result) == 1) {
147 list($pay) = SQL_FETCHROW($result);
148 $time = getPaymentPoints($pay, 'time');
149 $payment = getPaymentPoints($pay, 'payment');
154 SQL_FREERESULT($result);
158 $result = SQL_QUERY_ESC("SELECT points, time FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `id`=%s LIMIT 1",
159 array($url_bid), __FILE__, __LINE__);
160 if (SQL_NUMROWS($result) == 1) {
161 list($points, $time) = SQL_FETCHROW($result);
162 $payment = '0.00000';
167 SQL_FREERESULT($result);
170 default: // Invalid mail type
171 debug_report_bug('Invalid mail type ' . $ltype . ' detected.');
176 loadIncludeOnce('inc/header.php');
178 // Was that mail a valid one?
179 if ($isValid === true) {
180 // If time is zero seconds we have a sponsor mail. 1 Second shall be set to avoid problems
181 if (($time == '0') && ($payment > 0)) { $URL = getConfig('URL'); $time = '1'; }
182 if (($time > 0) && (($payment > 0) || ($points > 0))) {
183 // Export data into constants for the template
188 'url' => DEREFERER($URL)
192 LOAD_TEMPLATE('mailid_frames');
194 $errorCode = getCode('DATA_INVALID');
197 $errorCode = getCode('POSSIBLE_INVALID');
200 $errorCode = getCode('ACCOUNT_LOCKED');
203 SQL_FREERESULT($result);
204 $errorCode = getCode('USER_404');
207 SQL_FREERESULT($result);
208 $errorCode = getCode('STATS_404');
211 SQL_FREERESULT($result);
212 $errorCode = getCode('ALREADY_CONFIRMED');
216 $errorCode = getCode('ERROR_MAILID');
219 // Error code is set?
220 if (!empty($errorCode)) {
221 // @TODO Rewrite this to a filter
222 switch (getConfig('mailid_error_redirect')) {
223 case 'INDEX': // Redirect to index page
224 redirectToUrl('modules.php?module=index&msg=' . $errorCode . '&ext=mailid');
227 case 'REJECT': // Redirect to rejection page
228 redirectToConfiguredUrl('reject_url');
232 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown status %s detected in mailid_error_redirect.", getConfig('mailid_error_redirect')));
233 redirectToUrl('modules.php?module=index&msg=' . getCode('UNKNOWN_STATUS') . '&ext=mailid');
238 loadIncludeOnce('inc/footer.php');