@@ -15,7 +15,8 @@ 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 | 21 | global $modx; |
21 | 22 | $o = ''; |
@@ -59,7 +60,9 @@ discard block |
||
59 | 60 | if(isset($params['align']) && $params['align'] != 'none') { |
60 | 61 | $attr['align'] = $params['align']; |
61 | 62 | } |
62 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
63 | + foreach($attr as $k => $v) { |
|
64 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
65 | + } |
|
63 | 66 | $attributes .= ' ' . $params['attrib']; |
64 | 67 | |
65 | 68 | // Output the image with attributes |
@@ -128,7 +131,9 @@ discard block |
||
128 | 131 | 'style' => $params['style'], |
129 | 132 | 'target' => $params['target'], |
130 | 133 | ); |
131 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
134 | + foreach($attr as $k => $v) { |
|
135 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
136 | + } |
|
132 | 137 | $attributes .= ' ' . $params['attrib']; // add extra |
133 | 138 | |
134 | 139 | // Output the link |
@@ -157,7 +162,9 @@ discard block |
||
157 | 162 | 'class' => $params['class'], |
158 | 163 | 'style' => $params['style'], |
159 | 164 | ); |
160 | - foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
165 | + foreach($attr as $k => $v) { |
|
166 | + $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : ''); |
|
167 | + } |
|
161 | 168 | $attributes .= ' ' . $params['attrib']; // add extra |
162 | 169 | |
163 | 170 | // Output the HTML Tag |
@@ -341,7 +348,8 @@ discard block |
||
341 | 348 | * @param string $s |
342 | 349 | * @return string |
343 | 350 | */ |
344 | -function decodeParamValue($s) { |
|
351 | +function decodeParamValue($s) |
|
352 | +{ |
|
345 | 353 | $s = str_replace("%3D", '=', $s); // = |
346 | 354 | return str_replace("%26", '&', $s); // & |
347 | 355 | } |
@@ -355,12 +363,16 @@ discard block |
||
355 | 363 | * @param bool $columns |
356 | 364 | * @return array|string |
357 | 365 | */ |
358 | -function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array |
|
366 | +function parseInput($src, $delim = "||", $type = "string", $columns = true) |
|
367 | +{ |
|
368 | +// type can be: string, array |
|
359 | 369 | global $modx; |
360 | 370 | if($modx->db->isResult($src)) { |
361 | 371 | // must be a recordset |
362 | 372 | $rows = array(); |
363 | - while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
373 | + while($cols = $modx->db->getRow($src, 'num')) { |
|
374 | + $rows[] = ($columns) ? $cols : implode(" ", $cols); |
|
375 | + } |
|
364 | 376 | return ($type == "array") ? $rows : implode($delim, $rows); |
365 | 377 | } else { |
366 | 378 | // must be a text |
@@ -376,7 +388,8 @@ discard block |
||
376 | 388 | * @param string $value |
377 | 389 | * @return bool|false|int |
378 | 390 | */ |
379 | -function getUnixtimeFromDateString($value) { |
|
391 | +function getUnixtimeFromDateString($value) |
|
392 | +{ |
|
380 | 393 | $timestamp = false; |
381 | 394 | // Check for MySQL or legacy style date |
382 | 395 | $date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/'; |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | * @param array $tvsArray |
23 | 23 | * @return string |
24 | 24 | */ |
25 | -function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) { |
|
25 | +function ProcessTVCommand($value, $name = '', $docid = '', $src='docform', $tvsArray = array()) |
|
26 | +{ |
|
26 | 27 | global $modx; |
27 | 28 | $docid = (int)$docid > 0 ? (int)$docid : $modx->documentIdentifier; |
28 | 29 | $nvalue = trim($value); |
29 | - if (substr($nvalue, 0, 1) != '@') |
|
30 | - return $value; |
|
31 | - elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
30 | + if (substr($nvalue, 0, 1) != '@') { |
|
31 | + return $value; |
|
32 | + } elseif(isset($modx->config['enable_bindings']) && $modx->config['enable_bindings']!=1 && $src==='docform') { |
|
32 | 33 | return '@Bindings is disabled.'; |
33 | - } |
|
34 | - else { |
|
34 | + } else { |
|
35 | 35 | list ($cmd, $param) = ParseCommand($nvalue); |
36 | 36 | $cmd = trim($cmd); |
37 | 37 | $param = parseTvValues($param, $tvsArray); |
@@ -47,10 +47,11 @@ discard block |
||
47 | 47 | |
48 | 48 | case "DOCUMENT" : // retrieve a document and process it's content |
49 | 49 | $rs = $modx->getDocument($param); |
50 | - if (is_array($rs)) |
|
51 | - $output = $rs['content']; |
|
52 | - else |
|
53 | - $output = "Unable to locate document $param"; |
|
50 | + if (is_array($rs)) { |
|
51 | + $output = $rs['content']; |
|
52 | + } else { |
|
53 | + $output = "Unable to locate document $param"; |
|
54 | + } |
|
54 | 55 | break; |
55 | 56 | |
56 | 57 | case "SELECT" : // selects a record from the cms database |
@@ -80,8 +81,10 @@ discard block |
||
80 | 81 | |
81 | 82 | // Grab document regardless of publish status |
82 | 83 | $doc = $modx->getPageInfo($parent_id, 0, 'id,parent,published'); |
83 | - if ($doc['parent'] != 0 && !$doc['published']) |
|
84 | - continue; // hide unpublished docs if we're not at the top |
|
84 | + if ($doc['parent'] != 0 && !$doc['published']) { |
|
85 | + continue; |
|
86 | + } |
|
87 | + // hide unpublished docs if we're not at the top |
|
85 | 88 | |
86 | 89 | $tv = $modx->getTemplateVar($name, '*', $doc['id'], $doc['published']); |
87 | 90 | |
@@ -129,10 +132,13 @@ discard block |
||
129 | 132 | * @param $file |
130 | 133 | * @return string |
131 | 134 | */ |
132 | -function ProcessFile($file) { |
|
135 | +function ProcessFile($file) |
|
136 | +{ |
|
133 | 137 | // get the file |
134 | 138 | $buffer = @file_get_contents($file); |
135 | - if ($buffer === false) $buffer = " Could not retrieve document '$file'."; |
|
139 | + if ($buffer === false) { |
|
140 | + $buffer = " Could not retrieve document '$file'."; |
|
141 | + } |
|
136 | 142 | return $buffer; |
137 | 143 | } |
138 | 144 | |
@@ -146,10 +152,8 @@ discard block |
||
146 | 152 | { |
147 | 153 | global $BINDINGS; |
148 | 154 | $binding_array = array(); |
149 | - foreach($BINDINGS as $cmd) |
|
150 | - { |
|
151 | - if(strpos($binding_string,'@'.$cmd)===0) |
|
152 | - { |
|
155 | + foreach($BINDINGS as $cmd) { |
|
156 | + if(strpos($binding_string,'@'.$cmd)===0) { |
|
153 | 157 | $code = substr($binding_string,strlen($cmd)+1); |
154 | 158 | $binding_array = array($cmd,trim($code)); |
155 | 159 | break; |
@@ -356,7 +356,8 @@ discard block |
||
356 | 356 | * @param string $pwd |
357 | 357 | * @param string $ufn |
358 | 358 | */ |
359 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
359 | +function sendMailMessage($email, $uid, $pwd, $ufn) |
|
360 | +{ |
|
360 | 361 | global $modx, $_lang, $signupemail_message; |
361 | 362 | global $emailsubject, $emailsender; |
362 | 363 | global $site_name; |
@@ -389,7 +390,8 @@ discard block |
||
389 | 390 | * |
390 | 391 | * @param int $id |
391 | 392 | */ |
392 | -function saveUserSettings($id) { |
|
393 | +function saveUserSettings($id) |
|
394 | +{ |
|
393 | 395 | global $modx; |
394 | 396 | $tbl_user_settings = $modx->getFullTableName('user_settings'); |
395 | 397 | |
@@ -477,7 +479,8 @@ discard block |
||
477 | 479 | * |
478 | 480 | * @param $msg |
479 | 481 | */ |
480 | -function webAlertAndQuit($msg) { |
|
482 | +function webAlertAndQuit($msg) |
|
483 | +{ |
|
481 | 484 | global $id, $modx; |
482 | 485 | $mode = $_POST['mode']; |
483 | 486 | $modx->manager->saveFormValues($mode); |
@@ -490,7 +493,8 @@ discard block |
||
490 | 493 | * @param int $length |
491 | 494 | * @return string |
492 | 495 | */ |
493 | -function generate_password($length = 10) { |
|
496 | +function generate_password($length = 10) |
|
497 | +{ |
|
494 | 498 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
495 | 499 | $ps_len = strlen($allowable_characters); |
496 | 500 | mt_srand((double) microtime() * 1000000); |
@@ -79,7 +79,8 @@ discard block |
||
79 | 79 | * @return string |
80 | 80 | */ |
81 | 81 | public function getParents($id, $path = '') |
82 | - { // modx:returns child's parent |
|
82 | + { |
|
83 | +// modx:returns child's parent |
|
83 | 84 | global $modx; |
84 | 85 | if (empty($this->aliases)) { |
85 | 86 | $f = "id, IF(alias='', id, alias) AS alias, parent, alias_visible"; |
@@ -456,7 +457,8 @@ discard block |
||
456 | 457 | $_ = trim($_); |
457 | 458 | } |
458 | 459 | $lastChar = substr($_, -1); |
459 | - if (!in_array($lastChar, $chars)) {// ,320,327,288,284,289 |
|
460 | + if (!in_array($lastChar, $chars)) { |
|
461 | +// ,320,327,288,284,289 |
|
460 | 462 | if (!in_array($prev_token, |
461 | 463 | array(T_FOREACH, T_WHILE, T_FOR, T_BOOLEAN_AND, T_BOOLEAN_OR, T_DOUBLE_ARROW))) { |
462 | 464 | $_ .= ' '; |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @return string |
18 | 18 | */ |
19 | -function createGUID(){ |
|
19 | +function createGUID() |
|
20 | +{ |
|
20 | 21 | srand((double)microtime()*1000000); |
21 | 22 | $r = rand() ; |
22 | 23 | $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1); |
@@ -27,8 +28,11 @@ discard block |
||
27 | 28 | // count duplicates |
28 | 29 | $name = $modx->db->getValue($modx->db->select('name', $modx->getFullTableName('site_modules'), "id='{$id}'")); |
29 | 30 | $count = $modx->db->getRecordCount($modx->db->select('name', $modx->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
30 | -if($count>=1) $count = ' '.($count+1); |
|
31 | -else $count = ''; |
|
31 | +if($count>=1) { |
|
32 | + $count = ' '.($count+1); |
|
33 | +} else { |
|
34 | + $count = ''; |
|
35 | +} |
|
32 | 36 | |
33 | 37 | // duplicate module |
34 | 38 | $newid = $modx->db->insert( |
@@ -296,7 +296,8 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @param string $msg |
298 | 298 | */ |
299 | -function jsAlert($msg) { |
|
299 | +function jsAlert($msg) |
|
300 | +{ |
|
300 | 301 | global $modx; |
301 | 302 | if($_POST['ajax'] != 1) { |
302 | 303 | echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>"; |
@@ -311,7 +312,8 @@ discard block |
||
311 | 312 | * @param string $dbasePassword |
312 | 313 | * @return bool |
313 | 314 | */ |
314 | -function login($username, $givenPassword, $dbasePassword) { |
|
315 | +function login($username, $givenPassword, $dbasePassword) |
|
316 | +{ |
|
315 | 317 | global $modx; |
316 | 318 | return $modx->phpass->CheckPassword($givenPassword, $dbasePassword); |
317 | 319 | } |
@@ -323,7 +325,8 @@ discard block |
||
323 | 325 | * @param string $username |
324 | 326 | * @return bool |
325 | 327 | */ |
326 | -function loginV1($internalKey, $givenPassword, $dbasePassword, $username) { |
|
328 | +function loginV1($internalKey, $givenPassword, $dbasePassword, $username) |
|
329 | +{ |
|
327 | 330 | global $modx; |
328 | 331 | |
329 | 332 | $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey); |
@@ -353,7 +356,8 @@ discard block |
||
353 | 356 | * @param string $username |
354 | 357 | * @return bool |
355 | 358 | */ |
356 | -function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) { |
|
359 | +function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) |
|
360 | +{ |
|
357 | 361 | global $modx; |
358 | 362 | |
359 | 363 | if($dbasePassword != md5($givenPassword)) { |
@@ -367,7 +371,8 @@ discard block |
||
367 | 371 | * @param string $username |
368 | 372 | * @param string $password |
369 | 373 | */ |
370 | -function updateNewHash($username, $password) { |
|
374 | +function updateNewHash($username, $password) |
|
375 | +{ |
|
371 | 376 | global $modx; |
372 | 377 | |
373 | 378 | $field = array(); |
@@ -381,16 +386,19 @@ discard block |
||
381 | 386 | * @param int $failed_allowed |
382 | 387 | * @param int $blocked_minutes |
383 | 388 | */ |
384 | -function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) { |
|
389 | +function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) |
|
390 | +{ |
|
385 | 391 | global $modx; |
386 | 392 | |
387 | 393 | $failedlogins += 1; |
388 | 394 | |
389 | 395 | $fields = array('failedlogincount' => $failedlogins); |
390 | - if($failedlogins >= $failed_allowed) //block user for too many fail attempts |
|
396 | + if($failedlogins >= $failed_allowed) { |
|
397 | + //block user for too many fail attempts |
|
391 | 398 | { |
392 | 399 | $fields['blockeduntil'] = time() + ($blocked_minutes * 60); |
393 | 400 | } |
401 | + } |
|
394 | 402 | |
395 | 403 | $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); |
396 | 404 |
@@ -47,7 +47,8 @@ |
||
47 | 47 | /** |
48 | 48 | * @param int $parent |
49 | 49 | */ |
50 | -function getChildren($parent) { |
|
50 | +function getChildren($parent) |
|
51 | +{ |
|
51 | 52 | |
52 | 53 | global $modx; |
53 | 54 | global $children; |
@@ -17,10 +17,14 @@ discard block |
||
17 | 17 | $pth = str_replace("\\","/",$pth); |
18 | 18 | if(isset($_GET["rminstall"])) { |
19 | 19 | if(is_dir($pth)) { |
20 | - if(!rmdirRecursive($pth)) $msg="An error occured while attempting to remove the install folder"; |
|
20 | + if(!rmdirRecursive($pth)) { |
|
21 | + $msg="An error occured while attempting to remove the install folder"; |
|
22 | + } |
|
21 | 23 | } |
22 | 24 | } |
23 | -if($msg) echo "<script>alert('".addslashes($msg)."');</script>"; |
|
25 | +if($msg) { |
|
26 | + echo "<script>alert('".addslashes($msg)."');</script>"; |
|
27 | +} |
|
24 | 28 | echo "<script>window.location='../index.php?a=2';</script>"; |
25 | 29 | |
26 | 30 | /** |
@@ -30,13 +34,13 @@ discard block |
||
30 | 34 | * @param bool $followLinks |
31 | 35 | * @return bool |
32 | 36 | */ |
33 | -function rmdirRecursive($path, $followLinks=false) { |
|
37 | +function rmdirRecursive($path, $followLinks=false) |
|
38 | +{ |
|
34 | 39 | $dir = opendir($path) ; |
35 | 40 | while ($entry = readdir($dir)) { |
36 | 41 | if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) { |
37 | 42 | @unlink( "$path/$entry" ); |
38 | - } |
|
39 | - elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
43 | + } elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
40 | 44 | rmdirRecursive("$path/$entry"); // recursive |
41 | 45 | } |
42 | 46 | } |
@@ -42,7 +42,8 @@ discard block |
||
42 | 42 | * @param int $_toplevel |
43 | 43 | * @return int |
44 | 44 | */ |
45 | -function duplicateDocument($docid, $parent=null, $_toplevel=0) { |
|
45 | +function duplicateDocument($docid, $parent=null, $_toplevel=0) |
|
46 | +{ |
|
46 | 47 | global $modx, $_lang; |
47 | 48 | |
48 | 49 | // invoke OnBeforeDocDuplicate event |
@@ -63,8 +64,7 @@ discard block |
||
63 | 64 | $content = $modx->db->getRow($rs); |
64 | 65 | |
65 | 66 | // Handle incremental ID |
66 | - switch($modx->config['docid_incrmnt_method']) |
|
67 | - { |
|
67 | + switch($modx->config['docid_incrmnt_method']) { |
|
68 | 68 | case '1': |
69 | 69 | $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; |
70 | 70 | $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); |
@@ -85,8 +85,11 @@ discard block |
||
85 | 85 | $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); |
86 | 86 | $pagetitle = $modx->db->escape($pagetitle); |
87 | 87 | $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); |
88 | - if($count>=1) $count = ' '.($count+1); |
|
89 | - else $count = ''; |
|
88 | + if($count>=1) { |
|
89 | + $count = ' '.($count+1); |
|
90 | + } else { |
|
91 | + $count = ''; |
|
92 | + } |
|
90 | 93 | |
91 | 94 | $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle']; |
92 | 95 | $content['alias'] = null; |
@@ -95,7 +98,9 @@ discard block |
||
95 | 98 | } |
96 | 99 | |
97 | 100 | // change the parent accordingly |
98 | - if ($parent !== null) $content['parent'] = $parent; |
|
101 | + if ($parent !== null) { |
|
102 | + $content['parent'] = $parent; |
|
103 | + } |
|
99 | 104 | |
100 | 105 | // Change the author |
101 | 106 | $content['createdby'] = $userID; |
@@ -135,8 +140,9 @@ discard block |
||
135 | 140 | // Start duplicating all the child documents that aren't deleted. |
136 | 141 | $_toplevel++; |
137 | 142 | $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC'); |
138 | - while ($row = $modx->db->getRow($rs)) |
|
139 | - duplicateDocument($row['id'], $newparent, $_toplevel); |
|
143 | + while ($row = $modx->db->getRow($rs)) { |
|
144 | + duplicateDocument($row['id'], $newparent, $_toplevel); |
|
145 | + } |
|
140 | 146 | |
141 | 147 | // return the new doc id |
142 | 148 | return $newparent; |
@@ -148,7 +154,8 @@ discard block |
||
148 | 154 | * @param int $oldid |
149 | 155 | * @param int $newid |
150 | 156 | */ |
151 | -function duplicateTVs($oldid, $newid){ |
|
157 | +function duplicateTVs($oldid, $newid) |
|
158 | +{ |
|
152 | 159 | global $modx; |
153 | 160 | |
154 | 161 | $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues'); |
@@ -168,7 +175,8 @@ discard block |
||
168 | 175 | * @param int $oldid |
169 | 176 | * @param int $newid |
170 | 177 | */ |
171 | -function duplicateAccess($oldid, $newid){ |
|
178 | +function duplicateAccess($oldid, $newid) |
|
179 | +{ |
|
172 | 180 | global $modx; |
173 | 181 | |
174 | 182 | $tbldg = $modx->getFullTableName('document_groups'); |