@@ -293,7 +293,8 @@ |
||
| 293 | 293 | </form> |
| 294 | 294 | |
| 295 | 295 | <?php |
| 296 | -function render_form($name, $label, $status = '') { |
|
| 296 | +function render_form($name, $label, $status = '') |
|
| 297 | +{ |
|
| 297 | 298 | global $modx, $roledata; |
| 298 | 299 | |
| 299 | 300 | $tpl = '<label class="d-block" for="[+name+]check"> |
@@ -29,10 +29,12 @@ |
||
| 29 | 29 | |
| 30 | 30 | <div class="tab-page"> |
| 31 | 31 | <div class="container container-body"> |
| 32 | - <?php if($num_rows_pub) printf('<p>' . $_lang["refresh_published"] . '</p>', $num_rows_pub) ?> |
|
| 32 | + <?php if($num_rows_pub) { |
|
| 33 | + printf('<p>' . $_lang["refresh_published"] . '</p>', $num_rows_pub) ?> |
|
| 33 | 34 | <?php if($num_rows_unpub) printf('<p>' . $_lang["refresh_unpublished"] . '</p>', $num_rows_unpub) ?> |
| 34 | 35 | <?php |
| 35 | 36 | $modx->clearCache('full', true); |
| 37 | +} |
|
| 36 | 38 | // invoke OnSiteRefresh event |
| 37 | 39 | $modx->invokeEvent("OnSiteRefresh"); |
| 38 | 40 | ?> |
@@ -177,7 +177,9 @@ discard block |
||
| 177 | 177 | // save selected system events |
| 178 | 178 | $formEventList = array(); |
| 179 | 179 | foreach ($sysevents as $evtId) { |
| 180 | - if(!preg_match('@^[1-9][0-9]*$@',$evtId)) $evtId = getEventIdByName($evtId); |
|
| 180 | + if(!preg_match('@^[1-9][0-9]*$@',$evtId)) { |
|
| 181 | + $evtId = getEventIdByName($evtId); |
|
| 182 | + } |
|
| 181 | 183 | if ($mode == '101') { |
| 182 | 184 | $rs = $modx->db->select('max(priority) as priority', '[+prefix+]site_plugin_events', "evtid='{$evtId}'"); |
| 183 | 185 | } else { |
@@ -203,10 +205,14 @@ discard block |
||
| 203 | 205 | $dbEventList = array(); |
| 204 | 206 | $del = array(); |
| 205 | 207 | while($row = $modx->db->getRow($rs)) { |
| 206 | - if(!in_array($row['evtid'], $evtids)) $del[] = $row['evtid']; |
|
| 208 | + if(!in_array($row['evtid'], $evtids)) { |
|
| 209 | + $del[] = $row['evtid']; |
|
| 210 | + } |
|
| 207 | 211 | } |
| 208 | 212 | |
| 209 | - if(!$del) return; |
|
| 213 | + if(!$del) { |
|
| 214 | + return; |
|
| 215 | + } |
|
| 210 | 216 | |
| 211 | 217 | foreach($del as $delid) { |
| 212 | 218 | $modx->db->delete('[+prefix+]site_plugin_events', sprintf("evtid='%s' AND pluginid='%s'", $delid, $id)); |
@@ -218,7 +224,9 @@ discard block |
||
| 218 | 224 | global $modx; |
| 219 | 225 | static $eventIds=array(); |
| 220 | 226 | |
| 221 | - if(isset($eventIds[$name])) return $eventIds[$name]; |
|
| 227 | + if(isset($eventIds[$name])) { |
|
| 228 | + return $eventIds[$name]; |
|
| 229 | + } |
|
| 222 | 230 | |
| 223 | 231 | $rs = $modx->db->select('id, name', '[+prefix+]system_eventnames'); |
| 224 | 232 | while ($row = $modx->db->getRow($rs)) { |
@@ -1,13 +1,15 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class udperms{ |
|
| 3 | +class udperms |
|
| 4 | +{ |
|
| 4 | 5 | |
| 5 | 6 | var $user; |
| 6 | 7 | var $document; |
| 7 | 8 | var $role; |
| 8 | 9 | var $duplicateDoc = false; |
| 9 | 10 | |
| 10 | - function checkPermissions() { |
|
| 11 | + function checkPermissions() |
|
| 12 | + { |
|
| 11 | 13 | |
| 12 | 14 | global $udperms_allowroot; |
| 13 | 15 | global $modx; |
@@ -28,7 +30,10 @@ discard block |
||
| 28 | 30 | } |
| 29 | 31 | |
| 30 | 32 | $parent = $modx->db->getValue($modx->db->select('parent', $tblsc, "id='{$this->document}'")); |
| 31 | - if($document == 0 && $parent == NULL && $udperms_allowroot == 1) return true; // User is allowed to create new document in root |
|
| 33 | + if($document == 0 && $parent == NULL && $udperms_allowroot == 1) { |
|
| 34 | + return true; |
|
| 35 | + } |
|
| 36 | + // User is allowed to create new document in root |
|
| 32 | 37 | if (($this->duplicateDoc==true || $document==0) && $parent==0 && $udperms_allowroot==0) { |
| 33 | 38 | return false; // deny duplicate || create new document at root if Allow Root is No |
| 34 | 39 | } |
@@ -56,7 +61,9 @@ discard block |
||
| 56 | 61 | "sc.id='{$this->document}' AND (". ( (!$docgrp) ? null : "dg.document_group = ".$docgrp." ||" ) . " sc.privatemgr = 0)" |
| 57 | 62 | ); |
| 58 | 63 | $limit = $modx->db->getValue($rs); |
| 59 | - if($limit==1) $permissionsok = true; |
|
| 64 | + if($limit==1) { |
|
| 65 | + $permissionsok = true; |
|
| 66 | + } |
|
| 60 | 67 | |
| 61 | 68 | return $permissionsok; |
| 62 | 69 | } |
@@ -46,7 +46,8 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | function getParents($id, $path = '') |
| 49 | - { // modx:returns child's parent |
|
| 49 | + { |
|
| 50 | +// modx:returns child's parent |
|
| 50 | 51 | global $modx; |
| 51 | 52 | if (empty($this->aliases)) { |
| 52 | 53 | $f = "id, IF(alias='', id, alias) AS alias, parent, alias_visible"; |
@@ -403,7 +404,8 @@ discard block |
||
| 403 | 404 | $_ = trim($_); |
| 404 | 405 | } |
| 405 | 406 | $lastChar = substr($_, -1); |
| 406 | - if (!in_array($lastChar, $chars)) {// ,320,327,288,284,289 |
|
| 407 | + if (!in_array($lastChar, $chars)) { |
|
| 408 | +// ,320,327,288,284,289 |
|
| 407 | 409 | if (!in_array($prev_token, array(T_FOREACH, T_WHILE, T_FOR, T_BOOLEAN_AND, T_BOOLEAN_OR, T_DOUBLE_ARROW))) { |
| 408 | 410 | $_ .= ' '; |
| 409 | 411 | } |
@@ -349,7 +349,8 @@ discard block |
||
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | // Send an email to the user |
| 352 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
| 352 | +function sendMailMessage($email, $uid, $pwd, $ufn) |
|
| 353 | +{ |
|
| 353 | 354 | global $modx, $_lang, $signupemail_message; |
| 354 | 355 | global $emailsubject, $emailsender; |
| 355 | 356 | global $site_name; |
@@ -378,7 +379,8 @@ discard block |
||
| 378 | 379 | } |
| 379 | 380 | |
| 380 | 381 | // Save User Settings |
| 381 | -function saveUserSettings($id) { |
|
| 382 | +function saveUserSettings($id) |
|
| 383 | +{ |
|
| 382 | 384 | global $modx; |
| 383 | 385 | $tbl_user_settings = $modx->getFullTableName('user_settings'); |
| 384 | 386 | |
@@ -462,7 +464,8 @@ discard block |
||
| 462 | 464 | } |
| 463 | 465 | |
| 464 | 466 | // Web alert - sends an alert to web browser |
| 465 | -function webAlertAndQuit($msg) { |
|
| 467 | +function webAlertAndQuit($msg) |
|
| 468 | +{ |
|
| 466 | 469 | global $id, $modx; |
| 467 | 470 | $mode = $_POST['mode']; |
| 468 | 471 | $modx->manager->saveFormValues($mode); |
@@ -470,7 +473,8 @@ discard block |
||
| 470 | 473 | } |
| 471 | 474 | |
| 472 | 475 | // Generate password |
| 473 | -function generate_password($length = 10) { |
|
| 476 | +function generate_password($length = 10) |
|
| 477 | +{ |
|
| 474 | 478 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 475 | 479 | $ps_len = strlen($allowable_characters); |
| 476 | 480 | mt_srand((double) microtime() * 1000000); |
@@ -17,20 +17,24 @@ |
||
| 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 | // rmdirRecursive - detects symbollic links on unix |
| 27 | -function rmdirRecursive($path,$followLinks=false) { |
|
| 31 | +function rmdirRecursive($path,$followLinks=false) |
|
| 32 | +{ |
|
| 28 | 33 | $dir = opendir($path) ; |
| 29 | - while ($entry = readdir($dir)) { |
|
| 34 | + while ($entry = readdir($dir)) { |
|
| 30 | 35 | if (is_file("$path/$entry") || ((!$followLinks) && is_link("$path/$entry"))) { |
| 31 | 36 | @unlink( "$path/$entry" ); |
| 32 | - } |
|
| 33 | - elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 37 | + } elseif (is_dir("$path/$entry") && $entry!='.' && $entry!='..') { |
|
| 34 | 38 | rmdirRecursive("$path/$entry"); // recursive |
| 35 | 39 | } |
| 36 | 40 | } |
@@ -335,7 +335,8 @@ discard block |
||
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | // in case any plugins include a quoted_printable function |
| 338 | -function save_user_quoted_printable($string) { |
|
| 338 | +function save_user_quoted_printable($string) |
|
| 339 | +{ |
|
| 339 | 340 | $crlf = "\n"; |
| 340 | 341 | $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf; |
| 341 | 342 | $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e'; |
@@ -347,7 +348,8 @@ discard block |
||
| 347 | 348 | } |
| 348 | 349 | |
| 349 | 350 | // Send an email to the user |
| 350 | -function sendMailMessage($email, $uid, $pwd, $ufn) { |
|
| 351 | +function sendMailMessage($email, $uid, $pwd, $ufn) |
|
| 352 | +{ |
|
| 351 | 353 | global $modx, $_lang, $websignupemail_message; |
| 352 | 354 | global $emailsubject, $emailsender; |
| 353 | 355 | global $site_name, $site_url; |
@@ -375,7 +377,8 @@ discard block |
||
| 375 | 377 | } |
| 376 | 378 | |
| 377 | 379 | // Save User Settings |
| 378 | -function saveUserSettings($id) { |
|
| 380 | +function saveUserSettings($id) |
|
| 381 | +{ |
|
| 379 | 382 | global $modx; |
| 380 | 383 | $tbl_web_user_settings = $modx->getFullTableName('web_user_settings'); |
| 381 | 384 | |
@@ -404,7 +407,8 @@ discard block |
||
| 404 | 407 | } |
| 405 | 408 | |
| 406 | 409 | // Web alert - sends an alert to web browser |
| 407 | -function webAlertAndQuit($msg) { |
|
| 410 | +function webAlertAndQuit($msg) |
|
| 411 | +{ |
|
| 408 | 412 | global $id, $modx; |
| 409 | 413 | $mode = $_POST['mode']; |
| 410 | 414 | $modx->manager->saveFormValues($mode); |
@@ -412,7 +416,8 @@ discard block |
||
| 412 | 416 | } |
| 413 | 417 | |
| 414 | 418 | // Generate password |
| 415 | -function generate_password($length = 10) { |
|
| 419 | +function generate_password($length = 10) |
|
| 420 | +{ |
|
| 416 | 421 | $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"; |
| 417 | 422 | $ps_len = strlen($allowable_characters); |
| 418 | 423 | mt_srand((double) microtime() * 1000000); |
@@ -423,7 +428,8 @@ discard block |
||
| 423 | 428 | return $pass; |
| 424 | 429 | } |
| 425 | 430 | |
| 426 | -function sanitize($str = '', $safecount = 0) { |
|
| 431 | +function sanitize($str = '', $safecount = 0) |
|
| 432 | +{ |
|
| 427 | 433 | global $modx; |
| 428 | 434 | $safecount++; |
| 429 | 435 | if(1000 < $safecount) { |
@@ -292,7 +292,8 @@ discard block |
||
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | // show javascript alert |
| 295 | -function jsAlert($msg) { |
|
| 295 | +function jsAlert($msg) |
|
| 296 | +{ |
|
| 296 | 297 | global $modx; |
| 297 | 298 | if($_POST['ajax'] != 1) { |
| 298 | 299 | echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>"; |
@@ -301,12 +302,14 @@ discard block |
||
| 301 | 302 | } |
| 302 | 303 | } |
| 303 | 304 | |
| 304 | -function login($username, $givenPassword, $dbasePassword) { |
|
| 305 | +function login($username, $givenPassword, $dbasePassword) |
|
| 306 | +{ |
|
| 305 | 307 | global $modx; |
| 306 | 308 | return $modx->phpass->CheckPassword($givenPassword, $dbasePassword); |
| 307 | 309 | } |
| 308 | 310 | |
| 309 | -function loginV1($internalKey, $givenPassword, $dbasePassword, $username) { |
|
| 311 | +function loginV1($internalKey, $givenPassword, $dbasePassword, $username) |
|
| 312 | +{ |
|
| 310 | 313 | global $modx; |
| 311 | 314 | |
| 312 | 315 | $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey); |
@@ -329,7 +332,8 @@ discard block |
||
| 329 | 332 | return true; |
| 330 | 333 | } |
| 331 | 334 | |
| 332 | -function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) { |
|
| 335 | +function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) |
|
| 336 | +{ |
|
| 333 | 337 | global $modx; |
| 334 | 338 | |
| 335 | 339 | if($dbasePassword != md5($givenPassword)) { |
@@ -339,7 +343,8 @@ discard block |
||
| 339 | 343 | return true; |
| 340 | 344 | } |
| 341 | 345 | |
| 342 | -function updateNewHash($username, $password) { |
|
| 346 | +function updateNewHash($username, $password) |
|
| 347 | +{ |
|
| 343 | 348 | global $modx; |
| 344 | 349 | |
| 345 | 350 | $field = array(); |
@@ -347,16 +352,19 @@ discard block |
||
| 347 | 352 | $modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'"); |
| 348 | 353 | } |
| 349 | 354 | |
| 350 | -function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) { |
|
| 355 | +function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) |
|
| 356 | +{ |
|
| 351 | 357 | global $modx; |
| 352 | 358 | |
| 353 | 359 | $failedlogins += 1; |
| 354 | 360 | |
| 355 | 361 | $fields = array('failedlogincount' => $failedlogins); |
| 356 | - if($failedlogins >= $failed_allowed) //block user for too many fail attempts |
|
| 362 | + if($failedlogins >= $failed_allowed) { |
|
| 363 | + //block user for too many fail attempts |
|
| 357 | 364 | { |
| 358 | 365 | $fields['blockeduntil'] = time() + ($blocked_minutes * 60); |
| 359 | 366 | } |
| 367 | + } |
|
| 360 | 368 | |
| 361 | 369 | $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); |
| 362 | 370 | |