@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/'); |
|
3 | +if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', MODX_MANAGER_PATH.'includes/'); |
|
4 | 4 | |
5 | -class MODIFIERS { |
|
5 | +class MODIFIERS{ |
|
6 | 6 | /** |
7 | 7 | * @var array |
8 | 8 | */ |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | * @param string $modifiers |
72 | 72 | * @return bool|mixed|string |
73 | 73 | */ |
74 | - public function phxFilter($key,$value,$modifiers) |
|
74 | + public function phxFilter($key, $value, $modifiers) |
|
75 | 75 | { |
76 | 76 | global $modx; |
77 | - if(substr($modifiers,0,3)!=='id(') $value = $this->parseDocumentSource($value); |
|
77 | + if (substr($modifiers, 0, 3) !== 'id(') $value = $this->parseDocumentSource($value); |
|
78 | 78 | $this->srcValue = $value; |
79 | 79 | $modifiers = trim($modifiers); |
80 | - $modifiers = ':'.trim($modifiers,':'); |
|
81 | - $modifiers = str_replace(array("\r\n","\r"), "\n", $modifiers); |
|
80 | + $modifiers = ':'.trim($modifiers, ':'); |
|
81 | + $modifiers = str_replace(array("\r\n", "\r"), "\n", $modifiers); |
|
82 | 82 | $modifiers = $this->splitEachModifiers($modifiers); |
83 | 83 | |
84 | 84 | $this->placeholders = array(); |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | $this->placeholders['dummy'] = ''; |
87 | 87 | $this->condition = array(); |
88 | 88 | $this->vars = array(); |
89 | - $this->vars['name'] = & $key; |
|
90 | - $value = $this->parsePhx($key,$value,$modifiers); |
|
89 | + $this->vars['name'] = & $key; |
|
90 | + $value = $this->parsePhx($key, $value, $modifiers); |
|
91 | 91 | $this->vars = array(); |
92 | 92 | return $value; |
93 | 93 | } |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | * @param string $modifiers |
98 | 98 | * @return bool|string |
99 | 99 | */ |
100 | - public function _getDelim($mode,$modifiers) { |
|
101 | - $c = substr($modifiers,0,1); |
|
102 | - if(!in_array($c, array('"', "'", '`')) ) return false; |
|
100 | + public function _getDelim($mode, $modifiers){ |
|
101 | + $c = substr($modifiers, 0, 1); |
|
102 | + if (!in_array($c, array('"', "'", '`'))) return false; |
|
103 | 103 | |
104 | - $modifiers = substr($modifiers,1); |
|
105 | - $closure = $mode=='(' ? "{$c})" : $c; |
|
106 | - if(strpos($modifiers, $closure)===false) return false; |
|
104 | + $modifiers = substr($modifiers, 1); |
|
105 | + $closure = $mode == '(' ? "{$c})" : $c; |
|
106 | + if (strpos($modifiers, $closure) === false) return false; |
|
107 | 107 | |
108 | 108 | return $c; |
109 | 109 | } |
@@ -114,101 +114,101 @@ discard block |
||
114 | 114 | * @param string $modifiers |
115 | 115 | * @return bool|string |
116 | 116 | */ |
117 | - public function _getOpt($mode,$delim,$modifiers) { |
|
118 | - if($delim) { |
|
119 | - if($mode=='(') return substr($modifiers,1,strpos($modifiers, $delim . ')' )-1); |
|
117 | + public function _getOpt($mode, $delim, $modifiers){ |
|
118 | + if ($delim) { |
|
119 | + if ($mode == '(') return substr($modifiers, 1, strpos($modifiers, $delim.')') - 1); |
|
120 | 120 | |
121 | - return substr($modifiers,1,strpos($modifiers,$delim,1)-1); |
|
121 | + return substr($modifiers, 1, strpos($modifiers, $delim, 1) - 1); |
|
122 | 122 | } |
123 | 123 | else { |
124 | - if($mode=='(') return substr($modifiers,0,strpos($modifiers, ')') ); |
|
124 | + if ($mode == '(') return substr($modifiers, 0, strpos($modifiers, ')')); |
|
125 | 125 | |
126 | 126 | $chars = str_split($modifiers); |
127 | - $opt=''; |
|
128 | - foreach($chars as $c) { |
|
129 | - if($c==':' || $c==')') break; |
|
130 | - $opt .=$c; |
|
127 | + $opt = ''; |
|
128 | + foreach ($chars as $c) { |
|
129 | + if ($c == ':' || $c == ')') break; |
|
130 | + $opt .= $c; |
|
131 | 131 | } |
132 | 132 | return $opt; |
133 | 133 | } |
134 | 134 | } |
135 | - public function _getRemainModifiers($mode,$delim,$modifiers) { |
|
136 | - if($delim) { |
|
137 | - if($mode=='(') |
|
138 | - return $this->_fetchContent($modifiers, $delim . ')'); |
|
135 | + public function _getRemainModifiers($mode, $delim, $modifiers){ |
|
136 | + if ($delim) { |
|
137 | + if ($mode == '(') |
|
138 | + return $this->_fetchContent($modifiers, $delim.')'); |
|
139 | 139 | else { |
140 | 140 | $modifiers = trim($modifiers); |
141 | - $modifiers = substr($modifiers,1); |
|
141 | + $modifiers = substr($modifiers, 1); |
|
142 | 142 | return $this->_fetchContent($modifiers, $delim); |
143 | 143 | } |
144 | 144 | } |
145 | 145 | else { |
146 | - if($mode=='(') return $this->_fetchContent($modifiers, ')'); |
|
146 | + if ($mode == '(') return $this->_fetchContent($modifiers, ')'); |
|
147 | 147 | $chars = str_split($modifiers); |
148 | - foreach($chars as $c) { |
|
149 | - if($c==':') return $modifiers; |
|
150 | - else $modifiers = substr($modifiers,1); |
|
148 | + foreach ($chars as $c) { |
|
149 | + if ($c == ':') return $modifiers; |
|
150 | + else $modifiers = substr($modifiers, 1); |
|
151 | 151 | } |
152 | 152 | return $modifiers; |
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | - public function _fetchContent($string,$delim) { |
|
156 | + public function _fetchContent($string, $delim){ |
|
157 | 157 | $len = strlen($delim); |
158 | 158 | $string = $this->parseDocumentSource($string); |
159 | - return substr($string,strpos($string, $delim)+$len); |
|
159 | + return substr($string, strpos($string, $delim) + $len); |
|
160 | 160 | } |
161 | 161 | |
162 | - public function splitEachModifiers($modifiers) { |
|
162 | + public function splitEachModifiers($modifiers){ |
|
163 | 163 | global $modx; |
164 | 164 | |
165 | 165 | $cmd = ''; |
166 | 166 | $bt = ''; |
167 | 167 | $result = array(); |
168 | - while($bt!==$modifiers) { |
|
168 | + while ($bt !== $modifiers) { |
|
169 | 169 | $bt = $modifiers; |
170 | - $c = substr($modifiers,0,1); |
|
171 | - $modifiers = substr($modifiers,1); |
|
170 | + $c = substr($modifiers, 0, 1); |
|
171 | + $modifiers = substr($modifiers, 1); |
|
172 | 172 | |
173 | - if($c===':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
174 | - $c = substr($modifiers,strlen($match[1]),1); |
|
173 | + if ($c === ':' && preg_match('@^(!?[<>=]{1,2})@', $modifiers, $match)) { // :=, :!=, :<=, :>=, :!<=, :!>= |
|
174 | + $c = substr($modifiers, strlen($match[1]), 1); |
|
175 | 175 | $debuginfo = "#i=0 #c=[{$c}] #m=[{$modifiers}]"; |
176 | - if($c==='(') $modifiers = substr($modifiers,strlen($match[1])+1); |
|
177 | - else $modifiers = substr($modifiers,strlen($match[1])); |
|
176 | + if ($c === '(') $modifiers = substr($modifiers, strlen($match[1]) + 1); |
|
177 | + else $modifiers = substr($modifiers, strlen($match[1])); |
|
178 | 178 | |
179 | - $delim = $this->_getDelim($c,$modifiers); |
|
180 | - $opt = $this->_getOpt($c,$delim,$modifiers); |
|
181 | - $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers)); |
|
179 | + $delim = $this->_getDelim($c, $modifiers); |
|
180 | + $opt = $this->_getOpt($c, $delim, $modifiers); |
|
181 | + $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers)); |
|
182 | 182 | |
183 | - $result[]=array('cmd'=>trim($match[1]),'opt'=>$opt,'debuginfo'=>$debuginfo); |
|
183 | + $result[] = array('cmd'=>trim($match[1]), 'opt'=>$opt, 'debuginfo'=>$debuginfo); |
|
184 | 184 | $cmd = ''; |
185 | 185 | } |
186 | - elseif(in_array($c,array('+','-','*','/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... |
|
187 | - $modifiers = substr($modifiers,strlen($match[0])); |
|
188 | - $result[]=array('cmd'=>'math','opt'=>'%s'.$c.$match[0]); |
|
186 | + elseif (in_array($c, array('+', '-', '*', '/')) && preg_match('@^[0-9]+@', $modifiers, $match)) { // :+3, :-3, :*3 ... |
|
187 | + $modifiers = substr($modifiers, strlen($match[0])); |
|
188 | + $result[] = array('cmd'=>'math', 'opt'=>'%s'.$c.$match[0]); |
|
189 | 189 | $cmd = ''; |
190 | 190 | } |
191 | - elseif($c==='(' || $c==='=') { |
|
191 | + elseif ($c === '(' || $c === '=') { |
|
192 | 192 | $modifiers = $m1 = trim($modifiers); |
193 | - $delim = $this->_getDelim($c,$modifiers); |
|
194 | - $opt = $this->_getOpt($c,$delim,$modifiers); |
|
195 | - $modifiers = trim($this->_getRemainModifiers($c,$delim,$modifiers)); |
|
193 | + $delim = $this->_getDelim($c, $modifiers); |
|
194 | + $opt = $this->_getOpt($c, $delim, $modifiers); |
|
195 | + $modifiers = trim($this->_getRemainModifiers($c, $delim, $modifiers)); |
|
196 | 196 | $debuginfo = "#i=1 #c=[{$c}] #delim=[{$delim}] #m1=[{$m1}] remainMdf=[{$modifiers}]"; |
197 | 197 | |
198 | - $result[]=array('cmd'=>trim($cmd),'opt'=>$opt,'debuginfo'=>$debuginfo); |
|
198 | + $result[] = array('cmd'=>trim($cmd), 'opt'=>$opt, 'debuginfo'=>$debuginfo); |
|
199 | 199 | |
200 | 200 | $cmd = ''; |
201 | 201 | } |
202 | - elseif($c==':') { |
|
202 | + elseif ($c == ':') { |
|
203 | 203 | $debuginfo = "#i=2 #c=[{$c}] #m=[{$modifiers}]"; |
204 | - if($cmd!=='') $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
204 | + if ($cmd !== '') $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo); |
|
205 | 205 | |
206 | 206 | $cmd = ''; |
207 | 207 | } |
208 | - elseif(trim($modifiers)=='' && trim($cmd)!=='') { |
|
208 | + elseif (trim($modifiers) == '' && trim($cmd) !== '') { |
|
209 | 209 | $debuginfo = "#i=3 #c=[{$c}] #m=[{$modifiers}]"; |
210 | 210 | $cmd .= $c; |
211 | - $result[]=array('cmd'=>trim($cmd),'opt'=>'','debuginfo'=>$debuginfo); |
|
211 | + $result[] = array('cmd'=>trim($cmd), 'opt'=>'', 'debuginfo'=>$debuginfo); |
|
212 | 212 | |
213 | 213 | break; |
214 | 214 | } |
@@ -217,65 +217,65 @@ discard block |
||
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | - if(empty($result)) return array(); |
|
220 | + if (empty($result)) return array(); |
|
221 | 221 | |
222 | - foreach($result as $i=>$a) |
|
222 | + foreach ($result as $i=>$a) |
|
223 | 223 | { |
224 | 224 | $a['opt'] = $this->parseDocumentSource($a['opt']); |
225 | - $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'],$this->placeholders); |
|
225 | + $result[$i]['opt'] = $modx->mergePlaceholderContent($a['opt'], $this->placeholders); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | return $result; |
229 | 229 | } |
230 | 230 | |
231 | - public function parsePhx($key,$value,$modifiers) |
|
231 | + public function parsePhx($key, $value, $modifiers) |
|
232 | 232 | { |
233 | 233 | global $modx; |
234 | 234 | $lastKey = ''; |
235 | - $cacheKey = md5(sprintf('parsePhx#%s#%s#%s',$key,$value,print_r($modifiers,true))); |
|
236 | - if(isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey]; |
|
237 | - if(empty($modifiers)) return ''; |
|
235 | + $cacheKey = md5(sprintf('parsePhx#%s#%s#%s', $key, $value, print_r($modifiers, true))); |
|
236 | + if (isset($this->tmpCache[$cacheKey])) return $this->tmpCache[$cacheKey]; |
|
237 | + if (empty($modifiers)) return ''; |
|
238 | 238 | |
239 | - foreach($modifiers as $m) |
|
239 | + foreach ($modifiers as $m) |
|
240 | 240 | { |
241 | 241 | $lastKey = strtolower($m['cmd']); |
242 | 242 | } |
243 | - $_ = explode(',',$this->condModifiers); |
|
244 | - if(in_array($lastKey,$_)) |
|
243 | + $_ = explode(',', $this->condModifiers); |
|
244 | + if (in_array($lastKey, $_)) |
|
245 | 245 | { |
246 | - $modifiers[] = array('cmd'=>'then','opt'=>'1'); |
|
247 | - $modifiers[] = array('cmd'=>'else','opt'=>'0'); |
|
246 | + $modifiers[] = array('cmd'=>'then', 'opt'=>'1'); |
|
247 | + $modifiers[] = array('cmd'=>'else', 'opt'=>'0'); |
|
248 | 248 | } |
249 | 249 | |
250 | - foreach($modifiers as $i=>$a) |
|
250 | + foreach ($modifiers as $i=>$a) |
|
251 | 251 | { |
252 | - $value = $this->Filter($key,$value, $a['cmd'], $a['opt']); |
|
252 | + $value = $this->Filter($key, $value, $a['cmd'], $a['opt']); |
|
253 | 253 | } |
254 | 254 | $this->tmpCache[$cacheKey] = $value; |
255 | 255 | return $value; |
256 | 256 | } |
257 | 257 | |
258 | 258 | // Parser: modifier detection and eXtended processing if needed |
259 | - public function Filter($key, $value, $cmd, $opt='') |
|
259 | + public function Filter($key, $value, $cmd, $opt = '') |
|
260 | 260 | { |
261 | 261 | global $modx; |
262 | 262 | |
263 | - if($key==='documentObject') $value = $modx->documentIdentifier; |
|
263 | + if ($key === 'documentObject') $value = $modx->documentIdentifier; |
|
264 | 264 | $cmd = $this->parseDocumentSource($cmd); |
265 | - if(preg_match('@^[1-9][/0-9]*$@',$cmd)) |
|
265 | + if (preg_match('@^[1-9][/0-9]*$@', $cmd)) |
|
266 | 266 | { |
267 | - if(strpos($cmd,'/')!==false) |
|
268 | - $cmd = $this->substr($cmd,strrpos($cmd,'/')+1); |
|
267 | + if (strpos($cmd, '/') !== false) |
|
268 | + $cmd = $this->substr($cmd, strrpos($cmd, '/') + 1); |
|
269 | 269 | $opt = $cmd; |
270 | 270 | $cmd = 'id'; |
271 | 271 | } |
272 | 272 | |
273 | - if(isset($modx->snippetCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
274 | - elseif(isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
273 | + if (isset($modx->snippetCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
274 | + elseif (isset($modx->chunkCache["phx:{$cmd}"])) $this->elmName = "phx:{$cmd}"; |
|
275 | 275 | else $this->elmName = ''; |
276 | 276 | |
277 | 277 | $cmd = strtolower($cmd); |
278 | - if($this->elmName!=='') |
|
278 | + if ($this->elmName !== '') |
|
279 | 279 | $value = $this->getValueFromElement($key, $value, $cmd, $opt); |
280 | 280 | else |
281 | 281 | $value = $this->getValueFromPreset($key, $value, $cmd, $opt); |
@@ -285,12 +285,12 @@ discard block |
||
285 | 285 | return $value; |
286 | 286 | } |
287 | 287 | |
288 | - public function isEmpty($cmd,$value) |
|
288 | + public function isEmpty($cmd, $value) |
|
289 | 289 | { |
290 | - if($value!=='') return false; |
|
290 | + if ($value !== '') return false; |
|
291 | 291 | |
292 | - $_ = explode(',', $this->condModifiers . ',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); |
|
293 | - if(in_array($cmd,$_)) return false; |
|
292 | + $_ = explode(',', $this->condModifiers.',_default,default,if,input,or,and,show,this,select,switch,then,else,id,ifempty,smart_desc,smart_description,summary'); |
|
293 | + if (in_array($cmd, $_)) return false; |
|
294 | 294 | else return true; |
295 | 295 | } |
296 | 296 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | { |
299 | 299 | global $modx; |
300 | 300 | |
301 | - if($this->isEmpty($cmd,$value)) return ''; |
|
301 | + if ($this->isEmpty($cmd, $value)) return ''; |
|
302 | 302 | |
303 | 303 | $this->key = $key; |
304 | 304 | $this->value = $value; |
@@ -309,83 +309,83 @@ discard block |
||
309 | 309 | ##### Conditional Modifiers |
310 | 310 | case 'input': |
311 | 311 | case 'if': |
312 | - if(!$opt) return $value; |
|
312 | + if (!$opt) return $value; |
|
313 | 313 | return $opt; |
314 | 314 | case '=': |
315 | 315 | case 'eq': |
316 | 316 | case 'is': |
317 | 317 | case 'equals': |
318 | - $this->condition[] = (int)($value == $opt); break; |
|
318 | + $this->condition[] = (int) ($value == $opt); break; |
|
319 | 319 | case 'neq': |
320 | 320 | case 'ne': |
321 | 321 | case 'notequals': |
322 | 322 | case 'isnot': |
323 | 323 | case 'isnt': |
324 | 324 | case 'not': |
325 | - $this->condition[] = (int)($value != $opt);break; |
|
325 | + $this->condition[] = (int) ($value != $opt); break; |
|
326 | 326 | case '%': |
327 | - $this->condition[] = (int)($value%$opt==0);break; |
|
327 | + $this->condition[] = (int) ($value % $opt == 0); break; |
|
328 | 328 | case 'isempty': |
329 | - $this->condition[] = (int)(empty($value)); break; |
|
329 | + $this->condition[] = (int) (empty($value)); break; |
|
330 | 330 | case 'isntempty': |
331 | 331 | case 'isnotempty': |
332 | - $this->condition[] = (int)(!empty($value)); break; |
|
332 | + $this->condition[] = (int) (!empty($value)); break; |
|
333 | 333 | case '>=': |
334 | 334 | case 'gte': |
335 | 335 | case 'eg': |
336 | 336 | case 'isgte': |
337 | - $this->condition[] = (int)($value >= $opt);break; |
|
337 | + $this->condition[] = (int) ($value >= $opt); break; |
|
338 | 338 | case '<=': |
339 | 339 | case 'lte': |
340 | 340 | case 'el': |
341 | 341 | case 'islte': |
342 | - $this->condition[] = (int)($value <= $opt);break; |
|
342 | + $this->condition[] = (int) ($value <= $opt); break; |
|
343 | 343 | case '>': |
344 | 344 | case 'gt': |
345 | 345 | case 'greaterthan': |
346 | 346 | case 'isgreaterthan': |
347 | 347 | case 'isgt': |
348 | - $this->condition[] = (int)($value > $opt);break; |
|
348 | + $this->condition[] = (int) ($value > $opt); break; |
|
349 | 349 | case '<': |
350 | 350 | case 'lt': |
351 | 351 | case 'lowerthan': |
352 | 352 | case 'islowerthan': |
353 | 353 | case 'islt': |
354 | - $this->condition[] = (int)($value < $opt);break; |
|
354 | + $this->condition[] = (int) ($value < $opt); break; |
|
355 | 355 | case 'find': |
356 | - $this->condition[] = (int)(strpos($value, $opt)!==false);break; |
|
356 | + $this->condition[] = (int) (strpos($value, $opt) !== false); break; |
|
357 | 357 | case 'inarray': |
358 | 358 | case 'in_array': |
359 | 359 | case 'in': |
360 | 360 | $opt = explode(',', $opt); |
361 | - $this->condition[] = (int)(in_array($value, $opt)!==false);break; |
|
361 | + $this->condition[] = (int) (in_array($value, $opt) !== false); break; |
|
362 | 362 | case 'wildcard_match': |
363 | 363 | case 'wcard_match': |
364 | 364 | case 'wildcard': |
365 | 365 | case 'wcard': |
366 | 366 | case 'fnmatch': |
367 | - $this->condition[] = (int)(fnmatch($opt, $value)!==false);break; |
|
367 | + $this->condition[] = (int) (fnmatch($opt, $value) !== false); break; |
|
368 | 368 | case 'is_file': |
369 | 369 | case 'is_dir': |
370 | 370 | case 'file_exists': |
371 | 371 | case 'is_readable': |
372 | 372 | case 'is_writable': |
373 | - if(!$opt) $path = $value; |
|
373 | + if (!$opt) $path = $value; |
|
374 | 374 | else $path = $opt; |
375 | - if(strpos($path,MODX_MANAGER_PATH)!==false) exit('Can not read core path'); |
|
376 | - if(strpos($path,$modx->config['base_path'])===false) $path = ltrim($path,'/'); |
|
377 | - $this->condition[] = (int)($cmd($path)!==false);break; |
|
375 | + if (strpos($path, MODX_MANAGER_PATH) !== false) exit('Can not read core path'); |
|
376 | + if (strpos($path, $modx->config['base_path']) === false) $path = ltrim($path, '/'); |
|
377 | + $this->condition[] = (int) ($cmd($path) !== false); break; |
|
378 | 378 | case 'is_image': |
379 | - if(!$opt) $path = $value; |
|
379 | + if (!$opt) $path = $value; |
|
380 | 380 | else $path = $opt; |
381 | - if(!is_file($path)) {$this->condition[]='0';break;} |
|
381 | + if (!is_file($path)) {$this->condition[] = '0'; break; } |
|
382 | 382 | $_ = getimagesize($path); |
383 | - $this->condition[] = (int)($_[0]);break; |
|
383 | + $this->condition[] = (int) ($_[0]); break; |
|
384 | 384 | case 'regex': |
385 | 385 | case 'preg': |
386 | 386 | case 'preg_match': |
387 | 387 | case 'isinrole': |
388 | - $this->condition[] = (int)(preg_match($opt,$value));break; |
|
388 | + $this->condition[] = (int) (preg_match($opt, $value)); break; |
|
389 | 389 | case 'ir': |
390 | 390 | case 'memberof': |
391 | 391 | case 'mo': |
@@ -393,50 +393,50 @@ discard block |
||
393 | 393 | $this->condition[] = $this->includeMdfFile('memberof'); |
394 | 394 | break; |
395 | 395 | case 'or': |
396 | - $this->condition[] = '||';break; |
|
396 | + $this->condition[] = '||'; break; |
|
397 | 397 | case 'and': |
398 | - $this->condition[] = '&&';break; |
|
398 | + $this->condition[] = '&&'; break; |
|
399 | 399 | case 'show': |
400 | 400 | case 'this': |
401 | - $conditional = implode(' ',$this->condition); |
|
402 | - $isvalid = (int)(eval("return ({$conditional});")); |
|
401 | + $conditional = implode(' ', $this->condition); |
|
402 | + $isvalid = (int) (eval("return ({$conditional});")); |
|
403 | 403 | if ($isvalid) return $this->srcValue; |
404 | 404 | return NULL; |
405 | 405 | case 'then': |
406 | - $conditional = implode(' ',$this->condition); |
|
407 | - $isvalid = (int)eval("return ({$conditional});"); |
|
406 | + $conditional = implode(' ', $this->condition); |
|
407 | + $isvalid = (int) eval("return ({$conditional});"); |
|
408 | 408 | if ($isvalid) return $opt; |
409 | 409 | return null; |
410 | 410 | case 'else': |
411 | - $conditional = implode(' ',$this->condition); |
|
412 | - $isvalid = (int)eval("return ({$conditional});"); |
|
411 | + $conditional = implode(' ', $this->condition); |
|
412 | + $isvalid = (int) eval("return ({$conditional});"); |
|
413 | 413 | if (!$isvalid) return $opt; |
414 | 414 | break; |
415 | 415 | case 'select': |
416 | 416 | case 'switch': |
417 | - $raw = explode('&',$opt); |
|
417 | + $raw = explode('&', $opt); |
|
418 | 418 | $map = array(); |
419 | 419 | $c = count($raw); |
420 | - for($m=0; $m<$c; $m++) { |
|
421 | - $mi = explode('=',$raw[$m],2); |
|
420 | + for ($m = 0; $m < $c; $m++) { |
|
421 | + $mi = explode('=', $raw[$m], 2); |
|
422 | 422 | $map[$mi[0]] = $mi[1]; |
423 | 423 | } |
424 | - if(isset($map[$value])) return $map[$value]; |
|
424 | + if (isset($map[$value])) return $map[$value]; |
|
425 | 425 | else return ''; |
426 | 426 | ##### End of Conditional Modifiers |
427 | 427 | |
428 | 428 | ##### Encode / Decode / Hash / Escape |
429 | 429 | case 'htmlent': |
430 | 430 | case 'htmlentities': |
431 | - return htmlentities($value,ENT_QUOTES,$modx->config['modx_charset']); |
|
431 | + return htmlentities($value, ENT_QUOTES, $modx->config['modx_charset']); |
|
432 | 432 | case 'html_entity_decode': |
433 | 433 | case 'decode_html': |
434 | 434 | case 'html_decode': |
435 | - return html_entity_decode($value,ENT_QUOTES,$modx->config['modx_charset']); |
|
435 | + return html_entity_decode($value, ENT_QUOTES, $modx->config['modx_charset']); |
|
436 | 436 | case 'esc': |
437 | 437 | case 'escape': |
438 | 438 | $value = preg_replace('/&(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset'])); |
439 | - return str_replace(array('[', ']', '`'),array('[', ']', '`'),$value); |
|
439 | + return str_replace(array('[', ']', '`'), array('[', ']', '`'), $value); |
|
440 | 440 | case 'sql_escape': |
441 | 441 | case 'encode_js': |
442 | 442 | return $modx->db->escape($value); |
@@ -446,39 +446,39 @@ discard block |
||
446 | 446 | case 'html_encode': |
447 | 447 | return preg_replace('/&(#[0-9]+|[a-z]+);/i', '&$1;', htmlspecialchars($value, ENT_QUOTES, $modx->config['modx_charset'])); |
448 | 448 | case 'spam_protect': |
449 | - return str_replace(array('@','.'),array('@','.'),$value); |
|
449 | + return str_replace(array('@', '.'), array('@', '.'), $value); |
|
450 | 450 | case 'strip': |
451 | - if($opt==='') $opt = ' '; |
|
451 | + if ($opt === '') $opt = ' '; |
|
452 | 452 | return preg_replace('/[\n\r\t\s]+/', $opt, $value); |
453 | 453 | case 'strip_linefeeds': |
454 | - return str_replace(array("\n","\r"), '', $value); |
|
454 | + return str_replace(array("\n", "\r"), '', $value); |
|
455 | 455 | case 'notags': |
456 | 456 | case 'strip_tags': |
457 | 457 | case 'remove_html': |
458 | - if($opt!=='') |
|
458 | + if ($opt !== '') |
|
459 | 459 | { |
460 | 460 | $param = array(); |
461 | - foreach(explode(',',$opt) as $v) |
|
461 | + foreach (explode(',', $opt) as $v) |
|
462 | 462 | { |
463 | - $v = trim($v,'</> '); |
|
463 | + $v = trim($v, '</> '); |
|
464 | 464 | $param[] = "<{$v}>"; |
465 | 465 | } |
466 | - $params = implode(',',$param); |
|
466 | + $params = implode(',', $param); |
|
467 | 467 | } |
468 | 468 | else $params = ''; |
469 | - if(!strpos($params,'<br>')===false) { |
|
470 | - $value = preg_replace('@(<br[ /]*>)\n@','$1',$value); |
|
471 | - $value = preg_replace('@<br[ /]*>@',"\n",$value); |
|
469 | + if (!strpos($params, '<br>') === false) { |
|
470 | + $value = preg_replace('@(<br[ /]*>)\n@', '$1', $value); |
|
471 | + $value = preg_replace('@<br[ /]*>@', "\n", $value); |
|
472 | 472 | } |
473 | - return $this->strip_tags($value,$params); |
|
473 | + return $this->strip_tags($value, $params); |
|
474 | 474 | case 'urlencode': |
475 | 475 | case 'url_encode': |
476 | 476 | case 'encode_url': |
477 | 477 | return urlencode($value); |
478 | 478 | case 'base64_decode': |
479 | - if($opt!=='false') $opt = true; |
|
479 | + if ($opt !== 'false') $opt = true; |
|
480 | 480 | else $opt = false; |
481 | - return base64_decode($value,$opt); |
|
481 | + return base64_decode($value, $opt); |
|
482 | 482 | case 'encode_sha1': $cmd = 'sha1'; |
483 | 483 | case 'addslashes': |
484 | 484 | case 'urldecode': |
@@ -502,18 +502,18 @@ discard block |
||
502 | 502 | case 'upper_case': |
503 | 503 | return $this->strtoupper($value); |
504 | 504 | case 'capitalize': |
505 | - $_ = explode(' ',$value); |
|
506 | - foreach($_ as $i=>$v) |
|
505 | + $_ = explode(' ', $value); |
|
506 | + foreach ($_ as $i=>$v) |
|
507 | 507 | { |
508 | 508 | $_[$i] = ucfirst($v); |
509 | 509 | } |
510 | - return implode(' ',$_); |
|
510 | + return implode(' ', $_); |
|
511 | 511 | case 'zenhan': |
512 | - if(empty($opt)) $opt='VKas'; |
|
513 | - return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
|
512 | + if (empty($opt)) $opt = 'VKas'; |
|
513 | + return mb_convert_kana($value, $opt, $modx->config['modx_charset']); |
|
514 | 514 | case 'hanzen': |
515 | - if(empty($opt)) $opt='VKAS'; |
|
516 | - return mb_convert_kana($value,$opt,$modx->config['modx_charset']); |
|
515 | + if (empty($opt)) $opt = 'VKAS'; |
|
516 | + return mb_convert_kana($value, $opt, $modx->config['modx_charset']); |
|
517 | 517 | case 'str_shuffle': |
518 | 518 | case 'shuffle': |
519 | 519 | return $this->str_shuffle($value); |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | return $this->strlen($value); |
528 | 528 | case 'count_words': |
529 | 529 | $value = trim($value); |
530 | - return count(preg_split('/\s+/',$value)); |
|
530 | + return count(preg_split('/\s+/', $value)); |
|
531 | 531 | case 'str_word_count': |
532 | 532 | case 'word_count': |
533 | 533 | case 'wordcount': |
@@ -535,55 +535,55 @@ discard block |
||
535 | 535 | case 'count_paragraphs': |
536 | 536 | $value = trim($value); |
537 | 537 | $value = preg_replace('/\r/', '', $value); |
538 | - return count(preg_split('/\n+/',$value)); |
|
538 | + return count(preg_split('/\n+/', $value)); |
|
539 | 539 | case 'strpos': |
540 | - if($opt!=0&&empty($opt)) return $value; |
|
541 | - return $this->strpos($value,$opt); |
|
540 | + if ($opt != 0 && empty($opt)) return $value; |
|
541 | + return $this->strpos($value, $opt); |
|
542 | 542 | case 'wordwrap': |
543 | 543 | // default: 70 |
544 | - $wrapat = (int)$opt > 0 ? (int)$opt : 70; |
|
544 | + $wrapat = (int) $opt > 0 ? (int) $opt : 70; |
|
545 | 545 | if (version_compare(PHP_VERSION, '5.3.0') >= 0) return $this->includeMdfFile('wordwrap'); |
546 | - else return preg_replace("@(\b\w+\b)@e","wordwrap('\\1',\$wrapat,' ',1)",$value); |
|
546 | + else return preg_replace("@(\b\w+\b)@e", "wordwrap('\\1',\$wrapat,' ',1)", $value); |
|
547 | 547 | case 'wrap_text': |
548 | - $width = preg_match('/^[1-9][0-9]*$/',$opt) ? $opt : 70; |
|
549 | - if($modx->config['manager_language']==='japanese-utf8') { |
|
548 | + $width = preg_match('/^[1-9][0-9]*$/', $opt) ? $opt : 70; |
|
549 | + if ($modx->config['manager_language'] === 'japanese-utf8') { |
|
550 | 550 | $chunk = array(); |
551 | - $bt=''; |
|
552 | - while($bt!=$value) { |
|
551 | + $bt = ''; |
|
552 | + while ($bt != $value) { |
|
553 | 553 | $bt = $value; |
554 | - if($this->strlen($value)<$width) { |
|
554 | + if ($this->strlen($value) < $width) { |
|
555 | 555 | $chunk[] = $value; |
556 | 556 | break; |
557 | 557 | } |
558 | - $chunk[] = $this->substr($value,0,$width); |
|
559 | - $value = $this->substr($value,$width); |
|
558 | + $chunk[] = $this->substr($value, 0, $width); |
|
559 | + $value = $this->substr($value, $width); |
|
560 | 560 | } |
561 | - return implode("\n",$chunk); |
|
561 | + return implode("\n", $chunk); |
|
562 | 562 | } |
563 | 563 | else |
564 | - return wordwrap($value,$width,"\n",true); |
|
564 | + return wordwrap($value, $width, "\n", true); |
|
565 | 565 | case 'substr': |
566 | - if(empty($opt)) break; |
|
567 | - if(strpos($opt,',')!==false) { |
|
568 | - list($b,$e) = explode(',',$opt,2); |
|
569 | - return $this->substr($value,$b,(int)$e); |
|
566 | + if (empty($opt)) break; |
|
567 | + if (strpos($opt, ',') !== false) { |
|
568 | + list($b, $e) = explode(',', $opt, 2); |
|
569 | + return $this->substr($value, $b, (int) $e); |
|
570 | 570 | } |
571 | - else return $this->substr($value,$opt); |
|
571 | + else return $this->substr($value, $opt); |
|
572 | 572 | case 'limit': |
573 | 573 | case 'trim_to': // http://www.movabletype.jp/documentation/appendices/modifiers/trim_to.html |
574 | - if(strpos($opt,'+')!==false) |
|
575 | - list($len,$str) = explode('+',$opt,2); |
|
574 | + if (strpos($opt, '+') !== false) |
|
575 | + list($len, $str) = explode('+', $opt, 2); |
|
576 | 576 | else { |
577 | 577 | $len = $opt; |
578 | 578 | $str = ''; |
579 | 579 | } |
580 | - if($len==='') $len = 100; |
|
581 | - if(abs($len) > $this->strlen($value)) $str =''; |
|
582 | - if(preg_match('/^[1-9][0-9]*$/',$len)) { |
|
583 | - return $this->substr($value,0,$len) . $str; |
|
580 | + if ($len === '') $len = 100; |
|
581 | + if (abs($len) > $this->strlen($value)) $str = ''; |
|
582 | + if (preg_match('/^[1-9][0-9]*$/', $len)) { |
|
583 | + return $this->substr($value, 0, $len).$str; |
|
584 | 584 | } |
585 | - elseif(preg_match('/^\-[1-9][0-9]*$/',$len)) { |
|
586 | - return $str . $this->substr($value,$len); |
|
585 | + elseif (preg_match('/^\-[1-9][0-9]*$/', $len)) { |
|
586 | + return $str.$this->substr($value, $len); |
|
587 | 587 | } |
588 | 588 | break; |
589 | 589 | case 'summary': |
@@ -592,81 +592,81 @@ discard block |
||
592 | 592 | return $this->includeMdfFile('summary'); |
593 | 593 | case 'replace': |
594 | 594 | case 'str_replace': |
595 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
596 | - if (substr_count($opt, ',') ==1) $delim = ','; |
|
597 | - elseif(substr_count($opt, '|') ==1) $delim = '|'; |
|
598 | - elseif(substr_count($opt, '=>')==1) $delim = '=>'; |
|
599 | - elseif(substr_count($opt, '/') ==1) $delim = '/'; |
|
595 | + if (empty($opt) || strpos($opt, ',') === false) break; |
|
596 | + if (substr_count($opt, ',') == 1) $delim = ','; |
|
597 | + elseif (substr_count($opt, '|') == 1) $delim = '|'; |
|
598 | + elseif (substr_count($opt, '=>') == 1) $delim = '=>'; |
|
599 | + elseif (substr_count($opt, '/') == 1) $delim = '/'; |
|
600 | 600 | else break; |
601 | - list($s,$r) = explode($delim,$opt); |
|
602 | - if($value!=='') return str_replace($s,$r,$value); |
|
601 | + list($s, $r) = explode($delim, $opt); |
|
602 | + if ($value !== '') return str_replace($s, $r, $value); |
|
603 | 603 | break; |
604 | 604 | case 'replace_to': |
605 | 605 | case 'tpl': |
606 | - if($value!=='') return str_replace(array('[+value+]','[+output+]','{value}','%s'),$value,$opt); |
|
606 | + if ($value !== '') return str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $value, $opt); |
|
607 | 607 | break; |
608 | 608 | case 'eachtpl': |
609 | - $value = explode('||',$value); |
|
609 | + $value = explode('||', $value); |
|
610 | 610 | $_ = array(); |
611 | - foreach($value as $v) { |
|
612 | - $_[] = str_replace(array('[+value+]','[+output+]','{value}','%s'),$v,$opt); |
|
611 | + foreach ($value as $v) { |
|
612 | + $_[] = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), $v, $opt); |
|
613 | 613 | } |
614 | 614 | return implode("\n", $_); |
615 | 615 | case 'array_pop': |
616 | 616 | case 'array_shift': |
617 | - if(strpos($value,'||')!==false) $delim = '||'; |
|
617 | + if (strpos($value, '||') !== false) $delim = '||'; |
|
618 | 618 | else $delim = ','; |
619 | - return $cmd(explode($delim,$value)); |
|
619 | + return $cmd(explode($delim, $value)); |
|
620 | 620 | case 'preg_replace': |
621 | 621 | case 'regex_replace': |
622 | - if(empty($opt) || strpos($opt,',')===false) break; |
|
623 | - list($s,$r) = explode(',',$opt,2); |
|
624 | - if($value!=='') return preg_replace($s,$r,$value); |
|
622 | + if (empty($opt) || strpos($opt, ',') === false) break; |
|
623 | + list($s, $r) = explode(',', $opt, 2); |
|
624 | + if ($value !== '') return preg_replace($s, $r, $value); |
|
625 | 625 | break; |
626 | 626 | case 'cat': |
627 | 627 | case 'concatenate': |
628 | 628 | case '.': |
629 | - if($value!=='') return $value . $opt; |
|
629 | + if ($value !== '') return $value.$opt; |
|
630 | 630 | break; |
631 | 631 | case 'sprintf': |
632 | 632 | case 'string_format': |
633 | - if($value!=='') return sprintf($opt,$value); |
|
633 | + if ($value !== '') return sprintf($opt, $value); |
|
634 | 634 | break; |
635 | 635 | case 'number_format': |
636 | - if($opt=='') $opt = 0; |
|
637 | - return number_format($value,$opt); |
|
636 | + if ($opt == '') $opt = 0; |
|
637 | + return number_format($value, $opt); |
|
638 | 638 | case 'money_format': |
639 | - setlocale(LC_MONETARY,setlocale(LC_TIME,0)); |
|
640 | - if($value!=='') return money_format($opt,(double)$value); |
|
639 | + setlocale(LC_MONETARY, setlocale(LC_TIME, 0)); |
|
640 | + if ($value !== '') return money_format($opt, (double) $value); |
|
641 | 641 | break; |
642 | 642 | case 'tobool': |
643 | 643 | return boolval($value); |
644 | 644 | case 'nl2lf': |
645 | - if($value!=='') return str_replace(array("\r\n","\n", "\r"), '\n', $value); |
|
645 | + if ($value !== '') return str_replace(array("\r\n", "\n", "\r"), '\n', $value); |
|
646 | 646 | break; |
647 | 647 | case 'br2nl': |
648 | 648 | return preg_replace('@<br[\s/]*>@i', "\n", $value); |
649 | 649 | case 'nl2br': |
650 | 650 | if (version_compare(PHP_VERSION, '5.3.0', '<')) |
651 | 651 | return nl2br($value); |
652 | - if($opt!=='') |
|
652 | + if ($opt !== '') |
|
653 | 653 | { |
654 | 654 | $opt = trim($opt); |
655 | 655 | $opt = strtolower($opt); |
656 | - if($opt==='false') $opt = false; |
|
657 | - elseif($opt==='0') $opt = false; |
|
656 | + if ($opt === 'false') $opt = false; |
|
657 | + elseif ($opt === '0') $opt = false; |
|
658 | 658 | else $opt = true; |
659 | 659 | } |
660 | - elseif(isset($modx->config['mce_element_format'])&&$modx->config['mce_element_format']==='html') |
|
660 | + elseif (isset($modx->config['mce_element_format']) && $modx->config['mce_element_format'] === 'html') |
|
661 | 661 | $opt = false; |
662 | 662 | else $opt = true; |
663 | - return nl2br($value,$opt); |
|
663 | + return nl2br($value, $opt); |
|
664 | 664 | case 'ltrim': |
665 | 665 | case 'rtrim': |
666 | 666 | case 'trim': // ref http://mblo.info/modifiers/custom-modifiers/rtrim_opt.html |
667 | - if($opt==='') |
|
667 | + if ($opt === '') |
|
668 | 668 | return $cmd($value); |
669 | - else return $cmd($value,$opt); |
|
669 | + else return $cmd($value, $opt); |
|
670 | 670 | // These are all straight wrappers for PHP functions |
671 | 671 | case 'ucfirst': |
672 | 672 | case 'lcfirst': |
@@ -677,58 +677,58 @@ discard block |
||
677 | 677 | case 'strftime': |
678 | 678 | case 'date': |
679 | 679 | case 'dateformat': |
680 | - if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly'); |
|
681 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
682 | - if(strpos($opt,'%')!==false) |
|
683 | - return strftime($opt,0+$value); |
|
680 | + if (empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly'); |
|
681 | + if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value); |
|
682 | + if (strpos($opt, '%') !== false) |
|
683 | + return strftime($opt, 0 + $value); |
|
684 | 684 | else |
685 | - return date($opt,0+$value); |
|
685 | + return date($opt, 0 + $value); |
|
686 | 686 | case 'time': |
687 | - if(empty($opt)) $opt = '%H:%M'; |
|
688 | - if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); |
|
689 | - return strftime($opt,0+$value); |
|
687 | + if (empty($opt)) $opt = '%H:%M'; |
|
688 | + if (!preg_match('@^[0-9]+$@', $value)) $value = strtotime($value); |
|
689 | + return strftime($opt, 0 + $value); |
|
690 | 690 | case 'strtotime': |
691 | 691 | return strtotime($value); |
692 | 692 | ##### mathematical function |
693 | 693 | case 'toint': |
694 | - return (int)$value; |
|
694 | + return (int) $value; |
|
695 | 695 | case 'tofloat': |
696 | 696 | return floatval($value); |
697 | 697 | case 'round': |
698 | - if(!$opt) $opt = 0; |
|
699 | - return $cmd($value,$opt); |
|
698 | + if (!$opt) $opt = 0; |
|
699 | + return $cmd($value, $opt); |
|
700 | 700 | case 'max': |
701 | 701 | case 'min': |
702 | - return $cmd(explode(',',$value)); |
|
702 | + return $cmd(explode(',', $value)); |
|
703 | 703 | case 'floor': |
704 | 704 | case 'ceil': |
705 | 705 | case 'abs': |
706 | 706 | return $cmd($value); |
707 | 707 | case 'math': |
708 | 708 | case 'calc': |
709 | - $value = (int)$value; |
|
710 | - if(empty($value)) $value = '0'; |
|
711 | - $filter = str_replace(array('[+value+]','[+output+]','{value}','%s'),'?',$opt); |
|
712 | - $filter = preg_replace('@([a-zA-Z\n\r\t\s])@','',$filter); |
|
713 | - if(strpos($filter,'?')===false) $filter = "?{$filter}"; |
|
714 | - $filter = str_replace('?',$value,$filter); |
|
709 | + $value = (int) $value; |
|
710 | + if (empty($value)) $value = '0'; |
|
711 | + $filter = str_replace(array('[+value+]', '[+output+]', '{value}', '%s'), '?', $opt); |
|
712 | + $filter = preg_replace('@([a-zA-Z\n\r\t\s])@', '', $filter); |
|
713 | + if (strpos($filter, '?') === false) $filter = "?{$filter}"; |
|
714 | + $filter = str_replace('?', $value, $filter); |
|
715 | 715 | return eval("return {$filter};"); |
716 | 716 | case 'count': |
717 | - if($value=='') return 0; |
|
718 | - $value = explode(',',$value); |
|
717 | + if ($value == '') return 0; |
|
718 | + $value = explode(',', $value); |
|
719 | 719 | return count($value); |
720 | 720 | case 'sort': |
721 | 721 | case 'rsort': |
722 | - if(strpos($value,"\n")!==false) $delim="\n"; |
|
722 | + if (strpos($value, "\n") !== false) $delim = "\n"; |
|
723 | 723 | else $delim = ','; |
724 | - $swap = explode($delim,$value); |
|
725 | - if(!$opt) $opt = SORT_REGULAR; |
|
724 | + $swap = explode($delim, $value); |
|
725 | + if (!$opt) $opt = SORT_REGULAR; |
|
726 | 726 | else $opt = constant($opt); |
727 | - $cmd($swap,$opt); |
|
728 | - return implode($delim,$swap); |
|
727 | + $cmd($swap, $opt); |
|
728 | + return implode($delim, $swap); |
|
729 | 729 | ##### Resource fields |
730 | 730 | case 'id': |
731 | - if($opt) return $this->getDocumentObject($opt,$key); |
|
731 | + if ($opt) return $this->getDocumentObject($opt, $key); |
|
732 | 732 | break; |
733 | 733 | case 'type': |
734 | 734 | case 'contenttype': |
@@ -765,36 +765,36 @@ discard block |
||
765 | 765 | case 'privatemgr': |
766 | 766 | case 'content_dispo': |
767 | 767 | case 'hidemenu': |
768 | - if($cmd==='contenttype') $cmd = 'contentType'; |
|
769 | - return $this->getDocumentObject($value,$cmd); |
|
768 | + if ($cmd === 'contenttype') $cmd = 'contentType'; |
|
769 | + return $this->getDocumentObject($value, $cmd); |
|
770 | 770 | case 'title': |
771 | - $pagetitle = $this->getDocumentObject($value,'pagetitle'); |
|
772 | - $longtitle = $this->getDocumentObject($value,'longtitle'); |
|
771 | + $pagetitle = $this->getDocumentObject($value, 'pagetitle'); |
|
772 | + $longtitle = $this->getDocumentObject($value, 'longtitle'); |
|
773 | 773 | return $longtitle ? $longtitle : $pagetitle; |
774 | 774 | case 'shorttitle': |
775 | - $pagetitle = $this->getDocumentObject($value,'pagetitle'); |
|
776 | - $menutitle = $this->getDocumentObject($value,'menutitle'); |
|
775 | + $pagetitle = $this->getDocumentObject($value, 'pagetitle'); |
|
776 | + $menutitle = $this->getDocumentObject($value, 'menutitle'); |
|
777 | 777 | return $menutitle ? $menutitle : $pagetitle; |
778 | 778 | case 'templatename': |
779 | - $rs = $modx->db->select('templatename','[+prefix+]site_templates',"id='{$value}'"); |
|
779 | + $rs = $modx->db->select('templatename', '[+prefix+]site_templates', "id='{$value}'"); |
|
780 | 780 | $templateName = $modx->db->getValue($rs); |
781 | 781 | return !$templateName ? '(blank)' : $templateName; |
782 | 782 | case 'getfield': |
783 | - if(!$opt) $opt = 'content'; |
|
784 | - return $modx->getField($opt,$value); |
|
783 | + if (!$opt) $opt = 'content'; |
|
784 | + return $modx->getField($opt, $value); |
|
785 | 785 | case 'children': |
786 | 786 | case 'childids': |
787 | - if($value=='') $value = 0; // 値がない場合はルートと見なす |
|
787 | + if ($value == '') $value = 0; // 値がない場合はルートと見なす |
|
788 | 788 | $published = 1; |
789 | - if($opt=='') $opt = 'page'; |
|
790 | - $_ = explode(',',$opt); |
|
789 | + if ($opt == '') $opt = 'page'; |
|
790 | + $_ = explode(',', $opt); |
|
791 | 791 | $where = array(); |
792 | - foreach($_ as $opt) { |
|
793 | - switch(trim($opt)) { |
|
792 | + foreach ($_ as $opt) { |
|
793 | + switch (trim($opt)) { |
|
794 | 794 | case 'page'; case '!folder'; case '!isfolder': $where[] = 'sc.isfolder=0'; break; |
795 | 795 | case 'folder'; case 'isfolder': $where[] = 'sc.isfolder=1'; break; |
796 | - case 'menu'; case 'show_menu': $where[] = 'sc.hidemenu=0'; break; |
|
797 | - case '!menu'; case '!show_menu': $where[] = 'sc.hidemenu=1'; break; |
|
796 | + case 'menu'; case 'show_menu': $where[] = 'sc.hidemenu=0'; break; |
|
797 | + case '!menu'; case '!show_menu': $where[] = 'sc.hidemenu=1'; break; |
|
798 | 798 | case 'published': $published = 1; break; |
799 | 799 | case '!published': $published = 0; break; |
800 | 800 | } |
@@ -802,69 +802,69 @@ discard block |
||
802 | 802 | $where = implode(' AND ', $where); |
803 | 803 | $children = $modx->getDocumentChildren($value, $published, '0', 'id', $where); |
804 | 804 | $result = array(); |
805 | - foreach((array)$children as $child){ |
|
805 | + foreach ((array) $children as $child) { |
|
806 | 806 | $result[] = $child['id']; |
807 | 807 | } |
808 | 808 | return implode(',', $result); |
809 | 809 | case 'fullurl': |
810 | - if(!is_numeric($value)) return $value; |
|
810 | + if (!is_numeric($value)) return $value; |
|
811 | 811 | return $modx->makeUrl($value); |
812 | 812 | case 'makeurl': |
813 | - if(!is_numeric($value)) return $value; |
|
814 | - if(!$opt) $opt = 'full'; |
|
815 | - return $modx->makeUrl($value,'','',$opt); |
|
813 | + if (!is_numeric($value)) return $value; |
|
814 | + if (!$opt) $opt = 'full'; |
|
815 | + return $modx->makeUrl($value, '', '', $opt); |
|
816 | 816 | |
817 | 817 | ##### File system |
818 | 818 | case 'getimageinfo': |
819 | 819 | case 'imageinfo': |
820 | - if(!is_file($value)) return ''; |
|
820 | + if (!is_file($value)) return ''; |
|
821 | 821 | $_ = getimagesize($value); |
822 | - if(!$_[0]) return ''; |
|
822 | + if (!$_[0]) return ''; |
|
823 | 823 | $info['width'] = $_[0]; |
824 | 824 | $info['height'] = $_[1]; |
825 | - if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; |
|
826 | - elseif($_[0] < $_[1]) $info['aspect'] = 'portrait'; |
|
825 | + if ($_[0] > $_[1]) $info['aspect'] = 'landscape'; |
|
826 | + elseif ($_[0] < $_[1]) $info['aspect'] = 'portrait'; |
|
827 | 827 | else $info['aspect'] = 'square'; |
828 | - switch($_[2]) { |
|
828 | + switch ($_[2]) { |
|
829 | 829 | case IMAGETYPE_GIF : $info['type'] = 'gif'; break; |
830 | 830 | case IMAGETYPE_JPEG : $info['type'] = 'jpg'; break; |
831 | 831 | case IMAGETYPE_PNG : $info['type'] = 'png'; break; |
832 | 832 | default : $info['type'] = 'unknown'; |
833 | 833 | } |
834 | 834 | $info['attrib'] = $_[3]; |
835 | - switch($opt) { |
|
835 | + switch ($opt) { |
|
836 | 836 | case 'width' : return $info['width']; |
837 | 837 | case 'height': return $info['height']; |
838 | 838 | case 'aspect': return $info['aspect']; |
839 | 839 | case 'type' : return $info['type']; |
840 | 840 | case 'attrib': return $info['attrib']; |
841 | - default : return print_r($info,true); |
|
841 | + default : return print_r($info, true); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | case 'file_get_contents': |
845 | 845 | case 'readfile': |
846 | - if(!is_file($value)) return $value; |
|
846 | + if (!is_file($value)) return $value; |
|
847 | 847 | $value = realpath($value); |
848 | - if(strpos($value,MODX_MANAGER_PATH)!==false) exit('Can not read core file'); |
|
849 | - $ext = strtolower(substr($value,-4)); |
|
850 | - if($ext==='.php') exit('Can not read php file'); |
|
851 | - if($ext==='.cgi') exit('Can not read cgi file'); |
|
848 | + if (strpos($value, MODX_MANAGER_PATH) !== false) exit('Can not read core file'); |
|
849 | + $ext = strtolower(substr($value, -4)); |
|
850 | + if ($ext === '.php') exit('Can not read php file'); |
|
851 | + if ($ext === '.cgi') exit('Can not read cgi file'); |
|
852 | 852 | return file_get_contents($value); |
853 | 853 | case 'filesize': |
854 | - if($value == '') return ''; |
|
854 | + if ($value == '') return ''; |
|
855 | 855 | $filename = $value; |
856 | 856 | |
857 | 857 | $site_url = $modx->config['site_url']; |
858 | - if(strpos($filename,$site_url) === 0) |
|
859 | - $filename = substr($filename,0,strlen($site_url)); |
|
860 | - $filename = trim($filename,'/'); |
|
858 | + if (strpos($filename, $site_url) === 0) |
|
859 | + $filename = substr($filename, 0, strlen($site_url)); |
|
860 | + $filename = trim($filename, '/'); |
|
861 | 861 | |
862 | - $opt = trim($opt,'/'); |
|
863 | - if($opt!=='') $opt .= '/'; |
|
862 | + $opt = trim($opt, '/'); |
|
863 | + if ($opt !== '') $opt .= '/'; |
|
864 | 864 | |
865 | 865 | $filename = MODX_BASE_PATH.$opt.$filename; |
866 | 866 | |
867 | - if(is_file($filename)){ |
|
867 | + if (is_file($filename)) { |
|
868 | 868 | clearstatcache(); |
869 | 869 | $size = filesize($filename); |
870 | 870 | return $size; |
@@ -897,10 +897,10 @@ discard block |
||
897 | 897 | $this->opt = $cmd; |
898 | 898 | return $this->includeMdfFile('moduser'); |
899 | 899 | case 'userinfo': |
900 | - if(empty($opt)) $this->opt = 'username'; |
|
900 | + if (empty($opt)) $this->opt = 'username'; |
|
901 | 901 | return $this->includeMdfFile('moduser'); |
902 | 902 | case 'webuserinfo': |
903 | - if(empty($opt)) $this->opt = 'username'; |
|
903 | + if (empty($opt)) $this->opt = 'username'; |
|
904 | 904 | $this->value = -$value; |
905 | 905 | return $this->includeMdfFile('moduser'); |
906 | 906 | ##### Special functions |
@@ -911,27 +911,27 @@ discard block |
||
911 | 911 | case 'ifnotempty': |
912 | 912 | if (!empty($value)) return $opt; break; |
913 | 913 | case 'datagrid': |
914 | - include_once(MODX_CORE_PATH . 'controls/datagrid.class.php'); |
|
914 | + include_once(MODX_CORE_PATH.'controls/datagrid.class.php'); |
|
915 | 915 | $grd = new DataGrid(null, trim($value)); |
916 | 916 | $grd->itemStyle = ''; |
917 | 917 | $grd->altItemStyle = ''; |
918 | - $pos = strpos($value,"\n"); |
|
919 | - if($pos) $_ = substr($value,0,$pos); |
|
918 | + $pos = strpos($value, "\n"); |
|
919 | + if ($pos) $_ = substr($value, 0, $pos); |
|
920 | 920 | else $_ = $pos; |
921 | - $grd->cdelim = strpos($_,"\t")!==false ? 'tab' : ','; |
|
921 | + $grd->cdelim = strpos($_, "\t") !== false ? 'tab' : ','; |
|
922 | 922 | return $grd->render(); |
923 | 923 | case 'rotate': |
924 | 924 | case 'evenodd': |
925 | - if(strpos($opt,',')===false) $opt = 'odd,even'; |
|
925 | + if (strpos($opt, ',') === false) $opt = 'odd,even'; |
|
926 | 926 | $_ = explode(',', $opt); |
927 | 927 | $c = count($_); |
928 | 928 | $i = $value + $c; |
929 | 929 | $i = $i % $c; |
930 | 930 | return $_[$i]; |
931 | 931 | case 'takeval': |
932 | - $arr = explode(",",$opt); |
|
932 | + $arr = explode(",", $opt); |
|
933 | 933 | $idx = $value; |
934 | - if(!is_numeric($idx)) return $value; |
|
934 | + if (!is_numeric($idx)) return $value; |
|
935 | 935 | return $arr[$idx]; |
936 | 936 | case 'getimage': |
937 | 937 | return $this->includeMdfFile('getimage'); |
@@ -939,17 +939,17 @@ discard block |
||
939 | 939 | return $modx->nicesize($value); |
940 | 940 | case 'googlemap': |
941 | 941 | case 'googlemaps': |
942 | - if(empty($opt)) $opt = 'border:none;width:500px;height:350px;'; |
|
942 | + if (empty($opt)) $opt = 'border:none;width:500px;height:350px;'; |
|
943 | 943 | $tpl = '<iframe style="[+style+]" src="https://maps.google.co.jp/maps?ll=[+value+]&output=embed&z=15"></iframe>'; |
944 | 944 | $ph['style'] = $opt; |
945 | 945 | $ph['value'] = $value; |
946 | - return $modx->parseText($tpl,$ph); |
|
946 | + return $modx->parseText($tpl, $ph); |
|
947 | 947 | case 'youtube': |
948 | 948 | case 'youtube16x9': |
949 | - if(empty($opt)) $opt = 560; |
|
950 | - $h = round($opt*0.5625); |
|
949 | + if (empty($opt)) $opt = 560; |
|
950 | + $h = round($opt * 0.5625); |
|
951 | 951 | $tpl = '<iframe width="%s" height="%s" src="https://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>'; |
952 | - return sprintf($tpl,$opt,$h,$value); |
|
952 | + return sprintf($tpl, $opt, $h, $value); |
|
953 | 953 | //case 'youtube4x3':%s*0.75+25 |
954 | 954 | case 'setvar': |
955 | 955 | $modx->placeholders[$opt] = $value; |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | return $value; |
980 | 980 | } |
981 | 981 | |
982 | - public function includeMdfFile($cmd) { |
|
982 | + public function includeMdfFile($cmd){ |
|
983 | 983 | global $modx; |
984 | 984 | $key = $this->key; |
985 | 985 | $value = $this->value; |
@@ -990,54 +990,54 @@ discard block |
||
990 | 990 | public function getValueFromElement($key, $value, $cmd, $opt) |
991 | 991 | { |
992 | 992 | global $modx; |
993 | - if( isset($modx->snippetCache[$this->elmName]) ) |
|
993 | + if (isset($modx->snippetCache[$this->elmName])) |
|
994 | 994 | { |
995 | 995 | $php = $modx->snippetCache[$this->elmName]; |
996 | 996 | } |
997 | 997 | else |
998 | 998 | { |
999 | 999 | $esc_elmName = $modx->db->escape($this->elmName); |
1000 | - $result = $modx->db->select('snippet','[+prefix+]site_snippets',"name='{$esc_elmName}'"); |
|
1000 | + $result = $modx->db->select('snippet', '[+prefix+]site_snippets', "name='{$esc_elmName}'"); |
|
1001 | 1001 | $total = $modx->db->getRecordCount($result); |
1002 | - if($total == 1) |
|
1002 | + if ($total == 1) |
|
1003 | 1003 | { |
1004 | 1004 | $row = $modx->db->getRow($result); |
1005 | 1005 | $php = $row['snippet']; |
1006 | 1006 | } |
1007 | - elseif($total == 0) |
|
1007 | + elseif ($total == 0) |
|
1008 | 1008 | { |
1009 | 1009 | $assets_path = MODX_BASE_PATH.'assets/'; |
1010 | - if(is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) |
|
1010 | + if (is_file($assets_path."modifiers/mdf_{$cmd}.inc.php")) |
|
1011 | 1011 | $modifiers_path = $assets_path."modifiers/mdf_{$cmd}.inc.php"; |
1012 | - elseif(is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) |
|
1012 | + elseif (is_file($assets_path."plugins/phx/modifiers/{$cmd}.phx.php")) |
|
1013 | 1013 | $modifiers_path = $assets_path."plugins/phx/modifiers/{$cmd}.phx.php"; |
1014 | - elseif(is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) |
|
1014 | + elseif (is_file(MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php")) |
|
1015 | 1015 | $modifiers_path = MODX_CORE_PATH."extenders/modifiers/mdf_{$cmd}.inc.php"; |
1016 | 1016 | else $modifiers_path = false; |
1017 | 1017 | |
1018 | - if($modifiers_path !== false) { |
|
1018 | + if ($modifiers_path !== false) { |
|
1019 | 1019 | $php = @file_get_contents($modifiers_path); |
1020 | 1020 | $php = trim($php); |
1021 | - if(substr($php,0,5)==='<?php') $php = substr($php,6); |
|
1022 | - if(substr($php,0,2)==='<?') $php = substr($php,3); |
|
1023 | - if(substr($php,-2)==='?>') $php = substr($php,0,-2); |
|
1024 | - if($this->elmName!=='') |
|
1021 | + if (substr($php, 0, 5) === '<?php') $php = substr($php, 6); |
|
1022 | + if (substr($php, 0, 2) === '<?') $php = substr($php, 3); |
|
1023 | + if (substr($php, -2) === '?>') $php = substr($php, 0, -2); |
|
1024 | + if ($this->elmName !== '') |
|
1025 | 1025 | $modx->snippetCache[$this->elmName.'Props'] = ''; |
1026 | 1026 | } |
1027 | 1027 | else |
1028 | 1028 | $php = false; |
1029 | 1029 | } |
1030 | 1030 | else $php = false; |
1031 | - if($this->elmName!=='') $modx->snippetCache[$this->elmName]= $php; |
|
1031 | + if ($this->elmName !== '') $modx->snippetCache[$this->elmName] = $php; |
|
1032 | 1032 | } |
1033 | - if($php==='') $php=false; |
|
1033 | + if ($php === '') $php = false; |
|
1034 | 1034 | |
1035 | - if($php===false) $html = $modx->getChunk($this->elmName); |
|
1035 | + if ($php === false) $html = $modx->getChunk($this->elmName); |
|
1036 | 1036 | else $html = false; |
1037 | 1037 | |
1038 | 1038 | $self = '[+output+]'; |
1039 | 1039 | |
1040 | - if($php !== false) |
|
1040 | + if ($php !== false) |
|
1041 | 1041 | { |
1042 | 1042 | ob_start(); |
1043 | 1043 | $options = $opt; |
@@ -1050,71 +1050,71 @@ discard block |
||
1050 | 1050 | $this->vars['options'] = & $opt; |
1051 | 1051 | $custom = eval($php); |
1052 | 1052 | $msg = ob_get_contents(); |
1053 | - if($value===$this->bt) $value = $msg . $custom; |
|
1053 | + if ($value === $this->bt) $value = $msg.$custom; |
|
1054 | 1054 | ob_end_clean(); |
1055 | 1055 | } |
1056 | - elseif($html!==false && isset($value) && $value!=='') |
|
1056 | + elseif ($html !== false && isset($value) && $value !== '') |
|
1057 | 1057 | { |
1058 | - $html = str_replace(array($self,'[+value+]'), $value, $html); |
|
1059 | - $value = str_replace(array('[+options+]','[+param+]'), $opt, $html); |
|
1058 | + $html = str_replace(array($self, '[+value+]'), $value, $html); |
|
1059 | + $value = str_replace(array('[+options+]', '[+param+]'), $opt, $html); |
|
1060 | 1060 | } |
1061 | 1061 | else return false; |
1062 | 1062 | |
1063 | - if($php===false && $html===false && $value!=='' |
|
1064 | - && (strpos($cmd,'[+value+]')!==false || strpos($cmd,$self)!==false)) |
|
1063 | + if ($php === false && $html === false && $value !== '' |
|
1064 | + && (strpos($cmd, '[+value+]') !== false || strpos($cmd, $self) !== false)) |
|
1065 | 1065 | { |
1066 | - $value = str_replace(array('[+value+]',$self),$value,$cmd); |
|
1066 | + $value = str_replace(array('[+value+]', $self), $value, $cmd); |
|
1067 | 1067 | } |
1068 | 1068 | return $value; |
1069 | 1069 | } |
1070 | 1070 | |
1071 | - public function parseDocumentSource($content='') |
|
1071 | + public function parseDocumentSource($content = '') |
|
1072 | 1072 | { |
1073 | 1073 | global $modx; |
1074 | 1074 | |
1075 | - if(strpos($content,'[')===false && strpos($content,'{')===false) return $content; |
|
1075 | + if (strpos($content, '[') === false && strpos($content, '{') === false) return $content; |
|
1076 | 1076 | |
1077 | - if(!$modx->maxParserPasses) $modx->maxParserPasses = 10; |
|
1078 | - $bt=''; |
|
1079 | - $i=0; |
|
1080 | - while($bt!==$content) |
|
1077 | + if (!$modx->maxParserPasses) $modx->maxParserPasses = 10; |
|
1078 | + $bt = ''; |
|
1079 | + $i = 0; |
|
1080 | + while ($bt !== $content) |
|
1081 | 1081 | { |
1082 | 1082 | $bt = $content; |
1083 | - if(strpos($content,'[*')!==false && $modx->documentIdentifier) |
|
1083 | + if (strpos($content, '[*') !== false && $modx->documentIdentifier) |
|
1084 | 1084 | $content = $modx->mergeDocumentContent($content); |
1085 | - if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content); |
|
1086 | - if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content); |
|
1087 | - if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content); |
|
1088 | - if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content); |
|
1085 | + if (strpos($content, '[(') !== false) $content = $modx->mergeSettingsContent($content); |
|
1086 | + if (strpos($content, '{{') !== false) $content = $modx->mergeChunkContent($content); |
|
1087 | + if (strpos($content, '[!') !== false) $content = str_replace(array('[!', '!]'), array('[[', ']]'), $content); |
|
1088 | + if (strpos($content, '[[') !== false) $content = $modx->evalSnippets($content); |
|
1089 | 1089 | |
1090 | - if($content===$bt) break; |
|
1091 | - if($modx->maxParserPasses < $i) break; |
|
1090 | + if ($content === $bt) break; |
|
1091 | + if ($modx->maxParserPasses < $i) break; |
|
1092 | 1092 | $i++; |
1093 | 1093 | } |
1094 | 1094 | return $content; |
1095 | 1095 | } |
1096 | 1096 | |
1097 | - public function getDocumentObject($target='',$field='pagetitle') |
|
1097 | + public function getDocumentObject($target = '', $field = 'pagetitle') |
|
1098 | 1098 | { |
1099 | 1099 | global $modx; |
1100 | 1100 | |
1101 | 1101 | $target = trim($target); |
1102 | - if(empty($target)) $target = $modx->config['site_start']; |
|
1103 | - if(preg_match('@^[1-9][0-9]*$@',$target)) $method='id'; |
|
1102 | + if (empty($target)) $target = $modx->config['site_start']; |
|
1103 | + if (preg_match('@^[1-9][0-9]*$@', $target)) $method = 'id'; |
|
1104 | 1104 | else $method = 'alias'; |
1105 | 1105 | |
1106 | - if(!isset($this->documentObject[$target])) |
|
1106 | + if (!isset($this->documentObject[$target])) |
|
1107 | 1107 | { |
1108 | - $this->documentObject[$target] = $modx->getDocumentObject($method,$target,'direct'); |
|
1108 | + $this->documentObject[$target] = $modx->getDocumentObject($method, $target, 'direct'); |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | - if($this->documentObject[$target]['publishedon']==='0') |
|
1111 | + if ($this->documentObject[$target]['publishedon'] === '0') |
|
1112 | 1112 | return ''; |
1113 | - elseif(isset($this->documentObject[$target][$field])) |
|
1113 | + elseif (isset($this->documentObject[$target][$field])) |
|
1114 | 1114 | { |
1115 | - if(is_array($this->documentObject[$target][$field])) |
|
1115 | + if (is_array($this->documentObject[$target][$field])) |
|
1116 | 1116 | { |
1117 | - $a = $modx->getTemplateVarOutput($field,$target); |
|
1117 | + $a = $modx->getTemplateVarOutput($field, $target); |
|
1118 | 1118 | $this->documentObject[$target][$field] = $a[$field]; |
1119 | 1119 | } |
1120 | 1120 | } |
@@ -1123,8 +1123,8 @@ discard block |
||
1123 | 1123 | return $this->documentObject[$target][$field]; |
1124 | 1124 | } |
1125 | 1125 | |
1126 | - public function setPlaceholders($value = '', $key = '', $path = '') { |
|
1127 | - if($path!=='') $key = "{$path}.{$key}"; |
|
1126 | + public function setPlaceholders($value = '', $key = '', $path = ''){ |
|
1127 | + if ($path !== '') $key = "{$path}.{$key}"; |
|
1128 | 1128 | if (is_array($value)) { |
1129 | 1129 | foreach ($value as $subkey => $subval) { |
1130 | 1130 | $this->setPlaceholders($subval, $subkey, $key); |
@@ -1134,77 +1134,77 @@ discard block |
||
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | // Sets a placeholder variable which can only be access by Modifiers |
1137 | - public function setModifiersVariable($key, $value) { |
|
1137 | + public function setModifiersVariable($key, $value){ |
|
1138 | 1138 | if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value; |
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | //mbstring |
1142 | - public function substr($str, $s, $l = null) { |
|
1142 | + public function substr($str, $s, $l = null){ |
|
1143 | 1143 | global $modx; |
1144 | - if(is_null($l)) $l = $this->strlen($str); |
|
1144 | + if (is_null($l)) $l = $this->strlen($str); |
|
1145 | 1145 | if (function_exists('mb_substr')) |
1146 | 1146 | { |
1147 | - if(strpos($str,"\r")!==false) |
|
1148 | - $str = str_replace(array("\r\n","\r"), "\n", $str); |
|
1147 | + if (strpos($str, "\r") !== false) |
|
1148 | + $str = str_replace(array("\r\n", "\r"), "\n", $str); |
|
1149 | 1149 | return mb_substr($str, $s, $l, $modx->config['modx_charset']); |
1150 | 1150 | } |
1151 | 1151 | return substr($str, $s, $l); |
1152 | 1152 | } |
1153 | - public function strpos($haystack,$needle,$offset=0) { |
|
1153 | + public function strpos($haystack, $needle, $offset = 0){ |
|
1154 | 1154 | global $modx; |
1155 | - if (function_exists('mb_strpos')) return mb_strpos($haystack,$needle,$offset,$modx->config['modx_charset']); |
|
1156 | - return strpos($haystack,$needle,$offset); |
|
1155 | + if (function_exists('mb_strpos')) return mb_strpos($haystack, $needle, $offset, $modx->config['modx_charset']); |
|
1156 | + return strpos($haystack, $needle, $offset); |
|
1157 | 1157 | } |
1158 | - public function strlen($str) { |
|
1158 | + public function strlen($str){ |
|
1159 | 1159 | global $modx; |
1160 | - if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str),$modx->config['modx_charset']); |
|
1160 | + if (function_exists('mb_strlen')) return mb_strlen(str_replace("\r\n", "\n", $str), $modx->config['modx_charset']); |
|
1161 | 1161 | return strlen($str); |
1162 | 1162 | } |
1163 | - public function strtolower($str) { |
|
1163 | + public function strtolower($str){ |
|
1164 | 1164 | if (function_exists('mb_strtolower')) return mb_strtolower($str); |
1165 | 1165 | return strtolower($str); |
1166 | 1166 | } |
1167 | - public function strtoupper($str) { |
|
1167 | + public function strtoupper($str){ |
|
1168 | 1168 | if (function_exists('mb_strtoupper')) return mb_strtoupper($str); |
1169 | 1169 | return strtoupper($str); |
1170 | 1170 | } |
1171 | - public function ucfirst($str) { |
|
1171 | + public function ucfirst($str){ |
|
1172 | 1172 | if (function_exists('mb_strtoupper')) |
1173 | 1173 | return mb_strtoupper($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
1174 | 1174 | return ucfirst($str); |
1175 | 1175 | } |
1176 | - public function lcfirst($str) { |
|
1176 | + public function lcfirst($str){ |
|
1177 | 1177 | if (function_exists('mb_strtolower')) |
1178 | 1178 | return mb_strtolower($this->substr($str, 0, 1)).$this->substr($str, 1, $this->strlen($str)); |
1179 | 1179 | return lcfirst($str); |
1180 | 1180 | } |
1181 | - public function ucwords($str) { |
|
1181 | + public function ucwords($str){ |
|
1182 | 1182 | if (function_exists('mb_convert_case')) |
1183 | 1183 | return mb_convert_case($str, MB_CASE_TITLE); |
1184 | 1184 | return ucwords($str); |
1185 | 1185 | } |
1186 | - public function strrev($str) { |
|
1186 | + public function strrev($str){ |
|
1187 | 1187 | preg_match_all('/./us', $str, $ar); |
1188 | 1188 | return implode(array_reverse($ar[0])); |
1189 | 1189 | } |
1190 | - public function str_shuffle($str) { |
|
1190 | + public function str_shuffle($str){ |
|
1191 | 1191 | preg_match_all('/./us', $str, $ar); |
1192 | 1192 | shuffle($ar[0]); |
1193 | 1193 | return implode($ar[0]); |
1194 | 1194 | } |
1195 | - public function str_word_count($str) { |
|
1196 | - return count(preg_split('~[^\p{L}\p{N}\']+~u',$str)); |
|
1195 | + public function str_word_count($str){ |
|
1196 | + return count(preg_split('~[^\p{L}\p{N}\']+~u', $str)); |
|
1197 | 1197 | } |
1198 | - public function strip_tags($value,$params='') { |
|
1198 | + public function strip_tags($value, $params = ''){ |
|
1199 | 1199 | global $modx; |
1200 | 1200 | |
1201 | - if(stripos($params,'style')===false && stripos($value,'</style>')!==false) { |
|
1201 | + if (stripos($params, 'style') === false && stripos($value, '</style>') !== false) { |
|
1202 | 1202 | $value = preg_replace('@<style.*?>.*?</style>@is', '', $value); |
1203 | 1203 | } |
1204 | - if(stripos($params,'script')===false && stripos($value,'</script>')!==false) { |
|
1204 | + if (stripos($params, 'script') === false && stripos($value, '</script>') !== false) { |
|
1205 | 1205 | $value = preg_replace('@<script.*?>.*?</script>@is', '', $value); |
1206 | 1206 | } |
1207 | 1207 | |
1208 | - return trim(strip_tags($value,$params)); |
|
1208 | + return trim(strip_tags($value, $params)); |
|
1209 | 1209 | } |
1210 | 1210 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function setTableWidth($value) |
132 | 132 | { |
133 | - $this->tableWidth = (int)$value; |
|
133 | + $this->tableWidth = (int) $value; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | { |
318 | 318 | $currentWidth = ''; |
319 | 319 | if (is_array($this->columnWidths)) { |
320 | - $currentWidth = $this->columnWidths[$columnPosition] ? ' width="' . $this->columnWidths[$columnPosition] . '" ' : ''; |
|
320 | + $currentWidth = $this->columnWidths[$columnPosition] ? ' width="'.$this->columnWidths[$columnPosition].'" ' : ''; |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | return $currentWidth; |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $currentClass = $this->rowAlternateClass; |
347 | 347 | } |
348 | 348 | |
349 | - return ' class="' . $currentClass . '"'; |
|
349 | + return ' class="'.$currentClass.'"'; |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | { |
361 | 361 | $cellAction = ''; |
362 | 362 | if ($this->cellAction) { |
363 | - $cellAction = ' onClick="javascript:window.location=\'' . $this->cellAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '\'" '; |
|
363 | + $cellAction = ' onClick="javascript:window.location=\''.$this->cellAction.$this->actionField.'='.urlencode($currentActionFieldValue).'\'" '; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | return $cellAction; |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | { |
378 | 378 | $cell = $value; |
379 | 379 | if ($this->linkAction) { |
380 | - $cell = '<a href="' . $this->linkAction . $this->actionField . '=' . urlencode($currentActionFieldValue) . '">' . $cell . '</a>'; |
|
380 | + $cell = '<a href="'.$this->linkAction.$this->actionField.'='.urlencode($currentActionFieldValue).'">'.$cell.'</a>'; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | return $cell; |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | $end = '?'; |
407 | 407 | } |
408 | 408 | |
409 | - return $link . $end; |
|
409 | + return $link.$end; |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | if (is_array($fieldsArray)) { |
427 | 427 | $i = 0; |
428 | 428 | foreach ($fieldsArray as $fieldName => $fieldValue) { |
429 | - $table .= "\t<tr" . $this->determineRowClass($i) . ">\n"; |
|
429 | + $table .= "\t<tr".$this->determineRowClass($i).">\n"; |
|
430 | 430 | $currentActionFieldValue = $fieldValue[$this->actionField]; |
431 | 431 | if (is_array($this->selectedValues)) { |
432 | 432 | $isChecked = array_search($currentActionFieldValue, $this->selectedValues) === false ? 0 : 1; |
@@ -437,15 +437,15 @@ discard block |
||
437 | 437 | $colPosition = 0; |
438 | 438 | foreach ($fieldValue as $key => $value) { |
439 | 439 | if (!in_array($key, $this->excludeFields)) { |
440 | - $table .= "\t\t<td" . $this->getCellAction($currentActionFieldValue) . ">"; |
|
440 | + $table .= "\t\t<td".$this->getCellAction($currentActionFieldValue).">"; |
|
441 | 441 | $table .= $this->createCellText($currentActionFieldValue, $value); |
442 | 442 | $table .= "</td>\n"; |
443 | 443 | if ($i == 0) { |
444 | 444 | if (empty ($header) && $this->formElementType) { |
445 | - $header .= "\t\t<th style=\"width:32px\" " . ($this->thClass ? 'class="' . $this->thClass . '"' : '') . ">" . ($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '') . "</th>\n"; |
|
445 | + $header .= "\t\t<th style=\"width:32px\" ".($this->thClass ? 'class="'.$this->thClass.'"' : '').">".($this->allOption ? '<a href="javascript:clickAll()">all</a>' : '')."</th>\n"; |
|
446 | 446 | } |
447 | 447 | $headerText = array_key_exists($key, $fieldHeadersArray) ? $fieldHeadersArray[$key] : $key; |
448 | - $header .= "\t\t<th" . $this->getColumnWidth($colPosition) . ($this->thClass ? ' class="' . $this->thClass . '" ' : '') . ">" . $headerText . "</th>\n"; |
|
448 | + $header .= "\t\t<th".$this->getColumnWidth($colPosition).($this->thClass ? ' class="'.$this->thClass.'" ' : '').">".$headerText."</th>\n"; |
|
449 | 449 | } |
450 | 450 | $colPosition++; |
451 | 451 | } |
@@ -453,9 +453,9 @@ discard block |
||
453 | 453 | $i++; |
454 | 454 | $table .= "\t</tr>\n"; |
455 | 455 | } |
456 | - $table = "\n" . '<table' . ($this->tableWidth > 0 ? ' width="' . $this->tableWidth . '"' : '') . ($this->tableClass ? ' class="' . $this->tableClass . '"' : '') . ($this->tableID ? ' id="' . $this->tableID . '"' : '') . ">\n" . ($header ? "\t<thead>\n\t<tr class=\"" . $this->rowHeaderClass . "\">\n" . $header . "\t</tr>\n\t</thead>\n" : '') . $table . "</table>\n"; |
|
456 | + $table = "\n".'<table'.($this->tableWidth > 0 ? ' width="'.$this->tableWidth.'"' : '').($this->tableClass ? ' class="'.$this->tableClass.'"' : '').($this->tableID ? ' id="'.$this->tableID.'"' : '').">\n".($header ? "\t<thead>\n\t<tr class=\"".$this->rowHeaderClass."\">\n".$header."\t</tr>\n\t</thead>\n" : '').$table."</table>\n"; |
|
457 | 457 | if ($this->formElementType) { |
458 | - $table = "\n" . '<form id="' . $this->formName . '" name="' . $this->formName . '" action="' . $this->formAction . '" method="POST">' . $table; |
|
458 | + $table = "\n".'<form id="'.$this->formName.'" name="'.$this->formName.'" action="'.$this->formAction.'" method="POST">'.$table; |
|
459 | 459 | } |
460 | 460 | if (strlen($this->pageNav) > 1) {//changed to display the pagination if exists. |
461 | 461 | /* commented this part because of cookie |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | |
470 | 470 | $table .= '</select>'.$_lang["pagination_table_perpage"].'</div>'; |
471 | 471 | */ |
472 | - $table .= '<div id="pagination" class="paginate">' . $_lang["pagination_table_gotopage"] . '<ul>' . $this->pageNav . '</ul></div>'; |
|
472 | + $table .= '<div id="pagination" class="paginate">'.$_lang["pagination_table_gotopage"].'<ul>'.$this->pageNav.'</ul></div>'; |
|
473 | 473 | //$table .= '<script language="javascript">function updatePageSize(size){window.location = \''.$this->prepareLink($linkpage).'pageSize=\'+size;}</script>'; |
474 | 474 | |
475 | 475 | } |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | <script language="javascript"> |
479 | 479 | toggled = 0; |
480 | 480 | function clickAll() { |
481 | - myform = document.getElementById("' . $this->formName . '"); |
|
481 | + myform = document.getElementById("' . $this->formName.'"); |
|
482 | 482 | for(i=0;i<myform.length;i++) { |
483 | 483 | if(myform.elements[i].type==\'checkbox\') { |
484 | 484 | myform.elements[i].checked=(toggled?false:true); |
@@ -490,9 +490,9 @@ discard block |
||
490 | 490 | } |
491 | 491 | if ($this->formElementType) { |
492 | 492 | if ($this->extra) { |
493 | - $table .= "\n" . $this->extra . "\n"; |
|
493 | + $table .= "\n".$this->extra."\n"; |
|
494 | 494 | } |
495 | - $table .= "\n" . '</form>' . "\n"; |
|
495 | + $table .= "\n".'</form>'."\n"; |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | return $table; |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | $numPages = ceil($numRecords / MAX_DISPLAY_RECORDS_NUM); |
516 | 516 | $nav = ''; |
517 | 517 | if ($numPages > 1) { |
518 | - $currentURL = empty($qs) ? '' : '?' . $qs; |
|
518 | + $currentURL = empty($qs) ? '' : '?'.$qs; |
|
519 | 519 | if ($currentPage > 6) { |
520 | 520 | $nav .= $this->createPageLink($currentURL, 1, $_lang["pagination_table_first"]); |
521 | 521 | } |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | $nav .= $this->createPageLink($currentURL, $numPages, $_lang["pagination_table_last"]); |
541 | 541 | } |
542 | 542 | } |
543 | - $this->pageNav = ' ' . $nav; |
|
543 | + $this->pageNav = ' '.$nav; |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -556,14 +556,14 @@ discard block |
||
556 | 556 | public function createPageLink($link = '', $pageNum, $displayText, $currentPage = false, $qs = '') |
557 | 557 | { |
558 | 558 | global $modx; |
559 | - $orderBy = !empty($_GET['orderby']) ? '&orderby=' . $_GET['orderby'] : ''; |
|
560 | - $orderDir = !empty($_GET['orderdir']) ? '&orderdir=' . $_GET['orderdir'] : ''; |
|
559 | + $orderBy = !empty($_GET['orderby']) ? '&orderby='.$_GET['orderby'] : ''; |
|
560 | + $orderDir = !empty($_GET['orderdir']) ? '&orderdir='.$_GET['orderdir'] : ''; |
|
561 | 561 | if (!empty($qs)) { |
562 | 562 | $qs = "?$qs"; |
563 | 563 | } |
564 | 564 | $link = empty($link) ? $modx->makeUrl($modx->documentIdentifier, $modx->documentObject['alias'], |
565 | - $qs . "page=$pageNum$orderBy$orderDir") : $this->prepareLink($link) . "page=$pageNum"; |
|
566 | - $nav = '<li' . ($currentPage ? ' class="currentPage"' : '') . '><a' . ($currentPage ? ' class="currentPage"' : '') . ' href="' . $link . '">' . $displayText . '</a></li>' . "\n"; |
|
565 | + $qs."page=$pageNum$orderBy$orderDir") : $this->prepareLink($link)."page=$pageNum"; |
|
566 | + $nav = '<li'.($currentPage ? ' class="currentPage"' : '').'><a'.($currentPage ? ' class="currentPage"' : '').' href="'.$link.'">'.$displayText.'</a></li>'."\n"; |
|
567 | 567 | |
568 | 568 | return $nav; |
569 | 569 | } |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | $field = ''; |
582 | 582 | if ($this->formElementType) { |
583 | 583 | $checked = $isChecked ? "checked " : ""; |
584 | - $field = "\t\t" . '<td><input type="' . $this->formElementType . '" name="' . ($this->formElementName ? $this->formElementName : $value) . '" value="' . $value . '" ' . $checked . '/></td>' . "\n"; |
|
584 | + $field = "\t\t".'<td><input type="'.$this->formElementType.'" name="'.($this->formElementName ? $this->formElementName : $value).'" value="'.$value.'" '.$checked.'/></td>'."\n"; |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | return $field; |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | public function handlePaging() |
596 | 596 | { |
597 | 597 | $offset = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] - 1 : 0; |
598 | - $limitClause = ' LIMIT ' . ($offset * MAX_DISPLAY_RECORDS_NUM) . ', ' . MAX_DISPLAY_RECORDS_NUM; |
|
598 | + $limitClause = ' LIMIT '.($offset * MAX_DISPLAY_RECORDS_NUM).', '.MAX_DISPLAY_RECORDS_NUM; |
|
599 | 599 | |
600 | 600 | return $limitClause; |
601 | 601 | } |
@@ -610,10 +610,10 @@ discard block |
||
610 | 610 | public function handleSorting($natural_order = false) |
611 | 611 | { |
612 | 612 | $orderByClause = ''; |
613 | - if ((bool)$natural_order === false) { |
|
613 | + if ((bool) $natural_order === false) { |
|
614 | 614 | $orderby = !empty($_GET['orderby']) ? $_GET['orderby'] : "id"; |
615 | 615 | $orderdir = !empty($_GET['orderdir']) ? $_GET['orderdir'] : "DESC"; |
616 | - $orderByClause = !empty($orderby) ? ' ORDER BY ' . $orderby . ' ' . $orderdir . ' ' : ""; |
|
616 | + $orderByClause = !empty($orderby) ? ' ORDER BY '.$orderby.' '.$orderdir.' ' : ""; |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | return $orderByClause; |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | } |
643 | 643 | } |
644 | 644 | |
645 | - return '<a href="[~' . $modx->documentIdentifier . '~]?' . $qs . 'orderby=' . $key . $orderDir . '">' . $text . '</a>'; |
|
645 | + return '<a href="[~'.$modx->documentIdentifier.'~]?'.$qs.'orderby='.$key.$orderDir.'">'.$text.'</a>'; |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | } |
@@ -1,13 +1,13 @@ 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 | 5 | |
6 | 6 | // PROCESSOR FIRST |
7 | -if($_SESSION['mgrRole'] == 1) { |
|
8 | - if($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
7 | +if ($_SESSION['mgrRole'] == 1) { |
|
8 | + if ($_REQUEST['b'] == 'resetSysfilesChecksum' && $modx->hasPermission('settings')) { |
|
9 | 9 | $current = $modx->manager->getSystemChecksum($modx->config['check_files_onlogin']); |
10 | - if(!empty($current)) { |
|
10 | + if (!empty($current)) { |
|
11 | 11 | $modx->manager->setSystemChecksum($current); |
12 | 12 | $modx->clearCache('full'); |
13 | 13 | $modx->config['sys_files_checksum'] = $current; |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | $warningspresent = 0; |
20 | 20 | |
21 | 21 | $sysfiles_check = $modx->manager->checkSystemChecksum(); |
22 | -if ($sysfiles_check!=='0'){ |
|
22 | +if ($sysfiles_check !== '0') { |
|
23 | 23 | $warningspresent = 1; |
24 | 24 | $warnings[] = array($_lang['configcheck_sysfiles_mod']); |
25 | 25 | } |
26 | 26 | |
27 | -if (is_writable("includes/config.inc.php")){ |
|
27 | +if (is_writable("includes/config.inc.php")) { |
|
28 | 28 | // Warn if world writable |
29 | - if(@fileperms('includes/config.inc.php') & 0x0002) { |
|
29 | + if (@fileperms('includes/config.inc.php') & 0x0002) { |
|
30 | 30 | $warningspresent = 1; |
31 | 31 | $warnings[] = array($_lang['configcheck_configinc']); |
32 | 32 | } |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | $warnings[] = array($_lang['configcheck_php_gdzip']); |
43 | 43 | } |
44 | 44 | |
45 | -if(!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
46 | - if(isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
45 | +if (!isset($modx->config['_hide_configcheck_validate_referer']) || $modx->config['_hide_configcheck_validate_referer'] !== '1') { |
|
46 | + if (isset($_SESSION['mgrPermissions']['settings']) && $_SESSION['mgrPermissions']['settings'] == '1') { |
|
47 | 47 | if ($modx->db->getValue($modx->db->select('COUNT(setting_value)', $modx->getFullTableName('system_settings'), "setting_name='validate_referer' AND setting_value='0'"))) { |
48 | 48 | $warningspresent = 1; |
49 | 49 | $warnings[] = array($_lang['configcheck_validate_referer']); |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | // check for Template Switcher plugin |
55 | -if(!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
56 | - if(isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
55 | +if (!isset($modx->config['_hide_configcheck_templateswitcher_present']) || $modx->config['_hide_configcheck_templateswitcher_present'] !== '1') { |
|
56 | + if (isset($_SESSION['mgrPermissions']['edit_plugin']) && $_SESSION['mgrPermissions']['edit_plugin'] == '1') { |
|
57 | 57 | $rs = $modx->db->select('name, disabled', $modx->getFullTableName('site_plugins'), "name IN ('TemplateSwitcher', 'Template Switcher', 'templateswitcher', 'template_switcher', 'template switcher') OR plugincode LIKE '%TemplateSwitcher%'"); |
58 | 58 | $row = $modx->db->getRow($rs); |
59 | - if($row && $row['disabled'] == 0) { |
|
59 | + if ($row && $row['disabled'] == 0) { |
|
60 | 60 | $warningspresent = 1; |
61 | 61 | $warnings[] = array($_lang['configcheck_templateswitcher_present']); |
62 | 62 | $tplName = $row['name']; |
@@ -120,36 +120,36 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * @return bool |
122 | 122 | */ |
123 | - function checkSiteCache() { |
|
123 | + function checkSiteCache(){ |
|
124 | 124 | global $modx; |
125 | - $checked= true; |
|
126 | - if (file_exists($modx->config['base_path'] . 'assets/cache/siteCache.idx.php')) { |
|
127 | - $checked= @include_once ($modx->config['base_path'] . 'assets/cache/siteCache.idx.php'); |
|
125 | + $checked = true; |
|
126 | + if (file_exists($modx->config['base_path'].'assets/cache/siteCache.idx.php')) { |
|
127 | + $checked = @include_once ($modx->config['base_path'].'assets/cache/siteCache.idx.php'); |
|
128 | 128 | } |
129 | 129 | return $checked; |
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | -if (!is_writable(MODX_BASE_PATH . "assets/cache/")) { |
|
133 | +if (!is_writable(MODX_BASE_PATH."assets/cache/")) { |
|
134 | 134 | $warningspresent = 1; |
135 | 135 | $warnings[] = array($_lang['configcheck_cache']); |
136 | 136 | } |
137 | 137 | |
138 | 138 | if (!checkSiteCache()) { |
139 | 139 | $warningspresent = 1; |
140 | - $warnings[]= array($lang['configcheck_sitecache_integrity']); |
|
140 | + $warnings[] = array($lang['configcheck_sitecache_integrity']); |
|
141 | 141 | } |
142 | 142 | |
143 | -if (!is_writable(MODX_BASE_PATH . "assets/images/")) { |
|
143 | +if (!is_writable(MODX_BASE_PATH."assets/images/")) { |
|
144 | 144 | $warningspresent = 1; |
145 | 145 | $warnings[] = array($_lang['configcheck_images']); |
146 | 146 | } |
147 | 147 | |
148 | -if(strpos($modx->config['rb_base_dir'],MODX_BASE_PATH)!==0) { |
|
148 | +if (strpos($modx->config['rb_base_dir'], MODX_BASE_PATH) !== 0) { |
|
149 | 149 | $warningspresent = 1; |
150 | 150 | $warnings[] = array($_lang['configcheck_rb_base_dir']); |
151 | 151 | } |
152 | -if(strpos($modx->config['filemanager_path'],MODX_BASE_PATH)!==0) { |
|
152 | +if (strpos($modx->config['filemanager_path'], MODX_BASE_PATH) !== 0) { |
|
153 | 153 | $warningspresent = 1; |
154 | 154 | $warnings[] = array($_lang['configcheck_filemanager_path']); |
155 | 155 | } |
@@ -157,36 +157,36 @@ discard block |
||
157 | 157 | // clear file info cache |
158 | 158 | clearstatcache(); |
159 | 159 | |
160 | -if ($warningspresent==1) { |
|
160 | +if ($warningspresent == 1) { |
|
161 | 161 | |
162 | -if(!isset($modx->config['send_errormail'])) $modx->config['send_errormail']='3'; |
|
162 | +if (!isset($modx->config['send_errormail'])) $modx->config['send_errormail'] = '3'; |
|
163 | 163 | $config_check_results = "<h3>".$_lang['configcheck_notok']."</h3>"; |
164 | 164 | |
165 | -for ($i=0;$i<count($warnings);$i++) { |
|
165 | +for ($i = 0; $i < count($warnings); $i++) { |
|
166 | 166 | switch ($warnings[$i][0]) { |
167 | 167 | case $_lang['configcheck_configinc']; |
168 | 168 | $warnings[$i][1] = $_lang['configcheck_configinc_msg']; |
169 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_configinc']); |
|
169 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_configinc']); |
|
170 | 170 | break; |
171 | 171 | case $_lang['configcheck_installer'] : |
172 | 172 | $warnings[$i][1] = $_lang['configcheck_installer_msg']; |
173 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1],$_lang['configcheck_installer']); |
|
173 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1], $_lang['configcheck_installer']); |
|
174 | 174 | break; |
175 | 175 | case $_lang['configcheck_cache'] : |
176 | 176 | $warnings[$i][1] = $_lang['configcheck_cache_msg']; |
177 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_cache']); |
|
177 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_cache']); |
|
178 | 178 | break; |
179 | 179 | case $_lang['configcheck_images'] : |
180 | 180 | $warnings[$i][1] = $_lang['configcheck_images_msg']; |
181 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,2,$warnings[$i][1],$_lang['configcheck_images']); |
|
181 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 2, $warnings[$i][1], $_lang['configcheck_images']); |
|
182 | 182 | break; |
183 | 183 | case $_lang['configcheck_sysfiles_mod']: |
184 | 184 | $warnings[$i][1] = $_lang["configcheck_sysfiles_mod_msg"]; |
185 | - $warnings[$i][2] = '<ul><li>'. implode('</li><li>', $sysfiles_check) .'</li></ul>'; |
|
186 | - if($modx->hasPermission('settings')) { |
|
187 | - $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\'' . $_lang["reset_sysfiles_checksum_alert"] . '\')">' . $_lang["reset_sysfiles_checksum_button"] . '</a></li></ul>'; |
|
185 | + $warnings[$i][2] = '<ul><li>'.implode('</li><li>', $sysfiles_check).'</li></ul>'; |
|
186 | + if ($modx->hasPermission('settings')) { |
|
187 | + $warnings[$i][2] .= '<ul class="actionButtons" style="float:right"><li><a href="index.php?a=2&b=resetSysfilesChecksum" onclick="return confirm(\''.$_lang["reset_sysfiles_checksum_alert"].'\')">'.$_lang["reset_sysfiles_checksum_button"].'</a></li></ul>'; |
|
188 | 188 | } |
189 | - if(!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0,3,$warnings[$i][1]." ".implode(', ',$sysfiles_check),$_lang['configcheck_sysfiles_mod']); |
|
189 | + if (!$_SESSION["mgrConfigCheck"]) $modx->logEvent(0, 3, $warnings[$i][1]." ".implode(', ', $sysfiles_check), $_lang['configcheck_sysfiles_mod']); |
|
190 | 190 | break; |
191 | 191 | case $_lang['configcheck_lang_difference'] : |
192 | 192 | $warnings[$i][1] = $_lang['configcheck_lang_difference_msg']; |
@@ -208,18 +208,18 @@ discard block |
||
208 | 208 | break; |
209 | 209 | case $_lang['configcheck_validate_referer'] : |
210 | 210 | $msg = $_lang['configcheck_validate_referer_msg']; |
211 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
211 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'validate_referer'); |
|
212 | 212 | $warnings[$i][1] = "<span id=\"validate_referer_warning_wrapper\">{$msg}</span>\n"; |
213 | 213 | break; |
214 | 214 | case $_lang['configcheck_templateswitcher_present'] : |
215 | 215 | $msg = $_lang["configcheck_templateswitcher_present_msg"]; |
216 | - if(isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
217 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_disable"]; |
|
216 | + if (isset($_SESSION['mgrPermissions']['save_plugin']) && $_SESSION['mgrPermissions']['save_plugin'] == '1') { |
|
217 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_disable"]; |
|
218 | 218 | } |
219 | - if(isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
220 | - $msg .= '<br />' . $_lang["configcheck_templateswitcher_present_delete"]; |
|
219 | + if (isset($_SESSION['mgrPermissions']['delete_plugin']) && $_SESSION['mgrPermissions']['delete_plugin'] == '1') { |
|
220 | + $msg .= '<br />'.$_lang["configcheck_templateswitcher_present_delete"]; |
|
221 | 221 | } |
222 | - $msg .= '<br />' . sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
222 | + $msg .= '<br />'.sprintf($_lang["configcheck_hide_warning"], 'templateswitcher_present'); |
|
223 | 223 | $warnings[$i][1] = "<span id=\"templateswitcher_present_warning_wrapper\">{$msg}</span>\n"; |
224 | 224 | break; |
225 | 225 | case $_lang['configcheck_rb_base_dir'] : |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $warnings[$i][1] = $_lang['configcheck_default_msg']; |
233 | 233 | } |
234 | 234 | |
235 | - $admin_warning = $_SESSION['mgrRole']!=1 ? $_lang['configcheck_admin'] : "" ; |
|
235 | + $admin_warning = $_SESSION['mgrRole'] != 1 ? $_lang['configcheck_admin'] : ""; |
|
236 | 236 | $config_check_results .= " |
237 | 237 | <fieldset> |
238 | 238 | <p><strong>".$_lang['configcheck_warning']."</strong> '".$warnings[$i][0]."'</p> |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | ".(isset($warnings[$i][2]) ? '<div style="padding-left:1em">'.$warnings[$i][2].'</div>' : '')." |
242 | 242 | </fieldset> |
243 | 243 | "; |
244 | - if ($i!=count($warnings)-1) { |
|
244 | + if ($i != count($warnings) - 1) { |
|
245 | 245 | $config_check_results .= "<br />"; |
246 | 246 | } |
247 | 247 | } |
248 | - $_SESSION["mgrConfigCheck"]=true; |
|
248 | + $_SESSION["mgrConfigCheck"] = true; |
|
249 | 249 | } else { |
250 | 250 | $config_check_results = $_lang['configcheck_ok']; |
251 | 251 | } |
@@ -15,38 +15,38 @@ discard block |
||
15 | 15 | * @param string $sep |
16 | 16 | * @return mixed|string |
17 | 17 | */ |
18 | -function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') { |
|
18 | +function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = ''){ |
|
19 | 19 | |
20 | 20 | global $modx; |
21 | 21 | $o = ''; |
22 | 22 | |
23 | 23 | // process any TV commands in value |
24 | - $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
|
24 | + $docid = (int) $docid > 0 ? (int) $docid : $modx->documentIdentifier; |
|
25 | 25 | $value = ProcessTVCommand($value, $name, $docid); |
26 | 26 | |
27 | 27 | $params = array(); |
28 | - if($paramstring) { |
|
28 | + if ($paramstring) { |
|
29 | 29 | $cp = explode("&", $paramstring); |
30 | - foreach($cp as $p => $v) { |
|
30 | + foreach ($cp as $p => $v) { |
|
31 | 31 | $v = trim($v); // trim |
32 | 32 | $ar = explode("=", $v); |
33 | - if(is_array($ar) && count($ar) == 2) { |
|
33 | + if (is_array($ar) && count($ar) == 2) { |
|
34 | 34 | $params[$ar[0]] = decodeParamValue($ar[1]); |
35 | 35 | } |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | 39 | $id = "tv$name"; |
40 | - switch($format) { |
|
40 | + switch ($format) { |
|
41 | 41 | case 'image': |
42 | 42 | $images = parseInput($value, '||', 'array'); |
43 | - foreach($images as $image) { |
|
44 | - if(!is_array($image)) { |
|
43 | + foreach ($images as $image) { |
|
44 | + if (!is_array($image)) { |
|
45 | 45 | $image = explode('==', $image); |
46 | 46 | } |
47 | 47 | $src = $image[0]; |
48 | 48 | |
49 | - if($src) { |
|
49 | + if ($src) { |
|
50 | 50 | // We have a valid source |
51 | 51 | $attributes = ''; |
52 | 52 | $attr = array( |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | 'alt' => $modx->htmlspecialchars($params['alttext']), |
57 | 57 | 'style' => $params['style'] |
58 | 58 | ); |
59 | - if(isset($params['align']) && $params['align'] != 'none') { |
|
59 | + if (isset($params['align']) && $params['align'] != 'none') { |
|
60 | 60 | $attr['align'] = $params['align']; |
61 | 61 | } |
62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
63 | - $attributes .= ' ' . $params['attrib']; |
|
62 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
63 | + $attributes .= ' '.$params['attrib']; |
|
64 | 64 | |
65 | 65 | // Output the image with attributes |
66 | - $o .= '<img' . rtrim($attributes) . ' />'; |
|
66 | + $o .= '<img'.rtrim($attributes).' />'; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | break; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | case "delim": // display as delimitted list |
72 | 72 | $value = parseInput($value, "||"); |
73 | 73 | $p = $params['format'] ? $params['format'] : " "; |
74 | - if($p == "\\n") { |
|
74 | + if ($p == "\\n") { |
|
75 | 75 | $p = "\n"; |
76 | 76 | } |
77 | 77 | $o = str_replace("||", $p, $value); |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | case "string": |
81 | 81 | $value = parseInput($value); |
82 | 82 | $format = strtolower($params['format']); |
83 | - if($format == 'upper case') { |
|
83 | + if ($format == 'upper case') { |
|
84 | 84 | $o = strtoupper($value); |
85 | - } else if($format == 'lower case') { |
|
85 | + } else if ($format == 'lower case') { |
|
86 | 86 | $o = strtolower($value); |
87 | - } else if($format == 'sentence case') { |
|
87 | + } else if ($format == 'sentence case') { |
|
88 | 88 | $o = ucfirst($value); |
89 | - } else if($format == 'capitalize') { |
|
89 | + } else if ($format == 'capitalize') { |
|
90 | 90 | $o = ucwords($value); |
91 | 91 | } else { |
92 | 92 | $o = $value; |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | break; |
95 | 95 | |
96 | 96 | case "date": |
97 | - if($value != '' || $params['default'] == 'Yes') { |
|
98 | - if(empty($value)) { |
|
97 | + if ($value != '' || $params['default'] == 'Yes') { |
|
98 | + if (empty($value)) { |
|
99 | 99 | $value = 'now'; |
100 | 100 | } |
101 | 101 | $timestamp = getUnixtimeFromDateString($value); |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $value = parseInput($value, "||", "array"); |
111 | 111 | $o = ''; |
112 | 112 | $countValue = count($value); |
113 | - for($i = 0; $i < $countValue; $i++) { |
|
113 | + for ($i = 0; $i < $countValue; $i++) { |
|
114 | 114 | list($name, $url) = is_array($value[$i]) ? $value[$i] : explode("==", $value[$i]); |
115 | - if(!$url) { |
|
115 | + if (!$url) { |
|
116 | 116 | $url = $name; |
117 | 117 | } |
118 | - if($url) { |
|
119 | - if($o) { |
|
118 | + if ($url) { |
|
119 | + if ($o) { |
|
120 | 120 | $o .= '<br />'; |
121 | 121 | } |
122 | 122 | $attributes = ''; |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | 'style' => $params['style'], |
129 | 129 | 'target' => $params['target'], |
130 | 130 | ); |
131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
132 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
131 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
132 | + $attributes .= ' '.$params['attrib']; // add extra |
|
133 | 133 | |
134 | 134 | // Output the link |
135 | - $o .= '<a' . rtrim($attributes) . '>' . ($params['text'] ? $modx->htmlspecialchars($params['text']) : $name) . '</a>'; |
|
135 | + $o .= '<a'.rtrim($attributes).'>'.($params['text'] ? $modx->htmlspecialchars($params['text']) : $name).'</a>'; |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | break; |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | $o = ''; |
145 | 145 | // Loop through a list of tags |
146 | 146 | $countValue = count($value); |
147 | - for($i = 0; $i < $countValue; $i++) { |
|
147 | + for ($i = 0; $i < $countValue; $i++) { |
|
148 | 148 | $tagvalue = is_array($value[$i]) ? implode(' ', $value[$i]) : $value[$i]; |
149 | - if(!$tagvalue) { |
|
149 | + if (!$tagvalue) { |
|
150 | 150 | continue; |
151 | 151 | } |
152 | 152 | |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | 'class' => $params['class'], |
158 | 158 | 'style' => $params['style'], |
159 | 159 | ); |
160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
161 | - $attributes .= ' ' . $params['attrib']; // add extra |
|
160 | + foreach ($attr as $k => $v) $attributes .= ($v ? ' '.$k.'="'.$v.'"' : ''); |
|
161 | + $attributes .= ' '.$params['attrib']; // add extra |
|
162 | 162 | |
163 | 163 | // Output the HTML Tag |
164 | - $o .= '<' . $tagname . rtrim($attributes) . '>' . $tagvalue . '</' . $tagname . '>'; |
|
164 | + $o .= '<'.$tagname.rtrim($attributes).'>'.$tagvalue.'</'.$tagname.'>'; |
|
165 | 165 | } |
166 | 166 | break; |
167 | 167 | |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | $w = $params['w'] ? $params['w'] : '100%'; |
171 | 171 | $h = $params['h'] ? $params['h'] : '400px'; |
172 | 172 | $richtexteditor = $params['edt'] ? $params['edt'] : ""; |
173 | - $o = '<div class="MODX_RichTextWidget"><textarea id="' . $id . '" name="' . $id . '" style="width:' . $w . '; height:' . $h . ';">'; |
|
173 | + $o = '<div class="MODX_RichTextWidget"><textarea id="'.$id.'" name="'.$id.'" style="width:'.$w.'; height:'.$h.';">'; |
|
174 | 174 | $o .= $modx->htmlspecialchars($value); |
175 | 175 | $o .= '</textarea></div>'; |
176 | 176 | $replace_richtext = array($id); |
177 | 177 | // setup editors |
178 | - if(!empty($replace_richtext) && !empty($richtexteditor)) { |
|
178 | + if (!empty($replace_richtext) && !empty($richtexteditor)) { |
|
179 | 179 | // invoke OnRichTextEditorInit event |
180 | 180 | $evtOut = $modx->invokeEvent("OnRichTextEditorInit", array( |
181 | 181 | 'editor' => $richtexteditor, |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | 'width' => $w, |
185 | 185 | 'height' => $h |
186 | 186 | )); |
187 | - if(is_array($evtOut)) { |
|
187 | + if (is_array($evtOut)) { |
|
188 | 188 | $o .= implode("", $evtOut); |
189 | 189 | } |
190 | 190 | } |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | |
198 | 198 | case "viewport": |
199 | 199 | $value = parseInput($value); |
200 | - $id = '_' . time(); |
|
201 | - if(!$params['vpid']) { |
|
200 | + $id = '_'.time(); |
|
201 | + if (!$params['vpid']) { |
|
202 | 202 | $params['vpid'] = $id; |
203 | 203 | } |
204 | 204 | $sTag = "<iframe"; |
@@ -206,42 +206,42 @@ discard block |
||
206 | 206 | $autoMode = "0"; |
207 | 207 | $w = $params['width']; |
208 | 208 | $h = $params['height']; |
209 | - if($params['stretch'] == 'Yes') { |
|
209 | + if ($params['stretch'] == 'Yes') { |
|
210 | 210 | $w = "100%"; |
211 | 211 | $h = "100%"; |
212 | 212 | } |
213 | - if($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
214 | - $autoMode = "3"; //both |
|
215 | - } else if($params['awidth'] == 'Yes') { |
|
213 | + if ($params['asize'] == 'Yes' || ($params['awidth'] == 'Yes' && $params['aheight'] == 'Yes')) { |
|
214 | + $autoMode = "3"; //both |
|
215 | + } else if ($params['awidth'] == 'Yes') { |
|
216 | 216 | $autoMode = "1"; //width only |
217 | - } else if($params['aheight'] == 'Yes') { |
|
218 | - $autoMode = "2"; //height only |
|
217 | + } else if ($params['aheight'] == 'Yes') { |
|
218 | + $autoMode = "2"; //height only |
|
219 | 219 | } |
220 | 220 | |
221 | - $modx->regClientStartupScript(MODX_MANAGER_URL . "media/script/bin/viewport.js", array( |
|
221 | + $modx->regClientStartupScript(MODX_MANAGER_URL."media/script/bin/viewport.js", array( |
|
222 | 222 | 'name' => 'viewport', |
223 | 223 | 'version' => '0', |
224 | 224 | 'plaintext' => false |
225 | 225 | )); |
226 | - $o = $sTag . " id='" . $params['vpid'] . "' name='" . $params['vpid'] . "' "; |
|
227 | - if($params['class']) { |
|
228 | - $o .= " class='" . $params['class'] . "' "; |
|
226 | + $o = $sTag." id='".$params['vpid']."' name='".$params['vpid']."' "; |
|
227 | + if ($params['class']) { |
|
228 | + $o .= " class='".$params['class']."' "; |
|
229 | 229 | } |
230 | - if($params['style']) { |
|
231 | - $o .= " style='" . $params['style'] . "' "; |
|
230 | + if ($params['style']) { |
|
231 | + $o .= " style='".$params['style']."' "; |
|
232 | 232 | } |
233 | - if($params['attrib']) { |
|
234 | - $o .= $params['attrib'] . " "; |
|
233 | + if ($params['attrib']) { |
|
234 | + $o .= $params['attrib']." "; |
|
235 | 235 | } |
236 | - $o .= "scrolling='" . ($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto")) . "' "; |
|
237 | - $o .= "src='" . $value . "' frameborder='" . $params['borsize'] . "' "; |
|
238 | - $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'" . $params['vpid'] . "\\'," . $autoMode . ")',100);\" width='" . $w . "' height='" . $h . "' "; |
|
236 | + $o .= "scrolling='".($params['sbar'] == 'No' ? "no" : ($params['sbar'] == 'Yes' ? "yes" : "auto"))."' "; |
|
237 | + $o .= "src='".$value."' frameborder='".$params['borsize']."' "; |
|
238 | + $o .= "onload=\"window.setTimeout('ResizeViewPort(\\'".$params['vpid']."\\',".$autoMode.")',100);\" width='".$w."' height='".$h."' "; |
|
239 | 239 | $o .= ">"; |
240 | 240 | $o .= $eTag; |
241 | 241 | break; |
242 | 242 | |
243 | 243 | case "datagrid": |
244 | - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; |
|
244 | + include_once MODX_MANAGER_PATH."includes/controls/datagrid.class.php"; |
|
245 | 245 | $grd = new DataGrid('', $value); |
246 | 246 | |
247 | 247 | $grd->noRecordMsg = $params['egmsg']; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | case 'htmlentities': |
278 | 278 | $value = parseInput($value); |
279 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
279 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
280 | 280 | // remove delimiter from checkbox and listbox-multiple TVs |
281 | 281 | $value = str_replace('||', '', $value); |
282 | 282 | } |
@@ -287,33 +287,33 @@ discard block |
||
287 | 287 | $widget_output = ''; |
288 | 288 | $o = ''; |
289 | 289 | /* If we are loading a file */ |
290 | - if(substr($params['output'], 0, 5) == "@FILE") { |
|
291 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 6)); |
|
292 | - if(!file_exists($file_name)) { |
|
293 | - $widget_output = $file_name . ' does not exist'; |
|
290 | + if (substr($params['output'], 0, 5) == "@FILE") { |
|
291 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 6)); |
|
292 | + if (!file_exists($file_name)) { |
|
293 | + $widget_output = $file_name.' does not exist'; |
|
294 | 294 | } else { |
295 | 295 | $widget_output = file_get_contents($file_name); |
296 | 296 | } |
297 | - } elseif(substr($params['output'], 0, 8) == '@INCLUDE') { |
|
298 | - $file_name = MODX_BASE_PATH . trim(substr($params['output'], 9)); |
|
299 | - if(!file_exists($file_name)) { |
|
300 | - $widget_output = $file_name . ' does not exist'; |
|
297 | + } elseif (substr($params['output'], 0, 8) == '@INCLUDE') { |
|
298 | + $file_name = MODX_BASE_PATH.trim(substr($params['output'], 9)); |
|
299 | + if (!file_exists($file_name)) { |
|
300 | + $widget_output = $file_name.' does not exist'; |
|
301 | 301 | } else { |
302 | 302 | /* The included file needs to set $widget_output. Can be string, array, object */ |
303 | 303 | include $file_name; |
304 | 304 | } |
305 | - } elseif(substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
305 | + } elseif (substr($params['output'], 0, 6) == '@CHUNK' && $value !== '') { |
|
306 | 306 | $chunk_name = trim(substr($params['output'], 7)); |
307 | 307 | $widget_output = $modx->getChunk($chunk_name); |
308 | - } elseif(substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
308 | + } elseif (substr($params['output'], 0, 5) == '@EVAL' && $value !== '') { |
|
309 | 309 | $eval_str = trim(substr($params['output'], 6)); |
310 | 310 | $widget_output = eval($eval_str); |
311 | - } elseif($value !== '') { |
|
311 | + } elseif ($value !== '') { |
|
312 | 312 | $widget_output = $params['output']; |
313 | 313 | } else { |
314 | 314 | $widget_output = ''; |
315 | 315 | } |
316 | - if(is_string($widget_output)) { |
|
316 | + if (is_string($widget_output)) { |
|
317 | 317 | $_ = $modx->config['enable_filter']; |
318 | 318 | $modx->config['enable_filter'] = 1; |
319 | 319 | $widget_output = $modx->parseText($widget_output, array('value' => $value)); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | default: |
328 | 328 | $value = parseInput($value); |
329 | - if($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
329 | + if ($tvtype == 'checkbox' || $tvtype == 'listbox-multiple') { |
|
330 | 330 | // add separator |
331 | 331 | $value = explode('||', $value); |
332 | 332 | $value = implode($sep, $value); |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * @param string $s |
342 | 342 | * @return string |
343 | 343 | */ |
344 | -function decodeParamValue($s) { |
|
344 | +function decodeParamValue($s){ |
|
345 | 345 | $s = str_replace("%3D", '=', $s); // = |
346 | 346 | return str_replace("%26", '&', $s); // & |
347 | 347 | } |
@@ -355,16 +355,16 @@ discard block |
||
355 | 355 | * @param bool $columns |
356 | 356 | * @return array|string |
357 | 357 | */ |
358 | -function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
|
358 | +function parseInput($src, $delim = "||", $type = "string", $columns = true){ // type can be: string, array |
|
359 | 359 | global $modx; |
360 | - if($modx->db->isResult($src)) { |
|
360 | + if ($modx->db->isResult($src)) { |
|
361 | 361 | // must be a recordset |
362 | 362 | $rows = array(); |
363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
363 | + while ($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
364 | 364 | return ($type == "array") ? $rows : implode($delim, $rows); |
365 | 365 | } else { |
366 | 366 | // must be a text |
367 | - if($type == "array") { |
|
367 | + if ($type == "array") { |
|
368 | 368 | return explode($delim, $src); |
369 | 369 | } else { |
370 | 370 | return $src; |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | * @param string $value |
377 | 377 | * @return bool|false|int |
378 | 378 | */ |
379 | -function getUnixtimeFromDateString($value) { |
|
379 | +function getUnixtimeFromDateString($value){ |
|
380 | 380 | $timestamp = false; |
381 | 381 | // Check for MySQL or legacy style date |
382 | 382 | $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
383 | 383 | $date_match_2 = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
384 | 384 | $matches = array(); |
385 | - if(strpos($value, '-') !== false) { |
|
386 | - if(preg_match($date_match_1, $value, $matches)) { |
|
385 | + if (strpos($value, '-') !== false) { |
|
386 | + if (preg_match($date_match_1, $value, $matches)) { |
|
387 | 387 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); |
388 | - } elseif(preg_match($date_match_2, $value, $matches)) { |
|
388 | + } elseif (preg_match($date_match_2, $value, $matches)) { |
|
389 | 389 | $timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
390 | 390 | } |
391 | 391 | } |
392 | 392 | // If those didn't work, use strtotime to figure out the date |
393 | - if($timestamp === false || $timestamp === -1) { |
|
393 | + if ($timestamp === false || $timestamp === -1) { |
|
394 | 394 | $timestamp = strtotime($value); |
395 | 395 | } |
396 | 396 | return $timestamp; |
@@ -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 | } |
@@ -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; |
@@ -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); |
@@ -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); |
@@ -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 |