2 /************************************************************************
3 * MXChange v0.2.1 Start: 09/28/2003 *
4 * =============== Last change: 10/29/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-email_details.php *
8 * -------------------------------------------------------------------- *
9 * Short description : See all email details of ordered mails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Alle Details einer gebuchten Mail ansehen *
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 * -------------------------------------------------------------------- *
38 * Moded What-email_details.php / also Editet ! *
39 * Auf langsammen Servern (wie mein z.B Dauert das Laden) *
40 * enorm hoch zu lang. Jetzt werden nur auftraege aufgelistet die *
41 * NEU sind ( DB NEW) oder ADMIN freischalten muss (DB ADMIN ) *
42 * oder noch als TEMP gespecihert sind *
43 * der rest der schon als SEND sich melden darf wird per *
44 * what-email_archiv .php aufgerufen *
45 * beste gruesse Robert Niedziela / www.personal-webserver.de *
46 * oder auch www.mc-p.org *
47 ************************************************************************/
49 // Some security stuff...
50 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
51 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
55 // Add description as navigation point
56 ADD_DESCR('admin', __FILE__);
58 // Normal mails ordered by your members
59 // 0 1 2 3 4 5 6 7 8 9 10
60 $sql = "SELECT id, sender, subject, text, receivers, payment_id, data_type, timestamp, url, target_send, cat_id
61 FROM `{!_MYSQL_PREFIX!}_pool`
62 WHERE data_type IN('ADMIN','TEMP','NEW','ACTIVE')
63 ORDER BY timestamp DESC";
68 if (REQUEST_ISSET_GET(('mid'))) {
69 // Only a specific mail shall be displayed
70 // 0 1 2 3 4 5 6 7 8 9 10
71 $sql = "SELECT id, sender, subject, text, receivers, payment_id, data_type, timestamp, url, target_send, cat_id
72 FROM `{!_MYSQL_PREFIX!}_pool`
73 WHERE `id`='".bigintval(REQUEST_GET('mid'))."'
75 $WHO = MAIL_ID.": ".REQUEST_GET('mid');
76 } elseif (REQUEST_ISSET_GET('uid')) {
77 // All mails by a specific member shall be displayed
78 // 0 1 2 3 4 5 6 7 8 9 10
79 $sql = "SELECT id, sender, subject, text, receivers, payment_id, data_type, timestamp, url, target_send, cat_id
80 FROM `{!_MYSQL_PREFIX!}_pool`
81 WHERE sender='".bigintval(REQUEST_GET('uid'))."'
82 ORDER by timestamp DESC";
83 $WHO = USER_ID.": ".REQUEST_GET('uid');
86 if ((EXT_IS_ACTIVE('bonus')) && ($WHO == _ALL)) {
87 // Bonus mails sent by you
88 // 0 1 2 3 4 5 6 7 8 9 10 11 12
89 $SQL2 = "SELECT id, subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent, clicks
90 FROM `{!_MYSQL_PREFIX!}_bonus`
92 ORDER BY timestamp DESC";
94 // Check for maximum pages
95 $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
98 // Check for maximum pages
99 $result_normal = SQL_QUERY($sql, __FILE__, __LINE__);
101 // Set offset an current page to default values
102 if (!REQUEST_ISSET_GET('page')) REQUEST_SET_GET('page', '1');
104 if (!REQUEST_ISSET_GET('offset')) {
105 if (isConfigEntrySet('mails_page')) {
107 REQUEST_SET_GET('offset', getConfig('mails_page'));
110 REQUEST_SET_GET('offset', 10);
114 // Add limitation to SQL string
115 if (!REQUEST_ISSET_GET(('mid'))) {
116 // Create limitation line
117 $add = " LIMIT ".(bigintval(REQUEST_GET('offset')) * bigintval(REQUEST_GET('page')) - bigintval(REQUEST_GET('offset'))).", ".bigintval(REQUEST_GET('offset'));
123 if (!empty($SQL2)) $SQL2 .= $add;
126 // Run SQL query for normal mails
127 $result_list = SQL_QUERY($sql, __FILE__, __LINE__);
128 if ((!empty($SQL2)) && ($WHO == _ALL)) $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
132 if (isConfigEntrySet('mails_page')) {
133 $PAGES = round(SQL_NUMROWS($result_normal) / getConfig('mails_page') + 0.3);
137 SQL_FREERESULT($result_normal);
140 if (SQL_NUMROWS($result_list) > 0) {
142 $OUT = ''; $content = array();
144 // Walk through all entries
145 while ($pool = SQL_FETCHARRAY($result_list)) {
146 // Unconfirmed mails and sent mails
147 $result_uncon = SQL_QUERY_ESC("SELECT max_rec, clicks FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE pool_id=%s LIMIT 1",
148 array(bigintval($pool['id'])), __FILE__, __LINE__);
149 list($pool['sent_email'], $pool['clicks']) = SQL_FETCHROW($result_uncon);
150 SQL_FREERESULT($result_uncon);
153 $pool['unconfirmed'] = $pool['sent_email'] - $pool['clicks'];
154 if ($pool['unconfirmed'] > 0) {
155 // Add link to list_unconfirmed what-file
156 $pool['unconfirmed'] = "<strong><a href=\"{!URL!}/modules.php?module=admin&what=list_unconfirmed&mid=".$pool['id']."\">".$pool['unconfirmed']."</a></strong>";
157 } elseif ($pool['unconfirmed'] < 0) {
158 // Sometimes rarely displayed minus values will be "fixed" to zero
159 $pool['unconfirmed'] = 0;
164 $content['sender_link'] = generateUserProfileLink($pool['sender']);
165 $content['subject'] = COMPILE_CODE($pool['subject']);
166 $content['text'] = COMPILE_CODE($pool['text']);
167 $content['payment'] = getPaymentTitlePrice($pool['payment_id']);
168 $content['category'] = getCategory($pool['cat_id']);
169 $content['receivers'] = str_replace(';', ", ", $pool['receivers']);
170 $content['type'] = translatePoolType($pool['data_type']);
171 $content['frametester'] = FRAMETESTER($pool['url']);
172 $content['url'] = COMPILE_CODE($pool['url']);
173 $content['timestamp'] = generateDateTime($pool['timestamp'], '0');
176 $OUT .= LOAD_TEMPLATE("admin_list_emails_row", true, $content);
180 SQL_FREERESULT($result_list);
182 // Add navigation (with change box and colspan=3)
183 $content['nav'] = '';
184 if ($PAGES > 1) $content['nav'] = ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, '3', true);
187 $content['rows'] = $OUT;
188 $content['who'] = $WHO;
190 // Mail orders are in pool so we can display them
191 LOAD_TEMPLATE("admin_list_emails", false, $content);
194 if ((EXT_IS_ACTIVE('bonus')) && ($WHO == _ALL)) {
195 // Check only if bonus extension is active
196 if (SQL_NUMROWS($result_bonus) > 0) OUTPUT_HTML("<br /><br />");
200 if ((EXT_IS_ACTIVE('bonus')) && ($WHO == _ALL)) {
201 // Load bonus mails only when extension is active
202 if (SQL_NUMROWS($result_bonus) > 0) {
204 $PAGES = round(SQL_NUMROWS($result_bonus) / getConfig('mails_page') + 0.5);
207 $OUT = ''; $content = array();
208 while ($bonus = SQL_FETCHARRAY($result_bonus)) {
209 // Calculate unconfirmed emails
210 $bonus['unconfirmed'] = $bonus['mails_sent'] - $bonus['clicks'];
213 if ($bonus['unconfirmed'] > 0) {
214 // Add link to list_unconfirmed what-file
215 $bonus['unconfirmed'] = "<strong><a href=\"{!URL!}/modules.php?module=admin&what=list_unconfirmed&bid=".$bonus['id']."\">".$bonus['unconfirmed']."</a></strong>";
220 $content['time'] = createFancyTime($content['time']);
221 $content['category'] = getCategory($content['cat_id']);
222 $content['receivers'] = str_replace(';', ", ", $content['receivers']);
223 $content['type'] = translatePoolType($content['data_type']);
224 $content['frametester'] = FRAMETESTER($content['url']);
225 $content['timestamp'] = generateDateTime($content['timestamp'], '0');
228 $OUT .= LOAD_TEMPLATE("admin_list_bonus_emails_row", true, $content);
231 // Add navigation (without change box but with colspan=3)
232 $content['nav'] = '';
233 if ($PAGES > 1) $content['nav'] = ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, '3', true);
236 $content['rows'] = $OUT;
238 // Load main template
239 LOAD_TEMPLATE("admin_list_bonus_emails", false, $content);
245 // No mail orders fond
246 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NO_MAILS_IN_POOL'));