2 /************************************************************************
3 * MXChange v0.2.1 Start: 11/14/2003 *
4 * =============== Last change: 11/13/2004 *
6 * -------------------------------------------------------------------- *
7 * File : mailid_top.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Confirmation file for emails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Bestaetigung von Mails *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Load security stuff here (Oh, I hope this is not unsecure? Am I paranoia??? ;-) )
35 require_once("inc/libs/security_functions.php");
37 // Init "action" and "what"
38 global $what, $action;
39 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
41 // Tell everyone we are in this module
42 $GLOBALS['module'] = "mailid"; $CSS = 0;
44 // Load the required file(s)
45 require ("inc/config.php");
47 if (isBooleanConstantAndTrue('mxchange_installed'))
49 // Is the extension active
50 if (!EXT_IS_ACTIVE("mailid", true)) {
51 // Is not activated/installed yet!
52 ADD_FATAL(sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "register"));
56 $url_uid = 0; $url_bid = 0; $url_mid = 0; $code = 0; $mode = "";
57 if (!empty($_GET['uid'])) $url_uid = bigintval($_GET['uid']);
58 if (!empty($_GET['mailid'])) $url_mid = bigintval($_GET['mailid']);
59 if (!empty($_GET['bonusid'])) $url_bid = bigintval($_GET['bonusid']);
60 if (!empty($_GET['code'])) $code = bigintval($_GET['code']);
61 if (!empty($_GET['mode'])) $mode = $_GET['mode'];
63 // 01 1 12 2 2 21 1 2 2 10
64 if (($url_uid) > 0 && (($url_mid > 0) || ($url_bid > 0)) && (count($FATAL) == 0))
66 if ($mode != "img") require_once(PATH."inc/header.php");
68 // Maybe he wants to confirm an email?
71 $result = SQL_QUERY_ESC("SELECT id, link_type FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s AND userid=%s LIMIT 1",
72 array($url_mid, $url_uid), __FILE__, __LINE__);
73 $type = "mailid"; $DATA = $url_mid;
77 $result = SQL_QUERY_ESC("SELECT id, link_type FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%s AND userid=%s LIMIT 1",
78 array($url_bid, $url_uid), __FILE__, __LINE__);
79 $type = "bonusid"; $DATA = $url_bid;
81 if (SQL_NUMROWS($result) == 1)
83 // Is the stats ID valid?
84 list($lid, $ltype) = SQL_FETCHROW($result);
85 SQL_FREERESULT($result);
89 $result_mailid = SQL_QUERY_ESC("SELECT pool_id, userid, id FROM "._MYSQL_PREFIX."_user_stats WHERE id=%s LIMIT 1",
90 array($url_mid), __FILE__, __LINE__);
94 $result_mailid = SQL_QUERY_ESC("SELECT id, id, is_notify FROM "._MYSQL_PREFIX."_bonus WHERE id=%s LIMIT 1",
95 array($url_bid), __FILE__, __LINE__);
98 if (SQL_NUMROWS($result_mailid) == 1)
100 list($pool, $sender, $notify) = SQL_FETCHROW($result_mailid);
102 // Correct notification switch in non-bonus mails
103 if (($notify != "Y") && ($notify != "N")) $notify = "N";
106 SQL_FREERESULT($result_mailid);
108 // Set sender to 0 when we have a bonus mail
109 if ($ltype == "BONUS") $sender = 0;
111 // Is the user's ID unlocked?
112 $result = SQL_QUERY_ESC("SELECT status, gender, surname, family, ref_payout FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
113 array($url_uid), __FILE__, __LINE__);
114 if (SQL_NUMROWS($result) == 1)
117 list($status, $gender, $sname, $fname, $ref_pay) = SQL_FETCHROW($result);
118 SQL_FREERESULT($result);
120 if ($status == "CONFIRMED")
122 // Update last activity
123 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET last_online=UNIX_TIMESTAMP(), last_module='mailid_top' WHERE userid=%s LIMIT 1",
124 array($url_uid), __FILE__, __LINE__);
126 // User has confirmed his account so we can procede...
130 $result = SQL_QUERY_ESC("SELECT payment_id FROM "._MYSQL_PREFIX."_user_stats WHERE pool_id=%s LIMIT 1",
131 array(bigintval($pool)), __FILE__, __LINE__);
132 if (SQL_NUMROWS($result) == 1)
134 list($pay) = SQL_FETCHROW($result);
135 $time = GET_PAY_POINTS($pay, "time");
136 $payment = GET_PAY_POINTS($pay, "payment");
141 SQL_FREERESULT($result);
145 $result = SQL_QUERY_ESC("SELECT time, points FROM "._MYSQL_PREFIX."_bonus WHERE id=%s LIMIT 1",
146 array(bigintval($pool)), __FILE__, __LINE__);
147 if (SQL_NUMROWS($result) == 1)
149 list($time, $payment) = SQL_FETCHROW($result);
154 SQL_FREERESULT($result);
159 if (($time == "0") && ($payment > 0)) $time = "1";
160 if (($time > 0) && ($payment > 0))
165 $img_code = GEN_RANDOM_CODE($_CONFIG['code_length'], $code, $url_uid, $DATA);
175 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_stats SET clicks=clicks+1 WHERE id=%s LIMIT 1",
176 array($url_mid), __FILE__, __LINE__);
178 // Update mediadata as well
179 if (GET_EXT_VERSION("mediadata") >= "0.0.4")
182 MEDIA_UPDATE_ENTRY(array("total_clicks", "normal_clicks"), "add", 1);
187 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_bonus SET clicks=clicks+1 WHERE id=%s LIMIT 1",
188 array($url_bid), __FILE__, __LINE__);
190 // Update mediadata as well
191 if (GET_EXT_VERSION("mediadata") >= "0.0.4")
194 MEDIA_UPDATE_ENTRY(array("total_clicks", "bonus_clicks"), "add", 1);
199 // Export data into constants for the template
200 define('_POINTS_VALUE' , TRANSLATE_COMMA($payment));
201 define('_TEMPLATE_BANNER', LOAD_TEMPLATE("mailid_banner", true));
203 // Only when user extension = v0.1.2: Update mails-confirmed counter
204 if (GET_EXT_VERSION("user") >= "0.1.2")
207 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET mails_confirmed=mails_confirmed+1 WHERE userid=%s LIMIT 1",
208 array($url_uid), __FILE__, __LINE__);
211 // Right code entered?
212 if (bigintval($_POST['gfx_check']) == $img_code)
214 // Right code entered add points and remove entry
215 if (($ref_pay > 0) && ($_CONFIG['allow_direct_pay'] == "N"))
217 // Don't add points over the referral system
219 $template = "mailid_points_locked";
223 // Add points over referral system
225 $template = "mailid_points_done";
228 // Count down ref_payout value
229 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET ref_payout=ref_payout-1 WHERE userid=%s AND ref_payout > 0 LIMIT 1",
230 array($url_uid), __FILE__, __LINE__);
234 ADD_POINTS_REFSYSTEM($url_uid, $payment, false, "0", $locked);
236 // Shall I add bonus points for "turbo clickers" ?
237 if ((GET_EXT_VERSION("bonus") >= "0.2.2") && (function_exists('BONUS_ADD_TURBO_POINTS')))
239 // Is an active-rallye running and this is not a notification mail?
240 if (($_CONFIG['bonus_active'] == "Y") && ($notify == "N"))
242 // Shall I exclude the webmaster's own userid from the active-rallye?
243 if (((($_CONFIG['bonus_uid'] == $url_uid) && ($_CONFIG['bonus_include_own'] == "Y")) || ($_CONFIG['bonus_uid'] != $url_uid)) && ($_CONFIG['def_refid'] != $url_uid))
245 // Add points and remember ranking are done in this function....
246 BONUS_ADD_TURBO_POINTS($DATA, $url_uid, $type);
248 // Set template to mailid_points_done2 which contains a link to the ranking list
249 $template = "mailid_points_done2";
250 if ($locked) $template = "mailid_points_locked2";
251 define('_UID_VALUE' , $url_uid);
252 define('_TYPE_VALUE', $type);
253 define('_DATA_VALUE', TRANSLATE_COMMA($DATA));
258 // Remove link from table
259 $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE id=%s LIMIT 1",
260 array(bigintval($lid)), __FILE__, __LINE__);
263 define('__TOTAL_POINTS', TRANSLATE_COMMA(
264 GET_TOTAL_DATA($url_uid, "user_points", "points") -
265 GET_TOTAL_DATA($url_uid, "user_data", "used_points"))
269 LOAD_TEMPLATE($template);
273 // Wrong image code! So add points to sender's account
275 ADD_POINTS_REFSYSTEM($sender, $payment, false, 0, false, "direct");
277 // Remove link from table
278 $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE id=%s LIMIT 1",
279 array(bigintval($lid)), __FILE__, __LINE__);
282 LOAD_TEMPLATE("mailid_points_failed");
287 GENERATE_IMAGE($img_code);
293 // Export data into constants for the template
294 define('_CODE_VALUE', $code);
295 define('_UID_VALUE' , $url_uid );
296 define('_TYPE_VALUE', $type);
297 define('_DATA_VALUE', $DATA);
298 define('_TEMPLATE_BANNER', LOAD_TEMPLATE("mailid_banner", true));
299 if ($_CONFIG['code_length'] > 0)
302 define('_IMAGE_CODE', IMG_CODE($code, $type, $DATA, $url_uid));
303 $templ = "mailid_enter_code";
308 define('__GFX_CODE', $img_code);
309 $templ = "mailid_confirm_buttom";
313 LOAD_TEMPLATE($templ);
318 // Ok, all data is valid and loaded. Finally let's output the timer... :-)
319 // Export data into constants for the template
320 define('_TIME_VALUE', $time);
321 define('_TIM2_VALUE', strlen($time));
322 define('_UID_VALUE' , $url_uid );
323 define('_TYPE_VALUE', $type);
324 define('_DATA_VALUE', $DATA);
325 define('_RAND_VALUE', rand(0, 99999));
326 define('_TEMPLATE_BANNER', LOAD_TEMPLATE("mailid_banner", true));
329 LOAD_TEMPLATE("mailid_timer");
333 else OUTPUT_HTML("<STRONG class=\"member_failed\">".MAIL_ALREADY_CONFIRMED." (6)</STRONG>");
335 else OUTPUT_HTML("<STRONG class=\"member_failed\">".MAIL_ALREADY_CONFIRMED." (5)</STRONG>");
337 else OUTPUT_HTML("<STRONG class=\"member_failed\">".MAIL_ALREADY_CONFIRMED." (4)</STRONG>");
341 SQL_FREERESULT($result);
342 OUTPUT_HTML("<STRONG class=\"member_failed\">".MAIL_ALREADY_CONFIRMED." (3)</STRONG>");
347 SQL_FREERESULT($result);
348 OUTPUT_HTML("<STRONG class=\"member_failed\">".MAIL_ALREADY_CONFIRMED." (2)</STRONG>");
353 SQL_FREERESULT($result);
354 OUTPUT_HTML("<STRONG class=\"member_failed\">".MAIL_ALREADY_CONFIRMED." (1)</STRONG>");
359 require_once(PATH."inc/footer.php");
363 elseif ($mode != "img")
365 // You have to configure first!
366 LOAD_URL("install.php");
369 // Really all done here... ;-)