Completed
Pull Request — develop (#518)
by Agel_Nash
05:24
created
manager/processors/save_web_user.processor.php 4 patches
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if(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
 block discarded – undo
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 = intval($input['id']);
@@ -51,80 +51,80 @@  discard block
 block discarded – undo
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
-		$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73
-		$limit = $modx->db->getValue($rs);
74
-		if($limit > 0) {
75
-			webAlertAndQuit("Email is already in use!");
76
-		}
77
-
78
-		// generate a new password for this user
79
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
-			if(strlen($specifiedpassword) < 6) {
81
-				webAlertAndQuit("Password is too short!");
82
-			} else {
83
-				$newpassword = $specifiedpassword;
84
-			}
85
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
86
-			webAlertAndQuit("You didn't specify a password for this user!");
87
-		} elseif($passwordgenmethod == 'g') {
88
-			$newpassword = generate_password(8);
89
-		} else {
90
-			webAlertAndQuit("No password generation method specified!");
91
-		}
92
-
93
-		// invoke OnBeforeWUsrFormSave event
94
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
95
-			"mode" => "new",
96
-		));
97
-
98
-		// create the user account
99
-		$field = array();
100
-		$field['username'] = $esc_newusername;
101
-		$field['password'] = md5($newpassword);
102
-		$internalKey = $modx->db->insert($field, $tbl_web_users);
103
-
104
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
105
-		$field = $modx->db->escape($field);
106
-		$modx->db->insert($field, $tbl_web_user_attributes);
107
-
108
-		// Save User Settings
109
-		saveUserSettings($internalKey);
110
-
111
-		// Set the item name for logger
112
-		$_SESSION['itemname'] = $newusername;
113
-
114
-		/*******************************************************************************/
115
-		// put the user in the user_groups he/ she should be in
116
-		// first, check that up_perms are switched on!
117
-		if($use_udperms == 1) {
118
-			if(!empty($user_groups)) {
119
-				for($i = 0; $i < count($user_groups); $i++) {
120
-					$f = array();
121
-					$f['webgroup'] = intval($user_groups[$i]);
122
-					$f['webuser'] = $internalKey;
123
-					$modx->db->insert($f, $tbl_web_groups);
124
-				}
125
-			}
126
-		}
127
-		// 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
+        $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73
+        $limit = $modx->db->getValue($rs);
74
+        if($limit > 0) {
75
+            webAlertAndQuit("Email is already in use!");
76
+        }
77
+
78
+        // generate a new password for this user
79
+        if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
+            if(strlen($specifiedpassword) < 6) {
81
+                webAlertAndQuit("Password is too short!");
82
+            } else {
83
+                $newpassword = $specifiedpassword;
84
+            }
85
+        } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
86
+            webAlertAndQuit("You didn't specify a password for this user!");
87
+        } elseif($passwordgenmethod == 'g') {
88
+            $newpassword = generate_password(8);
89
+        } else {
90
+            webAlertAndQuit("No password generation method specified!");
91
+        }
92
+
93
+        // invoke OnBeforeWUsrFormSave event
94
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
95
+            "mode" => "new",
96
+        ));
97
+
98
+        // create the user account
99
+        $field = array();
100
+        $field['username'] = $esc_newusername;
101
+        $field['password'] = md5($newpassword);
102
+        $internalKey = $modx->db->insert($field, $tbl_web_users);
103
+
104
+        $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
105
+        $field = $modx->db->escape($field);
106
+        $modx->db->insert($field, $tbl_web_user_attributes);
107
+
108
+        // Save User Settings
109
+        saveUserSettings($internalKey);
110
+
111
+        // Set the item name for logger
112
+        $_SESSION['itemname'] = $newusername;
113
+
114
+        /*******************************************************************************/
115
+        // put the user in the user_groups he/ she should be in
116
+        // first, check that up_perms are switched on!
117
+        if($use_udperms == 1) {
118
+            if(!empty($user_groups)) {
119
+                for($i = 0; $i < count($user_groups); $i++) {
120
+                    $f = array();
121
+                    $f['webgroup'] = intval($user_groups[$i]);
122
+                    $f['webuser'] = $internalKey;
123
+                    $modx->db->insert($f, $tbl_web_groups);
124
+                }
125
+            }
126
+        }
127
+        // end of user_groups stuff!
128 128
 
129 129
         // invoke OnWebSaveUser event
130 130
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -142,26 +142,26 @@  discard block
 block discarded – undo
142 142
             "id" => $internalKey
143 143
         ));
144 144
 
145
-		if($passwordnotifymethod == 'e') {
146
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
147
-			if($input['stay'] != '') {
148
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
150
-				header($header);
151
-			} else {
152
-				$header = "Location: index.php?a=99&r=2";
153
-				header($header);
154
-			}
155
-		} else {
156
-			if($input['stay'] != '') {
157
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
159
-			} else {
160
-				$stayUrl = "index.php?a=99&r=2";
161
-			}
162
-
163
-			include_once "header.inc.php";
164
-			?>
145
+        if($passwordnotifymethod == 'e') {
146
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
147
+            if($input['stay'] != '') {
148
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
150
+                header($header);
151
+            } else {
152
+                $header = "Location: index.php?a=99&r=2";
153
+                header($header);
154
+            }
155
+        } else {
156
+            if($input['stay'] != '') {
157
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
159
+            } else {
160
+                $stayUrl = "index.php?a=99&r=2";
161
+            }
162
+
163
+            include_once "header.inc.php";
164
+            ?>
165 165
 
166 166
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
167 167
 
@@ -183,84 +183,84 @@  discard block
 block discarded – undo
183 183
 			</div>
184 184
 			<?php
185 185
 
186
-			include_once "footer.inc.php";
187
-		}
188
-		break;
189
-	case '88' : // edit user
190
-		// generate a new password for this user
191
-		if($genpassword == 1) {
192
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
-				if(strlen($specifiedpassword) < 6) {
194
-					webAlertAndQuit("Password is too short!");
195
-				} else {
196
-					$newpassword = $specifiedpassword;
197
-				}
198
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
199
-				webAlertAndQuit("You didn't specify a password for this user!");
200
-			} elseif($passwordgenmethod == 'g') {
201
-				$newpassword = generate_password(8);
202
-			} else {
203
-				webAlertAndQuit("No password generation method specified!");
204
-			}
205
-		}
206
-		if($passwordnotifymethod == 'e') {
207
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
208
-		}
209
-
210
-		// check if the username already exist
211
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212
-		$limit = $modx->db->getValue($rs);
213
-		if($limit > 0) {
214
-			webAlertAndQuit("User name is already in use!");
215
-		}
216
-
217
-		// check if the email address already exists
218
-		$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219
-		$limit = $modx->db->getValue($rs);
220
-		if($limit > 0) {
221
-			webAlertAndQuit("Email is already in use!");
222
-		}
223
-
224
-		// invoke OnBeforeWUsrFormSave event
225
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
226
-			"mode" => "upd",
227
-			"id" => $id
228
-		));
229
-
230
-		// update user name and password
231
-		$field = array();
232
-		$field['username'] = $esc_newusername;
233
-		if($genpassword == 1) {
234
-			$field['password'] = md5($newpassword);
235
-		}
236
-		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
237
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
238
-		$field = $modx->db->escape($field);
239
-		$modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
240
-
241
-		// Save User Settings
242
-		saveUserSettings($id);
243
-
244
-		// Set the item name for logger
245
-		$_SESSION['itemname'] = $newusername;
246
-
247
-		/*******************************************************************************/
248
-		// put the user in the user_groups he/ she should be in
249
-		// first, check that up_perms are switched on!
250
-		if($use_udperms == 1) {
251
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
252
-			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
-			if(!empty($user_groups)) {
254
-				for($i = 0; $i < count($user_groups); $i++) {
255
-					$field = array();
256
-					$field['webgroup'] = intval($user_groups[$i]);
257
-					$field['webuser'] = $id;
258
-					$modx->db->insert($field, $tbl_web_groups);
259
-				}
260
-			}
261
-		}
262
-		// end of user_groups stuff!
263
-		/*******************************************************************************/
186
+            include_once "footer.inc.php";
187
+        }
188
+        break;
189
+    case '88' : // edit user
190
+        // generate a new password for this user
191
+        if($genpassword == 1) {
192
+            if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
+                if(strlen($specifiedpassword) < 6) {
194
+                    webAlertAndQuit("Password is too short!");
195
+                } else {
196
+                    $newpassword = $specifiedpassword;
197
+                }
198
+            } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
199
+                webAlertAndQuit("You didn't specify a password for this user!");
200
+            } elseif($passwordgenmethod == 'g') {
201
+                $newpassword = generate_password(8);
202
+            } else {
203
+                webAlertAndQuit("No password generation method specified!");
204
+            }
205
+        }
206
+        if($passwordnotifymethod == 'e') {
207
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
208
+        }
209
+
210
+        // check if the username already exist
211
+        $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212
+        $limit = $modx->db->getValue($rs);
213
+        if($limit > 0) {
214
+            webAlertAndQuit("User name is already in use!");
215
+        }
216
+
217
+        // check if the email address already exists
218
+        $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219
+        $limit = $modx->db->getValue($rs);
220
+        if($limit > 0) {
221
+            webAlertAndQuit("Email is already in use!");
222
+        }
223
+
224
+        // invoke OnBeforeWUsrFormSave event
225
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
226
+            "mode" => "upd",
227
+            "id" => $id
228
+        ));
229
+
230
+        // update user name and password
231
+        $field = array();
232
+        $field['username'] = $esc_newusername;
233
+        if($genpassword == 1) {
234
+            $field['password'] = md5($newpassword);
235
+        }
236
+        $modx->db->update($field, $tbl_web_users, "id='{$id}'");
237
+        $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
238
+        $field = $modx->db->escape($field);
239
+        $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
240
+
241
+        // Save User Settings
242
+        saveUserSettings($id);
243
+
244
+        // Set the item name for logger
245
+        $_SESSION['itemname'] = $newusername;
246
+
247
+        /*******************************************************************************/
248
+        // put the user in the user_groups he/ she should be in
249
+        // first, check that up_perms are switched on!
250
+        if($use_udperms == 1) {
251
+            // as this is an existing user, delete his/ her entries in the groups before saving the new groups
252
+            $modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
+            if(!empty($user_groups)) {
254
+                for($i = 0; $i < count($user_groups); $i++) {
255
+                    $field = array();
256
+                    $field['webgroup'] = intval($user_groups[$i]);
257
+                    $field['webuser'] = $id;
258
+                    $modx->db->insert($field, $tbl_web_groups);
259
+                }
260
+            }
261
+        }
262
+        // end of user_groups stuff!
263
+        /*******************************************************************************/
264 264
 
265 265
         // invoke OnWebSaveUser event
266 266
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -289,16 +289,16 @@  discard block
 block discarded – undo
289 289
             "id" => $id
290 290
         ));
291 291
 
292
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
293
-			if($input['stay'] != '') {
294
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
296
-			} else {
297
-				$stayUrl = "index.php?a=99&r=2";
298
-			}
292
+        if($genpassword == 1 && $passwordnotifymethod == 's') {
293
+            if($input['stay'] != '') {
294
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
296
+            } else {
297
+                $stayUrl = "index.php?a=99&r=2";
298
+            }
299 299
 
300
-			include_once "header.inc.php";
301
-			?>
300
+            include_once "header.inc.php";
301
+            ?>
302 302
 
303 303
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
304 304
 
@@ -318,124 +318,124 @@  discard block
 block discarded – undo
318 318
 			</div>
319 319
 			<?php
320 320
 
321
-			include_once "footer.inc.php";
322
-		} else {
323
-			if($input['stay'] != '') {
324
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
326
-				header($header);
327
-			} else {
328
-				$header = "Location: index.php?a=99&r=2";
329
-				header($header);
330
-			}
331
-		}
332
-		break;
333
-	default :
334
-		webAlertAndQuit("No operation set in request.");
321
+            include_once "footer.inc.php";
322
+        } else {
323
+            if($input['stay'] != '') {
324
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
326
+                header($header);
327
+            } else {
328
+                $header = "Location: index.php?a=99&r=2";
329
+                header($header);
330
+            }
331
+        }
332
+        break;
333
+    default :
334
+        webAlertAndQuit("No operation set in request.");
335 335
 }
336 336
 
337 337
 // in case any plugins include a quoted_printable function
338 338
 function save_user_quoted_printable($string) {
339
-	$crlf = "\n";
340
-	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
341
-	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
342
-	$r[] = "'=' . sprintf('%02X', ord('\\1'))";
343
-	$f[] = '/([\011\040])' . $crlf . '/e';
344
-	$r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
345
-	$string = preg_replace($f, $r, $string);
346
-	return trim(wordwrap($string, 70, ' =' . $crlf));
339
+    $crlf = "\n";
340
+    $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
341
+    $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
342
+    $r[] = "'=' . sprintf('%02X', ord('\\1'))";
343
+    $f[] = '/([\011\040])' . $crlf . '/e';
344
+    $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
345
+    $string = preg_replace($f, $r, $string);
346
+    return trim(wordwrap($string, 70, ' =' . $crlf));
347 347
 }
348 348
 
349 349
 // Send an email to the user
350 350
 function sendMailMessage($email, $uid, $pwd, $ufn) {
351
-	global $modx, $_lang, $websignupemail_message;
352
-	global $emailsubject, $emailsender;
353
-	global $site_name, $site_url;
354
-	$message = sprintf($websignupemail_message, $uid, $pwd); // use old method
355
-	// replace placeholders
356
-	$message = str_replace("[+uid+]", $uid, $message);
357
-	$message = str_replace("[+pwd+]", $pwd, $message);
358
-	$message = str_replace("[+ufn+]", $ufn, $message);
359
-	$message = str_replace("[+sname+]", $site_name, $message);
360
-	$message = str_replace("[+saddr+]", $emailsender, $message);
361
-	$message = str_replace("[+semail+]", $emailsender, $message);
362
-	$message = str_replace("[+surl+]", $site_url, $message);
363
-
364
-	$param = array();
365
-	$param['from'] = "{$site_name}<{$emailsender}>";
366
-	$param['subject'] = $emailsubject;
367
-	$param['body'] = $message;
368
-	$param['to'] = $email;
369
-	$param['type'] = 'text';
370
-	$rs = $modx->sendmail($param);
371
-	if(!$rs) {
372
-		$modx->manager->saveFormValues();
373
-		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
374
-	}
351
+    global $modx, $_lang, $websignupemail_message;
352
+    global $emailsubject, $emailsender;
353
+    global $site_name, $site_url;
354
+    $message = sprintf($websignupemail_message, $uid, $pwd); // use old method
355
+    // replace placeholders
356
+    $message = str_replace("[+uid+]", $uid, $message);
357
+    $message = str_replace("[+pwd+]", $pwd, $message);
358
+    $message = str_replace("[+ufn+]", $ufn, $message);
359
+    $message = str_replace("[+sname+]", $site_name, $message);
360
+    $message = str_replace("[+saddr+]", $emailsender, $message);
361
+    $message = str_replace("[+semail+]", $emailsender, $message);
362
+    $message = str_replace("[+surl+]", $site_url, $message);
363
+
364
+    $param = array();
365
+    $param['from'] = "{$site_name}<{$emailsender}>";
366
+    $param['subject'] = $emailsubject;
367
+    $param['body'] = $message;
368
+    $param['to'] = $email;
369
+    $param['type'] = 'text';
370
+    $rs = $modx->sendmail($param);
371
+    if(!$rs) {
372
+        $modx->manager->saveFormValues();
373
+        $modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
374
+    }
375 375
 }
376 376
 
377 377
 // Save User Settings
378 378
 function saveUserSettings($id) {
379
-	global $modx;
380
-	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
381
-
382
-	$settings = array(
383
-		"login_home",
384
-		"allowed_ip",
385
-		"allowed_days"
386
-	);
387
-
388
-	$modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
389
-
390
-	foreach($settings as $n) {
391
-		$vl = $_POST[$n];
392
-		if(is_array($vl)) {
393
-			$vl = implode(",", $vl);
394
-		}
395
-		if($vl != '') {
396
-			$f = array();
397
-			$f['webuser'] = $id;
398
-			$f['setting_name'] = $n;
399
-			$f['setting_value'] = $vl;
400
-			$f = $modx->db->escape($f);
401
-			$modx->db->insert($f, $tbl_web_user_settings);
402
-		}
403
-	}
379
+    global $modx;
380
+    $tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
381
+
382
+    $settings = array(
383
+        "login_home",
384
+        "allowed_ip",
385
+        "allowed_days"
386
+    );
387
+
388
+    $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
389
+
390
+    foreach($settings as $n) {
391
+        $vl = $_POST[$n];
392
+        if(is_array($vl)) {
393
+            $vl = implode(",", $vl);
394
+        }
395
+        if($vl != '') {
396
+            $f = array();
397
+            $f['webuser'] = $id;
398
+            $f['setting_name'] = $n;
399
+            $f['setting_value'] = $vl;
400
+            $f = $modx->db->escape($f);
401
+            $modx->db->insert($f, $tbl_web_user_settings);
402
+        }
403
+    }
404 404
 }
405 405
 
406 406
 // Web alert -  sends an alert to web browser
407 407
 function webAlertAndQuit($msg) {
408
-	global $id, $modx;
409
-	$mode = $_POST['mode'];
410
-	$modx->manager->saveFormValues($mode);
411
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
408
+    global $id, $modx;
409
+    $mode = $_POST['mode'];
410
+    $modx->manager->saveFormValues($mode);
411
+    $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
412 412
 }
413 413
 
414 414
 // Generate password
415 415
 function generate_password($length = 10) {
416
-	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
417
-	$ps_len = strlen($allowable_characters);
418
-	mt_srand((double) microtime() * 1000000);
419
-	$pass = "";
420
-	for($i = 0; $i < $length; $i++) {
421
-		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
422
-	}
423
-	return $pass;
416
+    $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
417
+    $ps_len = strlen($allowable_characters);
418
+    mt_srand((double) microtime() * 1000000);
419
+    $pass = "";
420
+    for($i = 0; $i < $length; $i++) {
421
+        $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
422
+    }
423
+    return $pass;
424 424
 }
425 425
 
426 426
 function sanitize($str = '', $safecount = 0) {
427
-	global $modx;
428
-	$safecount++;
429
-	if(1000 < $safecount) {
430
-		exit("error too many loops '{$safecount}'");
431
-	}
432
-	if(is_array($str)) {
433
-		foreach($str as $i => $v) {
434
-			$str[$i] = sanitize($v, $safecount);
435
-		}
436
-	} else {
437
-		// $str = strip_tags($str); // LEAVE < and > intact
438
-		$str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']);
439
-	}
440
-	return $str;
427
+    global $modx;
428
+    $safecount++;
429
+    if(1000 < $safecount) {
430
+        exit("error too many loops '{$safecount}'");
431
+    }
432
+    if(is_array($str)) {
433
+        foreach($str as $i => $v) {
434
+            $str[$i] = sanitize($v, $safecount);
435
+        }
436
+    } else {
437
+        // $str = strip_tags($str); // LEAVE < and > intact
438
+        $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']);
439
+    }
440
+    return $str;
441 441
 }
Please login to merge, or discard this patch.
Switch Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -60,108 +60,108 @@  discard block
 block discarded – undo
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
-		$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73
-		$limit = $modx->db->getValue($rs);
74
-		if($limit > 0) {
75
-			webAlertAndQuit("Email is already in use!");
76
-		}
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
+		    $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73
+		    $limit = $modx->db->getValue($rs);
74
+		    if($limit > 0) {
75
+			    webAlertAndQuit("Email is already in use!");
76
+		    }
77
+
78
+		    // generate a new password for this user
79
+		    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
+			    if(strlen($specifiedpassword) < 6) {
81
+				    webAlertAndQuit("Password is too short!");
82
+			    } else {
83
+				    $newpassword = $specifiedpassword;
84
+			    }
85
+		    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
86
+			    webAlertAndQuit("You didn't specify a password for this user!");
87
+		    } elseif($passwordgenmethod == 'g') {
88
+			    $newpassword = generate_password(8);
89
+		    } else {
90
+			    webAlertAndQuit("No password generation method specified!");
91
+		    }
92
+
93
+		    // invoke OnBeforeWUsrFormSave event
94
+		    $modx->invokeEvent("OnBeforeWUsrFormSave", array(
95
+			    "mode" => "new",
96
+		    ));
97
+
98
+		    // create the user account
99
+		    $field = array();
100
+		    $field['username'] = $esc_newusername;
101
+		    $field['password'] = md5($newpassword);
102
+		    $internalKey = $modx->db->insert($field, $tbl_web_users);
103
+
104
+		    $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
105
+		    $field = $modx->db->escape($field);
106
+		    $modx->db->insert($field, $tbl_web_user_attributes);
107
+
108
+		    // Save User Settings
109
+		    saveUserSettings($internalKey);
110
+
111
+		    // Set the item name for logger
112
+		    $_SESSION['itemname'] = $newusername;
113
+
114
+		    /*******************************************************************************/
115
+		    // put the user in the user_groups he/ she should be in
116
+		    // first, check that up_perms are switched on!
117
+		    if($use_udperms == 1) {
118
+			    if(!empty($user_groups)) {
119
+				    for($i = 0; $i < count($user_groups); $i++) {
120
+					    $f = array();
121
+					    $f['webgroup'] = intval($user_groups[$i]);
122
+					    $f['webuser'] = $internalKey;
123
+					    $modx->db->insert($f, $tbl_web_groups);
124
+				    }
125
+			    }
126
+		    }
127
+		    // end of user_groups stuff!
128
+
129
+            // invoke OnWebSaveUser event
130
+            $modx->invokeEvent("OnWebSaveUser", array(
131
+                "mode" => "new",
132
+                "userid" => $internalKey,
133
+                "username" => $newusername,
134
+                "userpassword" => $newpassword,
135
+                "useremail" => $email,
136
+                "userfullname" => $fullname
137
+            ));
77 138
 
78
-		// generate a new password for this user
79
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
-			if(strlen($specifiedpassword) < 6) {
81
-				webAlertAndQuit("Password is too short!");
82
-			} else {
83
-				$newpassword = $specifiedpassword;
84
-			}
85
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
86
-			webAlertAndQuit("You didn't specify a password for this user!");
87
-		} elseif($passwordgenmethod == 'g') {
88
-			$newpassword = generate_password(8);
89
-		} else {
90
-			webAlertAndQuit("No password generation method specified!");
91
-		}
139
+            // invoke OnWUsrFormSave event
140
+            $modx->invokeEvent("OnWUsrFormSave", array(
141
+                "mode" => "new",
142
+                "id" => $internalKey
143
+            ));
92 144
 
93
-		// invoke OnBeforeWUsrFormSave event
94
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
95
-			"mode" => "new",
96
-		));
97
-
98
-		// create the user account
99
-		$field = array();
100
-		$field['username'] = $esc_newusername;
101
-		$field['password'] = md5($newpassword);
102
-		$internalKey = $modx->db->insert($field, $tbl_web_users);
103
-
104
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
105
-		$field = $modx->db->escape($field);
106
-		$modx->db->insert($field, $tbl_web_user_attributes);
107
-
108
-		// Save User Settings
109
-		saveUserSettings($internalKey);
110
-
111
-		// Set the item name for logger
112
-		$_SESSION['itemname'] = $newusername;
113
-
114
-		/*******************************************************************************/
115
-		// put the user in the user_groups he/ she should be in
116
-		// first, check that up_perms are switched on!
117
-		if($use_udperms == 1) {
118
-			if(!empty($user_groups)) {
119
-				for($i = 0; $i < count($user_groups); $i++) {
120
-					$f = array();
121
-					$f['webgroup'] = intval($user_groups[$i]);
122
-					$f['webuser'] = $internalKey;
123
-					$modx->db->insert($f, $tbl_web_groups);
124
-				}
125
-			}
126
-		}
127
-		// end of user_groups stuff!
128
-
129
-        // invoke OnWebSaveUser event
130
-        $modx->invokeEvent("OnWebSaveUser", array(
131
-            "mode" => "new",
132
-            "userid" => $internalKey,
133
-            "username" => $newusername,
134
-            "userpassword" => $newpassword,
135
-            "useremail" => $email,
136
-            "userfullname" => $fullname
137
-        ));
138
-
139
-        // invoke OnWUsrFormSave event
140
-        $modx->invokeEvent("OnWUsrFormSave", array(
141
-            "mode" => "new",
142
-            "id" => $internalKey
143
-        ));
144
-
145
-		if($passwordnotifymethod == 'e') {
146
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
147
-			if($input['stay'] != '') {
148
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
150
-				header($header);
151
-			} else {
152
-				$header = "Location: index.php?a=99&r=2";
153
-				header($header);
154
-			}
155
-		} else {
156
-			if($input['stay'] != '') {
157
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
159
-			} else {
160
-				$stayUrl = "index.php?a=99&r=2";
161
-			}
162
-
163
-			include_once "header.inc.php";
164
-			?>
145
+		    if($passwordnotifymethod == 'e') {
146
+			    sendMailMessage($email, $newusername, $newpassword, $fullname);
147
+			    if($input['stay'] != '') {
148
+				    $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
150
+				    header($header);
151
+			    } else {
152
+				    $header = "Location: index.php?a=99&r=2";
153
+				    header($header);
154
+			    }
155
+		    } else {
156
+			    if($input['stay'] != '') {
157
+				    $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
159
+			    } else {
160
+				    $stayUrl = "index.php?a=99&r=2";
161
+			    }
162
+
163
+			    include_once "header.inc.php";
164
+			    ?>
165 165
 
166 166
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
167 167
 
@@ -183,122 +183,122 @@  discard block
 block discarded – undo
183 183
 			</div>
184 184
 			<?php
185 185
 
186
-			include_once "footer.inc.php";
187
-		}
188
-		break;
189
-	case '88' : // edit user
190
-		// generate a new password for this user
191
-		if($genpassword == 1) {
192
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
-				if(strlen($specifiedpassword) < 6) {
194
-					webAlertAndQuit("Password is too short!");
195
-				} else {
196
-					$newpassword = $specifiedpassword;
197
-				}
198
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
199
-				webAlertAndQuit("You didn't specify a password for this user!");
200
-			} elseif($passwordgenmethod == 'g') {
201
-				$newpassword = generate_password(8);
202
-			} else {
203
-				webAlertAndQuit("No password generation method specified!");
204
-			}
205
-		}
206
-		if($passwordnotifymethod == 'e') {
207
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
208
-		}
209
-
210
-		// check if the username already exist
211
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212
-		$limit = $modx->db->getValue($rs);
213
-		if($limit > 0) {
214
-			webAlertAndQuit("User name is already in use!");
215
-		}
216
-
217
-		// check if the email address already exists
218
-		$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219
-		$limit = $modx->db->getValue($rs);
220
-		if($limit > 0) {
221
-			webAlertAndQuit("Email is already in use!");
222
-		}
223
-
224
-		// invoke OnBeforeWUsrFormSave event
225
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
226
-			"mode" => "upd",
227
-			"id" => $id
228
-		));
229
-
230
-		// update user name and password
231
-		$field = array();
232
-		$field['username'] = $esc_newusername;
233
-		if($genpassword == 1) {
234
-			$field['password'] = md5($newpassword);
235
-		}
236
-		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
237
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
238
-		$field = $modx->db->escape($field);
239
-		$modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
240
-
241
-		// Save User Settings
242
-		saveUserSettings($id);
243
-
244
-		// Set the item name for logger
245
-		$_SESSION['itemname'] = $newusername;
246
-
247
-		/*******************************************************************************/
248
-		// put the user in the user_groups he/ she should be in
249
-		// first, check that up_perms are switched on!
250
-		if($use_udperms == 1) {
251
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
252
-			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
-			if(!empty($user_groups)) {
254
-				for($i = 0; $i < count($user_groups); $i++) {
255
-					$field = array();
256
-					$field['webgroup'] = intval($user_groups[$i]);
257
-					$field['webuser'] = $id;
258
-					$modx->db->insert($field, $tbl_web_groups);
259
-				}
260
-			}
261
-		}
262
-		// end of user_groups stuff!
263
-		/*******************************************************************************/
264
-
265
-        // invoke OnWebSaveUser event
266
-        $modx->invokeEvent("OnWebSaveUser", array(
267
-            "mode" => "upd",
268
-            "userid" => $id,
269
-            "username" => $newusername,
270
-            "userpassword" => $newpassword,
271
-            "useremail" => $email,
272
-            "userfullname" => $fullname,
273
-            "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
274
-            "olduseremail" => (($oldemail != $email) ? $oldemail : "")
275
-        ));
276
-
277
-        // invoke OnWebChangePassword event
278
-        if($genpassword == 1) {
279
-            $modx->invokeEvent("OnWebChangePassword", array(
186
+			    include_once "footer.inc.php";
187
+		    }
188
+		    break;
189
+	    case '88' : // edit user
190
+		    // generate a new password for this user
191
+		    if($genpassword == 1) {
192
+			    if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
+				    if(strlen($specifiedpassword) < 6) {
194
+					    webAlertAndQuit("Password is too short!");
195
+				    } else {
196
+					    $newpassword = $specifiedpassword;
197
+				    }
198
+			    } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
199
+				    webAlertAndQuit("You didn't specify a password for this user!");
200
+			    } elseif($passwordgenmethod == 'g') {
201
+				    $newpassword = generate_password(8);
202
+			    } else {
203
+				    webAlertAndQuit("No password generation method specified!");
204
+			    }
205
+		    }
206
+		    if($passwordnotifymethod == 'e') {
207
+			    sendMailMessage($email, $newusername, $newpassword, $fullname);
208
+		    }
209
+
210
+		    // check if the username already exist
211
+		    $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212
+		    $limit = $modx->db->getValue($rs);
213
+		    if($limit > 0) {
214
+			    webAlertAndQuit("User name is already in use!");
215
+		    }
216
+
217
+		    // check if the email address already exists
218
+		    $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219
+		    $limit = $modx->db->getValue($rs);
220
+		    if($limit > 0) {
221
+			    webAlertAndQuit("Email is already in use!");
222
+		    }
223
+
224
+		    // invoke OnBeforeWUsrFormSave event
225
+		    $modx->invokeEvent("OnBeforeWUsrFormSave", array(
226
+			    "mode" => "upd",
227
+			    "id" => $id
228
+		    ));
229
+
230
+		    // update user name and password
231
+		    $field = array();
232
+		    $field['username'] = $esc_newusername;
233
+		    if($genpassword == 1) {
234
+			    $field['password'] = md5($newpassword);
235
+		    }
236
+		    $modx->db->update($field, $tbl_web_users, "id='{$id}'");
237
+		    $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
238
+		    $field = $modx->db->escape($field);
239
+		    $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
240
+
241
+		    // Save User Settings
242
+		    saveUserSettings($id);
243
+
244
+		    // Set the item name for logger
245
+		    $_SESSION['itemname'] = $newusername;
246
+
247
+		    /*******************************************************************************/
248
+		    // put the user in the user_groups he/ she should be in
249
+		    // first, check that up_perms are switched on!
250
+		    if($use_udperms == 1) {
251
+			    // as this is an existing user, delete his/ her entries in the groups before saving the new groups
252
+			    $modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
+			    if(!empty($user_groups)) {
254
+				    for($i = 0; $i < count($user_groups); $i++) {
255
+					    $field = array();
256
+					    $field['webgroup'] = intval($user_groups[$i]);
257
+					    $field['webuser'] = $id;
258
+					    $modx->db->insert($field, $tbl_web_groups);
259
+				    }
260
+			    }
261
+		    }
262
+		    // end of user_groups stuff!
263
+		    /*******************************************************************************/
264
+
265
+            // invoke OnWebSaveUser event
266
+            $modx->invokeEvent("OnWebSaveUser", array(
267
+                "mode" => "upd",
280 268
                 "userid" => $id,
281 269
                 "username" => $newusername,
282
-                "userpassword" => $newpassword
270
+                "userpassword" => $newpassword,
271
+                "useremail" => $email,
272
+                "userfullname" => $fullname,
273
+                "oldusername" => (($oldusername != $newusername) ? $oldusername : ""),
274
+                "olduseremail" => (($oldemail != $email) ? $oldemail : "")
283 275
             ));
284
-        }
285 276
 
286
-        // invoke OnWUsrFormSave event
287
-        $modx->invokeEvent("OnWUsrFormSave", array(
288
-            "mode" => "upd",
289
-            "id" => $id
290
-        ));
277
+            // invoke OnWebChangePassword event
278
+            if($genpassword == 1) {
279
+                $modx->invokeEvent("OnWebChangePassword", array(
280
+                    "userid" => $id,
281
+                    "username" => $newusername,
282
+                    "userpassword" => $newpassword
283
+                ));
284
+            }
285
+
286
+            // invoke OnWUsrFormSave event
287
+            $modx->invokeEvent("OnWUsrFormSave", array(
288
+                "mode" => "upd",
289
+                "id" => $id
290
+            ));
291 291
 
292
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
293
-			if($input['stay'] != '') {
294
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
296
-			} else {
297
-				$stayUrl = "index.php?a=99&r=2";
298
-			}
292
+		    if($genpassword == 1 && $passwordnotifymethod == 's') {
293
+			    if($input['stay'] != '') {
294
+				    $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
+				    $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
296
+			    } else {
297
+				    $stayUrl = "index.php?a=99&r=2";
298
+			    }
299 299
 
300
-			include_once "header.inc.php";
301
-			?>
300
+			    include_once "header.inc.php";
301
+			    ?>
302 302
 
303 303
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
304 304
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
 			</div>
319 319
 			<?php
320 320
 
321
-			include_once "footer.inc.php";
322
-		} else {
323
-			if($input['stay'] != '') {
324
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
326
-				header($header);
327
-			} else {
328
-				$header = "Location: index.php?a=99&r=2";
329
-				header($header);
330
-			}
331
-		}
332
-		break;
333
-	default :
334
-		webAlertAndQuit("No operation set in request.");
321
+			    include_once "footer.inc.php";
322
+		    } else {
323
+			    if($input['stay'] != '') {
324
+				    $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
+				    $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
326
+				    header($header);
327
+			    } else {
328
+				    $header = "Location: index.php?a=99&r=2";
329
+				    header($header);
330
+			    }
331
+		    }
332
+		    break;
333
+	    default :
334
+		    webAlertAndQuit("No operation set in request.");
335 335
 }
336 336
 
337 337
 // in case any plugins include a quoted_printable function
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(IN_MANAGER_MODE != "true") {
2
+if (IN_MANAGER_MODE != "true") {
3 3
 	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5
-if(!$modx->hasPermission('save_web_user')) {
5
+if (!$modx->hasPermission('save_web_user')) {
6 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
 $tbl_web_groups = $modx->getFullTableName('web_groups');
12 12
 
13 13
 $input = $_POST;
14
-foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
14
+foreach ($input as $k => $v) {
15
+	if ($k !== 'comment') {
16 16
 		$v = sanitize($v);
17 17
 	}
18 18
 	$input[$k] = $v;
@@ -50,41 +50,41 @@  discard block
 block discarded – undo
50 50
 $user_groups = $input['user_groups'];
51 51
 
52 52
 // verify password
53
-if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
53
+if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54 54
 	webAlertAndQuit("Password typed is mismatched");
55 55
 }
56 56
 
57 57
 // verify email
58
-if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
58
+if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
59 59
 	webAlertAndQuit("E-mail address doesn't seem to be valid!");
60 60
 }
61 61
 
62
-switch($input['mode']) {
62
+switch ($input['mode']) {
63 63
 	case '87' : // new user
64 64
 		// check if this user name already exist
65 65
 		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66 66
 		$limit = $modx->db->getValue($rs);
67
-		if($limit > 0) {
67
+		if ($limit > 0) {
68 68
 			webAlertAndQuit("User name is already in use!");
69 69
 		}
70 70
 
71 71
 		// check if the email address already exist
72 72
 		$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73 73
 		$limit = $modx->db->getValue($rs);
74
-		if($limit > 0) {
74
+		if ($limit > 0) {
75 75
 			webAlertAndQuit("Email is already in use!");
76 76
 		}
77 77
 
78 78
 		// generate a new password for this user
79
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
-			if(strlen($specifiedpassword) < 6) {
79
+		if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
+			if (strlen($specifiedpassword) < 6) {
81 81
 				webAlertAndQuit("Password is too short!");
82 82
 			} else {
83 83
 				$newpassword = $specifiedpassword;
84 84
 			}
85
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
85
+		} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
86 86
 			webAlertAndQuit("You didn't specify a password for this user!");
87
-		} elseif($passwordgenmethod == 'g') {
87
+		} elseif ($passwordgenmethod == 'g') {
88 88
 			$newpassword = generate_password(8);
89 89
 		} else {
90 90
 			webAlertAndQuit("No password generation method specified!");
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 		/*******************************************************************************/
115 115
 		// put the user in the user_groups he/ she should be in
116 116
 		// first, check that up_perms are switched on!
117
-		if($use_udperms == 1) {
118
-			if(!empty($user_groups)) {
119
-				for($i = 0; $i < count($user_groups); $i++) {
117
+		if ($use_udperms == 1) {
118
+			if (!empty($user_groups)) {
119
+				for ($i = 0; $i < count($user_groups); $i++) {
120 120
 					$f = array();
121 121
 					$f['webgroup'] = intval($user_groups[$i]);
122 122
 					$f['webuser'] = $internalKey;
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
             "id" => $internalKey
143 143
         ));
144 144
 
145
-		if($passwordnotifymethod == 'e') {
145
+		if ($passwordnotifymethod == 'e') {
146 146
 			sendMailMessage($email, $newusername, $newpassword, $fullname);
147
-			if($input['stay'] != '') {
147
+			if ($input['stay'] != '') {
148 148
 				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
149
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
150 150
 				header($header);
151 151
 			} else {
152 152
 				$header = "Location: index.php?a=99&r=2";
153 153
 				header($header);
154 154
 			}
155 155
 		} else {
156
-			if($input['stay'] != '') {
156
+			if ($input['stay'] != '') {
157 157
 				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
158
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
159 159
 			} else {
160 160
 				$stayUrl = "index.php?a=99&r=2";
161 161
 			}
@@ -188,36 +188,36 @@  discard block
 block discarded – undo
188 188
 		break;
189 189
 	case '88' : // edit user
190 190
 		// generate a new password for this user
191
-		if($genpassword == 1) {
192
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
-				if(strlen($specifiedpassword) < 6) {
191
+		if ($genpassword == 1) {
192
+			if ($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
+				if (strlen($specifiedpassword) < 6) {
194 194
 					webAlertAndQuit("Password is too short!");
195 195
 				} else {
196 196
 					$newpassword = $specifiedpassword;
197 197
 				}
198
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
198
+			} elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") {
199 199
 				webAlertAndQuit("You didn't specify a password for this user!");
200
-			} elseif($passwordgenmethod == 'g') {
200
+			} elseif ($passwordgenmethod == 'g') {
201 201
 				$newpassword = generate_password(8);
202 202
 			} else {
203 203
 				webAlertAndQuit("No password generation method specified!");
204 204
 			}
205 205
 		}
206
-		if($passwordnotifymethod == 'e') {
206
+		if ($passwordnotifymethod == 'e') {
207 207
 			sendMailMessage($email, $newusername, $newpassword, $fullname);
208 208
 		}
209 209
 
210 210
 		// check if the username already exist
211 211
 		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212 212
 		$limit = $modx->db->getValue($rs);
213
-		if($limit > 0) {
213
+		if ($limit > 0) {
214 214
 			webAlertAndQuit("User name is already in use!");
215 215
 		}
216 216
 
217 217
 		// check if the email address already exists
218 218
 		$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219 219
 		$limit = $modx->db->getValue($rs);
220
-		if($limit > 0) {
220
+		if ($limit > 0) {
221 221
 			webAlertAndQuit("Email is already in use!");
222 222
 		}
223 223
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		// update user name and password
231 231
 		$field = array();
232 232
 		$field['username'] = $esc_newusername;
233
-		if($genpassword == 1) {
233
+		if ($genpassword == 1) {
234 234
 			$field['password'] = md5($newpassword);
235 235
 		}
236 236
 		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
 		/*******************************************************************************/
248 248
 		// put the user in the user_groups he/ she should be in
249 249
 		// first, check that up_perms are switched on!
250
-		if($use_udperms == 1) {
250
+		if ($use_udperms == 1) {
251 251
 			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
252 252
 			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
-			if(!empty($user_groups)) {
254
-				for($i = 0; $i < count($user_groups); $i++) {
253
+			if (!empty($user_groups)) {
254
+				for ($i = 0; $i < count($user_groups); $i++) {
255 255
 					$field = array();
256 256
 					$field['webgroup'] = intval($user_groups[$i]);
257 257
 					$field['webuser'] = $id;
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         ));
276 276
 
277 277
         // invoke OnWebChangePassword event
278
-        if($genpassword == 1) {
278
+        if ($genpassword == 1) {
279 279
             $modx->invokeEvent("OnWebChangePassword", array(
280 280
                 "userid" => $id,
281 281
                 "username" => $newusername,
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
             "id" => $id
290 290
         ));
291 291
 
292
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
293
-			if($input['stay'] != '') {
292
+		if ($genpassword == 1 && $passwordnotifymethod == 's') {
293
+			if ($input['stay'] != '') {
294 294
 				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
295
+				$stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay'];
296 296
 			} else {
297 297
 				$stayUrl = "index.php?a=99&r=2";
298 298
 			}
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
 
321 321
 			include_once "footer.inc.php";
322 322
 		} else {
323
-			if($input['stay'] != '') {
323
+			if ($input['stay'] != '') {
324 324
 				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
325
+				$header = "Location: index.php?a={$a}&r=2&stay=".$input['stay'];
326 326
 				header($header);
327 327
 			} else {
328 328
 				$header = "Location: index.php?a=99&r=2";
@@ -335,19 +335,19 @@  discard block
 block discarded – undo
335 335
 }
336 336
 
337 337
 // in case any plugins include a quoted_printable function
338
-function save_user_quoted_printable($string) {
338
+function save_user_quoted_printable($string){
339 339
 	$crlf = "\n";
340
-	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
340
+	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string).$crlf;
341 341
 	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
342 342
 	$r[] = "'=' . sprintf('%02X', ord('\\1'))";
343
-	$f[] = '/([\011\040])' . $crlf . '/e';
344
-	$r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
343
+	$f[] = '/([\011\040])'.$crlf.'/e';
344
+	$r[] = "'=' . sprintf('%02X', ord('\\1')) . '".$crlf."'";
345 345
 	$string = preg_replace($f, $r, $string);
346
-	return trim(wordwrap($string, 70, ' =' . $crlf));
346
+	return trim(wordwrap($string, 70, ' ='.$crlf));
347 347
 }
348 348
 
349 349
 // Send an email to the user
350
-function sendMailMessage($email, $uid, $pwd, $ufn) {
350
+function sendMailMessage($email, $uid, $pwd, $ufn){
351 351
 	global $modx, $_lang, $websignupemail_message;
352 352
 	global $emailsubject, $emailsender;
353 353
 	global $site_name, $site_url;
@@ -368,14 +368,14 @@  discard block
 block discarded – undo
368 368
 	$param['to'] = $email;
369 369
 	$param['type'] = 'text';
370 370
 	$rs = $modx->sendmail($param);
371
-	if(!$rs) {
371
+	if (!$rs) {
372 372
 		$modx->manager->saveFormValues();
373 373
 		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
374 374
 	}
375 375
 }
376 376
 
377 377
 // Save User Settings
378
-function saveUserSettings($id) {
378
+function saveUserSettings($id){
379 379
 	global $modx;
380 380
 	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
381 381
 
@@ -387,12 +387,12 @@  discard block
 block discarded – undo
387 387
 
388 388
 	$modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
389 389
 
390
-	foreach($settings as $n) {
390
+	foreach ($settings as $n) {
391 391
 		$vl = $_POST[$n];
392
-		if(is_array($vl)) {
392
+		if (is_array($vl)) {
393 393
 			$vl = implode(",", $vl);
394 394
 		}
395
-		if($vl != '') {
395
+		if ($vl != '') {
396 396
 			$f = array();
397 397
 			$f['webuser'] = $id;
398 398
 			$f['setting_name'] = $n;
@@ -404,33 +404,33 @@  discard block
 block discarded – undo
404 404
 }
405 405
 
406 406
 // Web alert -  sends an alert to web browser
407
-function webAlertAndQuit($msg) {
407
+function webAlertAndQuit($msg){
408 408
 	global $id, $modx;
409 409
 	$mode = $_POST['mode'];
410 410
 	$modx->manager->saveFormValues($mode);
411
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
411
+	$modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '88' ? "&id={$id}" : ''));
412 412
 }
413 413
 
414 414
 // Generate password
415
-function generate_password($length = 10) {
415
+function generate_password($length = 10){
416 416
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
417 417
 	$ps_len = strlen($allowable_characters);
418 418
 	mt_srand((double) microtime() * 1000000);
419 419
 	$pass = "";
420
-	for($i = 0; $i < $length; $i++) {
420
+	for ($i = 0; $i < $length; $i++) {
421 421
 		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
422 422
 	}
423 423
 	return $pass;
424 424
 }
425 425
 
426
-function sanitize($str = '', $safecount = 0) {
426
+function sanitize($str = '', $safecount = 0){
427 427
 	global $modx;
428 428
 	$safecount++;
429
-	if(1000 < $safecount) {
429
+	if (1000 < $safecount) {
430 430
 		exit("error too many loops '{$safecount}'");
431 431
 	}
432
-	if(is_array($str)) {
433
-		foreach($str as $i => $v) {
432
+	if (is_array($str)) {
433
+		foreach ($str as $i => $v) {
434 434
 			$str[$i] = sanitize($v, $safecount);
435 435
 		}
436 436
 	} else {
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -335,7 +335,8 @@  discard block
 block discarded – undo
335 335
 }
336 336
 
337 337
 // in case any plugins include a quoted_printable function
338
-function save_user_quoted_printable($string) {
338
+function save_user_quoted_printable($string)
339
+{
339 340
 	$crlf = "\n";
340 341
 	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
341 342
 	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
@@ -347,7 +348,8 @@  discard block
 block discarded – undo
347 348
 }
348 349
 
349 350
 // Send an email to the user
350
-function sendMailMessage($email, $uid, $pwd, $ufn) {
351
+function sendMailMessage($email, $uid, $pwd, $ufn)
352
+{
351 353
 	global $modx, $_lang, $websignupemail_message;
352 354
 	global $emailsubject, $emailsender;
353 355
 	global $site_name, $site_url;
@@ -375,7 +377,8 @@  discard block
 block discarded – undo
375 377
 }
376 378
 
377 379
 // Save User Settings
378
-function saveUserSettings($id) {
380
+function saveUserSettings($id)
381
+{
379 382
 	global $modx;
380 383
 	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
381 384
 
@@ -404,7 +407,8 @@  discard block
 block discarded – undo
404 407
 }
405 408
 
406 409
 // Web alert -  sends an alert to web browser
407
-function webAlertAndQuit($msg) {
410
+function webAlertAndQuit($msg)
411
+{
408 412
 	global $id, $modx;
409 413
 	$mode = $_POST['mode'];
410 414
 	$modx->manager->saveFormValues($mode);
@@ -412,7 +416,8 @@  discard block
 block discarded – undo
412 416
 }
413 417
 
414 418
 // Generate password
415
-function generate_password($length = 10) {
419
+function generate_password($length = 10)
420
+{
416 421
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
417 422
 	$ps_len = strlen($allowable_characters);
418 423
 	mt_srand((double) microtime() * 1000000);
@@ -423,7 +428,8 @@  discard block
 block discarded – undo
423 428
 	return $pass;
424 429
 }
425 430
 
426
-function sanitize($str = '', $safecount = 0) {
431
+function sanitize($str = '', $safecount = 0)
432
+{
427 433
 	global $modx;
428 434
 	$safecount++;
429 435
 	if(1000 < $safecount) {
Please login to merge, or discard this patch.
manager/processors/duplicate_tmplvars.processor.php 3 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3 3
 if(!$modx->hasPermission('edit_template')) {
4
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
4
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 5
 }
6 6
 
7 7
 $id = isset($_GET['id'])? intval($_GET['id']) : 0;
8 8
 if($id==0) {
9
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
9
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
10 10
 }
11 11
 
12 12
 // count duplicates
@@ -17,37 +17,37 @@  discard block
 block discarded – undo
17 17
 
18 18
 // duplicate TV
19 19
 $newid = $modx->db->insert(
20
-	array(
21
-		'type'=>'',
22
-		'name'=>'',
23
-		'caption'=>'',
24
-		'description'=>'',
25
-		'default_text'=>'',
26
-		'elements'=>'',
27
-		'rank'=>'',
28
-		'display'=>'',
29
-		'display_params'=>'',
30
-		'category'=>'',
31
-		), $modx->getFullTableName('site_tmplvars'), // Insert into
32
-	"type, CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, CONCAT(caption, ' Duplicate{$count}') AS caption, description, default_text, elements, rank, display, display_params, category", $modx->getFullTableName('site_tmplvars'), "id='{$id}'"); // Copy from
20
+    array(
21
+        'type'=>'',
22
+        'name'=>'',
23
+        'caption'=>'',
24
+        'description'=>'',
25
+        'default_text'=>'',
26
+        'elements'=>'',
27
+        'rank'=>'',
28
+        'display'=>'',
29
+        'display_params'=>'',
30
+        'category'=>'',
31
+        ), $modx->getFullTableName('site_tmplvars'), // Insert into
32
+    "type, CONCAT(name, ' {$_lang['duplicated_el_suffix']}{$count}') AS name, CONCAT(caption, ' Duplicate{$count}') AS caption, description, default_text, elements, rank, display, display_params, category", $modx->getFullTableName('site_tmplvars'), "id='{$id}'"); // Copy from
33 33
 
34 34
 
35 35
 // duplicate TV Template Access Permissions
36 36
 $modx->db->insert(
37
-	array(
38
-		'tmplvarid'=>'',
39
-		'templateid'=>'',
40
-		'rank'=>'',
41
-		), $modx->getFullTableName('site_tmplvar_templates'), // Insert into
42
-	"'{$newid}', templateid, rank", $modx->getFullTableName('site_tmplvar_templates'), "tmplvarid='{$id}'"); // Copy from
37
+    array(
38
+        'tmplvarid'=>'',
39
+        'templateid'=>'',
40
+        'rank'=>'',
41
+        ), $modx->getFullTableName('site_tmplvar_templates'), // Insert into
42
+    "'{$newid}', templateid, rank", $modx->getFullTableName('site_tmplvar_templates'), "tmplvarid='{$id}'"); // Copy from
43 43
 
44 44
 // duplicate TV Access Permissions
45 45
 $modx->db->insert(
46
-	array(
47
-		'tmplvarid'=>'',
48
-		'documentgroup'=>'',
49
-		), $modx->getFullTableName('site_tmplvar_access'), // Insert into
50
-	"'{$newid}', documentgroup", $modx->getFullTableName('site_tmplvar_access'), "tmplvarid='{$id}'"); // Copy from
46
+    array(
47
+        'tmplvarid'=>'',
48
+        'documentgroup'=>'',
49
+        ), $modx->getFullTableName('site_tmplvar_access'), // Insert into
50
+    "'{$newid}', documentgroup", $modx->getFullTableName('site_tmplvar_access'), "tmplvarid='{$id}'"); // Copy from
51 51
 
52 52
 // Set the item name for logger
53 53
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_tmplvars'), "id='{$newid}'"));
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
-if(!$modx->hasPermission('edit_template')) {
2
+if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
+if (!$modx->hasPermission('edit_template')) {
4 4
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 5
 }
6 6
 
7
-$id = isset($_GET['id'])? intval($_GET['id']) : 0;
8
-if($id==0) {
7
+$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
8
+if ($id == 0) {
9 9
 	$modx->webAlertAndQuit($_lang["error_no_id"]);
10 10
 }
11 11
 
12 12
 // count duplicates
13 13
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_tmplvars'), "id='{$id}'"));
14 14
 $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_tmplvars'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
15
-if($count>=1) $count = ' '.($count+1);
15
+if ($count >= 1) $count = ' '.($count + 1);
16 16
 else $count = '';
17 17
 
18 18
 // duplicate TV
@@ -54,5 +54,5 @@  discard block
 block discarded – undo
54 54
 $_SESSION['itemname'] = $name;
55 55
 
56 56
 // finish duplicating - redirect to new variable
57
-$header="Location: index.php?r=2&a=301&id=$newid";
57
+$header = "Location: index.php?r=2&a=301&id=$newid";
58 58
 header($header);
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
2
+if(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.");
4
+}
3 5
 if(!$modx->hasPermission('edit_template')) {
4 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 7
 }
@@ -12,8 +14,11 @@  discard block
 block discarded – undo
12 14
 // count duplicates
13 15
 $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_tmplvars'), "id='{$id}'"));
14 16
 $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_tmplvars'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'"));
15
-if($count>=1) $count = ' '.($count+1);
16
-else $count = '';
17
+if($count>=1) {
18
+    $count = ' '.($count+1);
19
+} else {
20
+    $count = '';
21
+}
17 22
 
18 23
 // duplicate TV
19 24
 $newid = $modx->db->insert(
Please login to merge, or discard this patch.
manager/processors/delete_eventlog.processor.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3 3
 if(!$modx->hasPermission('delete_eventlog')) {
4
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
4
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 5
 }
6 6
 
7 7
 if (isset($_GET['cls']) && $_GET['cls']==1) {
8
-	$where = '';
8
+    $where = '';
9 9
 } else {
10
-	$id = isset($_GET['id'])? intval($_GET['id']) : 0;
11
-	if($id==0) {
12
-		$modx->webAlertAndQuit($_lang["error_no_id"]);
13
-	}
14
-	$where = "id='{$id}'";
10
+    $id = isset($_GET['id'])? intval($_GET['id']) : 0;
11
+    if($id==0) {
12
+        $modx->webAlertAndQuit($_lang["error_no_id"]);
13
+    }
14
+    $where = "id='{$id}'";
15 15
 }
16 16
 
17 17
 // delete event log
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
-if(!$modx->hasPermission('delete_eventlog')) {
2
+if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
+if (!$modx->hasPermission('delete_eventlog')) {
4 4
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 5
 }
6 6
 
7
-if (isset($_GET['cls']) && $_GET['cls']==1) {
7
+if (isset($_GET['cls']) && $_GET['cls'] == 1) {
8 8
 	$where = '';
9 9
 } else {
10
-	$id = isset($_GET['id'])? intval($_GET['id']) : 0;
11
-	if($id==0) {
10
+	$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
11
+	if ($id == 0) {
12 12
 		$modx->webAlertAndQuit($_lang["error_no_id"]);
13 13
 	}
14 14
 	$where = "id='{$id}'";
@@ -17,5 +17,5 @@  discard block
 block discarded – undo
17 17
 // delete event log
18 18
 $modx->db->delete($modx->getFullTableName('event_log'), $where);
19 19
 
20
-$header="Location: index.php?a=114";
20
+$header = "Location: index.php?a=114";
21 21
 header($header);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
2
+if(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.");
4
+}
3 5
 if(!$modx->hasPermission('delete_eventlog')) {
4 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 7
 }
Please login to merge, or discard this patch.
manager/processors/save_snippet.processor.php 2 patches
Switch Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -66,111 +66,111 @@
 block discarded – undo
66 66
 }
67 67
 
68 68
 switch ($_POST['mode']) {
69
-    case '23': // Save new snippet
70
-
71
-        // invoke OnBeforeSnipFormSave event
72
-        $modx->invokeEvent("OnBeforeSnipFormSave", array(
73
-            "mode" => "new",
74
-            "id" => $id
75
-        ));
76
-
77
-        // disallow duplicate names for new snippets
78
-        $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_snippets'), "name='{$name}'");
79
-        $count = $modx->db->getValue($rs);
80
-        if ($count > 0) {
81
-            $modx->manager->saveFormValues(23);
82
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=23");
83
-        }
84
-
85
-        //do stuff to save the new doc
86
-        $newid = $modx->db->insert(array(
87
-            'name' => $name,
88
-            'description' => $description,
89
-            'snippet' => $snippet,
90
-            'moduleguid' => $moduleguid,
91
-            'locked' => $locked,
92
-            'properties' => $properties,
93
-            'category' => $categoryid,
94
-            'disabled' => $disabled,
95
-            'createdon' => $currentdate,
96
-            'editedon' => $currentdate
97
-        ), $modx->getFullTableName('site_snippets'));
98
-
99
-        // invoke OnSnipFormSave event
100
-        $modx->invokeEvent("OnSnipFormSave", array(
101
-            "mode" => "new",
102
-            "id" => $newid
103
-        ));
104
-
105
-        // Set the item name for logger
106
-        $_SESSION['itemname'] = $name;
107
-
108
-        // empty cache
109
-        $modx->clearCache('full');
110
-
111
-        // finished emptying cache - redirect
112
-        if ($_POST['stay'] != '') {
113
-            $a = ($_POST['stay'] == '2') ? "22&id=$newid" : "23";
114
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
-            header($header);
116
-        } else {
117
-            $header = "Location: index.php?a=76&r=2";
118
-            header($header);
119
-        }
120
-        break;
121
-    case '22': // Save existing snippet
122
-        // invoke OnBeforeSnipFormSave event
123
-        $modx->invokeEvent("OnBeforeSnipFormSave", array(
124
-            "mode" => "upd",
125
-            "id" => $id
126
-        ));
127
-
128
-        // disallow duplicate names for snippets
129
-        $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_snippets'), "name='{$name}' AND id!='{$id}'");
130
-        if ($modx->db->getValue($rs) > 0) {
131
-            $modx->manager->saveFormValues(22);
132
-            $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=22&id={$id}");
133
-        }
134
-
135
-        //do stuff to save the edited doc
136
-        $modx->db->update(array(
137
-            'name' => $name,
138
-            'description' => $description,
139
-            'snippet' => $snippet,
140
-            'moduleguid' => $moduleguid,
141
-            'locked' => $locked,
142
-            'properties' => $properties,
143
-            'category' => $categoryid,
144
-            'disabled' => $disabled,
145
-            'editedon' => $currentdate
146
-        ), $modx->getFullTableName('site_snippets'), "id='{$id}'");
147
-
148
-        // invoke OnSnipFormSave event
149
-        $modx->invokeEvent("OnSnipFormSave", array(
150
-            "mode" => "upd",
151
-            "id" => $id
152
-        ));
153
-
154
-        // Set the item name for logger
155
-        $_SESSION['itemname'] = $name;
156
-
157
-        // empty cache
158
-        $modx->clearCache('full');
159
-
160
-        if ($_POST['runsnippet']) {
161
-            run_snippet($snippet);
162
-        }
163
-        // finished emptying cache - redirect
164
-        if ($_POST['stay'] != '') {
165
-            $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23";
166
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
167
-            header($header);
168
-        } else {
169
-            $modx->unlockElement(4, $id);
170
-            $header = "Location: index.php?a=76&r=2";
171
-            header($header);
172
-        }
173
-        break;
174
-    default:
175
-        $modx->webAlertAndQuit("No operation set in request.");
69
+        case '23': // Save new snippet
70
+
71
+            // invoke OnBeforeSnipFormSave event
72
+            $modx->invokeEvent("OnBeforeSnipFormSave", array(
73
+                "mode" => "new",
74
+                "id" => $id
75
+            ));
76
+
77
+            // disallow duplicate names for new snippets
78
+            $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_snippets'), "name='{$name}'");
79
+            $count = $modx->db->getValue($rs);
80
+            if ($count > 0) {
81
+                $modx->manager->saveFormValues(23);
82
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=23");
83
+            }
84
+
85
+            //do stuff to save the new doc
86
+            $newid = $modx->db->insert(array(
87
+                'name' => $name,
88
+                'description' => $description,
89
+                'snippet' => $snippet,
90
+                'moduleguid' => $moduleguid,
91
+                'locked' => $locked,
92
+                'properties' => $properties,
93
+                'category' => $categoryid,
94
+                'disabled' => $disabled,
95
+                'createdon' => $currentdate,
96
+                'editedon' => $currentdate
97
+            ), $modx->getFullTableName('site_snippets'));
98
+
99
+            // invoke OnSnipFormSave event
100
+            $modx->invokeEvent("OnSnipFormSave", array(
101
+                "mode" => "new",
102
+                "id" => $newid
103
+            ));
104
+
105
+            // Set the item name for logger
106
+            $_SESSION['itemname'] = $name;
107
+
108
+            // empty cache
109
+            $modx->clearCache('full');
110
+
111
+            // finished emptying cache - redirect
112
+            if ($_POST['stay'] != '') {
113
+                $a = ($_POST['stay'] == '2') ? "22&id=$newid" : "23";
114
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
115
+                header($header);
116
+            } else {
117
+                $header = "Location: index.php?a=76&r=2";
118
+                header($header);
119
+            }
120
+            break;
121
+        case '22': // Save existing snippet
122
+            // invoke OnBeforeSnipFormSave event
123
+            $modx->invokeEvent("OnBeforeSnipFormSave", array(
124
+                "mode" => "upd",
125
+                "id" => $id
126
+            ));
127
+
128
+            // disallow duplicate names for snippets
129
+            $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_snippets'), "name='{$name}' AND id!='{$id}'");
130
+            if ($modx->db->getValue($rs) > 0) {
131
+                $modx->manager->saveFormValues(22);
132
+                $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=22&id={$id}");
133
+            }
134
+
135
+            //do stuff to save the edited doc
136
+            $modx->db->update(array(
137
+                'name' => $name,
138
+                'description' => $description,
139
+                'snippet' => $snippet,
140
+                'moduleguid' => $moduleguid,
141
+                'locked' => $locked,
142
+                'properties' => $properties,
143
+                'category' => $categoryid,
144
+                'disabled' => $disabled,
145
+                'editedon' => $currentdate
146
+            ), $modx->getFullTableName('site_snippets'), "id='{$id}'");
147
+
148
+            // invoke OnSnipFormSave event
149
+            $modx->invokeEvent("OnSnipFormSave", array(
150
+                "mode" => "upd",
151
+                "id" => $id
152
+            ));
153
+
154
+            // Set the item name for logger
155
+            $_SESSION['itemname'] = $name;
156
+
157
+            // empty cache
158
+            $modx->clearCache('full');
159
+
160
+            if ($_POST['runsnippet']) {
161
+                run_snippet($snippet);
162
+            }
163
+            // finished emptying cache - redirect
164
+            if ($_POST['stay'] != '') {
165
+                $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23";
166
+                $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
167
+                header($header);
168
+            } else {
169
+                $modx->unlockElement(4, $id);
170
+                $header = "Location: index.php?a=76&r=2";
171
+                header($header);
172
+            }
173
+            break;
174
+        default:
175
+            $modx->webAlertAndQuit("No operation set in request.");
176 176
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
38 38
     $categoryid = 0;
39 39
 } else {
40
-    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
40
+    include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
41 41
     $categoryid = checkCategory($_POST['newcategory']);
42 42
     if (!$categoryid) {
43 43
         $categoryid = newCategory($_POST['newcategory']);
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
     $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid;
56 56
 
57 57
     $description = isset($parsed['description']) ? $parsed['description'] : $description;
58
-    $version = isset($parsed['version']) ? '<b>' . $parsed['version'] . '</b> ' : '';
58
+    $version = isset($parsed['version']) ? '<b>'.$parsed['version'].'</b> ' : '';
59 59
     if ($version) {
60
-        $description = $version . trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
60
+        $description = $version.trim(preg_replace('/(<b>.+?)+(<\/b>)/i', '', $description));
61 61
     }
62 62
     if (isset($parsed['modx_category'])) {
63
-        include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
63
+        include_once(MODX_MANAGER_PATH.'includes/categories.inc.php');
64 64
         $categoryid = getCategory($parsed['modx_category']);
65 65
     }
66 66
 }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         // finished emptying cache - redirect
112 112
         if ($_POST['stay'] != '') {
113 113
             $a = ($_POST['stay'] == '2') ? "22&id=$newid" : "23";
114
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
114
+            $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay'];
115 115
             header($header);
116 116
         } else {
117 117
             $header = "Location: index.php?a=76&r=2";
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         // finished emptying cache - redirect
164 164
         if ($_POST['stay'] != '') {
165 165
             $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23";
166
-            $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'];
166
+            $header = "Location: index.php?a=".$a."&r=2&stay=".$_POST['stay'];
167 167
             header($header);
168 168
         } else {
169 169
             $modx->unlockElement(4, $id);
Please login to merge, or discard this patch.
manager/processors/export_site.processor.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3 3
 if(!$modx->hasPermission('export_static')) {
4
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
4
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 5
 }
6 6
 
7 7
 $maxtime = (is_numeric($_POST['maxtime'])) ? $_POST['maxtime'] : 30;
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 $modx->export->targetDir = $export_dir;
16 16
 
17 17
 if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path'])))
18
-	return $_lang['export_site.static.php6'];
18
+    return $_lang['export_site.static.php6'];
19 19
 elseif($modx->config['rb_base_dir'] === $export_dir . '/')
20
-	return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']);
20
+    return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']);
21 21
 elseif(!is_writable($export_dir))
22
-	return $_lang['export_site_target_unwritable'];
22
+    return $_lang['export_site_target_unwritable'];
23 23
 
24 24
 $modx->export->generate_mode = $_POST['generate_mode'];
25 25
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
  ||$includenoncache!==$_POST['includenoncache']
36 36
  ||$repl_before!==$_POST['repl_before']
37 37
  ||$repl_after !==$_POST['repl_after']) {
38
-	$modx->clearCache('full');
38
+    $modx->clearCache('full');
39 39
 }
40 40
 
41 41
 $total = $modx->export->getTotal($_POST['ignore_ids'], $modx->config['export_includenoncache']);
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
-if(!$modx->hasPermission('export_static')) {
2
+if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
+if (!$modx->hasPermission('export_static')) {
4 4
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 5
 }
6 6
 
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
 $modx->loadExtension('EXPORT_SITE');
11 11
 
12 12
 
13
-if(is_dir(MODX_BASE_PATH . 'temp'))       $export_dir = MODX_BASE_PATH . 'temp/export';
14
-elseif(is_dir(MODX_BASE_PATH . 'assets')) $export_dir = MODX_BASE_PATH . 'assets/export';
13
+if (is_dir(MODX_BASE_PATH.'temp'))       $export_dir = MODX_BASE_PATH.'temp/export';
14
+elseif (is_dir(MODX_BASE_PATH.'assets')) $export_dir = MODX_BASE_PATH.'assets/export';
15 15
 $modx->export->targetDir = $export_dir;
16 16
 
17
-if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path'])))
17
+if (strpos($modx->config['base_path'], "{$export_dir}/") === 0 && 0 <= strlen(str_replace("{$export_dir}/", '', $modx->config['base_path'])))
18 18
 	return $_lang['export_site.static.php6'];
19
-elseif($modx->config['rb_base_dir'] === $export_dir . '/')
20
-	return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']);
21
-elseif(!is_writable($export_dir))
19
+elseif ($modx->config['rb_base_dir'] === $export_dir.'/')
20
+	return $modx->parsePlaceholder($_lang['export_site.static.php7'], 'rb_base_url='.$modx->config['base_url'].$modx->config['rb_base_url']);
21
+elseif (!is_writable($export_dir))
22 22
 	return $_lang['export_site_target_unwritable'];
23 23
 
24 24
 $modx->export->generate_mode = $_POST['generate_mode'];
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 $repl_after      = $_POST['repl_after'];
32 32
 $includenoncache = $_POST['includenoncache'];
33 33
 
34
-if($ignore_ids!==$_POST['ignore_ids']
35
- ||$includenoncache!==$_POST['includenoncache']
36
- ||$repl_before!==$_POST['repl_before']
37
- ||$repl_after !==$_POST['repl_after']) {
34
+if ($ignore_ids !== $_POST['ignore_ids']
35
+ ||$includenoncache !== $_POST['includenoncache']
36
+ ||$repl_before !== $_POST['repl_before']
37
+ ||$repl_after !== $_POST['repl_after']) {
38 38
 	$modx->clearCache('full');
39 39
 }
40 40
 
@@ -50,5 +50,5 @@  discard block
 block discarded – undo
50 50
 
51 51
 $exportend = $modx->export->get_mtime();
52 52
 $totaltime = ($exportend - $modx->export->exportstart);
53
-$output .= sprintf ('<p>'.$_lang["export_site_time"].'</p>', round($totaltime, 3));
53
+$output .= sprintf('<p>'.$_lang["export_site_time"].'</p>', round($totaltime, 3));
54 54
 return $output;
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
2
+if(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.");
4
+}
3 5
 if(!$modx->hasPermission('export_static')) {
4 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 7
 }
@@ -10,16 +12,20 @@  discard block
 block discarded – undo
10 12
 $modx->loadExtension('EXPORT_SITE');
11 13
 
12 14
 
13
-if(is_dir(MODX_BASE_PATH . 'temp'))       $export_dir = MODX_BASE_PATH . 'temp/export';
14
-elseif(is_dir(MODX_BASE_PATH . 'assets')) $export_dir = MODX_BASE_PATH . 'assets/export';
15
+if(is_dir(MODX_BASE_PATH . 'temp')) {
16
+    $export_dir = MODX_BASE_PATH . 'temp/export';
17
+} elseif(is_dir(MODX_BASE_PATH . 'assets')) {
18
+    $export_dir = MODX_BASE_PATH . 'assets/export';
19
+}
15 20
 $modx->export->targetDir = $export_dir;
16 21
 
17
-if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path'])))
22
+if(strpos($modx->config['base_path'],"{$export_dir}/")===0 && 0 <= strlen(str_replace("{$export_dir}/",'',$modx->config['base_path']))) {
18 23
 	return $_lang['export_site.static.php6'];
19
-elseif($modx->config['rb_base_dir'] === $export_dir . '/')
24
+} elseif($modx->config['rb_base_dir'] === $export_dir . '/') {
20 25
 	return $modx->parsePlaceholder($_lang['export_site.static.php7'],'rb_base_url=' . $modx->config['base_url'] . $modx->config['rb_base_url']);
21
-elseif(!is_writable($export_dir))
26
+} elseif(!is_writable($export_dir)) {
22 27
 	return $_lang['export_site_target_unwritable'];
28
+}
23 29
 
24 30
 $modx->export->generate_mode = $_POST['generate_mode'];
25 31
 
Please login to merge, or discard this patch.
manager/processors/send_message.processor.php 3 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3 3
 if(!$modx->hasPermission('messages')) {
4
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
4
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 5
 }
6 6
 
7 7
 $sendto = $_REQUEST['sendto'];
@@ -14,55 +14,55 @@  discard block
 block discarded – undo
14 14
 $postdate = time();
15 15
 
16 16
 if($sendto=='u') {
17
-	if($userid==0) {
18
-		$modx->webAlertAndQuit($_lang["error_no_user_selected"]);
19
-	}
20
-	$modx->db->insert(
21
-		array(
22
-			'recipient' => $userid,
23
-			'sender'    => $modx->getLoginUserID(),
24
-			'subject'   => $subject,
25
-			'message'   => $message,
26
-			'postdate'  => $postdate,
27
-			'type'      => 'Message',
28
-			'private'   => 1,
29
-		), $modx->getFullTableName('user_messages'));
17
+    if($userid==0) {
18
+        $modx->webAlertAndQuit($_lang["error_no_user_selected"]);
19
+    }
20
+    $modx->db->insert(
21
+        array(
22
+            'recipient' => $userid,
23
+            'sender'    => $modx->getLoginUserID(),
24
+            'subject'   => $subject,
25
+            'message'   => $message,
26
+            'postdate'  => $postdate,
27
+            'type'      => 'Message',
28
+            'private'   => 1,
29
+        ), $modx->getFullTableName('user_messages'));
30 30
 }
31 31
 
32 32
 if($sendto=='g') {
33
-	if($groupid==0) {
34
-		$modx->webAlertAndQuit($_lang["error_no_group_selected"]);
35
-	}
36
-	$rs = $modx->db->select('internalKey', $modx->getFullTableName('user_attributes'), "role='{$groupid}' AND internalKey!='".$modx->getLoginUserID()."'");
37
-	while ($row=$modx->db->getRow($rs)) {
38
-		$modx->db->insert(
39
-			array(
40
-				'recipient' => $row['internalKey'],
41
-				'sender'    => $modx->getLoginUserID(),
42
-				'subject'   => $subject,
43
-				'message'   => $message,
44
-				'postdate'  => $postdate,
45
-				'type'      => 'Message',
46
-				'private'   => 0,
47
-			), $modx->getFullTableName('user_messages'));
48
-	}
33
+    if($groupid==0) {
34
+        $modx->webAlertAndQuit($_lang["error_no_group_selected"]);
35
+    }
36
+    $rs = $modx->db->select('internalKey', $modx->getFullTableName('user_attributes'), "role='{$groupid}' AND internalKey!='".$modx->getLoginUserID()."'");
37
+    while ($row=$modx->db->getRow($rs)) {
38
+        $modx->db->insert(
39
+            array(
40
+                'recipient' => $row['internalKey'],
41
+                'sender'    => $modx->getLoginUserID(),
42
+                'subject'   => $subject,
43
+                'message'   => $message,
44
+                'postdate'  => $postdate,
45
+                'type'      => 'Message',
46
+                'private'   => 0,
47
+            ), $modx->getFullTableName('user_messages'));
48
+    }
49 49
 }
50 50
 
51 51
 
52 52
 if($sendto=='a') {
53
-	$rs = $modx->db->select('id', $modx->getFullTableName('manager_users'), "id!='".$modx->getLoginUserID()."'");
54
-	while ($row=$modx->db->getRow($rs)) {
55
-		$modx->db->insert(
56
-			array(
57
-				'recipient' => $row['id'],
58
-				'sender'    => $modx->getLoginUserID(),
59
-				'subject'   => $subject,
60
-				'message'   => $message,
61
-				'postdate'  => $postdate,
62
-				'type'      => 'Message',
63
-				'private'   => 0,
64
-			), $modx->getFullTableName('user_messages'));
65
-	}
53
+    $rs = $modx->db->select('id', $modx->getFullTableName('manager_users'), "id!='".$modx->getLoginUserID()."'");
54
+    while ($row=$modx->db->getRow($rs)) {
55
+        $modx->db->insert(
56
+            array(
57
+                'recipient' => $row['id'],
58
+                'sender'    => $modx->getLoginUserID(),
59
+                'subject'   => $subject,
60
+                'message'   => $message,
61
+                'postdate'  => $postdate,
62
+                'type'      => 'Message',
63
+                'private'   => 0,
64
+            ), $modx->getFullTableName('user_messages'));
65
+    }
66 66
 }
67 67
 
68 68
 $header = "Location: index.php?a=10";
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
-if(!$modx->hasPermission('messages')) {
2
+if (IN_MANAGER_MODE != "true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
+if (!$modx->hasPermission('messages')) {
4 4
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 5
 }
6 6
 
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
 $userid = $_REQUEST['user'];
9 9
 $groupid = $_REQUEST['group'];
10 10
 $subject = $modx->db->escape($_REQUEST['messagesubject']);
11
-if($subject=="") $subject="(no subject)";
11
+if ($subject == "") $subject = "(no subject)";
12 12
 $message = $modx->db->escape($_REQUEST['messagebody']);
13
-if($message=="") $message="(no message)";
13
+if ($message == "") $message = "(no message)";
14 14
 $postdate = time();
15 15
 
16
-if($sendto=='u') {
17
-	if($userid==0) {
16
+if ($sendto == 'u') {
17
+	if ($userid == 0) {
18 18
 		$modx->webAlertAndQuit($_lang["error_no_user_selected"]);
19 19
 	}
20 20
 	$modx->db->insert(
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
 		), $modx->getFullTableName('user_messages'));
30 30
 }
31 31
 
32
-if($sendto=='g') {
33
-	if($groupid==0) {
32
+if ($sendto == 'g') {
33
+	if ($groupid == 0) {
34 34
 		$modx->webAlertAndQuit($_lang["error_no_group_selected"]);
35 35
 	}
36 36
 	$rs = $modx->db->select('internalKey', $modx->getFullTableName('user_attributes'), "role='{$groupid}' AND internalKey!='".$modx->getLoginUserID()."'");
37
-	while ($row=$modx->db->getRow($rs)) {
37
+	while ($row = $modx->db->getRow($rs)) {
38 38
 		$modx->db->insert(
39 39
 			array(
40 40
 				'recipient' => $row['internalKey'],
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 }
50 50
 
51 51
 
52
-if($sendto=='a') {
52
+if ($sendto == 'a') {
53 53
 	$rs = $modx->db->select('id', $modx->getFullTableName('manager_users'), "id!='".$modx->getLoginUserID()."'");
54
-	while ($row=$modx->db->getRow($rs)) {
54
+	while ($row = $modx->db->getRow($rs)) {
55 55
 		$modx->db->insert(
56 56
 			array(
57 57
 				'recipient' => $row['id'],
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
2
+if(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.");
4
+}
3 5
 if(!$modx->hasPermission('messages')) {
4 6
 	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
5 7
 }
@@ -8,9 +10,13 @@  discard block
 block discarded – undo
8 10
 $userid = $_REQUEST['user'];
9 11
 $groupid = $_REQUEST['group'];
10 12
 $subject = $modx->db->escape($_REQUEST['messagesubject']);
11
-if($subject=="") $subject="(no subject)";
13
+if($subject=="") {
14
+    $subject="(no subject)";
15
+}
12 16
 $message = $modx->db->escape($_REQUEST['messagebody']);
13
-if($message=="") $message="(no message)";
17
+if($message=="") {
18
+    $message="(no message)";
19
+}
14 20
 $postdate = time();
15 21
 
16 22
 if($sendto=='u') {
Please login to merge, or discard this patch.
manager/processors/login.processor.php 4 patches
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
3
-	header('HTTP/1.0 404 Not Found');
4
-	exit('error');
3
+    header('HTTP/1.0 404 Not Found');
4
+    exit('error');
5 5
 }
6 6
 define('IN_MANAGER_MODE', true);  // we use this to make sure files are accessed through
7 7
 define('MODX_API_MODE', true);
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 include_once("{$core_path}lang/english.inc.php");
19 19
 
20 20
 if($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) {
21
-	include_once("{$core_path}lang/{$manager_language}.inc.php");
21
+    include_once("{$core_path}lang/{$manager_language}.inc.php");
22 22
 }
23 23
 
24 24
 // include the logger
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 // Initialize System Alert Message Queque
28 28
 if(!isset($_SESSION['SystemAlertMsgQueque'])) {
29
-	$_SESSION['SystemAlertMsgQueque'] = array();
29
+    $_SESSION['SystemAlertMsgQueque'] = array();
30 30
 }
31 31
 $SystemAlertMsgQueque = &$_SESSION['SystemAlertMsgQueque'];
32 32
 
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 
42 42
 // invoke OnBeforeManagerLogin event
43 43
 $modx->invokeEvent('OnBeforeManagerLogin', array(
44
-		'username' => $username,
45
-		'userpassword' => $givenPassword,
46
-		'rememberme' => $rememberme
47
-	));
44
+        'username' => $username,
45
+        'userpassword' => $givenPassword,
46
+        'rememberme' => $rememberme
47
+    ));
48 48
 $fields = 'mu.*, ua.*';
49 49
 $from = '[+prefix+]manager_users AS mu, [+prefix+]user_attributes AS ua';
50 50
 $where = "BINARY mu.username='{$username}' and ua.internalKey=mu.id";
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 $limit = $modx->db->getRecordCount($rs);
53 53
 
54 54
 if($limit == 0 || $limit > 1) {
55
-	jsAlert($_lang['login_processor_unknown_user']);
56
-	return;
55
+    jsAlert($_lang['login_processor_unknown_user']);
56
+    return;
57 57
 }
58 58
 
59 59
 $row = $modx->db->getRow($rs);
@@ -74,127 +74,127 @@  discard block
 block discarded – undo
74 74
 // get the user settings from the database
75 75
 $rs = $modx->db->select('setting_name, setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_value!=''");
76 76
 while($row = $modx->db->getRow($rs)) {
77
-	extract($row);
78
-	${$setting_name} = $setting_value;
77
+    extract($row);
78
+    ${$setting_name} = $setting_value;
79 79
 }
80 80
 
81 81
 // blocked due to number of login errors.
82 82
 if($failedlogins >= $failed_allowed && $blockeduntildate > time()) {
83
-	@session_destroy();
84
-	session_unset();
85
-	if($cip = getenv("HTTP_CLIENT_IP")) {
86
-		$ip = $cip;
87
-	} elseif($cip = getenv("HTTP_X_FORWARDED_FOR")) {
88
-		$ip = $cip;
89
-	} elseif($cip = getenv("REMOTE_ADDR")) {
90
-		$ip = $cip;
91
-	} else {
92
-		$ip = "UNKNOWN";
93
-	}
94
-	$log = new logHandler;
95
-	$log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip);
96
-	jsAlert($_lang['login_processor_many_failed_logins']);
97
-	return;
83
+    @session_destroy();
84
+    session_unset();
85
+    if($cip = getenv("HTTP_CLIENT_IP")) {
86
+        $ip = $cip;
87
+    } elseif($cip = getenv("HTTP_X_FORWARDED_FOR")) {
88
+        $ip = $cip;
89
+    } elseif($cip = getenv("REMOTE_ADDR")) {
90
+        $ip = $cip;
91
+    } else {
92
+        $ip = "UNKNOWN";
93
+    }
94
+    $log = new logHandler;
95
+    $log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip);
96
+    jsAlert($_lang['login_processor_many_failed_logins']);
97
+    return;
98 98
 }
99 99
 
100 100
 // blocked due to number of login errors, but get to try again
101 101
 if($failedlogins >= $failed_allowed && $blockeduntildate < time()) {
102
-	$fields = array();
103
-	$fields['failedlogincount'] = '0';
104
-	$fields['blockeduntil'] = time() - 1;
105
-	$modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
102
+    $fields = array();
103
+    $fields['failedlogincount'] = '0';
104
+    $fields['blockeduntil'] = time() - 1;
105
+    $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
106 106
 }
107 107
 
108 108
 // this user has been blocked by an admin, so no way he's loggin in!
109 109
 if($blocked == '1') {
110
-	@session_destroy();
111
-	session_unset();
112
-	jsAlert($_lang['login_processor_blocked1']);
113
-	return;
110
+    @session_destroy();
111
+    session_unset();
112
+    jsAlert($_lang['login_processor_blocked1']);
113
+    return;
114 114
 }
115 115
 
116 116
 // blockuntil: this user has a block until date
117 117
 if($blockeduntildate > time()) {
118
-	@session_destroy();
119
-	session_unset();
120
-	jsAlert($_lang['login_processor_blocked2']);
121
-	return;
118
+    @session_destroy();
119
+    session_unset();
120
+    jsAlert($_lang['login_processor_blocked2']);
121
+    return;
122 122
 }
123 123
 
124 124
 // blockafter: this user has a block after date
125 125
 if($blockedafterdate > 0 && $blockedafterdate < time()) {
126
-	@session_destroy();
127
-	session_unset();
128
-	jsAlert($_lang['login_processor_blocked3']);
129
-	return;
126
+    @session_destroy();
127
+    session_unset();
128
+    jsAlert($_lang['login_processor_blocked3']);
129
+    return;
130 130
 }
131 131
 
132 132
 // allowed ip
133 133
 if($allowed_ip) {
134
-	if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) {
135
-		if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) {
136
-			jsAlert($_lang['login_processor_remotehost_ip']);
137
-			return;
138
-		}
139
-	}
140
-	if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) {
141
-		jsAlert($_lang['login_processor_remote_ip']);
142
-		return;
143
-	}
134
+    if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) {
135
+        if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) {
136
+            jsAlert($_lang['login_processor_remotehost_ip']);
137
+            return;
138
+        }
139
+    }
140
+    if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) {
141
+        jsAlert($_lang['login_processor_remote_ip']);
142
+        return;
143
+    }
144 144
 }
145 145
 
146 146
 // allowed days
147 147
 if($allowed_days) {
148
-	$date = getdate();
149
-	$day = $date['wday'] + 1;
150
-	if(strpos($allowed_days, $day) === false) {
151
-		jsAlert($_lang['login_processor_date']);
152
-		return;
153
-	}
148
+    $date = getdate();
149
+    $day = $date['wday'] + 1;
150
+    if(strpos($allowed_days, $day) === false) {
151
+        jsAlert($_lang['login_processor_date']);
152
+        return;
153
+    }
154 154
 }
155 155
 
156 156
 // invoke OnManagerAuthentication event
157 157
 $rt = $modx->invokeEvent('OnManagerAuthentication', array(
158
-		'userid' => $internalKey,
159
-		'username' => $username,
160
-		'userpassword' => $givenPassword,
161
-		'savedpassword' => $dbasePassword,
162
-		'rememberme' => $rememberme
163
-	));
158
+        'userid' => $internalKey,
159
+        'username' => $username,
160
+        'userpassword' => $givenPassword,
161
+        'savedpassword' => $dbasePassword,
162
+        'rememberme' => $rememberme
163
+    ));
164 164
 
165 165
 // check if plugin authenticated the user
166 166
 $matchPassword = false;
167 167
 if(!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) {
168
-	// check user password - local authentication
169
-	$hashType = $modx->manager->getHashType($dbasePassword);
170
-	if($hashType == 'phpass') {
171
-		$matchPassword = login($username, $_REQUEST['password'], $dbasePassword);
172
-	} elseif($hashType == 'md5') {
173
-		$matchPassword = loginMD5($internalKey, $_REQUEST['password'], $dbasePassword, $username);
174
-	} elseif($hashType == 'v1') {
175
-		$matchPassword = loginV1($internalKey, $_REQUEST['password'], $dbasePassword, $username);
176
-	} else {
177
-		$matchPassword = false;
178
-	}
168
+    // check user password - local authentication
169
+    $hashType = $modx->manager->getHashType($dbasePassword);
170
+    if($hashType == 'phpass') {
171
+        $matchPassword = login($username, $_REQUEST['password'], $dbasePassword);
172
+    } elseif($hashType == 'md5') {
173
+        $matchPassword = loginMD5($internalKey, $_REQUEST['password'], $dbasePassword, $username);
174
+    } elseif($hashType == 'v1') {
175
+        $matchPassword = loginV1($internalKey, $_REQUEST['password'], $dbasePassword, $username);
176
+    } else {
177
+        $matchPassword = false;
178
+    }
179 179
 } else if($rt === true || (is_array($rt) && in_array(true, $rt))) {
180
-	$matchPassword = true;
180
+    $matchPassword = true;
181 181
 }
182 182
 
183 183
 if(!$matchPassword) {
184
-	jsAlert($_lang['login_processor_wrong_password']);
185
-	incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
186
-	return;
184
+    jsAlert($_lang['login_processor_wrong_password']);
185
+    incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
186
+    return;
187 187
 }
188 188
 
189 189
 if($modx->config['use_captcha'] == 1) {
190
-	if(!isset ($_SESSION['veriword'])) {
191
-		jsAlert($_lang['login_processor_captcha_config']);
192
-		return;
193
-	} elseif($_SESSION['veriword'] != $captcha_code) {
194
-		jsAlert($_lang['login_processor_bad_code']);
195
-		incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
196
-		return;
197
-	}
190
+    if(!isset ($_SESSION['veriword'])) {
191
+        jsAlert($_lang['login_processor_captcha_config']);
192
+        return;
193
+    } elseif($_SESSION['veriword'] != $captcha_code) {
194
+        jsAlert($_lang['login_processor_bad_code']);
195
+        incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
196
+        return;
197
+    }
198 198
 }
199 199
 
200 200
 $modx->cleanupExpiredLocks();
@@ -229,36 +229,36 @@  discard block
 block discarded – undo
229 229
 $_SESSION['mgrToken'] = md5($currentsessionid);
230 230
 
231 231
 if($rememberme == '1') {
232
-	$_SESSION['modx.mgr.session.cookie.lifetime'] = intval($modx->config['session.cookie.lifetime']);
233
-
234
-	// Set a cookie separate from the session cookie with the username in it. 
235
-	// Are we using secure connection? If so, make sure the cookie is secure
236
-	global $https_port;
237
-
238
-	$secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port);
239
-	if(version_compare(PHP_VERSION, '5.2', '<')) {
240
-		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure);
241
-	} else {
242
-		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true);
243
-	}
232
+    $_SESSION['modx.mgr.session.cookie.lifetime'] = intval($modx->config['session.cookie.lifetime']);
233
+
234
+    // Set a cookie separate from the session cookie with the username in it. 
235
+    // Are we using secure connection? If so, make sure the cookie is secure
236
+    global $https_port;
237
+
238
+    $secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port);
239
+    if(version_compare(PHP_VERSION, '5.2', '<')) {
240
+        setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure);
241
+    } else {
242
+        setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true);
243
+    }
244 244
 } else {
245
-	$_SESSION['modx.mgr.session.cookie.lifetime'] = 0;
245
+    $_SESSION['modx.mgr.session.cookie.lifetime'] = 0;
246 246
 
247
-	// Remove the Remember Me cookie
248
-	setcookie('modx_remember_manager', '', time() - 3600, MODX_BASE_URL);
247
+    // Remove the Remember Me cookie
248
+    setcookie('modx_remember_manager', '', time() - 3600, MODX_BASE_URL);
249 249
 }
250 250
 
251 251
 // Check if user already has an active session, if not check if user pressed logout end of last session
252 252
 $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_user_sessions'), "internalKey='{$internalKey}'");
253 253
 $activeSession = $modx->db->getValue($rs);
254 254
 if(!$activeSession) {
255
-	$rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8");
256
-	if($lastHit = $modx->db->getValue($rs)) {
257
-		$_SESSION['show_logout_reminder'] = array(
258
-			'type' => 'logout_reminder',
259
-			'lastHit' => $lastHit
260
-		);
261
-	}
255
+    $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8");
256
+    if($lastHit = $modx->db->getValue($rs)) {
257
+        $_SESSION['show_logout_reminder'] = array(
258
+            'type' => 'logout_reminder',
259
+            'lastHit' => $lastHit
260
+        );
261
+    }
262 262
 }
263 263
 
264 264
 $log = new logHandler;
@@ -266,109 +266,109 @@  discard block
 block discarded – undo
266 266
 
267 267
 // invoke OnManagerLogin event
268 268
 $modx->invokeEvent('OnManagerLogin', array(
269
-		'userid' => $internalKey,
270
-		'username' => $username,
271
-		'userpassword' => $givenPassword,
272
-		'rememberme' => $rememberme
273
-	));
269
+        'userid' => $internalKey,
270
+        'username' => $username,
271
+        'userpassword' => $givenPassword,
272
+        'rememberme' => $rememberme
273
+    ));
274 274
 
275 275
 // check if we should redirect user to a web page
276 276
 $rs = $modx->db->select('setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_name='manager_login_startup'");
277 277
 $id = intval($modx->db->getValue($rs));
278 278
 if($id > 0) {
279
-	$header = 'Location: ' . $modx->makeUrl($id, '', '', 'full');
280
-	if($_POST['ajax'] == 1) {
281
-		echo $header;
282
-	} else {
283
-		header($header);
284
-	}
279
+    $header = 'Location: ' . $modx->makeUrl($id, '', '', 'full');
280
+    if($_POST['ajax'] == 1) {
281
+        echo $header;
282
+    } else {
283
+        header($header);
284
+    }
285 285
 } else {
286
-	$header = 'Location: ' . MODX_MANAGER_URL;
287
-	if($_POST['ajax'] == 1) {
288
-		echo $header;
289
-	} else {
290
-		header($header);
291
-	}
286
+    $header = 'Location: ' . MODX_MANAGER_URL;
287
+    if($_POST['ajax'] == 1) {
288
+        echo $header;
289
+    } else {
290
+        header($header);
291
+    }
292 292
 }
293 293
 
294 294
 // show javascript alert
295 295
 function jsAlert($msg) {
296
-	global $modx;
297
-	if($_POST['ajax'] != 1) {
298
-		echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>";
299
-	} else {
300
-		echo $msg . "\n";
301
-	}
296
+    global $modx;
297
+    if($_POST['ajax'] != 1) {
298
+        echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>";
299
+    } else {
300
+        echo $msg . "\n";
301
+    }
302 302
 }
303 303
 
304 304
 function login($username, $givenPassword, $dbasePassword) {
305
-	global $modx;
306
-	return $modx->phpass->CheckPassword($givenPassword, $dbasePassword);
305
+    global $modx;
306
+    return $modx->phpass->CheckPassword($givenPassword, $dbasePassword);
307 307
 }
308 308
 
309 309
 function loginV1($internalKey, $givenPassword, $dbasePassword, $username) {
310
-	global $modx;
310
+    global $modx;
311 311
 
312
-	$user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey);
312
+    $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey);
313 313
 
314
-	if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) {
315
-		$modx->config['pwd_hash_algo'] = 'UNCRYPT';
316
-	}
314
+    if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) {
315
+        $modx->config['pwd_hash_algo'] = 'UNCRYPT';
316
+    }
317 317
 
318
-	if($user_algo !== $modx->config['pwd_hash_algo']) {
319
-		$bk_pwd_hash_algo = $modx->config['pwd_hash_algo'];
320
-		$modx->config['pwd_hash_algo'] = $user_algo;
321
-	}
318
+    if($user_algo !== $modx->config['pwd_hash_algo']) {
319
+        $bk_pwd_hash_algo = $modx->config['pwd_hash_algo'];
320
+        $modx->config['pwd_hash_algo'] = $user_algo;
321
+    }
322 322
 
323
-	if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) {
324
-		return false;
325
-	}
323
+    if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) {
324
+        return false;
325
+    }
326 326
 
327
-	updateNewHash($username, $givenPassword);
327
+    updateNewHash($username, $givenPassword);
328 328
 
329
-	return true;
329
+    return true;
330 330
 }
331 331
 
332 332
 function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) {
333
-	global $modx;
333
+    global $modx;
334 334
 
335
-	if($dbasePassword != md5($givenPassword)) {
336
-		return false;
337
-	}
338
-	updateNewHash($username, $givenPassword);
339
-	return true;
335
+    if($dbasePassword != md5($givenPassword)) {
336
+        return false;
337
+    }
338
+    updateNewHash($username, $givenPassword);
339
+    return true;
340 340
 }
341 341
 
342 342
 function updateNewHash($username, $password) {
343
-	global $modx;
343
+    global $modx;
344 344
 
345
-	$field = array();
346
-	$field['password'] = $modx->phpass->HashPassword($password);
347
-	$modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'");
345
+    $field = array();
346
+    $field['password'] = $modx->phpass->HashPassword($password);
347
+    $modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'");
348 348
 }
349 349
 
350 350
 function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) {
351
-	global $modx;
352
-
353
-	$failedlogins += 1;
354
-
355
-	$fields = array('failedlogincount' => $failedlogins);
356
-	if($failedlogins >= $failed_allowed) //block user for too many fail attempts
357
-	{
358
-		$fields['blockeduntil'] = time() + ($blocked_minutes * 60);
359
-	}
360
-
361
-	$modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
362
-
363
-	if($failedlogins < $failed_allowed) {
364
-		//sleep to help prevent brute force attacks
365
-		$sleep = (int) $failedlogins / 2;
366
-		if($sleep > 5) {
367
-			$sleep = 5;
368
-		}
369
-		sleep($sleep);
370
-	}
371
-	@session_destroy();
372
-	session_unset();
373
-	return;
351
+    global $modx;
352
+
353
+    $failedlogins += 1;
354
+
355
+    $fields = array('failedlogincount' => $failedlogins);
356
+    if($failedlogins >= $failed_allowed) //block user for too many fail attempts
357
+    {
358
+        $fields['blockeduntil'] = time() + ($blocked_minutes * 60);
359
+    }
360
+
361
+    $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
362
+
363
+    if($failedlogins < $failed_allowed) {
364
+        //sleep to help prevent brute force attacks
365
+        $sleep = (int) $failedlogins / 2;
366
+        if($sleep > 5) {
367
+            $sleep = 5;
368
+        }
369
+        sleep($sleep);
370
+    }
371
+    @session_destroy();
372
+    session_unset();
373
+    return;
374 374
 }
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
2
+if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
3 3
 	header('HTTP/1.0 404 Not Found');
4 4
 	exit('error');
5 5
 }
6
-define('IN_MANAGER_MODE', true);  // we use this to make sure files are accessed through
6
+define('IN_MANAGER_MODE', true); // we use this to make sure files are accessed through
7 7
 define('MODX_API_MODE', true);
8
-include_once(__DIR__ . '/../../index.php');
8
+include_once(__DIR__.'/../../index.php');
9 9
 $modx->db->connect();
10 10
 $modx->getSettings();
11 11
 $modx->invokeEvent('OnManagerPageInit');
12 12
 $modx->loadExtension('ManagerAPI');
13 13
 $modx->loadExtension('phpass');
14 14
 
15
-$core_path = MODX_MANAGER_PATH . 'includes/';
15
+$core_path = MODX_MANAGER_PATH.'includes/';
16 16
 // include_once the language file
17 17
 $_lang = array();
18 18
 include_once("{$core_path}lang/english.inc.php");
19 19
 
20
-if($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) {
20
+if ($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) {
21 21
 	include_once("{$core_path}lang/{$manager_language}.inc.php");
22 22
 }
23 23
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 include_once("{$core_path}log.class.inc.php");
26 26
 
27 27
 // Initialize System Alert Message Queque
28
-if(!isset($_SESSION['SystemAlertMsgQueque'])) {
28
+if (!isset($_SESSION['SystemAlertMsgQueque'])) {
29 29
 	$_SESSION['SystemAlertMsgQueque'] = array();
30 30
 }
31 31
 $SystemAlertMsgQueque = &$_SESSION['SystemAlertMsgQueque'];
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 $rs = $modx->db->select($fields, $from, $where);
52 52
 $limit = $modx->db->getRecordCount($rs);
53 53
 
54
-if($limit == 0 || $limit > 1) {
54
+if ($limit == 0 || $limit > 1) {
55 55
 	jsAlert($_lang['login_processor_unknown_user']);
56 56
 	return;
57 57
 }
@@ -73,32 +73,32 @@  discard block
 block discarded – undo
73 73
 
74 74
 // get the user settings from the database
75 75
 $rs = $modx->db->select('setting_name, setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_value!=''");
76
-while($row = $modx->db->getRow($rs)) {
76
+while ($row = $modx->db->getRow($rs)) {
77 77
 	extract($row);
78 78
 	${$setting_name} = $setting_value;
79 79
 }
80 80
 
81 81
 // blocked due to number of login errors.
82
-if($failedlogins >= $failed_allowed && $blockeduntildate > time()) {
82
+if ($failedlogins >= $failed_allowed && $blockeduntildate > time()) {
83 83
 	@session_destroy();
84 84
 	session_unset();
85
-	if($cip = getenv("HTTP_CLIENT_IP")) {
85
+	if ($cip = getenv("HTTP_CLIENT_IP")) {
86 86
 		$ip = $cip;
87
-	} elseif($cip = getenv("HTTP_X_FORWARDED_FOR")) {
87
+	} elseif ($cip = getenv("HTTP_X_FORWARDED_FOR")) {
88 88
 		$ip = $cip;
89
-	} elseif($cip = getenv("REMOTE_ADDR")) {
89
+	} elseif ($cip = getenv("REMOTE_ADDR")) {
90 90
 		$ip = $cip;
91 91
 	} else {
92 92
 		$ip = "UNKNOWN";
93 93
 	}
94 94
 	$log = new logHandler;
95
-	$log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip);
95
+	$log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: ".$ip);
96 96
 	jsAlert($_lang['login_processor_many_failed_logins']);
97 97
 	return;
98 98
 }
99 99
 
100 100
 // blocked due to number of login errors, but get to try again
101
-if($failedlogins >= $failed_allowed && $blockeduntildate < time()) {
101
+if ($failedlogins >= $failed_allowed && $blockeduntildate < time()) {
102 102
 	$fields = array();
103 103
 	$fields['failedlogincount'] = '0';
104 104
 	$fields['blockeduntil'] = time() - 1;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 }
107 107
 
108 108
 // this user has been blocked by an admin, so no way he's loggin in!
109
-if($blocked == '1') {
109
+if ($blocked == '1') {
110 110
 	@session_destroy();
111 111
 	session_unset();
112 112
 	jsAlert($_lang['login_processor_blocked1']);
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 }
115 115
 
116 116
 // blockuntil: this user has a block until date
117
-if($blockeduntildate > time()) {
117
+if ($blockeduntildate > time()) {
118 118
 	@session_destroy();
119 119
 	session_unset();
120 120
 	jsAlert($_lang['login_processor_blocked2']);
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 }
123 123
 
124 124
 // blockafter: this user has a block after date
125
-if($blockedafterdate > 0 && $blockedafterdate < time()) {
125
+if ($blockedafterdate > 0 && $blockedafterdate < time()) {
126 126
 	@session_destroy();
127 127
 	session_unset();
128 128
 	jsAlert($_lang['login_processor_blocked3']);
@@ -130,24 +130,24 @@  discard block
 block discarded – undo
130 130
 }
131 131
 
132 132
 // allowed ip
133
-if($allowed_ip) {
134
-	if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) {
135
-		if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) {
133
+if ($allowed_ip) {
134
+	if (($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) {
135
+		if (gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) {
136 136
 			jsAlert($_lang['login_processor_remotehost_ip']);
137 137
 			return;
138 138
 		}
139 139
 	}
140
-	if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) {
140
+	if (!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) {
141 141
 		jsAlert($_lang['login_processor_remote_ip']);
142 142
 		return;
143 143
 	}
144 144
 }
145 145
 
146 146
 // allowed days
147
-if($allowed_days) {
147
+if ($allowed_days) {
148 148
 	$date = getdate();
149 149
 	$day = $date['wday'] + 1;
150
-	if(strpos($allowed_days, $day) === false) {
150
+	if (strpos($allowed_days, $day) === false) {
151 151
 		jsAlert($_lang['login_processor_date']);
152 152
 		return;
153 153
 	}
@@ -164,33 +164,33 @@  discard block
 block discarded – undo
164 164
 
165 165
 // check if plugin authenticated the user
166 166
 $matchPassword = false;
167
-if(!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) {
167
+if (!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) {
168 168
 	// check user password - local authentication
169 169
 	$hashType = $modx->manager->getHashType($dbasePassword);
170
-	if($hashType == 'phpass') {
170
+	if ($hashType == 'phpass') {
171 171
 		$matchPassword = login($username, $_REQUEST['password'], $dbasePassword);
172
-	} elseif($hashType == 'md5') {
172
+	} elseif ($hashType == 'md5') {
173 173
 		$matchPassword = loginMD5($internalKey, $_REQUEST['password'], $dbasePassword, $username);
174
-	} elseif($hashType == 'v1') {
174
+	} elseif ($hashType == 'v1') {
175 175
 		$matchPassword = loginV1($internalKey, $_REQUEST['password'], $dbasePassword, $username);
176 176
 	} else {
177 177
 		$matchPassword = false;
178 178
 	}
179
-} else if($rt === true || (is_array($rt) && in_array(true, $rt))) {
179
+} else if ($rt === true || (is_array($rt) && in_array(true, $rt))) {
180 180
 	$matchPassword = true;
181 181
 }
182 182
 
183
-if(!$matchPassword) {
183
+if (!$matchPassword) {
184 184
 	jsAlert($_lang['login_processor_wrong_password']);
185 185
 	incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
186 186
 	return;
187 187
 }
188 188
 
189
-if($modx->config['use_captcha'] == 1) {
190
-	if(!isset ($_SESSION['veriword'])) {
189
+if ($modx->config['use_captcha'] == 1) {
190
+	if (!isset ($_SESSION['veriword'])) {
191 191
 		jsAlert($_lang['login_processor_captcha_config']);
192 192
 		return;
193
-	} elseif($_SESSION['veriword'] != $captcha_code) {
193
+	} elseif ($_SESSION['veriword'] != $captcha_code) {
194 194
 		jsAlert($_lang['login_processor_bad_code']);
195 195
 		incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
196 196
 		return;
@@ -218,17 +218,17 @@  discard block
 block discarded – undo
218 218
 $_SESSION['mgrPermissions'] = $modx->db->getRow($rs);
219 219
 
220 220
 // successful login so reset fail count and update key values
221
-$modx->db->update('failedlogincount=0, ' . 'logincount=logincount+1, ' . 'lastlogin=thislogin, ' . 'thislogin=' . time() . ', ' . "sessionid='{$currentsessionid}'", '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
221
+$modx->db->update('failedlogincount=0, '.'logincount=logincount+1, '.'lastlogin=thislogin, '.'thislogin='.time().', '."sessionid='{$currentsessionid}'", '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
222 222
 
223 223
 // get user's document groups
224 224
 $i = 0;
225
-$rs = $modx->db->select('uga.documentgroup', $modx->getFullTableName('member_groups') . ' ug
226
-		INNER JOIN ' . $modx->getFullTableName('membergroup_access') . ' uga ON uga.membergroup=ug.user_group', "ug.member='{$internalKey}'");
225
+$rs = $modx->db->select('uga.documentgroup', $modx->getFullTableName('member_groups').' ug
226
+		INNER JOIN ' . $modx->getFullTableName('membergroup_access').' uga ON uga.membergroup=ug.user_group', "ug.member='{$internalKey}'");
227 227
 $_SESSION['mgrDocgroups'] = $modx->db->getColumn('documentgroup', $rs);
228 228
 
229 229
 $_SESSION['mgrToken'] = md5($currentsessionid);
230 230
 
231
-if($rememberme == '1') {
231
+if ($rememberme == '1') {
232 232
 	$_SESSION['modx.mgr.session.cookie.lifetime'] = intval($modx->config['session.cookie.lifetime']);
233 233
 
234 234
 	// Set a cookie separate from the session cookie with the username in it. 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	global $https_port;
237 237
 
238 238
 	$secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port);
239
-	if(version_compare(PHP_VERSION, '5.2', '<')) {
239
+	if (version_compare(PHP_VERSION, '5.2', '<')) {
240 240
 		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure);
241 241
 	} else {
242 242
 		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true);
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 // Check if user already has an active session, if not check if user pressed logout end of last session
252 252
 $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_user_sessions'), "internalKey='{$internalKey}'");
253 253
 $activeSession = $modx->db->getValue($rs);
254
-if(!$activeSession) {
254
+if (!$activeSession) {
255 255
 	$rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8");
256
-	if($lastHit = $modx->db->getValue($rs)) {
256
+	if ($lastHit = $modx->db->getValue($rs)) {
257 257
 		$_SESSION['show_logout_reminder'] = array(
258 258
 			'type' => 'logout_reminder',
259 259
 			'lastHit' => $lastHit
@@ -275,16 +275,16 @@  discard block
 block discarded – undo
275 275
 // check if we should redirect user to a web page
276 276
 $rs = $modx->db->select('setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_name='manager_login_startup'");
277 277
 $id = intval($modx->db->getValue($rs));
278
-if($id > 0) {
279
-	$header = 'Location: ' . $modx->makeUrl($id, '', '', 'full');
280
-	if($_POST['ajax'] == 1) {
278
+if ($id > 0) {
279
+	$header = 'Location: '.$modx->makeUrl($id, '', '', 'full');
280
+	if ($_POST['ajax'] == 1) {
281 281
 		echo $header;
282 282
 	} else {
283 283
 		header($header);
284 284
 	}
285 285
 } else {
286
-	$header = 'Location: ' . MODX_MANAGER_URL;
287
-	if($_POST['ajax'] == 1) {
286
+	$header = 'Location: '.MODX_MANAGER_URL;
287
+	if ($_POST['ajax'] == 1) {
288 288
 		echo $header;
289 289
 	} else {
290 290
 		header($header);
@@ -292,35 +292,35 @@  discard block
 block discarded – undo
292 292
 }
293 293
 
294 294
 // show javascript alert
295
-function jsAlert($msg) {
295
+function jsAlert($msg){
296 296
 	global $modx;
297
-	if($_POST['ajax'] != 1) {
298
-		echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>";
297
+	if ($_POST['ajax'] != 1) {
298
+		echo "<script>window.setTimeout(\"alert('".addslashes($modx->db->escape($msg))."')\",10);history.go(-1)</script>";
299 299
 	} else {
300
-		echo $msg . "\n";
300
+		echo $msg."\n";
301 301
 	}
302 302
 }
303 303
 
304
-function login($username, $givenPassword, $dbasePassword) {
304
+function login($username, $givenPassword, $dbasePassword){
305 305
 	global $modx;
306 306
 	return $modx->phpass->CheckPassword($givenPassword, $dbasePassword);
307 307
 }
308 308
 
309
-function loginV1($internalKey, $givenPassword, $dbasePassword, $username) {
309
+function loginV1($internalKey, $givenPassword, $dbasePassword, $username){
310 310
 	global $modx;
311 311
 
312 312
 	$user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey);
313 313
 
314
-	if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) {
314
+	if (!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) {
315 315
 		$modx->config['pwd_hash_algo'] = 'UNCRYPT';
316 316
 	}
317 317
 
318
-	if($user_algo !== $modx->config['pwd_hash_algo']) {
318
+	if ($user_algo !== $modx->config['pwd_hash_algo']) {
319 319
 		$bk_pwd_hash_algo = $modx->config['pwd_hash_algo'];
320 320
 		$modx->config['pwd_hash_algo'] = $user_algo;
321 321
 	}
322 322
 
323
-	if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) {
323
+	if ($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) {
324 324
 		return false;
325 325
 	}
326 326
 
@@ -329,17 +329,17 @@  discard block
 block discarded – undo
329 329
 	return true;
330 330
 }
331 331
 
332
-function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) {
332
+function loginMD5($internalKey, $givenPassword, $dbasePassword, $username){
333 333
 	global $modx;
334 334
 
335
-	if($dbasePassword != md5($givenPassword)) {
335
+	if ($dbasePassword != md5($givenPassword)) {
336 336
 		return false;
337 337
 	}
338 338
 	updateNewHash($username, $givenPassword);
339 339
 	return true;
340 340
 }
341 341
 
342
-function updateNewHash($username, $password) {
342
+function updateNewHash($username, $password){
343 343
 	global $modx;
344 344
 
345 345
 	$field = array();
@@ -347,23 +347,23 @@  discard block
 block discarded – undo
347 347
 	$modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'");
348 348
 }
349 349
 
350
-function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) {
350
+function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes){
351 351
 	global $modx;
352 352
 
353 353
 	$failedlogins += 1;
354 354
 
355 355
 	$fields = array('failedlogincount' => $failedlogins);
356
-	if($failedlogins >= $failed_allowed) //block user for too many fail attempts
356
+	if ($failedlogins >= $failed_allowed) //block user for too many fail attempts
357 357
 	{
358 358
 		$fields['blockeduntil'] = time() + ($blocked_minutes * 60);
359 359
 	}
360 360
 
361 361
 	$modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
362 362
 
363
-	if($failedlogins < $failed_allowed) {
363
+	if ($failedlogins < $failed_allowed) {
364 364
 		//sleep to help prevent brute force attacks
365 365
 		$sleep = (int) $failedlogins / 2;
366
-		if($sleep > 5) {
366
+		if ($sleep > 5) {
367 367
 			$sleep = 5;
368 368
 		}
369 369
 		sleep($sleep);
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -292,7 +292,8 @@  discard block
 block discarded – undo
292 292
 }
293 293
 
294 294
 // show javascript alert
295
-function jsAlert($msg) {
295
+function jsAlert($msg)
296
+{
296 297
 	global $modx;
297 298
 	if($_POST['ajax'] != 1) {
298 299
 		echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>";
@@ -301,12 +302,14 @@  discard block
 block discarded – undo
301 302
 	}
302 303
 }
303 304
 
304
-function login($username, $givenPassword, $dbasePassword) {
305
+function login($username, $givenPassword, $dbasePassword)
306
+{
305 307
 	global $modx;
306 308
 	return $modx->phpass->CheckPassword($givenPassword, $dbasePassword);
307 309
 }
308 310
 
309
-function loginV1($internalKey, $givenPassword, $dbasePassword, $username) {
311
+function loginV1($internalKey, $givenPassword, $dbasePassword, $username)
312
+{
310 313
 	global $modx;
311 314
 
312 315
 	$user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey);
@@ -329,7 +332,8 @@  discard block
 block discarded – undo
329 332
 	return true;
330 333
 }
331 334
 
332
-function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) {
335
+function loginMD5($internalKey, $givenPassword, $dbasePassword, $username)
336
+{
333 337
 	global $modx;
334 338
 
335 339
 	if($dbasePassword != md5($givenPassword)) {
@@ -339,7 +343,8 @@  discard block
 block discarded – undo
339 343
 	return true;
340 344
 }
341 345
 
342
-function updateNewHash($username, $password) {
346
+function updateNewHash($username, $password)
347
+{
343 348
 	global $modx;
344 349
 
345 350
 	$field = array();
@@ -347,16 +352,19 @@  discard block
 block discarded – undo
347 352
 	$modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'");
348 353
 }
349 354
 
350
-function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) {
355
+function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes)
356
+{
351 357
 	global $modx;
352 358
 
353 359
 	$failedlogins += 1;
354 360
 
355 361
 	$fields = array('failedlogincount' => $failedlogins);
356
-	if($failedlogins >= $failed_allowed) //block user for too many fail attempts
362
+	if($failedlogins >= $failed_allowed) {
363
+	    //block user for too many fail attempts
357 364
 	{
358 365
 		$fields['blockeduntil'] = time() + ($blocked_minutes * 60);
359 366
 	}
367
+	}
360 368
 
361 369
 	$modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
362 370
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
 	if(version_compare(PHP_VERSION, '5.2', '<')) {
240 240
 		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure);
241 241
 	} else {
242
-		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true);
242
+		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, null, $secure, true);
243 243
 	}
244 244
 } else {
245 245
 	$_SESSION['modx.mgr.session.cookie.lifetime'] = 0;
Please login to merge, or discard this patch.
manager/frames/nodes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 $parent = intval($_REQUEST['parent']);
23 23
 $expandAll = intval($_REQUEST['expandAll']);
24 24
 $output = '';
25
-$theme = $manager_theme . "/";
25
+$theme = $manager_theme."/";
26 26
 $hereid = isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) ? $_REQUEST['id'] : '';
27 27
 
28 28
 if (isset($_REQUEST['showonlyfolders'])) {
Please login to merge, or discard this patch.
manager/frames/1.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -236,9 +236,9 @@
 block discarded – undo
236 236
         lockedElementsTranslation: <?= json_encode($unlockTranslations, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE) . "\n" ?>
237 237
       };
238 238
       <?php
239
-      $opened = array_filter(array_map('intval', explode('|', $_SESSION['openedArray'])));
240
-      echo (empty($opened) ? '' : 'modx.openedArray[' . implode("] = 1;\n		modx.openedArray[", $opened) . '] = 1;') . "\n";
241
-      ?>
239
+        $opened = array_filter(array_map('intval', explode('|', $_SESSION['openedArray'])));
240
+        echo (empty($opened) ? '' : 'modx.openedArray[' . implode("] = 1;\n		modx.openedArray[", $opened) . '] = 1;') . "\n";
241
+        ?>
242 242
     </script>
243 243
     <script src="media/style/<?= $modx->config['manager_theme'] ?>/js/modx.min.js?v=<?= $lastInstallTime ?>"></script>
244 244
     <?php if ($modx->config['show_picker'] != "0") { ?>
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 }
48 48
 
49 49
 if (isset($_COOKIE['MODX_themeColor'])) {
50
-    $body_class .= ' ' . $_COOKIE['MODX_themeColor'];
50
+    $body_class .= ' '.$_COOKIE['MODX_themeColor'];
51 51
 }
52 52
 
53 53
 if (isset($modx->pluginCache['ElementsInTree'])) {
@@ -75,36 +75,36 @@  discard block
 block discarded – undo
75 75
     $user['which_browser'] = $modx->config['which_browser'];
76 76
 }
77 77
 
78
-$css = 'media/style/' . $modx->config['manager_theme'] . '/css/page.css?v=' . $lastInstallTime;
78
+$css = 'media/style/'.$modx->config['manager_theme'].'/css/page.css?v='.$lastInstallTime;
79 79
 
80 80
 if ($modx->config['manager_theme'] == 'default') {
81
-    if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) {
82
-        require_once MODX_BASE_PATH . 'assets/lib/Formatter/CSSMinify.php';
81
+    if (!file_exists(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css') && is_writable(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css')) {
82
+        require_once MODX_BASE_PATH.'assets/lib/Formatter/CSSMinify.php';
83 83
         $minifier = new Formatter\CSSMinify();
84
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css');
85
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/font-awesome/css/font-awesome.min.css');
86
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/fonts.css');
87
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/forms.css');
88
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/mainmenu.css');
89
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/tree.css');
90
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/custom.css');
91
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/tabpane.css');
92
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/contextmenu.css');
93
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/index.css');
94
-        $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/main.css');
84
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/common/bootstrap/css/bootstrap.min.css');
85
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/common/font-awesome/css/font-awesome.min.css');
86
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/fonts.css');
87
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/forms.css');
88
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/mainmenu.css');
89
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/tree.css');
90
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/custom.css');
91
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/tabpane.css');
92
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/contextmenu.css');
93
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/index.css');
94
+        $minifier->addFile(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/main.css');
95 95
         $css = $minifier->minify();
96
-        file_put_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css', $css);
96
+        file_put_contents(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css', $css);
97 97
     }
98
-    if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) {
99
-        $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime;
98
+    if (file_exists(MODX_MANAGER_PATH.'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css')) {
99
+        $css = 'media/style/'.$modx->config['manager_theme'].'/css/styles.min.css?v='.$lastInstallTime;
100 100
     }
101 101
 }
102 102
 
103
-$modx->config['global_tabs'] = (int)($modx->config['global_tabs'] && ($user['role'] == 1 || $modx->hasPermission('edit_template') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_plugin')));
103
+$modx->config['global_tabs'] = (int) ($modx->config['global_tabs'] && ($user['role'] == 1 || $modx->hasPermission('edit_template') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_plugin')));
104 104
 
105 105
 ?>
106 106
 <!DOCTYPE html>
107
-<html <?= (isset($modx_textdir) && $modx_textdir ? 'dir="rtl" lang="' : 'lang="') . $mxla . '" xml:lang="' . $mxla . '"' ?>>
107
+<html <?= (isset($modx_textdir) && $modx_textdir ? 'dir="rtl" lang="' : 'lang="').$mxla.'" xml:lang="'.$mxla.'"' ?>>
108 108
 <head>
109 109
     <title><?= $site_name ?>- (EVO CMS Manager)</title>
110 110
     <meta http-equiv="Content-Type" content="text/html; charset=<?= $modx_manager_charset ?>" />
@@ -135,20 +135,20 @@  discard block
 block discarded – undo
135 135
         MODX_SITE_URL: '<?= MODX_SITE_URL ?>',
136 136
         MODX_MANAGER_URL: '<?= MODX_MANAGER_URL ?>',
137 137
         user: {
138
-          role: <?= (int)$user['role'] ?>,
138
+          role: <?= (int) $user['role'] ?>,
139 139
           username: '<?= $user['username'] ?>'
140 140
         },
141 141
         config: {
142 142
           mail_check_timeperiod: <?= $modx->config['mail_check_timeperiod'] ?>,
143
-          menu_height: <?= (int)$menu_height ?>,
144
-          tree_width: <?= (int)$tree_width ?>,
145
-          tree_min_width: <?= (int)$tree_min_width ?>,
146
-          session_timeout: <?= (int)$modx->config['session_timeout'] ?>,
147
-          site_start: <?= (int)$modx->config['site_start'] ?>,
148
-          tree_page_click: <?=(!empty($modx->config['tree_page_click']) ? (int)$modx->config['tree_page_click'] : 27) ?>,
143
+          menu_height: <?= (int) $menu_height ?>,
144
+          tree_width: <?= (int) $tree_width ?>,
145
+          tree_min_width: <?= (int) $tree_min_width ?>,
146
+          session_timeout: <?= (int) $modx->config['session_timeout'] ?>,
147
+          site_start: <?= (int) $modx->config['site_start'] ?>,
148
+          tree_page_click: <?=(!empty($modx->config['tree_page_click']) ? (int) $modx->config['tree_page_click'] : 27) ?>,
149 149
           theme: '<?= $modx->config['manager_theme'] ?>',
150 150
           which_browser: '<?= $user['which_browser'] ?>',
151
-          layout: <?= (int)$manager_layout ?>,
151
+          layout: <?= (int) $manager_layout ?>,
152 152
           textdir: '<?= $modx_textdir ?>',
153 153
           global_tabs: <?= $modx->config['global_tabs'] ?>
154 154
 
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
           delete a[b];
234 234
         },
235 235
         openedArray: [],
236
-        lockedElementsTranslation: <?= json_encode($unlockTranslations, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE) . "\n" ?>
236
+        lockedElementsTranslation: <?= json_encode($unlockTranslations, JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE)."\n" ?>
237 237
       };
238 238
       <?php
239 239
       $opened = array_filter(array_map('intval', explode('|', $_SESSION['openedArray'])));
240
-      echo (empty($opened) ? '' : 'modx.openedArray[' . implode("] = 1;\n		modx.openedArray[", $opened) . '] = 1;') . "\n";
240
+      echo (empty($opened) ? '' : 'modx.openedArray['.implode("] = 1;\n		modx.openedArray[", $opened).'] = 1;')."\n";
241 241
       ?>
242 242
     </script>
243 243
     <script src="media/style/<?= $modx->config['manager_theme'] ?>/js/modx.min.js?v=<?= $lastInstallTime ?>"></script>
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
                             <a href="javascript:;" class="dropdown-toggle" onclick="return false;">
367 367
                                 <span class="username"><?= $user['username'] ?></span>
368 368
                                 <?php if ($user['photo']) { ?>
369
-                                    <span class="icon photo" style="background-image: url(<?= MODX_SITE_URL . $user['photo'] ?>);"></span>
369
+                                    <span class="icon photo" style="background-image: url(<?= MODX_SITE_URL.$user['photo'] ?>);"></span>
370 370
                                 <?php } else { ?>
371 371
                                     <span class="icon"><?= $_style['menu_user'] ?></span>
372 372
                                 <?php } ?>
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
                                 $version = 'Evolution';
394 394
                                 ?>
395 395
                                 <?php
396
-                                echo sprintf('<li><span class="dropdown-item" title="%s &ndash; %s" %s>' . $version . ' %s</span></li>', $site_name, $modx->getVersionData('full_appname'), $style, $modx->config['settings_version']);
396
+                                echo sprintf('<li><span class="dropdown-item" title="%s &ndash; %s" %s>'.$version.' %s</span></li>', $site_name, $modx->getVersionData('full_appname'), $style, $modx->config['settings_version']);
397 397
                                 ?>
398 398
                             </ul>
399 399
                         </li>
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
     <script type="text/javascript">
533 533
 
534 534
       if (document.getElementById('treeMenu')) {
535
-          <?php if($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin')) { ?>
535
+          <?php if ($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin')) { ?>
536 536
 
537 537
         document.getElementById('treeMenu_openelements').onclick = function(e) {
538 538
           e.preventDefault();
@@ -550,12 +550,12 @@  discard block
 block discarded – undo
550 550
           }
551 551
         };
552 552
           <?php } ?>
553
-          <?php if($use_browser && $modx->hasPermission('assets_images')) { ?>
553
+          <?php if ($use_browser && $modx->hasPermission('assets_images')) { ?>
554 554
 
555 555
         document.getElementById('treeMenu_openimages').onclick = function(e) {
556 556
           e.preventDefault();
557 557
           if (modx.config.global_tabs && !e.shiftKey) {
558
-            modx.tabs({url: '<?= MODX_MANAGER_URL . 'media/browser/' . $which_browser . '/browse.php?filemanager=media/browser/' . $which_browser . '/browse.php&type=images' ?>', title: '<?= $_lang["images_management"] ?>'});
558
+            modx.tabs({url: '<?= MODX_MANAGER_URL.'media/browser/'.$which_browser.'/browse.php?filemanager=media/browser/'.$which_browser.'/browse.php&type=images' ?>', title: '<?= $_lang["images_management"] ?>'});
559 559
           } else {
560 560
             var randomNum = '<?= $_lang["files_files"] ?>';
561 561
             if (e.shiftKey) {
@@ -568,12 +568,12 @@  discard block
 block discarded – undo
568 568
           }
569 569
         };
570 570
           <?php } ?>
571
-          <?php if($use_browser && $modx->hasPermission('assets_files')) { ?>
571
+          <?php if ($use_browser && $modx->hasPermission('assets_files')) { ?>
572 572
 
573 573
         document.getElementById('treeMenu_openfiles').onclick = function(e) {
574 574
           e.preventDefault();
575 575
           if (modx.config.global_tabs && !e.shiftKey) {
576
-            modx.tabs({url: '<?= MODX_MANAGER_URL . 'media/browser/' . $which_browser . '/browse.php?filemanager=media/browser/' . $which_browser . '/browse.php&type=files' ?>', title: '<?= $_lang["files_files"] ?>'});
576
+            modx.tabs({url: '<?= MODX_MANAGER_URL.'media/browser/'.$which_browser.'/browse.php?filemanager=media/browser/'.$which_browser.'/browse.php&type=files' ?>', title: '<?= $_lang["files_files"] ?>'});
577 577
           } else {
578 578
             var randomNum = '<?= $_lang["files_files"] ?>';
579 579
             if (e.shiftKey) {
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 
628 628
 </div>
629 629
 <?php if ($modx->config['show_picker'] != "0") {
630
-    include('media/style/' . $modx->config['manager_theme'] . '/color.switcher.php');
630
+    include('media/style/'.$modx->config['manager_theme'].'/color.switcher.php');
631 631
 } ?>
632 632
 </body>
633 633
 </html>
Please login to merge, or discard this patch.
Braces   +29 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (IN_MANAGER_MODE != "true") {
3
+if (IN_MANAGER_MODE != "true") {
4 4
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
5 5
 }
6 6
 header("X-XSS-Protection: 0");
@@ -12,22 +12,22 @@  discard block
 block discarded – undo
12 12
 
13 13
 $mxla = $modx_lang_attribute ? $modx_lang_attribute : 'en';
14 14
 
15
-if (!isset($modx->config['manager_menu_height'])) {
15
+if (!isset($modx->config['manager_menu_height'])) {
16 16
     $modx->config['manager_menu_height'] = 2.2; // rem
17 17
 }
18 18
 
19
-if (!isset($modx->config['manager_tree_width'])) {
19
+if (!isset($modx->config['manager_tree_width'])) {
20 20
     $modx->config['manager_tree_width'] = 20; // rem
21 21
 }
22 22
 
23
-if (isset($_SESSION['onLoginForwardToAction']) && is_int($_SESSION['onLoginForwardToAction'])) {
23
+if (isset($_SESSION['onLoginForwardToAction']) && is_int($_SESSION['onLoginForwardToAction'])) {
24 24
     $initMainframeAction = $_SESSION['onLoginForwardToAction'];
25 25
     unset($_SESSION['onLoginForwardToAction']);
26
-} else {
26
+} else {
27 27
     $initMainframeAction = 2; // welcome.static
28 28
 }
29 29
 
30
-if (!isset($_SESSION['tree_show_only_folders'])) {
30
+if (!isset($_SESSION['tree_show_only_folders'])) {
31 31
     $_SESSION['tree_show_only_folders'] = 0;
32 32
 }
33 33
 
@@ -36,21 +36,21 @@  discard block
 block discarded – undo
36 36
 $tree_width = $modx->config['manager_tree_width'];
37 37
 $tree_min_width = 0;
38 38
 
39
-if (isset($_COOKIE['MODX_widthSideBar'])) {
39
+if (isset($_COOKIE['MODX_widthSideBar'])) {
40 40
     $MODX_widthSideBar = $_COOKIE['MODX_widthSideBar'];
41
-} else {
41
+} else {
42 42
     $MODX_widthSideBar = $tree_width;
43 43
 }
44 44
 
45
-if (!$MODX_widthSideBar) {
45
+if (!$MODX_widthSideBar) {
46 46
     $body_class .= 'sidebar-closed';
47 47
 }
48 48
 
49
-if (isset($_COOKIE['MODX_themeColor'])) {
49
+if (isset($_COOKIE['MODX_themeColor'])) {
50 50
     $body_class .= ' ' . $_COOKIE['MODX_themeColor'];
51 51
 }
52 52
 
53
-if (isset($modx->pluginCache['ElementsInTree'])) {
53
+if (isset($modx->pluginCache['ElementsInTree'])) {
54 54
     $body_class .= ' ElementsInTree';
55 55
 }
56 56
 
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
     'type8' => $_lang["lock_element_type_8"]
67 67
 );
68 68
 
69
-foreach ($unlockTranslations as $key => $value) {
69
+foreach ($unlockTranslations as $key => $value) {
70 70
     $unlockTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value);
71 71
 }
72 72
 
73 73
 $user = $modx->getUserInfo($modx->getLoginUserID());
74
-if ($user['which_browser'] == 'default') {
74
+if ($user['which_browser'] == 'default') {
75 75
     $user['which_browser'] = $modx->config['which_browser'];
76 76
 }
77 77
 
78 78
 $css = 'media/style/' . $modx->config['manager_theme'] . '/css/page.css?v=' . $lastInstallTime;
79 79
 
80
-if ($modx->config['manager_theme'] == 'default') {
81
-    if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) {
80
+if ($modx->config['manager_theme'] == 'default') {
81
+    if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) {
82 82
         require_once MODX_BASE_PATH . 'assets/lib/Formatter/CSSMinify.php';
83 83
         $minifier = new Formatter\CSSMinify();
84 84
         $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css');
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         $css = $minifier->minify();
96 96
         file_put_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css', $css);
97 97
     }
98
-    if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) {
98
+    if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) {
99 99
         $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime;
100 100
     }
101 101
 }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     <?php
250 250
     // invoke OnManagerTopPrerender event
251 251
     $evtOut = $modx->invokeEvent('OnManagerTopPrerender', $_REQUEST);
252
-    if (is_array($evtOut)) {
252
+    if (is_array($evtOut)) {
253 253
         echo implode("\n", $evtOut);
254 254
     }
255 255
     ?>
@@ -420,9 +420,12 @@  discard block
 block discarded – undo
420 420
             <div id="evo-tab-page-home" class="evo-tab-page show">
421 421
                 <iframe id="mainframe" src="index.php?a=<?= $initMainframeAction ?>" scrolling="auto" frameborder="0" onload="modx.main.onload(event);"></iframe>
422 422
             </div>
423
-        <?php else: ?>
423
+        <?php else {
424
+    : ?>
424 425
             <iframe id="mainframe" name="main" src="index.php?a=<?= $initMainframeAction ?>" scrolling="auto" frameborder="0" onload="modx.main.onload(event);"></iframe>
425
-        <?php endif; ?>
426
+        <?php endif;
427
+}
428
+?>
426 429
         <div id="mainloader"></div>
427 430
     </div>
428 431
     <div id="resizer"></div>
@@ -435,11 +438,11 @@  discard block
 block discarded – undo
435 438
             'tree_sortdir',
436 439
             'tree_nodename'
437 440
         );
438
-        foreach ($sortParams as $param) {
439
-            if (isset($_REQUEST[$param])) {
441
+        foreach ($sortParams as $param) {
442
+            if (isset($_REQUEST[$param])) {
440 443
                 $modx->manager->saveLastUserSetting($param, $_REQUEST[$param]);
441 444
                 $_SESSION[$param] = $_REQUEST[$param];
442
-            } else if (!isset($_SESSION[$param])) {
445
+            } else if (!isset($_SESSION[$param])) {
443 446
                 $_SESSION[$param] = $modx->manager->getLastUserSetting($param);
444 447
             }
445 448
         }
@@ -519,9 +522,9 @@  discard block
 block discarded – undo
519 522
     </div>
520 523
 
521 524
     <?php
522
-    function constructLink($action, $img, $text, $allowed)
523
-    {
524
-        if ($allowed == 1) {
525
+    function constructLink($action, $img, $text, $allowed)
526
+    {
527
+        if ($allowed == 1) {
525 528
             echo sprintf('<div class="menuLink" id="item%s" onclick="modx.tree.menuHandler(%s);">', $action, $action);
526 529
             echo sprintf('<i class="%s"></i> %s</div>', $img, $text);
527 530
         }
@@ -626,7 +629,7 @@  discard block
 block discarded – undo
626 629
     ?>
627 630
 
628 631
 </div>
629
-<?php if ($modx->config['show_picker'] != "0") {
632
+<?php if ($modx->config['show_picker'] != "0") {
630 633
     include('media/style/' . $modx->config['manager_theme'] . '/color.switcher.php');
631 634
 } ?>
632 635
 </body>
Please login to merge, or discard this patch.