4fd94922c491d5e233a37c01c63c498981d6e4ef
[mailer.git] / inc / modules / admin / what-config_bonus.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 08/31/2004 *
4  * ================                             Last change: 11/14/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-config_bonus.php                            *
8  * -------------------------------------------------------------------- *
9  * Short description : Configure "turbo-click-bonus"                    *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Einstellen der Turbo-Klick-Verguetungen          *
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 (isset($_POST['ok']))
44 {
45         // Replace german decimal commas to computer decimal dots
46         $_POST['login_bonus']         = str_replace(",", ".", $_POST['login_bonus']        );
47         $_POST['turbo_bonus']         = str_replace(",", ".", $_POST['turbo_bonus']        );
48         $_POST['bonus_ref']           = str_replace(",", ".", $_POST['bonus_ref']          );
49         $_POST['bonus_order']         = str_replace(",", ".", $_POST['bonus_order']        );
50         $_POST['bonus_notify_points'] = str_replace(",", ".", $_POST['bonus_notify_points']);
51
52         // Generate string for saving ranks
53         $_POST['turbo_rates'] = ""; $RATES = array();
54         foreach ($_POST['rate'] as $rate)
55         {
56                 $rate = trim(str_replace(",", ".", $rate));
57                 if (isset($rate)) $RATES[] = $rate;
58         }
59         $_POST['turbo_rates'] = trim(implode(";", $RATES));
60         unset($_POST['rate']);
61
62         // Automatically calculate bonus points for ranks 2 and 3 when not set
63         if (empty($_POST['turbo_rates'])) $_POST['turbo_rates'] = "".round($CONFIG['turbo_bonus'] / 2).";".round($CONFIG['turbo_bonus'] / 4)."";
64
65         // Save data
66         ADMIN_SAVE_SETTINGS($_POST, "_config", "config='0'");
67
68         // Remember new settings
69         $CONFIG['bonus_active']    = $_POST['bonus_active'];
70         $CONFIG['bonus_en_notify'] = $_POST['bonus_en_notify'];
71         $CONFIG['bonus_di_notify'] = $_POST['bonus_di_notify'];
72
73         // Include sending out mails
74         if ((($CONFIG['bonus_active'] == "Y") && ($CONFIG['bonus_en_notify'] == "Y")) || (($CONFIG['bonus_active'] == "N") && ($CONFIG['bonus_di_notify'] == "Y")))
75         {
76                 include(PATH."inc/mails/bonus_mails.php");
77         }
78 }
79  else
80 {
81         // Prepare contants for the template
82         define('__LOGIN_VALUE' , TRANSLATE_COMMA($CONFIG['login_bonus']        , false));
83         define('__TURBO_VALUE' , TRANSLATE_COMMA($CONFIG['turbo_bonus']        , false));
84         define('__ORDER_VALUE' , TRANSLATE_COMMA($CONFIG['bonus_order']        , false));
85         define('__REF_VALUE'   , TRANSLATE_COMMA($CONFIG['bonus_ref']          , false));
86         define('__STATS_VALUE' , TRANSLATE_COMMA($CONFIG['bonus_stats']        , false));
87         define('__NOTIFY_VALUE', TRANSLATE_COMMA($CONFIG['bonus_notify_points'], false));
88         define('__TRANKS_VALUE', $CONFIG['bonus_ranks']);
89         define('__TLINES_VALUE', $CONFIG['bonus_lines']);
90
91         // Transfer options to template __MEMBER_SELECTION
92         ADD_MEMBER_SELECTION_BOX(false, true, true, $CONFIG['bonus_uid']);
93
94         // Initialize array for the points list
95         $RANKS = explode(";", $CONFIG['bonus_rates']);
96
97         // Automatically calculate bonus points for ranks 2 and 3 when not set
98         if (empty($CONFIG['bonus_rates'])) $RANKS = array(round($CONFIG['turbo_bonus'] / 2), round($CONFIG['turbo_bonus'] / 4));
99
100         // Generate list
101         $OUT = "<OL start=\"2\">\n";
102         foreach ($RANKS as $k=>$rate)
103         {
104                 if (!empty($rate))
105                 {
106                         // Print only when something is in
107                         $OUT .= "  <LI><INPUT type=\"text\" name=\"rate[".($k + 2)."]\" class=\"admin_normal\" size=\"4\" maxlength=\"7\" value=\"".$rate."\">&nbsp;<FONT class=\"admin_notes\">(".POINTS.")</FONT?</LI>\n";
108                 }
109         }
110         for ($i = 3; $i < 8; $i++)
111         {
112                 $OUT .= "  <LI><INPUT type=\"text\" name=\"rate[".($k + $i)."]\" class=\"admin_normal\" size=\"4\" maxlength=\"7\">&nbsp;<FONT class=\"admin_notes\">(".POINTS.")</FONT?</LI>\n";
113         }
114         $OUT .= "</OL>\n";
115         define('__TRATES_LIST', $OUT);
116
117         define('__LOGIN_TIMEOUT_SELECTION', CREATE_TIME_SELECTIONS($CONFIG['login_timeout']    , "login_timeout"    , "WDh"));
118         define('__BONUS_TIMEOUT_SELECTION', CREATE_TIME_SELECTIONS($CONFIG['bonus_timeout']    , "bonus_timeout"    , "WDh"));
119         define('__WAIT_SELECTION'         , CREATE_TIME_SELECTIONS($CONFIG['bonus_notify_wait'], "bonus_notify_wait", "ms" ));
120
121         // Activate / Deactivate bonus active rallye (Y/N)
122         switch ($CONFIG['bonus_active'])
123         {
124         case "Y":
125                 define('__BONUS_ACTIVE_Y', " checked");
126                 define('__BONUS_ACTIVE_N', "");
127                 break;
128
129         case "N":
130                 define('__BONUS_ACTIVE_Y', "");
131                 define('__BONUS_ACTIVE_N', " checked");
132                 break;
133         }
134         // Other bonus to de-/activate
135         switch ($CONFIG['bonus_login_yn'])
136         {
137         case "Y":
138                 define('__BONUS_LOGIN_Y', " checked");
139                 define('__BONUS_LOGIN_N', "");
140                 break;
141
142         case "N":
143                 define('__BONUS_LOGIN_Y', "");
144                 define('__BONUS_LOGIN_N', " checked");
145                 break;
146         }
147         switch ($CONFIG['bonus_stats_yn'])
148         {
149         case "Y":
150                 define('__BONUS_STATS_Y', " checked");
151                 define('__BONUS_STATS_N', "");
152                 break;
153
154         case "N":
155                 define('__BONUS_STATS_Y', "");
156                 define('__BONUS_STATS_N', " checked");
157                 break;
158         }
159         switch ($CONFIG['bonus_order_yn'])
160         {
161         case "Y":
162                 define('__BONUS_ORDER_Y', " checked");
163                 define('__BONUS_ORDER_N', "");
164                 break;
165
166         case "N":
167                 define('__BONUS_ORDER_Y', "");
168                 define('__BONUS_ORDER_N', " checked");
169                 break;
170         }
171         switch ($CONFIG['bonus_ref_yn'])
172         {
173         case "Y":
174                 define('__BONUS_REF_Y', " checked");
175                 define('__BONUS_REF_N', "");
176                 break;
177
178         case "N":
179                 define('__BONUS_REF_Y', "");
180                 define('__BONUS_REF_N', " checked");
181                 break;
182         }
183         switch ($CONFIG['bonus_click_yn'])
184         {
185         case "Y":
186                 define('__BONUS_CLICK_Y', " checked");
187                 define('__BONUS_CLICK_N', "");
188                 break;
189
190         case "N":
191                 define('__BONUS_CLICK_Y', "");
192                 define('__BONUS_CLICK_N', " checked");
193                 break;
194         }
195         switch ($CONFIG['bonus_en_notify'])
196         {
197         case "Y":
198                 define('__BONUS_EN_NOTIFY_Y', " checked");
199                 define('__BONUS_EN_NOTIFY_N', "");
200                 break;
201
202         case "N":
203                 define('__BONUS_EN_NOTIFY_Y', "");
204                 define('__BONUS_EN_NOTIFY_N', " checked");
205                 break;
206         }
207         switch ($CONFIG['bonus_di_notify'])
208         {
209         case "Y":
210                 define('__BONUS_DI_NOTIFY_Y', " checked");
211                 define('__BONUS_DI_NOTIFY_N', "");
212                 break;
213
214         case "N":
215                 define('__BONUS_DI_NOTIFY_Y', "");
216                 define('__BONUS_DI_NOTIFY_N', " checked");
217                 break;
218         }
219         switch ($CONFIG['bonus_new_mem_notify'])
220         {
221         case "Y":
222                 define('__BONUS_NEW_MEMBER_NOTIFY_Y', " checked");
223                 define('__BONUS_NEW_MEMBER_NOTIFY_N', "");
224                 break;
225
226         case "N":
227                 define('__BONUS_NEW_MEMBER_NOTIFY_Y', "");
228                 define('__BONUS_NEW_MEMBER_NOTIFY_N', " checked");
229                 break;
230         }
231         switch ($CONFIG['bonus_include_own'])
232         {
233         case "Y":
234                 define('__BONUS_INCLUDE_OWN_Y', " checked");
235                 define('__BONUS_INCLUDE_OWN_N', "");
236                 break;
237
238         case "N":
239                 define('__BONUS_INCLUDE_OWN_Y', "");
240                 define('__BONUS_INCLUDE_OWN_N', " checked");
241                 break;
242         }
243
244         // Load final template
245         LOAD_TEMPLATE("admin_config_bonus", false);
246 }
247 //
248 ?>