2 /************************************************************************
3 * MXChange v0.2.1 Start: 04/11/2004 *
4 * ================ Last change: 08/12/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-config_payouts.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Configure payout types *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Auszahlungensarten editieren *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
32 ************************************************************************/
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // Add description as navigation point
41 ADD_DESCR("admin", basename(__FILE__));
43 if (!empty($_POST['rate'])) $_POST['rate'] = str_replace(",", ".", $_POST['rate']);
45 if ((isset($_POST['add'])) && (!empty($_POST['title'])) && ($_POST['rate'] > 0))
47 // Add new payout type
48 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_payout_types WHERE type='%s' LIMIT 1",
49 array($_POST['title']), __FILE__, __LINE__);
50 if (SQL_NUMROWS($result) == 0)
53 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_payout_types
54 (type, rate, min_points, from_account, from_pass, engine_url, engine_ret_ok, engine_ret_failed, pass_enc, allow_url)
55 VALUES ('%s', %d, %d,'%s','%s','%s','%s','%s','%s','%s')",
58 bigintval($_POST['rate']),
59 bigintval($_POST['mpoi']),
67 ), __FILE__, __LINE__);
68 $msg = "<FONT class=\"admin_done\">".ADMIN_PAYOUT_TYPE_ADDED."</FONT>";
73 SQL_FREERESULT($result);
76 $msg = "<FONT class=\"admin_failed\">".ADMIN_PAYOUT_TYPE_ALREADY."</FONT>";
80 // Payout requests by your members
81 $result_mem = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_user_payouts WHERE status='NEW' ORDER BY payout_timestamp DESC", __FILE__, __LINE__);
84 if ((isset($_POST['edit'])) && (SELECTION_COUNT($_POST['sel']) > 0))
87 if ((isset($_GET['ok'])) && ($_GET['ok'] == "ok"))
90 foreach ($_POST['sel'] as $id => $sel)
95 // Edit only if something is entered
96 if ((!empty($_POST['title'][$id])) && ($_POST['rate'][$id] > 0))
99 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_payout_types SET
104 WHERE id='".$id."' LIMIT 1",
106 $_POST['title'][$id],
107 bigintval(str_replace(",", ".", $_POST['rate'][$id])),
108 bigintval(str_replace(",", ".", $_POST['mpoi'][$id])),
109 $_POST['allow'][$id],
110 ),__FILE__, __LINE__);
113 $msg = ADMIN_PAYOUT_ENTRIES_CHANGED;
117 $display = false; //Suppress any other outputs
119 foreach ($_POST['sel'] as $id => $sel)
122 $result = SQL_QUERY_ESC("SELECT type, rate, min_points, allow_url FROM "._MYSQL_PREFIX."_payout_types WHERE id=%s LIMIT 1",
123 array(bigintval($id)), __FILE__, __LINE__);
124 list($title, $rate, $mpoi, $allow) = SQL_FETCHROW($result);
125 SQL_FREERESULT($result);
127 // Prepare data for the row template
131 'title' => COMPILE_CODE($title),
132 'rate' => TRANSLATE_COMMA($rate),
133 'mpoi' => TRANSLATE_COMMA($mpoi),
134 'allow' => ADD_SELECTION("yn", $allow, "allow[".$id."]"),
137 // Load row template and switch color
138 $OUT .= LOAD_TEMPLATE("admin_config_payouts_edit_row", true, $content);
141 define('__PAYOUT_ROWS', $OUT);
143 // Load main template
144 LOAD_TEMPLATE("admin_config_payouts_edit");
147 elseif ((isset($_POST['del'])) && (SELECTION_COUNT($_POST['sel']) > 0))
149 // Delete payout types
150 if ($_GET['ok'] == "ok")
153 foreach ($_POST['sel'] as $id => $sel)
155 $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_payout_types WHERE id=%s LIMIT 1",
156 array(bigintval($id)), __FILE__, __LINE__);
158 $msg = ADMIN_PAYOUT_ENTRIES_DELETED;
162 $display = false; //Suppress any other outputs
164 foreach ($_POST['sel'] as $id => $sel)
167 $id = bigintval($id);
170 $result = SQL_QUERY_ESC("SELECT type, rate, min_points FROM "._MYSQL_PREFIX."_payout_types WHERE id=%s LIMIT 1",
171 array($id), __FILE__, __LINE__);
172 list($title, $rate, $mpoi) = SQL_FETCHROW($result);
173 SQL_FREERESULT($result);
175 // Prepare data for the row template
179 'title' => COMPILE_CODE($title),
180 'rate' => TRANSLATE_COMMA($rate),
181 'mpoi' => TRANSLATE_COMMA($mpoi),
184 // Load row template and switch color
185 $OUT .= LOAD_TEMPLATE("admin_config_payouts_del_row", true, $content);
188 define('__PAYOUT_ROWS', $OUT);
190 // Load main template
191 LOAD_TEMPLATE("admin_config_payouts_del");
198 LOAD_TEMPLATE("admin_settings_saved", false, $msg);
202 $result_type = SQL_QUERY("SELECT id, type, rate, min_points, from_account FROM "._MYSQL_PREFIX."_payout_types ORDER BY type", __FILE__, __LINE__);
204 if ((SQL_NUMROWS($result_type) > 0) && ($display))
206 // List all payout types
208 while (list($id, $type, $rate, $mpoi, $from) = SQL_FETCHROW($result_type))
210 // Prepare data for the row template
214 'from' => COMPILE_CODE($from),
215 'type' => COMPILE_CODE($type),
216 'rate' => TRANSLATE_COMMA($rate),
217 'mpoi' => TRANSLATE_COMMA($mpoi),
220 // Load row template and switch color
221 $OUT .= LOAD_TEMPLATE("admin_config_payouts_row", true, $content);
226 SQL_FREERESULT($result_type);
227 define('__PAYOUT_ROWS', $OUT);
229 // Load main template
230 LOAD_TEMPLATE("admin_config_payouts");
233 // Does your members request payouts?
234 if ((SQL_NUMROWS($result_mem) > 0) && ($display))
236 // Members has requested payouts
237 SQL_FREERESULT($result_mem);
238 OUTPUT_HTML("<P><A href=\"".URL."/modules.php?module=admin&what=list_payouts\">".ADMIN_PAYOUT_LIST_REQUESTS."</A></P>");
242 // No member requests so far
243 OUTPUT_HTML("<P><STRONG>".ADMIN_PAYOUT_NO_MEMBER_REQUESTS."</STRONG></P>");
245 // Add new paypout type
246 if ($display) LOAD_TEMPLATE("admin_payout_add_new");