Fix for the fix... :(
[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 - 2008 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 "action" and "what"
43 $GLOBALS['startTime'] = microtime(true);
44 $GLOBALS['what'] = '';
45 $GLOBALS['action'] = '';
46
47 // Set this because we have no module in URI
48 $GLOBALS['module'] = 'show_bonus';
49 $GLOBALS['output_mode'] = 0;
50
51 // Load the required file(s)
52 require('inc/config-global.php');
53
54 // Is the 'bonus' extension active?
55 redirectOnUninstalledExtension('bonus');
56
57 // List only rankings when script is installed
58 if (!isInstalled()) {
59         // You have to install first!
60         redirectToUrl('install.php');
61 } // END - if
62
63 // Include header
64 loadIncludeOnce('inc/header.php');
65
66 if ((REQUEST_GET('uid') > 0) && (REQUEST_GET('d') > 0) && (REQUEST_ISSET_GET(('t')))) {
67         // Set row name
68         $t = '';
69         switch (REQUEST_GET('t')) {
70                 case 'bonusid': // Bonus mail
71                         $t = 'bonus_id';
72                         break;
73
74                 case 'mailid': // Regular member mail
75                         $t = 'mail_id';
76                         break;
77
78                 default: // Invalid type
79                         DEBUG_LOG(__FILE__, __LINE__, sprintf("Invalid type %s detected.", REQUEST_GET('t')));
80                         break;
81         } // END - switch
82
83         // Valid type?
84         if (!empty($t)) {
85                 // Check for data
86                 $result = SQL_QUERY_ESC("SELECT DISTINCT d.gender, d.surname, d.family, b.level, b.points
87 FROM `{!_MYSQL_PREFIX!}_user_data` AS d
88 RIGHT JOIN `{!_MYSQL_PREFIX!}_bonus_turbo` AS b
89 ON d.userid=b.userid
90 WHERE d.`status`='CONFIRMED' AND d.userid=%s AND b.%s=%s
91 LIMIT 1",
92                 array(bigintval(REQUEST_GET('uid')), $t, bigintval(REQUEST_GET('d'))), __FILE__, __LINE__);
93
94                 // Entry found?
95                 if (SQL_NUMROWS($result) == 1) {
96                         // Load data
97                         $content = SQL_FETCHARRAY($result);
98
99                         // Prepare constants for the pre-template
100                         $content['gender'] = translateGender($content['gender']);
101                         $content['points'] = translateComma($content['points']);
102                         $content['mailid'] = bigintval(REQUEST_GET('d'));
103                         $content['rows']   = BONUS_MAKE_RANK_ROWS(bigintval(REQUEST_GET('d')), $t, bigintval(REQUEST_GET('uid')));
104
105                         // Constant created within previous function which contains informations for current user's ranking position:
106                         // @TODO Rewrite this constant
107                         //   __YOUR_RANKING_LINE
108
109                         // Load pre-template
110                         $content['msg'] = LOAD_TEMPLATE('show_bonus_msg', true, $content);
111                 } else {
112                         // No data found
113                         $content['msg'] = "<span class=\"guest_failed\">{--BONUS_SHOW_NO_DATA--}</span>";
114                 }
115
116                 // Free memory
117                 SQL_FREERESULT($result);
118         } else {
119                 // Wrong type entered
120                 $content['msg'] = "<span class=\"guest_failed\">{--BONUS_SHOW_WRONG_TYPE--}</span>";
121         }
122 } else {
123         // Wrong call!
124         $content['msg'] = "<span class=\"guest_failed\">{--BONUS_SHOW_WRONG_CALL--}</span>";
125 }
126
127 // Load send_bonus header template (for your banners, e.g.?)
128 $content['header'] = LOAD_TEMPLATE('show_bonus_header', true);
129
130 // Load show_bonus footer template (for your banners, e.g.?)
131 $content['footer'] = LOAD_TEMPLATE('show_bonus_footer', true);
132
133 // Total ranks who can win
134 $content['total_ranks'] = getConfig('bonus_ranks');
135
136 // Load final template
137 LOAD_TEMPLATE('show_bonus', false, $content);
138
139 // Include footer
140 loadIncludeOnce('inc/footer.php');
141
142 // [EOF]
143 ?>