(no commit message)
[mailer.git] / 0.2.1 / 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 {
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 if (empty($_POST['max'])) unset($_POST['add_max']);
45 if (isset($_POST['add_max']))
46 {
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         {
52                 // Add this value (including comment)
53                 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_max_receive (value, comment) VALUES ('%s', '%s')",
54                  array(bigintval($_POST['max']), stripslashes($_POST['comment'])),__FILE__, __LINE__);
55                 $content = "<SPAN class=\"admin_done\">".MAX_VALUE_SAVED."</SPAN>";
56         }
57          else
58         {
59                 // Free memory
60                 SQL_FREERESULT($result);
61
62                 // Value does alread exists!
63                 $content = "<SPAN class=\"admin_failed\">".MAX_VALUE_ALREADY."</SPAN>";
64         }
65
66         // Display message
67         LOAD_TEMPLATE("admin_settings_saved", false, $content);
68 }
69  elseif ((isset($_POST['ok'])) && (isset($_GET['do'])))
70 {
71         // Change or delete entries...
72         $TEXT = "";
73         foreach ($_POST['id'] as $id=>$value)
74         {
75                 // Secure ID
76                 $id = bigintval($id);
77
78                 switch ($_GET['do'])
79                 {
80                 case "edit": // Change entries
81                         $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_max_receive SET value='%s', comment='%s' WHERE id=%d LIMIT 1",
82                          array(bigintval($_POST['val'][$id]), $_POST['comm'][$id], $id),__FILE__, __LINE__);
83                         $TEXT = MRECEIVE_SAVED;
84                         break;
85
86                 case "del":
87                         $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_max_receive WHERE id=%d LIMIT 1",
88                          array($id), __FILE__, __LINE__);
89                         $TEXT = MRECEIVE_DELETED;
90                         break;
91                 }
92         }
93         if (isset($TEXT))
94         {
95                 // Display message
96                 LOAD_TEMPLATE("admin_settings_saved", false, $TEXT);
97         }
98 }
99  elseif ((isset($_POST['del'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0]))))
100 {
101         // Delete entries
102         $SW = 2; $OUT = "";
103         foreach ($_POST['sel'] as $id=>$value)
104         {
105                 // Load data
106                 $result = SQL_QUERY_ESC("SELECT value, comment FROM "._MYSQL_PREFIX."_max_receive WHERE id=%d LIMIT 1",
107                  array(bigintval($id)), __FILE__, __LINE__);
108                 list($value, $comment) = SQL_FETCHROW($result);
109                 SQL_FREERESULT($result);
110
111                 // Prepare data for the row template
112                 $content = array(
113                         'sw'      => $SW,
114                         'id'      => $id,
115                         'value'   => $value,
116                         'comment' => $comment,
117                 );
118
119                 // Load row template and switch color
120                 $OUT .= LOAD_TEMPLATE("admin_config_email_del_row", true, $content);
121                 $SW = 3 - $SW;
122         }
123         define('__ROWS', $OUT);
124
125         // Load main template
126         LOAD_TEMPLATE("admin_config_email_del");
127 }
128  elseif ((isset($_POST['edit'])) && ((SELECTION_COUNT($_POST['sel']) > 0) || (isset($_POST['sel'][0]))))
129 {
130         // Edit entries
131         $SW = 2; $OUT = "";
132         foreach ($_POST['sel'] as $id=>$value)
133         {
134                 // Load data
135                 $result = SQL_QUERY_ESC("SELECT value, comment FROM "._MYSQL_PREFIX."_max_receive WHERE id=%d LIMIT 1",
136                  array(bigintval($id)), __FILE__, __LINE__);
137                 list($value, $comment) = SQL_FETCHROW($result);
138                 SQL_FREERESULT($result);
139
140                 // Prepare data for the row template
141                 $content = array(
142                         'sw'      => $SW,
143                         'id'      => $id,
144                         'value'   => $value,
145                         'comment' => $comment,
146                 );
147
148                 // Load row template and switch color
149                 $OUT .= LOAD_TEMPLATE("admin_config_email_edit_row", true, $content);
150                 $SW = 3 - $SW;
151         }
152         define('__ROWS', $OUT);
153
154         // Load main template
155         LOAD_TEMPLATE("admin_config_email_edit");
156 }
157  else
158 {
159         $result = SQL_QUERY("SELECT id, value, comment FROM "._MYSQL_PREFIX."_max_receive ORDER BY value", __FILE__, __LINE__);
160         if (SQL_NUMROWS($result) > 0)
161         {
162                 // List already existing entries for editing
163                 $SW = 2; $OUT = "";
164                 while (list($id, $value, $comment) = SQL_FETCHROW($result))
165                 {
166                         // Prepare data for the row template
167                         $content = array(
168                                 'sw'      => $SW,
169                                 'id'      => $id,
170                                 'value'   => $value,
171                                 'comment' => $comment,
172                         );
173
174                         // Load row template and switch color
175                         $OUT .= LOAD_TEMPLATE("admin_config_email_row", true, $content);
176                         $SW = 3 - $SW;
177                 }
178
179                 // Free memory
180                 SQL_FREERESULT($result);
181                 define('__ROWS', $OUT);
182
183                 // Load main template
184                 LOAD_TEMPLATE("admin_config_email");
185         }
186
187         // Display form
188         LOAD_TEMPLATE("admin_add_max");
189 }
190 CLOSE_TABLE();
191 //
192 ?>