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 * 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 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!isAdmin())) {
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
48 $result_main = SQL_QUERY("SELECT
49 `id`,`sender`,`subject`,`payment_id` AS `payment`,`timestamp`,`url`,`target_send`,`cat_id` AS category
51 `{?_MYSQL_PREFIX?}_pool`
55 `timestamp` ASC", __FILE__, __LINE__);
57 if ((SQL_NUMROWS($result_main) > 0) || (isPostRequestParameterSet('lock'))) {
58 if (isPostRequestParameterSet('accept')) {
59 if (countPostSelection() > 0) {
61 foreach (postRequestParameter('sel') as $id => $value) {
65 // Order placed in queue...
66 $result = SQL_QUERY_ESC("SELECT
67 po.url, po.subject, po.sender, pay.payment, po.payment_id
69 `{?_MYSQL_PREFIX?}_pool` AS po
71 `{?_MYSQL_PREFIX?}_payments` AS pay
77 array($id), __FILE__, __LINE__);
80 if (SQL_NUMROWS($result) == 1) {
82 $content = SQL_FETCHARRAY($result);
85 SQL_FREERESULT($result);
87 // Is the surfbar installed?
88 // @TODO Rewrite these if-blocks to a filter
89 if ((isExtensionActive('surfbar')) && (getConfig('surfbar_migrate_order') == 'Y')) {
90 // Then "migrate" the URL to the surfbar
91 SURFBAR_ADMIN_MIGRATE_URL($content['url'], $content['sender']);
94 // Check for bonus extension version >= 0.4.4 for the order bonus
95 if ((getExtensionVersion('bonus') >= '0.4.4') && (getConfig('bonus_active') == 'Y')) {
96 // Add points directly
97 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_order`=`bonus_order`+".getConfig('bonus_order')." WHERE `userid`=%s LIMIT 1",
98 array(bigintval($content['sender'])), __FILE__, __LINE__);
100 // Subtract bonus points from system
101 handleBonusPoints(getConfig('bonus_order'));
104 // Load email template
105 $message_user = loadEmailTemplate('order-accept', $content, $content['sender']);
108 sendEmail($content['sender'], getMessage('MEMBER_ORDER_ACCEPTED'), $message_user);
110 // Unlock selected email
111 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='NEW' WHERE `id`=%s AND `data_type`='ADMIN' LIMIT 1",
112 array($id), __FILE__, __LINE__);
117 $message = getMessage('ADMIN_MAILS_ACTIVATED');
120 $message = getMessage('ADMIN_MAILS_NOTHING_CHECKED');
123 // Mails unlocked for mail delivery
124 loadTemplate('admin_settings_saved', false, $message);
125 } elseif (isPostRequestParameterSet(('reject'))) {
126 if (countPostSelection() > 0) {
127 // Reject mail orders
129 foreach (postRequestParameter('sel') as $id => $value) {
131 $id = bigintval($id);
133 // Load URL and subject from pool
134 $result = SQL_QUERY_ESC("SELECT `url`, `subject`, `sender` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1",
135 array($id), __FILE__, __LINE__);
138 $content = SQL_FETCHARRAY($result);
141 SQL_FREERESULT($result);
143 // Load email template and send it away
144 $message_user = loadEmailTemplate('order-reject', $content, $content['sender']);
145 sendEmail($content['sender'], getMessage('MEMBER_ORDER_REJECTED'), $message_user);
147 // If you do not enter an URL to redirect to, your URL will be set!
148 if ((!isPostRequestParameterSet('redirect')) || (postRequestParameter('redirect') == 'http://')) setPostRequestParameter('redirect', getConfig('URL'));
151 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET url='%s', `data_type`='NEW' WHERE `id`=%s LIMIT 1",
152 array(postRequestParameter('redirect'), $id),__FILE__, __LINE__);
154 // Prepare data for the row template
158 'url' => postRequestParameter('url', $id),
161 // Load row template and switch colors
162 $OUT .= loadTemplate('admin_unlock_emails_redir_row', true, $content);
166 // Load main template
167 loadTemplate('admin_unlock_emails_redir', false, $OUT);
170 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_MAILS_NOTHING_CHECKED'));
172 } elseif ((isPostRequestParameterSet('lock')) && (countPostSelection() > 0) && (getConfig('url_blacklist') == 'Y')) {
174 foreach (postRequestParameter('sel') as $id => $url) {
176 $id = bigintval($id);
178 // Lookup in blacklist
179 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_url_blacklist` WHERE `url`='%s' LIMIT 1",
180 array($url), __FILE__, __LINE__);
181 if (SQL_NUMROWS($result) == '0') {
182 // Did not find a record so we can add it... :)
183 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_url_blacklist` (`url`,`pool_id`) VALUES ('%s',%s)",
184 array($url, $id), __FILE__, __LINE__);
188 SQL_FREERESULT($result);
192 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_URLS_BLOCKED'));
193 } elseif ((!isPostRequestParameterSet('lock')) && (!isPostRequestParameterSet('accept')) && (!isPostRequestParameterSet('reject'))) {
194 // Mail orders are in pool so we can display them
196 while ($content = SQL_FETCHARRAY($result_main)) {
197 // Prepare data for the template
200 'id' => $content['id'],
201 'sender' => $content['sender'],
202 'u_link' => generateUserProfileLink($content['sender']),
203 'subject' => $content['subject'],
204 'tester' => generateFrametesterUrl($content['url']),
205 'url' => $content['url'],
206 'cat_title' => str_replace("\"", '"', getCategory($content['category'])),
207 'cat_link' => $content['category'],
208 'pay_title' => str_replace("\"", '"', getPaymentTitlePrice($content['payment'], true)),
209 'pay_link' => $content['payment'],
210 'timestamp' => generateDateTime($content['timestamp'], 2),
211 'target_send' => $content['target_send'],
214 // Load row template and switch colors
215 $OUT .= loadTemplate('admin_unlock_emails_row', true, $content);
220 SQL_FREERESULT($result_main);
223 $content['rows'] = $OUT;
225 // Load main template
226 loadTemplate('admin_unlock_emails', false, $content);
227 } elseif ((isPostRequestParameterSet('lock')) && (getConfig('url_blacklist') != 'Y')) {
228 // URL blacklist not activated
229 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_URL_BLACKLIST_DISABLED'));
232 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_WRONG_CALL'));
235 // No mail orders fond
236 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NO_MAILS_IN_POOL'));