handling of boolean constants improved (not fully)
[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  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Load security stuff here (Oh, I hope this is not unsecure? Am I paranoia??? ;-) )
35 require_once("inc/libs/security_functions.php");
36
37 // Init "action" and "what"
38 global $what, $action, $startTime;
39 $GLOBALS['startTime'] = microtime(true);
40 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
41
42 // Set this because we have no module in URI
43 $GLOBALS['module'] = "show_bonus"; $CSS = 0;
44
45 // Load the required file(s)
46 require ("inc/config.php");
47
48 // List only rankings when script is installed
49 if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_installed')))
50 {
51         // Include header
52         include(PATH."inc/header.php");
53
54         if (($_GET['uid'] > 0) && ($_GET['d'] > 0) && (!empty($_GET['t'])))
55         {
56                 // Set row name
57                 $t = "";
58                 switch ($_GET['t'])
59                 {
60                 case "bonusid":
61                         $t = "bonus_id";
62                         break;
63
64                 case "mailid":
65                         $t = "mail_id";
66                         break;
67                 }
68                 if (!empty($t))
69                 {
70                         // Check for data
71                         $result = SQL_QUERY_ESC("SELECT DISTINCT d.sex, d.surname, d.family, b.level, b.points
72 FROM "._MYSQL_PREFIX."_user_data AS d
73 RIGHT JOIN "._MYSQL_PREFIX."_bonus_turbo AS b
74 ON d.userid=b.userid
75 WHERE d.status='CONFIRMED' AND d.userid=%d AND b.".$t."='%s' LIMIT 1",
76  array(bigintval($_GET['uid']), bigintval($_GET['d'])), __FILE__, __LINE__);
77                         if (SQL_NUMROWS($result) == 1)
78                         {
79                                 // Load data
80                                 list($sex, $sname, $fname, $level, $points) = SQL_FETCHROW($result);
81
82                                 // Prepare constants for the pre-template
83                                 define('__SALUT'    , TRANSLATE_SEX($sex));
84                                 define('__SNAME'    , $sname);
85                                 define('__FNAME'    , $fname);
86                                 define('__RANK'     , $level);
87                                 define('__POINTS'   , $points);
88                                 define('__MAILID'   , $_GET['d']);
89                                 define('__RANK_ROWS', BONUS_MAKE_RANK_ROWS(bigintval($_GET['d']), $t, bigintval($_GET['uid'])));
90
91                                 // Constant created within previous function which contains informations for current user's ranking position:
92                                 //   __YOUR_RANKING_LINE
93
94                                 // Load pre-template
95                                 define('__BONUS_MSG', LOAD_TEMPLATE("show_bonus_msg", true));
96                         }
97                          else
98                         {
99                                 // No data found
100                                 define('__BONUS_MSG', "<FONT class=\"guest_failed\">".BONUS_SHOW_NO_DATA."</FONT>");
101                         }
102
103                         // Free memory
104                         SQL_FREERESULT($result);
105                 }
106                  else
107                 {
108                         // Wrong type entered
109                         define('__BONUS_MSG', "<FONT class=\"guest_failed\">".BONUS_SHOW_WRONG_TYPE."</FONT>");
110                 }
111         }
112          else
113         {
114                 // Wrong call!
115                 define('__BONUS_MSG', "<FONT class=\"guest_failed\">".BONUS_SHOW_WRONG_CALL."</FONT>");
116         }
117
118         // Load send_bonus header template (for your banners, e.g.?)
119         define('__BONUS_HEADER', LOAD_TEMPLATE("show_bonus_header", true));
120
121         // Load show_bonus footer template (for your banners, e.g.?)
122         define('__BONUS_FOOTER', LOAD_TEMPLATE("show_bonus_footer", true));
123
124         // Total ranks who can win
125         define('__BONUS_TOTAL_RANKS', $_CONFIG['bonus_ranks']);
126
127         // Load final template
128         LOAD_TEMPLATE("show_bonus");
129
130         // Include footer
131         include(PATH."inc/footer.php");
132 }
133  else
134 {
135         // You have to configure first!
136         LOAD_URL("install.php");
137 }
138 // Really all done here... ;-)
139 ?>