- obsolete templates/scripts removed
[mailer.git] / 0.2.1 / mailid.php
1 <?php\r
2 /************************************************************************\r
3  * MXChange v0.2.1                                    Start: 11/14/2003 *\r
4  * ===============                              Last change: 11/25/2004 *\r
5  *                                                                      *\r
6  * -------------------------------------------------------------------- *\r
7  * File              : mailid.php                                       *\r
8  * -------------------------------------------------------------------- *\r
9  * Short description : Confirmation file for emails                     *\r
10  * -------------------------------------------------------------------- *\r
11  * Kurzbeschreibung  : Bestaetigung von Mails                           *\r
12  * -------------------------------------------------------------------- *\r
13  *                                                                      *\r
14  * -------------------------------------------------------------------- *\r
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *\r
16  * For more information visit: http://www.mxchange.org                  *\r
17  *                                                                      *\r
18  * This program is free software; you can redistribute it and/or modify *\r
19  * it under the terms of the GNU General Public License as published by *\r
20  * the Free Software Foundation; either version 2 of the License, or    *\r
21  * (at your option) any later version.                                  *\r
22  *                                                                      *\r
23  * This program is distributed in the hope that it will be useful,      *\r
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
26  * GNU General Public License for more details.                         *\r
27  *                                                                      *\r
28  * You should have received a copy of the GNU General Public License    *\r
29  * along with this program; if not, write to the Free Software          *\r
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
31  * MA  02110-1301  USA                                                  *\r
32  ************************************************************************/\r
33 \r
34 // Load security stuff here (Oh, I hope this is not unsecure? Am I paranoia??? ;-) )\r
35 require_once("inc/libs/security_functions.php");\r
36 \r
37 // Init "action" and "what"\r
38 global $what, $action;\r
39 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";\r
40 if (!empty($_GET['action'])) $GLOBALS['action'] = secureString($_GET['action']);\r
41 if (!empty($_GET['what'])) $GLOBALS['what'] = secureString($_GET['what']);\r
42 \r
43 // Tell everyone we are in this module\r
44 $GLOBALS['module'] = "mailid"; $CSS = -1;\r
45 \r
46 // Load the required file(s)\r
47 require ("inc/config.php");\r
48 \r
49 if (defined('mxchange_installed') && (mxchange_installed))\r
50 {\r
51         // Is the extension active\r
52         if (!EXT_IS_ACTIVE("mailid", true)) {\r
53                 // Is not activated/installed yet!\r
54                 ADD_FATAL(sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "register"));\r
55         }\r
56 \r
57         // Add header\r
58         require_once(PATH."inc/header.php");\r
59 \r
60         // Secure all data\r
61         $url_uid = "0"; $url_bid = "0"; $url_mid = "0";\r
62         if (!empty($_GET['uid']))     $url_uid = bigintval($_GET['uid']);\r
63         if (!empty($_GET['mailid']))  $url_mid = bigintval($_GET['mailid']);\r
64         if (!empty($_GET['bonusid'])) $url_bid = bigintval($_GET['bonusid']);\r
65 \r
66         // 01        1        12            3    32           21    1     2      2     10\r
67         if (($url_uid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (count($FATAL) == 0))\r
68         {\r
69                 // Maybe he wants to confirm an email?\r
70                 if ($url_mid > 0)\r
71                 {\r
72                         // Normal-Mails\r
73                         $result = SQL_QUERY_ESC("SELECT link_type FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%d AND userid=%d LIMIT 1",\r
74                          array($url_mid, $url_uid), __FILE__, __LINE__);\r
75                         $TYPE = "mailid"; $DATA = $url_mid;\r
76                 }\r
77                  elseif ($url_bid > 0)\r
78                 {\r
79                         // Bonus-Mail\r
80                         $result = SQL_QUERY_ESC("SELECT link_type FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%d AND userid=%d LIMIT 1",\r
81                          array($url_bid, $url_uid), __FILE__, __LINE__);\r
82                         $TYPE = "bonusid"; $DATA = $url_bid;\r
83                 }\r
84                  else\r
85                 {\r
86                         // Problem: No ID entered\r
87                         LOAD_URL("index.php");\r
88                 }\r
89                 if (SQL_NUMROWS($result) == 1)\r
90                 {\r
91                         list($ltype) = SQL_FETCHROW($result);\r
92                         SQL_FREERESULT($result);\r
93                         switch ($ltype)\r
94                         {\r
95                         case "NORMAL":\r
96                                 // Is the stats ID valid?\r
97                                 $result = SQL_QUERY_ESC("SELECT pool_id, url FROM "._MYSQL_PREFIX."_user_stats WHERE id=%d LIMIT 1",\r
98                                  array($url_mid), __FILE__, __LINE__);\r
99                                 break;\r
100 \r
101                         case "BONUS":\r
102                                 // Bonus-Mails\r
103                                 $result = SQL_QUERY_ESC("SELECT id, url FROM "._MYSQL_PREFIX."_bonus WHERE id=%d LIMIT 1",\r
104                                  array($url_bid), __FILE__, __LINE__);\r
105                                 break;\r
106                         }\r
107 \r
108                         if (SQL_NUMROWS($result) == 1)\r
109                         {\r
110                                 // Load data\r
111                                 list($pool, $URL) = SQL_FETCHROW($result);\r
112                                 SQL_FREERESULT($result);\r
113 \r
114                                 // Is the user's ID unlocked?\r
115                                 $result = SQL_QUERY_ESC("SELECT status, sex, surname, family FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",\r
116                                  array($url_uid), __FILE__, __LINE__);\r
117                                 if (SQL_NUMROWS($result) == 1)\r
118                                 {\r
119                                         list($status, $sex, $sname, $fname) = SQL_FETCHROW($result);\r
120                                         SQL_FREERESULT($result);\r
121                                         if ($status == "CONFIRMED")\r
122                                         {\r
123                                                 // User has confirmed his account so we can procede...\r
124                                                 switch ($ltype)\r
125                                                 {\r
126                                                 case "NORMAL":\r
127                                                         $result = SQL_QUERY_ESC("SELECT payment_id FROM "._MYSQL_PREFIX."_user_stats WHERE pool_id=%d LIMIT 1",\r
128                                                          array(bigintval($pool)), __FILE__, __LINE__);\r
129                                                         if (SQL_NUMROWS($result) == 1)\r
130                                                         {\r
131                                                                 list($pay) = SQL_FETCHROW($result);\r
132                                                                 $time      = GET_PAY_POINTS($pay, "time");\r
133                                                                 $payment   = GET_PAY_POINTS($pay, "payment");\r
134                                                                 $VALID     = true;\r
135                                                         }\r
136 \r
137                                                         // Free memory\r
138                                                         SQL_FREERESULT($result);\r
139                                                         break;\r
140 \r
141                                                 case "BONUS":\r
142                                                         $result = SQL_QUERY_ESC("SELECT points, time FROM "._MYSQL_PREFIX."_bonus WHERE id=%d LIMIT 1",\r
143                                                          array($url_bid), __FILE__, __LINE__);\r
144                                                         if (SQL_NUMROWS($result) == 1)\r
145                                                         {\r
146                                                                 list($points, $time) = SQL_FETCHROW($result);\r
147                                                                 $payment = "0.00000";\r
148                                                                 $VALID = true;\r
149                                                         }\r
150 \r
151                                                         // Free memory\r
152                                                         SQL_FREERESULT($result);\r
153                                                         break;\r
154                                                 }\r
155 \r
156                                                 if ($VALID)\r
157                                                 {\r
158                                                         // If time is zero seconds we have a sponsor mail. 1 Second shall be set to avoid problems\r
159                                                         if (($time == "0") && ($payment > 0)) { $URL = URL; $time = "1"; }\r
160                                                         if (($time > 0) && (($payment > 0) || ($points > 0)))\r
161                                                         {\r
162                                                                 // He can confirm this mail!\r
163                                                                 // Export data into constants for the template\r
164                                                                 define('_UID_VALUE' , $url_uid);\r
165                                                                 define('_TYPE_VALUE', $TYPE);\r
166                                                                 define('_DATA_VALUE', $DATA);\r
167                                                                 define('_URL_VALUE' , DEREFERER($URL));\r
168 \r
169                                                                 // Load template\r
170                                                                 LOAD_TEMPLATE("mailid_frames");\r
171                                                         }\r
172                                                          else\r
173                                                         {\r
174                                                                 $msg = CODE_DATA_INVALID;\r
175                                                         }\r
176                                                 }\r
177                                                  else\r
178                                                 {\r
179                                                         $msg = CODE_POSSIBLE_INVALID;\r
180                                                 }\r
181                                         }\r
182                                          else\r
183                                         {\r
184                                                 $msg = CODE_ACCOUNT_LOCKED;\r
185                                         }\r
186                                 }\r
187                                  else\r
188                                 {\r
189                                         SQL_FREERESULT($result);\r
190                                         $msg = CODE_USER_404;\r
191                                 }\r
192                         }\r
193                          else\r
194                         {\r
195                                 SQL_FREERESULT($result);\r
196                                 $msg = CODE_STATS_404;\r
197                         }\r
198                 }\r
199                  else\r
200                 {\r
201                         SQL_FREERESULT($result);\r
202                         $msg = CODE_ALREADY_CONFIRMED;\r
203                 }\r
204         }\r
205          else\r
206         {\r
207                 // Nothing entered\r
208                 $msg = CODE_ERROR_MAILID;\r
209         }\r
210         if (!empty($msg))\r
211         {\r
212                 LOAD_URL(URL."/modules.php?module=index&msg=".$msg);\r
213         }\r
214 \r
215         require_once(PATH."inc/footer.php");\r
216 }\r
217  else\r
218 {\r
219         // You have to configure first!\r
220         LOAD_URL("install.php");\r
221 }\r
222 // Really all done here... ;-)\r
223 die();\r
224 \r
225 //\r
226 ?>\r