cb306c5d5a20e5d0ed0875f467d8620e3dad32ae
[mailer.git] / inc / modules / admin / what-config_email.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/11/2003 *
4  * ===============                              Last change: 07/04/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-config_emails.php                           *
8  * -------------------------------------------------------------------- *
9  * Short description : Edit all things around email and sending         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Aendern aller Email-Einstellungen                *
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         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Add description as navigation point
41 ADD_DESCR("admin", basename(__FILE__));
42
43 // Remove empty array index
44 if (empty($_POST['max'])) unset($_POST['add_max']);
45
46 if (isset($_POST['add_max'])) {
47         // Save all settings
48         $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_max_receive WHERE value='%s' LIMIT 1",
49          array(bigintval($_POST['max'])), __FILE__, __LINE__);
50         if (SQL_NUMROWS($result) == 0) {
51                 // Add this value (including comment)
52                 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_max_receive (value, comment) VALUES ('%s', '%s')",
53                  array(bigintval($_POST['max']), $_POST['comment']),__FILE__, __LINE__);
54                 $content = "<SPAN class=\"admin_done\">".MAX_VALUE_SAVED."</SPAN>";
55         } else {
56                 // Free memory
57                 SQL_FREERESULT($result);
58
59                 // Value does alread exists!
60                 $content = "<SPAN class=\"admin_failed\">".MAX_VALUE_ALREADY."</SPAN>";
61         }
62
63         // Display message
64         LOAD_TEMPLATE("admin_settings_saved", false, $content);
65 } elseif ((isset($_POST['ok'])) && (isset($_GET['do']))) {
66         // Change or delete entries...
67         $TEXT = "";
68         foreach ($_POST['id'] as $id => $value) {
69                 // Secure ID
70                 $id = bigintval($id);
71
72                 switch ($_GET['do'])
73                 {
74                 case "edit": // Change entries
75                         $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_max_receive SET value='%s', comment='%s' WHERE id=%s LIMIT 1",
76                          array(bigintval($_POST['val'][$id]), $_POST['comm'][$id], $id),__FILE__, __LINE__);
77                         $TEXT = MRECEIVE_SAVED;
78                         break;
79
80                 case "del":
81                         $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_max_receive WHERE id=%s LIMIT 1",
82                          array($id), __FILE__, __LINE__);
83                         $TEXT = MRECEIVE_DELETED;
84                         break;
85                 }
86         }
87
88         if (isset($TEXT)) {
89                 // Display message
90                 LOAD_TEMPLATE("admin_settings_saved", false, $TEXT);
91         }
92 } elseif ((isset($_POST['del'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0])))) {
93         // Delete entries
94         $SW = 2; $OUT = "";
95         foreach ($_POST['sel'] as $id => $value)
96         {
97                 // Load data
98                 $result = SQL_QUERY_ESC("SELECT value, comment FROM "._MYSQL_PREFIX."_max_receive WHERE id=%s LIMIT 1",
99                  array(bigintval($id)), __FILE__, __LINE__);
100                 list($value, $comment) = SQL_FETCHROW($result);
101                 SQL_FREERESULT($result);
102
103                 // Prepare data for the row template
104                 $content = array(
105                         'sw'      => $SW,
106                         'id'      => $id,
107                         'value'   => $value,
108                         'comment' => $comment,
109                 );
110
111                 // Load row template and switch color
112                 $OUT .= LOAD_TEMPLATE("admin_config_email_del_row", true, $content);
113                 $SW = 3 - $SW;
114         }
115         define('__ROWS', $OUT);
116
117         // Load main template
118         LOAD_TEMPLATE("admin_config_email_del");
119 } elseif ((isset($_POST['edit'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0])))) {
120         // Edit entries
121         $SW = 2; $OUT = "";
122         foreach ($_POST['sel'] as $id => $value) {
123                 // Load data
124                 $result = SQL_QUERY_ESC("SELECT value, comment FROM "._MYSQL_PREFIX."_max_receive WHERE id=%s LIMIT 1",
125                  array(bigintval($id)), __FILE__, __LINE__);
126                 list($value, $comment) = SQL_FETCHROW($result);
127                 SQL_FREERESULT($result);
128
129                 // Prepare data for the row template
130                 $content = array(
131                         'sw'      => $SW,
132                         'id'      => $id,
133                         'value'   => $value,
134                         'comment' => $comment,
135                 );
136
137                 // Load row template and switch color
138                 $OUT .= LOAD_TEMPLATE("admin_config_email_edit_row", true, $content);
139                 $SW = 3 - $SW;
140         }
141         define('__ROWS', $OUT);
142
143         // Load main template
144         LOAD_TEMPLATE("admin_config_email_edit");
145 } else {
146         $result = SQL_QUERY("SELECT id, value, comment FROM "._MYSQL_PREFIX."_max_receive ORDER BY value", __FILE__, __LINE__);
147         if (SQL_NUMROWS($result) > 0) {
148                 // List already existing entries for editing
149                 $SW = 2; $OUT = "";
150                 while (list($id, $value, $comment) = SQL_FETCHROW($result)) {
151                         // Prepare data for the row template
152                         $content = array(
153                                 'sw'      => $SW,
154                                 'id'      => $id,
155                                 'value'   => $value,
156                                 'comment' => $comment,
157                         );
158
159                         // Load row template and switch color
160                         $OUT .= LOAD_TEMPLATE("admin_config_email_row", true, $content);
161                         $SW = 3 - $SW;
162                 }
163
164                 // Free memory
165                 SQL_FREERESULT($result);
166                 define('__ROWS', $OUT);
167
168                 // Load main template
169                 LOAD_TEMPLATE("admin_config_email");
170         }
171
172         // Display form
173         LOAD_TEMPLATE("admin_add_max");
174 }
175
176 //
177 ?>