2375215afcf0dd47b15f0965eb15fb95ff5c8dc0
[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;
39 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
40
41 // Set this because we have no module in URI
42 $GLOBALS['module'] = "show_bonus"; $CSS = 0;
43
44 // Load the required file(s)
45 require ("inc/config.php");
46
47 // List only rankings when script is installed
48 if (defined('mxchange_installed') && (mxchange_installed))
49 {
50         // Include header
51         include(PATH."inc/header.php");
52
53         if (($_GET['uid'] > 0) && ($_GET['d'] > 0) && (!empty($_GET['t'])))
54         {
55                 // Set row name
56                 $t = "";
57                 switch ($_GET['t'])
58                 {
59                 case "bonusid":
60                         $t = "bonus_id";
61                         break;
62
63                 case "mailid":
64                         $t = "mail_id";
65                         break;
66                 }
67                 if (!empty($t))
68                 {
69                         // Check for data
70                         $result = SQL_QUERY_ESC("SELECT DISTINCT d.sex, d.surname, d.family, b.level, b.points
71 FROM "._MYSQL_PREFIX."_user_data AS d
72 RIGHT JOIN "._MYSQL_PREFIX."_bonus_turbo AS b
73 ON d.userid=b.userid
74 WHERE d.status='CONFIRMED' AND d.userid=%d AND b.".$t."='%s' LIMIT 1",
75  array(bigintval($_GET['uid']), bigintval($_GET['d'])), __FILE__, __LINE__);
76                         if (SQL_NUMROWS($result) == 1)
77                         {
78                                 // Load data
79                                 list($sex, $sname, $fname, $level, $points) = SQL_FETCHROW($result);
80
81                                 // Prepare constants for the pre-template
82                                 define('__SALUT'    , TRANSLATE_SEX($sex));
83                                 define('__SNAME'    , $sname);
84                                 define('__FNAME'    , $fname);
85                                 define('__RANK'     , $level);
86                                 define('__POINTS'   , $points);
87                                 define('__MAILID'   , $_GET['d']);
88                                 define('__RANK_ROWS', BONUS_MAKE_RANK_ROWS(bigintval($_GET['d']), $t, bigintval($_GET['uid'])));
89
90                                 // Constant created within previous function which contains informations for current user's ranking position:
91                                 //   __YOUR_RANKING_LINE
92
93                                 // Load pre-template
94                                 define('__BONUS_MSG', LOAD_TEMPLATE("show_bonus_msg", true));
95                         }
96                          else
97                         {
98                                 // No data found
99                                 define('__BONUS_MSG', "<FONT class=\"guest_failed\">".BONUS_SHOW_NO_DATA."</FONT>");
100                         }
101
102                         // Free memory
103                         SQL_FREERESULT($result);
104                 }
105                  else
106                 {
107                         // Wrong type entered
108                         define('__BONUS_MSG', "<FONT class=\"guest_failed\">".BONUS_SHOW_WRONG_TYPE."</FONT>");
109                 }
110         }
111          else
112         {
113                 // Wrong call!
114                 define('__BONUS_MSG', "<FONT class=\"guest_failed\">".BONUS_SHOW_WRONG_CALL."</FONT>");
115         }
116
117         // Load send_bonus header template (for your banners, e.g.?)
118         define('__BONUS_HEADER', LOAD_TEMPLATE("show_bonus_header", true));
119
120         // Load show_bonus footer template (for your banners, e.g.?)
121         define('__BONUS_FOOTER', LOAD_TEMPLATE("show_bonus_footer", true));
122
123         // Total ranks who can win
124         define('__BONUS_TOTAL_RANKS', $CONFIG['bonus_ranks']);
125
126         // Load final template
127         LOAD_TEMPLATE("show_bonus");
128
129         // Include footer
130         include(PATH."inc/footer.php");
131 }
132  else
133 {
134         // You have to configure first!
135         LOAD_URL(URL."/install.php");
136 }
137 // Really all done here... ;-)
138 ?>