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