Security line in all includes changed
[mailer.git] / inc / modules / admin / what-list_beg.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/22/2005 *
4  * ================                             Last change: 10/22/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-list_beg.php                                *
8  * -------------------------------------------------------------------- *
9  * Short description : List members in begging-rallye                   *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Mitglieder in Bettel-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 ((!defined('__SECURITY')) || (!is_admin())) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39 // Add description as navigation point
40 ADD_DESCR("admin", basename(__FILE__));
41
42 if ($_CONFIG['beg_rallye'] == "Y")
43 {
44         // Shall I withdraw now?
45         if (isset($_POST['withdraw']))
46         {
47                 // Okay, let's prepare...
48                 $curr = date("m", time()) - 1;
49                 if (strlen($curr) == 1) $curr = "0".$curr;
50                 UPDATE_CONFIG("last_month", $curr);
51                 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BEG_WITHDRAW_PREPARED);
52                 OUTPUT_HTML("<br />");
53         }
54
55         // Autopurge installed?
56         $LAST = "%s"; $ONLINE = "";
57         if (EXT_IS_ACTIVE("autopurge"))
58         {
59                 // Use last online timestamp to keep inactive members away from here
60                 $LAST   = " AND last_online >= %s";
61                 $ONLINE = bigintval(time() - $_CONFIG['ap_in_since']);
62         }
63
64         // Check if at least one is in the active rallye
65         $result = SQL_QUERY_ESC("SELECT userid, email, gender, surname, family, beg_points, last_online
66 FROM "._MYSQL_PREFIX."_user_data
67 WHERE status='CONFIRMED' AND beg_points > 0".$LAST."
68 ORDER BY beg_points DESC, last_online DESC, userid",
69          array($ONLINE), __FILE__, __LINE__);
70
71         if (SQL_NUMROWS($result) > 0)
72         {
73                 // List users
74                 $OUT = "";$SW = 2; $cnt = 1; $total = 0;
75                 while(list($uid, $email, $gender, $sname, $fname, $turbo, $last) = SQL_FETCHROW($result))
76                 {
77                         // Generate array fore the dynamic template
78                         $WIN1 = ""; $WIN2 = "";
79                         if ($cnt <= $_CONFIG['beg_ranks'])
80                         {
81                                 // Maybe he can win his active beg?
82                                 $WIN1 = "<STRONG>";
83                                 $WIN2 = "</STRONG>";
84                         }
85                         $content = array(
86                                 'uid'    => $uid,
87                                 'email'  => CREATE_EMAIL_LINK($email, "user_data"),
88                                 'gender' => TRANSLATE_GENDER($gender),
89                                 'sname'  => $sname,
90                                 'fname'  => $fname,
91                                 'turbo'  => TRANSLATE_COMMA($turbo),
92                                 'last'   => MAKE_DATETIME($last, "2"),
93                                 'sw'     => $SW,
94                                 'win1'   => $WIN1,
95                                 'win2'   => $WIN2,
96                                 'cnt'    => $cnt,
97                         );
98
99                         // Load template and add it
100                         $OUT .= LOAD_TEMPLATE("admin_list_beg_rows", true, $content);
101                         $SW = 3 - $SW; $cnt++; $total += $turbo;
102                 }
103                 define('__BEG_ROWS', $OUT);
104                 define('__TOTAL', TRANSLATE_COMMA($total));
105
106                 // Check if we need to display form or not with manuel withdraw
107                 if ($_CONFIG['last_month'] == date("m", time()))
108                 {
109                         // Load form
110                         define('__BEG_WITHDRAW_FORM', LOAD_TEMPLATE("admin_list_beg_form", true));
111                 }
112                  else
113                 {
114                         // Display message "no manual withdraw possible"
115                         define('__BEG_WITHDRAW_FORM', "<FONT class=\"admin_failed\">".ADMIN_BEG_ALREADY_WITHDRAW."</FONT>");
116                 }
117
118                 // Prepare constant for timemark
119                 define('__AUTOPURGE_TIMEOUT', MAKE_DATETIME(time() - $_CONFIG['ap_in_since'], "2"));
120
121                 // Load final template
122                 LOAD_TEMPLATE("admin_list_beg");
123         }
124          else
125         {
126                 // No one has joined the begging rallye...
127                 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BEG_NO_RALLYE);
128         }
129 }
130  else
131 {
132         // Rallye deactivated
133         LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BEG_RALLYE_DEACTIVATED);
134 }
135
136 //
137 ?>