cbdede7a5952f870cb51090470609fdaadd0d8ad
[mailer.git] / 0.2.1 / inc / modules / admin / what-config_email.php
1 <?php\r
2 /************************************************************************\r
3  * MXChange v0.2.1                                    Start: 10/11/2003 *\r
4  * ===============                              Last change: 07/04/2004 *\r
5  *                                                                      *\r
6  * -------------------------------------------------------------------- *\r
7  * File              : what-config_emails.php                           *\r
8  * -------------------------------------------------------------------- *\r
9  * Short description : Edit all things around email and sending         *\r
10  * -------------------------------------------------------------------- *\r
11  * Kurzbeschreibung  : Ă„ndern aller Email-Einstellungen                 *\r
12  * -------------------------------------------------------------------- *\r
13  *                                                                      *\r
14  * -------------------------------------------------------------------- *\r
15  * Copyright (c) 2003 - 2007 by Roland Haeder                           *\r
16  * For more information visit: http://www.mxchange.org                  *\r
17  *                                                                      *\r
18  * This program is free software; you can redistribute it and/or modify *\r
19  * it under the terms of the GNU General Public License as published by *\r
20  * the Free Software Foundation; either version 2 of the License, or    *\r
21  * (at your option) any later version.                                  *\r
22  *                                                                      *\r
23  * This program is distributed in the hope that it will be useful,      *\r
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
26  * GNU General Public License for more details.                         *\r
27  *                                                                      *\r
28  * You should have received a copy of the GNU General Public License    *\r
29  * along with this program; if not, write to the Free Software          *\r
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
31  * MA  02110-1301  USA                                                  *\r
32  ************************************************************************/\r
33 \r
34 // Some security stuff...\r
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))\r
36 {\r
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";\r
38         require($INC);\r
39 }\r
40 // Add description as navigation point\r
41 ADD_DESCR("admin", basename(__FILE__));\r
42 \r
43 OPEN_TABLE("100%", "admin_content admin_content_align", "");\r
44 if (empty($_POST['max'])) unset($_POST['add_max']);\r
45 if (isset($_POST['add_max']))\r
46 {\r
47         // Save all settings\r
48         $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_max_receive WHERE value='%s' LIMIT 1",\r
49          array(bigintval($_POST['max'])), __FILE__, __LINE__);\r
50         if (SQL_NUMROWS($result) == 0)\r
51         {\r
52                 // Add this value (including comment)\r
53                 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_max_receive (value, comment) VALUES ('%s', '%s')",\r
54                  array(bigintval($_POST['max']), stripslashes($_POST['comment'])),__FILE__, __LINE__);\r
55                 $content = "<SPAN class=\"admin_done\">".MAX_VALUE_SAVED."</SPAN>";\r
56         }\r
57          else\r
58         {\r
59                 // Free memory\r
60                 SQL_FREERESULT($result);\r
61 \r
62                 // Value does alread exists!\r
63                 $content = "<SPAN class=\"admin_failed\">".MAX_VALUE_ALREADY."</SPAN>";\r
64         }\r
65 \r
66         // Display message\r
67         LOAD_TEMPLATE("admin_settings_saved", false, $content);\r
68 }\r
69  elseif ((isset($_POST['ok'])) && (isset($_GET['do'])))\r
70 {\r
71         // Change or delete entries...\r
72         $TEXT = "";\r
73         foreach ($_POST['id'] as $id=>$value)\r
74         {\r
75                 // Secure ID\r
76                 $id = bigintval($id);\r
77 \r
78                 switch ($_GET['do'])\r
79                 {\r
80                 case "edit": // Change entries\r
81                         $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_max_receive SET value='%s', comment='%s' WHERE id=%d LIMIT 1",\r
82                          array(bigintval($_POST['val'][$id]), $_POST['comm'][$id], $id),__FILE__, __LINE__);\r
83                         $TEXT = MRECEIVE_SAVED;\r
84                         break;\r
85 \r
86                 case "del":\r
87                         $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_max_receive WHERE id=%d LIMIT 1",\r
88                          array($id), __FILE__, __LINE__);\r
89                         $TEXT = MRECEIVE_DELETED;\r
90                         break;\r
91                 }\r
92         }\r
93         if (isset($TEXT))\r
94         {\r
95                 // Display message\r
96                 LOAD_TEMPLATE("admin_settings_saved", false, $TEXT);\r
97         }\r
98 }\r
99  elseif ((isset($_POST['del'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0]))))\r
100 {\r
101         // Delete entries\r
102         $SW = 2; $OUT = "";\r
103         foreach ($_POST['sel'] as $id=>$value)\r
104         {\r
105                 // Load data\r
106                 $result = SQL_QUERY_ESC("SELECT value, comment FROM "._MYSQL_PREFIX."_max_receive WHERE id=%d LIMIT 1",\r
107                  array(bigintval($id)), __FILE__, __LINE__);\r
108                 list($value, $comment) = SQL_FETCHROW($result);\r
109                 SQL_FREERESULT($result);\r
110 \r
111                 // Prepare data for the row template\r
112                 $content = array(\r
113                         'sw'      => $SW,\r
114                         'id'      => $id,\r
115                         'value'   => $value,\r
116                         'comment' => $comment,\r
117                 );\r
118 \r
119                 // Load row template and switch color\r
120                 $OUT .= LOAD_TEMPLATE("admin_config_email_del_row", true, $content);\r
121                 $SW = 3 - $SW;\r
122         }\r
123         define('__ROWS', $OUT);\r
124 \r
125         // Load main template\r
126         LOAD_TEMPLATE("admin_config_email_del");\r
127 }\r
128  elseif ((isset($_POST['edit'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0]))))\r
129 {\r
130         // Edit entries\r
131         $SW = 2; $OUT = "";\r
132         foreach ($_POST['sel'] as $id=>$value)\r
133         {\r
134                 // Load data\r
135                 $result = SQL_QUERY_ESC("SELECT value, comment FROM "._MYSQL_PREFIX."_max_receive WHERE id=%d LIMIT 1",\r
136                  array(bigintval($id)), __FILE__, __LINE__);\r
137                 list($value, $comment) = SQL_FETCHROW($result);\r
138                 SQL_FREERESULT($result);\r
139 \r
140                 // Prepare data for the row template\r
141                 $content = array(\r
142                         'sw'      => $SW,\r
143                         'id'      => $id,\r
144                         'value'   => $value,\r
145                         'comment' => $comment,\r
146                 );\r
147 \r
148                 // Load row template and switch color\r
149                 $OUT .= LOAD_TEMPLATE("admin_config_email_edit_row", true, $content);\r
150                 $SW = 3 - $SW;\r
151         }\r
152         define('__ROWS', $OUT);\r
153 \r
154         // Load main template\r
155         LOAD_TEMPLATE("admin_config_email_edit");\r
156 }\r
157  else\r
158 {\r
159         $result = SQL_QUERY("SELECT id, value, comment FROM "._MYSQL_PREFIX."_max_receive ORDER BY value", __FILE__, __LINE__);\r
160         if (SQL_NUMROWS($result) > 0)\r
161         {\r
162                 // List already existing entries for editing\r
163                 $SW = 2; $OUT = "";\r
164                 while (list($id, $value, $comment) = SQL_FETCHROW($result))\r
165                 {\r
166                         // Prepare data for the row template\r
167                         $content = array(\r
168                                 'sw'      => $SW,\r
169                                 'id'      => $id,\r
170                                 'value'   => $value,\r
171                                 'comment' => $comment,\r
172                         );\r
173 \r
174                         // Load row template and switch color\r
175                         $OUT .= LOAD_TEMPLATE("admin_config_email_row", true, $content);\r
176                         $SW = 3 - $SW;\r
177                 }\r
178 \r
179                 // Free memory\r
180                 SQL_FREERESULT($result);\r
181                 define('__ROWS', $OUT);\r
182 \r
183                 // Load main template\r
184                 LOAD_TEMPLATE("admin_config_email");\r
185         }\r
186 \r
187         // Display form\r
188         LOAD_TEMPLATE("admin_add_max");\r
189 }\r
190 CLOSE_TABLE();\r
191 //\r
192 ?>\r