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