Completed
Pull Request — develop (#545)
by Agel_Nash
05:36
created
manager/includes/document.parser.class.inc.php 1 patch
Doc Comments   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      * MODX_MANAGER_PATH."includes/extenders/ex_{$extname}.inc.php"
278 278
      * $extname - extension name in lowercase
279 279
      *
280
-     * @param $extname
280
+     * @param string $extname
281 281
      * @param bool $reload
282 282
      * @return bool
283 283
      */
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
      * @param int $count_attempts
321 321
      * @param string $type $type
322 322
      * @param string $responseCode
323
-     * @return bool|null
323
+     * @return false|null
324 324
      * @global string $base_url
325 325
      * @global string $site_url
326 326
      */
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
     }
1022 1022
 
1023 1023
     /**
1024
-     * @param $contents
1024
+     * @param string $contents
1025 1025
      * @return mixed
1026 1026
      */
1027 1027
     public function RecoveryEscapedTags($contents)
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
     }
1046 1046
 
1047 1047
     /**
1048
-     * @param $tstart
1048
+     * @param double $tstart
1049 1049
      * @return array
1050 1050
      */
1051 1051
     public function getTimerStats($tstart)
@@ -1797,7 +1797,7 @@  discard block
 block discarded – undo
1797 1797
 
1798 1798
     /**
1799 1799
      * Remove Comment-Tags from output like <!--@- Comment -@-->
1800
-     * @param $content
1800
+     * @param string $content
1801 1801
      * @param string $left
1802 1802
      * @param string $right
1803 1803
      * @return mixed
@@ -1970,7 +1970,7 @@  discard block
 block discarded – undo
1970 1970
     /**
1971 1971
      * Run snippets as per the tags in $documentSource and replace the tags with the returned values.
1972 1972
      *
1973
-     * @param $content
1973
+     * @param string $content
1974 1974
      * @return string
1975 1975
      * @internal param string $documentSource
1976 1976
      */
@@ -3002,7 +3002,7 @@  discard block
 block discarded – undo
3002 3002
 
3003 3003
     /**
3004 3004
      * @param $templateID
3005
-     * @return mixed
3005
+     * @return string
3006 3006
      */
3007 3007
     public function _getTemplateCodeFromDB($templateID)
3008 3008
     {
@@ -3043,9 +3043,9 @@  discard block
 block discarded – undo
3043 3043
     }
3044 3044
 
3045 3045
     /**
3046
-     * @param $id
3046
+     * @param integer $id
3047 3047
      * @param int $top
3048
-     * @return mixed
3048
+     * @return string
3049 3049
      */
3050 3050
     public function getUltimateParentId($id, $top = 0)
3051 3051
     {
@@ -3376,7 +3376,7 @@  discard block
 block discarded – undo
3376 3376
      *
3377 3377
      * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role
3378 3378
      * @param int $id Element- / Resource-id
3379
-     * @return bool
3379
+     * @return false|null
3380 3380
      */
3381 3381
     public function lockElement($type, $id)
3382 3382
     {
@@ -3398,7 +3398,7 @@  discard block
 block discarded – undo
3398 3398
      * @param int $type Types: 1=template, 2=tv, 3=chunk, 4=snippet, 5=plugin, 6=module, 7=resource, 8=role
3399 3399
      * @param int $id Element- / Resource-id
3400 3400
      * @param bool $includeAllUsers true = Deletes not only own user-locks
3401
-     * @return bool
3401
+     * @return false|null
3402 3402
      */
3403 3403
     public function unlockElement($type, $id, $includeAllUsers = false)
3404 3404
     {
@@ -3506,7 +3506,7 @@  discard block
 block discarded – undo
3506 3506
      * @param array $params
3507 3507
      * @param string $msg
3508 3508
      * @param array $files
3509
-     * @return mixed
3509
+     * @return boolean
3510 3510
      */
3511 3511
     public function sendmail($params = array(), $msg = '', $files = array())
3512 3512
     {
@@ -3910,7 +3910,7 @@  discard block
 block discarded – undo
3910 3910
      *                     Default: 1
3911 3911
      * @param string $fields List of fields
3912 3912
      *                       Default: id, pagetitle, description, alias
3913
-     * @return boolean|array
3913
+     * @return string
3914 3914
      */
3915 3915
     public function getPageInfo($pageid = -1, $active = 1, $fields = 'id, pagetitle, description, alias')
3916 3916
     {
@@ -4002,7 +4002,7 @@  discard block
 block discarded – undo
4002 4002
      *
4003 4003
      * @param string $type
4004 4004
      * @param bool $report
4005
-     * @return bool
4005
+     * @return boolean|null
4006 4006
      */
4007 4007
     public function clearCache($type = '', $report = false)
4008 4008
     {
@@ -4369,7 +4369,7 @@  discard block
 block discarded – undo
4369 4369
      * - Placeholders prefix. Default: '{'.
4370 4370
      * @param string $suffix {string}
4371 4371
      * - Placeholders suffix. Default: '}'.
4372
-     * @return bool|mixed|string {string; false} - Parsed chunk or false if $chunkArr is not array.
4372
+     * @return false|string {string; false} - Parsed chunk or false if $chunkArr is not array.
4373 4373
      * - Parsed chunk or false if $chunkArr is not array.
4374 4374
      */
4375 4375
     public function parseChunk($chunkName, $chunkArr, $prefix = '{', $suffix = '}')
@@ -5345,7 +5345,7 @@  discard block
 block discarded – undo
5345 5345
      * Remove event listener - only for use within the current execution cycle
5346 5346
      *
5347 5347
      * @param string $evtName
5348
-     * @return boolean
5348
+     * @return false|null
5349 5349
      */
5350 5350
     public function removeEventListener($evtName)
5351 5351
     {
@@ -5369,7 +5369,7 @@  discard block
 block discarded – undo
5369 5369
      *
5370 5370
      * @param string $evtName
5371 5371
      * @param array $extParams Parameters available to plugins. Each array key will be the PHP variable name, and the array value will be the variable value.
5372
-     * @return boolean|array
5372
+     * @return false|null
5373 5373
      */
5374 5374
     public function invokeEvent($evtName, $extParams = array())
5375 5375
     {
@@ -5968,7 +5968,7 @@  discard block
 block discarded – undo
5968 5968
 
5969 5969
     /**
5970 5970
      * @param string $str
5971
-     * @return bool|mixed|string
5971
+     * @return string
5972 5972
      */
5973 5973
     public function atBindFileContent($str = '')
5974 5974
     {
@@ -6019,8 +6019,8 @@  discard block
 block discarded – undo
6019 6019
     }
6020 6020
 
6021 6021
     /**
6022
-     * @param $str
6023
-     * @return bool|string
6022
+     * @param string $str
6023
+     * @return false|string
6024 6024
      */
6025 6025
     public function getExtFromFilename($str)
6026 6026
     {
@@ -6048,7 +6048,7 @@  discard block
 block discarded – undo
6048 6048
      * @param string $text Error message
6049 6049
      * @param string $file File where the error was detected
6050 6050
      * @param string $line Line number within $file
6051
-     * @return boolean
6051
+     * @return boolean|null
6052 6052
      */
6053 6053
     public function phpError($nr, $text, $file, $line)
6054 6054
     {
@@ -6100,7 +6100,7 @@  discard block
 block discarded – undo
6100 6100
      * @param string $text
6101 6101
      * @param string $line
6102 6102
      * @param string $output
6103
-     * @return bool
6103
+     * @return null|boolean
6104 6104
      */
6105 6105
     public function messageQuit($msg = 'unspecified error', $query = '', $is_error = true, $nr = '', $file = '', $source = '', $text = '', $line = '', $output = '')
6106 6106
     {
@@ -6522,7 +6522,7 @@  discard block
 block discarded – undo
6522 6522
 
6523 6523
     /**
6524 6524
      * @param string $str
6525
-     * @return bool|mixed|string
6525
+     * @return string
6526 6526
      */
6527 6527
     public function atBindInclude($str = '')
6528 6528
     {
@@ -6573,7 +6573,7 @@  discard block
 block discarded – undo
6573 6573
      * @param $str
6574 6574
      * @param int $flags
6575 6575
      * @param string $encode
6576
-     * @return mixed
6576
+     * @return string
6577 6577
      */
6578 6578
     public function htmlspecialchars($str, $flags = ENT_COMPAT, $encode = '')
6579 6579
     {
@@ -6582,7 +6582,7 @@  discard block
 block discarded – undo
6582 6582
     }
6583 6583
 
6584 6584
     /**
6585
-     * @param $string
6585
+     * @param string $string
6586 6586
      * @param bool $returnData
6587 6587
      * @return bool|mixed
6588 6588
      */
Please login to merge, or discard this patch.
manager/includes/extenders/dbapi.mysql.class.inc.php 1 patch
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -414,6 +414,9 @@  discard block
 block discarded – undo
414 414
         }
415 415
     }
416 416
 
417
+    /**
418
+     * @param string $table
419
+     */
417 420
     public function save($fields, $table, $where = '')
418 421
     {
419 422
 
@@ -444,6 +447,7 @@  discard block
 block discarded – undo
444 447
     /**
445 448
      * @name:  freeResult
446 449
      *
450
+     * @param mysqli_result $rs
447 451
      */
448 452
     public function freeResult($rs)
449 453
     {
@@ -554,6 +558,7 @@  discard block
 block discarded – undo
554 558
      * @name:  getColumn
555 559
      * @desc:  returns an array of the values found on colun $name
556 560
      * @param: $dsq - dataset or query string
561
+     * @param string $name
557 562
      */
558 563
     public function getColumn($name, $dsq)
559 564
     {
@@ -720,6 +725,9 @@  discard block
 block discarded – undo
720 725
         return $result;
721 726
     }
722 727
 
728
+    /**
729
+     * @param string $table_name
730
+     */
723 731
     public function optimize($table_name)
724 732
     {
725 733
         $rs = $this->query("OPTIMIZE TABLE {$table_name}");
@@ -730,6 +738,9 @@  discard block
 block discarded – undo
730 738
         return $rs;
731 739
     }
732 740
 
741
+    /**
742
+     * @param string $table_name
743
+     */
733 744
     public function truncate($table_name)
734 745
     {
735 746
         $rs = $this->query("TRUNCATE {$table_name}");
Please login to merge, or discard this patch.
manager/includes/extenders/dbapi.mysqli.class.inc.php 1 patch
Doc Comments   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
     }
241 241
 
242 242
     /**
243
-     * @param string|array $fields
244
-     * @param string|array $from
245
-     * @param string|array $where
243
+     * @param string $fields
244
+     * @param string $from
245
+     * @param string $where
246 246
      * @param string $orderBy
247 247
      * @param string $limit
248 248
      * @return bool|mysqli_result
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
      * @param string $fromtable
327 327
      * @param string $where
328 328
      * @param string $limit
329
-     * @return mixed
329
+     * @return null|integer
330 330
      */
331 331
     public function insert($fields, $intotable, $fromfields = "*", $fromtable = "", $where = "", $limit = "")
332 332
     {
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 
369 369
     /**
370 370
      * @param $fields
371
-     * @param $table
371
+     * @param string $table
372 372
      * @param string $where
373 373
      * @return bool|mixed|mysqli_result
374 374
      */
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 
436 436
     /**
437 437
      * @param null|mysqli $conn
438
-     * @return mixed
438
+     * @return integer
439 439
      */
440 440
     public function getInsertId($conn = null)
441 441
     {
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
     }
514 514
 
515 515
     /**
516
-     * @param $name
516
+     * @param string $name
517 517
      * @param mysqli_result|string $dsq
518 518
      * @return array
519 519
      */
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
     /**
574 574
      * @param string $table
575
-     * @return array
575
+     * @return boolean
576 576
      */
577 577
     public function getTableMetaData($table)
578 578
     {
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
     }
620 620
 
621 621
     /**
622
-     * @param string|mysqli_result $rs
622
+     * @param string $rs
623 623
      * @param bool $index
624 624
      * @return array
625 625
      */
Please login to merge, or discard this patch.
manager/includes/extenders/deprecated.functions.inc.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
      * @deprecated
73 73
      *
74 74
      * @param $rs
75
-     * @return int|mixed
75
+     * @return integer
76 76
      */
77 77
     public function insertId($rs)
78 78
     {
Please login to merge, or discard this patch.
manager/includes/extenders/modifiers.class.inc.php 1 patch
Doc Comments   +27 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     /**
95 95
      * @param string $mode
96 96
      * @param string $modifiers
97
-     * @return bool|string
97
+     * @return false|string
98 98
      */
99 99
     public function _getDelim($mode,$modifiers) {
100 100
         $c = substr($modifiers,0,1);
@@ -131,6 +131,14 @@  discard block
 block discarded – undo
131 131
             return $opt;
132 132
         }
133 133
     }
134
+
135
+    /**
136
+     * @param string $mode
137
+     * @param false|string $delim
138
+     * @param string $modifiers
139
+     *
140
+     * @return string
141
+     */
134 142
     public function _getRemainModifiers($mode,$delim,$modifiers) {
135 143
         if($delim) {
136 144
             if($mode=='(')
@@ -158,6 +166,9 @@  discard block
 block discarded – undo
158 166
         return substr($string,strpos($string, $delim)+$len);
159 167
     }
160 168
 
169
+    /**
170
+     * @param string $modifiers
171
+     */
161 172
     public function splitEachModifiers($modifiers) {
162 173
         $modx = DocumentParser::getInstance();
163 174
 
@@ -227,6 +238,10 @@  discard block
 block discarded – undo
227 238
         return $result;
228 239
     }
229 240
 
241
+    /**
242
+     * @param string $key
243
+     * @param string $value
244
+     */
230 245
     public function parsePhx($key,$value,$modifiers)
231 246
     {
232 247
         $modx = DocumentParser::getInstance();
@@ -293,6 +308,10 @@  discard block
 block discarded – undo
293 308
         else                  return true;
294 309
     }
295 310
 
311
+    /**
312
+     * @param string $cmd
313
+     * @param string $opt
314
+     */
296 315
     public function getValueFromPreset($key, $value, $cmd, $opt)
297 316
     {
298 317
         $modx = DocumentParser::getInstance();
@@ -978,6 +997,9 @@  discard block
 block discarded – undo
978 997
         return $value;
979 998
     }
980 999
 
1000
+    /**
1001
+     * @param string $cmd
1002
+     */
981 1003
     public function includeMdfFile($cmd) {
982 1004
         $modx = DocumentParser::getInstance();
983 1005
         $key = $this->key;
@@ -1133,6 +1155,10 @@  discard block
 block discarded – undo
1133 1155
     }
1134 1156
 
1135 1157
     // Sets a placeholder variable which can only be access by Modifiers
1158
+
1159
+    /**
1160
+     * @param string $value
1161
+     */
1136 1162
     public function setModifiersVariable($key, $value) {
1137 1163
         if ($key != 'phx' && $key != 'dummy') $this->placeholders[$key] = $value;
1138 1164
     }
Please login to merge, or discard this patch.
manager/processors/move_document.processor.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('edit_document')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $newParentID = isset($_REQUEST['new_parent']) ? (int)$_REQUEST['new_parent'] : 0;
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
 // check user has permission to move document to chosen location
26 26
 
27 27
 if ($use_udperms == 1) {
28
-	if ($oldparent != $newParentID) {
29
-		include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
30
-		$udperms = new udperms();
31
-		$udperms->user = $modx->getLoginUserID();
32
-		$udperms->document = $newParentID;
33
-		$udperms->role = $_SESSION['mgrRole'];
34
-
35
-		 if (!$udperms->checkPermissions()) {
36
-			$modx->webAlertAndQuit($_lang["access_permission_parent_denied"]);
37
-		 }
38
-	}
28
+    if ($oldparent != $newParentID) {
29
+        include_once MODX_MANAGER_PATH . "processors/user_documents_permissions.class.php";
30
+        $udperms = new udperms();
31
+        $udperms->user = $modx->getLoginUserID();
32
+        $udperms->document = $newParentID;
33
+        $udperms->role = $_SESSION['mgrRole'];
34
+
35
+            if (!$udperms->checkPermissions()) {
36
+            $modx->webAlertAndQuit($_lang["access_permission_parent_denied"]);
37
+            }
38
+    }
39 39
 }
40 40
 
41 41
 /**
@@ -43,67 +43,67 @@  discard block
 block discarded – undo
43 43
  * @return array
44 44
  */
45 45
 function allChildren($currDocID) {
46
-	$modx = DocumentParser::getInstance();
47
-	$children= array();
48
-	$currDocID = $modx->db->escape($currDocID);
49
-	$rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'");
50
-	while ($child= $modx->db->getRow($rs)) {
51
-		$children[]= $child['id'];
52
-		$children= array_merge($children, allChildren($child['id']));
53
-	}
54
-	return $children;
46
+    $modx = DocumentParser::getInstance();
47
+    $children= array();
48
+    $currDocID = $modx->db->escape($currDocID);
49
+    $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "parent = '{$currDocID}'");
50
+    while ($child= $modx->db->getRow($rs)) {
51
+        $children[]= $child['id'];
52
+        $children= array_merge($children, allChildren($child['id']));
53
+    }
54
+    return $children;
55 55
 }
56 56
 
57 57
 $evtOut = $modx->invokeEvent("onBeforeMoveDocument", array (
58
-	"id_document" => $documentID,
59
-	"old_parent" => $oldparent,
60
-	"new_parent" => $newParentID
58
+    "id_document" => $documentID,
59
+    "old_parent" => $oldparent,
60
+    "new_parent" => $newParentID
61 61
 ));
62 62
 if (is_array($evtOut) && count($evtOut) > 0){
63
-	$newParent = array_pop($evtOut);
64
-	if($newParent == $oldparent) {
65
-		$modx->webAlertAndQuit($_lang["error_movedocument2"]);
66
-	}else{
67
-		$newParentID = $newParent;
68
-	}
63
+    $newParent = array_pop($evtOut);
64
+    if($newParent == $oldparent) {
65
+        $modx->webAlertAndQuit($_lang["error_movedocument2"]);
66
+    }else{
67
+        $newParentID = $newParent;
68
+    }
69 69
 }
70 70
 
71 71
 $children = allChildren($documentID);
72 72
 if (!array_search($newParentID, $children)) {
73
-	$modx->db->update(array(
74
-		'isfolder' => 1,
75
-	), $modx->getFullTableName('site_content'), "id='{$newParentID}'");
76
-
77
-	$modx->db->update(array(
78
-		'parent'   => $newParentID,
79
-		'editedby' => $modx->getLoginUserID(),
80
-		'editedon' => time(),
81
-	), $modx->getFullTableName('site_content'), "id='{$documentID}'");
82
-
83
-	// finished moving the document, now check to see if the old_parent should no longer be a folder.
84
-	$rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'");
85
-	$limit = $modx->db->getValue($rs);
86
-
87
-	if(!$limit>0) {
88
-		$modx->db->update(array(
89
-			'isfolder' => 0,
90
-		), $modx->getFullTableName('site_content'), "id='{$oldparent}'");
91
-	}
92
-	// Set the item name for logger
93
-	$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'"));
94
-	$_SESSION['itemname'] = $pagetitle;
95
-
96
-	$modx->invokeEvent("onAfterMoveDocument", array (
97
-		"id_document" => $documentID,
98
-		"old_parent" => $oldparent,
99
-		"new_parent" => $newParentID
100
-	));
101
-
102
-	// empty cache & sync site
103
-	$modx->clearCache('full');
104
-
105
-	$header="Location: index.php?a=3&id={$documentID}&r=9";
106
-	header($header);
73
+    $modx->db->update(array(
74
+        'isfolder' => 1,
75
+    ), $modx->getFullTableName('site_content'), "id='{$newParentID}'");
76
+
77
+    $modx->db->update(array(
78
+        'parent'   => $newParentID,
79
+        'editedby' => $modx->getLoginUserID(),
80
+        'editedon' => time(),
81
+    ), $modx->getFullTableName('site_content'), "id='{$documentID}'");
82
+
83
+    // finished moving the document, now check to see if the old_parent should no longer be a folder.
84
+    $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_content'), "parent='{$oldparent}'");
85
+    $limit = $modx->db->getValue($rs);
86
+
87
+    if(!$limit>0) {
88
+        $modx->db->update(array(
89
+            'isfolder' => 0,
90
+        ), $modx->getFullTableName('site_content'), "id='{$oldparent}'");
91
+    }
92
+    // Set the item name for logger
93
+    $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$documentID}'"));
94
+    $_SESSION['itemname'] = $pagetitle;
95
+
96
+    $modx->invokeEvent("onAfterMoveDocument", array (
97
+        "id_document" => $documentID,
98
+        "old_parent" => $oldparent,
99
+        "new_parent" => $newParentID
100
+    ));
101
+
102
+    // empty cache & sync site
103
+    $modx->clearCache('full');
104
+
105
+    $header="Location: index.php?a=3&id={$documentID}&r=9";
106
+    header($header);
107 107
 } else {
108
-	$modx->webAlertAndQuit("You cannot move a document to a child document!");
108
+    $modx->webAlertAndQuit("You cannot move a document to a child document!");
109 109
 }
Please login to merge, or discard this patch.
manager/processors/save_web_user.processor.php 1 patch
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) {
3
-	die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
3
+    die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('save_web_user')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $tbl_web_users = $modx->getFullTableName('web_users');
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 $input = $_POST;
14 14
 foreach($input as $k => $v) {
15
-	if($k !== 'comment') {
16
-		$v = sanitize($v);
17
-	}
18
-	$input[$k] = $v;
15
+    if($k !== 'comment') {
16
+        $v = sanitize($v);
17
+    }
18
+    $input[$k] = $v;
19 19
 }
20 20
 
21 21
 $id = (int)$input['id'];
@@ -51,80 +51,80 @@  discard block
 block discarded – undo
51 51
 
52 52
 // verify password
53 53
 if($passwordgenmethod == "spec" && $input['specifiedpassword'] != $input['confirmpassword']) {
54
-	webAlertAndQuit("Password typed is mismatched");
54
+    webAlertAndQuit("Password typed is mismatched");
55 55
 }
56 56
 
57 57
 // verify email
58 58
 if($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24}$/i", $email)) {
59
-	webAlertAndQuit("E-mail address doesn't seem to be valid!");
59
+    webAlertAndQuit("E-mail address doesn't seem to be valid!");
60 60
 }
61 61
 
62 62
 switch($input['mode']) {
63
-	case '87' : // new user
64
-		// check if this user name already exist
65
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
-		$limit = $modx->db->getValue($rs);
67
-		if($limit > 0) {
68
-			webAlertAndQuit("User name is already in use!");
69
-		}
70
-
71
-		// check if the email address already exist
72
-		$rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73
-		$limit = $modx->db->getValue($rs);
74
-		if($limit > 0) {
75
-			webAlertAndQuit("Email is already in use!");
76
-		}
77
-
78
-		// generate a new password for this user
79
-		if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
-			if(strlen($specifiedpassword) < 6) {
81
-				webAlertAndQuit("Password is too short!");
82
-			} else {
83
-				$newpassword = $specifiedpassword;
84
-			}
85
-		} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
86
-			webAlertAndQuit("You didn't specify a password for this user!");
87
-		} elseif($passwordgenmethod == 'g') {
88
-			$newpassword = generate_password(8);
89
-		} else {
90
-			webAlertAndQuit("No password generation method specified!");
91
-		}
92
-
93
-		// invoke OnBeforeWUsrFormSave event
94
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
95
-			"mode" => "new",
96
-		));
97
-
98
-		// create the user account
99
-		$field = array();
100
-		$field['username'] = $esc_newusername;
101
-		$field['password'] = md5($newpassword);
102
-		$internalKey = $modx->db->insert($field, $tbl_web_users);
103
-
104
-		$field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
105
-		$field = $modx->db->escape($field);
106
-		$modx->db->insert($field, $tbl_web_user_attributes);
107
-
108
-		// Save User Settings
109
-		saveUserSettings($internalKey);
110
-
111
-		// Set the item name for logger
112
-		$_SESSION['itemname'] = $newusername;
113
-
114
-		/*******************************************************************************/
115
-		// put the user in the user_groups he/ she should be in
116
-		// first, check that up_perms are switched on!
117
-		if($use_udperms == 1) {
118
-			if(!empty($user_groups)) {
119
-				for($i = 0; $i < count($user_groups); $i++) {
120
-					$f = array();
121
-					$f['webgroup'] = (int)$user_groups[$i];
122
-					$f['webuser'] = $internalKey;
123
-					$modx->db->insert($f, $tbl_web_groups);
124
-				}
125
-			}
126
-		}
127
-		// end of user_groups stuff!
63
+    case '87' : // new user
64
+        // check if this user name already exist
65
+        $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}'");
66
+        $limit = $modx->db->getValue($rs);
67
+        if($limit > 0) {
68
+            webAlertAndQuit("User name is already in use!");
69
+        }
70
+
71
+        // check if the email address already exist
72
+        $rs = $modx->db->select('count(id)', $tbl_web_user_attributes, "email='{$esc_email}' AND id!='{$id}'");
73
+        $limit = $modx->db->getValue($rs);
74
+        if($limit > 0) {
75
+            webAlertAndQuit("Email is already in use!");
76
+        }
77
+
78
+        // generate a new password for this user
79
+        if($specifiedpassword != "" && $passwordgenmethod == "spec") {
80
+            if(strlen($specifiedpassword) < 6) {
81
+                webAlertAndQuit("Password is too short!");
82
+            } else {
83
+                $newpassword = $specifiedpassword;
84
+            }
85
+        } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
86
+            webAlertAndQuit("You didn't specify a password for this user!");
87
+        } elseif($passwordgenmethod == 'g') {
88
+            $newpassword = generate_password(8);
89
+        } else {
90
+            webAlertAndQuit("No password generation method specified!");
91
+        }
92
+
93
+        // invoke OnBeforeWUsrFormSave event
94
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
95
+            "mode" => "new",
96
+        ));
97
+
98
+        // create the user account
99
+        $field = array();
100
+        $field['username'] = $esc_newusername;
101
+        $field['password'] = md5($newpassword);
102
+        $internalKey = $modx->db->insert($field, $tbl_web_users);
103
+
104
+        $field = compact('internalKey', 'fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'blocked', 'blockeduntil', 'blockedafter');
105
+        $field = $modx->db->escape($field);
106
+        $modx->db->insert($field, $tbl_web_user_attributes);
107
+
108
+        // Save User Settings
109
+        saveUserSettings($internalKey);
110
+
111
+        // Set the item name for logger
112
+        $_SESSION['itemname'] = $newusername;
113
+
114
+        /*******************************************************************************/
115
+        // put the user in the user_groups he/ she should be in
116
+        // first, check that up_perms are switched on!
117
+        if($use_udperms == 1) {
118
+            if(!empty($user_groups)) {
119
+                for($i = 0; $i < count($user_groups); $i++) {
120
+                    $f = array();
121
+                    $f['webgroup'] = (int)$user_groups[$i];
122
+                    $f['webuser'] = $internalKey;
123
+                    $modx->db->insert($f, $tbl_web_groups);
124
+                }
125
+            }
126
+        }
127
+        // end of user_groups stuff!
128 128
 
129 129
         // invoke OnWebSaveUser event
130 130
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -142,26 +142,26 @@  discard block
 block discarded – undo
142 142
             "id" => $internalKey
143 143
         ));
144 144
 
145
-		if($passwordnotifymethod == 'e') {
146
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
147
-			if($input['stay'] != '') {
148
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
150
-				header($header);
151
-			} else {
152
-				$header = "Location: index.php?a=99&r=2";
153
-				header($header);
154
-			}
155
-		} else {
156
-			if($input['stay'] != '') {
157
-				$a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
159
-			} else {
160
-				$stayUrl = "index.php?a=99&r=2";
161
-			}
162
-
163
-			include_once "header.inc.php";
164
-			?>
145
+        if($passwordnotifymethod == 'e') {
146
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
147
+            if($input['stay'] != '') {
148
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
149
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
150
+                header($header);
151
+            } else {
152
+                $header = "Location: index.php?a=99&r=2";
153
+                header($header);
154
+            }
155
+        } else {
156
+            if($input['stay'] != '') {
157
+                $a = ($input['stay'] == '2') ? "88&id={$internalKey}" : "87";
158
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
159
+            } else {
160
+                $stayUrl = "index.php?a=99&r=2";
161
+            }
162
+
163
+            include_once "header.inc.php";
164
+            ?>
165 165
 
166 166
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
167 167
 
@@ -183,84 +183,84 @@  discard block
 block discarded – undo
183 183
 			</div>
184 184
 			<?php
185 185
 
186
-			include_once "footer.inc.php";
187
-		}
188
-		break;
189
-	case '88' : // edit user
190
-		// generate a new password for this user
191
-		if($genpassword == 1) {
192
-			if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
-				if(strlen($specifiedpassword) < 6) {
194
-					webAlertAndQuit("Password is too short!");
195
-				} else {
196
-					$newpassword = $specifiedpassword;
197
-				}
198
-			} elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
199
-				webAlertAndQuit("You didn't specify a password for this user!");
200
-			} elseif($passwordgenmethod == 'g') {
201
-				$newpassword = generate_password(8);
202
-			} else {
203
-				webAlertAndQuit("No password generation method specified!");
204
-			}
205
-		}
206
-		if($passwordnotifymethod == 'e') {
207
-			sendMailMessage($email, $newusername, $newpassword, $fullname);
208
-		}
209
-
210
-		// check if the username already exist
211
-		$rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212
-		$limit = $modx->db->getValue($rs);
213
-		if($limit > 0) {
214
-			webAlertAndQuit("User name is already in use!");
215
-		}
216
-
217
-		// check if the email address already exists
218
-		$rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219
-		$limit = $modx->db->getValue($rs);
220
-		if($limit > 0) {
221
-			webAlertAndQuit("Email is already in use!");
222
-		}
223
-
224
-		// invoke OnBeforeWUsrFormSave event
225
-		$modx->invokeEvent("OnBeforeWUsrFormSave", array(
226
-			"mode" => "upd",
227
-			"id" => $id
228
-		));
229
-
230
-		// update user name and password
231
-		$field = array();
232
-		$field['username'] = $esc_newusername;
233
-		if($genpassword == 1) {
234
-			$field['password'] = md5($newpassword);
235
-		}
236
-		$modx->db->update($field, $tbl_web_users, "id='{$id}'");
237
-		$field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
238
-		$field = $modx->db->escape($field);
239
-		$modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
240
-
241
-		// Save User Settings
242
-		saveUserSettings($id);
243
-
244
-		// Set the item name for logger
245
-		$_SESSION['itemname'] = $newusername;
246
-
247
-		/*******************************************************************************/
248
-		// put the user in the user_groups he/ she should be in
249
-		// first, check that up_perms are switched on!
250
-		if($use_udperms == 1) {
251
-			// as this is an existing user, delete his/ her entries in the groups before saving the new groups
252
-			$modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
-			if(!empty($user_groups)) {
254
-				for($i = 0; $i < count($user_groups); $i++) {
255
-					$field = array();
256
-					$field['webgroup'] = (int)$user_groups[$i];
257
-					$field['webuser'] = $id;
258
-					$modx->db->insert($field, $tbl_web_groups);
259
-				}
260
-			}
261
-		}
262
-		// end of user_groups stuff!
263
-		/*******************************************************************************/
186
+            include_once "footer.inc.php";
187
+        }
188
+        break;
189
+    case '88' : // edit user
190
+        // generate a new password for this user
191
+        if($genpassword == 1) {
192
+            if($specifiedpassword != "" && $passwordgenmethod == "spec") {
193
+                if(strlen($specifiedpassword) < 6) {
194
+                    webAlertAndQuit("Password is too short!");
195
+                } else {
196
+                    $newpassword = $specifiedpassword;
197
+                }
198
+            } elseif($specifiedpassword == "" && $passwordgenmethod == "spec") {
199
+                webAlertAndQuit("You didn't specify a password for this user!");
200
+            } elseif($passwordgenmethod == 'g') {
201
+                $newpassword = generate_password(8);
202
+            } else {
203
+                webAlertAndQuit("No password generation method specified!");
204
+            }
205
+        }
206
+        if($passwordnotifymethod == 'e') {
207
+            sendMailMessage($email, $newusername, $newpassword, $fullname);
208
+        }
209
+
210
+        // check if the username already exist
211
+        $rs = $modx->db->select('count(id)', $tbl_web_users, "username='{$esc_newusername}' AND id!='{$id}'");
212
+        $limit = $modx->db->getValue($rs);
213
+        if($limit > 0) {
214
+            webAlertAndQuit("User name is already in use!");
215
+        }
216
+
217
+        // check if the email address already exists
218
+        $rs = $modx->db->select('count(internalKey)', $tbl_web_user_attributes, "email='{$esc_email}' AND internalKey!='{$id}'");
219
+        $limit = $modx->db->getValue($rs);
220
+        if($limit > 0) {
221
+            webAlertAndQuit("Email is already in use!");
222
+        }
223
+
224
+        // invoke OnBeforeWUsrFormSave event
225
+        $modx->invokeEvent("OnBeforeWUsrFormSave", array(
226
+            "mode" => "upd",
227
+            "id" => $id
228
+        ));
229
+
230
+        // update user name and password
231
+        $field = array();
232
+        $field['username'] = $esc_newusername;
233
+        if($genpassword == 1) {
234
+            $field['password'] = md5($newpassword);
235
+        }
236
+        $modx->db->update($field, $tbl_web_users, "id='{$id}'");
237
+        $field = compact('fullname', 'role', 'email', 'phone', 'mobilephone', 'fax', 'zip', 'street', 'city', 'state', 'country', 'gender', 'dob', 'photo', 'comment', 'failedlogincount', 'blocked', 'blockeduntil', 'blockedafter');
238
+        $field = $modx->db->escape($field);
239
+        $modx->db->update($field, $tbl_web_user_attributes, "internalKey='{$id}'");
240
+
241
+        // Save User Settings
242
+        saveUserSettings($id);
243
+
244
+        // Set the item name for logger
245
+        $_SESSION['itemname'] = $newusername;
246
+
247
+        /*******************************************************************************/
248
+        // put the user in the user_groups he/ she should be in
249
+        // first, check that up_perms are switched on!
250
+        if($use_udperms == 1) {
251
+            // as this is an existing user, delete his/ her entries in the groups before saving the new groups
252
+            $modx->db->delete($tbl_web_groups, "webuser='{$id}'");
253
+            if(!empty($user_groups)) {
254
+                for($i = 0; $i < count($user_groups); $i++) {
255
+                    $field = array();
256
+                    $field['webgroup'] = (int)$user_groups[$i];
257
+                    $field['webuser'] = $id;
258
+                    $modx->db->insert($field, $tbl_web_groups);
259
+                }
260
+            }
261
+        }
262
+        // end of user_groups stuff!
263
+        /*******************************************************************************/
264 264
 
265 265
         // invoke OnWebSaveUser event
266 266
         $modx->invokeEvent("OnWebSaveUser", array(
@@ -289,16 +289,16 @@  discard block
 block discarded – undo
289 289
             "id" => $id
290 290
         ));
291 291
 
292
-		if($genpassword == 1 && $passwordnotifymethod == 's') {
293
-			if($input['stay'] != '') {
294
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
-				$stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
296
-			} else {
297
-				$stayUrl = "index.php?a=99&r=2";
298
-			}
292
+        if($genpassword == 1 && $passwordnotifymethod == 's') {
293
+            if($input['stay'] != '') {
294
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
295
+                $stayUrl = "index.php?a={$a}&r=2&stay=" . $input['stay'];
296
+            } else {
297
+                $stayUrl = "index.php?a=99&r=2";
298
+            }
299 299
 
300
-			include_once "header.inc.php";
301
-			?>
300
+            include_once "header.inc.php";
301
+            ?>
302 302
 
303 303
 			<h1><?php echo $_lang['web_user_title']; ?></h1>
304 304
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
 			</div>
319 319
 			<?php
320 320
 
321
-			include_once "footer.inc.php";
322
-		} else {
323
-			if($input['stay'] != '') {
324
-				$a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
-				$header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
326
-				header($header);
327
-			} else {
328
-				$header = "Location: index.php?a=99&r=2";
329
-				header($header);
330
-			}
331
-		}
332
-		break;
333
-	default :
334
-		webAlertAndQuit("No operation set in request.");
321
+            include_once "footer.inc.php";
322
+        } else {
323
+            if($input['stay'] != '') {
324
+                $a = ($input['stay'] == '2') ? "88&id={$id}" : "87";
325
+                $header = "Location: index.php?a={$a}&r=2&stay=" . $input['stay'];
326
+                header($header);
327
+            } else {
328
+                $header = "Location: index.php?a=99&r=2";
329
+                header($header);
330
+            }
331
+        }
332
+        break;
333
+    default :
334
+        webAlertAndQuit("No operation set in request.");
335 335
 }
336 336
 
337 337
 /**
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
  * @return string
342 342
  */
343 343
 function save_user_quoted_printable($string) {
344
-	$crlf = "\n";
345
-	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
346
-	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
347
-	$r[] = "'=' . sprintf('%02X', ord('\\1'))";
348
-	$f[] = '/([\011\040])' . $crlf . '/e';
349
-	$r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
350
-	$string = preg_replace($f, $r, $string);
351
-	return trim(wordwrap($string, 70, ' =' . $crlf));
344
+    $crlf = "\n";
345
+    $string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
346
+    $f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
347
+    $r[] = "'=' . sprintf('%02X', ord('\\1'))";
348
+    $f[] = '/([\011\040])' . $crlf . '/e';
349
+    $r[] = "'=' . sprintf('%02X', ord('\\1')) . '" . $crlf . "'";
350
+    $string = preg_replace($f, $r, $string);
351
+    return trim(wordwrap($string, 70, ' =' . $crlf));
352 352
 }
353 353
 
354 354
 /**
@@ -360,94 +360,94 @@  discard block
 block discarded – undo
360 360
  * @param string $ufn
361 361
  */
362 362
 function sendMailMessage($email, $uid, $pwd, $ufn) {
363
-	$modx = DocumentParser::getInstance(); global $_lang, $websignupemail_message;
364
-	global $emailsubject, $emailsender;
365
-	global $site_name, $site_url;
366
-	$message = sprintf($websignupemail_message, $uid, $pwd); // use old method
367
-	// replace placeholders
368
-	$message = str_replace("[+uid+]", $uid, $message);
369
-	$message = str_replace("[+pwd+]", $pwd, $message);
370
-	$message = str_replace("[+ufn+]", $ufn, $message);
371
-	$message = str_replace("[+sname+]", $site_name, $message);
372
-	$message = str_replace("[+saddr+]", $emailsender, $message);
373
-	$message = str_replace("[+semail+]", $emailsender, $message);
374
-	$message = str_replace("[+surl+]", $site_url, $message);
375
-
376
-	$param = array();
377
-	$param['from'] = "{$site_name}<{$emailsender}>";
378
-	$param['subject'] = $emailsubject;
379
-	$param['body'] = $message;
380
-	$param['to'] = $email;
381
-	$param['type'] = 'text';
382
-	$rs = $modx->sendmail($param);
383
-	if(!$rs) {
384
-		$modx->manager->saveFormValues();
385
-		$modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
386
-	}
363
+    $modx = DocumentParser::getInstance(); global $_lang, $websignupemail_message;
364
+    global $emailsubject, $emailsender;
365
+    global $site_name, $site_url;
366
+    $message = sprintf($websignupemail_message, $uid, $pwd); // use old method
367
+    // replace placeholders
368
+    $message = str_replace("[+uid+]", $uid, $message);
369
+    $message = str_replace("[+pwd+]", $pwd, $message);
370
+    $message = str_replace("[+ufn+]", $ufn, $message);
371
+    $message = str_replace("[+sname+]", $site_name, $message);
372
+    $message = str_replace("[+saddr+]", $emailsender, $message);
373
+    $message = str_replace("[+semail+]", $emailsender, $message);
374
+    $message = str_replace("[+surl+]", $site_url, $message);
375
+
376
+    $param = array();
377
+    $param['from'] = "{$site_name}<{$emailsender}>";
378
+    $param['subject'] = $emailsubject;
379
+    $param['body'] = $message;
380
+    $param['to'] = $email;
381
+    $param['type'] = 'text';
382
+    $rs = $modx->sendmail($param);
383
+    if(!$rs) {
384
+        $modx->manager->saveFormValues();
385
+        $modx->messageQuit("{$email} - {$_lang['error_sending_email']}");
386
+    }
387 387
 }
388 388
 
389 389
 // Save User Settings
390 390
 function saveUserSettings($id) {
391
-	$modx = DocumentParser::getInstance();
392
-	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393
-
394
-	$settings = array(
395
-		"login_home",
396
-		"allowed_ip",
397
-		"allowed_days"
398
-	);
399
-
400
-	$modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
401
-
402
-	foreach($settings as $n) {
403
-		$vl = $_POST[$n];
404
-		if(is_array($vl)) {
405
-			$vl = implode(",", $vl);
406
-		}
407
-		if($vl != '') {
408
-			$f = array();
409
-			$f['webuser'] = $id;
410
-			$f['setting_name'] = $n;
411
-			$f['setting_value'] = $vl;
412
-			$f = $modx->db->escape($f);
413
-			$modx->db->insert($f, $tbl_web_user_settings);
414
-		}
415
-	}
391
+    $modx = DocumentParser::getInstance();
392
+    $tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393
+
394
+    $settings = array(
395
+        "login_home",
396
+        "allowed_ip",
397
+        "allowed_days"
398
+    );
399
+
400
+    $modx->db->delete($tbl_web_user_settings, "webuser='{$id}'");
401
+
402
+    foreach($settings as $n) {
403
+        $vl = $_POST[$n];
404
+        if(is_array($vl)) {
405
+            $vl = implode(",", $vl);
406
+        }
407
+        if($vl != '') {
408
+            $f = array();
409
+            $f['webuser'] = $id;
410
+            $f['setting_name'] = $n;
411
+            $f['setting_value'] = $vl;
412
+            $f = $modx->db->escape($f);
413
+            $modx->db->insert($f, $tbl_web_user_settings);
414
+        }
415
+    }
416 416
 }
417 417
 
418 418
 // Web alert -  sends an alert to web browser
419 419
 function webAlertAndQuit($msg) {
420
-	global $id, $modx;
421
-	$mode = $_POST['mode'];
422
-	$modx->manager->saveFormValues($mode);
423
-	$modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
420
+    global $id, $modx;
421
+    $mode = $_POST['mode'];
422
+    $modx->manager->saveFormValues($mode);
423
+    $modx->webAlertAndQuit($msg, "index.php?a={$mode}" . ($mode == '88' ? "&id={$id}" : ''));
424 424
 }
425 425
 
426 426
 // Generate password
427 427
 function generate_password($length = 10) {
428
-	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
429
-	$ps_len = strlen($allowable_characters);
430
-	mt_srand((double) microtime() * 1000000);
431
-	$pass = "";
432
-	for($i = 0; $i < $length; $i++) {
433
-		$pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
434
-	}
435
-	return $pass;
428
+    $allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
429
+    $ps_len = strlen($allowable_characters);
430
+    mt_srand((double) microtime() * 1000000);
431
+    $pass = "";
432
+    for($i = 0; $i < $length; $i++) {
433
+        $pass .= $allowable_characters[mt_rand(0, $ps_len - 1)];
434
+    }
435
+    return $pass;
436 436
 }
437 437
 
438 438
 function sanitize($str = '', $safecount = 0) {
439
-	$modx = DocumentParser::getInstance();
440
-	$safecount++;
441
-	if(1000 < $safecount) {
442
-		exit("error too many loops '{$safecount}'");
443
-	}
444
-	if(is_array($str)) {
445
-		foreach($str as $i => $v) {
446
-			$str[$i] = sanitize($v, $safecount);
447
-		}
448
-	} else {
449
-		// $str = strip_tags($str); // LEAVE < and > intact
450
-		$str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']);
451
-	}
452
-	return $str;
439
+    $modx = DocumentParser::getInstance();
440
+    $safecount++;
441
+    if(1000 < $safecount) {
442
+        exit("error too many loops '{$safecount}'");
443
+    }
444
+    if(is_array($str)) {
445
+        foreach($str as $i => $v) {
446
+            $str[$i] = sanitize($v, $safecount);
447
+        }
448
+    } else {
449
+        // $str = strip_tags($str); // LEAVE < and > intact
450
+        $str = htmlspecialchars($str, ENT_NOQUOTES, $modx->config['modx_charset']);
451
+    }
452
+    return $str;
453 453
 }
Please login to merge, or discard this patch.
manager/processors/duplicate_content.processor.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
3 3
     die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly.");
4 4
 }
5 5
 if(!$modx->hasPermission('new_document') || !$modx->hasPermission('save_document')) {
6
-	$modx->webAlertAndQuit($_lang["error_no_privileges"]);
6
+    $modx->webAlertAndQuit($_lang["error_no_privileges"]);
7 7
 }
8 8
 
9 9
 $id = isset($_GET['id'])? (int)$_GET['id'] : 0;
10 10
 if($id==0) {
11
-	$modx->webAlertAndQuit($_lang["error_no_id"]);
11
+    $modx->webAlertAndQuit($_lang["error_no_id"]);
12 12
 }
13 13
 
14 14
 $children = array();
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 $udperms->duplicateDoc = true;
23 23
 
24 24
 if(!$udperms->checkPermissions()) {
25
-	$modx->webAlertAndQuit($_lang["access_permission_denied"]);
25
+    $modx->webAlertAndQuit($_lang["access_permission_denied"]);
26 26
 }
27 27
 
28 28
 // Run the duplicator
@@ -43,103 +43,103 @@  discard block
 block discarded – undo
43 43
  * @return int
44 44
  */
45 45
 function duplicateDocument($docid, $parent=null, $_toplevel=0) {
46
-	$modx = DocumentParser::getInstance(); global $_lang;
47
-
48
-	// invoke OnBeforeDocDuplicate event
49
-	$evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array(
50
-		'id' => $docid
51
-	));
52
-
53
-	// if( !in_array( 'false', array_values( $evtOut ) ) ){}
54
-	// TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication
55
-	// [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false');
56
-
57
-	$userID = $modx->getLoginUserID();
58
-
59
-	$tblsc = $modx->getFullTableName('site_content');
60
-
61
-	// Grab the original document
62
-	$rs = $modx->db->select('*', $tblsc, "id='{$docid}'");
63
-	$content = $modx->db->getRow($rs);
64
-
65
-	// Handle incremental ID
66
-	switch($modx->config['docid_incrmnt_method'])
67
-	{
68
-		case '1':
69
-			$from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
70
-			$rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL");
71
-			$content['id'] = $modx->db->getValue($rs);
72
-			break;
73
-		case '2':
74
-			$rs = $modx->db->select('MAX(id)+1',$tblsc);
75
-			$content['id'] = $modx->db->getValue($rs);
76
-			break;
77
-
78
-		default:
79
-			unset($content['id']); // remove the current id.
80
-	}
81
-
82
-	// Once we've grabbed the document object, start doing some modifications
83
-	if ($_toplevel == 0) {
84
-		// count duplicates
85
-		$pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'"));
86
-		$pagetitle = $modx->db->escape($pagetitle);
87
-		$count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'"));
88
-		if($count>=1) $count = ' '.($count+1);
89
-		else $count = '';
90
-
91
-		$content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92
-		$content['alias'] = null;
93
-	} elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
94
-		$content['alias'] = null;
95
-	}
96
-
97
-	// change the parent accordingly
98
-	if ($parent !== null) $content['parent'] = $parent;
99
-
100
-	// Change the author
101
-	$content['createdby'] = $userID;
102
-	$content['createdon'] = time();
103
-	// Remove other modification times
104
-	$content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0;
105
-
106
-	// [FS#922] Should the published status be honored? - sirlancelot
46
+    $modx = DocumentParser::getInstance(); global $_lang;
47
+
48
+    // invoke OnBeforeDocDuplicate event
49
+    $evtOut = $modx->invokeEvent('OnBeforeDocDuplicate', array(
50
+        'id' => $docid
51
+    ));
52
+
53
+    // if( !in_array( 'false', array_values( $evtOut ) ) ){}
54
+    // TODO: Determine necessary handling for duplicateDocument "return $newparent" if OnBeforeDocDuplicate were able to conditially control duplication
55
+    // [DISABLED]: Proceed with duplicateDocument if OnBeforeDocDuplicate did not return false via: $event->output('false');
56
+
57
+    $userID = $modx->getLoginUserID();
58
+
59
+    $tblsc = $modx->getFullTableName('site_content');
60
+
61
+    // Grab the original document
62
+    $rs = $modx->db->select('*', $tblsc, "id='{$docid}'");
63
+    $content = $modx->db->getRow($rs);
64
+
65
+    // Handle incremental ID
66
+    switch($modx->config['docid_incrmnt_method'])
67
+    {
68
+        case '1':
69
+            $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id";
70
+            $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL");
71
+            $content['id'] = $modx->db->getValue($rs);
72
+            break;
73
+        case '2':
74
+            $rs = $modx->db->select('MAX(id)+1',$tblsc);
75
+            $content['id'] = $modx->db->getValue($rs);
76
+            break;
77
+
78
+        default:
79
+            unset($content['id']); // remove the current id.
80
+    }
81
+
82
+    // Once we've grabbed the document object, start doing some modifications
83
+    if ($_toplevel == 0) {
84
+        // count duplicates
85
+        $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'"));
86
+        $pagetitle = $modx->db->escape($pagetitle);
87
+        $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'"));
88
+        if($count>=1) $count = ' '.($count+1);
89
+        else $count = '';
90
+
91
+        $content['pagetitle'] = $_lang['duplicated_el_suffix'].$count.' '.$content['pagetitle'];
92
+        $content['alias'] = null;
93
+    } elseif($modx->config['friendly_urls'] == 0 || $modx->config['allow_duplicate_alias'] == 0) {
94
+        $content['alias'] = null;
95
+    }
96
+
97
+    // change the parent accordingly
98
+    if ($parent !== null) $content['parent'] = $parent;
99
+
100
+    // Change the author
101
+    $content['createdby'] = $userID;
102
+    $content['createdon'] = time();
103
+    // Remove other modification times
104
+    $content['editedby'] = $content['editedon'] = $content['deleted'] = $content['deletedby'] = $content['deletedon'] = 0;
105
+
106
+    // [FS#922] Should the published status be honored? - sirlancelot
107 107
 //	if ($modx->hasPermission('publish_document')) {
108 108
 //		if ($modx->config['publish_default'])
109 109
 //			$content['pub_date'] = $content['pub_date']; // should this be changed to 1?
110 110
 //		else	$content['pub_date'] = 0;
111 111
 //	} else {
112
-		// User can't publish documents
112
+        // User can't publish documents
113 113
 //		$content['published'] = $content['pub_date'] = 0;
114 114
 //	}
115 115
 
116 116
     // Set the published status to unpublished by default (see above ... commit #3388)
117 117
     $content['published'] = $content['pub_date'] = 0;
118 118
 
119
-	// Escape the proper strings
120
-	$content = $modx->db->escape($content);
119
+    // Escape the proper strings
120
+    $content = $modx->db->escape($content);
121 121
 
122
-	// Duplicate the Document
123
-	$newparent = $modx->db->insert($content, $tblsc);
122
+    // Duplicate the Document
123
+    $newparent = $modx->db->insert($content, $tblsc);
124 124
 
125
-	// duplicate document's TVs
126
-	duplicateTVs($docid, $newparent);
127
-	duplicateAccess($docid, $newparent);
125
+    // duplicate document's TVs
126
+    duplicateTVs($docid, $newparent);
127
+    duplicateAccess($docid, $newparent);
128 128
 
129
-	// invoke OnDocDuplicate event
130
-	$evtOut = $modx->invokeEvent('OnDocDuplicate', array(
131
-		'id' => $docid,
132
-		'new_id' => $newparent
133
-	));
129
+    // invoke OnDocDuplicate event
130
+    $evtOut = $modx->invokeEvent('OnDocDuplicate', array(
131
+        'id' => $docid,
132
+        'new_id' => $newparent
133
+    ));
134 134
 
135
-	// Start duplicating all the child documents that aren't deleted.
136
-	$_toplevel++;
137
-	$rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC');
138
-		while ($row = $modx->db->getRow($rs))
139
-			duplicateDocument($row['id'], $newparent, $_toplevel);
135
+    // Start duplicating all the child documents that aren't deleted.
136
+    $_toplevel++;
137
+    $rs = $modx->db->select('id', $tblsc, "parent='{$docid}' AND deleted=0", 'id ASC');
138
+        while ($row = $modx->db->getRow($rs))
139
+            duplicateDocument($row['id'], $newparent, $_toplevel);
140 140
 
141
-	// return the new doc id
142
-	return $newparent;
141
+    // return the new doc id
142
+    return $newparent;
143 143
 }
144 144
 
145 145
 /**
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
  * @param int $newid
150 150
  */
151 151
 function duplicateTVs($oldid, $newid){
152
-	$modx = DocumentParser::getInstance();
152
+    $modx = DocumentParser::getInstance();
153 153
 
154
-	$tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
154
+    $tbltvc = $modx->getFullTableName('site_tmplvar_contentvalues');
155 155
 
156 156
     $newid = (int)$newid;
157 157
     $oldid = (int)$oldid;
158 158
 
159 159
     $modx->db->insert(
160
-		array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into
161
-		"{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from
162
-	);
160
+        array('contentid'=>'', 'tmplvarid'=>'', 'value'=>''), $tbltvc, // Insert into
161
+        "{$newid}, tmplvarid, value", $tbltvc, "contentid='{$oldid}'" // Copy from
162
+    );
163 163
 }
164 164
 
165 165
 /**
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
  * @param int $newid
170 170
  */
171 171
 function duplicateAccess($oldid, $newid){
172
-	$modx = DocumentParser::getInstance();
172
+    $modx = DocumentParser::getInstance();
173 173
 
174
-	$tbldg = $modx->getFullTableName('document_groups');
174
+    $tbldg = $modx->getFullTableName('document_groups');
175 175
 
176 176
     $newid = (int)$newid;
177 177
     $oldid = (int)$oldid;
178 178
 
179 179
     $modx->db->insert(
180
-		array('document'=>'', 'document_group'=>''), $tbldg, // Insert into
181
-		"{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from
182
-	);
180
+        array('document'=>'', 'document_group'=>''), $tbldg, // Insert into
181
+        "{$newid}, document_group", $tbldg, "document='{$oldid}'" // Copy from
182
+    );
183 183
 }
Please login to merge, or discard this patch.
manager/processors/login.processor.php 1 patch
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
3
-	header('HTTP/1.0 404 Not Found');
4
-	exit('error');
3
+    header('HTTP/1.0 404 Not Found');
4
+    exit('error');
5 5
 }
6 6
 define('IN_MANAGER_MODE', true);  // we use this to make sure files are accessed through
7 7
 define('MODX_API_MODE', true);
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 include_once("{$core_path}lang/english.inc.php");
19 19
 
20 20
 if($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) {
21
-	include_once("{$core_path}lang/{$manager_language}.inc.php");
21
+    include_once("{$core_path}lang/{$manager_language}.inc.php");
22 22
 }
23 23
 
24 24
 // include the logger
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 // Initialize System Alert Message Queque
28 28
 if(!isset($_SESSION['SystemAlertMsgQueque'])) {
29
-	$_SESSION['SystemAlertMsgQueque'] = array();
29
+    $_SESSION['SystemAlertMsgQueque'] = array();
30 30
 }
31 31
 $SystemAlertMsgQueque = &$_SESSION['SystemAlertMsgQueque'];
32 32
 
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 
42 42
 // invoke OnBeforeManagerLogin event
43 43
 $modx->invokeEvent('OnBeforeManagerLogin', array(
44
-		'username' => $username,
45
-		'userpassword' => $givenPassword,
46
-		'rememberme' => $rememberme
47
-	));
44
+        'username' => $username,
45
+        'userpassword' => $givenPassword,
46
+        'rememberme' => $rememberme
47
+    ));
48 48
 $fields = 'mu.*, ua.*';
49 49
 $from = '[+prefix+]manager_users AS mu, [+prefix+]user_attributes AS ua';
50 50
 $where = "BINARY mu.username='{$username}' and ua.internalKey=mu.id";
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 $limit = $modx->db->getRecordCount($rs);
53 53
 
54 54
 if($limit == 0 || $limit > 1) {
55
-	jsAlert($_lang['login_processor_unknown_user']);
56
-	return;
55
+    jsAlert($_lang['login_processor_unknown_user']);
56
+    return;
57 57
 }
58 58
 
59 59
 $row = $modx->db->getRow($rs);
@@ -74,127 +74,127 @@  discard block
 block discarded – undo
74 74
 // get the user settings from the database
75 75
 $rs = $modx->db->select('setting_name, setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_value!=''");
76 76
 while($row = $modx->db->getRow($rs)) {
77
-	extract($row);
78
-	${$setting_name} = $setting_value;
77
+    extract($row);
78
+    ${$setting_name} = $setting_value;
79 79
 }
80 80
 
81 81
 // blocked due to number of login errors.
82 82
 if($failedlogins >= $failed_allowed && $blockeduntildate > time()) {
83
-	@session_destroy();
84
-	session_unset();
85
-	if($cip = getenv("HTTP_CLIENT_IP")) {
86
-		$ip = $cip;
87
-	} elseif($cip = getenv("HTTP_X_FORWARDED_FOR")) {
88
-		$ip = $cip;
89
-	} elseif($cip = getenv("REMOTE_ADDR")) {
90
-		$ip = $cip;
91
-	} else {
92
-		$ip = "UNKNOWN";
93
-	}
94
-	$log = new logHandler;
95
-	$log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip);
96
-	jsAlert($_lang['login_processor_many_failed_logins']);
97
-	return;
83
+    @session_destroy();
84
+    session_unset();
85
+    if($cip = getenv("HTTP_CLIENT_IP")) {
86
+        $ip = $cip;
87
+    } elseif($cip = getenv("HTTP_X_FORWARDED_FOR")) {
88
+        $ip = $cip;
89
+    } elseif($cip = getenv("REMOTE_ADDR")) {
90
+        $ip = $cip;
91
+    } else {
92
+        $ip = "UNKNOWN";
93
+    }
94
+    $log = new logHandler;
95
+    $log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip);
96
+    jsAlert($_lang['login_processor_many_failed_logins']);
97
+    return;
98 98
 }
99 99
 
100 100
 // blocked due to number of login errors, but get to try again
101 101
 if($failedlogins >= $failed_allowed && $blockeduntildate < time()) {
102
-	$fields = array();
103
-	$fields['failedlogincount'] = '0';
104
-	$fields['blockeduntil'] = time() - 1;
105
-	$modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
102
+    $fields = array();
103
+    $fields['failedlogincount'] = '0';
104
+    $fields['blockeduntil'] = time() - 1;
105
+    $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
106 106
 }
107 107
 
108 108
 // this user has been blocked by an admin, so no way he's loggin in!
109 109
 if($blocked == '1') {
110
-	@session_destroy();
111
-	session_unset();
112
-	jsAlert($_lang['login_processor_blocked1']);
113
-	return;
110
+    @session_destroy();
111
+    session_unset();
112
+    jsAlert($_lang['login_processor_blocked1']);
113
+    return;
114 114
 }
115 115
 
116 116
 // blockuntil: this user has a block until date
117 117
 if($blockeduntildate > time()) {
118
-	@session_destroy();
119
-	session_unset();
120
-	jsAlert($_lang['login_processor_blocked2']);
121
-	return;
118
+    @session_destroy();
119
+    session_unset();
120
+    jsAlert($_lang['login_processor_blocked2']);
121
+    return;
122 122
 }
123 123
 
124 124
 // blockafter: this user has a block after date
125 125
 if($blockedafterdate > 0 && $blockedafterdate < time()) {
126
-	@session_destroy();
127
-	session_unset();
128
-	jsAlert($_lang['login_processor_blocked3']);
129
-	return;
126
+    @session_destroy();
127
+    session_unset();
128
+    jsAlert($_lang['login_processor_blocked3']);
129
+    return;
130 130
 }
131 131
 
132 132
 // allowed ip
133 133
 if($allowed_ip) {
134
-	if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) {
135
-		if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) {
136
-			jsAlert($_lang['login_processor_remotehost_ip']);
137
-			return;
138
-		}
139
-	}
140
-	if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) {
141
-		jsAlert($_lang['login_processor_remote_ip']);
142
-		return;
143
-	}
134
+    if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) {
135
+        if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) {
136
+            jsAlert($_lang['login_processor_remotehost_ip']);
137
+            return;
138
+        }
139
+    }
140
+    if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) {
141
+        jsAlert($_lang['login_processor_remote_ip']);
142
+        return;
143
+    }
144 144
 }
145 145
 
146 146
 // allowed days
147 147
 if($allowed_days) {
148
-	$date = getdate();
149
-	$day = $date['wday'] + 1;
150
-	if(strpos($allowed_days, $day) === false) {
151
-		jsAlert($_lang['login_processor_date']);
152
-		return;
153
-	}
148
+    $date = getdate();
149
+    $day = $date['wday'] + 1;
150
+    if(strpos($allowed_days, $day) === false) {
151
+        jsAlert($_lang['login_processor_date']);
152
+        return;
153
+    }
154 154
 }
155 155
 
156 156
 // invoke OnManagerAuthentication event
157 157
 $rt = $modx->invokeEvent('OnManagerAuthentication', array(
158
-		'userid' => $internalKey,
159
-		'username' => $username,
160
-		'userpassword' => $givenPassword,
161
-		'savedpassword' => $dbasePassword,
162
-		'rememberme' => $rememberme
163
-	));
158
+        'userid' => $internalKey,
159
+        'username' => $username,
160
+        'userpassword' => $givenPassword,
161
+        'savedpassword' => $dbasePassword,
162
+        'rememberme' => $rememberme
163
+    ));
164 164
 
165 165
 // check if plugin authenticated the user
166 166
 $matchPassword = false;
167 167
 if(!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) {
168
-	// check user password - local authentication
169
-	$hashType = $modx->manager->getHashType($dbasePassword);
170
-	if($hashType == 'phpass') {
171
-		$matchPassword = login($username, $_REQUEST['password'], $dbasePassword);
172
-	} elseif($hashType == 'md5') {
173
-		$matchPassword = loginMD5($internalKey, $_REQUEST['password'], $dbasePassword, $username);
174
-	} elseif($hashType == 'v1') {
175
-		$matchPassword = loginV1($internalKey, $_REQUEST['password'], $dbasePassword, $username);
176
-	} else {
177
-		$matchPassword = false;
178
-	}
168
+    // check user password - local authentication
169
+    $hashType = $modx->manager->getHashType($dbasePassword);
170
+    if($hashType == 'phpass') {
171
+        $matchPassword = login($username, $_REQUEST['password'], $dbasePassword);
172
+    } elseif($hashType == 'md5') {
173
+        $matchPassword = loginMD5($internalKey, $_REQUEST['password'], $dbasePassword, $username);
174
+    } elseif($hashType == 'v1') {
175
+        $matchPassword = loginV1($internalKey, $_REQUEST['password'], $dbasePassword, $username);
176
+    } else {
177
+        $matchPassword = false;
178
+    }
179 179
 } else if($rt === true || (is_array($rt) && in_array(true, $rt))) {
180
-	$matchPassword = true;
180
+    $matchPassword = true;
181 181
 }
182 182
 
183 183
 if(!$matchPassword) {
184
-	jsAlert($_lang['login_processor_wrong_password']);
185
-	incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
186
-	return;
184
+    jsAlert($_lang['login_processor_wrong_password']);
185
+    incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
186
+    return;
187 187
 }
188 188
 
189 189
 if($modx->config['use_captcha'] == 1) {
190
-	if(!isset ($_SESSION['veriword'])) {
191
-		jsAlert($_lang['login_processor_captcha_config']);
192
-		return;
193
-	} elseif($_SESSION['veriword'] != $captcha_code) {
194
-		jsAlert($_lang['login_processor_bad_code']);
195
-		incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
196
-		return;
197
-	}
190
+    if(!isset ($_SESSION['veriword'])) {
191
+        jsAlert($_lang['login_processor_captcha_config']);
192
+        return;
193
+    } elseif($_SESSION['veriword'] != $captcha_code) {
194
+        jsAlert($_lang['login_processor_bad_code']);
195
+        incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes);
196
+        return;
197
+    }
198 198
 }
199 199
 
200 200
 $modx->cleanupExpiredLocks();
@@ -229,36 +229,36 @@  discard block
 block discarded – undo
229 229
 $_SESSION['mgrToken'] = md5($currentsessionid);
230 230
 
231 231
 if($rememberme == '1') {
232
-	$_SESSION['modx.mgr.session.cookie.lifetime'] = (int)$modx->config['session.cookie.lifetime'];
233
-
234
-	// Set a cookie separate from the session cookie with the username in it.
235
-	// Are we using secure connection? If so, make sure the cookie is secure
236
-	global $https_port;
237
-
238
-	$secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port);
239
-	if(version_compare(PHP_VERSION, '5.2', '<')) {
240
-		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure);
241
-	} else {
242
-		setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true);
243
-	}
232
+    $_SESSION['modx.mgr.session.cookie.lifetime'] = (int)$modx->config['session.cookie.lifetime'];
233
+
234
+    // Set a cookie separate from the session cookie with the username in it.
235
+    // Are we using secure connection? If so, make sure the cookie is secure
236
+    global $https_port;
237
+
238
+    $secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port);
239
+    if(version_compare(PHP_VERSION, '5.2', '<')) {
240
+        setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure);
241
+    } else {
242
+        setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true);
243
+    }
244 244
 } else {
245
-	$_SESSION['modx.mgr.session.cookie.lifetime'] = 0;
245
+    $_SESSION['modx.mgr.session.cookie.lifetime'] = 0;
246 246
 
247
-	// Remove the Remember Me cookie
248
-	setcookie('modx_remember_manager', '', time() - 3600, MODX_BASE_URL);
247
+    // Remove the Remember Me cookie
248
+    setcookie('modx_remember_manager', '', time() - 3600, MODX_BASE_URL);
249 249
 }
250 250
 
251 251
 // Check if user already has an active session, if not check if user pressed logout end of last session
252 252
 $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_user_sessions'), "internalKey='{$internalKey}'");
253 253
 $activeSession = $modx->db->getValue($rs);
254 254
 if(!$activeSession) {
255
-	$rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8");
256
-	if($lastHit = $modx->db->getValue($rs)) {
257
-		$_SESSION['show_logout_reminder'] = array(
258
-			'type' => 'logout_reminder',
259
-			'lastHit' => $lastHit
260
-		);
261
-	}
255
+    $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8");
256
+    if($lastHit = $modx->db->getValue($rs)) {
257
+        $_SESSION['show_logout_reminder'] = array(
258
+            'type' => 'logout_reminder',
259
+            'lastHit' => $lastHit
260
+        );
261
+    }
262 262
 }
263 263
 
264 264
 $log = new logHandler;
@@ -266,29 +266,29 @@  discard block
 block discarded – undo
266 266
 
267 267
 // invoke OnManagerLogin event
268 268
 $modx->invokeEvent('OnManagerLogin', array(
269
-		'userid' => $internalKey,
270
-		'username' => $username,
271
-		'userpassword' => $givenPassword,
272
-		'rememberme' => $rememberme
273
-	));
269
+        'userid' => $internalKey,
270
+        'username' => $username,
271
+        'userpassword' => $givenPassword,
272
+        'rememberme' => $rememberme
273
+    ));
274 274
 
275 275
 // check if we should redirect user to a web page
276 276
 $rs = $modx->db->select('setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_name='manager_login_startup'");
277 277
 $id = (int)$modx->db->getValue($rs);
278 278
 if($id > 0) {
279
-	$header = 'Location: ' . $modx->makeUrl($id, '', '', 'full');
280
-	if($_POST['ajax'] == 1) {
281
-		echo $header;
282
-	} else {
283
-		header($header);
284
-	}
279
+    $header = 'Location: ' . $modx->makeUrl($id, '', '', 'full');
280
+    if($_POST['ajax'] == 1) {
281
+        echo $header;
282
+    } else {
283
+        header($header);
284
+    }
285 285
 } else {
286
-	$header = 'Location: ' . MODX_MANAGER_URL;
287
-	if($_POST['ajax'] == 1) {
288
-		echo $header;
289
-	} else {
290
-		header($header);
291
-	}
286
+    $header = 'Location: ' . MODX_MANAGER_URL;
287
+    if($_POST['ajax'] == 1) {
288
+        echo $header;
289
+    } else {
290
+        header($header);
291
+    }
292 292
 }
293 293
 
294 294
 /**
@@ -297,12 +297,12 @@  discard block
 block discarded – undo
297 297
  * @param string $msg
298 298
  */
299 299
 function jsAlert($msg) {
300
-	$modx = DocumentParser::getInstance();
301
-	if($_POST['ajax'] != 1) {
302
-		echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>";
303
-	} else {
304
-		echo $msg . "\n";
305
-	}
300
+    $modx = DocumentParser::getInstance();
301
+    if($_POST['ajax'] != 1) {
302
+        echo "<script>window.setTimeout(\"alert('" . addslashes($modx->db->escape($msg)) . "')\",10);history.go(-1)</script>";
303
+    } else {
304
+        echo $msg . "\n";
305
+    }
306 306
 }
307 307
 
308 308
 /**
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
  * @return bool
313 313
  */
314 314
 function login($username, $givenPassword, $dbasePassword) {
315
-	$modx = DocumentParser::getInstance();
316
-	return $modx->phpass->CheckPassword($givenPassword, $dbasePassword);
315
+    $modx = DocumentParser::getInstance();
316
+    return $modx->phpass->CheckPassword($givenPassword, $dbasePassword);
317 317
 }
318 318
 
319 319
 /**
@@ -324,26 +324,26 @@  discard block
 block discarded – undo
324 324
  * @return bool
325 325
  */
326 326
 function loginV1($internalKey, $givenPassword, $dbasePassword, $username) {
327
-	$modx = DocumentParser::getInstance();
327
+    $modx = DocumentParser::getInstance();
328 328
 
329
-	$user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey);
329
+    $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey);
330 330
 
331
-	if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) {
332
-		$modx->config['pwd_hash_algo'] = 'UNCRYPT';
333
-	}
331
+    if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) {
332
+        $modx->config['pwd_hash_algo'] = 'UNCRYPT';
333
+    }
334 334
 
335
-	if($user_algo !== $modx->config['pwd_hash_algo']) {
336
-		$bk_pwd_hash_algo = $modx->config['pwd_hash_algo'];
337
-		$modx->config['pwd_hash_algo'] = $user_algo;
338
-	}
335
+    if($user_algo !== $modx->config['pwd_hash_algo']) {
336
+        $bk_pwd_hash_algo = $modx->config['pwd_hash_algo'];
337
+        $modx->config['pwd_hash_algo'] = $user_algo;
338
+    }
339 339
 
340
-	if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) {
341
-		return false;
342
-	}
340
+    if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) {
341
+        return false;
342
+    }
343 343
 
344
-	updateNewHash($username, $givenPassword);
344
+    updateNewHash($username, $givenPassword);
345 345
 
346
-	return true;
346
+    return true;
347 347
 }
348 348
 
349 349
 /**
@@ -354,13 +354,13 @@  discard block
 block discarded – undo
354 354
  * @return bool
355 355
  */
356 356
 function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) {
357
-	$modx = DocumentParser::getInstance();
357
+    $modx = DocumentParser::getInstance();
358 358
 
359
-	if($dbasePassword != md5($givenPassword)) {
360
-		return false;
361
-	}
362
-	updateNewHash($username, $givenPassword);
363
-	return true;
359
+    if($dbasePassword != md5($givenPassword)) {
360
+        return false;
361
+    }
362
+    updateNewHash($username, $givenPassword);
363
+    return true;
364 364
 }
365 365
 
366 366
 /**
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
  * @param string $password
369 369
  */
370 370
 function updateNewHash($username, $password) {
371
-	$modx = DocumentParser::getInstance();
371
+    $modx = DocumentParser::getInstance();
372 372
 
373
-	$field = array();
374
-	$field['password'] = $modx->phpass->HashPassword($password);
375
-	$modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'");
373
+    $field = array();
374
+    $field['password'] = $modx->phpass->HashPassword($password);
375
+    $modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'");
376 376
 }
377 377
 
378 378
 /**
@@ -382,27 +382,27 @@  discard block
 block discarded – undo
382 382
  * @param int $blocked_minutes
383 383
  */
384 384
 function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) {
385
-	$modx = DocumentParser::getInstance();
386
-
387
-	$failedlogins += 1;
388
-
389
-	$fields = array('failedlogincount' => $failedlogins);
390
-	if($failedlogins >= $failed_allowed) //block user for too many fail attempts
391
-	{
392
-		$fields['blockeduntil'] = time() + ($blocked_minutes * 60);
393
-	}
394
-
395
-	$modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
396
-
397
-	if($failedlogins < $failed_allowed) {
398
-		//sleep to help prevent brute force attacks
399
-		$sleep = (int) $failedlogins / 2;
400
-		if($sleep > 5) {
401
-			$sleep = 5;
402
-		}
403
-		sleep($sleep);
404
-	}
405
-	@session_destroy();
406
-	session_unset();
407
-	return;
385
+    $modx = DocumentParser::getInstance();
386
+
387
+    $failedlogins += 1;
388
+
389
+    $fields = array('failedlogincount' => $failedlogins);
390
+    if($failedlogins >= $failed_allowed) //block user for too many fail attempts
391
+    {
392
+        $fields['blockeduntil'] = time() + ($blocked_minutes * 60);
393
+    }
394
+
395
+    $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'");
396
+
397
+    if($failedlogins < $failed_allowed) {
398
+        //sleep to help prevent brute force attacks
399
+        $sleep = (int) $failedlogins / 2;
400
+        if($sleep > 5) {
401
+            $sleep = 5;
402
+        }
403
+        sleep($sleep);
404
+    }
405
+    @session_destroy();
406
+    session_unset();
407
+    return;
408 408
 }
Please login to merge, or discard this patch.