Completed
Push — develop ( 30673e...6e72d2 )
by Dmytro
07:41 queued 01:16
created
manager/processors/move_document.processor.php 1 patch
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,12 +12,20 @@  discard block
 block discarded – undo
12 12
 // ok, two things to check.
13 13
 // first, document cannot be moved to itself
14 14
 // second, new parent must be a folder. If not, set it to folder.
15
-if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]);
16
-if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
17
-if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]);
15
+if($documentID==$newParentID) {
16
+    $modx->webAlertAndQuit($_lang["error_movedocument1"]);
17
+}
18
+if($documentID <= 0) {
19
+    $modx->webAlertAndQuit($_lang["error_movedocument2"]);
20
+}
21
+if($newParentID < 0) {
22
+    $modx->webAlertAndQuit($_lang["error_movedocument2"]);
23
+}
18 24
 
19 25
 $parents = $modx->getParentIds($newParentID);
20
-if (in_array($documentID, $parents))  $modx->webAlertAndQuit($_lang["error_movedocument2"]);
26
+if (in_array($documentID, $parents)) {
27
+    $modx->webAlertAndQuit($_lang["error_movedocument2"]);
28
+}
21 29
 
22 30
 $rs = $modx->db->select('parent', $modx->getFullTableName('site_content'), "id='{$documentID}'");
23 31
 $oldparent = $modx->db->getValue($rs);
@@ -42,7 +50,8 @@  discard block
 block discarded – undo
42 50
  * @param int $currDocID
43 51
  * @return array
44 52
  */
45
-function allChildren($currDocID) {
53
+function allChildren($currDocID)
54
+{
46 55
 	global $modx;
47 56
 	$children= array();
48 57
 	$currDocID = $modx->db->escape($currDocID);
@@ -59,11 +68,11 @@  discard block
 block discarded – undo
59 68
 	"old_parent" => $oldparent,
60 69
 	"new_parent" => $newParentID
61 70
 ));
62
-if (is_array($evtOut) && count($evtOut) > 0){
71
+if (is_array($evtOut) && count($evtOut) > 0) {
63 72
 	$newParent = array_pop($evtOut);
64 73
 	if($newParent == $oldparent) {
65 74
 		$modx->webAlertAndQuit($_lang["error_movedocument2"]);
66
-	}else{
75
+	} else {
67 76
 		$newParentID = $newParent;
68 77
 	}
69 78
 }
Please login to merge, or discard this patch.
manager/processors/save_web_user.processor.php 1 patch
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -340,7 +340,8 @@  discard block
 block discarded – undo
340 340
  * @param string $string
341 341
  * @return string
342 342
  */
343
-function save_user_quoted_printable($string) {
343
+function save_user_quoted_printable($string)
344
+{
344 345
 	$crlf = "\n";
345 346
 	$string = preg_replace('!(\r\n|\r|\n)!', $crlf, $string) . $crlf;
346 347
 	$f[] = '/([\000-\010\013\014\016-\037\075\177-\377])/e';
@@ -359,7 +360,8 @@  discard block
 block discarded – undo
359 360
  * @param string $pwd
360 361
  * @param string $ufn
361 362
  */
362
-function sendMailMessage($email, $uid, $pwd, $ufn) {
363
+function sendMailMessage($email, $uid, $pwd, $ufn)
364
+{
363 365
 	global $modx, $_lang, $websignupemail_message;
364 366
 	global $emailsubject, $emailsender;
365 367
 	global $site_name, $site_url;
@@ -387,7 +389,8 @@  discard block
 block discarded – undo
387 389
 }
388 390
 
389 391
 // Save User Settings
390
-function saveUserSettings($id) {
392
+function saveUserSettings($id)
393
+{
391 394
 	global $modx;
392 395
 	$tbl_web_user_settings = $modx->getFullTableName('web_user_settings');
393 396
 
@@ -416,7 +419,8 @@  discard block
 block discarded – undo
416 419
 }
417 420
 
418 421
 // Web alert -  sends an alert to web browser
419
-function webAlertAndQuit($msg) {
422
+function webAlertAndQuit($msg)
423
+{
420 424
 	global $id, $modx;
421 425
 	$mode = $_POST['mode'];
422 426
 	$modx->manager->saveFormValues($mode);
@@ -424,7 +428,8 @@  discard block
 block discarded – undo
424 428
 }
425 429
 
426 430
 // Generate password
427
-function generate_password($length = 10) {
431
+function generate_password($length = 10)
432
+{
428 433
 	$allowable_characters = "abcdefghjkmnpqrstuvxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
429 434
 	$ps_len = strlen($allowable_characters);
430 435
 	mt_srand((double) microtime() * 1000000);
@@ -435,7 +440,8 @@  discard block
 block discarded – undo
435 440
 	return $pass;
436 441
 }
437 442
 
438
-function sanitize($str = '', $safecount = 0) {
443
+function sanitize($str = '', $safecount = 0)
444
+{
439 445
 	global $modx;
440 446
 	$safecount++;
441 447
 	if(1000 < $safecount) {
Please login to merge, or discard this patch.
manager/media/script/air-datepicker/datepicker.inc.php 1 patch
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,13 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class DATEPICKER {
2
+class DATEPICKER
3
+{
3 4
     /**
4 5
      * @return string
5 6
      */
6
-    public function getDP() {
7
+    public function getDP()
8
+    {
7 9
         global $modx;
8 10
 
9 11
         $load_script = file_get_contents(dirname(__FILE__).'/datepicker.tpl');
10
-        if(!isset($modx->config['lang_code'])) $modx->config['lang_code'] = $this->getLangCode();
12
+        if(!isset($modx->config['lang_code'])) {
13
+            $modx->config['lang_code'] = $this->getLangCode();
14
+        }
11 15
 		$modx->config['datetime_format_lc'] = isset($modx->config['datetime_format']) ? strtolower($modx->config['datetime_format']) : 'dd-mm-yyyy';
12 16
         return $modx->mergeSettingsContent($load_script);
13 17
     }
@@ -15,13 +19,18 @@  discard block
 block discarded – undo
15 19
     /**
16 20
      * @return string
17 21
      */
18
-    public function getLangCode() {
22
+    public function getLangCode()
23
+    {
19 24
         global $modx, $modx_lang_attribute;
20 25
 
21
-        if(!$modx_lang_attribute) return 'en';
26
+        if(!$modx_lang_attribute) {
27
+            return 'en';
28
+        }
22 29
 
23 30
         $lc = $modx_lang_attribute;
24
-        if($lc === 'uk') return 'ru';
31
+        if($lc === 'uk') {
32
+            return 'ru';
33
+        }
25 34
         $dp_path = str_replace('\\','/',dirname(__FILE__));
26 35
 
27 36
         return (is_file("{$dp_path}/i18n/datepicker.{$lc}.js")) ? $modx_lang_attribute : 'en';
Please login to merge, or discard this patch.
index.php 1 patch
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -50,17 +50,23 @@  discard block
 block discarded – undo
50 50
 	include_once($autoloader);
51 51
 }
52 52
 
53
-if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
53
+if(!isset($_SERVER['REQUEST_TIME_FLOAT'])) {
54
+    $_SERVER['REQUEST_TIME_FLOAT'] = microtime(true);
55
+}
54 56
 
55 57
 $base_path = str_replace('\\','/',dirname(__FILE__)) . '/';
56
-if(is_file($base_path . 'assets/cache/siteManager.php'))
58
+if(is_file($base_path . 'assets/cache/siteManager.php')) {
57 59
     include_once($base_path . 'assets/cache/siteManager.php');
58
-if(!defined('MGR_DIR') && is_dir("{$base_path}manager"))
60
+}
61
+if(!defined('MGR_DIR') && is_dir("{$base_path}manager")) {
59 62
 	define('MGR_DIR', 'manager');
60
-if(is_file($base_path . 'assets/cache/siteHostnames.php'))
63
+}
64
+if(is_file($base_path . 'assets/cache/siteHostnames.php')) {
61 65
     include_once($base_path . 'assets/cache/siteHostnames.php');
62
-if(!defined('MODX_SITE_HOSTNAMES'))
66
+}
67
+if(!defined('MODX_SITE_HOSTNAMES')) {
63 68
 	define('MODX_SITE_HOSTNAMES', '');
69
+}
64 70
 
65 71
 // get start time
66 72
 $mstart = memory_get_usage();
@@ -129,7 +135,7 @@  discard block
 block discarded – undo
129 135
     @ini_set("display_errors","0");
130 136
 }
131 137
 
132
-if(MODX_CLI){
138
+if(MODX_CLI) {
133 139
     @set_time_limit(0);
134 140
     @ini_set('max_execution_time',0);
135 141
 }
Please login to merge, or discard this patch.
manager/includes/preload.functions.inc.php 1 patch
Braces   +18 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 /**
7 7
  * @return string
8 8
  */
9
-function genEvoSessionName()
10
-{
9
+function genEvoSessionName()
10
+{
11 11
     $_ = crc32(__FILE__);
12 12
     $_ = sprintf('%u', $_);
13 13
 
@@ -17,10 +17,12 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * @return void
19 19
  */
20
-function startCMSSession()
21
-{
20
+function startCMSSession()
21
+{
22 22
     global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain;
23
-    if(MODX_CLI) return;
23
+    if(MODX_CLI) {
24
+        return;
25
+    }
24 26
 
25 27
     session_name($site_sessionname);
26 28
     removeInvalidCmsSessionIds($site_sessionname);
@@ -31,14 +33,14 @@  discard block
 block discarded – undo
31 33
     session_set_cookie_params($cookieExpiration, $cookiePath, $cookieDomain, $secure, true);
32 34
     session_start();
33 35
     $key = "modx.mgr.session.cookie.lifetime";
34
-    if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
36
+    if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
35 37
         $cookieLifetime = (int)$_SESSION[$key];
36
-        if ($cookieLifetime) {
38
+        if ($cookieLifetime) {
37 39
             $cookieExpiration = $_SERVER['REQUEST_TIME'] + $cookieLifetime;
38 40
         }
39 41
         setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true);
40 42
     }
41
-    if (!isset($_SESSION['modx.session.created.time'])) {
43
+    if (!isset($_SESSION['modx.session.created.time'])) {
42 44
         $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME'];
43 45
     }
44 46
 }
@@ -48,9 +50,9 @@  discard block
 block discarded – undo
48 50
  * @param $session_name
49 51
  * @return void
50 52
  */
51
-function removeInvalidCmsSessionFromStorage(&$storage, $session_name)
52
-{
53
-    if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) {
53
+function removeInvalidCmsSessionFromStorage(&$storage, $session_name)
54
+{
55
+    if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) {
54 56
         unset($storage[$session_name]);
55 57
     }
56 58
 }
@@ -59,9 +61,11 @@  discard block
 block discarded – undo
59 61
  * @param $session_name
60 62
  * @return void
61 63
  */
62
-function removeInvalidCmsSessionIds($session_name)
63
-{
64
-    if(MODX_CLI) return;
64
+function removeInvalidCmsSessionIds($session_name)
65
+{
66
+    if(MODX_CLI) {
67
+        return;
68
+    }
65 69
     // session ids is invalid iff it is empty string
66 70
     // storage priorioty can see in PHP source ext/session/session.c
67 71
     removeInvalidCmsSessionFromStorage($_COOKIE, $session_name);
Please login to merge, or discard this patch.
install/actions/action_mode.php 1 patch
Braces   +12 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,20 +1,22 @@
 block discarded – undo
1 1
 <?php
2 2
 // Determine upgradeability
3 3
 $upgradeable = 0;
4
-if (is_file($base_path . MGR_DIR . '/includes/config.inc.php')) { // Include the file so we can test its validity
4
+if (is_file($base_path . MGR_DIR . '/includes/config.inc.php')) {
5
+// Include the file so we can test its validity
5 6
     include_once $base_path . MGR_DIR . '/includes/config.inc.php';
6 7
     // We need to have all connection settings - tho prefix may be empty so we have to ignore it
7 8
     if (isset($dbase)) {
8
-        if (!$conn = @mysqli_connect($database_server, $database_user, $database_password))
9
-            $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2;
10
-        elseif (!@mysqli_select_db($conn, trim($dbase, '`')))
11
-            $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2;
12
-        else
13
-            $upgradeable = 1;
9
+        if (!$conn = @mysqli_connect($database_server, $database_user, $database_password)) {
10
+                    $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2;
11
+        } elseif (!@mysqli_select_db($conn, trim($dbase, '`'))) {
12
+                    $upgradeable = isset($_POST['installmode']) && $_POST['installmode'] == 'new' ? 0 : 2;
13
+        } else {
14
+                    $upgradeable = 1;
15
+        }
16
+    } else {
17
+            $upgradeable = 2;
18
+    }
14 19
     }
15
-    else
16
-        $upgradeable = 2;
17
-}
18 20
 
19 21
 $ph['moduleName']       = $moduleName;
20 22
 $ph['displayNew']       = ($upgradeable!=0) ? 'display:none;' : '';
Please login to merge, or discard this patch.
manager/processors/save_content.processor.php 1 patch
Braces   +23 added lines, -19 removed lines patch added patch discarded remove patch
@@ -134,8 +134,7 @@  discard block
 block discarded – undo
134 134
         }
135 135
         //end webber
136 136
     }
137
-}
138
-elseif ($alias) {
137
+} elseif ($alias) {
139 138
     $alias = $modx->stripAlias($alias);
140 139
 }
141 140
 
@@ -149,8 +148,7 @@  discard block
 block discarded – undo
149 148
 
150 149
     if ($pub_date < $currentdate) {
151 150
         $published = 1;
152
-    }
153
-    elseif ($pub_date > $currentdate) {
151
+    } elseif ($pub_date > $currentdate) {
154 152
         $published = 0;
155 153
     }
156 154
 }
@@ -278,8 +276,7 @@  discard block
 block discarded – undo
278 276
         case 'new' :
279 277
 
280 278
             // invoke OnBeforeDocFormSave event
281
-            switch($modx->config['docid_incrmnt_method'])
282
-            {
279
+            switch($modx->config['docid_incrmnt_method']) {
283 280
             case '1':
284 281
                 $from = "{$tbl_site_content} AS T0 LEFT JOIN {$tbl_site_content} AS T1 ON T0.id + 1 = T1.id";
285 282
                 $where = "T1.id IS NULL";
@@ -347,8 +344,9 @@  discard block
 block discarded – undo
347 344
             "alias_visible"    => $aliasvisible
348 345
         );
349 346
 
350
-        if ($id != '')
351
-            $dbInsert["id"] = $id;
347
+        if ($id != '') {
348
+                    $dbInsert["id"] = $id;
349
+        }
352 350
 
353 351
         $key = $modx->db->insert($dbInsert, $tbl_site_content);
354 352
 
@@ -424,11 +422,13 @@  discard block
 block discarded – undo
424 422
         // redirect/stay options
425 423
         if ($_POST['stay'] != '') {
426 424
             // weblink
427
-            if ($_POST['mode'] == "72")
428
-                $a = ($_POST['stay'] == '2') ? "27&id=$key" : "72&pid=$parent";
425
+            if ($_POST['mode'] == "72") {
426
+                            $a = ($_POST['stay'] == '2') ? "27&id=$key" : "72&pid=$parent";
427
+            }
429 428
             // document
430
-            if ($_POST['mode'] == "4")
431
-                $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent";
429
+            if ($_POST['mode'] == "4") {
430
+                            $a = ($_POST['stay'] == '2') ? "27&id=$key" : "4&pid=$parent";
431
+            }
432 432
             $header = "Location: index.php?a=".$a."&r=1&stay=".$_POST['stay'];
433 433
         } else {
434 434
             $header = "Location: index.php?a=3&id=$key&r=1";
@@ -489,10 +489,10 @@  discard block
 block discarded – undo
489 489
             if (!$was_published && $published) {
490 490
                 $publishedon = $currentdate;
491 491
                 $publishedby = $modx->getLoginUserID();
492
-                }elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) {
492
+                } elseif ((!empty($pub_date)&& $pub_date<=$currentdate && $published)) {
493 493
                 $publishedon = $pub_date;
494 494
                 $publishedby = $modx->getLoginUserID();
495
-                   }elseif ($was_published && !$published) {
495
+                   } elseif ($was_published && !$published) {
496 496
                 $publishedon = 0;
497 497
                 $publishedby = 0;
498 498
             } else {
@@ -548,7 +548,9 @@  discard block
 block discarded – undo
548 548
             $tvChanges = array();
549 549
             foreach ($tmplvars as $field => $value) {
550 550
                 if (!is_array($value)) {
551
-                    if (isset($tvIds[$value])) $tvDeletions[] = $tvIds[$value];
551
+                    if (isset($tvIds[$value])) {
552
+                        $tvDeletions[] = $tvIds[$value];
553
+                    }
552 554
                 } else {
553 555
                     $tvId = $value[0];
554 556
                     $tvVal = $value[1];
@@ -596,7 +598,9 @@  discard block
 block discarded – undo
596 598
                     "((1=".(int)$isManager." AND dgn.private_memgroup) OR (1=".(int)$isWeb." AND dgn.private_webgroup)) AND groups.document = '{$id}'"
597 599
                     );
598 600
                 $old_groups = array();
599
-                while ($row = $modx->db->getRow($rs)) $old_groups[$row['document_group']] = $row['id'];
601
+                while ($row = $modx->db->getRow($rs)) {
602
+                    $old_groups[$row['document_group']] = $row['id'];
603
+                }
600 604
 
601 605
                 // update the permissions in the database
602 606
                 $insertions = $deletions = array();
@@ -658,9 +662,9 @@  discard block
 block discarded – undo
658 662
                 $modx->clearCache('full');
659 663
             }
660 664
 
661
-            if ($_POST['refresh_preview'] == '1')
662
-                $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev";
663
-            else {
665
+            if ($_POST['refresh_preview'] == '1') {
666
+                            $header = "Location: ".MODX_SITE_URL."index.php?id=$id&z=manprev";
667
+            } else {
664 668
                 if ($_POST['stay'] != '2' && $id > 0) {
665 669
                     $modx->unlockElement(7, $id);
666 670
                 }
Please login to merge, or discard this patch.
install/cli-install.php 1 patch
Braces   +98 added lines, -66 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 $args = array_slice($argv, 1);
59 59
 
60
-if ( empty($args) ){
60
+if ( empty($args) ) {
61 61
     echo 'Install Evolution CMS'.PHP_EOL;
62 62
     //$installYes = readline("Type 'y' to continue: ");
63 63
     //if ($installYes != 'y') return;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     $managerlanguage = readline('Мanager language:' . ' [en] ');
77 77
     $installData = readline('Instal demo-site (y/n):' . ' [n] ');
78 78
     
79
-}else{
79
+} else {
80 80
     
81 81
     $cli_variables = [];
82 82
     foreach ($args as $arg) {
@@ -130,21 +130,24 @@  discard block
 block discarded – undo
130 130
 }
131 131
 
132 132
 //////////////////////////////////////////////////////////////////////////////////////
133
-if( ! function_exists('f_owc')){
133
+if( ! function_exists('f_owc')) {
134 134
     /**
135 135
      * @param $path
136 136
      * @param $data
137 137
      * @param null|int $mode
138 138
      */
139
-    function f_owc($path, $data, $mode = null){
139
+    function f_owc($path, $data, $mode = null)
140
+    {
140 141
         try {
141 142
             // make an attempt to create the file
142 143
             $hnd = fopen($path, 'w');
143 144
             fwrite($hnd, $data);
144 145
             fclose($hnd);
145 146
 
146
-            if(null !== $mode) chmod($path, $mode);
147
-        }catch(Exception $e){
147
+            if(null !== $mode) {
148
+                chmod($path, $mode);
149
+            }
150
+        } catch(Exception $e) {
148 151
             // Nothing, this is NOT normal
149 152
             unset($e);
150 153
         }
@@ -210,7 +213,7 @@  discard block
 block discarded – undo
210 213
 
211 214
 // File Browser directories exists?
212 215
 echo strip_tags($_lang['checking_if_images_exist']);
213
-switch(true){
216
+switch(true) {
214 217
     case !file_exists($path."../assets/images"):
215 218
     case !file_exists($path."../assets/files"):
216 219
     case !file_exists($path."../assets/backup"):
@@ -225,7 +228,7 @@  discard block
 block discarded – undo
225 228
 
226 229
 // File Browser directories writable?
227 230
 echo strip_tags($_lang['checking_if_images_writable']);
228
-switch(true){
231
+switch(true) {
229 232
     case !is_writable($path."../assets/images"):
230 233
     case !is_writable($path."../assets/files"):
231 234
     case !is_writable($path."../assets/backup"):
@@ -361,7 +364,7 @@  discard block
 block discarded – undo
361 364
 if ($conn) {
362 365
     echo $_lang['checking_mysql_strict_mode'];
363 366
     $mysqlmode = mysqli_query($conn, "SELECT @@global.sql_mode");
364
-    if (mysqli_num_rows($mysqlmode) > 0){
367
+    if (mysqli_num_rows($mysqlmode) > 0) {
365 368
         $modes = mysqli_fetch_array($mysqlmode, MYSQLI_NUM);
366 369
         //$modes = array("STRICT_TRANS_TABLES"); // for testing
367 370
         // print_r($modes);
@@ -397,9 +400,9 @@  discard block
 block discarded – undo
397 400
 if ($errors > 0) {
398 401
     echo $_lang['setup_cannot_continue'] . ' ';
399 402
 
400
-    if($errors > 1){
403
+    if($errors > 1) {
401 404
         echo $errors . " " . $_lang['errors'] . $_lang['please_correct_errors'] . $_lang['and_try_again_plural'];
402
-    }else{
405
+    } else {
403 406
         echo $_lang['error'] . $_lang['please_correct_error'] . $_lang['and_try_again']. PHP_EOL;
404 407
     }
405 408
 
@@ -445,13 +448,15 @@  discard block
 block discarded – undo
445 448
 
446 449
 // get base path and url
447 450
 $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"])));
448
-if (count($a) > 1)
451
+if (count($a) > 1) {
449 452
     array_pop($a);
453
+}
450 454
 $url = implode("install", $a);
451 455
 reset($a);
452 456
 $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__))));
453
-if (count($a) > 1)
457
+if (count($a) > 1) {
454 458
     array_pop($a);
459
+}
455 460
 $pth = implode("install", $a);
456 461
 unset ($a);
457 462
 $base_url = $url . (substr($url, -1) != "/" ? "/" : "");
@@ -472,7 +477,9 @@  discard block
 block discarded – undo
472 477
     echo $_lang['setup_database_selection_failed']." ".$_lang['setup_database_selection_failed_note'].PHP_EOL;
473 478
     $create = true;
474 479
 } else {
475
-    if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset);
480
+    if (function_exists('mysqli_set_charset')) {
481
+        mysqli_set_charset($conn, $database_charset);
482
+    }
476 483
     mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}");
477 484
     echo $_lang['ok'].PHP_EOL;
478 485
 }
@@ -518,7 +525,8 @@  discard block
 block discarded – undo
518 525
      * @param string $propertyString
519 526
      * @return array
520 527
      */
521
-    function parseProperties($propertyString) {
528
+    function parseProperties($propertyString)
529
+    {
522 530
         $parameter= array ();
523 531
         if (!empty ($propertyString)) {
524 532
             $tmpParams= explode("&", $propertyString);
@@ -527,11 +535,14 @@  discard block
 block discarded – undo
527 535
                 if (strpos($tmpParams[$x], '=', 0)) {
528 536
                     $pTmp= explode("=", $tmpParams[$x]);
529 537
                     $pvTmp= explode(";", trim($pTmp[1]));
530
-                    if ($pvTmp[1] == 'list' && $pvTmp[3] != "")
531
-                        $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default
538
+                    if ($pvTmp[1] == 'list' && $pvTmp[3] != "") {
539
+                                            $parameter[trim($pTmp[0])]= $pvTmp[3];
540
+                    }
541
+                    //list default
532 542
                     else
533
-                        if ($pvTmp[1] != 'list' && $pvTmp[2] != "")
534
-                            $parameter[trim($pTmp[0])]= $pvTmp[2];
543
+                        if ($pvTmp[1] != 'list' && $pvTmp[2] != "") {
544
+                                                    $parameter[trim($pTmp[0])]= $pvTmp[2];
545
+                        }
535 546
                 }
536 547
             }
537 548
         }
@@ -579,12 +590,12 @@  discard block
 block discarded – undo
579 590
 $mt = &$moduleTemplates;
580 591
 if(is_dir($templatePath) && is_readable($templatePath)) {
581 592
     $d = dir($templatePath);
582
-    while (false !== ($tplfile = $d->read()))
583
-    {
584
-        if(substr($tplfile, -4) != '.tpl') continue;
593
+    while (false !== ($tplfile = $d->read())) {
594
+        if(substr($tplfile, -4) != '.tpl') {
595
+            continue;
596
+        }
585 597
         $params = parse_docblock($templatePath, $tplfile);
586
-        if(is_array($params) && (count($params)>0))
587
-        {
598
+        if(is_array($params) && (count($params)>0)) {
588 599
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
589 600
             $mt[] = array
590 601
             (
@@ -608,7 +619,9 @@  discard block
 block discarded – undo
608 619
 if(is_dir($tvPath) && is_readable($tvPath)) {
609 620
     $d = dir($tvPath);
610 621
     while (false !== ($tplfile = $d->read())) {
611
-        if(substr($tplfile, -4) != '.tpl') continue;
622
+        if(substr($tplfile, -4) != '.tpl') {
623
+            continue;
624
+        }
612 625
         $params = parse_docblock($tvPath, $tplfile);
613 626
         if(is_array($params) && (count($params)>0)) {
614 627
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
@@ -801,7 +814,8 @@  discard block
 block discarded – undo
801 814
 // setup callback function
802 815
 $callBackFnc = "clean_up";
803 816
 
804
-function clean_up($sqlParser) {
817
+function clean_up($sqlParser)
818
+{
805 819
     $ids = array();
806 820
 
807 821
     // secure web documents - privateweb
@@ -814,9 +828,10 @@  discard block
 block discarded – undo
814 828
     $ds = mysqli_query($sqlParser->conn,$sql);
815 829
     if(!$ds) {
816 830
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
817
-    }
818
-    else {
819
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
831
+    } else {
832
+        while($r = mysqli_fetch_assoc($ds)) {
833
+            $ids[]=$r["id"];
834
+        }
820 835
         if(count($ids)>0) {
821 836
             mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")");
822 837
             unset($ids);
@@ -833,9 +848,10 @@  discard block
 block discarded – undo
833 848
     $ds = mysqli_query($sqlParser->conn,$sql);
834 849
     if(!$ds) {
835 850
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
836
-    }
837
-    else {
838
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
851
+    } else {
852
+        while($r = mysqli_fetch_assoc($ds)) {
853
+            $ids[]=$r["id"];
854
+        }
839 855
         if(count($ids)>0) {
840 856
             mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")");
841 857
             unset($ids);
@@ -843,7 +859,8 @@  discard block
 block discarded – undo
843 859
     }
844 860
 }
845 861
 
846
-function parse_docblock($element_dir, $filename) {
862
+function parse_docblock($element_dir, $filename)
863
+{
847 864
     $params = array();
848 865
     $fullpath = $element_dir . '/' . $filename;
849 866
     if(is_readable($fullpath)) {
@@ -944,7 +961,7 @@  discard block
 block discarded – undo
944 961
 // custom or not
945 962
 if (file_exists($path."../assets/cache/siteManager.php")) {
946 963
     $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");';
947
-}else{
964
+} else {
948 965
     $mgrdir = 'define(\'MGR_DIR\', \'manager\');';
949 966
 }
950 967
 
@@ -1084,7 +1101,9 @@  discard block
 block discarded – undo
1084 1101
                         echo mysqli_error($sqlParser->conn) . PHP_EOL;
1085 1102
                         die();
1086 1103
                     }
1087
-                    if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1104
+                    if(!is_null($save_sql_id_as)) {
1105
+                        $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1106
+                    }
1088 1107
                     echo "  $name: " . $_lang['installed'] . PHP_EOL;
1089 1108
                 }
1090 1109
             }
@@ -1179,9 +1198,9 @@  discard block
 block discarded – undo
1179 1198
             $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]);
1180 1199
             $filecontent = $moduleChunk[2];
1181 1200
 
1182
-            if (!file_exists($filecontent))
1183
-                echo "  $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1184
-            else {
1201
+            if (!file_exists($filecontent)) {
1202
+                            echo "  $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1203
+            } else {
1185 1204
 
1186 1205
                 // Create the category if it does not already exist
1187 1206
                 $category_id = getCreateDbCategory($category, $sqlParser);
@@ -1234,9 +1253,9 @@  discard block
 block discarded – undo
1234 1253
             $guid = mysqli_real_escape_string($conn, $moduleModule[4]);
1235 1254
             $shared = mysqli_real_escape_string($conn, $moduleModule[5]);
1236 1255
             $category = mysqli_real_escape_string($conn, $moduleModule[6]);
1237
-            if (!file_exists($filecontent))
1238
-                echo "  $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1239
-            else {
1256
+            if (!file_exists($filecontent)) {
1257
+                            echo "  $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1258
+            } else {
1240 1259
 
1241 1260
                 // Create the category if it does not already exist
1242 1261
                 $category = getCreateDbCategory($category, $sqlParser);
@@ -1254,7 +1273,7 @@  discard block
 block discarded – undo
1254 1273
                     }
1255 1274
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1256 1275
                 } else {
1257
-                    if ($properties != NULL ){
1276
+                    if ($properties != NULL ) {
1258 1277
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1259 1278
                     }
1260 1279
                     if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) {
@@ -1289,9 +1308,9 @@  discard block
 block discarded – undo
1289 1308
                 // parse comma-separated legacy names and prepare them for sql IN clause
1290 1309
                 $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'";
1291 1310
             }
1292
-            if (!file_exists($filecontent))
1293
-                echo "  $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1294
-            else {
1311
+            if (!file_exists($filecontent)) {
1312
+                            echo "  $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1313
+            } else {
1295 1314
 
1296 1315
                 // disable legacy versions based on legacy_names provided
1297 1316
                 if(!empty($leg_names)) {
@@ -1310,7 +1329,7 @@  discard block
 block discarded – undo
1310 1329
                     $insert = true;
1311 1330
                     while($row = mysqli_fetch_assoc($rs)) {
1312 1331
                         $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1313
-                        if($row['description'] == $desc){
1332
+                        if($row['description'] == $desc) {
1314 1333
                             if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
1315 1334
                                 echo mysqli_error($sqlParser->conn) . PHP_EOL;
1316 1335
                                 return;
@@ -1332,7 +1351,7 @@  discard block
 block discarded – undo
1332 1351
                     }
1333 1352
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1334 1353
                 } else {
1335
-                    if ($properties != NULL ){
1354
+                    if ($properties != NULL ) {
1336 1355
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1337 1356
                     }
1338 1357
                     if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);")) {
@@ -1371,9 +1390,9 @@  discard block
 block discarded – undo
1371 1390
             $filecontent = $moduleSnippet[2];
1372 1391
             $properties = $moduleSnippet[3];
1373 1392
             $category = mysqli_real_escape_string($conn, $moduleSnippet[4]);
1374
-            if (!file_exists($filecontent))
1375
-                echo "  $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1376
-            else {
1393
+            if (!file_exists($filecontent)) {
1394
+                            echo "  $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1395
+            } else {
1377 1396
 
1378 1397
                 // Create the category if it does not already exist
1379 1398
                 $category = getCreateDbCategory($category, $sqlParser);
@@ -1391,7 +1410,7 @@  discard block
 block discarded – undo
1391 1410
                     }
1392 1411
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1393 1412
                 } else {
1394
-                    if ($properties != NULL ){
1413
+                    if ($properties != NULL ) {
1395 1414
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1396 1415
                     }
1397 1416
                     if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
@@ -1484,11 +1503,14 @@  discard block
 block discarded – undo
1484 1503
 }
1485 1504
 
1486 1505
 // call back function
1487
-if ($callBackFnc != "")
1506
+if ($callBackFnc != "") {
1488 1507
     $callBackFnc ($sqlParser);
1508
+}
1489 1509
 
1490 1510
 // Setup the MODX API -- needed for the cache processor
1491
-if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
1511
+if (!defined('MODX_MANAGER_PATH')) {
1512
+    define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
1513
+}
1492 1514
 $database_type = 'mysqli';
1493 1515
 // initiate a new document parser
1494 1516
 include_once($path.'../'.MGR_DIR.'/includes/document.parser.class.inc.php');
@@ -1527,7 +1549,7 @@  discard block
 block discarded – undo
1527 1549
 }
1528 1550
 
1529 1551
 
1530
-if ( empty($args) ){
1552
+if ( empty($args) ) {
1531 1553
     echo PHP_EOL . 'Remove install folder?'.PHP_EOL;
1532 1554
     $removeInstall = readline("Type 'y' or 'n' to continue: ");
1533 1555
 }
@@ -1543,11 +1565,12 @@  discard block
 block discarded – undo
1543 1565
  * @param string $old
1544 1566
  * @return string
1545 1567
  */
1546
-function propUpdate($new,$old){
1568
+function propUpdate($new,$old)
1569
+{
1547 1570
     $newArr = parseProperties($new);
1548 1571
     $oldArr = parseProperties($old);
1549
-    foreach ($oldArr as $k => $v){
1550
-        if (isset($v['0']['options'])){
1572
+    foreach ($oldArr as $k => $v) {
1573
+        if (isset($v['0']['options'])) {
1551 1574
             $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options'];
1552 1575
         }
1553 1576
     }
@@ -1562,12 +1585,17 @@  discard block
 block discarded – undo
1562 1585
  * @param bool|mixed $json
1563 1586
  * @return string
1564 1587
  */
1565
-function parseProperties($propertyString, $json=false) {
1588
+function parseProperties($propertyString, $json=false)
1589
+{
1566 1590
     $propertyString = str_replace('{}', '', $propertyString );
1567 1591
     $propertyString = str_replace('} {', ',', $propertyString );
1568 1592
 
1569
-    if(empty($propertyString)) return array();
1570
-    if($propertyString=='{}' || $propertyString=='[]') return array();
1593
+    if(empty($propertyString)) {
1594
+        return array();
1595
+    }
1596
+    if($propertyString=='{}' || $propertyString=='[]') {
1597
+        return array();
1598
+    }
1571 1599
 
1572 1600
     $jsonFormat = isJson($propertyString, true);
1573 1601
     $property = array();
@@ -1609,7 +1637,7 @@  discard block
 block discarded – undo
1609 1637
 
1610 1638
         }
1611 1639
     // new json-format
1612
-    } else if(!empty($jsonFormat)){
1640
+    } else if(!empty($jsonFormat)) {
1613 1641
         $property = $jsonFormat;
1614 1642
     }
1615 1643
     if ($json) {
@@ -1624,7 +1652,8 @@  discard block
 block discarded – undo
1624 1652
  * @param bool $returnData
1625 1653
  * @return bool|mixed
1626 1654
  */
1627
-function isJson($string, $returnData=false) {
1655
+function isJson($string, $returnData=false)
1656
+{
1628 1657
     $data = json_decode($string, true);
1629 1658
     return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false;
1630 1659
 }
@@ -1634,7 +1663,8 @@  discard block
 block discarded – undo
1634 1663
  * @param SqlParser $sqlParser
1635 1664
  * @return int
1636 1665
  */
1637
-function getCreateDbCategory($category, $sqlParser) {
1666
+function getCreateDbCategory($category, $sqlParser)
1667
+{
1638 1668
     $dbase = $sqlParser->dbname;
1639 1669
     $dbase = '`' . trim($dbase,'`') . '`';
1640 1670
     $table_prefix = $sqlParser->prefix;
@@ -1662,7 +1692,8 @@  discard block
 block discarded – undo
1662 1692
  * @param string $type
1663 1693
  * @return string
1664 1694
  */
1665
-function removeDocblock($code, $type) {
1695
+function removeDocblock($code, $type)
1696
+{
1666 1697
 
1667 1698
     $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
1668 1699
 
@@ -1683,8 +1714,9 @@  discard block
 block discarded – undo
1683 1714
         default:
1684 1715
             return $cleaned;
1685 1716
     };
1686
-    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
1687
-        return $cleaned;
1717
+    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') {
1718
+            return $cleaned;
1719
+    }
1688 1720
 
1689 1721
     // fileBinding not found - return code incl docblock
1690 1722
     return $code;
Please login to merge, or discard this patch.
manager/includes/log.class.inc.php 1 patch
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -105,7 +105,8 @@  discard block
 block discarded – undo
105 105
         }
106 106
     }
107 107
 
108
-    private function getUserIP() {
108
+    private function getUserIP()
109
+    {
109 110
         if( array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
110 111
             if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')>0) {
111 112
                 $addr = explode(",",$_SERVER['HTTP_X_FORWARDED_FOR']);
@@ -113,8 +114,7 @@  discard block
 block discarded – undo
113 114
             } else {
114 115
                 return $_SERVER['HTTP_X_FORWARDED_FOR'];
115 116
             }
116
-        }
117
-        else {
117
+        } else {
118 118
             return $_SERVER['REMOTE_ADDR'];
119 119
         }
120 120
     }
Please login to merge, or discard this patch.