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