List active/inactive extensions
[mailer.git] / 0.2.1 / inc / modules / admin / what-list_bonus.php
1 <?php\r
2 /************************************************************************\r
3  * MXChange v0.2.1                                    Start: 02/04/2005 *\r
4  * ================                             Last change: 11/19/2005 *\r
5  *                                                                      *\r
6  * -------------------------------------------------------------------- *\r
7  * File              : what-list_bonus.php                              *\r
8  * -------------------------------------------------------------------- *\r
9  * Short description : List members in active-rallye                    *\r
10  * -------------------------------------------------------------------- *\r
11  * Kurzbeschreibung  : Mitglieder in Aktiv-Rallye auflisten             *\r
12  * -------------------------------------------------------------------- *\r
13  *                                                                      *\r
14  * -------------------------------------------------------------------- *\r
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *\r
16  * For more information visit: http://www.mxchange.org                  *\r
17  *                                                                      *\r
18  * This program is free software; you can redistribute it and/or modify *\r
19  * it under the terms of the GNU General Public License as published by *\r
20  * the Free Software Foundation; either version 2 of the License, or    *\r
21  * (at your option) any later version.                                  *\r
22  *                                                                      *\r
23  * This program is distributed in the hope that it will be useful,      *\r
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
26  * GNU General Public License for more details.                         *\r
27  *                                                                      *\r
28  * You should have received a copy of the GNU General Public License    *\r
29  * along with this program; if not, write to the Free Software          *\r
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
31  * MA  02110-1301  USA                                                  *\r
32  ************************************************************************/\r
33 \r
34 // Some security stuff...\r
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!is_admin()))\r
36 {\r
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";\r
38         require($INC);\r
39 }\r
40 // Add description as navigation point\r
41 ADD_DESCR("admin", basename(__FILE__));\r
42 \r
43 if ($CONFIG['bonus_active'] == "Y")\r
44 {\r
45         // Shall I withdraw now?\r
46         if (isset($_POST['withdraw']))\r
47         {\r
48                 // Okay, let's prepare...\r
49                 $curr = date("m", time()) - 1;\r
50                 if (strlen($curr) == 1) $curr = "0".$curr;\r
51                 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_config SET last_bonus_month='%s' WHERE config='0' LIMIT 1",\r
52                  array($curr), __FILE__, __LINE__);\r
53                 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_WITHDRAW_PREPARED);\r
54                 OUTPUT_HTML("<BR>");\r
55         }\r
56 \r
57         if (GET_EXT_VERSION("bonus") >= "0.6.9")\r
58         {\r
59                 // Add more bonus points here\r
60                 $USE = "(0";\r
61                 if ($CONFIG['bonus_click_yn'] == "Y") $USE .= " + turbo_bonus";\r
62                 if ($CONFIG['bonus_login_yn'] == "Y") $USE .= " + login_bonus";\r
63                 if ($CONFIG['bonus_order_yn'] == "Y") $USE .= " + bonus_order";\r
64                 if ($CONFIG['bonus_stats_yn'] == "Y") $USE .= " + bonus_stats";\r
65                 if ($CONFIG['bonus_ref_yn']   == "Y") $USE .= " + bonus_ref";\r
66                 $USE .= ")";\r
67         }\r
68          else\r
69         {\r
70                 // Old version ???\r
71                 $USE = "turbo_bonus";\r
72         }\r
73 \r
74         // Autopurge installed?\r
75         $LAST = "%s"; $ONLINE = "";\r
76         if (EXT_IS_ACTIVE("autopurge"))\r
77         {\r
78                 // Use last online timestamp to keep inactive members away from here\r
79                 $LAST   = " AND last_online >= %s";\r
80                 $ONLINE = bigintval(time() - $CONFIG['ap_in_since']);\r
81         }\r
82 \r
83         // Check if at least one is in the active rallye\r
84         $result = SQL_QUERY_ESC("SELECT userid, email, sex, surname, family, ".$USE." AS active_bonus, last_online\r
85 FROM "._MYSQL_PREFIX."_user_data\r
86 WHERE status='CONFIRMED' AND ".$USE." > 0".$LAST."\r
87 ORDER BY active_bonus DESC, last_online DESC, userid",\r
88          array($ONLINE), __FILE__, __LINE__);\r
89 \r
90         if (SQL_NUMROWS($result) > 0)\r
91         {\r
92                 // List users\r
93                 $OUT = "";$SW = 2; $cnt = 1; $total = 0;\r
94                 while(list($uid, $email, $sex, $sname, $fname, $turbo, $last) = SQL_FETCHROW($result))\r
95                 {\r
96                         // Generate array fore the dynamic template\r
97                         $WIN1 = ""; $WIN2 = "";\r
98                         if ($cnt <= $CONFIG['bonus_ranks'])\r
99                         {\r
100                                 // Maybe he can win his active bonus?\r
101                                 $WIN1 = "<STRONG>";\r
102                                 $WIN2 = "</STRONG>";\r
103                         }\r
104                         $content = array(\r
105                                 'uid'   => $uid,\r
106                                 'email' => CREATE_EMAIL_LINK($email, "user_data"),\r
107                                 'salut' => TRANSLATE_SEX($sex),\r
108                                 'sname' => $sname,\r
109                                 'fname' => $fname,\r
110                                 'turbo' => TRANSLATE_COMMA($turbo),\r
111                                 'last'  => MAKE_DATETIME($last, "2"),\r
112                                 'sw'    => $SW,\r
113                                 'win1'  => $WIN1,\r
114                                 'win2'  => $WIN2,\r
115                                 'cnt'   => $cnt,\r
116                         );\r
117 \r
118                         // Load template and add it\r
119                         $OUT .= LOAD_TEMPLATE("admin_list_bonus_rows", true, $content);\r
120                         $SW = 3 - $SW; $cnt++; $total += $turbo;\r
121                 }\r
122                 define('__BONUS_ROWS', $OUT);\r
123                 define('__TOTAL', TRANSLATE_COMMA($total));\r
124 \r
125                 // Check if we need to display form or not with manuel withdraw\r
126                 if ($CONFIG['bonus_month'] == date("m", time()))\r
127                 {\r
128                         // Load form\r
129                         define('__BONUS_WITHDRAW_FORM', LOAD_TEMPLATE("admin_list_bonus_form", true));\r
130                 }\r
131                  else\r
132                 {\r
133                         // Display message "no manual withdraw possible"\r
134                         define('__BONUS_WITHDRAW_FORM', "<FONT class=\"admin_failed\">".ADMIN_BONUS_ALREADY_WITHDRAW."</FONT>");\r
135                 }\r
136 \r
137                 // Prepare constant for timemark\r
138                 define('__AUTOPURGE_TIMEOUT', MAKE_DATETIME(time() - $CONFIG['ap_in_since'], "2"));\r
139 \r
140                 // Load final template\r
141                 LOAD_TEMPLATE("admin_list_bonus");\r
142         }\r
143          else\r
144         {\r
145                 // No one has become an "activity bonus"...\r
146                 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_NO_ACTIVE_RALLYE);\r
147         }\r
148 }\r
149  else\r
150 {\r
151         // Aktive-Rallye not activated\r
152         LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_RALLYE_DEACTIVATED);\r
153 }\r
154 \r
155 //\r
156 ?>\r