@@ -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'); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // check if user has access permission, except admins |
| 15 | -if($_SESSION['mgrRole']!=1){ |
|
| 15 | +if($_SESSION['mgrRole']!=1) { |
|
| 16 | 16 | $rs = $modx->db->select( |
| 17 | 17 | 'sma.usergroup,mg.member', |
| 18 | 18 | $modx->getFullTableName("site_module_access")." sma |
@@ -70,7 +70,8 @@ discard block |
||
| 70 | 70 | * @param array $params |
| 71 | 71 | * @return string |
| 72 | 72 | */ |
| 73 | -function evalModule($moduleCode,$params){ |
|
| 73 | +function evalModule($moduleCode,$params) |
|
| 74 | +{ |
|
| 74 | 75 | global $modx; |
| 75 | 76 | $modx->event->params = &$params; // store params inside event object |
| 76 | 77 | if(is_array($params)) { |
@@ -80,11 +81,9 @@ discard block |
||
| 80 | 81 | $mod = eval($moduleCode); |
| 81 | 82 | $msg = ob_get_contents(); |
| 82 | 83 | ob_end_clean(); |
| 83 | - if (isset($php_errormsg)) |
|
| 84 | - { |
|
| 84 | + if (isset($php_errormsg)) { |
|
| 85 | 85 | $error_info = error_get_last(); |
| 86 | - switch($error_info['type']) |
|
| 87 | - { |
|
| 86 | + switch($error_info['type']) { |
|
| 88 | 87 | case E_NOTICE : |
| 89 | 88 | $error_level = 1; |
| 90 | 89 | case E_USER_NOTICE : |
@@ -97,8 +96,7 @@ discard block |
||
| 97 | 96 | default: |
| 98 | 97 | $error_level = 99; |
| 99 | 98 | } |
| 100 | - if($modx->config['error_reporting']==='99' || 2<$error_level) |
|
| 101 | - { |
|
| 99 | + if($modx->config['error_reporting']==='99' || 2<$error_level) { |
|
| 102 | 100 | $modx->messageQuit('PHP Parse Error', '', true, $error_info['type'], $error_info['file'], $_SESSION['itemname'] . ' - Module', $error_info['message'], $error_info['line'], $msg); |
| 103 | 101 | $modx->event->alert("An error occurred while loading. Please see the event log for more information<p>{$msg}</p>"); |
| 104 | 102 | } |
@@ -12,12 +12,20 @@ discard block |
||
| 12 | 12 | // ok, two things to check. |
| 13 | 13 | // first, document cannot be moved to itself |
| 14 | 14 | // second, new parent must be a folder. If not, set it to folder. |
| 15 | -if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 16 | -if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 17 | -if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 15 | +if($documentID==$newParentID) { |
|
| 16 | + $modx->webAlertAndQuit($_lang["error_movedocument1"]); |
|
| 17 | +} |
|
| 18 | +if($documentID <= 0) { |
|
| 19 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 20 | +} |
|
| 21 | +if($newParentID < 0) { |
|
| 22 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 23 | +} |
|
| 18 | 24 | |
| 19 | 25 | $parents = $modx->getParentIds($newParentID); |
| 20 | -if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 26 | +if (in_array($documentID, $parents)) { |
|
| 27 | + $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
|
| 28 | +} |
|
| 21 | 29 | |
| 22 | 30 | $rs = $modx->db->select('parent', $modx->getFullTableName('site_content'), "id='{$documentID}'"); |
| 23 | 31 | $oldparent = $modx->db->getValue($rs); |
@@ -42,7 +50,8 @@ discard block |
||
| 42 | 50 | * @param int $currDocID |
| 43 | 51 | * @return array |
| 44 | 52 | */ |
| 45 | -function allChildren($currDocID) { |
|
| 53 | +function allChildren($currDocID) |
|
| 54 | +{ |
|
| 46 | 55 | global $modx; |
| 47 | 56 | $children= array(); |
| 48 | 57 | $currDocID = $modx->db->escape($currDocID); |
@@ -59,11 +68,11 @@ discard block |
||
| 59 | 68 | "old_parent" => $oldparent, |
| 60 | 69 | "new_parent" => $newParentID |
| 61 | 70 | )); |
| 62 | -if (is_array($evtOut) && count($evtOut) > 0){ |
|
| 71 | +if (is_array($evtOut) && count($evtOut) > 0) { |
|
| 63 | 72 | $newParent = array_pop($evtOut); |
| 64 | 73 | if($newParent == $oldparent) { |
| 65 | 74 | $modx->webAlertAndQuit($_lang["error_movedocument2"]); |
| 66 | - }else{ |
|
| 75 | + } else { |
|
| 67 | 76 | $newParentID = $newParent; |
| 68 | 77 | } |
| 69 | 78 | } |