2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 09/28/2003 *
4 * =================== Last change: 07/13/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-unlock_emails.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Unlock ordered emails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Werbebuchungen freigeben *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2012 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
47 $result_main = SQL_QUERY("SELECT
57 `{?_MYSQL_PREFIX?}_pool`
61 `timestamp` ASC", __FILE__, __LINE__);
63 if ((!SQL_HASZERONUMS($result_main)) || (isFormSent('lock'))) {
64 if (isFormSent('accept')) {
65 if (ifPostContainsSelections()) {
67 foreach (postRequestElement('sel') as $id => $value) {
71 // Order placed in queue...
72 $result = SQL_QUERY_ESC('SELECT
79 `{?_MYSQL_PREFIX?}_pool` AS `po`
81 `{?_MYSQL_PREFIX?}_payments` AS `pay`
83 po.`payment_id`=pay.`id`
87 array($id), __FILE__, __LINE__);
90 if (SQL_NUMROWS($result) == 1) {
92 $content = SQL_FETCHARRAY($result);
94 // Is the surfbar installed?
95 // @TODO Rewrite these if-blocks to a filter
96 if ((isExtensionActive('surfbar')) && (getConfig('surfbar_migrate_order') == 'Y')) {
97 // Then "migrate" the URL to the surfbar
98 doSurfbarAdminMigrateUrl($content['url'], $content['sender']);
101 // Check for bonus extension version >= 0.4.4 for the order bonus
102 if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (isBonusRallyeActive())) {
103 // Add points directly
104 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_order`=`bonus_order`+{?bonus_order?} WHERE `userid`=%s LIMIT 1",
105 array(bigintval($content['sender'])), __FILE__, __LINE__);
107 // Subtract bonus points from system
108 handleBonusPoints(getConfig('bonus_order'), $content['sender']);
111 // Load email template
112 $message_user = loadEmailTemplate('member_order_accepted', $content, $content['sender']);
115 sendEmail($content['sender'], '{--MEMBER_ORDER_ACCEPTED--}', $message_user);
117 // Unlock selected email
118 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='NEW' WHERE `id`=%s AND `data_type`='ADMIN' LIMIT 1",
119 array($id), __FILE__, __LINE__);
123 SQL_FREERESULT($result);
127 $message = '{--ADMIN_MAILS_ACTIVATED--}';
130 $message = '{--ADMIN_MAILS_NOTHING_CHECKED--}';
133 // Mails unlocked for mail delivery
134 displayMessage($message);
135 } elseif (isPostRequestElementSet('reject')) {
136 if (ifPostContainsSelections()) {
137 // Reject mail orders
139 foreach (postRequestElement('sel') as $id => $value) {
141 $id = bigintval($id);
143 // Load URL and subject from pool
144 $result = SQL_QUERY_ESC("SELECT `url`, `subject`, `sender` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1",
145 array($id), __FILE__, __LINE__);
148 $content = SQL_FETCHARRAY($result);
151 SQL_FREERESULT($result);
153 // Load email template and send it away
154 $message_user = loadEmailTemplate('member_order_rejected', $content, $content['sender']);
155 sendEmail($content['sender'], '{--MEMBER_ORDER_REJECTED--}', $message_user);
157 // If you do not enter an URL to redirect to, your URL will be set!
158 if ((!isPostRequestElementSet('redirect')) || (postRequestElement('redirect') == 'http://')) {
159 setPostRequestElement('redirect', getUrl());
163 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `url`='%s',`data_type`='NEW' WHERE `id`=%s LIMIT 1",
164 array(postRequestElement('redirect'), $id),__FILE__, __LINE__);
166 // Prepare data for the row template
169 'url' => postRequestElement('url', $id),
172 // Load row template and switch colors
173 $OUT .= loadTemplate('admin_unlock_emails_redir_row', true, $content);
176 // Load main template
177 loadTemplate('admin_unlock_emails_redir', false, $OUT);
180 displayMessage('{--ADMIN_MAILS_NOTHING_CHECKED--}');
182 } elseif ((isFormSent('lock')) && (ifPostContainsSelections()) && (isUrlBlacklistEnabled())) {
184 foreach (postRequestElement('sel') as $id => $url) {
186 $id = bigintval($id);
188 // Lookup in blacklist
189 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_url_blacklist` WHERE `url`='%s' LIMIT 1",
190 array($url), __FILE__, __LINE__);
191 if (SQL_HASZERONUMS($result)) {
192 // Did not find a record so we can add it... :)
193 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_url_blacklist` (`url`, `pool_id`) VALUES ('%s',%s)",
194 array($url, $id), __FILE__, __LINE__);
198 SQL_FREERESULT($result);
202 displayMessage('{--ADMIN_URLS_BLOCKED--}');
203 } elseif ((!isFormSent('lock')) && (!isFormSent('accept')) && (!isFormSent('reject'))) {
204 // Mail orders are in pool so we can display them
206 while ($content = SQL_FETCHARRAY($result_main)) {
207 // Prepare data for the template
208 $content['timestamp'] = generateDateTime($content['timestamp'], 2);
210 // Load row template and switch colors
211 $OUT .= loadTemplate('admin_unlock_emails_row', true, $content);
215 SQL_FREERESULT($result_main);
218 $content['rows'] = $OUT;
220 // Load main template
221 loadTemplate('admin_unlock_emails', false, $content);
222 } elseif ((isFormSent('lock')) && (!isUrlBlacklistEnabled())) {
223 // URL blacklist not activated
224 displayMessage('{--ADMIN_URL_BLACKLIST_DISABLED--}');
227 displayMessage('{--ADMIN_WRONG_CALL--}');
230 // No mail orders fond
231 displayMessage('{--ADMIN_NO_MAILS_IN_POOL--}');