@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | */ |
132 | 132 | function ProcessFile($file) { |
133 | 133 | // get the file |
134 | - $buffer = @file_get_contents($file); |
|
135 | - if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
134 | + $buffer = @file_get_contents($file); |
|
135 | + if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
136 | 136 | return $buffer; |
137 | 137 | } |
138 | 138 | |
@@ -167,21 +167,21 @@ discard block |
||
167 | 167 | */ |
168 | 168 | function parseTvValues($param, $tvsArray) |
169 | 169 | { |
170 | - global $modx; |
|
171 | - $tvsArray = is_array($modx->documentObject) ? array_merge($tvsArray, $modx->documentObject) : $tvsArray; |
|
172 | - if (strpos($param, '[*') !== false) { |
|
173 | - $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
|
174 | - foreach ($matches[0] as $i=>$match) { |
|
175 | - if(isset($tvsArray[ $matches[1][$i] ])) { |
|
176 | - if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
177 | - $value = $tvsArray[$matches[1][$i]]['value']; |
|
178 | - $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
|
179 | - } else { |
|
180 | - $value = $tvsArray[ $matches[1][$i] ]; |
|
181 | - } |
|
182 | - $param = str_replace($match, $value, $param); |
|
183 | - } |
|
184 | - } |
|
185 | - } |
|
186 | - return $param; |
|
170 | + global $modx; |
|
171 | + $tvsArray = is_array($modx->documentObject) ? array_merge($tvsArray, $modx->documentObject) : $tvsArray; |
|
172 | + if (strpos($param, '[*') !== false) { |
|
173 | + $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
|
174 | + foreach ($matches[0] as $i=>$match) { |
|
175 | + if(isset($tvsArray[ $matches[1][$i] ])) { |
|
176 | + if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
177 | + $value = $tvsArray[$matches[1][$i]]['value']; |
|
178 | + $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
|
179 | + } else { |
|
180 | + $value = $tvsArray[ $matches[1][$i] ]; |
|
181 | + } |
|
182 | + $param = str_replace($match, $value, $param); |
|
183 | + } |
|
184 | + } |
|
185 | + } |
|
186 | + return $param; |
|
187 | 187 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * Created by Raymond Irving Feb, 2005 |
5 | 5 | */ |
6 | 6 | global $BINDINGS; // Array of supported bindings. must be upper case |
7 | -$BINDINGS = array ( |
|
7 | +$BINDINGS = array( |
|
8 | 8 | 'FILE', |
9 | 9 | 'CHUNK', |
10 | 10 | 'DOCUMENT', |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | * @param array $tvsArray |
23 | 23 | * @return string |
24 | 24 | */ |
25 | -function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) { |
|
25 | +function ProcessTVCommand($value, $name = '', $docid = '', $src = 'docform', $tvsArray = array()){ |
|
26 | 26 | global $modx; |
27 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
27 | + $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier; |
|
28 | 28 | $nvalue = trim($value); |
29 | 29 | if (substr($nvalue, 0, 1) != '@') |
30 | 30 | return $value; |
31 | - elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
31 | + elseif (isset($modx->config['enable_bindings']) && $modx->config['enable_bindings'] != 1 && $src === 'docform') { |
|
32 | 32 | return '@Bindings is disabled.'; |
33 | 33 | } |
34 | 34 | else { |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | break; |
55 | 55 | |
56 | 56 | case "SELECT" : // selects a record from the cms database |
57 | - $rt = array (); |
|
58 | - $replacementVars = array ( |
|
57 | + $rt = array(); |
|
58 | + $replacementVars = array( |
|
59 | 59 | 'DBASE' => $modx->db->config['dbase'], |
60 | 60 | 'PREFIX' => $modx->db->config['table_prefix'] |
61 | 61 | ); |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | break; |
97 | 97 | |
98 | 98 | case 'DIRECTORY' : |
99 | - $files = array (); |
|
100 | - $path = $modx->config['base_path'] . $param; |
|
99 | + $files = array(); |
|
100 | + $path = $modx->config['base_path'].$param; |
|
101 | 101 | if (substr($path, -1, 1) != '/') { |
102 | 102 | $path .= '/'; |
103 | 103 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @param $file |
130 | 130 | * @return string |
131 | 131 | */ |
132 | -function ProcessFile($file) { |
|
132 | +function ProcessFile($file){ |
|
133 | 133 | // get the file |
134 | 134 | $buffer = @file_get_contents($file); |
135 | 135 | if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | { |
147 | 147 | global $BINDINGS; |
148 | 148 | $binding_array = array(); |
149 | - foreach($BINDINGS as $cmd) |
|
149 | + foreach ($BINDINGS as $cmd) |
|
150 | 150 | { |
151 | - if(strpos($binding_string,'@'.$cmd)===0) |
|
151 | + if (strpos($binding_string, '@'.$cmd) === 0) |
|
152 | 152 | { |
153 | - $code = substr($binding_string,strlen($cmd)+1); |
|
154 | - $binding_array = array($cmd,trim($code)); |
|
153 | + $code = substr($binding_string, strlen($cmd) + 1); |
|
154 | + $binding_array = array($cmd, trim($code)); |
|
155 | 155 | break; |
156 | 156 | } |
157 | 157 | } |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | if (strpos($param, '[*') !== false) { |
173 | 173 | $matches = $modx->getTagsFromContent($param, '[*', '*]'); |
174 | 174 | foreach ($matches[0] as $i=>$match) { |
175 | - if(isset($tvsArray[ $matches[1][$i] ])) { |
|
176 | - if(is_array($tvsArray[ $matches[1][$i] ])) { |
|
175 | + if (isset($tvsArray[$matches[1][$i]])) { |
|
176 | + if (is_array($tvsArray[$matches[1][$i]])) { |
|
177 | 177 | $value = $tvsArray[$matches[1][$i]]['value']; |
178 | 178 | $value = $value === '' ? $tvsArray[$matches[1][$i]]['default_text'] : $value; |
179 | 179 | } else { |
180 | - $value = $tvsArray[ $matches[1][$i] ]; |
|
180 | + $value = $tvsArray[$matches[1][$i]]; |
|
181 | 181 | } |
182 | 182 | $param = str_replace($match, $value, $param); |
183 | 183 | } |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | * @param array $tvsArray |
23 | 23 | * @return string |
24 | 24 | */ |
25 | -function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) { |
|
25 | +function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) |
|
26 | +{ |
|
26 | 27 | global $modx; |
27 | 28 | $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
28 | 29 | $nvalue = trim($value); |
29 | - if (substr($nvalue, 0, 1) != '@') |
|
30 | - return $value; |
|
31 | - elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
30 | + if (substr($nvalue, 0, 1) != '@') { |
|
31 | + return $value; |
|
32 | + } elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
32 | 33 | return '@Bindings is disabled.'; |
33 | - } |
|
34 | - else { |
|
34 | + } else { |
|
35 | 35 | list ($cmd, $param) = ParseCommand($nvalue); |
36 | 36 | $cmd = trim($cmd); |
37 | 37 | $param = parseTvValues($param, $tvsArray); |
@@ -47,10 +47,11 @@ discard block |
||
47 | 47 | |
48 | 48 | case "DOCUMENT" : // retrieve a document and process it's content |
49 | 49 | $rs = $modx->getDocument($param); |
50 | - if (is_array($rs)) |
|
51 | - $output = $rs['content']; |
|
52 | - else |
|
53 | - $output = "Unable to locate document $param"; |
|
50 | + if (is_array($rs)) { |
|
51 | + $output = $rs['content']; |
|
52 | + } else { |
|
53 | + $output = "Unable to locate document $param"; |
|
54 | + } |
|
54 | 55 | break; |
55 | 56 | |
56 | 57 | case "SELECT" : // selects a record from the cms database |
@@ -80,8 +81,10 @@ discard block |
||
80 | 81 | |
81 | 82 | // Grab document regardless of publish status |
82 | 83 | $doc = $modx->getPageInfo($parent_id, 0, 'id,parent,published'); |
83 | - if ($doc['parent'] != 0 && !$doc['published']) |
|
84 | - continue; // hide unpublished docs if we're not at the top |
|
84 | + if ($doc['parent'] != 0 && !$doc['published']) { |
|
85 | + continue; |
|
86 | + } |
|
87 | + // hide unpublished docs if we're not at the top |
|
85 | 88 | |
86 | 89 | $tv = $modx->getTemplateVar($name, '*', $doc['id'], $doc['published']); |
87 | 90 | |
@@ -129,10 +132,13 @@ discard block |
||
129 | 132 | * @param $file |
130 | 133 | * @return string |
131 | 134 | */ |
132 | -function ProcessFile($file) { |
|
135 | +function ProcessFile($file) |
|
136 | +{ |
|
133 | 137 | // get the file |
134 | 138 | $buffer = @file_get_contents($file); |
135 | - if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
139 | + if ($buffer === false) { |
|
140 | + $buffer = " Could not retrieve document '$file'."; |
|
141 | + } |
|
136 | 142 | return $buffer; |
137 | 143 | } |
138 | 144 | |
@@ -146,10 +152,8 @@ discard block |
||
146 | 152 | { |
147 | 153 | global $BINDINGS; |
148 | 154 | $binding_array = array(); |
149 | - foreach($BINDINGS as $cmd) |
|
150 | - { |
|
151 | - if(strpos($binding_string,'@'.$cmd)===0) |
|
152 | - { |
|
155 | + foreach($BINDINGS as $cmd) { |
|
156 | + if(strpos($binding_string,'@'.$cmd)===0) { |
|
153 | 157 | $code = substr($binding_string,strlen($cmd)+1); |
154 | 158 | $binding_array = array($cmd,trim($code)); |
155 | 159 | break; |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
4 | 4 | } |
5 | 5 | if(!$modx->hasPermission('save_user')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $modx->loadExtension('phpass'); |
@@ -45,134 +45,134 @@ discard block |
||
45 | 45 | |
46 | 46 | // verify password |
47 | 47 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
48 | - webAlertAndQuit("Password typed is mismatched"); |
|
48 | + webAlertAndQuit("Password typed is mismatched"); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // verify email |
52 | 52 | if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
53 | - webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
53 | + webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | // verify admin security |
57 | 57 | if($_SESSION['mgrRole'] != 1) { |
58 | - // Check to see if user tried to spoof a "1" (admin) role |
|
59 | - if(!$modx->hasPermission('save_role')) { |
|
60 | - webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!"); |
|
61 | - } |
|
62 | - // Verify that the user being edited wasn't an admin and the user ID got spoofed |
|
63 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
|
64 | - $limit = $modx->db->getValue($rs); |
|
65 | - if($limit > 0) { |
|
66 | - webAlertAndQuit("You cannot alter an administrative user."); |
|
67 | - } |
|
58 | + // Check to see if user tried to spoof a "1" (admin) role |
|
59 | + if(!$modx->hasPermission('save_role')) { |
|
60 | + webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!"); |
|
61 | + } |
|
62 | + // Verify that the user being edited wasn't an admin and the user ID got spoofed |
|
63 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
|
64 | + $limit = $modx->db->getValue($rs); |
|
65 | + if($limit > 0) { |
|
66 | + webAlertAndQuit("You cannot alter an administrative user."); |
|
67 | + } |
|
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | 71 | switch($input['mode']) { |
72 | - case '11' : // new user |
|
73 | - // check if this user name already exist |
|
74 | - $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
|
75 | - $limit = $modx->db->getValue($rs); |
|
76 | - if($limit > 0) { |
|
77 | - webAlertAndQuit("User name is already in use!"); |
|
78 | - } |
|
79 | - |
|
80 | - // check if the email address already exist |
|
81 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
|
82 | - $limit = $modx->db->getValue($rs); |
|
83 | - if($limit > 0) { |
|
84 | - webAlertAndQuit("Email is already in use!"); |
|
85 | - } |
|
86 | - |
|
87 | - // generate a new password for this user |
|
88 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
89 | - if(strlen($specifiedpassword) < 6) { |
|
90 | - webAlertAndQuit("Password is too short!"); |
|
91 | - } else { |
|
92 | - $newpassword = $specifiedpassword; |
|
93 | - } |
|
94 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
95 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
96 | - } elseif($passwordgenmethod == 'g') { |
|
97 | - $newpassword = generate_password(8); |
|
98 | - } else { |
|
99 | - webAlertAndQuit("No password generation method specified!"); |
|
100 | - } |
|
101 | - |
|
102 | - // invoke OnBeforeUserFormSave event |
|
103 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
104 | - "mode" => "new", |
|
105 | - )); |
|
106 | - |
|
107 | - // create the user account |
|
108 | - $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users); |
|
109 | - |
|
110 | - $field = array(); |
|
111 | - $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
112 | - $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
113 | - |
|
114 | - $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
115 | - $field = $modx->db->escape($field); |
|
116 | - $modx->db->insert($field, $tbl_user_attributes); |
|
117 | - |
|
118 | - // Save user settings |
|
119 | - saveUserSettings($internalKey); |
|
120 | - |
|
121 | - // invoke OnManagerSaveUser event |
|
122 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
123 | - "mode" => "new", |
|
124 | - "userid" => $internalKey, |
|
125 | - "username" => $newusername, |
|
126 | - "userpassword" => $newpassword, |
|
127 | - "useremail" => $email, |
|
128 | - "userfullname" => $fullname, |
|
129 | - "userroleid" => $role |
|
130 | - )); |
|
131 | - |
|
132 | - // invoke OnUserFormSave event |
|
133 | - $modx->invokeEvent("OnUserFormSave", array( |
|
134 | - "mode" => "new", |
|
135 | - "id" => $internalKey |
|
136 | - )); |
|
137 | - |
|
138 | - // Set the item name for logger |
|
139 | - $_SESSION['itemname'] = $newusername; |
|
140 | - |
|
141 | - /*******************************************************************************/ |
|
142 | - // put the user in the user_groups he/ she should be in |
|
143 | - // first, check that up_perms are switched on! |
|
144 | - if($use_udperms == 1) { |
|
145 | - if(!empty($user_groups)) { |
|
146 | - for($i = 0; $i < count($user_groups); $i++) { |
|
147 | - $f = array(); |
|
148 | - $f['user_group'] = (int)$user_groups[$i]; |
|
149 | - $f['member'] = $internalKey; |
|
150 | - $modx->db->insert($f, $tbl_member_groups); |
|
151 | - } |
|
152 | - } |
|
153 | - } |
|
154 | - // end of user_groups stuff! |
|
155 | - |
|
156 | - if($passwordnotifymethod == 'e') { |
|
157 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
158 | - if($input['stay'] != '') { |
|
159 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
160 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
161 | - header($header); |
|
162 | - } else { |
|
163 | - $header = "Location: index.php?a=75&r=2"; |
|
164 | - header($header); |
|
165 | - } |
|
166 | - } else { |
|
167 | - if($input['stay'] != '') { |
|
168 | - $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
169 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
170 | - } else { |
|
171 | - $stayUrl = "index.php?a=75&r=2"; |
|
172 | - } |
|
173 | - |
|
174 | - include_once "header.inc.php"; |
|
175 | - ?> |
|
72 | + case '11' : // new user |
|
73 | + // check if this user name already exist |
|
74 | + $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
|
75 | + $limit = $modx->db->getValue($rs); |
|
76 | + if($limit > 0) { |
|
77 | + webAlertAndQuit("User name is already in use!"); |
|
78 | + } |
|
79 | + |
|
80 | + // check if the email address already exist |
|
81 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
|
82 | + $limit = $modx->db->getValue($rs); |
|
83 | + if($limit > 0) { |
|
84 | + webAlertAndQuit("Email is already in use!"); |
|
85 | + } |
|
86 | + |
|
87 | + // generate a new password for this user |
|
88 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
89 | + if(strlen($specifiedpassword) < 6) { |
|
90 | + webAlertAndQuit("Password is too short!"); |
|
91 | + } else { |
|
92 | + $newpassword = $specifiedpassword; |
|
93 | + } |
|
94 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
95 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
96 | + } elseif($passwordgenmethod == 'g') { |
|
97 | + $newpassword = generate_password(8); |
|
98 | + } else { |
|
99 | + webAlertAndQuit("No password generation method specified!"); |
|
100 | + } |
|
101 | + |
|
102 | + // invoke OnBeforeUserFormSave event |
|
103 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
104 | + "mode" => "new", |
|
105 | + )); |
|
106 | + |
|
107 | + // create the user account |
|
108 | + $internalKey = $modx->db->insert(array('username' => $modx->db->escape($newusername)), $tbl_manager_users); |
|
109 | + |
|
110 | + $field = array(); |
|
111 | + $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
112 | + $modx->db->update($field, $tbl_manager_users, "id='{$internalKey}'"); |
|
113 | + |
|
114 | + $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter'); |
|
115 | + $field = $modx->db->escape($field); |
|
116 | + $modx->db->insert($field, $tbl_user_attributes); |
|
117 | + |
|
118 | + // Save user settings |
|
119 | + saveUserSettings($internalKey); |
|
120 | + |
|
121 | + // invoke OnManagerSaveUser event |
|
122 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
123 | + "mode" => "new", |
|
124 | + "userid" => $internalKey, |
|
125 | + "username" => $newusername, |
|
126 | + "userpassword" => $newpassword, |
|
127 | + "useremail" => $email, |
|
128 | + "userfullname" => $fullname, |
|
129 | + "userroleid" => $role |
|
130 | + )); |
|
131 | + |
|
132 | + // invoke OnUserFormSave event |
|
133 | + $modx->invokeEvent("OnUserFormSave", array( |
|
134 | + "mode" => "new", |
|
135 | + "id" => $internalKey |
|
136 | + )); |
|
137 | + |
|
138 | + // Set the item name for logger |
|
139 | + $_SESSION['itemname'] = $newusername; |
|
140 | + |
|
141 | + /*******************************************************************************/ |
|
142 | + // put the user in the user_groups he/ she should be in |
|
143 | + // first, check that up_perms are switched on! |
|
144 | + if($use_udperms == 1) { |
|
145 | + if(!empty($user_groups)) { |
|
146 | + for($i = 0; $i < count($user_groups); $i++) { |
|
147 | + $f = array(); |
|
148 | + $f['user_group'] = (int)$user_groups[$i]; |
|
149 | + $f['member'] = $internalKey; |
|
150 | + $modx->db->insert($f, $tbl_member_groups); |
|
151 | + } |
|
152 | + } |
|
153 | + } |
|
154 | + // end of user_groups stuff! |
|
155 | + |
|
156 | + if($passwordnotifymethod == 'e') { |
|
157 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
158 | + if($input['stay'] != '') { |
|
159 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
160 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
161 | + header($header); |
|
162 | + } else { |
|
163 | + $header = "Location: index.php?a=75&r=2"; |
|
164 | + header($header); |
|
165 | + } |
|
166 | + } else { |
|
167 | + if($input['stay'] != '') { |
|
168 | + $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
|
169 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
170 | + } else { |
|
171 | + $stayUrl = "index.php?a=75&r=2"; |
|
172 | + } |
|
173 | + |
|
174 | + include_once "header.inc.php"; |
|
175 | + ?> |
|
176 | 176 | |
177 | 177 | <h1><?php echo $_lang['user_title']; ?></h1> |
178 | 178 | |
@@ -194,125 +194,125 @@ discard block |
||
194 | 194 | </div> |
195 | 195 | <?php |
196 | 196 | |
197 | - include_once "footer.inc.php"; |
|
198 | - } |
|
199 | - break; |
|
200 | - case '12' : // edit user |
|
201 | - // generate a new password for this user |
|
202 | - if($genpassword == 1) { |
|
203 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
204 | - if(strlen($specifiedpassword) < 6) { |
|
205 | - webAlertAndQuit("Password is too short!"); |
|
206 | - } else { |
|
207 | - $newpassword = $specifiedpassword; |
|
208 | - } |
|
209 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
210 | - webAlertAndQuit("You didn't specify a password for this user!"); |
|
211 | - } elseif($passwordgenmethod == 'g') { |
|
212 | - $newpassword = generate_password(8); |
|
213 | - } else { |
|
214 | - webAlertAndQuit("No password generation method specified!"); |
|
215 | - } |
|
216 | - } |
|
217 | - if($passwordnotifymethod == 'e') { |
|
218 | - sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
219 | - } |
|
220 | - |
|
221 | - // check if the username already exist |
|
222 | - $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
|
223 | - $limit = $modx->db->getValue($rs); |
|
224 | - if($limit > 0) { |
|
225 | - webAlertAndQuit("User name is already in use!"); |
|
226 | - } |
|
227 | - |
|
228 | - // check if the email address already exists |
|
229 | - $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
|
230 | - $limit = $modx->db->getValue($rs); |
|
231 | - if($limit > 0) { |
|
232 | - webAlertAndQuit("Email is already in use!"); |
|
233 | - } |
|
234 | - |
|
235 | - // invoke OnBeforeUserFormSave event |
|
236 | - $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
237 | - "mode" => "upd", |
|
238 | - "id" => $id |
|
239 | - )); |
|
240 | - |
|
241 | - // update user name and password |
|
242 | - $field = array(); |
|
243 | - $field['username'] = $modx->db->escape($newusername); |
|
244 | - if($genpassword == 1) { |
|
245 | - $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
246 | - } |
|
247 | - $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
|
248 | - $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
249 | - $field = $modx->db->escape($field); |
|
250 | - $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
251 | - |
|
252 | - // Save user settings |
|
253 | - saveUserSettings($id); |
|
254 | - |
|
255 | - // Set the item name for logger |
|
256 | - $_SESSION['itemname'] = $newusername; |
|
257 | - |
|
258 | - // invoke OnManagerSaveUser event |
|
259 | - $modx->invokeEvent("OnManagerSaveUser", array( |
|
260 | - "mode" => "upd", |
|
261 | - "userid" => $id, |
|
262 | - "username" => $newusername, |
|
263 | - "userpassword" => $newpassword, |
|
264 | - "useremail" => $email, |
|
265 | - "userfullname" => $fullname, |
|
266 | - "userroleid" => $role, |
|
267 | - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
268 | - "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
269 | - )); |
|
270 | - |
|
271 | - // invoke OnManagerChangePassword event |
|
272 | - if($genpassword == 1) { |
|
273 | - $modx->invokeEvent("OnManagerChangePassword", array( |
|
274 | - "userid" => $id, |
|
275 | - "username" => $newusername, |
|
276 | - "userpassword" => $newpassword |
|
277 | - )); |
|
278 | - } |
|
279 | - |
|
280 | - // invoke OnUserFormSave event |
|
281 | - $modx->invokeEvent("OnUserFormSave", array( |
|
282 | - "mode" => "upd", |
|
283 | - "id" => $id |
|
284 | - )); |
|
285 | - |
|
286 | - /*******************************************************************************/ |
|
287 | - // put the user in the user_groups he/ she should be in |
|
288 | - // first, check that up_perms are switched on! |
|
289 | - if($use_udperms == 1) { |
|
290 | - // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
291 | - $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
|
292 | - if(!empty($user_groups)) { |
|
293 | - for($i = 0; $i < count($user_groups); $i++) { |
|
294 | - $field = array(); |
|
295 | - $field['user_group'] = (int)$user_groups[$i]; |
|
296 | - $field['member'] = $id; |
|
297 | - $modx->db->insert($field, $tbl_member_groups); |
|
298 | - } |
|
299 | - } |
|
300 | - } |
|
301 | - // end of user_groups stuff! |
|
302 | - /*******************************************************************************/ |
|
303 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
304 | - $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
305 | - } |
|
306 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
307 | - if($input['stay'] != '') { |
|
308 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
309 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
310 | - } else { |
|
311 | - $stayUrl = "index.php?a=75&r=2"; |
|
312 | - } |
|
313 | - |
|
314 | - include_once "header.inc.php"; |
|
315 | - ?> |
|
197 | + include_once "footer.inc.php"; |
|
198 | + } |
|
199 | + break; |
|
200 | + case '12' : // edit user |
|
201 | + // generate a new password for this user |
|
202 | + if($genpassword == 1) { |
|
203 | + if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
204 | + if(strlen($specifiedpassword) < 6) { |
|
205 | + webAlertAndQuit("Password is too short!"); |
|
206 | + } else { |
|
207 | + $newpassword = $specifiedpassword; |
|
208 | + } |
|
209 | + } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
210 | + webAlertAndQuit("You didn't specify a password for this user!"); |
|
211 | + } elseif($passwordgenmethod == 'g') { |
|
212 | + $newpassword = generate_password(8); |
|
213 | + } else { |
|
214 | + webAlertAndQuit("No password generation method specified!"); |
|
215 | + } |
|
216 | + } |
|
217 | + if($passwordnotifymethod == 'e') { |
|
218 | + sendMailMessage($email, $newusername, $newpassword, $fullname); |
|
219 | + } |
|
220 | + |
|
221 | + // check if the username already exist |
|
222 | + $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
|
223 | + $limit = $modx->db->getValue($rs); |
|
224 | + if($limit > 0) { |
|
225 | + webAlertAndQuit("User name is already in use!"); |
|
226 | + } |
|
227 | + |
|
228 | + // check if the email address already exists |
|
229 | + $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
|
230 | + $limit = $modx->db->getValue($rs); |
|
231 | + if($limit > 0) { |
|
232 | + webAlertAndQuit("Email is already in use!"); |
|
233 | + } |
|
234 | + |
|
235 | + // invoke OnBeforeUserFormSave event |
|
236 | + $modx->invokeEvent("OnBeforeUserFormSave", array( |
|
237 | + "mode" => "upd", |
|
238 | + "id" => $id |
|
239 | + )); |
|
240 | + |
|
241 | + // update user name and password |
|
242 | + $field = array(); |
|
243 | + $field['username'] = $modx->db->escape($newusername); |
|
244 | + if($genpassword == 1) { |
|
245 | + $field['password'] = $modx->phpass->HashPassword($newpassword); |
|
246 | + } |
|
247 | + $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
|
248 | + $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter'); |
|
249 | + $field = $modx->db->escape($field); |
|
250 | + $modx->db->update($field, $tbl_user_attributes, "internalKey='{$id}'"); |
|
251 | + |
|
252 | + // Save user settings |
|
253 | + saveUserSettings($id); |
|
254 | + |
|
255 | + // Set the item name for logger |
|
256 | + $_SESSION['itemname'] = $newusername; |
|
257 | + |
|
258 | + // invoke OnManagerSaveUser event |
|
259 | + $modx->invokeEvent("OnManagerSaveUser", array( |
|
260 | + "mode" => "upd", |
|
261 | + "userid" => $id, |
|
262 | + "username" => $newusername, |
|
263 | + "userpassword" => $newpassword, |
|
264 | + "useremail" => $email, |
|
265 | + "userfullname" => $fullname, |
|
266 | + "userroleid" => $role, |
|
267 | + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), |
|
268 | + "olduseremail" => (($oldemail != $email) ? $oldemail : "") |
|
269 | + )); |
|
270 | + |
|
271 | + // invoke OnManagerChangePassword event |
|
272 | + if($genpassword == 1) { |
|
273 | + $modx->invokeEvent("OnManagerChangePassword", array( |
|
274 | + "userid" => $id, |
|
275 | + "username" => $newusername, |
|
276 | + "userpassword" => $newpassword |
|
277 | + )); |
|
278 | + } |
|
279 | + |
|
280 | + // invoke OnUserFormSave event |
|
281 | + $modx->invokeEvent("OnUserFormSave", array( |
|
282 | + "mode" => "upd", |
|
283 | + "id" => $id |
|
284 | + )); |
|
285 | + |
|
286 | + /*******************************************************************************/ |
|
287 | + // put the user in the user_groups he/ she should be in |
|
288 | + // first, check that up_perms are switched on! |
|
289 | + if($use_udperms == 1) { |
|
290 | + // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
|
291 | + $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
|
292 | + if(!empty($user_groups)) { |
|
293 | + for($i = 0; $i < count($user_groups); $i++) { |
|
294 | + $field = array(); |
|
295 | + $field['user_group'] = (int)$user_groups[$i]; |
|
296 | + $field['member'] = $id; |
|
297 | + $modx->db->insert($field, $tbl_member_groups); |
|
298 | + } |
|
299 | + } |
|
300 | + } |
|
301 | + // end of user_groups stuff! |
|
302 | + /*******************************************************************************/ |
|
303 | + if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
304 | + $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
|
305 | + } |
|
306 | + if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
307 | + if($input['stay'] != '') { |
|
308 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
309 | + $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
310 | + } else { |
|
311 | + $stayUrl = "index.php?a=75&r=2"; |
|
312 | + } |
|
313 | + |
|
314 | + include_once "header.inc.php"; |
|
315 | + ?> |
|
316 | 316 | |
317 | 317 | <h1><?php echo $_lang['user_title']; ?></h1> |
318 | 318 | |
@@ -332,20 +332,20 @@ discard block |
||
332 | 332 | </div> |
333 | 333 | <?php |
334 | 334 | |
335 | - include_once "footer.inc.php"; |
|
336 | - } else { |
|
337 | - if($input['stay'] != '') { |
|
338 | - $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
340 | - header($header); |
|
341 | - } else { |
|
342 | - $header = "Location: index.php?a=75&r=2"; |
|
343 | - header($header); |
|
344 | - } |
|
345 | - } |
|
346 | - break; |
|
347 | - default: |
|
348 | - webAlertAndQuit("No operation set in request."); |
|
335 | + include_once "footer.inc.php"; |
|
336 | + } else { |
|
337 | + if($input['stay'] != '') { |
|
338 | + $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
|
339 | + $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
340 | + header($header); |
|
341 | + } else { |
|
342 | + $header = "Location: index.php?a=75&r=2"; |
|
343 | + header($header); |
|
344 | + } |
|
345 | + } |
|
346 | + break; |
|
347 | + default: |
|
348 | + webAlertAndQuit("No operation set in request."); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
@@ -357,31 +357,31 @@ discard block |
||
357 | 357 | * @param string $ufn |
358 | 358 | */ |
359 | 359 | function sendMailMessage($email, $uid, $pwd, $ufn) { |
360 | - global $modx, $_lang, $signupemail_message; |
|
361 | - global $emailsubject, $emailsender; |
|
362 | - global $site_name; |
|
363 | - $manager_url = MODX_MANAGER_URL; |
|
364 | - $message = sprintf($signupemail_message, $uid, $pwd); // use old method |
|
365 | - // replace placeholders |
|
366 | - $message = str_replace("[+uid+]", $uid, $message); |
|
367 | - $message = str_replace("[+pwd+]", $pwd, $message); |
|
368 | - $message = str_replace("[+ufn+]", $ufn, $message); |
|
369 | - $message = str_replace("[+sname+]", $site_name, $message); |
|
370 | - $message = str_replace("[+saddr+]", $emailsender, $message); |
|
371 | - $message = str_replace("[+semail+]", $emailsender, $message); |
|
372 | - $message = str_replace("[+surl+]", $manager_url, $message); |
|
373 | - |
|
374 | - $param = array(); |
|
375 | - $param['from'] = "{$site_name}<{$emailsender}>"; |
|
376 | - $param['subject'] = $emailsubject; |
|
377 | - $param['body'] = $message; |
|
378 | - $param['to'] = $email; |
|
379 | - $param['type'] = 'text'; |
|
380 | - $rs = $modx->sendmail($param); |
|
381 | - if(!$rs) { |
|
382 | - $modx->manager->saveFormValues(); |
|
383 | - $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
384 | - } |
|
360 | + global $modx, $_lang, $signupemail_message; |
|
361 | + global $emailsubject, $emailsender; |
|
362 | + global $site_name; |
|
363 | + $manager_url = MODX_MANAGER_URL; |
|
364 | + $message = sprintf($signupemail_message, $uid, $pwd); // use old method |
|
365 | + // replace placeholders |
|
366 | + $message = str_replace("[+uid+]", $uid, $message); |
|
367 | + $message = str_replace("[+pwd+]", $pwd, $message); |
|
368 | + $message = str_replace("[+ufn+]", $ufn, $message); |
|
369 | + $message = str_replace("[+sname+]", $site_name, $message); |
|
370 | + $message = str_replace("[+saddr+]", $emailsender, $message); |
|
371 | + $message = str_replace("[+semail+]", $emailsender, $message); |
|
372 | + $message = str_replace("[+surl+]", $manager_url, $message); |
|
373 | + |
|
374 | + $param = array(); |
|
375 | + $param['from'] = "{$site_name}<{$emailsender}>"; |
|
376 | + $param['subject'] = $emailsubject; |
|
377 | + $param['body'] = $message; |
|
378 | + $param['to'] = $email; |
|
379 | + $param['type'] = 'text'; |
|
380 | + $rs = $modx->sendmail($param); |
|
381 | + if(!$rs) { |
|
382 | + $modx->manager->saveFormValues(); |
|
383 | + $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
384 | + } |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -390,86 +390,86 @@ discard block |
||
390 | 390 | * @param int $id |
391 | 391 | */ |
392 | 392 | function saveUserSettings($id) { |
393 | - global $modx; |
|
394 | - $tbl_user_settings = $modx->getFullTableName('user_settings'); |
|
395 | - |
|
396 | - $ignore = array( |
|
397 | - 'id', |
|
398 | - 'oldusername', |
|
399 | - 'oldemail', |
|
400 | - 'newusername', |
|
401 | - 'fullname', |
|
402 | - 'newpassword', |
|
403 | - 'newpasswordcheck', |
|
404 | - 'passwordgenmethod', |
|
405 | - 'passwordnotifymethod', |
|
406 | - 'specifiedpassword', |
|
407 | - 'confirmpassword', |
|
408 | - 'email', |
|
409 | - 'phone', |
|
410 | - 'mobilephone', |
|
411 | - 'fax', |
|
412 | - 'dob', |
|
413 | - 'country', |
|
414 | - 'street', |
|
415 | - 'city', |
|
416 | - 'state', |
|
417 | - 'zip', |
|
418 | - 'gender', |
|
419 | - 'photo', |
|
420 | - 'comment', |
|
421 | - 'role', |
|
422 | - 'failedlogincount', |
|
423 | - 'blocked', |
|
424 | - 'blockeduntil', |
|
425 | - 'blockedafter', |
|
426 | - 'user_groups', |
|
427 | - 'mode', |
|
428 | - 'blockedmode', |
|
429 | - 'stay', |
|
430 | - 'save', |
|
431 | - 'theme_refresher' |
|
432 | - ); |
|
433 | - |
|
434 | - // determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values) |
|
435 | - $defaults = array( |
|
436 | - 'upload_images', |
|
437 | - 'upload_media', |
|
438 | - 'upload_flash', |
|
439 | - 'upload_files' |
|
440 | - ); |
|
441 | - |
|
442 | - // get user setting field names |
|
443 | - $settings = array(); |
|
444 | - foreach($_POST as $n => $v) { |
|
445 | - if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
446 | - continue; |
|
447 | - } // ignore blacklist and empties |
|
448 | - $settings[$n] = $v; // this value should be saved |
|
449 | - } |
|
450 | - |
|
451 | - foreach($defaults as $k) { |
|
452 | - if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
453 | - unset($settings[$k]); |
|
454 | - } |
|
455 | - unset($settings['default_' . $k]); |
|
456 | - } |
|
457 | - |
|
458 | - $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
|
459 | - |
|
460 | - foreach($settings as $n => $vl) { |
|
461 | - if(is_array($vl)) { |
|
462 | - $vl = implode(",", $vl); |
|
463 | - } |
|
464 | - if($vl != '') { |
|
465 | - $f = array(); |
|
466 | - $f['user'] = $id; |
|
467 | - $f['setting_name'] = $n; |
|
468 | - $f['setting_value'] = $vl; |
|
469 | - $f = $modx->db->escape($f); |
|
470 | - $modx->db->insert($f, $tbl_user_settings); |
|
471 | - } |
|
472 | - } |
|
393 | + global $modx; |
|
394 | + $tbl_user_settings = $modx->getFullTableName('user_settings'); |
|
395 | + |
|
396 | + $ignore = array( |
|
397 | + 'id', |
|
398 | + 'oldusername', |
|
399 | + 'oldemail', |
|
400 | + 'newusername', |
|
401 | + 'fullname', |
|
402 | + 'newpassword', |
|
403 | + 'newpasswordcheck', |
|
404 | + 'passwordgenmethod', |
|
405 | + 'passwordnotifymethod', |
|
406 | + 'specifiedpassword', |
|
407 | + 'confirmpassword', |
|
408 | + 'email', |
|
409 | + 'phone', |
|
410 | + 'mobilephone', |
|
411 | + 'fax', |
|
412 | + 'dob', |
|
413 | + 'country', |
|
414 | + 'street', |
|
415 | + 'city', |
|
416 | + 'state', |
|
417 | + 'zip', |
|
418 | + 'gender', |
|
419 | + 'photo', |
|
420 | + 'comment', |
|
421 | + 'role', |
|
422 | + 'failedlogincount', |
|
423 | + 'blocked', |
|
424 | + 'blockeduntil', |
|
425 | + 'blockedafter', |
|
426 | + 'user_groups', |
|
427 | + 'mode', |
|
428 | + 'blockedmode', |
|
429 | + 'stay', |
|
430 | + 'save', |
|
431 | + 'theme_refresher' |
|
432 | + ); |
|
433 | + |
|
434 | + // determine which settings can be saved blank (based on 'default_{settingname}' POST checkbox values) |
|
435 | + $defaults = array( |
|
436 | + 'upload_images', |
|
437 | + 'upload_media', |
|
438 | + 'upload_flash', |
|
439 | + 'upload_files' |
|
440 | + ); |
|
441 | + |
|
442 | + // get user setting field names |
|
443 | + $settings = array(); |
|
444 | + foreach($_POST as $n => $v) { |
|
445 | + if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
446 | + continue; |
|
447 | + } // ignore blacklist and empties |
|
448 | + $settings[$n] = $v; // this value should be saved |
|
449 | + } |
|
450 | + |
|
451 | + foreach($defaults as $k) { |
|
452 | + if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
453 | + unset($settings[$k]); |
|
454 | + } |
|
455 | + unset($settings['default_' . $k]); |
|
456 | + } |
|
457 | + |
|
458 | + $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
|
459 | + |
|
460 | + foreach($settings as $n => $vl) { |
|
461 | + if(is_array($vl)) { |
|
462 | + $vl = implode(",", $vl); |
|
463 | + } |
|
464 | + if($vl != '') { |
|
465 | + $f = array(); |
|
466 | + $f['user'] = $id; |
|
467 | + $f['setting_name'] = $n; |
|
468 | + $f['setting_value'] = $vl; |
|
469 | + $f = $modx->db->escape($f); |
|
470 | + $modx->db->insert($f, $tbl_user_settings); |
|
471 | + } |
|
472 | + } |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -478,10 +478,10 @@ discard block |
||
478 | 478 | * @param $msg |
479 | 479 | */ |
480 | 480 | function webAlertAndQuit($msg) { |
481 | - global $id, $modx; |
|
482 | - $mode = $_POST['mode']; |
|
483 | - $modx->manager->saveFormValues($mode); |
|
484 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
481 | + global $id, $modx; |
|
482 | + $mode = $_POST['mode']; |
|
483 | + $modx->manager->saveFormValues($mode); |
|
484 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -491,12 +491,12 @@ discard block |
||
491 | 491 | * @return string |
492 | 492 | */ |
493 | 493 | function generate_password($length = 10) { |
494 | - $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
495 | - $ps_len = strlen($allowable_characters); |
|
496 | - mt_srand((double) microtime() * 1000000); |
|
497 | - $pass = ""; |
|
498 | - for($i = 0; $i < $length; $i++) { |
|
499 | - $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
500 | - } |
|
501 | - return $pass; |
|
494 | + $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
495 | + $ps_len = strlen($allowable_characters); |
|
496 | + mt_srand((double) microtime() * 1000000); |
|
497 | + $pass = ""; |
|
498 | + for($i = 0; $i < $length; $i++) { |
|
499 | + $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
500 | + } |
|
501 | + return $pass; |
|
502 | 502 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || 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_user')) { |
|
5 | +if (!$modx->hasPermission('save_user')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | $input = $_POST; |
16 | 16 | |
17 | -$id = (int)$input['id']; |
|
17 | +$id = (int) $input['id']; |
|
18 | 18 | $oldusername = $input['oldusername']; |
19 | 19 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
20 | 20 | $fullname = $input['fullname']; |
@@ -44,56 +44,56 @@ discard block |
||
44 | 44 | $user_groups = $input['user_groups']; |
45 | 45 | |
46 | 46 | // verify password |
47 | -if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
47 | +if ($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
|
48 | 48 | webAlertAndQuit("Password typed is mismatched"); |
49 | 49 | } |
50 | 50 | |
51 | 51 | // verify email |
52 | -if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
52 | +if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
|
53 | 53 | webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
54 | 54 | } |
55 | 55 | |
56 | 56 | // verify admin security |
57 | -if($_SESSION['mgrRole'] != 1) { |
|
57 | +if ($_SESSION['mgrRole'] != 1) { |
|
58 | 58 | // Check to see if user tried to spoof a "1" (admin) role |
59 | - if(!$modx->hasPermission('save_role')) { |
|
59 | + if (!$modx->hasPermission('save_role')) { |
|
60 | 60 | webAlertAndQuit("Illegal attempt to create/modify administrator by non-administrator!"); |
61 | 61 | } |
62 | 62 | // Verify that the user being edited wasn't an admin and the user ID got spoofed |
63 | 63 | $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, "internalKey='{$id}' AND role=1"); |
64 | 64 | $limit = $modx->db->getValue($rs); |
65 | - if($limit > 0) { |
|
65 | + if ($limit > 0) { |
|
66 | 66 | webAlertAndQuit("You cannot alter an administrative user."); |
67 | 67 | } |
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | -switch($input['mode']) { |
|
71 | +switch ($input['mode']) { |
|
72 | 72 | case '11' : // new user |
73 | 73 | // check if this user name already exist |
74 | 74 | $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s'", $modx->db->escape($newusername))); |
75 | 75 | $limit = $modx->db->getValue($rs); |
76 | - if($limit > 0) { |
|
76 | + if ($limit > 0) { |
|
77 | 77 | webAlertAndQuit("User name is already in use!"); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // check if the email address already exist |
81 | 81 | $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND id!='%s'", $modx->db->escape($email), $id)); |
82 | 82 | $limit = $modx->db->getValue($rs); |
83 | - if($limit > 0) { |
|
83 | + if ($limit > 0) { |
|
84 | 84 | webAlertAndQuit("Email is already in use!"); |
85 | 85 | } |
86 | 86 | |
87 | 87 | // generate a new password for this user |
88 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
89 | - if(strlen($specifiedpassword) < 6) { |
|
88 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
89 | + if (strlen($specifiedpassword) < 6) { |
|
90 | 90 | webAlertAndQuit("Password is too short!"); |
91 | 91 | } else { |
92 | 92 | $newpassword = $specifiedpassword; |
93 | 93 | } |
94 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
94 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
95 | 95 | webAlertAndQuit("You didn't specify a password for this user!"); |
96 | - } elseif($passwordgenmethod == 'g') { |
|
96 | + } elseif ($passwordgenmethod == 'g') { |
|
97 | 97 | $newpassword = generate_password(8); |
98 | 98 | } else { |
99 | 99 | webAlertAndQuit("No password generation method specified!"); |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | /*******************************************************************************/ |
142 | 142 | // put the user in the user_groups he/ she should be in |
143 | 143 | // first, check that up_perms are switched on! |
144 | - if($use_udperms == 1) { |
|
145 | - if(!empty($user_groups)) { |
|
146 | - for($i = 0; $i < count($user_groups); $i++) { |
|
144 | + if ($use_udperms == 1) { |
|
145 | + if (!empty($user_groups)) { |
|
146 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
147 | 147 | $f = array(); |
148 | - $f['user_group'] = (int)$user_groups[$i]; |
|
148 | + $f['user_group'] = (int) $user_groups[$i]; |
|
149 | 149 | $f['member'] = $internalKey; |
150 | 150 | $modx->db->insert($f, $tbl_member_groups); |
151 | 151 | } |
@@ -153,20 +153,20 @@ discard block |
||
153 | 153 | } |
154 | 154 | // end of user_groups stuff! |
155 | 155 | |
156 | - if($passwordnotifymethod == 'e') { |
|
156 | + if ($passwordnotifymethod == 'e') { |
|
157 | 157 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
158 | - if($input['stay'] != '') { |
|
158 | + if ($input['stay'] != '') { |
|
159 | 159 | $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
160 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
160 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
161 | 161 | header($header); |
162 | 162 | } else { |
163 | 163 | $header = "Location: index.php?a=75&r=2"; |
164 | 164 | header($header); |
165 | 165 | } |
166 | 166 | } else { |
167 | - if($input['stay'] != '') { |
|
167 | + if ($input['stay'] != '') { |
|
168 | 168 | $a = ($input['stay'] == '2') ? "12&id={$internalKey}" : "11"; |
169 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
169 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
170 | 170 | } else { |
171 | 171 | $stayUrl = "index.php?a=75&r=2"; |
172 | 172 | } |
@@ -199,36 +199,36 @@ discard block |
||
199 | 199 | break; |
200 | 200 | case '12' : // edit user |
201 | 201 | // generate a new password for this user |
202 | - if($genpassword == 1) { |
|
203 | - if($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
204 | - if(strlen($specifiedpassword) < 6) { |
|
202 | + if ($genpassword == 1) { |
|
203 | + if ($specifiedpassword != "" && $passwordgenmethod == "spec") { |
|
204 | + if (strlen($specifiedpassword) < 6) { |
|
205 | 205 | webAlertAndQuit("Password is too short!"); |
206 | 206 | } else { |
207 | 207 | $newpassword = $specifiedpassword; |
208 | 208 | } |
209 | - } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
209 | + } elseif ($specifiedpassword == "" && $passwordgenmethod == "spec") { |
|
210 | 210 | webAlertAndQuit("You didn't specify a password for this user!"); |
211 | - } elseif($passwordgenmethod == 'g') { |
|
211 | + } elseif ($passwordgenmethod == 'g') { |
|
212 | 212 | $newpassword = generate_password(8); |
213 | 213 | } else { |
214 | 214 | webAlertAndQuit("No password generation method specified!"); |
215 | 215 | } |
216 | 216 | } |
217 | - if($passwordnotifymethod == 'e') { |
|
217 | + if ($passwordnotifymethod == 'e') { |
|
218 | 218 | sendMailMessage($email, $newusername, $newpassword, $fullname); |
219 | 219 | } |
220 | 220 | |
221 | 221 | // check if the username already exist |
222 | 222 | $rs = $modx->db->select('count(id)', $tbl_manager_users, sprintf("username='%s' AND id!='%s'", $modx->db->escape($newusername), $id)); |
223 | 223 | $limit = $modx->db->getValue($rs); |
224 | - if($limit > 0) { |
|
224 | + if ($limit > 0) { |
|
225 | 225 | webAlertAndQuit("User name is already in use!"); |
226 | 226 | } |
227 | 227 | |
228 | 228 | // check if the email address already exists |
229 | 229 | $rs = $modx->db->select('count(internalKey)', $tbl_user_attributes, sprintf("email='%s' AND internalKey!='%s'", $modx->db->escape($email), $id)); |
230 | 230 | $limit = $modx->db->getValue($rs); |
231 | - if($limit > 0) { |
|
231 | + if ($limit > 0) { |
|
232 | 232 | webAlertAndQuit("Email is already in use!"); |
233 | 233 | } |
234 | 234 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | // update user name and password |
242 | 242 | $field = array(); |
243 | 243 | $field['username'] = $modx->db->escape($newusername); |
244 | - if($genpassword == 1) { |
|
244 | + if ($genpassword == 1) { |
|
245 | 245 | $field['password'] = $modx->phpass->HashPassword($newpassword); |
246 | 246 | } |
247 | 247 | $modx->db->update($field, $tbl_manager_users, "id='{$id}'"); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | )); |
270 | 270 | |
271 | 271 | // invoke OnManagerChangePassword event |
272 | - if($genpassword == 1) { |
|
272 | + if ($genpassword == 1) { |
|
273 | 273 | $modx->invokeEvent("OnManagerChangePassword", array( |
274 | 274 | "userid" => $id, |
275 | 275 | "username" => $newusername, |
@@ -286,13 +286,13 @@ discard block |
||
286 | 286 | /*******************************************************************************/ |
287 | 287 | // put the user in the user_groups he/ she should be in |
288 | 288 | // first, check that up_perms are switched on! |
289 | - if($use_udperms == 1) { |
|
289 | + if ($use_udperms == 1) { |
|
290 | 290 | // as this is an existing user, delete his/ her entries in the groups before saving the new groups |
291 | 291 | $modx->db->delete($tbl_member_groups, "member='{$id}'"); |
292 | - if(!empty($user_groups)) { |
|
293 | - for($i = 0; $i < count($user_groups); $i++) { |
|
292 | + if (!empty($user_groups)) { |
|
293 | + for ($i = 0; $i < count($user_groups); $i++) { |
|
294 | 294 | $field = array(); |
295 | - $field['user_group'] = (int)$user_groups[$i]; |
|
295 | + $field['user_group'] = (int) $user_groups[$i]; |
|
296 | 296 | $field['member'] = $id; |
297 | 297 | $modx->db->insert($field, $tbl_member_groups); |
298 | 298 | } |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | } |
301 | 301 | // end of user_groups stuff! |
302 | 302 | /*******************************************************************************/ |
303 | - if($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
303 | + if ($id == $modx->getLoginUserID() && ($genpassword !== 1 && $passwordnotifymethod != 's')) { |
|
304 | 304 | $modx->webAlertAndQuit($_lang["user_changeddata"], 'javascript:top.location.href="index.php?a=8";'); |
305 | 305 | } |
306 | - if($genpassword == 1 && $passwordnotifymethod == 's') { |
|
307 | - if($input['stay'] != '') { |
|
306 | + if ($genpassword == 1 && $passwordnotifymethod == 's') { |
|
307 | + if ($input['stay'] != '') { |
|
308 | 308 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
309 | - $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
309 | + $stayUrl = "index.php?a={$a}&r=2&stay=".$input['stay']; |
|
310 | 310 | } else { |
311 | 311 | $stayUrl = "index.php?a=75&r=2"; |
312 | 312 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | <div class="sectionHeader"><?php echo $_lang['user_title']; ?></div> |
327 | 327 | <div class="sectionBody"> |
328 | 328 | <div id="disp"> |
329 | - <p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)) . (($id == $modx->getLoginUserID()) ? ' ' . $_lang['user_changeddata'] : ''); ?></p> |
|
329 | + <p><?php echo sprintf($_lang["password_msg"], $modx->htmlspecialchars($newusername), $modx->htmlspecialchars($newpassword)).(($id == $modx->getLoginUserID()) ? ' '.$_lang['user_changeddata'] : ''); ?></p> |
|
330 | 330 | </div> |
331 | 331 | </div> |
332 | 332 | </div> |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | |
335 | 335 | include_once "footer.inc.php"; |
336 | 336 | } else { |
337 | - if($input['stay'] != '') { |
|
337 | + if ($input['stay'] != '') { |
|
338 | 338 | $a = ($input['stay'] == '2') ? "12&id={$id}" : "11"; |
339 | - $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay']; |
|
339 | + $header = "Location: index.php?a={$a}&r=2&stay=".$input['stay']; |
|
340 | 340 | header($header); |
341 | 341 | } else { |
342 | 342 | $header = "Location: index.php?a=75&r=2"; |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @param string $pwd |
357 | 357 | * @param string $ufn |
358 | 358 | */ |
359 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
359 | +function sendMailMessage($email, $uid, $pwd, $ufn){ |
|
360 | 360 | global $modx, $_lang, $signupemail_message; |
361 | 361 | global $emailsubject, $emailsender; |
362 | 362 | global $site_name; |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | $param['to'] = $email; |
379 | 379 | $param['type'] = 'text'; |
380 | 380 | $rs = $modx->sendmail($param); |
381 | - if(!$rs) { |
|
381 | + if (!$rs) { |
|
382 | 382 | $modx->manager->saveFormValues(); |
383 | 383 | $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
384 | 384 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @param int $id |
391 | 391 | */ |
392 | -function saveUserSettings($id) { |
|
392 | +function saveUserSettings($id){ |
|
393 | 393 | global $modx; |
394 | 394 | $tbl_user_settings = $modx->getFullTableName('user_settings'); |
395 | 395 | |
@@ -441,27 +441,27 @@ discard block |
||
441 | 441 | |
442 | 442 | // get user setting field names |
443 | 443 | $settings = array(); |
444 | - foreach($_POST as $n => $v) { |
|
445 | - if(in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
444 | + foreach ($_POST as $n => $v) { |
|
445 | + if (in_array($n, $ignore) || (!in_array($n, $defaults) && is_scalar($v) && trim($v) == '') || (!in_array($n, $defaults) && is_array($v) && empty($v))) { |
|
446 | 446 | continue; |
447 | 447 | } // ignore blacklist and empties |
448 | 448 | $settings[$n] = $v; // this value should be saved |
449 | 449 | } |
450 | 450 | |
451 | - foreach($defaults as $k) { |
|
452 | - if(isset($settings['default_' . $k]) && $settings['default_' . $k] == '1') { |
|
451 | + foreach ($defaults as $k) { |
|
452 | + if (isset($settings['default_'.$k]) && $settings['default_'.$k] == '1') { |
|
453 | 453 | unset($settings[$k]); |
454 | 454 | } |
455 | - unset($settings['default_' . $k]); |
|
455 | + unset($settings['default_'.$k]); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | $modx->db->delete($tbl_user_settings, "user='{$id}'"); |
459 | 459 | |
460 | - foreach($settings as $n => $vl) { |
|
461 | - if(is_array($vl)) { |
|
460 | + foreach ($settings as $n => $vl) { |
|
461 | + if (is_array($vl)) { |
|
462 | 462 | $vl = implode(",", $vl); |
463 | 463 | } |
464 | - if($vl != '') { |
|
464 | + if ($vl != '') { |
|
465 | 465 | $f = array(); |
466 | 466 | $f['user'] = $id; |
467 | 467 | $f['setting_name'] = $n; |
@@ -477,11 +477,11 @@ discard block |
||
477 | 477 | * |
478 | 478 | * @param $msg |
479 | 479 | */ |
480 | -function webAlertAndQuit($msg) { |
|
480 | +function webAlertAndQuit($msg){ |
|
481 | 481 | global $id, $modx; |
482 | 482 | $mode = $_POST['mode']; |
483 | 483 | $modx->manager->saveFormValues($mode); |
484 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '12' ? "&id={$id}" : '')); |
|
484 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '12' ? "&id={$id}" : '')); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -490,12 +490,12 @@ discard block |
||
490 | 490 | * @param int $length |
491 | 491 | * @return string |
492 | 492 | */ |
493 | -function generate_password($length = 10) { |
|
493 | +function generate_password($length = 10){ |
|
494 | 494 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
495 | 495 | $ps_len = strlen($allowable_characters); |
496 | 496 | mt_srand((double) microtime() * 1000000); |
497 | 497 | $pass = ""; |
498 | - for($i = 0; $i < $length; $i++) { |
|
498 | + for ($i = 0; $i < $length; $i++) { |
|
499 | 499 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
500 | 500 | } |
501 | 501 | return $pass; |
@@ -356,7 +356,8 @@ discard block |
||
356 | 356 | * @param string $pwd |
357 | 357 | * @param string $ufn |
358 | 358 | */ |
359 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
359 | +function sendMailMessage($email, $uid, $pwd, $ufn) |
|
360 | +{ |
|
360 | 361 | global $modx, $_lang, $signupemail_message; |
361 | 362 | global $emailsubject, $emailsender; |
362 | 363 | global $site_name; |
@@ -389,7 +390,8 @@ discard block |
||
389 | 390 | * |
390 | 391 | * @param int $id |
391 | 392 | */ |
392 | -function saveUserSettings($id) { |
|
393 | +function saveUserSettings($id) |
|
394 | +{ |
|
393 | 395 | global $modx; |
394 | 396 | $tbl_user_settings = $modx->getFullTableName('user_settings'); |
395 | 397 | |
@@ -477,7 +479,8 @@ discard block |
||
477 | 479 | * |
478 | 480 | * @param $msg |
479 | 481 | */ |
480 | -function webAlertAndQuit($msg) { |
|
482 | +function webAlertAndQuit($msg) |
|
483 | +{ |
|
481 | 484 | global $id, $modx; |
482 | 485 | $mode = $_POST['mode']; |
483 | 486 | $modx->manager->saveFormValues($mode); |
@@ -490,7 +493,8 @@ discard block |
||
490 | 493 | * @param int $length |
491 | 494 | * @return string |
492 | 495 | */ |
493 | -function generate_password($length = 10) { |
|
496 | +function generate_password($length = 10) |
|
497 | +{ |
|
494 | 498 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
495 | 499 | $ps_len = strlen($allowable_characters); |
496 | 500 | mt_srand((double) microtime() * 1000000); |
@@ -79,7 +79,8 @@ discard block |
||
79 | 79 | * @return string |
80 | 80 | */ |
81 | 81 | public function getParents($id, $path = '') |
82 | - { // modx:returns child's parent |
|
82 | + { |
|
83 | +// modx:returns child's parent |
|
83 | 84 | global $modx; |
84 | 85 | if (empty($this->aliases)) { |
85 | 86 | $f = "id, IF(alias='', id, alias) AS alias, parent, alias_visible"; |
@@ -456,7 +457,8 @@ discard block |
||
456 | 457 | $_ = trim($_); |
457 | 458 | } |
458 | 459 | $lastChar = substr($_, -1); |
459 | - if (!in_array($lastChar, $chars)) {// ,320,327,288,284,289 |
|
460 | + if (!in_array($lastChar, $chars)) { |
|
461 | +// ,320,327,288,284,289 |
|
460 | 462 | if (!in_array($prev_token, |
461 | 463 | array(T_FOREACH, T_WHILE, T_FOR, T_BOOLEAN_AND, T_BOOLEAN_OR, T_DOUBLE_ARROW))) { |
462 | 464 | $_ .= ' '; |
@@ -1,7 +1,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
229 | 229 | $_SESSION['mgrToken'] = md5($currentsessionid); |
230 | 230 | |
231 | 231 | if($rememberme == '1') { |
232 | - $_SESSION['modx.mgr.session.cookie.lifetime'] = (int)$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'] = (int)$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,29 +266,29 @@ discard block |
||
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 = (int)$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 | /** |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | * @param string $msg |
298 | 298 | */ |
299 | 299 | function jsAlert($msg) { |
300 | - global $modx; |
|
301 | - if($_POST['ajax'] != 1) { |
|
302 | - echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>"; |
|
303 | - } else { |
|
304 | - echo $msg . "\n"; |
|
305 | - } |
|
300 | + global $modx; |
|
301 | + if($_POST['ajax'] != 1) { |
|
302 | + echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>"; |
|
303 | + } else { |
|
304 | + echo $msg . "\n"; |
|
305 | + } |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | * @return bool |
313 | 313 | */ |
314 | 314 | function login($username, $givenPassword, $dbasePassword) { |
315 | - global $modx; |
|
316 | - return $modx->phpass->CheckPassword($givenPassword, $dbasePassword); |
|
315 | + global $modx; |
|
316 | + return $modx->phpass->CheckPassword($givenPassword, $dbasePassword); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -324,26 +324,26 @@ discard block |
||
324 | 324 | * @return bool |
325 | 325 | */ |
326 | 326 | function loginV1($internalKey, $givenPassword, $dbasePassword, $username) { |
327 | - global $modx; |
|
327 | + global $modx; |
|
328 | 328 | |
329 | - $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey); |
|
329 | + $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey); |
|
330 | 330 | |
331 | - if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) { |
|
332 | - $modx->config['pwd_hash_algo'] = 'UNCRYPT'; |
|
333 | - } |
|
331 | + if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) { |
|
332 | + $modx->config['pwd_hash_algo'] = 'UNCRYPT'; |
|
333 | + } |
|
334 | 334 | |
335 | - if($user_algo !== $modx->config['pwd_hash_algo']) { |
|
336 | - $bk_pwd_hash_algo = $modx->config['pwd_hash_algo']; |
|
337 | - $modx->config['pwd_hash_algo'] = $user_algo; |
|
338 | - } |
|
335 | + if($user_algo !== $modx->config['pwd_hash_algo']) { |
|
336 | + $bk_pwd_hash_algo = $modx->config['pwd_hash_algo']; |
|
337 | + $modx->config['pwd_hash_algo'] = $user_algo; |
|
338 | + } |
|
339 | 339 | |
340 | - if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) { |
|
341 | - return false; |
|
342 | - } |
|
340 | + if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) { |
|
341 | + return false; |
|
342 | + } |
|
343 | 343 | |
344 | - updateNewHash($username, $givenPassword); |
|
344 | + updateNewHash($username, $givenPassword); |
|
345 | 345 | |
346 | - return true; |
|
346 | + return true; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -354,13 +354,13 @@ discard block |
||
354 | 354 | * @return bool |
355 | 355 | */ |
356 | 356 | function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) { |
357 | - global $modx; |
|
357 | + global $modx; |
|
358 | 358 | |
359 | - if($dbasePassword != md5($givenPassword)) { |
|
360 | - return false; |
|
361 | - } |
|
362 | - updateNewHash($username, $givenPassword); |
|
363 | - return true; |
|
359 | + if($dbasePassword != md5($givenPassword)) { |
|
360 | + return false; |
|
361 | + } |
|
362 | + updateNewHash($username, $givenPassword); |
|
363 | + return true; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -368,11 +368,11 @@ discard block |
||
368 | 368 | * @param string $password |
369 | 369 | */ |
370 | 370 | function updateNewHash($username, $password) { |
371 | - global $modx; |
|
371 | + global $modx; |
|
372 | 372 | |
373 | - $field = array(); |
|
374 | - $field['password'] = $modx->phpass->HashPassword($password); |
|
375 | - $modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'"); |
|
373 | + $field = array(); |
|
374 | + $field['password'] = $modx->phpass->HashPassword($password); |
|
375 | + $modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'"); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -382,27 +382,27 @@ discard block |
||
382 | 382 | * @param int $blocked_minutes |
383 | 383 | */ |
384 | 384 | function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) { |
385 | - global $modx; |
|
386 | - |
|
387 | - $failedlogins += 1; |
|
388 | - |
|
389 | - $fields = array('failedlogincount' => $failedlogins); |
|
390 | - if($failedlogins >= $failed_allowed) //block user for too many fail attempts |
|
391 | - { |
|
392 | - $fields['blockeduntil'] = time() + ($blocked_minutes * 60); |
|
393 | - } |
|
394 | - |
|
395 | - $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); |
|
396 | - |
|
397 | - if($failedlogins < $failed_allowed) { |
|
398 | - //sleep to help prevent brute force attacks |
|
399 | - $sleep = (int) $failedlogins / 2; |
|
400 | - if($sleep > 5) { |
|
401 | - $sleep = 5; |
|
402 | - } |
|
403 | - sleep($sleep); |
|
404 | - } |
|
405 | - @session_destroy(); |
|
406 | - session_unset(); |
|
407 | - return; |
|
385 | + global $modx; |
|
386 | + |
|
387 | + $failedlogins += 1; |
|
388 | + |
|
389 | + $fields = array('failedlogincount' => $failedlogins); |
|
390 | + if($failedlogins >= $failed_allowed) //block user for too many fail attempts |
|
391 | + { |
|
392 | + $fields['blockeduntil'] = time() + ($blocked_minutes * 60); |
|
393 | + } |
|
394 | + |
|
395 | + $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); |
|
396 | + |
|
397 | + if($failedlogins < $failed_allowed) { |
|
398 | + //sleep to help prevent brute force attacks |
|
399 | + $sleep = (int) $failedlogins / 2; |
|
400 | + if($sleep > 5) { |
|
401 | + $sleep = 5; |
|
402 | + } |
|
403 | + sleep($sleep); |
|
404 | + } |
|
405 | + @session_destroy(); |
|
406 | + session_unset(); |
|
407 | + return; |
|
408 | 408 | } |
@@ -1,23 +1,23 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,25 +218,25 @@ discard block |
||
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') { |
|
232 | - $_SESSION['modx.mgr.session.cookie.lifetime'] = (int)$modx->config['session.cookie.lifetime']; |
|
231 | +if ($rememberme == '1') { |
|
232 | + $_SESSION['modx.mgr.session.cookie.lifetime'] = (int) $modx->config['session.cookie.lifetime']; |
|
233 | 233 | |
234 | 234 | // Set a cookie separate from the session cookie with the username in it. |
235 | 235 | // Are we using secure connection? If so, make sure the cookie is secure |
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 |
||
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 |
@@ -274,17 +274,17 @@ discard block |
||
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 | -$id = (int)$modx->db->getValue($rs); |
|
278 | -if($id > 0) { |
|
279 | - $header = 'Location: ' . $modx->makeUrl($id, '', '', 'full'); |
|
280 | - if($_POST['ajax'] == 1) { |
|
277 | +$id = (int) $modx->db->getValue($rs); |
|
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); |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @param string $msg |
298 | 298 | */ |
299 | -function jsAlert($msg) { |
|
299 | +function jsAlert($msg){ |
|
300 | 300 | global $modx; |
301 | - if($_POST['ajax'] != 1) { |
|
302 | - echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>"; |
|
301 | + if ($_POST['ajax'] != 1) { |
|
302 | + echo "<script>window.setTimeout(\"alert('".addslashes($modx->db->escape($msg))."')\",10);history.go(-1)</script>"; |
|
303 | 303 | } else { |
304 | - echo $msg . "\n"; |
|
304 | + echo $msg."\n"; |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @param string $dbasePassword |
312 | 312 | * @return bool |
313 | 313 | */ |
314 | -function login($username, $givenPassword, $dbasePassword) { |
|
314 | +function login($username, $givenPassword, $dbasePassword){ |
|
315 | 315 | global $modx; |
316 | 316 | return $modx->phpass->CheckPassword($givenPassword, $dbasePassword); |
317 | 317 | } |
@@ -323,21 +323,21 @@ discard block |
||
323 | 323 | * @param string $username |
324 | 324 | * @return bool |
325 | 325 | */ |
326 | -function loginV1($internalKey, $givenPassword, $dbasePassword, $username) { |
|
326 | +function loginV1($internalKey, $givenPassword, $dbasePassword, $username){ |
|
327 | 327 | global $modx; |
328 | 328 | |
329 | 329 | $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey); |
330 | 330 | |
331 | - if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) { |
|
331 | + if (!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) { |
|
332 | 332 | $modx->config['pwd_hash_algo'] = 'UNCRYPT'; |
333 | 333 | } |
334 | 334 | |
335 | - if($user_algo !== $modx->config['pwd_hash_algo']) { |
|
335 | + if ($user_algo !== $modx->config['pwd_hash_algo']) { |
|
336 | 336 | $bk_pwd_hash_algo = $modx->config['pwd_hash_algo']; |
337 | 337 | $modx->config['pwd_hash_algo'] = $user_algo; |
338 | 338 | } |
339 | 339 | |
340 | - if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) { |
|
340 | + if ($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) { |
|
341 | 341 | return false; |
342 | 342 | } |
343 | 343 | |
@@ -353,10 +353,10 @@ discard block |
||
353 | 353 | * @param string $username |
354 | 354 | * @return bool |
355 | 355 | */ |
356 | -function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) { |
|
356 | +function loginMD5($internalKey, $givenPassword, $dbasePassword, $username){ |
|
357 | 357 | global $modx; |
358 | 358 | |
359 | - if($dbasePassword != md5($givenPassword)) { |
|
359 | + if ($dbasePassword != md5($givenPassword)) { |
|
360 | 360 | return false; |
361 | 361 | } |
362 | 362 | updateNewHash($username, $givenPassword); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * @param string $username |
368 | 368 | * @param string $password |
369 | 369 | */ |
370 | -function updateNewHash($username, $password) { |
|
370 | +function updateNewHash($username, $password){ |
|
371 | 371 | global $modx; |
372 | 372 | |
373 | 373 | $field = array(); |
@@ -381,23 +381,23 @@ discard block |
||
381 | 381 | * @param int $failed_allowed |
382 | 382 | * @param int $blocked_minutes |
383 | 383 | */ |
384 | -function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) { |
|
384 | +function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes){ |
|
385 | 385 | global $modx; |
386 | 386 | |
387 | 387 | $failedlogins += 1; |
388 | 388 | |
389 | 389 | $fields = array('failedlogincount' => $failedlogins); |
390 | - if($failedlogins >= $failed_allowed) //block user for too many fail attempts |
|
390 | + if ($failedlogins >= $failed_allowed) //block user for too many fail attempts |
|
391 | 391 | { |
392 | 392 | $fields['blockeduntil'] = time() + ($blocked_minutes * 60); |
393 | 393 | } |
394 | 394 | |
395 | 395 | $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); |
396 | 396 | |
397 | - if($failedlogins < $failed_allowed) { |
|
397 | + if ($failedlogins < $failed_allowed) { |
|
398 | 398 | //sleep to help prevent brute force attacks |
399 | 399 | $sleep = (int) $failedlogins / 2; |
400 | - if($sleep > 5) { |
|
400 | + if ($sleep > 5) { |
|
401 | 401 | $sleep = 5; |
402 | 402 | } |
403 | 403 | sleep($sleep); |
@@ -296,7 +296,8 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @param string $msg |
298 | 298 | */ |
299 | -function jsAlert($msg) { |
|
299 | +function jsAlert($msg) |
|
300 | +{ |
|
300 | 301 | global $modx; |
301 | 302 | if($_POST['ajax'] != 1) { |
302 | 303 | echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>"; |
@@ -311,7 +312,8 @@ discard block |
||
311 | 312 | * @param string $dbasePassword |
312 | 313 | * @return bool |
313 | 314 | */ |
314 | -function login($username, $givenPassword, $dbasePassword) { |
|
315 | +function login($username, $givenPassword, $dbasePassword) |
|
316 | +{ |
|
315 | 317 | global $modx; |
316 | 318 | return $modx->phpass->CheckPassword($givenPassword, $dbasePassword); |
317 | 319 | } |
@@ -323,7 +325,8 @@ discard block |
||
323 | 325 | * @param string $username |
324 | 326 | * @return bool |
325 | 327 | */ |
326 | -function loginV1($internalKey, $givenPassword, $dbasePassword, $username) { |
|
328 | +function loginV1($internalKey, $givenPassword, $dbasePassword, $username) |
|
329 | +{ |
|
327 | 330 | global $modx; |
328 | 331 | |
329 | 332 | $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey); |
@@ -353,7 +356,8 @@ discard block |
||
353 | 356 | * @param string $username |
354 | 357 | * @return bool |
355 | 358 | */ |
356 | -function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) { |
|
359 | +function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) |
|
360 | +{ |
|
357 | 361 | global $modx; |
358 | 362 | |
359 | 363 | if($dbasePassword != md5($givenPassword)) { |
@@ -367,7 +371,8 @@ discard block |
||
367 | 371 | * @param string $username |
368 | 372 | * @param string $password |
369 | 373 | */ |
370 | -function updateNewHash($username, $password) { |
|
374 | +function updateNewHash($username, $password) |
|
375 | +{ |
|
371 | 376 | global $modx; |
372 | 377 | |
373 | 378 | $field = array(); |
@@ -381,16 +386,19 @@ discard block |
||
381 | 386 | * @param int $failed_allowed |
382 | 387 | * @param int $blocked_minutes |
383 | 388 | */ |
384 | -function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) { |
|
389 | +function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) |
|
390 | +{ |
|
385 | 391 | global $modx; |
386 | 392 | |
387 | 393 | $failedlogins += 1; |
388 | 394 | |
389 | 395 | $fields = array('failedlogincount' => $failedlogins); |
390 | - if($failedlogins >= $failed_allowed) //block user for too many fail attempts |
|
396 | + if($failedlogins >= $failed_allowed) { |
|
397 | + //block user for too many fail attempts |
|
391 | 398 | { |
392 | 399 | $fields['blockeduntil'] = time() + ($blocked_minutes * 60); |
393 | 400 | } |
401 | + } |
|
394 | 402 | |
395 | 403 | $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); |
396 | 404 |
@@ -3,12 +3,12 @@ discard block |
||
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 | 5 | if(!$modx->hasPermission('delete_document')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0; |
10 | 10 | if($id==0) { |
11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /************ webber ********/ |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | $udperms->role = $_SESSION['mgrRole']; |
33 | 33 | |
34 | 34 | if(!$udperms->checkPermissions()) { |
35 | - $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
35 | + $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | // get the timestamp on which the document was deleted. |
39 | 39 | $rs = $modx->db->select('deletedon', $modx->getFullTableName('site_content'), "id='{$id}' AND deleted=1"); |
40 | 40 | $deltime = $modx->db->getValue($rs); |
41 | 41 | if(!$deltime) { |
42 | - $modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!"); |
|
42 | + $modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!"); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $children = array(); |
@@ -49,36 +49,36 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function getChildren($parent) { |
51 | 51 | |
52 | - global $modx; |
|
53 | - global $children; |
|
54 | - global $deltime; |
|
55 | - |
|
56 | - $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'"); |
|
57 | - // the document has children documents, we'll need to delete those too |
|
58 | - while ($row=$modx->db->getRow($rs)) { |
|
59 | - $children[] = $row['id']; |
|
60 | - getChildren($row['id']); |
|
61 | - //echo "Found childNode of parentNode $parent: ".$row['id']."<br />"; |
|
62 | - } |
|
52 | + global $modx; |
|
53 | + global $children; |
|
54 | + global $deltime; |
|
55 | + |
|
56 | + $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'"); |
|
57 | + // the document has children documents, we'll need to delete those too |
|
58 | + while ($row=$modx->db->getRow($rs)) { |
|
59 | + $children[] = $row['id']; |
|
60 | + getChildren($row['id']); |
|
61 | + //echo "Found childNode of parentNode $parent: ".$row['id']."<br />"; |
|
62 | + } |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | getChildren($id); |
66 | 66 | |
67 | 67 | if(count($children)>0) { |
68 | - $modx->db->update( |
|
69 | - array( |
|
70 | - 'deleted' => 0, |
|
71 | - 'deletedby' => 0, |
|
72 | - 'deletedon' => 0, |
|
73 | - ), $modx->getFullTableName('site_content'), "id IN(".implode(", ", $children).")"); |
|
68 | + $modx->db->update( |
|
69 | + array( |
|
70 | + 'deleted' => 0, |
|
71 | + 'deletedby' => 0, |
|
72 | + 'deletedon' => 0, |
|
73 | + ), $modx->getFullTableName('site_content'), "id IN(".implode(", ", $children).")"); |
|
74 | 74 | } |
75 | 75 | //'undelete' the document. |
76 | 76 | $modx->db->update( |
77 | - array( |
|
78 | - 'deleted' => 0, |
|
79 | - 'deletedby' => 0, |
|
80 | - 'deletedon' => 0, |
|
81 | - ), $modx->getFullTableName('site_content'), "id='{$id}'"); |
|
77 | + array( |
|
78 | + 'deleted' => 0, |
|
79 | + 'deletedby' => 0, |
|
80 | + 'deletedon' => 0, |
|
81 | + ), $modx->getFullTableName('site_content'), "id='{$id}'"); |
|
82 | 82 | |
83 | 83 | $modx->invokeEvent("OnDocFormUnDelete", |
84 | 84 | array( |
@@ -1,44 +1,44 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || 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('delete_document')) { |
|
5 | +if (!$modx->hasPermission('delete_document')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | /************ webber ********/ |
15 | -$content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
16 | -$pid=($content['parent']==0?$id:$content['parent']); |
|
15 | +$content = $modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); |
|
16 | +$pid = ($content['parent'] == 0 ? $id : $content['parent']); |
|
17 | 17 | |
18 | 18 | /************** webber *************/ |
19 | -$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; |
|
20 | -$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; |
|
21 | -$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; |
|
22 | -$add_path=$sd.$sb.$pg; |
|
19 | +$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC'; |
|
20 | +$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon'; |
|
21 | +$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : ''; |
|
22 | +$add_path = $sd.$sb.$pg; |
|
23 | 23 | |
24 | 24 | /***********************************/ |
25 | 25 | |
26 | 26 | |
27 | 27 | // check permissions on the document |
28 | -include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
28 | +include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
29 | 29 | $udperms = new udperms(); |
30 | 30 | $udperms->user = $modx->getLoginUserID(); |
31 | 31 | $udperms->document = $id; |
32 | 32 | $udperms->role = $_SESSION['mgrRole']; |
33 | 33 | |
34 | -if(!$udperms->checkPermissions()) { |
|
34 | +if (!$udperms->checkPermissions()) { |
|
35 | 35 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
36 | 36 | } |
37 | 37 | |
38 | 38 | // get the timestamp on which the document was deleted. |
39 | 39 | $rs = $modx->db->select('deletedon', $modx->getFullTableName('site_content'), "id='{$id}' AND deleted=1"); |
40 | 40 | $deltime = $modx->db->getValue($rs); |
41 | -if(!$deltime) { |
|
41 | +if (!$deltime) { |
|
42 | 42 | $modx->webAlertAndQuit("Couldn't find document to determine it's date of deletion!"); |
43 | 43 | } |
44 | 44 | |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * @param int $parent |
49 | 49 | */ |
50 | -function getChildren($parent) { |
|
50 | +function getChildren($parent){ |
|
51 | 51 | |
52 | 52 | global $modx; |
53 | 53 | global $children; |
54 | 54 | global $deltime; |
55 | 55 | |
56 | - $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int)$parent."' AND deleted=1 AND deletedon='".(int)$deltime."'"); |
|
56 | + $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent='".(int) $parent."' AND deleted=1 AND deletedon='".(int) $deltime."'"); |
|
57 | 57 | // the document has children documents, we'll need to delete those too |
58 | - while ($row=$modx->db->getRow($rs)) { |
|
58 | + while ($row = $modx->db->getRow($rs)) { |
|
59 | 59 | $children[] = $row['id']; |
60 | 60 | getChildren($row['id']); |
61 | 61 | //echo "Found childNode of parentNode $parent: ".$row['id']."<br />"; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | getChildren($id); |
66 | 66 | |
67 | -if(count($children)>0) { |
|
67 | +if (count($children) > 0) { |
|
68 | 68 | $modx->db->update( |
69 | 69 | array( |
70 | 70 | 'deleted' => 0, |
@@ -93,5 +93,5 @@ discard block |
||
93 | 93 | $modx->clearCache('full'); |
94 | 94 | |
95 | 95 | // finished emptying cache - redirect |
96 | -$header="Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
96 | +$header = "Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
97 | 97 | header($header); |
@@ -47,7 +47,8 @@ |
||
47 | 47 | /** |
48 | 48 | * @param int $parent |
49 | 49 | */ |
50 | -function getChildren($parent) { |
|
50 | +function getChildren($parent) |
|
51 | +{ |
|
51 | 52 | |
52 | 53 | global $modx; |
53 | 54 | global $children; |
@@ -3,12 +3,12 @@ discard block |
||
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 | 5 | if(!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
10 | 10 | if($id==0) { |
11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | $children = array(); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | $udperms->duplicateDoc = true; |
23 | 23 | |
24 | 24 | if(!$udperms->checkPermissions()) { |
25 | - $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
25 | + $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | // Run the duplicator |
@@ -43,103 +43,103 @@ discard block |
||
43 | 43 | * @return int |
44 | 44 | */ |
45 | 45 | function duplicateDocument($docid, $parent=null, $_toplevel=0) { |
46 | - global $modx, $_lang; |
|
47 | - |
|
48 | - // invoke OnBeforeDocDuplicate event |
|
49 | - $evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array( |
|
50 | - 'id' => $docid |
|
51 | - )); |
|
52 | - |
|
53 | - // if( !in_array( 'false', array_values( $evtOut ) ) ){} |
|
54 | - // TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication |
|
55 | - // [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false'); |
|
56 | - |
|
57 | - $userID = $modx->getLoginUserID(); |
|
58 | - |
|
59 | - $tblsc = $modx->getFullTableName('site_content'); |
|
60 | - |
|
61 | - // Grab the original document |
|
62 | - $rs = $modx->db->select('*', $tblsc, "id='{$docid}'"); |
|
63 | - $content = $modx->db->getRow($rs); |
|
64 | - |
|
65 | - // Handle incremental ID |
|
66 | - switch($modx->config['docid_incrmnt_method']) |
|
67 | - { |
|
68 | - case '1': |
|
69 | - $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
|
70 | - $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
|
71 | - $content['id'] = $modx->db->getValue($rs); |
|
72 | - break; |
|
73 | - case '2': |
|
74 | - $rs = $modx->db->select('MAX(id)+1',$tblsc); |
|
75 | - $content['id'] = $modx->db->getValue($rs); |
|
76 | - break; |
|
77 | - |
|
78 | - default: |
|
79 | - unset($content['id']); // remove the current id. |
|
80 | - } |
|
81 | - |
|
82 | - // Once we've grabbed the document object, start doing some modifications |
|
83 | - if ($_toplevel == 0) { |
|
84 | - // count duplicates |
|
85 | - $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
|
86 | - $pagetitle = $modx->db->escape($pagetitle); |
|
87 | - $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
|
88 | - if($count>=1) $count = ' '.($count+1); |
|
89 | - else $count = ''; |
|
90 | - |
|
91 | - $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
|
92 | - $content['alias'] = null; |
|
93 | - } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) { |
|
94 | - $content['alias'] = null; |
|
95 | - } |
|
96 | - |
|
97 | - // change the parent accordingly |
|
98 | - if ($parent !== null) $content['parent'] = $parent; |
|
99 | - |
|
100 | - // Change the author |
|
101 | - $content['createdby'] = $userID; |
|
102 | - $content['createdon'] = time(); |
|
103 | - // Remove other modification times |
|
104 | - $content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0; |
|
105 | - |
|
106 | - // [FS#922] Should the published status be honored? - sirlancelot |
|
46 | + global $modx, $_lang; |
|
47 | + |
|
48 | + // invoke OnBeforeDocDuplicate event |
|
49 | + $evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array( |
|
50 | + 'id' => $docid |
|
51 | + )); |
|
52 | + |
|
53 | + // if( !in_array( 'false', array_values( $evtOut ) ) ){} |
|
54 | + // TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication |
|
55 | + // [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false'); |
|
56 | + |
|
57 | + $userID = $modx->getLoginUserID(); |
|
58 | + |
|
59 | + $tblsc = $modx->getFullTableName('site_content'); |
|
60 | + |
|
61 | + // Grab the original document |
|
62 | + $rs = $modx->db->select('*', $tblsc, "id='{$docid}'"); |
|
63 | + $content = $modx->db->getRow($rs); |
|
64 | + |
|
65 | + // Handle incremental ID |
|
66 | + switch($modx->config['docid_incrmnt_method']) |
|
67 | + { |
|
68 | + case '1': |
|
69 | + $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
|
70 | + $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
|
71 | + $content['id'] = $modx->db->getValue($rs); |
|
72 | + break; |
|
73 | + case '2': |
|
74 | + $rs = $modx->db->select('MAX(id)+1',$tblsc); |
|
75 | + $content['id'] = $modx->db->getValue($rs); |
|
76 | + break; |
|
77 | + |
|
78 | + default: |
|
79 | + unset($content['id']); // remove the current id. |
|
80 | + } |
|
81 | + |
|
82 | + // Once we've grabbed the document object, start doing some modifications |
|
83 | + if ($_toplevel == 0) { |
|
84 | + // count duplicates |
|
85 | + $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
|
86 | + $pagetitle = $modx->db->escape($pagetitle); |
|
87 | + $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
|
88 | + if($count>=1) $count = ' '.($count+1); |
|
89 | + else $count = ''; |
|
90 | + |
|
91 | + $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
|
92 | + $content['alias'] = null; |
|
93 | + } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) { |
|
94 | + $content['alias'] = null; |
|
95 | + } |
|
96 | + |
|
97 | + // change the parent accordingly |
|
98 | + if ($parent !== null) $content['parent'] = $parent; |
|
99 | + |
|
100 | + // Change the author |
|
101 | + $content['createdby'] = $userID; |
|
102 | + $content['createdon'] = time(); |
|
103 | + // Remove other modification times |
|
104 | + $content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0; |
|
105 | + |
|
106 | + // [FS#922] Should the published status be honored? - sirlancelot |
|
107 | 107 | // if ($modx->hasPermission('publish_document')) { |
108 | 108 | // if ($modx->config['publish_default']) |
109 | 109 | // $content['pub_date'] = $content['pub_date']; // should this be changed to 1? |
110 | 110 | // else $content['pub_date'] = 0; |
111 | 111 | // } else { |
112 | - // User can't publish documents |
|
112 | + // User can't publish documents |
|
113 | 113 | // $content['published'] = $content['pub_date'] = 0; |
114 | 114 | // } |
115 | 115 | |
116 | 116 | // Set the published status to unpublished by default (see above ... commit #3388) |
117 | 117 | $content['published'] = $content['pub_date'] = 0; |
118 | 118 | |
119 | - // Escape the proper strings |
|
120 | - $content = $modx->db->escape($content); |
|
119 | + // Escape the proper strings |
|
120 | + $content = $modx->db->escape($content); |
|
121 | 121 | |
122 | - // Duplicate the Document |
|
123 | - $newparent = $modx->db->insert($content, $tblsc); |
|
122 | + // Duplicate the Document |
|
123 | + $newparent = $modx->db->insert($content, $tblsc); |
|
124 | 124 | |
125 | - // duplicate document's TVs |
|
126 | - duplicateTVs($docid, $newparent); |
|
127 | - duplicateAccess($docid, $newparent); |
|
125 | + // duplicate document's TVs |
|
126 | + duplicateTVs($docid, $newparent); |
|
127 | + duplicateAccess($docid, $newparent); |
|
128 | 128 | |
129 | - // invoke OnDocDuplicate event |
|
130 | - $evtOut = $modx->invokeEvent('OnDocDuplicate', array( |
|
131 | - 'id' => $docid, |
|
132 | - 'new_id' => $newparent |
|
133 | - )); |
|
129 | + // invoke OnDocDuplicate event |
|
130 | + $evtOut = $modx->invokeEvent('OnDocDuplicate', array( |
|
131 | + 'id' => $docid, |
|
132 | + 'new_id' => $newparent |
|
133 | + )); |
|
134 | 134 | |
135 | - // Start duplicating all the child documents that aren't deleted. |
|
136 | - $_toplevel++; |
|
137 | - $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC'); |
|
138 | - while ($row = $modx->db->getRow($rs)) |
|
139 | - duplicateDocument($row['id'], $newparent, $_toplevel); |
|
135 | + // Start duplicating all the child documents that aren't deleted. |
|
136 | + $_toplevel++; |
|
137 | + $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC'); |
|
138 | + while ($row = $modx->db->getRow($rs)) |
|
139 | + duplicateDocument($row['id'], $newparent, $_toplevel); |
|
140 | 140 | |
141 | - // return the new doc id |
|
142 | - return $newparent; |
|
141 | + // return the new doc id |
|
142 | + return $newparent; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -149,17 +149,17 @@ discard block |
||
149 | 149 | * @param int $newid |
150 | 150 | */ |
151 | 151 | function duplicateTVs($oldid, $newid){ |
152 | - global $modx; |
|
152 | + global $modx; |
|
153 | 153 | |
154 | - $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
|
154 | + $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
|
155 | 155 | |
156 | 156 | $newid = (int)$newid; |
157 | 157 | $oldid = (int)$oldid; |
158 | 158 | |
159 | 159 | $modx->db->insert( |
160 | - array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into |
|
161 | - "{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from |
|
162 | - ); |
|
160 | + array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into |
|
161 | + "{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from |
|
162 | + ); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | * @param int $newid |
170 | 170 | */ |
171 | 171 | function duplicateAccess($oldid, $newid){ |
172 | - global $modx; |
|
172 | + global $modx; |
|
173 | 173 | |
174 | - $tbldg = $modx->getFullTableName('document_groups'); |
|
174 | + $tbldg = $modx->getFullTableName('document_groups'); |
|
175 | 175 | |
176 | 176 | $newid = (int)$newid; |
177 | 177 | $oldid = (int)$oldid; |
178 | 178 | |
179 | 179 | $modx->db->insert( |
180 | - array('document'=>'', 'document_group'=>''), $tbldg, // Insert into |
|
181 | - "{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from |
|
182 | - ); |
|
180 | + array('document'=>'', 'document_group'=>''), $tbldg, // Insert into |
|
181 | + "{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from |
|
182 | + ); |
|
183 | 183 | } |
@@ -1,27 +1,27 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || 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('new_document') || !$modx->hasPermission('save_document')) { |
|
5 | +if (!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | $children = array(); |
15 | 15 | |
16 | 16 | // check permissions on the document |
17 | -include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
17 | +include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
18 | 18 | $udperms = new udperms(); |
19 | 19 | $udperms->user = $modx->getLoginUserID(); |
20 | 20 | $udperms->document = $id; |
21 | 21 | $udperms->role = $_SESSION['mgrRole']; |
22 | 22 | $udperms->duplicateDoc = true; |
23 | 23 | |
24 | -if(!$udperms->checkPermissions()) { |
|
24 | +if (!$udperms->checkPermissions()) { |
|
25 | 25 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
26 | 26 | } |
27 | 27 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $_SESSION['itemname'] = $name; |
34 | 34 | |
35 | 35 | // finish cloning - redirect |
36 | -$header="Location: index.php?r=1&a=3&id=$id"; |
|
36 | +$header = "Location: index.php?r=1&a=3&id=$id"; |
|
37 | 37 | header($header); |
38 | 38 | |
39 | 39 | /** |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param int $_toplevel |
43 | 43 | * @return int |
44 | 44 | */ |
45 | -function duplicateDocument($docid, $parent=null, $_toplevel=0) { |
|
45 | +function duplicateDocument($docid, $parent = null, $_toplevel = 0){ |
|
46 | 46 | global $modx, $_lang; |
47 | 47 | |
48 | 48 | // invoke OnBeforeDocDuplicate event |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $content = $modx->db->getRow($rs); |
64 | 64 | |
65 | 65 | // Handle incremental ID |
66 | - switch($modx->config['docid_incrmnt_method']) |
|
66 | + switch ($modx->config['docid_incrmnt_method']) |
|
67 | 67 | { |
68 | 68 | case '1': |
69 | 69 | $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $content['id'] = $modx->db->getValue($rs); |
72 | 72 | break; |
73 | 73 | case '2': |
74 | - $rs = $modx->db->select('MAX(id)+1',$tblsc); |
|
74 | + $rs = $modx->db->select('MAX(id)+1', $tblsc); |
|
75 | 75 | $content['id'] = $modx->db->getValue($rs); |
76 | 76 | break; |
77 | 77 | |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
86 | 86 | $pagetitle = $modx->db->escape($pagetitle); |
87 | 87 | $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
88 | - if($count>=1) $count = ' '.($count+1); |
|
88 | + if ($count >= 1) $count = ' '.($count + 1); |
|
89 | 89 | else $count = ''; |
90 | 90 | |
91 | 91 | $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
92 | 92 | $content['alias'] = null; |
93 | - } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) { |
|
93 | + } elseif ($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) { |
|
94 | 94 | $content['alias'] = null; |
95 | 95 | } |
96 | 96 | |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | |
154 | 154 | $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
155 | 155 | |
156 | - $newid = (int)$newid; |
|
157 | - $oldid = (int)$oldid; |
|
156 | + $newid = (int) $newid; |
|
157 | + $oldid = (int) $oldid; |
|
158 | 158 | |
159 | 159 | $modx->db->insert( |
160 | 160 | array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | |
174 | 174 | $tbldg = $modx->getFullTableName('document_groups'); |
175 | 175 | |
176 | - $newid = (int)$newid; |
|
177 | - $oldid = (int)$oldid; |
|
176 | + $newid = (int) $newid; |
|
177 | + $oldid = (int) $oldid; |
|
178 | 178 | |
179 | 179 | $modx->db->insert( |
180 | 180 | array('document'=>'', 'document_group'=>''), $tbldg, // Insert into |
@@ -42,7 +42,8 @@ discard block |
||
42 | 42 | * @param int $_toplevel |
43 | 43 | * @return int |
44 | 44 | */ |
45 | -function duplicateDocument($docid, $parent=null, $_toplevel=0) { |
|
45 | +function duplicateDocument($docid, $parent=null, $_toplevel=0) |
|
46 | +{ |
|
46 | 47 | global $modx, $_lang; |
47 | 48 | |
48 | 49 | // invoke OnBeforeDocDuplicate event |
@@ -63,8 +64,7 @@ discard block |
||
63 | 64 | $content = $modx->db->getRow($rs); |
64 | 65 | |
65 | 66 | // Handle incremental ID |
66 | - switch($modx->config['docid_incrmnt_method']) |
|
67 | - { |
|
67 | + switch($modx->config['docid_incrmnt_method']) { |
|
68 | 68 | case '1': |
69 | 69 | $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
70 | 70 | $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
@@ -85,8 +85,11 @@ discard block |
||
85 | 85 | $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
86 | 86 | $pagetitle = $modx->db->escape($pagetitle); |
87 | 87 | $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
88 | - if($count>=1) $count = ' '.($count+1); |
|
89 | - else $count = ''; |
|
88 | + if($count>=1) { |
|
89 | + $count = ' '.($count+1); |
|
90 | + } else { |
|
91 | + $count = ''; |
|
92 | + } |
|
90 | 93 | |
91 | 94 | $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
92 | 95 | $content['alias'] = null; |
@@ -95,7 +98,9 @@ discard block |
||
95 | 98 | } |
96 | 99 | |
97 | 100 | // change the parent accordingly |
98 | - if ($parent !== null) $content['parent'] = $parent; |
|
101 | + if ($parent !== null) { |
|
102 | + $content['parent'] = $parent; |
|
103 | + } |
|
99 | 104 | |
100 | 105 | // Change the author |
101 | 106 | $content['createdby'] = $userID; |
@@ -135,8 +140,9 @@ discard block |
||
135 | 140 | // Start duplicating all the child documents that aren't deleted. |
136 | 141 | $_toplevel++; |
137 | 142 | $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC'); |
138 | - while ($row = $modx->db->getRow($rs)) |
|
139 | - duplicateDocument($row['id'], $newparent, $_toplevel); |
|
143 | + while ($row = $modx->db->getRow($rs)) { |
|
144 | + duplicateDocument($row['id'], $newparent, $_toplevel); |
|
145 | + } |
|
140 | 146 | |
141 | 147 | // return the new doc id |
142 | 148 | return $newparent; |
@@ -148,7 +154,8 @@ discard block |
||
148 | 154 | * @param int $oldid |
149 | 155 | * @param int $newid |
150 | 156 | */ |
151 | -function duplicateTVs($oldid, $newid){ |
|
157 | +function duplicateTVs($oldid, $newid) |
|
158 | +{ |
|
152 | 159 | global $modx; |
153 | 160 | |
154 | 161 | $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
@@ -168,7 +175,8 @@ discard block |
||
168 | 175 | * @param int $oldid |
169 | 176 | * @param int $newid |
170 | 177 | */ |
171 | -function duplicateAccess($oldid, $newid){ |
|
178 | +function duplicateAccess($oldid, $newid) |
|
179 | +{ |
|
172 | 180 | global $modx; |
173 | 181 | |
174 | 182 | $tbldg = $modx->getFullTableName('document_groups'); |
@@ -3,51 +3,51 @@ discard block |
||
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 | 5 | if(!$modx->hasPermission('exec_module')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
10 | 10 | if($id==0) { |
11 | - $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
11 | + $modx->webAlertAndQuit($_lang["error_no_id"]); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | // check if user has access permission, except admins |
15 | 15 | if($_SESSION['mgrRole']!=1){ |
16 | - $rs = $modx->db->select( |
|
17 | - 'sma.usergroup,mg.member', |
|
18 | - $modx->getFullTableName("site_module_access")." sma |
|
16 | + $rs = $modx->db->select( |
|
17 | + 'sma.usergroup,mg.member', |
|
18 | + $modx->getFullTableName("site_module_access")." sma |
|
19 | 19 | LEFT JOIN ".$modx->getFullTableName("member_groups")." mg ON mg.user_group = sma.usergroup AND member='".$modx->getLoginUserID()."'", |
20 | - "sma.module = '{$id}'" |
|
21 | - ); |
|
22 | - //initialize permission to -1, if it stays -1 no permissions |
|
23 | - //attached so permission granted |
|
24 | - $permissionAccessInt = -1; |
|
20 | + "sma.module = '{$id}'" |
|
21 | + ); |
|
22 | + //initialize permission to -1, if it stays -1 no permissions |
|
23 | + //attached so permission granted |
|
24 | + $permissionAccessInt = -1; |
|
25 | 25 | |
26 | - while ($row = $modx->db->getRow($rs)) { |
|
27 | - if($row["usergroup"] && $row["member"]) { |
|
28 | - //if there are permissions and this member has permission, ofcourse |
|
29 | - //this is granted |
|
30 | - $permissionAccessInt = 1; |
|
31 | - } elseif ($permissionAccessInt==-1) { |
|
32 | - //if there are permissions but this member has no permission and the |
|
33 | - //variable was still in init state we set permission to 0; no permissions |
|
34 | - $permissionAccessInt = 0; |
|
35 | - } |
|
36 | - } |
|
26 | + while ($row = $modx->db->getRow($rs)) { |
|
27 | + if($row["usergroup"] && $row["member"]) { |
|
28 | + //if there are permissions and this member has permission, ofcourse |
|
29 | + //this is granted |
|
30 | + $permissionAccessInt = 1; |
|
31 | + } elseif ($permissionAccessInt==-1) { |
|
32 | + //if there are permissions but this member has no permission and the |
|
33 | + //variable was still in init state we set permission to 0; no permissions |
|
34 | + $permissionAccessInt = 0; |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | - if($permissionAccessInt==0) { |
|
39 | - $modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106"); |
|
40 | - } |
|
38 | + if($permissionAccessInt==0) { |
|
39 | + $modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106"); |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // get module data |
44 | 44 | $rs = $modx->db->select('*', $modx->getFullTableName("site_modules"), "id='{$id}'"); |
45 | 45 | $content = $modx->db->getRow($rs); |
46 | 46 | if(!$content) { |
47 | - $modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106"); |
|
47 | + $modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106"); |
|
48 | 48 | } |
49 | 49 | if($content['disabled']) { |
50 | - $modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106"); |
|
50 | + $modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106"); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // Set the item name for logger |
@@ -71,38 +71,38 @@ discard block |
||
71 | 71 | * @return string |
72 | 72 | */ |
73 | 73 | function evalModule($moduleCode,$params){ |
74 | - global $modx; |
|
75 | - $modx->event->params = &$params; // store params inside event object |
|
76 | - if(is_array($params)) { |
|
77 | - extract($params, EXTR_SKIP); |
|
78 | - } |
|
79 | - ob_start(); |
|
80 | - $mod = eval($moduleCode); |
|
81 | - $msg = ob_get_contents(); |
|
82 | - ob_end_clean(); |
|
83 | - if (isset($php_errormsg)) |
|
84 | - { |
|
85 | - $error_info = error_get_last(); |
|
74 | + global $modx; |
|
75 | + $modx->event->params = &$params; // store params inside event object |
|
76 | + if(is_array($params)) { |
|
77 | + extract($params, EXTR_SKIP); |
|
78 | + } |
|
79 | + ob_start(); |
|
80 | + $mod = eval($moduleCode); |
|
81 | + $msg = ob_get_contents(); |
|
82 | + ob_end_clean(); |
|
83 | + if (isset($php_errormsg)) |
|
84 | + { |
|
85 | + $error_info = error_get_last(); |
|
86 | 86 | switch($error_info['type']) |
87 | 87 | { |
88 | - case E_NOTICE : |
|
89 | - $error_level = 1; |
|
90 | - case E_USER_NOTICE : |
|
91 | - break; |
|
92 | - case E_DEPRECATED : |
|
93 | - case E_USER_DEPRECATED : |
|
94 | - case E_STRICT : |
|
95 | - $error_level = 2; |
|
96 | - break; |
|
97 | - default: |
|
98 | - $error_level = 99; |
|
88 | + case E_NOTICE : |
|
89 | + $error_level = 1; |
|
90 | + case E_USER_NOTICE : |
|
91 | + break; |
|
92 | + case E_DEPRECATED : |
|
93 | + case E_USER_DEPRECATED : |
|
94 | + case E_STRICT : |
|
95 | + $error_level = 2; |
|
96 | + break; |
|
97 | + default: |
|
98 | + $error_level = 99; |
|
99 | + } |
|
100 | + if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
101 | + { |
|
102 | + $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
|
103 | + $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
|
99 | 104 | } |
100 | - if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
101 | - { |
|
102 | - $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
|
103 | - $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
|
104 | - } |
|
105 | - } |
|
106 | - unset($modx->event->params); |
|
107 | - return $mod.$msg; |
|
105 | + } |
|
106 | + unset($modx->event->params); |
|
107 | + return $mod.$msg; |
|
108 | 108 | } |
@@ -1,18 +1,18 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || 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('exec_module')) { |
|
5 | +if (!$modx->hasPermission('exec_module')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | // check if user has access permission, except admins |
15 | -if($_SESSION['mgrRole']!=1){ |
|
15 | +if ($_SESSION['mgrRole'] != 1) { |
|
16 | 16 | $rs = $modx->db->select( |
17 | 17 | 'sma.usergroup,mg.member', |
18 | 18 | $modx->getFullTableName("site_module_access")." sma |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | $permissionAccessInt = -1; |
25 | 25 | |
26 | 26 | while ($row = $modx->db->getRow($rs)) { |
27 | - if($row["usergroup"] && $row["member"]) { |
|
27 | + if ($row["usergroup"] && $row["member"]) { |
|
28 | 28 | //if there are permissions and this member has permission, ofcourse |
29 | 29 | //this is granted |
30 | 30 | $permissionAccessInt = 1; |
31 | - } elseif ($permissionAccessInt==-1) { |
|
31 | + } elseif ($permissionAccessInt == -1) { |
|
32 | 32 | //if there are permissions but this member has no permission and the |
33 | 33 | //variable was still in init state we set permission to 0; no permissions |
34 | 34 | $permissionAccessInt = 0; |
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | - if($permissionAccessInt==0) { |
|
38 | + if ($permissionAccessInt == 0) { |
|
39 | 39 | $modx->webAlertAndQuit("You do not sufficient privileges to execute this module.", "index.php?a=106"); |
40 | 40 | } |
41 | 41 | } |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | // get module data |
44 | 44 | $rs = $modx->db->select('*', $modx->getFullTableName("site_modules"), "id='{$id}'"); |
45 | 45 | $content = $modx->db->getRow($rs); |
46 | -if(!$content) { |
|
46 | +if (!$content) { |
|
47 | 47 | $modx->webAlertAndQuit("No record found for id {$id}.", "index.php?a=106"); |
48 | 48 | } |
49 | -if($content['disabled']) { |
|
49 | +if ($content['disabled']) { |
|
50 | 50 | $modx->webAlertAndQuit("This module is disabled and cannot be executed.", "index.php?a=106"); |
51 | 51 | } |
52 | 52 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // Set the item name for logger |
60 | 60 | $_SESSION['itemname'] = $content['name']; |
61 | 61 | |
62 | -$output = evalModule($content["modulecode"],$parameter); |
|
62 | +$output = evalModule($content["modulecode"], $parameter); |
|
63 | 63 | echo $output; |
64 | 64 | include MODX_MANAGER_PATH."includes/sysalert.display.inc.php"; |
65 | 65 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | * @param array $params |
71 | 71 | * @return string |
72 | 72 | */ |
73 | -function evalModule($moduleCode,$params){ |
|
73 | +function evalModule($moduleCode, $params){ |
|
74 | 74 | global $modx; |
75 | 75 | $modx->event->params = &$params; // store params inside event object |
76 | - if(is_array($params)) { |
|
76 | + if (is_array($params)) { |
|
77 | 77 | extract($params, EXTR_SKIP); |
78 | 78 | } |
79 | 79 | ob_start(); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | if (isset($php_errormsg)) |
84 | 84 | { |
85 | 85 | $error_info = error_get_last(); |
86 | - switch($error_info['type']) |
|
86 | + switch ($error_info['type']) |
|
87 | 87 | { |
88 | 88 | case E_NOTICE : |
89 | 89 | $error_level = 1; |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | default: |
98 | 98 | $error_level = 99; |
99 | 99 | } |
100 | - if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
100 | + if ($modx->config['error_reporting'] === '99' || 2 < $error_level) |
|
101 | 101 | { |
102 | - $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
|
102 | + $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'].' - Module', $error_info['message'], $error_info['line'], $msg); |
|
103 | 103 | $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
104 | 104 | } |
105 | 105 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | // check if user has access permission, except admins |
15 | -if($_SESSION['mgrRole']!=1){ |
|
15 | +if($_SESSION['mgrRole']!=1) { |
|
16 | 16 | $rs = $modx->db->select( |
17 | 17 | 'sma.usergroup,mg.member', |
18 | 18 | $modx->getFullTableName("site_module_access")." sma |
@@ -70,7 +70,8 @@ discard block |
||
70 | 70 | * @param array $params |
71 | 71 | * @return string |
72 | 72 | */ |
73 | -function evalModule($moduleCode,$params){ |
|
73 | +function evalModule($moduleCode,$params) |
|
74 | +{ |
|
74 | 75 | global $modx; |
75 | 76 | $modx->event->params = &$params; // store params inside event object |
76 | 77 | if(is_array($params)) { |
@@ -80,11 +81,9 @@ discard block |
||
80 | 81 | $mod = eval($moduleCode); |
81 | 82 | $msg = ob_get_contents(); |
82 | 83 | ob_end_clean(); |
83 | - if (isset($php_errormsg)) |
|
84 | - { |
|
84 | + if (isset($php_errormsg)) { |
|
85 | 85 | $error_info = error_get_last(); |
86 | - switch($error_info['type']) |
|
87 | - { |
|
86 | + switch($error_info['type']) { |
|
88 | 87 | case E_NOTICE : |
89 | 88 | $error_level = 1; |
90 | 89 | case E_USER_NOTICE : |
@@ -97,8 +96,7 @@ discard block |
||
97 | 96 | default: |
98 | 97 | $error_level = 99; |
99 | 98 | } |
100 | - if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
101 | - { |
|
99 | + if($modx->config['error_reporting']==='99' || 2<$error_level) { |
|
102 | 100 | $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
103 | 101 | $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
104 | 102 | } |
@@ -3,7 +3,7 @@ discard block |
||
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 | 5 | if(!$modx->hasPermission('edit_document')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0; |
@@ -25,17 +25,17 @@ discard block |
||
25 | 25 | // check user has permission to move document to chosen location |
26 | 26 | |
27 | 27 | if ($use_udperms == 1) { |
28 | - if ($oldparent != $newParentID) { |
|
29 | - include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
30 | - $udperms = new udperms(); |
|
31 | - $udperms->user = $modx->getLoginUserID(); |
|
32 | - $udperms->document = $newParentID; |
|
33 | - $udperms->role = $_SESSION['mgrRole']; |
|
34 | - |
|
35 | - if (!$udperms->checkPermissions()) { |
|
36 | - $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]); |
|
37 | - } |
|
38 | - } |
|
28 | + if ($oldparent != $newParentID) { |
|
29 | + include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
30 | + $udperms = new udperms(); |
|
31 | + $udperms->user = $modx->getLoginUserID(); |
|
32 | + $udperms->document = $newParentID; |
|
33 | + $udperms->role = $_SESSION['mgrRole']; |
|
34 | + |
|
35 | + if (!$udperms->checkPermissions()) { |
|
36 | + $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]); |
|
37 | + } |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -43,67 +43,67 @@ discard block |
||
43 | 43 | * @return array |
44 | 44 | */ |
45 | 45 | function allChildren($currDocID) { |
46 | - global $modx; |
|
47 | - $children= array(); |
|
48 | - $currDocID = $modx->db->escape($currDocID); |
|
49 | - $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'"); |
|
50 | - while ($child= $modx->db->getRow($rs)) { |
|
51 | - $children[]= $child['id']; |
|
52 | - $children= array_merge($children, allChildren($child['id'])); |
|
53 | - } |
|
54 | - return $children; |
|
46 | + global $modx; |
|
47 | + $children= array(); |
|
48 | + $currDocID = $modx->db->escape($currDocID); |
|
49 | + $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'"); |
|
50 | + while ($child= $modx->db->getRow($rs)) { |
|
51 | + $children[]= $child['id']; |
|
52 | + $children= array_merge($children, allChildren($child['id'])); |
|
53 | + } |
|
54 | + return $children; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $evtOut = $modx->invokeEvent("onBeforeMoveDocument", array ( |
58 | - "id_document" => $documentID, |
|
59 | - "old_parent" => $oldparent, |
|
60 | - "new_parent" => $newParentID |
|
58 | + "id_document" => $documentID, |
|
59 | + "old_parent" => $oldparent, |
|
60 | + "new_parent" => $newParentID |
|
61 | 61 | )); |
62 | 62 | if (is_array($evtOut) && count($evtOut) > 0){ |
63 | - $newParent = array_pop($evtOut); |
|
64 | - if($newParent == $oldparent) { |
|
65 | - $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
66 | - }else{ |
|
67 | - $newParentID = $newParent; |
|
68 | - } |
|
63 | + $newParent = array_pop($evtOut); |
|
64 | + if($newParent == $oldparent) { |
|
65 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
66 | + }else{ |
|
67 | + $newParentID = $newParent; |
|
68 | + } |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $children = allChildren($documentID); |
72 | 72 | if (!array_search($newParentID, $children)) { |
73 | - $modx->db->update(array( |
|
74 | - 'isfolder' => 1, |
|
75 | - ), $modx->getFullTableName('site_content'), "id='{$newParentID}'"); |
|
76 | - |
|
77 | - $modx->db->update(array( |
|
78 | - 'parent' => $newParentID, |
|
79 | - 'editedby' => $modx->getLoginUserID(), |
|
80 | - 'editedon' => time(), |
|
81 | - ), $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
|
82 | - |
|
83 | - // finished moving the document, now check to see if the old_parent should no longer be a folder. |
|
84 | - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
|
85 | - $limit = $modx->db->getValue($rs); |
|
86 | - |
|
87 | - if(!$limit>0) { |
|
88 | - $modx->db->update(array( |
|
89 | - 'isfolder' => 0, |
|
90 | - ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
|
91 | - } |
|
92 | - // Set the item name for logger |
|
93 | - $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
|
94 | - $_SESSION['itemname'] = $pagetitle; |
|
95 | - |
|
96 | - $modx->invokeEvent("onAfterMoveDocument", array ( |
|
97 | - "id_document" => $documentID, |
|
98 | - "old_parent" => $oldparent, |
|
99 | - "new_parent" => $newParentID |
|
100 | - )); |
|
101 | - |
|
102 | - // empty cache & sync site |
|
103 | - $modx->clearCache('full'); |
|
104 | - |
|
105 | - $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
106 | - header($header); |
|
73 | + $modx->db->update(array( |
|
74 | + 'isfolder' => 1, |
|
75 | + ), $modx->getFullTableName('site_content'), "id='{$newParentID}'"); |
|
76 | + |
|
77 | + $modx->db->update(array( |
|
78 | + 'parent' => $newParentID, |
|
79 | + 'editedby' => $modx->getLoginUserID(), |
|
80 | + 'editedon' => time(), |
|
81 | + ), $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
|
82 | + |
|
83 | + // finished moving the document, now check to see if the old_parent should no longer be a folder. |
|
84 | + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
|
85 | + $limit = $modx->db->getValue($rs); |
|
86 | + |
|
87 | + if(!$limit>0) { |
|
88 | + $modx->db->update(array( |
|
89 | + 'isfolder' => 0, |
|
90 | + ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
|
91 | + } |
|
92 | + // Set the item name for logger |
|
93 | + $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
|
94 | + $_SESSION['itemname'] = $pagetitle; |
|
95 | + |
|
96 | + $modx->invokeEvent("onAfterMoveDocument", array ( |
|
97 | + "id_document" => $documentID, |
|
98 | + "old_parent" => $oldparent, |
|
99 | + "new_parent" => $newParentID |
|
100 | + )); |
|
101 | + |
|
102 | + // empty cache & sync site |
|
103 | + $modx->clearCache('full'); |
|
104 | + |
|
105 | + $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
106 | + header($header); |
|
107 | 107 | } else { |
108 | - $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
|
108 | + $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
|
109 | 109 | } |
@@ -1,20 +1,20 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || 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('edit_document')) { |
|
5 | +if (!$modx->hasPermission('edit_document')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0; |
|
10 | -$documentID = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
9 | +$newParentID = isset($_REQUEST['new_parent']) ? (int) $_REQUEST['new_parent'] : 0; |
|
10 | +$documentID = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
11 | 11 | |
12 | 12 | // ok, two things to check. |
13 | 13 | // first, document cannot be moved to itself |
14 | 14 | // second, new parent must be a folder. If not, set it to folder. |
15 | -if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
16 | -if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
17 | -if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
15 | +if ($documentID == $newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
16 | +if ($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
17 | +if ($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
18 | 18 | |
19 | 19 | $parents = $modx->getParentIds($newParentID); |
20 | 20 | if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | if ($use_udperms == 1) { |
28 | 28 | if ($oldparent != $newParentID) { |
29 | - include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php"; |
|
29 | + include_once MODX_MANAGER_PATH."processors/user_documents_permissions.class.php"; |
|
30 | 30 | $udperms = new udperms(); |
31 | 31 | $udperms->user = $modx->getLoginUserID(); |
32 | 32 | $udperms->document = $newParentID; |
@@ -42,28 +42,28 @@ discard block |
||
42 | 42 | * @param int $currDocID |
43 | 43 | * @return array |
44 | 44 | */ |
45 | -function allChildren($currDocID) { |
|
45 | +function allChildren($currDocID){ |
|
46 | 46 | global $modx; |
47 | - $children= array(); |
|
47 | + $children = array(); |
|
48 | 48 | $currDocID = $modx->db->escape($currDocID); |
49 | 49 | $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'"); |
50 | - while ($child= $modx->db->getRow($rs)) { |
|
51 | - $children[]= $child['id']; |
|
52 | - $children= array_merge($children, allChildren($child['id'])); |
|
50 | + while ($child = $modx->db->getRow($rs)) { |
|
51 | + $children[] = $child['id']; |
|
52 | + $children = array_merge($children, allChildren($child['id'])); |
|
53 | 53 | } |
54 | 54 | return $children; |
55 | 55 | } |
56 | 56 | |
57 | -$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array ( |
|
57 | +$evtOut = $modx->invokeEvent("onBeforeMoveDocument", array( |
|
58 | 58 | "id_document" => $documentID, |
59 | 59 | "old_parent" => $oldparent, |
60 | 60 | "new_parent" => $newParentID |
61 | 61 | )); |
62 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
62 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
63 | 63 | $newParent = array_pop($evtOut); |
64 | - if($newParent == $oldparent) { |
|
64 | + if ($newParent == $oldparent) { |
|
65 | 65 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
66 | - }else{ |
|
66 | + } else { |
|
67 | 67 | $newParentID = $newParent; |
68 | 68 | } |
69 | 69 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'"); |
85 | 85 | $limit = $modx->db->getValue($rs); |
86 | 86 | |
87 | - if(!$limit>0) { |
|
87 | + if (!$limit > 0) { |
|
88 | 88 | $modx->db->update(array( |
89 | 89 | 'isfolder' => 0, |
90 | 90 | ), $modx->getFullTableName('site_content'), "id='{$oldparent}'"); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'")); |
94 | 94 | $_SESSION['itemname'] = $pagetitle; |
95 | 95 | |
96 | - $modx->invokeEvent("onAfterMoveDocument", array ( |
|
96 | + $modx->invokeEvent("onAfterMoveDocument", array( |
|
97 | 97 | "id_document" => $documentID, |
98 | 98 | "old_parent" => $oldparent, |
99 | 99 | "new_parent" => $newParentID |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | // empty cache & sync site |
103 | 103 | $modx->clearCache('full'); |
104 | 104 | |
105 | - $header="Location: index.php?a=3&id={$documentID}&r=9"; |
|
105 | + $header = "Location: index.php?a=3&id={$documentID}&r=9"; |
|
106 | 106 | header($header); |
107 | 107 | } else { |
108 | 108 | $modx->webAlertAndQuit("You cannot move a document to a child document!"); |
@@ -12,12 +12,20 @@ discard block |
||
12 | 12 | // ok, two things to check. |
13 | 13 | // first, document cannot be moved to itself |
14 | 14 | // second, new parent must be a folder. If not, set it to folder. |
15 | -if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
16 | -if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
17 | -if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
15 | +if($documentID==$newParentID) { |
|
16 | + $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
17 | +} |
|
18 | +if($documentID <= 0) { |
|
19 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
20 | +} |
|
21 | +if($newParentID < 0) { |
|
22 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
23 | +} |
|
18 | 24 | |
19 | 25 | $parents = $modx->getParentIds($newParentID); |
20 | -if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
26 | +if (in_array($documentID, $parents)) { |
|
27 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
28 | +} |
|
21 | 29 | |
22 | 30 | $rs = $modx->db->select('parent', $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
23 | 31 | $oldparent = $modx->db->getValue($rs); |
@@ -42,7 +50,8 @@ discard block |
||
42 | 50 | * @param int $currDocID |
43 | 51 | * @return array |
44 | 52 | */ |
45 | -function allChildren($currDocID) { |
|
53 | +function allChildren($currDocID) |
|
54 | +{ |
|
46 | 55 | global $modx; |
47 | 56 | $children= array(); |
48 | 57 | $currDocID = $modx->db->escape($currDocID); |
@@ -59,11 +68,11 @@ discard block |
||
59 | 68 | "old_parent" => $oldparent, |
60 | 69 | "new_parent" => $newParentID |
61 | 70 | )); |
62 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
71 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
63 | 72 | $newParent = array_pop($evtOut); |
64 | 73 | if($newParent == $oldparent) { |
65 | 74 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
66 | - }else{ |
|
75 | + } else { |
|
67 | 76 | $newParentID = $newParent; |
68 | 77 | } |
69 | 78 | } |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
3 | - die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
3 | + die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
|
4 | 4 | } |
5 | 5 | if(!$modx->hasPermission('save_web_user')) { |
6 | - $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
6 | + $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | $tbl_web_users = $modx->getFullTableName('web_users'); |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | $input = $_POST; |
14 | 14 | foreach($input as $k => $v) { |
15 | - if($k !== 'comment') { |
|
16 | - $v = sanitize($v); |
|
17 | - } |
|
18 | - $input[$k] = $v; |
|
15 | + if($k !== 'comment') { |
|
16 | + $v = sanitize($v); |
|
17 | + } |
|
18 | + $input[$k] = $v; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | $id = (int)$input['id']; |
@@ -51,80 +51,80 @@ discard block |
||
51 | 51 | |
52 | 52 | // verify password |
53 | 53 | if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) { |
54 | - webAlertAndQuit("Password typed is mismatched"); |
|
54 | + webAlertAndQuit("Password typed is mismatched"); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // verify email |
58 | 58 | if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) { |
59 | - webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
59 | + webAlertAndQuit("E-mail address doesn't seem to be valid!"); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | switch($input['mode']) { |
63 | - case '87' : // new user |
|
64 | - // check if this user name already exist |
|
65 | - $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'"); |
|
66 | - $limit = $modx->db->getValue($rs); |
|
67 | - if($limit > 0) { |
|
68 | - webAlertAndQuit("User name is already in use!"); |
|
69 | - } |
|
70 | - |
|
71 | - // check if the email address already exist |
|
72 | - $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'] = (int)$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'] = (int)$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 |
||
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 |
||
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'] = (int)$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'] = (int)$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 |
||
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,20 +318,20 @@ discard block |
||
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 | /** |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | * @return string |
342 | 342 | */ |
343 | 343 | function save_user_quoted_printable($string) { |
344 | - $crlf = "\n"; |
|
345 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
346 | - $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
347 | - $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
348 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
349 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
350 | - $string = preg_replace($f, $r, $string); |
|
351 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
344 | + $crlf = "\n"; |
|
345 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
346 | + $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
|
347 | + $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
|
348 | + $f[] = '/([\011\040])' . $crlf . '/e'; |
|
349 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
350 | + $string = preg_replace($f, $r, $string); |
|
351 | + return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -360,94 +360,94 @@ discard block |
||
360 | 360 | * @param string $ufn |
361 | 361 | */ |
362 | 362 | function sendMailMessage($email, $uid, $pwd, $ufn) { |
363 | - global $modx, $_lang, $websignupemail_message; |
|
364 | - global $emailsubject, $emailsender; |
|
365 | - global $site_name, $site_url; |
|
366 | - $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
367 | - // replace placeholders |
|
368 | - $message = str_replace("[+uid+]", $uid, $message); |
|
369 | - $message = str_replace("[+pwd+]", $pwd, $message); |
|
370 | - $message = str_replace("[+ufn+]", $ufn, $message); |
|
371 | - $message = str_replace("[+sname+]", $site_name, $message); |
|
372 | - $message = str_replace("[+saddr+]", $emailsender, $message); |
|
373 | - $message = str_replace("[+semail+]", $emailsender, $message); |
|
374 | - $message = str_replace("[+surl+]", $site_url, $message); |
|
375 | - |
|
376 | - $param = array(); |
|
377 | - $param['from'] = "{$site_name}<{$emailsender}>"; |
|
378 | - $param['subject'] = $emailsubject; |
|
379 | - $param['body'] = $message; |
|
380 | - $param['to'] = $email; |
|
381 | - $param['type'] = 'text'; |
|
382 | - $rs = $modx->sendmail($param); |
|
383 | - if(!$rs) { |
|
384 | - $modx->manager->saveFormValues(); |
|
385 | - $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
386 | - } |
|
363 | + global $modx, $_lang, $websignupemail_message; |
|
364 | + global $emailsubject, $emailsender; |
|
365 | + global $site_name, $site_url; |
|
366 | + $message = sprintf($websignupemail_message, $uid, $pwd); // use old method |
|
367 | + // replace placeholders |
|
368 | + $message = str_replace("[+uid+]", $uid, $message); |
|
369 | + $message = str_replace("[+pwd+]", $pwd, $message); |
|
370 | + $message = str_replace("[+ufn+]", $ufn, $message); |
|
371 | + $message = str_replace("[+sname+]", $site_name, $message); |
|
372 | + $message = str_replace("[+saddr+]", $emailsender, $message); |
|
373 | + $message = str_replace("[+semail+]", $emailsender, $message); |
|
374 | + $message = str_replace("[+surl+]", $site_url, $message); |
|
375 | + |
|
376 | + $param = array(); |
|
377 | + $param['from'] = "{$site_name}<{$emailsender}>"; |
|
378 | + $param['subject'] = $emailsubject; |
|
379 | + $param['body'] = $message; |
|
380 | + $param['to'] = $email; |
|
381 | + $param['type'] = 'text'; |
|
382 | + $rs = $modx->sendmail($param); |
|
383 | + if(!$rs) { |
|
384 | + $modx->manager->saveFormValues(); |
|
385 | + $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
|
386 | + } |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | // Save User Settings |
390 | 390 | function saveUserSettings($id) { |
391 | - global $modx; |
|
392 | - $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
393 | - |
|
394 | - $settings = array( |
|
395 | - "login_home", |
|
396 | - "allowed_ip", |
|
397 | - "allowed_days" |
|
398 | - ); |
|
399 | - |
|
400 | - $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
401 | - |
|
402 | - foreach($settings as $n) { |
|
403 | - $vl = $_POST[$n]; |
|
404 | - if(is_array($vl)) { |
|
405 | - $vl = implode(",", $vl); |
|
406 | - } |
|
407 | - if($vl != '') { |
|
408 | - $f = array(); |
|
409 | - $f['webuser'] = $id; |
|
410 | - $f['setting_name'] = $n; |
|
411 | - $f['setting_value'] = $vl; |
|
412 | - $f = $modx->db->escape($f); |
|
413 | - $modx->db->insert($f, $tbl_web_user_settings); |
|
414 | - } |
|
415 | - } |
|
391 | + global $modx; |
|
392 | + $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
|
393 | + |
|
394 | + $settings = array( |
|
395 | + "login_home", |
|
396 | + "allowed_ip", |
|
397 | + "allowed_days" |
|
398 | + ); |
|
399 | + |
|
400 | + $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
|
401 | + |
|
402 | + foreach($settings as $n) { |
|
403 | + $vl = $_POST[$n]; |
|
404 | + if(is_array($vl)) { |
|
405 | + $vl = implode(",", $vl); |
|
406 | + } |
|
407 | + if($vl != '') { |
|
408 | + $f = array(); |
|
409 | + $f['webuser'] = $id; |
|
410 | + $f['setting_name'] = $n; |
|
411 | + $f['setting_value'] = $vl; |
|
412 | + $f = $modx->db->escape($f); |
|
413 | + $modx->db->insert($f, $tbl_web_user_settings); |
|
414 | + } |
|
415 | + } |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | // Web alert - sends an alert to web browser |
419 | 419 | function webAlertAndQuit($msg) { |
420 | - global $id, $modx; |
|
421 | - $mode = $_POST['mode']; |
|
422 | - $modx->manager->saveFormValues($mode); |
|
423 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
420 | + global $id, $modx; |
|
421 | + $mode = $_POST['mode']; |
|
422 | + $modx->manager->saveFormValues($mode); |
|
423 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | // Generate password |
427 | 427 | function generate_password($length = 10) { |
428 | - $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
429 | - $ps_len = strlen($allowable_characters); |
|
430 | - mt_srand((double) microtime() * 1000000); |
|
431 | - $pass = ""; |
|
432 | - for($i = 0; $i < $length; $i++) { |
|
433 | - $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
434 | - } |
|
435 | - return $pass; |
|
428 | + $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
|
429 | + $ps_len = strlen($allowable_characters); |
|
430 | + mt_srand((double) microtime() * 1000000); |
|
431 | + $pass = ""; |
|
432 | + for($i = 0; $i < $length; $i++) { |
|
433 | + $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
|
434 | + } |
|
435 | + return $pass; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | function sanitize($str = '', $safecount = 0) { |
439 | - global $modx; |
|
440 | - $safecount++; |
|
441 | - if(1000 < $safecount) { |
|
442 | - exit("error too many loops '{$safecount}'"); |
|
443 | - } |
|
444 | - if(is_array($str)) { |
|
445 | - foreach($str as $i => $v) { |
|
446 | - $str[$i] = sanitize($v, $safecount); |
|
447 | - } |
|
448 | - } else { |
|
449 | - // $str = strip_tags($str); // LEAVE < and > intact |
|
450 | - $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
451 | - } |
|
452 | - return $str; |
|
439 | + global $modx; |
|
440 | + $safecount++; |
|
441 | + if(1000 < $safecount) { |
|
442 | + exit("error too many loops '{$safecount}'"); |
|
443 | + } |
|
444 | + if(is_array($str)) { |
|
445 | + foreach($str as $i => $v) { |
|
446 | + $str[$i] = sanitize($v, $safecount); |
|
447 | + } |
|
448 | + } else { |
|
449 | + // $str = strip_tags($str); // LEAVE < and > intact |
|
450 | + $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']); |
|
451 | + } |
|
452 | + return $str; |
|
453 | 453 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || 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,14 +11,14 @@ discard block |
||
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; |
19 | 19 | } |
20 | 20 | |
21 | -$id = (int)$input['id']; |
|
21 | +$id = (int) $input['id']; |
|
22 | 22 | $oldusername = $input['oldusername']; |
23 | 23 | $newusername = !empty ($input['newusername']) ? trim($input['newusername']) : "New User"; |
24 | 24 | $esc_newusername = $modx->db->escape($newusername); |
@@ -50,41 +50,41 @@ discard block |
||
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,11 +114,11 @@ discard block |
||
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 | - $f['webgroup'] = (int)$user_groups[$i]; |
|
121 | + $f['webgroup'] = (int) $user_groups[$i]; |
|
122 | 122 | $f['webuser'] = $internalKey; |
123 | 123 | $modx->db->insert($f, $tbl_web_groups); |
124 | 124 | } |
@@ -142,20 +142,20 @@ discard block |
||
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 |
||
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 |
||
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,13 +247,13 @@ discard block |
||
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 | - $field['webgroup'] = (int)$user_groups[$i]; |
|
256 | + $field['webgroup'] = (int) $user_groups[$i]; |
|
257 | 257 | $field['webuser'] = $id; |
258 | 258 | $modx->db->insert($field, $tbl_web_groups); |
259 | 259 | } |
@@ -275,7 +275,7 @@ discard block |
||
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 |
||
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 |
||
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"; |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | * @param string $string |
341 | 341 | * @return string |
342 | 342 | */ |
343 | -function save_user_quoted_printable($string) { |
|
343 | +function save_user_quoted_printable($string){ |
|
344 | 344 | $crlf = "\n"; |
345 | - $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
|
345 | + $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string).$crlf; |
|
346 | 346 | $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
347 | 347 | $r[] = "'=' . sprintf('%02X', ord('\\1'))"; |
348 | - $f[] = '/([\011\040])' . $crlf . '/e'; |
|
349 | - $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'"; |
|
348 | + $f[] = '/([\011\040])'.$crlf.'/e'; |
|
349 | + $r[] = "'=' . sprintf('%02X', ord('\\1')) . '".$crlf."'"; |
|
350 | 350 | $string = preg_replace($f, $r, $string); |
351 | - return trim(wordwrap($string, 70, ' =' . $crlf)); |
|
351 | + return trim(wordwrap($string, 70, ' ='.$crlf)); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @param string $pwd |
360 | 360 | * @param string $ufn |
361 | 361 | */ |
362 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
362 | +function sendMailMessage($email, $uid, $pwd, $ufn){ |
|
363 | 363 | global $modx, $_lang, $websignupemail_message; |
364 | 364 | global $emailsubject, $emailsender; |
365 | 365 | global $site_name, $site_url; |
@@ -380,14 +380,14 @@ discard block |
||
380 | 380 | $param['to'] = $email; |
381 | 381 | $param['type'] = 'text'; |
382 | 382 | $rs = $modx->sendmail($param); |
383 | - if(!$rs) { |
|
383 | + if (!$rs) { |
|
384 | 384 | $modx->manager->saveFormValues(); |
385 | 385 | $modx->messageQuit("{$email} - {$_lang['error_sending_email']}"); |
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
389 | 389 | // Save User Settings |
390 | -function saveUserSettings($id) { |
|
390 | +function saveUserSettings($id){ |
|
391 | 391 | global $modx; |
392 | 392 | $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
393 | 393 | |
@@ -399,12 +399,12 @@ discard block |
||
399 | 399 | |
400 | 400 | $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'"); |
401 | 401 | |
402 | - foreach($settings as $n) { |
|
402 | + foreach ($settings as $n) { |
|
403 | 403 | $vl = $_POST[$n]; |
404 | - if(is_array($vl)) { |
|
404 | + if (is_array($vl)) { |
|
405 | 405 | $vl = implode(",", $vl); |
406 | 406 | } |
407 | - if($vl != '') { |
|
407 | + if ($vl != '') { |
|
408 | 408 | $f = array(); |
409 | 409 | $f['webuser'] = $id; |
410 | 410 | $f['setting_name'] = $n; |
@@ -416,33 +416,33 @@ discard block |
||
416 | 416 | } |
417 | 417 | |
418 | 418 | // Web alert - sends an alert to web browser |
419 | -function webAlertAndQuit($msg) { |
|
419 | +function webAlertAndQuit($msg){ |
|
420 | 420 | global $id, $modx; |
421 | 421 | $mode = $_POST['mode']; |
422 | 422 | $modx->manager->saveFormValues($mode); |
423 | - $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : '')); |
|
423 | + $modx->webAlertAndQuit($msg, "index.php?a={$mode}".($mode == '88' ? "&id={$id}" : '')); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | // Generate password |
427 | -function generate_password($length = 10) { |
|
427 | +function generate_password($length = 10){ |
|
428 | 428 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
429 | 429 | $ps_len = strlen($allowable_characters); |
430 | 430 | mt_srand((double) microtime() * 1000000); |
431 | 431 | $pass = ""; |
432 | - for($i = 0; $i < $length; $i++) { |
|
432 | + for ($i = 0; $i < $length; $i++) { |
|
433 | 433 | $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)]; |
434 | 434 | } |
435 | 435 | return $pass; |
436 | 436 | } |
437 | 437 | |
438 | -function sanitize($str = '', $safecount = 0) { |
|
438 | +function sanitize($str = '', $safecount = 0){ |
|
439 | 439 | global $modx; |
440 | 440 | $safecount++; |
441 | - if(1000 < $safecount) { |
|
441 | + if (1000 < $safecount) { |
|
442 | 442 | exit("error too many loops '{$safecount}'"); |
443 | 443 | } |
444 | - if(is_array($str)) { |
|
445 | - foreach($str as $i => $v) { |
|
444 | + if (is_array($str)) { |
|
445 | + foreach ($str as $i => $v) { |
|
446 | 446 | $str[$i] = sanitize($v, $safecount); |
447 | 447 | } |
448 | 448 | } else { |
@@ -340,7 +340,8 @@ discard block |
||
340 | 340 | * @param string $string |
341 | 341 | * @return string |
342 | 342 | */ |
343 | -function save_user_quoted_printable($string) { |
|
343 | +function save_user_quoted_printable($string) |
|
344 | +{ |
|
344 | 345 | $crlf = "\n"; |
345 | 346 | $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
346 | 347 | $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
@@ -359,7 +360,8 @@ discard block |
||
359 | 360 | * @param string $pwd |
360 | 361 | * @param string $ufn |
361 | 362 | */ |
362 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
363 | +function sendMailMessage($email, $uid, $pwd, $ufn) |
|
364 | +{ |
|
363 | 365 | global $modx, $_lang, $websignupemail_message; |
364 | 366 | global $emailsubject, $emailsender; |
365 | 367 | global $site_name, $site_url; |
@@ -387,7 +389,8 @@ discard block |
||
387 | 389 | } |
388 | 390 | |
389 | 391 | // Save User Settings |
390 | -function saveUserSettings($id) { |
|
392 | +function saveUserSettings($id) |
|
393 | +{ |
|
391 | 394 | global $modx; |
392 | 395 | $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
393 | 396 | |
@@ -416,7 +419,8 @@ discard block |
||
416 | 419 | } |
417 | 420 | |
418 | 421 | // Web alert - sends an alert to web browser |
419 | -function webAlertAndQuit($msg) { |
|
422 | +function webAlertAndQuit($msg) |
|
423 | +{ |
|
420 | 424 | global $id, $modx; |
421 | 425 | $mode = $_POST['mode']; |
422 | 426 | $modx->manager->saveFormValues($mode); |
@@ -424,7 +428,8 @@ discard block |
||
424 | 428 | } |
425 | 429 | |
426 | 430 | // Generate password |
427 | -function generate_password($length = 10) { |
|
431 | +function generate_password($length = 10) |
|
432 | +{ |
|
428 | 433 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
429 | 434 | $ps_len = strlen($allowable_characters); |
430 | 435 | mt_srand((double) microtime() * 1000000); |
@@ -435,7 +440,8 @@ discard block |
||
435 | 440 | return $pass; |
436 | 441 | } |
437 | 442 | |
438 | -function sanitize($str = '', $safecount = 0) { |
|
443 | +function sanitize($str = '', $safecount = 0) |
|
444 | +{ |
|
439 | 445 | global $modx; |
440 | 446 | $safecount++; |
441 | 447 | if(1000 < $safecount) { |