2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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 bestätigte Mails *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
48 if (((!isPostRequestParameterSet(('t_wait'))) || (!isPostRequestParameterSet(('payment')))) && (isGetRequestParameterSet('do')) && (getRequestParameter('do') == 'add')) {
49 unsetPostRequestParameter('ok');
53 switch (getRequestParameter('do')) {
55 addSql("INSERT INTO `{?_MYSQL_PREFIX?}_payments` (`time`, `payment`, `mail_title`, `price`) VALUES ('".postRequestParameter('t_wait')."','".postRequestParameter('payment')."','".postRequestParameter('title')."','".postRequestParameter('price')."')");
56 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `time`='%s' LIMIT 1",
57 array(postRequestParameter('t_wait')), __FILE__, __LINE__);
58 if (SQL_NUMROWS($result) == 1) {
59 // Re-init the array here
63 SQL_FREERESULT($result);
68 foreach (postRequestParameter('time') as $id => $value) {
69 addSql("UPDATE `{?_MYSQL_PREFIX?}_payments` SET `time`='" . $value . "', `payment`='".postRequestParameter('pay', $id)."', price='".postRequestParameter('price', $id)."', mail_title='".postRequestParameter('title', $id)."' WHERE `id`='".$id."' LIMIT 1");
74 foreach (postRequestParameter('id') as $id => $value) {
75 addSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=" . bigintval($id) . " LIMIT 1");
81 if (countSqls() > 0) {
83 runFilterChain('run_sqls');
84 $content = '<span class="admin_failed">{--SETTINGS_SAVED--}</span>';
86 // Nothing has changed!
87 $content = '<span class="admin_failed">{--SETTINGS_NOT_SAVED--}</span>';
91 loadTemplate('admin_settings_saved', false, $content);
92 } elseif ((isFormSent('del')) && (ifPostContainsSelections())) {
93 // Delete entries here
95 foreach (postRequestParameter('sel') as $id => $value) {
96 $result = SQL_QUERY_ESC("SELECT time, mail_title FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
97 array(bigintval($id)), __FILE__, __LINE__);
98 list($time, $title) = SQL_FETCHROW($result);
99 SQL_FREERESULT($result);
101 // Prepare array for the row template
108 // Load row template and switch colors
109 $OUT .= loadTemplate('admin_del_payments_row', true, $content);
112 // Load main template
113 loadTemplate('admin_del_payments', false, $OUT);
114 } elseif ((isFormSent('edit')) && (ifPostContainsSelections())) {
117 foreach (postRequestParameter('sel') as $id => $value) {
118 $result = SQL_QUERY_ESC("SELECT time, payment, mail_title, price FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
119 array(bigintval($id)), __FILE__, __LINE__);
120 list($time, $pay, $title, $price) = SQL_FETCHROW($result);
121 SQL_FREERESULT($result);
123 // Prepare array for the row template
132 // Load row template and switch colors
133 $OUT .= loadTemplate('admin_edit_payments_row', true, $content);
136 // Load main template
137 loadTemplate('admin_edit_payments', false, $OUT);
140 $result = SQL_QUERY("SELECT `id`, `time`, `payment`, `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` ORDER BY `time` ASC", __FILE__, __LINE__);
141 if (!SQL_HASZERONUMS($result)) {
142 // Make referal levels editable and deletable
145 // List already existing categories for editing
146 while ($content = SQL_FETCHARRAY($result)) {
147 // Load row template and switch colors
148 $OUT .= loadTemplate('admin_list_payments_row', true, $content);
152 SQL_FREERESULT($result);
154 // Load main template
155 loadTemplate('admin_list_payments', false, $OUT);
158 // Form for adding new referal levels
159 loadTemplate('admin_add_payment');