Unlock of booked URLs in surfbar added, fix for URL-encoded links in loader module
[mailer.git] / inc / modules / admin / what-edit_emails.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 09/28/2003 *
4  * ===============                              Last change: 04/09/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-edit_emails.php                             *
8  * -------------------------------------------------------------------- *
9  * Short description : Edit ordered mails e.g. redirecting the URL      *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Werbebuchungen aendern (z.B. umleiten der URL)   *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
36 {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40 // Add description as navigation point
41 ADD_DESCR("admin", basename(__FILE__));
42
43 OPEN_TABLE("100%", "admin_content admin_content_align", "");
44 global $link;
45
46 if ((isset($_POST['ok'])) && (empty($_POST['id'])))
47 {
48         unset($_POST['ok']);
49 }
50
51 $result = SQL_QUERY("SELECT id, sender, subject, payment_id, cat_id FROM "._MYSQL_PREFIX."_pool ORDER BY timestamp", __FILE__, __LINE__);
52 if (SQL_NUMROWS($result) > 0)
53 {
54         if (isset($_POST['ok']))
55         {
56                 // Make mail editable...
57                 $result = SQL_QUERY_ESC("SELECT subject, text, url FROM "._MYSQL_PREFIX."_pool WHERE id=%s LIMIT 1",
58                  array(bigintval($_POST['id'])), __FILE__, __LINE__);
59                 list($subj, $text, $url) = SQL_FETCHROW($result);
60                 SQL_FREERESULT($result);
61                 define('__ID_VALUE'  , $_POST['id']);
62                 define('__URL_VALUE' , $url);
63                 define('__SUBJ_VALUE', $subj);
64                 define('__TEXT_VALUE', $text);
65
66                 // Load template
67                 LOAD_TEMPLATE("admin_edit_email");
68         }
69          elseif (!empty($_POST['save']))
70         {
71                 // Save changes
72                 if (!empty($SQL))
73                 {
74                         $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET
75 subject='%s',
76 text='%s',
77 url='%s'
78 WHERE id=%s LIMIT 1",
79  array(
80         addslashes($_POST['subj']),
81         addslashes($_POST['text']),
82         addslashes($_POST['url']),
83         bigintval($_POST['id']),
84 ), __FILE__, __LINE__);
85                         if (SQL_AFFECTEDROWS($link, __FILE__, __LINE__) == 1)
86                         {
87                                 $content = "<SPAN class=\"admin_done\">".SETTINGS_SAVED."</SPAN>";
88                         }
89                          else
90                         {
91                                 $content = "<SPAN class=\"admin_failed\">".SETTINGS_NOT_SAVED."</SPAN>";
92                         }
93                 }
94                  else
95                 {
96                         $content = "<SPAN class=\"admin_failed\">".SETTINGS_NOT_SAVED."</SPAN>";
97                 }
98
99                 // Display message
100                 LOAD_TEMPLATE("admin_settings_saved", false, $content);
101         }
102          else
103         {
104                 // There are mail orders available
105                 $SW = 2; $OUT = "";
106                 while (list($id, $sender, $subj, $pay, $cat) = SQL_FETCHROW($result))
107                 {
108                         // Prepare data for the row template
109                         $content = array(
110                                 'sw'   => $SW,
111                                 'id'   => $id,
112                                 'subj' => $subj,
113                                 'uid'  => ADMIN_USER_PROFILE_LINK($sender),
114                                 'pay'  => GET_PAYMENT($pay),
115                                 'cat'  => GET_CATEGORY($cat),
116                         );
117
118                         // Load row template and switch colors
119                         $OUT .= LOAD_TEMPLATE("admin_edit_email_row", true, $content);
120                         $SW = 3 - $SW;
121                 }
122
123                 // Free memory
124                 SQL_FREERESULT($result);
125                 define('__EMAIL_SELECT_ROWS', $OUT);
126
127                 // Load email template
128                 LOAD_TEMPLATE("admin_edit_email_select");
129         }
130 }
131  else
132 {
133         // No mail orders left in pool
134         OUTPUT_HTML("<SPAN class=\"admin_failed\">".ADMIN_NO_MAILS_IN_POOL."</SPAN>");
135 }
136 CLOSE_TABLE();
137 //
138 ?>