RevBomb patch applied (thanks to profi-concept)
[mailer.git] / inc / modules / admin / what-email_archiv.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 09/28/2003 *
4  * ===============                              Last change: 04/03/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-email_archiv .php                           *
8  * -------------------------------------------------------------------- *
9  * Short description : See send emails details of ordered mails         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Alle  Mails ansehen die versand wurden           *
12  * -------------------------------------------------------------------- *
13  * $Revision:: 856                                                    $ *
14  * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. Mär 2009)              $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author:: stelzi                                                   $ *
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  * Mod-Copyright (c) 2004 by Robert Niedziela                           *
39  * www.megacomputing.de                                                 *
40  ************************************************************************/
41
42 // Some security stuff...
43 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
44         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
45         require($INC);
46 }
47
48 // Add description as navigation point
49 ADD_DESCR("admin", __FILE__);
50
51 //             0     1        2      3        4          5           6          7      8         9        10
52 $sql = "SELECT id, sender, subject, text, receivers, payment_id, data_type, timestamp, url, target_send, cat_id
53  FROM `{!_MYSQL_PREFIX!}_pool`
54  WHERE data_type='SEND' OR data_type='DELETED'
55  ORDER BY timestamp DESC";
56
57 // Check for maximum pages
58 $result_normal = SQL_QUERY($sql, __FILE__, __LINE__);
59
60 // Set offset an current page to default values
61 if (!REQUEST_ISSET_GET(('page')))   REQUEST_GET('page')   = "1";
62 if (!REQUEST_ISSET_GET(('offset'))) REQUEST_SET_GET('offset', getConfig('mails_page'));
63
64 // Add limitation to SQL string
65 $sql .= " LIMIT ".(REQUEST_GET('offset') * REQUEST_GET('page') - REQUEST_GET('offset')).", ".REQUEST_GET('offset');
66
67 // Run SQL query for normal mails
68 $result = SQL_QUERY($sql, __FILE__, __LINE__);
69
70 // Calculate pages
71 $PAGES = round(SQL_NUMROWS($result_normal) / getConfig('mails_page') + 0.5);
72 SQL_FREERESULT($result_normal);
73
74 if (SQL_NUMROWS($result) > 0)
75 {
76         // Mail orders are in pool so we can display them
77
78         // Add navigation table rows
79         if ($PAGES > 1)
80         {
81                 define('__TOP_EMAIL_NAV'   , ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), true , "3", true));
82                 define('__BOTTOM_EMAIL_NAV', ADD_EMAIL_NAV($PAGES, getConfig('mails_page'), false, "3", true));
83         }
84          else
85         {
86                 define('__TOP_EMAIL_NAV'   , "");
87                 define('__BOTTOM_EMAIL_NAV', "");
88         }
89
90         $OUT = ""; $SW = 2;
91         while ($pool = SQL_FETCHROW($result))
92         {
93                 // Check sent mails and clicks
94                 $result_mails = SQL_QUERY_ESC("SELECT max_rec, clicks FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE pool_id=%s LIMIT 1",
95                  array(bigintval($pool[0])), __FILE__, __LINE__);
96                 list($sent, $clicks) = SQL_FETCHROW($result_mails);
97                 SQL_FREERESULT($result_mails);
98
99                 // Unconfirmed mails
100                 $unconfirmed = $sent - $clicks;
101                 if ($unconfirmed > 0)
102                 {
103                         // Add link to list_unconfirmed what-file
104                         $unconfirmed = "<strong><a href=\"{!URL!}/modules.php?module=admin&amp;what=list_unconfirmed&amp;mid=".$pool[0]."\">".$unconfirmed."</a></strong>";
105                 }
106
107                 // Prepare data for the row template
108                 $content = array(
109                         'sw'          => $SW,
110                         'u_link'      => ADMIN_USER_PROFILE_LINK($pool[1]),
111                         'subj'        => COMPILE_CODE($pool[2]),
112                         'text'        => COMPILE_CODE($pool[3]),
113                         'pay'         => GET_PAYMENT($pool[5]),
114                         'cat'         => GET_CATEGORY($pool[10]),
115                         'sent'        => $sent,
116                         'ruids'       => str_replace(";", ", ", $pool[4]),
117                         'unconfirmed' => $unconfirmed,
118                         'type'        => TRANSLATE_POOL_TYPE($pool[6]),
119                         'tsend'       => $pool[9],
120                         'frametester' => FRAMETESTER($pool[8]),
121                         'url'         => COMPILE_CODE($pool[8]),
122                         'stamp'       => MAKE_DATETIME($pool[7], "0"),
123                         'mid'         => $pool[0],
124                 );
125
126                 // Load row template and switch colors
127                 $OUT .= LOAD_TEMPLATE("admin_email_archiv_row", true, $content);
128                 $SW = 3 - $SW;
129         }
130
131         // Free memory
132         SQL_FREERESULT($result);
133         define('__EMAIL_ROWS', $OUT);
134
135         // Load main template
136         LOAD_TEMPLATE("admin_email_archiv");
137 } else {
138         // No mail orders fond
139         LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_NO_MAILS_IN_POOL'));
140 }
141 //
142 ?>