2 /************************************************************************
3 * MXChange v0.2.1 Start: 10/19/2003 *
4 * =============== Last change: 12/12/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-payments.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Payments (points) for confirmed mails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Verguetungen fuer bestaetigte Mails *
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 ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
37 $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($_GET['do'])) unset($_GET['do']);
44 if (((empty($_POST['t_wait'])) || (empty($_POST['payment']))) && (!empty($_GET['do'])) && ($_GET['do'] == "add"))
49 if (isset($_POST['ok']))
55 $SQL[] = "INSERT INTO "._MYSQL_PREFIX."_payments (time, payment, mail_title, price) VALUES ('".$_POST['t_wait']."', '".$_POST['payment']."', '".$_POST['title']."', '".$_POST['price']."')";
56 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_payments WHERE time='%s' LIMIT 1",
57 array($_POST['t_wait']), __FILE__, __LINE__);
58 if (SQL_NUMROWS($result) == 1)
62 SQL_FREERESULT($result);
67 foreach ($_POST['time'] as $id => $value)
69 $SQL[] = "UPDATE "._MYSQL_PREFIX."_payments SET time='".$value."', payment='".$_POST['pay'][$id]."', price='".$_POST['price'][$id]."', mail_title='".$_POST['title'][$id]."' WHERE id='".$id."' LIMIT 1";
74 foreach ($_POST['id'] as $id => $value)
76 $SQL[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_payments WHERE id='".$id."' LIMIT 1";
81 if ((count($SQL) > 0) || (!empty($SQL[0])))
87 // Only run non-empty strings
88 $result = SQL_QUERY(trim($s), __FILE__, __LINE__);
91 if (SQL_AFFECTEDROWS() == 1)
93 $content = "<SPAN class=\"admin_done\">".SETTINGS_SAVED."</SPAN>";
97 $content = "<SPAN class=\"admin_failed\">".SETTINGS_NOT_SAVED."</SPAN>";
105 $content = "<SPAN class=\"admin_failed\">".SETTINGS_NOT_SAVED."</SPAN>";
107 LOAD_TEMPLATE("admin_settings_saved", false, $content);
109 elseif ((isset($_POST['del'])) && (SELECTION_COUNT($_POST['sel']) > 0))
111 // Delete entries here
113 foreach ($_POST['sel'] as $id => $value)
115 $result = SQL_QUERY_ESC("SELECT time, mail_title FROM "._MYSQL_PREFIX."_payments WHERE id=%s LIMIT 1",
116 array(bigintval($id)), __FILE__, __LINE__);
117 list($time, $title) = SQL_FETCHROW($result);
118 SQL_FREERESULT($result);
120 // Prepare array for the row template
128 // Load row template and switch colors
129 $OUT .= LOAD_TEMPLATE("admin_del_payments_row", true, $content);
132 define('__PAYMENT_ROWS', $OUT);
134 // Load main template
135 LOAD_TEMPLATE("admin_del_payments");
137 elseif ((isset($_POST['edit'])) && (SELECTION_COUNT($_POST['sel']) > 0))
141 foreach ($_POST['sel'] as $id => $value)
143 $result = SQL_QUERY_ESC("SELECT time, payment, mail_title, price FROM "._MYSQL_PREFIX."_payments WHERE id=%s LIMIT 1",
144 array(bigintval($id)), __FILE__, __LINE__);
145 list($time, $pay, $title, $price) = SQL_FETCHROW($result);
146 SQL_FREERESULT($result);
148 // Prepare array for the row template
158 // Load row template and switch colors
159 $OUT .= LOAD_TEMPLATE("admin_edit_payments_row", true, $content);
162 define('__PAYMENT_ROWS', $OUT);
164 // Load main template
165 LOAD_TEMPLATE("admin_edit_payments");
170 $result = SQL_QUERY("SELECT id, time, payment, mail_title, price FROM "._MYSQL_PREFIX."_payments ORDER BY time", __FILE__, __LINE__);
171 if (SQL_NUMROWS($result) > 0)
173 // Make referral levels editable and deletable
176 // List already existing categories for editing
177 while (list($id, $time, $pay, $title, $price) = SQL_FETCHROW($result))
179 $pay = TRANSLATE_COMMA($pay);
180 $price = TRANSLATE_COMMA($price);
182 // Prepare array for the row template
192 // Load row template and switch colors
193 $OUT .= LOAD_TEMPLATE("admin_payments_list_row", true, $content);
198 SQL_FREERESULT($result);
199 define('__PAYMENT_ROWS', $OUT);
201 // Load main template
202 LOAD_TEMPLATE("admin_list_payments");
205 // Form for adding new referral levels
206 LOAD_TEMPLATE("admin_add_payment");