]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-unlock_emails.php
bb4911f983d3a3a8f93adbd11290c1f3e2a6b0ad
[mailer.git] / inc / modules / admin / what-unlock_emails.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 09/28/2003 *
4  * ===============                              Last change: 07/13/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-unlock_emails.php                           *
8  * -------------------------------------------------------------------- *
9  * Short description : Unlock ordered emails                            *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Werbebuchungen freigeben                         *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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                  *
22  *                                                                      *
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.                                  *
27  *                                                                      *
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.                         *
32  *                                                                      *
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,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
42         require($INC);
43 }
44
45 // Add description as navigation point
46 ADD_DESCR('admin', __FILE__);
47
48 // Define some variables
49 global $DATA;
50
51 // Check for mails
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__);
56
57 if ((SQL_NUMROWS($result_main) > 0) || (REQUEST_ISSET_POST(('lock')))) {
58         // Count checked checkboxes
59         $SEL = 0;
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'));
65                 } // END - if
66         } // END - if
67
68         if (REQUEST_ISSET_POST(('accept'))) {
69                 if ($SEL > 0) {
70                         // Accept mail orders
71                         foreach (REQUEST_POST('sel') as $id => $value) {
72                                 // Secure ID number
73                                 $id = bigintval($id);
74
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
80 WHERE po.id=%s
81 LIMIT 1",
82                                         array($id), __FILE__, __LINE__);
83
84                                 // Update wents fine?
85                                 if (SQL_NUMROWS($result) == 1) {
86                                         // Load data
87                                         $DATA = SQL_FETCHARRAY($result);
88
89                                         // Free result
90                                         SQL_FREERESULT($result);
91
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']);
96                                         } // END - if
97
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__);
103
104                                                 // Subtract bonus points from system
105                                                 BONUS_POINTS_HANDLER(getConfig('bonus_order'));
106                                         } // END - if
107
108                                         // Load email template
109                                         $msg_user = LOAD_EMAIL_TEMPLATE("order-accept", array(), $DATA['sender']);
110
111                                         // Send email
112                                         SEND_EMAIL($DATA['sender'], MEMBER_ORDER_ACCEPTED, $msg_user);
113
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__);
117                                 } // END - if
118                         } // END - foreach
119
120                         // Set message
121                         $message = ADMIN_MAILS_ACTIVATED;
122                 } else {
123                         // Nothing checked!
124                         $message = ADMIN_MAILS_NOTHING_CHECKED;
125                 }
126
127                 // Mails unlocked for mail delivery
128                 LOAD_TEMPLATE('admin_settings_saved', false, $message);
129         } elseif (REQUEST_ISSET_POST(('reject'))) {
130                 if ($SEL > 0) {
131                         // Reject mail orders
132                         $OUT = ''; $SW = 2;
133                         foreach (REQUEST_POST('sel') as $id => $value) {
134                                 // Secure ID number
135                                 $id = bigintval($id);
136
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__);
140
141                                 // Load data
142                                 $DATA = SQL_FETCHARRAY($result);
143
144                                 // Free result
145                                 SQL_FREERESULT($result);
146
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);
150
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'));
153
154                                 // Redirect 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__);
157
158                                 // Prepare data for the row template
159                                 $content = array(
160                                         'sw'  => $SW,
161                                         'id'  => $id,
162                                         'url' => REQUEST_POST('url', $id),
163                                 );
164
165                                 // Load row template and switch colors
166                                 $OUT .= LOAD_TEMPLATE("admin_unlock_emails_redir_row", true, $content);
167                                 $SW = 3 - $SW;
168                         }
169                         define('__URL_ROWS', $OUT);
170
171                         // Load main template
172                         LOAD_TEMPLATE("admin_unlock_emails_redir");
173                 } else {
174                         // Nothing selected
175                         LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_MAILS_NOTHING_CHECKED'));
176                 }
177         } elseif ((REQUEST_ISSET_POST(('lock'))) && ($SEL > 0) && (getConfig('url_blacklist') == 'Y')) {
178                 // Lock URLs
179                 foreach (REQUEST_POST('sel') as $id => $url) {
180                         // Secure id number
181                         $id = bigintval($id);
182
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__);
190                         } // END - if
191
192                         // Free memory
193                         SQL_FREERESULT($result);
194                 } // END - foreach
195
196                 // Output message
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
200                 $OUT = ''; $SW = 2;
201                 while ($content = SQL_FETCHARRAY($result_main)) {
202                         // Prepare data for the template
203                         $content = array(
204                                 'sw'        => $SW,
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("\"", "&quot;", GET_CATEGORY($content['category'])),
212                                 'cat_link'  => $content['category'],
213                                 'pay_title' => str_replace("\"", "&quot;", GET_PAYMENT($content['payment'], true)),
214                                 'pay_link'  => $content['payment'],
215                                 'ordered'   => MAKE_DATETIME($content['timestamp'], "2"),
216                                 'tsend'     => $content['target_send'],
217                         );
218
219                         // Load row template and switch colors
220                         $OUT .= LOAD_TEMPLATE("admin_unlock_emails_row", true, $content);
221                         $SW = 3 - $SW;
222                 } // END - while
223
224                 // Free memory
225                 SQL_FREERESULT($result_main);
226                 define('__UNLOCK_ROWS', $OUT);
227
228                 // Prepare rejection URL
229                 $REJECT = "http://";
230                 if (GET_EXT_VERSION('other') >= '0.1.6') $REJECT = getConfig('reject_url');
231                 define('__REJECT_URL', $REJECT);
232
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'));
238         } else {
239                 // Wrong call!
240                 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_WRONG_CALL'));
241         }
242 } else {
243         // No mail orders fond
244         LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NO_MAILS_IN_POOL'));
245 }
246
247 //
248 ?>