@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
4 | 4 | } |
5 | 5 | if(!$modx->hasPermission('save_web_user')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $tbl_web_users = $modx->getFullTableName('web_users'); |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | $input = $_POST; |
14 | 14 | foreach($input as $k => $v) { |
15 | - if($k !== 'comment') { |
|
16 | - $v = sanitize($v); |
|
17 | - } |
|
18 | - $input[$k] = $v; |
|
15 | + if($k !== 'comment') { |
|
16 | + $v = sanitize($v); |
|
17 | + } |
|
18 | + $input[$k] = $v; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | $id = (int)$input['id']; |
@@ -51,82 +51,82 @@ discard block |
||
51 | 51 | |
52 | 52 | // verify password |
53 | 53 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
54 | - webAlertAndQuit("Password typed is mismatched"); |
|
54 | + webAlertAndQuit("Password typed is mismatched"); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // verify email |
58 | 58 | if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
59 | - webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
59 | + webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | switch($input['mode']) { |
63 | - case '87' : // new user |
|
64 | - // check if this user name already exist |
|
65 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
66 | - $limit = $modx->db->getValue($rs); |
|
67 | - if($limit > 0) { |
|
68 | - webAlertAndQuit("User name is already in use!"); |
|
69 | - } |
|
70 | - |
|
71 | - // check if the email address already exist |
|
72 | - if ($modx->config['allow_multiple_emails'] != 1) { |
|
73 | - $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
74 | - $limit = $modx->db->getValue($rs); |
|
75 | - if($limit > 0) { |
|
76 | - webAlertAndQuit("Email is already in use!"); |
|
77 | - } |
|
78 | - } |
|
79 | - |
|
80 | - // generate a new password for this user |
|
81 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
82 | - if(strlen($specifiedpassword) < 6) { |
|
83 | - webAlertAndQuit("Password is too short!"); |
|
84 | - } else { |
|
85 | - $newpassword = $specifiedpassword; |
|
86 | - } |
|
87 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
88 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
89 | - } elseif($passwordgenmethod == 'g') { |
|
90 | - $newpassword = generate_password(8); |
|
91 | - } else { |
|
92 | - webAlertAndQuit("No password generation method specified!"); |
|
93 | - } |
|
94 | - |
|
95 | - // invoke OnBeforeWUsrFormSave event |
|
96 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
97 | - "mode" => "new", |
|
98 | - )); |
|
99 | - |
|
100 | - // create the user account |
|
101 | - $field = array(); |
|
102 | - $field['username'] = $esc_newusername; |
|
103 | - $field['password'] = md5($newpassword); |
|
104 | - $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
105 | - |
|
106 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
107 | - $field = $modx->db->escape($field); |
|
108 | - $modx->db->insert($field, $tbl_web_user_attributes); |
|
109 | - |
|
110 | - // Save User Settings |
|
111 | - saveUserSettings($internalKey); |
|
112 | - |
|
113 | - // Set the item name for logger |
|
114 | - $_SESSION['itemname'] = $newusername; |
|
115 | - |
|
116 | - /*******************************************************************************/ |
|
117 | - // put the user in the user_groups he/ she should be in |
|
118 | - // first, check that up_perms are switched on! |
|
119 | - if($use_udperms == 1) { |
|
120 | - if(!empty($user_groups)) { |
|
121 | - for($i = 0; $i < count($user_groups); $i++) { |
|
122 | - $f = array(); |
|
123 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
124 | - $f['webuser'] = $internalKey; |
|
125 | - $modx->db->insert($f, $tbl_web_groups); |
|
126 | - } |
|
127 | - } |
|
128 | - } |
|
129 | - // end of user_groups stuff! |
|
63 | + case '87' : // new user |
|
64 | + // check if this user name already exist |
|
65 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
66 | + $limit = $modx->db->getValue($rs); |
|
67 | + if($limit > 0) { |
|
68 | + webAlertAndQuit("User name is already in use!"); |
|
69 | + } |
|
70 | + |
|
71 | + // check if the email address already exist |
|
72 | + if ($modx->config['allow_multiple_emails'] != 1) { |
|
73 | + $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'"); |
|
74 | + $limit = $modx->db->getValue($rs); |
|
75 | + if($limit > 0) { |
|
76 | + webAlertAndQuit("Email is already in use!"); |
|
77 | + } |
|
78 | + } |
|
79 | + |
|
80 | + // generate a new password for this user |
|
81 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
82 | + if(strlen($specifiedpassword) < 6) { |
|
83 | + webAlertAndQuit("Password is too short!"); |
|
84 | + } else { |
|
85 | + $newpassword = $specifiedpassword; |
|
86 | + } |
|
87 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
88 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
89 | + } elseif($passwordgenmethod == 'g') { |
|
90 | + $newpassword = generate_password(8); |
|
91 | + } else { |
|
92 | + webAlertAndQuit("No password generation method specified!"); |
|
93 | + } |
|
94 | + |
|
95 | + // invoke OnBeforeWUsrFormSave event |
|
96 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
97 | + "mode" => "new", |
|
98 | + )); |
|
99 | + |
|
100 | + // create the user account |
|
101 | + $field = array(); |
|
102 | + $field['username'] = $esc_newusername; |
|
103 | + $field['password'] = md5($newpassword); |
|
104 | + $internalKey = $modx->db->insert($field, $tbl_web_users); |
|
105 | + |
|
106 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
107 | + $field = $modx->db->escape($field); |
|
108 | + $modx->db->insert($field, $tbl_web_user_attributes); |
|
109 | + |
|
110 | + // Save User Settings |
|
111 | + saveUserSettings($internalKey); |
|
112 | + |
|
113 | + // Set the item name for logger |
|
114 | + $_SESSION['itemname'] = $newusername; |
|
115 | + |
|
116 | + /*******************************************************************************/ |
|
117 | + // put the user in the user_groups he/ she should be in |
|
118 | + // first, check that up_perms are switched on! |
|
119 | + if($use_udperms == 1) { |
|
120 | + if(!empty($user_groups)) { |
|
121 | + for($i = 0; $i < count($user_groups); $i++) { |
|
122 | + $f = array(); |
|
123 | + $f['webgroup'] = (int)$user_groups[$i]; |
|
124 | + $f['webuser'] = $internalKey; |
|
125 | + $modx->db->insert($f, $tbl_web_groups); |
|
126 | + } |
|
127 | + } |
|
128 | + } |
|
129 | + // end of user_groups stuff! |
|
130 | 130 | |
131 | 131 | // invoke OnWebSaveUser event |
132 | 132 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -144,26 +144,26 @@ discard block |
||
144 | 144 | "id" => $internalKey |
145 | 145 | )); |
146 | 146 | |
147 | - if($passwordnotifymethod == 'e') { |
|
148 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
149 | - if($input['stay'] != '') { |
|
150 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
151 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
152 | - header($header); |
|
153 | - } else { |
|
154 | - $header = "Location: index.php?a=99&r=2"; |
|
155 | - header($header); |
|
156 | - } |
|
157 | - } else { |
|
158 | - if($input['stay'] != '') { |
|
159 | - $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
160 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
161 | - } else { |
|
162 | - $stayUrl = "index.php?a=99&r=2"; |
|
163 | - } |
|
164 | - |
|
165 | - include_once "header.inc.php"; |
|
166 | - ?> |
|
147 | + if($passwordnotifymethod == 'e') { |
|
148 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
149 | + if($input['stay'] != '') { |
|
150 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
151 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
152 | + header($header); |
|
153 | + } else { |
|
154 | + $header = "Location: index.php?a=99&r=2"; |
|
155 | + header($header); |
|
156 | + } |
|
157 | + } else { |
|
158 | + if($input['stay'] != '') { |
|
159 | + $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87"; |
|
160 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
161 | + } else { |
|
162 | + $stayUrl = "index.php?a=99&r=2"; |
|
163 | + } |
|
164 | + |
|
165 | + include_once "header.inc.php"; |
|
166 | + ?> |
|
167 | 167 | |
168 | 168 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
169 | 169 | |
@@ -185,86 +185,86 @@ discard block |
||
185 | 185 | </div> |
186 | 186 | <?php |
187 | 187 | |
188 | - include_once "footer.inc.php"; |
|
189 | - } |
|
190 | - break; |
|
191 | - case '88' : // edit user |
|
192 | - // generate a new password for this user |
|
193 | - if($genpassword == 1) { |
|
194 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
195 | - if(strlen($specifiedpassword) < 6) { |
|
196 | - webAlertAndQuit("Password is too short!"); |
|
197 | - } else { |
|
198 | - $newpassword = $specifiedpassword; |
|
199 | - } |
|
200 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
201 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
202 | - } elseif($passwordgenmethod == 'g') { |
|
203 | - $newpassword = generate_password(8); |
|
204 | - } else { |
|
205 | - webAlertAndQuit("No password generation method specified!"); |
|
206 | - } |
|
207 | - } |
|
208 | - if($passwordnotifymethod == 'e') { |
|
209 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
210 | - } |
|
211 | - |
|
212 | - // check if the username already exist |
|
213 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
214 | - $limit = $modx->db->getValue($rs); |
|
215 | - if($limit > 0) { |
|
216 | - webAlertAndQuit("User name is already in use!"); |
|
217 | - } |
|
218 | - |
|
219 | - // check if the email address already exists |
|
220 | - if ($modx->config['allow_multiple_emails'] != 1) { |
|
221 | - $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
222 | - $limit = $modx->db->getValue($rs); |
|
223 | - if($limit > 0) { |
|
224 | - webAlertAndQuit("Email is already in use!"); |
|
225 | - } |
|
226 | - } |
|
227 | - |
|
228 | - // invoke OnBeforeWUsrFormSave event |
|
229 | - $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
230 | - "mode" => "upd", |
|
231 | - "id" => $id |
|
232 | - )); |
|
233 | - |
|
234 | - // update user name and password |
|
235 | - $field = array(); |
|
236 | - $field['username'] = $esc_newusername; |
|
237 | - if($genpassword == 1) { |
|
238 | - $field['password'] = md5($newpassword); |
|
239 | - } |
|
240 | - $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
241 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
242 | - $field = $modx->db->escape($field); |
|
243 | - $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
244 | - |
|
245 | - // Save User Settings |
|
246 | - saveUserSettings($id); |
|
247 | - |
|
248 | - // Set the item name for logger |
|
249 | - $_SESSION['itemname'] = $newusername; |
|
250 | - |
|
251 | - /*******************************************************************************/ |
|
252 | - // put the user in the user_groups he/ she should be in |
|
253 | - // first, check that up_perms are switched on! |
|
254 | - if($use_udperms == 1) { |
|
255 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
256 | - $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
257 | - if(!empty($user_groups)) { |
|
258 | - for($i = 0; $i < count($user_groups); $i++) { |
|
259 | - $field = array(); |
|
260 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
261 | - $field['webuser'] = $id; |
|
262 | - $modx->db->insert($field, $tbl_web_groups); |
|
263 | - } |
|
264 | - } |
|
265 | - } |
|
266 | - // end of user_groups stuff! |
|
267 | - /*******************************************************************************/ |
|
188 | + include_once "footer.inc.php"; |
|
189 | + } |
|
190 | + break; |
|
191 | + case '88' : // edit user |
|
192 | + // generate a new password for this user |
|
193 | + if($genpassword == 1) { |
|
194 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
195 | + if(strlen($specifiedpassword) < 6) { |
|
196 | + webAlertAndQuit("Password is too short!"); |
|
197 | + } else { |
|
198 | + $newpassword = $specifiedpassword; |
|
199 | + } |
|
200 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
201 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
202 | + } elseif($passwordgenmethod == 'g') { |
|
203 | + $newpassword = generate_password(8); |
|
204 | + } else { |
|
205 | + webAlertAndQuit("No password generation method specified!"); |
|
206 | + } |
|
207 | + } |
|
208 | + if($passwordnotifymethod == 'e') { |
|
209 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
210 | + } |
|
211 | + |
|
212 | + // check if the username already exist |
|
213 | + $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'"); |
|
214 | + $limit = $modx->db->getValue($rs); |
|
215 | + if($limit > 0) { |
|
216 | + webAlertAndQuit("User name is already in use!"); |
|
217 | + } |
|
218 | + |
|
219 | + // check if the email address already exists |
|
220 | + if ($modx->config['allow_multiple_emails'] != 1) { |
|
221 | + $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'"); |
|
222 | + $limit = $modx->db->getValue($rs); |
|
223 | + if($limit > 0) { |
|
224 | + webAlertAndQuit("Email is already in use!"); |
|
225 | + } |
|
226 | + } |
|
227 | + |
|
228 | + // invoke OnBeforeWUsrFormSave event |
|
229 | + $modx->invokeEvent("OnBeforeWUsrFormSave", array( |
|
230 | + "mode" => "upd", |
|
231 | + "id" => $id |
|
232 | + )); |
|
233 | + |
|
234 | + // update user name and password |
|
235 | + $field = array(); |
|
236 | + $field['username'] = $esc_newusername; |
|
237 | + if($genpassword == 1) { |
|
238 | + $field['password'] = md5($newpassword); |
|
239 | + } |
|
240 | + $modx->db->update($field, $tbl_web_users, "id='{$id}'"); |
|
241 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
242 | + $field = $modx->db->escape($field); |
|
243 | + $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'"); |
|
244 | + |
|
245 | + // Save User Settings |
|
246 | + saveUserSettings($id); |
|
247 | + |
|
248 | + // Set the item name for logger |
|
249 | + $_SESSION['itemname'] = $newusername; |
|
250 | + |
|
251 | + /*******************************************************************************/ |
|
252 | + // put the user in the user_groups he/ she should be in |
|
253 | + // first, check that up_perms are switched on! |
|
254 | + if($use_udperms == 1) { |
|
255 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
256 | + $modx->db->delete($tbl_web_groups, "webuser='{$id}'"); |
|
257 | + if(!empty($user_groups)) { |
|
258 | + for($i = 0; $i < count($user_groups); $i++) { |
|
259 | + $field = array(); |
|
260 | + $field['webgroup'] = (int)$user_groups[$i]; |
|
261 | + $field['webuser'] = $id; |
|
262 | + $modx->db->insert($field, $tbl_web_groups); |
|
263 | + } |
|
264 | + } |
|
265 | + } |
|
266 | + // end of user_groups stuff! |
|
267 | + /*******************************************************************************/ |
|
268 | 268 | |
269 | 269 | // invoke OnWebSaveUser event |
270 | 270 | $modx->invokeEvent("OnWebSaveUser", array( |
@@ -293,16 +293,16 @@ discard block |
||
293 | 293 | "id" => $id |
294 | 294 | )); |
295 | 295 | |
296 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
297 | - if($input['stay'] != '') { |
|
298 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
299 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
300 | - } else { |
|
301 | - $stayUrl = "index.php?a=99&r=2"; |
|
302 | - } |
|
296 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
297 | + if($input['stay'] != '') { |
|
298 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
299 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
300 | + } else { |
|
301 | + $stayUrl = "index.php?a=99&r=2"; |
|
302 | + } |
|
303 | 303 | |
304 | - include_once "header.inc.php"; |
|
305 | - ?> |
|
304 | + include_once "header.inc.php"; |
|
305 | + ?> |
|
306 | 306 | |
307 | 307 | <h1><?php echo $_lang['web_user_title']; ?></h1> |
308 | 308 | |
@@ -322,20 +322,20 @@ discard block |
||
322 | 322 | </div> |
323 | 323 | <?php |
324 | 324 | |
325 | - include_once "footer.inc.php"; |
|
326 | - } else { |
|
327 | - if($input['stay'] != '') { |
|
328 | - $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
329 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
330 | - header($header); |
|
331 | - } else { |
|
332 | - $header = "Location: index.php?a=99&r=2"; |
|
333 | - header($header); |
|
334 | - } |
|
335 | - } |
|
336 | - break; |
|
337 | - default : |
|
338 | - webAlertAndQuit("No operation set in request."); |
|
325 | + include_once "footer.inc.php"; |
|
326 | + } else { |
|
327 | + if($input['stay'] != '') { |
|
328 | + $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; |
|
329 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
330 | + header($header); |
|
331 | + } else { |
|
332 | + $header = "Location: index.php?a=99&r=2"; |
|
333 | + header($header); |
|
334 | + } |
|
335 | + } |
|
336 | + break; |
|
337 | + default : |
|
338 | + webAlertAndQuit("No operation set in request."); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -345,14 +345,14 @@ discard block |
||
345 | 345 | * @return string |
346 | 346 | */ |
347 | 347 | function save_user_quoted_printable($string) { |
348 | - $crlf = "\n"; |
|
349 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
350 | - $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
351 | - $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
352 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
353 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
354 | - $string = preg_replace($f, $r, $string); |
|
355 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
348 | + $crlf = "\n"; |
|
349 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
350 | + $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
351 | + $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
352 | + $f[] = '/([\011\040])' . $crlf . '/e'; |
|
353 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
354 | + $string = preg_replace($f, $r, $string); |
|
355 | + return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -364,94 +364,94 @@ discard block |
||
364 | 364 | * @param string $ufn |
365 | 365 | */ |
366 | 366 | function sendMailMessage($email, $uid, $pwd, $ufn) { |
367 | - global $modx, $_lang, $websignupemail_message; |
|
368 | - global $emailsubject, $emailsender; |
|
369 | - global $site_name, $site_url; |
|
370 | - $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
371 | - // replace placeholders |
|
372 | - $message = str_replace("[+uid+]", $uid, $message); |
|
373 | - $message = str_replace("[+pwd+]", $pwd, $message); |
|
374 | - $message = str_replace("[+ufn+]", $ufn, $message); |
|
375 | - $message = str_replace("[+sname+]", $site_name, $message); |
|
376 | - $message = str_replace("[+saddr+]", $emailsender, $message); |
|
377 | - $message = str_replace("[+semail+]", $emailsender, $message); |
|
378 | - $message = str_replace("[+surl+]", $site_url, $message); |
|
379 | - |
|
380 | - $param = array(); |
|
381 | - $param['from'] = "{$site_name}<{$emailsender}>"; |
|
382 | - $param['subject'] = $emailsubject; |
|
383 | - $param['body'] = $message; |
|
384 | - $param['to'] = $email; |
|
385 | - $param['type'] = 'text'; |
|
386 | - $rs = $modx->sendmail($param); |
|
387 | - if(!$rs) { |
|
388 | - $modx->manager->saveFormValues(); |
|
389 | - $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
390 | - } |
|
367 | + global $modx, $_lang, $websignupemail_message; |
|
368 | + global $emailsubject, $emailsender; |
|
369 | + global $site_name, $site_url; |
|
370 | + $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
371 | + // replace placeholders |
|
372 | + $message = str_replace("[+uid+]", $uid, $message); |
|
373 | + $message = str_replace("[+pwd+]", $pwd, $message); |
|
374 | + $message = str_replace("[+ufn+]", $ufn, $message); |
|
375 | + $message = str_replace("[+sname+]", $site_name, $message); |
|
376 | + $message = str_replace("[+saddr+]", $emailsender, $message); |
|
377 | + $message = str_replace("[+semail+]", $emailsender, $message); |
|
378 | + $message = str_replace("[+surl+]", $site_url, $message); |
|
379 | + |
|
380 | + $param = array(); |
|
381 | + $param['from'] = "{$site_name}<{$emailsender}>"; |
|
382 | + $param['subject'] = $emailsubject; |
|
383 | + $param['body'] = $message; |
|
384 | + $param['to'] = $email; |
|
385 | + $param['type'] = 'text'; |
|
386 | + $rs = $modx->sendmail($param); |
|
387 | + if(!$rs) { |
|
388 | + $modx->manager->saveFormValues(); |
|
389 | + $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
390 | + } |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | // Save User Settings |
394 | 394 | function saveUserSettings($id) { |
395 | - global $modx; |
|
396 | - $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
397 | - |
|
398 | - $settings = array( |
|
399 | - "login_home", |
|
400 | - "allowed_ip", |
|
401 | - "allowed_days" |
|
402 | - ); |
|
403 | - |
|
404 | - $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
405 | - |
|
406 | - foreach($settings as $n) { |
|
407 | - $vl = $_POST[$n]; |
|
408 | - if(is_array($vl)) { |
|
409 | - $vl = implode(",", $vl); |
|
410 | - } |
|
411 | - if($vl != '') { |
|
412 | - $f = array(); |
|
413 | - $f['webuser'] = $id; |
|
414 | - $f['setting_name'] = $n; |
|
415 | - $f['setting_value'] = $vl; |
|
416 | - $f = $modx->db->escape($f); |
|
417 | - $modx->db->insert($f, $tbl_web_user_settings); |
|
418 | - } |
|
419 | - } |
|
395 | + global $modx; |
|
396 | + $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
397 | + |
|
398 | + $settings = array( |
|
399 | + "login_home", |
|
400 | + "allowed_ip", |
|
401 | + "allowed_days" |
|
402 | + ); |
|
403 | + |
|
404 | + $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
405 | + |
|
406 | + foreach($settings as $n) { |
|
407 | + $vl = $_POST[$n]; |
|
408 | + if(is_array($vl)) { |
|
409 | + $vl = implode(",", $vl); |
|
410 | + } |
|
411 | + if($vl != '') { |
|
412 | + $f = array(); |
|
413 | + $f['webuser'] = $id; |
|
414 | + $f['setting_name'] = $n; |
|
415 | + $f['setting_value'] = $vl; |
|
416 | + $f = $modx->db->escape($f); |
|
417 | + $modx->db->insert($f, $tbl_web_user_settings); |
|
418 | + } |
|
419 | + } |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | // Web alert - sends an alert to web browser |
423 | 423 | function webAlertAndQuit($msg) { |
424 | - global $id, $modx; |
|
425 | - $mode = $_POST['mode']; |
|
426 | - $modx->manager->saveFormValues($mode); |
|
427 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
424 | + global $id, $modx; |
|
425 | + $mode = $_POST['mode']; |
|
426 | + $modx->manager->saveFormValues($mode); |
|
427 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | // Generate password |
431 | 431 | function generate_password($length = 10) { |
432 | - $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
433 | - $ps_len = strlen($allowable_characters); |
|
434 | - mt_srand((double) microtime() * 1000000); |
|
435 | - $pass = ""; |
|
436 | - for($i = 0; $i < $length; $i++) { |
|
437 | - $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
438 | - } |
|
439 | - return $pass; |
|
432 | + $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
433 | + $ps_len = strlen($allowable_characters); |
|
434 | + mt_srand((double) microtime() * 1000000); |
|
435 | + $pass = ""; |
|
436 | + for($i = 0; $i < $length; $i++) { |
|
437 | + $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
438 | + } |
|
439 | + return $pass; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | function sanitize($str = '', $safecount = 0) { |
443 | - global $modx; |
|
444 | - $safecount++; |
|
445 | - if(1000 < $safecount) { |
|
446 | - exit("error too many loops '{$safecount}'"); |
|
447 | - } |
|
448 | - if(is_array($str)) { |
|
449 | - foreach($str as $i => $v) { |
|
450 | - $str[$i] = sanitize($v, $safecount); |
|
451 | - } |
|
452 | - } else { |
|
453 | - // $str = strip_tags($str); // LEAVE < and > intact |
|
454 | - $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
455 | - } |
|
456 | - return $str; |
|
443 | + global $modx; |
|
444 | + $safecount++; |
|
445 | + if(1000 < $safecount) { |
|
446 | + exit("error too many loops '{$safecount}'"); |
|
447 | + } |
|
448 | + if(is_array($str)) { |
|
449 | + foreach($str as $i => $v) { |
|
450 | + $str[$i] = sanitize($v, $safecount); |
|
451 | + } |
|
452 | + } else { |
|
453 | + // $str = strip_tags($str); // LEAVE < and > intact |
|
454 | + $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
455 | + } |
|
456 | + return $str; |
|
457 | 457 | } |