2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Load security stuff here
41 require('inc/libs/security_functions.php');
44 $GLOBALS['startTime'] = microtime(true);
46 // Tell everyone we are in this module
47 $GLOBALS['module'] = 'mailid';
48 $GLOBALS['output_mode'] = -1;
51 // Load the required file(s)
52 require('inc/config-global.php');
55 setContentType('text/html');
57 // Is the extension active?
58 redirectOnUninstalledExtension('mailid');
66 if (isGetRequestParameterSet('userid')) $userId = bigintval(getRequestParameter('userid'));
67 if (isGetRequestParameterSet('mailid')) $mailId = bigintval(getRequestParameter('mailid'));
68 if (isGetRequestParameterSet('bonusid')) $bonusId = bigintval(getRequestParameter('bonusid'));
70 // 01 1 12 2 2 21 1 2210
71 if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalErrorsDetected())) {
75 // Maybe he wants to confirm an email?
78 $result_link = SQL_QUERY_ESC("SELECT `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1",
79 array($mailId, $userId), __FILE__, __LINE__);
82 } elseif ($bonusId > 0) {
84 $result_link = SQL_QUERY_ESC("SELECT `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1",
85 array($bonusId, $userId), __FILE__, __LINE__);
89 // Problem: No id entered
90 redirectToUrl('modules.php?module=index');
93 if (SQL_NUMROWS($result_link) == 1) {
95 list($ltype) = SQL_FETCHROW($result_link);
97 // @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($mailId), __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($bonusId), __FILE__, __LINE__);
114 default: // Invalid mail type
115 debug_report_bug(__FILE__, __LINE__, 'Invalid mail type ' . $ltype . ' detected.');
119 if (SQL_NUMROWS($result) == 1) {
121 list($pool, $URL, $title) = SQL_FETCHROW($result);
124 SQL_FREERESULT($result);
127 setExtraTitle($title);
129 // Is the user's id unlocked?
130 if (fetchUserData($userId)) {
131 // Status must be CONFIRMED
132 if (getUserData('status') == 'CONFIRMED') {
133 // Update last activity if not admin
135 // Is not admin, so update last activity
136 updateLastActivity($userId);
139 // User has confirmed his account so we can procede...
140 // @TODO Rewrite this to a filter
143 $result = SQL_QUERY_ESC("SELECT `payment_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
144 array(bigintval($pool)), __FILE__, __LINE__);
145 if (SQL_NUMROWS($result) == 1) {
146 list($pay) = SQL_FETCHROW($result);
147 $time = getPaymentPoints($pay, 'time');
148 $payment = getPaymentPoints($pay, 'payment');
153 SQL_FREERESULT($result);
157 $result = SQL_QUERY_ESC("SELECT `points`, `time` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
158 array($bonusId), __FILE__, __LINE__);
159 if (SQL_NUMROWS($result) == 1) {
160 list($points, $time) = SQL_FETCHROW($result);
161 $payment = '0.00000';
166 SQL_FREERESULT($result);
169 default: // Invalid mail type
170 debug_report_bug(__FILE__, __LINE__, 'Invalid mail type ' . $ltype . ' detected.');
175 loadIncludeOnce('inc/header.php');
177 // Was that mail a valid one?
178 if ($isValid === true) {
179 // If time is zero seconds we have a sponsor mail. 1 Second shall be set to avoid problems
180 if (($time == '0') && ($payment > 0)) {
185 if (($time > 0) && (($payment > 0) || ($points > 0))) {
186 // Export data into constants for the template
195 loadTemplate('mailid_frames', false, $content);
197 $errorCode = getCode('DATA_INVALID');
200 $errorCode = getCode('POSSIBLE_INVALID');
203 $errorCode = getCode('ACCOUNT_' . getUserData('status'));
206 $errorCode = getCode('USER_404');
209 $errorCode = getCode('STATS_404');
212 $errorCode = getCode('ALREADY_CONFIRMED');
216 SQL_FREERESULT($result_link);
219 $errorCode = getCode('ERROR_MAILID');
222 // Error code is set?
223 handleMailIdErrorCode($errorCode);
226 loadIncludeOnce('inc/footer.php');