]> git.mxchange.org Git - mailer.git/blob - mailid.php
fcf1e3beac9f0375ece5a96a985ade1fe4df60e3
[mailer.git] / mailid.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 11/14/2003 *
4  * ===================                          Last change: 11/25/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : mailid.php                                       *
8  * -------------------------------------------------------------------- *
9  * Short description : Confirmation file for emails                     *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Bestaetigung von Mails                           *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Load security stuff here
39 require('inc/libs/security_functions.php');
40
41 // Init start time
42 $GLOBALS['__start_time'] = microtime(true);
43
44 // Tell everyone we are in this module
45 $GLOBALS['__module']      = 'mailid';
46 $GLOBALS['__output_mode'] = '0';
47 $errorCode = '';
48
49 // This is a frameset module
50 $GLOBALS['frameset_mode'] = true;
51
52 // Disable copyright footer which would break the frameset
53 $GLOBALS['__copyright_enabled'] = 'N';
54
55 // Load the required file(s)
56 require('inc/config-global.php');
57
58 // Set content type and HTTP status
59 setContentType('text/html');
60 setHttpStatus('404 Not Found');
61
62 // Is the extension active?
63 redirectOnUninstalledExtension('mailid');
64
65 // Init
66 $userId  = '0';
67 $bonusId = '0';
68 $mailId  = '0';
69
70 // Secure all data
71 if (isGetRequestElementSet('userid'))  $userId  = bigintval(getRequestElement('userid'));
72 if (isGetRequestElementSet('mailid'))  $mailId  = bigintval(getRequestElement('mailid'));
73 if (isGetRequestElementSet('bonusid')) $bonusId = bigintval(getRequestElement('bonusid'));
74
75 // 01           1        12            2    2            21    1                      2210
76 if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalErrorsDetected())) {
77         // Init result
78         $result_link = false;
79
80         // Maybe he wants to confirm an email?
81         if ($mailId > 0) {
82                 // Member mail
83                 $result_link = SQL_QUERY_ESC("SELECT `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s AND `userid`=%s LIMIT 1",
84                         array($mailId, $userId), __FILE__, __LINE__);
85                 $type = 'mailid';
86                 $urlId = $mailId;
87         } elseif ($bonusId > 0) {
88                 // Bonus mail
89                 $result_link = SQL_QUERY_ESC("SELECT `link_type` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s AND `userid`=%s LIMIT 1",
90                         array($bonusId, $userId), __FILE__, __LINE__);
91                 $type = 'bonusid';
92                 $urlId = $bonusId;
93         } else {
94                 // Problem: No id entered
95                 redirectToUrl('modules.php?module=index');
96         }
97
98         if (SQL_NUMROWS($result_link) == 1) {
99                 // Load the entry
100                 list($ltype) = SQL_FETCHROW($result_link);
101
102                 // @TODO Rewrite this to a filter
103                 switch ($ltype) {
104                         case 'NORMAL':
105                                 // Is the stats id valid?
106                                 $result = SQL_QUERY_ESC("SELECT `pool_id`, `url`, `subject` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `id`=%s LIMIT 1",
107                                         array($mailId), __FILE__, __LINE__);
108                                 break;
109
110                         case 'BONUS':
111                                 // Is the bonus extension active?
112                                 redirectOnUninstalledExtension('bonus');
113
114                                 // Bonus-Mails
115                                 $result = SQL_QUERY_ESC("SELECT `id`, `url`, `subject` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
116                                         array($bonusId), __FILE__, __LINE__);
117                                 break;
118
119                         default: // Invalid mail type
120                                 reportBug(__FILE__, __LINE__, 'Invalid mail type ' . $ltype . ' detected.');
121                                 break;
122                 } // END - switch
123
124                 if (SQL_NUMROWS($result) == 1) {
125                         // Load data
126                         list($pool, $url, $title) = SQL_FETCHROW($result);
127
128                         // Free result
129                         SQL_FREERESULT($result);
130
131                         // Set it
132                         setExtraTitle($title);
133
134                         // Is the user's id unlocked?
135                         if (fetchUserData($userId)) {
136                                 // Status must be CONFIRMED
137                                 if (getUserData('status') == 'CONFIRMED') {
138                                         // Update last activity if not admin
139                                         if ((!isAdmin()) || (isDebugModeEnabled())) {
140                                                 // Is not admin, so update last activity
141                                                 updateLastActivity($userId);
142                                         } // END - if
143
144                                         // User has confirmed his account so we can procede...
145                                         // @TODO Rewrite this to a filter
146                                         switch ($ltype) {
147                                                 case 'NORMAL':
148                                                         $result = SQL_QUERY_ESC("SELECT `payment_id` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
149                                                                 array(bigintval($pool)), __FILE__, __LINE__);
150                                                         if (SQL_NUMROWS($result) == 1) {
151                                                                 list($pay) = SQL_FETCHROW($result);
152                                                                 $time      = getPaymentData($pay, 'time');
153                                                                 $payment   = getPaymentData($pay, 'payment');
154                                                                 $isValid   = true;
155                                                         } // END - if
156
157                                                         // Free memory
158                                                         SQL_FREERESULT($result);
159                                                         break;
160
161                                                 case 'BONUS':
162                                                         $result = SQL_QUERY_ESC("SELECT `points`, `time` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
163                                                                 array($bonusId), __FILE__, __LINE__);
164                                                         if (SQL_NUMROWS($result) == 1) {
165                                                                 list($points, $time) = SQL_FETCHROW($result);
166                                                                 $payment = '0.00000';
167                                                                 $isValid = true;
168                                                         } // END - if
169
170                                                         // Free memory
171                                                         SQL_FREERESULT($result);
172                                                         break;
173
174                                                 default: // Invalid mail type
175                                                         reportBug(__FILE__, __LINE__, 'Invalid mail type ' . $ltype . ' detected.');
176                                                         break;
177                                         }
178
179                                         // Add header
180                                         loadIncludeOnce('inc/header.php');
181
182                                         // Was that mail a valid one?
183                                         if ($isValid === true) {
184                                                 // If time is zero seconds we have a sponsor mail. 1 Second shall be set to avoid problems
185                                                 if (($time == '0') && ($payment > 0)) { 
186                                                         $url = getUrl();
187                                                         $time = 1; 
188                                                 } // END - if
189
190                                                 if (($time > 0) && (($payment > 0) || ($points > 0))) {
191                                                         // Set HTTP status to okay
192                                                         setHttpStatus('200 OK');
193
194                                                         // Export data into constants for the template
195                                                         $content = array(
196                                                                 'userid'  => $userId,
197                                                                 'type'    => $type,
198                                                                 'data'    => $urlId,
199                                                                 'url'     => $url
200                                                         );
201
202                                                         // Load template
203                                                         loadTemplate('mailid_frames', false, $content);
204                                                 } else {
205                                                         $errorCode = getCode('DATA_INVALID');
206                                                 }
207                                         } else {
208                                                 $errorCode = getCode('POSSIBLE_INVALID');
209                                         }
210                                 } else {
211                                         $errorCode = getCode('ACCOUNT_' . strtoupper(getUserData('status')));
212                                 }
213                         } else {
214                                 $errorCode = getCode('USER_404');
215                         }
216                 } else {
217                         $errorCode = getCode('STATS_404');
218                 }
219         } else {
220                 $errorCode = getCode('ALREADY_CONFIRMED');
221         }
222
223         // Free result
224         SQL_FREERESULT($result_link);
225 } else {
226         // Nothing entered
227         $errorCode = getCode('ERROR_MAILID');
228 }
229
230 // Error code is set?
231 handleMailIdErrorCode($errorCode);
232
233 // Include footer
234 loadIncludeOnce('inc/footer.php');
235
236 // [EOF]
237 ?>