A *lot* more code-cleanups, errors in CSS fixed (missing brackets) and frameset suppo...
[mailer.git] / inc / modules / admin / what-list_bonus.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 02/04/2005 *
4  * ================                             Last change: 11/19/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_bonus.php                              *
8  * -------------------------------------------------------------------- *
9  * Short description : List members in active-rallye                    *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Mitglieder in Aktiv-Rallye auflisten             *
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 // Some security stuff...
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!is_admin()))
36 {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40 // Add description as navigation point
41 ADD_DESCR("admin", basename(__FILE__));
42
43 if ($CONFIG['bonus_active'] == 'Y')
44 {
45         // Shall I withdraw now?
46         if (isset($_POST['withdraw']))
47         {
48                 // Okay, let's prepare...
49                 $curr = date("m", time()) - 1;
50                 if (strlen($curr) == 1) $curr = "0".$curr;
51                 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_config SET last_bonus_month='%s' WHERE config='0' LIMIT 1",
52                  array($curr), __FILE__, __LINE__);
53                 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_WITHDRAW_PREPARED);
54                 OUTPUT_HTML("<br />");
55         }
56
57         if (GET_EXT_VERSION("bonus") >= "0.6.9")
58         {
59                 // Add more bonus points here
60                 $USE = "(0";
61                 if ($CONFIG['bonus_click_yn'] == 'Y') $USE .= " + turbo_bonus";
62                 if ($CONFIG['bonus_login_yn'] == 'Y') $USE .= " + login_bonus";
63                 if ($CONFIG['bonus_order_yn'] == 'Y') $USE .= " + bonus_order";
64                 if ($CONFIG['bonus_stats_yn'] == 'Y') $USE .= " + bonus_stats";
65                 if ($CONFIG['bonus_ref_yn']   == 'Y') $USE .= " + bonus_ref";
66                 $USE .= ")";
67         }
68          else
69         {
70                 // Old version ???
71                 $USE = "turbo_bonus";
72         }
73
74         // Autopurge installed?
75         $LAST = "%s"; $ONLINE = "";
76         if (EXT_IS_ACTIVE("autopurge"))
77         {
78                 // Use last online timestamp to keep inactive members away from here
79                 $LAST   = " AND last_online >= %s";
80                 $ONLINE = bigintval(time() - $CONFIG['ap_in_since']);
81         }
82
83         // Check if at least one is in the active rallye
84         $result = SQL_QUERY_ESC("SELECT userid, email, sex, surname, family, ".$USE." AS active_bonus, last_online
85 FROM "._MYSQL_PREFIX."_user_data
86 WHERE status='CONFIRMED' AND ".$USE." > 0".$LAST."
87 ORDER BY active_bonus DESC, last_online DESC, userid",
88          array($ONLINE), __FILE__, __LINE__);
89
90         if (SQL_NUMROWS($result) > 0)
91         {
92                 // List users
93                 $OUT = "";$SW = 2; $cnt = 1; $total = 0;
94                 while(list($uid, $email, $sex, $sname, $fname, $turbo, $last) = SQL_FETCHROW($result))
95                 {
96                         // Generate array fore the dynamic template
97                         $WIN1 = ""; $WIN2 = "";
98                         if ($cnt <= $CONFIG['bonus_ranks'])
99                         {
100                                 // Maybe he can win his active bonus?
101                                 $WIN1 = "<STRONG>";
102                                 $WIN2 = "</STRONG>";
103                         }
104                         $content = array(
105                                 'uid'   => $uid,
106                                 'email' => CREATE_EMAIL_LINK($email, "user_data"),
107                                 'salut' => TRANSLATE_SEX($sex),
108                                 'sname' => $sname,
109                                 'fname' => $fname,
110                                 'turbo' => TRANSLATE_COMMA($turbo),
111                                 'last'  => MAKE_DATETIME($last, "2"),
112                                 'sw'    => $SW,
113                                 'win1'  => $WIN1,
114                                 'win2'  => $WIN2,
115                                 'cnt'   => $cnt,
116                         );
117
118                         // Load template and add it
119                         $OUT .= LOAD_TEMPLATE("admin_list_bonus_rows", true, $content);
120                         $SW = 3 - $SW; $cnt++; $total += $turbo;
121                 }
122                 define('__BONUS_ROWS', $OUT);
123                 define('__TOTAL', TRANSLATE_COMMA($total));
124
125                 // Check if we need to display form or not with manuel withdraw
126                 if ($CONFIG['bonus_month'] == date("m", time()))
127                 {
128                         // Load form
129                         define('__BONUS_WITHDRAW_FORM', LOAD_TEMPLATE("admin_list_bonus_form", true));
130                 }
131                  else
132                 {
133                         // Display message "no manual withdraw possible"
134                         define('__BONUS_WITHDRAW_FORM', "<FONT class=\"admin_failed\">".ADMIN_BONUS_ALREADY_WITHDRAW."</FONT>");
135                 }
136
137                 // Prepare constant for timemark
138                 define('__AUTOPURGE_TIMEOUT', MAKE_DATETIME(time() - $CONFIG['ap_in_since'], "2"));
139
140                 // Load final template
141                 LOAD_TEMPLATE("admin_list_bonus");
142         }
143          else
144         {
145                 // No one has become an "activity bonus"...
146                 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_NO_ACTIVE_RALLYE);
147         }
148 }
149  else
150 {
151         // Aktive-Rallye not activated
152         LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_RALLYE_DEACTIVATED);
153 }
154
155 //
156 ?>