Fixed logfile writing in installation phase, .revision is now ignored
[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:: 856                                                    $ *
14  * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. Mär 2009)              $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author:: stelzi                                                   $ *
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 (Oh, I hope this is not unsecure? Am I paranoia??? ;-) )
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.php");
53
54 // Is the "bonus" extension active?
55 REDIRECT_ON_UNINSTALLED_EXTENSION("bonus");
56
57 // List only rankings when script is installed
58 if (isInstalled()) {
59         // Include header
60         LOAD_INC("inc/header.php");
61
62         if ((REQUEST_GET('uid') > 0) && (REQUEST_GET('d') > 0) && (REQUEST_ISSET_GET(('t')))) {
63                 // Set row name
64                 $t = "";
65                 switch (REQUEST_GET('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                                 DEBUG_LOG(__FILE__, __LINE__, sprintf("Invalid type %s detected.", REQUEST_GET('t')));
76                                 break;
77                 } // END - switch
78
79                 // Valid type?
80                 if (!empty($t)) {
81                         // Check for data
82                         $result = SQL_QUERY_ESC("SELECT DISTINCT d.gender, d.surname, d.family, b.level, b.points
83 FROM `{!_MYSQL_PREFIX!}_user_data` AS d
84 RIGHT JOIN `{!_MYSQL_PREFIX!}_bonus_turbo` AS b
85 ON d.userid=b.userid
86 WHERE d.`status`='CONFIRMED' AND d.userid=%s AND b.%s=%s
87 LIMIT 1",
88                                 array(bigintval(REQUEST_GET('uid')), $t, bigintval(REQUEST_GET('d'))), __FILE__, __LINE__);
89
90                         // Entry found?
91                         if (SQL_NUMROWS($result) == 1) {
92                                 // Load data
93                                 $content = SQL_FETCHARRAY($result);
94
95                                 // Prepare constants for the pre-template
96                                 define('__GENDER'   , TRANSLATE_GENDER($content['gender']));
97                                 define('__SNAME'    , $content['surname']);
98                                 define('__FNAME'    , $content['family']);
99                                 define('__RANK'     , BIGINTVAL($content['level']));
100                                 define('__POINTS'   , TRANSLATE_COMMA($content['points']));
101                                 define('__MAILID'   , bigintval(REQUEST_GET('d')));
102                                 define('__RANK_ROWS', BONUS_MAKE_RANK_ROWS(bigintval(REQUEST_GET('d')), $t, bigintval(REQUEST_GET('uid'))));
103
104                                 // Constant created within previous function which contains informations for current user's ranking position:
105                                 //   __YOUR_RANKING_LINE
106
107                                 // Load pre-template
108                                 define('__BONUS_MSG', LOAD_TEMPLATE("show_bonus_msg", true));
109                         } else {
110                                 // No data found
111                                 define('__BONUS_MSG', "<span class=\"guest_failed\">{--BONUS_SHOW_NO_DATA--}</span>");
112                         }
113
114                         // Free memory
115                         SQL_FREERESULT($result);
116                 } else {
117                         // Wrong type entered
118                         define('__BONUS_MSG', "<span class=\"guest_failed\">{--BONUS_SHOW_WRONG_TYPE--}</span>");
119                 }
120         } else {
121                 // Wrong call!
122                 define('__BONUS_MSG', "<span class=\"guest_failed\">{--BONUS_SHOW_WRONG_CALL--}</span>");
123         }
124
125         // Load send_bonus header template (for your banners, e.g.?)
126         define('__BONUS_HEADER', LOAD_TEMPLATE("show_bonus_header", true));
127
128         // Load show_bonus footer template (for your banners, e.g.?)
129         define('__BONUS_FOOTER', LOAD_TEMPLATE("show_bonus_footer", true));
130
131         // Total ranks who can win
132         define('__BONUS_TOTAL_RANKS', getConfig('bonus_ranks'));
133
134         // Load final template
135         LOAD_TEMPLATE("show_bonus");
136
137         // Include footer
138         LOAD_INC("inc/footer.php");
139 } else {
140         // You have to install first!
141         LOAD_URL("install.php");
142 }
143
144 // Really all done here... ;-)
145 shutdown();
146
147 //
148 ?>