2 /************************************************************************
3 * MXChange v0.2.1 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 - 2008 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')) || (!IS_ADMIN())) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
45 // Add description as navigation point
46 ADD_DESCR('admin', __FILE__);
48 // Define some variables
52 $result_main = SQL_QUERY("SELECT `id`,`sender`,`subject`,`payment_id` AS `payment`,`timestamp`,`url`,`target_send`,`cat_id` AS `category`
53 FROM `{!_MYSQL_PREFIX!}_pool`
54 WHERE `data_type`='ADMIN'
55 ORDER BY `timestamp` ASC", __FILE__, __LINE__);
57 if ((SQL_NUMROWS($result_main) > 0) || (REQUEST_ISSET_POST(('lock')))) {
58 // Count checked checkboxes
60 if (REQUEST_ISSET_POST('sel')) {
61 // Are there checked boxes?
62 if (count(REQUEST_POST('sel')) > 0) {
63 // Count now... We use an own function for now
64 $SEL = SELECTION_COUNT(REQUEST_POST('sel'));
68 if (REQUEST_ISSET_POST(('accept'))) {
71 foreach (REQUEST_POST('sel') as $id => $value) {
75 // Order placed in queue...
76 $result = SQL_QUERY_ESC("SELECT po.url, po.subject, po.sender, pay.payment, po.payment_id
77 FROM `{!_MYSQL_PREFIX!}_pool` AS po
78 INNER JOIN `{!_MYSQL_PREFIX!}_payments` AS pay
79 ON po.payment_id=pay.id
82 array($id), __FILE__, __LINE__);
85 if (SQL_NUMROWS($result) == 1) {
87 $DATA = SQL_FETCHARRAY($result);
90 SQL_FREERESULT($result);
92 // Is the surfbar installed?
93 if ((EXT_IS_ACTIVE('surfbar')) && (getConfig('surfbar_migrate_order') == 'Y')) {
94 // Then "migrate" the URL to the surfbar
95 SURFBAR_ADMIN_MIGRATE_URL($DATA['url'], $DATA['sender']);
98 // Check for bonus extension version >= 0.4.4 for the order bonus
99 if ((GET_EXT_VERSION('bonus') >= '0.4.4') && (getConfig('bonus_active') == 'Y')) {
100 // Add points directly
101 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET bonus_order=bonus_order+".getConfig('bonus_order')." WHERE userid=%s LIMIT 1",
102 array(bigintval($DATA['sender'])), __FILE__, __LINE__);
104 // Subtract bonus points from system
105 BONUS_POINTS_HANDLER(getConfig('bonus_order'));
108 // Load email template
109 $msg_user = LOAD_EMAIL_TEMPLATE("order-accept", array(), $DATA['sender']);
112 SEND_EMAIL($DATA['sender'], MEMBER_ORDER_ACCEPTED, $msg_user);
114 // Unlock selected email
115 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET data_type='NEW' WHERE id=%s AND data_type='ADMIN' LIMIT 1",
116 array($id), __FILE__, __LINE__);
121 $message = ADMIN_MAILS_ACTIVATED;
124 $message = ADMIN_MAILS_NOTHING_CHECKED;
127 // Mails unlocked for mail delivery
128 LOAD_TEMPLATE('admin_settings_saved', false, $message);
129 } elseif (REQUEST_ISSET_POST(('reject'))) {
131 // Reject mail orders
133 foreach (REQUEST_POST('sel') as $id => $value) {
135 $id = bigintval($id);
137 // Load URL and subject from pool
138 $result = SQL_QUERY_ESC("SELECT url, subject, sender FROM `{!_MYSQL_PREFIX!}_pool` WHERE id=%s LIMIT 1",
139 array($id), __FILE__, __LINE__);
142 $DATA = SQL_FETCHARRAY($result);
145 SQL_FREERESULT($result);
147 // Load email template and send it away
148 $msg_user = LOAD_EMAIL_TEMPLATE("order-reject", array(), $DATA['sender']);
149 SEND_EMAIL($DATA['sender'], MEMBER_ORDER_REJECTED, $msg_user);
151 // If you do not enter an URL to redirect to, your URL will be set!
152 if ((!REQUEST_ISSET_POST(('redirect'))) || (REQUEST_POST('redirect') == "http://")) REQUEST_SET_POST('redirect', constant('URL'));
155 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET url='%s', data_type='NEW' WHERE id=%s LIMIT 1",
156 array(REQUEST_POST('redirect'), $id),__FILE__, __LINE__);
158 // Prepare data for the row template
162 'url' => REQUEST_POST('url', $id),
165 // Load row template and switch colors
166 $OUT .= LOAD_TEMPLATE("admin_unlock_emails_redir_row", true, $content);
169 define('__URL_ROWS', $OUT);
171 // Load main template
172 LOAD_TEMPLATE("admin_unlock_emails_redir");
175 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_MAILS_NOTHING_CHECKED'));
177 } elseif ((REQUEST_ISSET_POST(('lock'))) && ($SEL > 0) && (getConfig('url_blacklist') == 'Y')) {
179 foreach (REQUEST_POST('sel') as $id => $url) {
181 $id = bigintval($id);
183 // Lookup in blacklist
184 $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_url_blacklist` WHERE `url`='%s' LIMIT 1",
185 array($url), __FILE__, __LINE__);
186 if (SQL_NUMROWS($result) == 0) {
187 // Did not find a record so we can add it... :)
188 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_url_blacklist` (`url`,`pool_id`) VALUES ('%s',%s)",
189 array($url, $id), __FILE__, __LINE__);
193 SQL_FREERESULT($result);
197 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_URLS_BLOCKED'));
198 } elseif ((!REQUEST_ISSET_POST(('lock'))) && (!REQUEST_ISSET_POST(('accept'))) && (!REQUEST_ISSET_POST(('reject'))) && (getConfig('url_blacklist') == 'Y')) {
199 // Mail orders are in pool so we can display them
201 while ($content = SQL_FETCHARRAY($result_main)) {
202 // Prepare data for the template
205 'id' => $content['id'],
206 'sender' => $content['sender'],
207 'u_link' => ADMIN_USER_PROFILE_LINK($content['sender']),
208 'subj' => COMPILE_CODE($content['subject']),
209 'tester' => FRAMETESTER($content['url']),
210 'url' => $content['url'],
211 'cat_title' => str_replace("\"", """, GET_CATEGORY($content['category'])),
212 'cat_link' => $content['category'],
213 'pay_title' => str_replace("\"", """, GET_PAYMENT($content['payment'], true)),
214 'pay_link' => $content['payment'],
215 'ordered' => MAKE_DATETIME($content['timestamp'], "2"),
216 'tsend' => $content['target_send'],
219 // Load row template and switch colors
220 $OUT .= LOAD_TEMPLATE("admin_unlock_emails_row", true, $content);
225 SQL_FREERESULT($result_main);
226 define('__UNLOCK_ROWS', $OUT);
228 // Prepare rejection URL
230 if (GET_EXT_VERSION('other') >= '0.1.6') $REJECT = getConfig('reject_url');
231 define('__REJECT_URL', $REJECT);
233 // Load main template
234 LOAD_TEMPLATE("admin_unlock_emails");
235 } elseif ((REQUEST_ISSET_POST(('lock'))) && (getConfig('url_blacklist') != "Y")) {
236 // URL blacklist not activated
237 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_URL_BLACKLIST_DISABLED'));
240 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_WRONG_CALL'));
243 // No mail orders fond
244 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NO_MAILS_IN_POOL'));