Rewrites/fixes for handling config entries in SQLs
[mailer.git] / show_bonus.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 11/13/2004 *
4  * ===================                          Last change: 11/14/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : show_bonus.php                                   *
8  * -------------------------------------------------------------------- *
9  * Short description : Show ranking list for turbo-bonus                *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Rankliste fuer Turbo-Bonus anzeigen              *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Load security stuff here
41 require('inc/libs/security_functions.php');
42
43 // Init start time
44 $GLOBALS['startTime'] = microtime(true);
45
46 // Set this because we have no module in URI
47 $GLOBALS['module'] = 'show_bonus';
48 $GLOBALS['output_mode'] = '0';
49
50 // Load the required file(s)
51 require('inc/config-global.php');
52
53 // Set content type
54 setContentType('text/html');
55
56 // Is the 'bonus' extension active?
57 redirectOnUninstalledExtension('bonus');
58
59 // Include header
60 loadIncludeOnce('inc/header.php');
61
62 if ((getRequestParameter('userid') > 0) && (getRequestParameter('d') > 0) && (isGetRequestParameterSet('t'))) {
63         // Set row name
64         $t = '';
65         switch (getRequestParameter('t')) {
66                 case 'bonusid': // Bonus mail
67                         $t = 'bonus_id';
68                         break;
69
70                 case 'mailid': // Regular member mail
71                         $t = 'mail_id';
72                         break;
73
74                 default: // Invalid type
75                         logDebugMessage(__FILE__, __LINE__, sprintf("Invalid type %s detected.", getRequestParameter('t')));
76                         break;
77         } // END - switch
78
79         // Valid type?
80         if (!empty($t)) {
81                 // Check for data
82                 $result = SQL_QUERY_ESC("SELECT d.gender, d.surname, d.family, b.level, b.points
83 FROM
84         `{?_MYSQL_PREFIX?}_user_data` AS d
85 RIGHT JOIN
86         `{?_MYSQL_PREFIX?}_bonus_turbo` AS b
87 ON
88         d.userid=b.userid
89 WHERE
90         d.`status`='CONFIRMED' AND d.userid=%s AND b.%s=%s
91 LIMIT 1",
92                         array(
93                                 bigintval(getRequestParameter('userid')),
94                                 $t,
95                                 bigintval(getRequestParameter('d'))
96                         ), __FILE__, __LINE__);
97
98                 // Entry found?
99                 if (SQL_NUMROWS($result) == 1) {
100                         // Load data
101                         $content = SQL_FETCHARRAY($result);
102
103                         // Prepare constants for the pre-template
104                         $content['gender'] = translateGender($content['gender']);
105                         $content['points'] = translateComma($content['points']);
106                         $content['mailid'] = bigintval(getRequestParameter('d'));
107                         $content['rows']   = addBonusRanks(bigintval(getRequestParameter('d')), $t, bigintval(getRequestParameter('userid')));
108
109                         // Get some prepared content
110                         $content = merge_array($content, $GLOBALS['ranking_content']);
111
112                         // Load pre-template
113                         $content['message'] = loadTemplate('show_bonus_msg', true, $content);
114                 } else {
115                         // No data found
116                         $content['message'] = '<span class="guest_failed">{--BONUS_SHOW_NO_DATA--}</span>';
117                 }
118
119                 // Free memory
120                 SQL_FREERESULT($result);
121         } else {
122                 // Wrong type entered
123                 $content['message'] = '<span class="guest_failed">{--BONUS_SHOW_WRONG_TYPE--}</span>';
124         }
125 } else {
126         // Wrong call!
127         $content['message'] = '<span class="guest_failed">{--BONUS_SHOW_WRONG_CALL--}</span>';
128 }
129
130 // Load send_bonus header template (for your banners, e.g.?)
131 $content['header'] = loadTemplate('show_bonus_header', true);
132
133 // Load show_bonus footer template (for your banners, e.g.?)
134 $content['footer'] = loadTemplate('show_bonus_footer', true);
135
136 // Load final template
137 loadTemplate('show_bonus', false, $content);
138
139 // Include footer
140 loadIncludeOnce('inc/footer.php');
141
142 // [EOF]
143 ?>