removed
[mailer.git] / birthday_confirm.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/03/2004 *
4  * ===============                              Last change: 10/03/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : birthday_confirm.php                             *
8  * -------------------------------------------------------------------- *
9  * Short description : Birthday bonus confirmation link                 *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Geburtstagsgutschrift bestaetigen                *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
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.                                  *
22  *                                                                      *
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.                         *
27  *                                                                      *
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,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Load security stuff here (Oh, I hope this is not unsecure? Am I paranoia??? ;-) )
35 require_once("inc/libs/security_functions.php");
36
37 // Init "action" and "what"
38 global $what, $action;
39 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
40 if (!empty($_GET['action'])) $GLOBALS['action'] = secureString($_GET['action']);
41 if (!empty($_GET['what'])) $GLOBALS['what'] = secureString($_GET['what']);
42
43 // Set module
44 $GLOBALS['module'] = "birthday_confirm"; $CSS = -1;
45
46 // Load the required file(s)
47 require ("inc/config.php");
48
49 if (defined('mxchange_installed') && (mxchange_installed))
50 {
51         // Script is installed so let's check for his confirmation link...
52         $uid = strip_tags(bigintval($_GET['uid']));
53
54         // Only allow numbers here...
55         $chk = strip_tags(bigintval($_GET['check']));
56
57         // .. only first 32 numbers
58         $chk = substr($chk, 0, 32);
59
60         // Check if link is not clicked so far
61         $result = SQL_QUERY_ESC("SELECT DISTINCT b.points, d.sex, d.surname, d.family, d.status
62 FROM "._MYSQL_PREFIX."_user_birthday AS b
63 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
64 ON b.userid=d.userid
65 WHERE b.userid=%d AND b.chk_value='%s' LIMIT 1",
66  array($uid, $chk), __FILE__, __LINE__);
67
68         if (SQL_NUMROWS($result) == 1)
69         {
70                 // Ok, congratulation again! Here's your gift from us...
71                 list($GIFT, $salut, $sname, $fname, $status) = SQL_FETCHROW($result);
72                 if ($status == "CONFIRMED")
73                 {
74                         // Set mode depending on how many mails the member has to confirm
75                         $locked = false;
76                         if (($ref_payout > 0) && ($CONFIG['allow_direct_pay'] == "N")) $locked = true;
77
78                         // Add points to account
79                         ADD_POINTS_REFSYSTEM($uid, $GIFT, false, "0", $locked, strtolower($CONFIG['birthday_mode']));
80
81                         // Remove entry from table
82                         $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_birthday WHERE userid=%d LIMIT 1",
83                          array($uid), __FILE__, __LINE__);
84
85                         // Update mediadata if version is 0.0.4 or newer
86                         if (GET_EXT_VERSION("mediadata") >= "0.0.4")
87                         {
88                                 // Update database
89                                 MEDIA_UPDATE_ENTRY(array("total_points"), "add", $GIFT);
90                         }
91
92                         // Transfer data to constants for the template
93                         define('__SALUT', TRANSLATE_SEX($salut));
94                         define('__SNAME', $sname);
95                         define('__FNAME', $fname);
96                         define('__GIFT' , $GIFT);
97
98                         // Load message from template
99                         define('__MSG', LOAD_TEMPLATE("birthday_msg", true));
100                 }
101                  else
102                 {
103                         // Unconfirmed / locked accounts cannot get points
104                         define('__MSG', BIRTHDAY_CANNOT_STATUS_1.TRANSLATE_STATUS($status).BIRTHDAY_CANNOT_STATUS_2);
105                 }
106         }
107          else
108         {
109                 // Cannot load data!
110                 define('__MSG', BIRTHDAY_CANNOT_LOAD_DATA);
111         }
112
113         // Free memory
114         SQL_FREERESULT($result);
115
116         // Set this because we have no module in URI
117         $GLOBALS['module'] = "birthday_confirm";
118
119         // Include header
120         include(PATH."inc/header.php");
121
122         // Load birthday header template (for your banners, e.g.?)
123         define('__BIRTHDAY_HEADER', LOAD_TEMPLATE("birthday_header", true));
124
125         // Load birthday footer template (for your banners, e.g.?)
126         define('__BIRTHDAY_FOOTER', LOAD_TEMPLATE("birthday_footer", true));
127
128         // Load final template and output it
129         LOAD_TEMPLATE("birthday_confirm");
130
131         // Include footer
132         include(PATH."inc/footer.php");
133 }
134  else
135 {
136         // You have to configure first!
137         LOAD_URL(URL."/install.php");
138 }
139 // Really all done here... ;-)
140 ?>