root/trunk/gui/admin/admin_edit.php

Revision 1390, 9.2 kB (checked in by simple, 1 month ago)

fix according to http://www.isp-control.net/ispcp/ticket/1564
* clear untechnical message
* including the required length
* message according to config-setting (passwd_strong or not)
changed all files with chk_password and error message in it, as well as the language files base and de_DE to add the string

Line 
1 <?php
2 /**
3  * ispCP ω (OMEGA) a Virtual Hosting Control System
4  *
5  * @copyright     2001-2006 by moleSoftware GmbH
6  * @copyright     2006-2008 by ispCP | http://isp-control.net
7  * @link         http://isp-control.net
8  * @author         ispCP Team (2007)
9  *
10  * @license
11  *   This program is free software; you can redistribute it and/or modify it under
12  *   the terms of the MPL General Public License as published by the Free Software
13  *   Foundation; either version 1.1 of the License, or (at your option) any later
14  *   version.
15  *   You should have received a copy of the MPL Mozilla Public License along with
16  *   this program; if not, write to the Open Source Initiative (OSI)
17  *   http://opensource.org | osi@opensource.org
18  */
19
20 require '../include/ispcp-lib.php';
21
22 check_login(__FILE__);
23
24 if (isset($_GET['edit_id'])) {
25     $edit_id = $_GET['edit_id'];
26 } else if (isset($_POST['edit_id'])) {
27     $edit_id = $_POST['edit_id'];
28 } else {
29     user_goto('manage_users.php');
30 }
31
32 $tpl = new pTemplate();
33 $tpl->define_dynamic('page', Config::get('ADMIN_TEMPLATE_PATH') . '/admin_edit.tpl');
34 $tpl->define_dynamic('page_message', 'page');
35 $tpl->define_dynamic('hosting_plans', 'page');
36
37 $theme_color = Config::get('USER_INITIAL_THEME');
38
39 $tpl->assign(
40         array(
41             'TR_ADMIN_EDIT_USER_PAGE_TITLE' => tr('ispCP - Admin/Manage users/Edit Administrator'),
42             'THEME_COLOR_PATH' => "../themes/$theme_color",
43             'THEME_CHARSET' => tr('encoding'),
44             'ISP_LOGO' => get_logo($_SESSION['user_id']),
45
46             )
47     );
48
49 function update_data(&$sql) {
50     global $edit_id;
51
52     if (isset($_POST['Submit']) && isset($_POST['uaction']) && $_POST['uaction'] === 'edit_user') {
53         if (check_user_data()) {
54             $user_id = $_SESSION['user_id'];
55
56             $fname = clean_input($_POST['fname']);
57             $lname = clean_input($_POST['lname']);
58             $firm = clean_input($_POST['firm']);
59             $gender = clean_input($_POST['gender']);
60             $zip = clean_input($_POST['zip']);
61             $city = clean_input($_POST['city']);
62             $country = clean_input($_POST['country']);
63             $email = clean_input($_POST['email']);
64             $phone = clean_input($_POST['phone']);
65             $fax = clean_input($_POST['fax']);
66             $street1 = clean_input($_POST['street1']);
67             $street2 = clean_input($_POST['street2']);
68
69             if (empty($_POST['pass'])) {
70                 $query = <<<SQL_QUERY
71                         update
72                             admin
73                         set
74                             fname = ?,
75                             lname = ?,
76                             firm = ?,
77                             zip = ?,
78                             city = ?,
79                             country = ?,
80                             email = ?,
81                             phone = ?,
82                             fax = ?,
83                             street1 = ?,
84                             street2 = ?,
85                             gender = ?
86                     where
87                         admin_id = ?
88 SQL_QUERY;
89                 $rs = exec_query($sql, $query, array($fname,
90                         $lname,
91                         $firm,
92                         $zip,
93                         $city,
94                         $country,
95                         $email,
96                         $phone,
97                         $fax,
98                         $street1,
99                         $street2,
100                         $gender,
101                         $edit_id));
102             } else {
103                 $edit_id = $_POST['edit_id'];
104
105                 if ($_POST['pass'] != $_POST['pass_rep']) {
106                     set_page_message(tr("Entered passwords do not match!"));
107
108                     header("Location: admin_edit.php?edit_id=$edit_id");
109                     die();
110                 }
111
112                 if (!chk_password($_POST['pass'])) {
113                     if(Config::get('PASSWD_STRONG')){
114             set_page_message(sprintf(tr('The password must be at least %s long and contain letters and numbers to be valid.'), Config::get('PASSWD_CHARS')));
115           } else {
116             set_page_message(sprintf(tr('Password data is shorter than %s signs or includes not permitted signs!'), Config::get('PASSWD_CHARS')));
117           }
118
119                     header("Location: admin_edit.php?edit_id=$edit_id");
120                     die();
121                 }
122
123                 $upass = crypt_user_pass($_POST['pass']);
124
125                 $query = <<<SQL_QUERY
126                         update
127                             admin
128                         set
129                             admin_pass = ?,
130                             fname = ?,
131                             lname = ?,
132                             firm = ?,
133                             zip = ?,
134                             city = ?,
135                             country = ?,
136                             email = ?,
137                             phone = ?,
138                             fax = ?,
139                             street1 = ?,
140                             street2 = ?,
141                             gender = ?
142                         where
143                             admin_id = ?
144 SQL_QUERY;
145
146                 $rs = exec_query($sql, $query, array($upass,
147                         $fname,
148                         $lname,
149                         $firm,
150                         $zip,
151                         $city,
152                         $country,
153                         $email,
154                         $phone,
155                         $fax,
156                         $street1,
157                         $street2,
158                         $gender,
159                         $edit_id));
160
161                 // Kill any existing session of the edited user
162
163                 $admin_name = get_user_name($edit_id);
164                 $query = <<<SQL_QUERY
165                     delete from
166                         login
167                     where
168                         user_name = ?
169 SQL_QUERY;
170
171                 $rs = exec_query($sql, $query, array($admin_name));
172                 if ($rs->RecordCount() != 0) {
173                     set_page_message(tr('User session was killed!'));
174                     write_log($_SESSION['user_logged'] . " killed " . $admin_name . "'s session because of password change");
175                 }
176             }
177
178             $edit_username = clean_input($_POST['edit_username']);
179
180             $user_logged = $_SESSION['user_logged'];
181
182             write_log("$user_logged: changes data/password for $edit_username!");
183
184             if (isset($_POST['send_data']) && !empty($_POST['pass'])) {
185                 $query = "SELECT admin_type FROM admin WHERE admin_id='" . addslashes(htmlspecialchars($edit_id)) . "'";
186
187                 $res = exec_query($sql, $query, array());
188
189                 if ($res->fields['admin_type'] == 'admin') {
190                     $admin_type = tr('Administrator');
191                 } else if ($res->fields['admin_type'] == 'reseller') {
192                     $admin_type = tr('Reseller');
193                 } else {
194                     $admin_type = tr('Domain account');
195                 }
196
197                 send_add_user_auto_msg ($user_id,
198                     $edit_username,
199                     clean_input($_POST['pass']),
200                     clean_input($_POST['email']),
201                     clean_input($_POST['fname']),
202                     clean_input($_POST['lname']),
203                     tr($admin_type),
204                     $gender);
205             }
206
207             $_SESSION['user_updated'] = 1;
208
209             header("Location: manage_users.php");
210             die();
211         }
212     }
213 }
214
215 function check_user_data() {
216     if (!chk_email($_POST['email'])) {
217         set_page_message(tr("Incorrect email length or syntax!"));
218
219         return false;
220     }
221
222     return true;
223 }
224
225 if ($edit_id == $_SESSION['user_id']) {
226     header('Location: personal_change.php');
227     die();
228 }
229
230 /*
231  *
232  * static page messages.
233  *
234  */
235
236 $query = <<<SQL_QUERY
237     select
238         admin_name,
239         fname,
240         lname,
241         firm,
242         zip,
243         city,
244         country,
245         phone,
246         fax,
247         street1,
248         street2,
249         email,
250         gender
251     from
252         admin
253     where
254         admin_id = ?
255 SQL_QUERY;
256
257 $rs = exec_query($sql, $query, array($edit_id));
258
259 if ($rs->RecordCount() <= 0) {
260     header('Location: manage_users.php');
261     die();
262 }
263
264 gen_admin_mainmenu($tpl, Config::get('ADMIN_TEMPLATE_PATH') . '/main_menu_users_manage.tpl');
265 gen_admin_menu($tpl, Config::get('ADMIN_TEMPLATE_PATH') . '/menu_users_manage.tpl');
266
267 update_data($sql);
268
269 $admin_name = decode_idna($rs->fields['admin_name']);
270
271 if (isset($_POST['genpass'])) {
272     $tpl->assign('VAL_PASSWORD', passgen());
273 } else {
274     $tpl->assign('VAL_PASSWORD', '');
275 }
276
277 $tpl->assign(
278         array(
279             'TR_EMPTY_OR_WORNG_DATA' => tr('Empty data or wrong field!'),
280             'TR_PASSWORD_NOT_MATCH' => tr("Passwords don't match!"),
281             'TR_EDIT_ADMIN' => tr('Edit admin'),
282             'TR_CORE_DATA' => tr('Core data'),
283             'TR_USERNAME' => tr('Username'),
284             'TR_PASSWORD' => tr('Password'),
285             'TR_PASSWORD_REPEAT' => tr('Repeat password'),
286             'TR_EMAIL' => tr('Email'),
287             'TR_ADDITIONAL_DATA' => tr('Additional data'),
288             'TR_FIRST_NAME' => tr('First name'),
289             'TR_LAST_NAME' => tr('Last name'),
290             'TR_COMPANY' => tr('Company'),
291             'TR_ZIP_POSTAL_CODE' => tr('Zip/Postal code'),
292             'TR_CITY' => tr('City'),
293             'TR_COUNTRY' => tr('Country'),
294             'TR_STREET_1' => tr('Street 1'),
295             'TR_STREET_2' => tr('Street 2'),
296             'TR_PHONE' => tr('Phone'),
297             'TR_FAX' => tr('Fax'),
298             'TR_PHONE' => tr('Phone'),
299             'TR_GENDER' => tr('Gender'),
300             'TR_MALE' => tr('Male'),
301             'TR_FEMALE' => tr('Female'),
302             'TR_UNKNOWN' => tr('Unknown'),
303             'TR_UPDATE' => tr('Update'),
304             'TR_SEND_DATA' => tr('Send new login data'),
305             'TR_PASSWORD_GENERATE' => tr('Generate password'),
306
307             'FIRST_NAME' => $rs->fields['fname'],
308             'LAST_NAME' => $rs->fields['lname'],
309             'FIRM' => $rs->fields['firm'],
310             'ZIP' => $rs->fields['zip'],
311             'CITY' => $rs->fields['city'],
312             'COUNTRY' => $rs->fields['country'],
313             'STREET_1' => $rs->fields['street1'],
314             'STREET_2' => $rs->fields['street2'],
315             'PHONE' => $rs->fields['phone'],
316             'FAX' => $rs->fields['fax'],
317             'USERNAME' => $admin_name,
318             'EMAIL' => $rs->fields['email'],
319             'VL_MALE' => (($rs->fields['gender'] === 'M') ? 'selected' : ''),
320             'VL_FEMALE' => (($rs->fields['gender'] === 'F') ? 'selected' : ''),
321             'VL_UNKNOWN' => ((($rs->fields['gender'] === 'U') || (empty($rs->fields['gender']))) ? 'selected' : ''),
322             'EDIT_ID' => $edit_id
323             )
324     );
325
326 gen_page_message($tpl);
327
328 $tpl->parse('PAGE', 'page');
329 $tpl->prnt();
330
331 if (Config::get('DUMP_GUI_DEBUG'))
332     dump_gui_debug();
333
334 unset_messages();
335
336 ?>
Note: See TracBrowser for help on using the browser.