Completed
Push — develop ( a90c15...940a29 )
by Maxim
22:53 queued 16:45
created
install/actions/action_options.php 1 patch
Braces   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -182,16 +182,18 @@  discard block
 block discarded – undo
182 182
     }
183 183
 }
184 184
 
185
-switch($installMode){
185
+switch($installMode) {
186 186
     case 0:
187 187
     case 2:
188 188
         $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci';
189 189
         $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
190 190
         $_POST['database_connection_charset'] = $database_charset;
191
-        if(!empty($_POST['databaseloginpassword']))
192
-            $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword'];
193
-        if(!empty($_POST['databaseloginname']))
194
-            $_SESSION['databaseloginname'] = $_POST['databaseloginname'];
191
+        if(!empty($_POST['databaseloginpassword'])) {
192
+                    $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword'];
193
+        }
194
+        if(!empty($_POST['databaseloginname'])) {
195
+                    $_SESSION['databaseloginname'] = $_POST['databaseloginname'];
196
+        }
195 197
         break;
196 198
     case 1:
197 199
         include $base_path . MGR_DIR . '/includes/config.inc.php';
@@ -205,7 +207,9 @@  discard block
 block discarded – undo
205 207
                 }
206 208
             }
207 209
         }
208
-        if (empty ($database_collation)) $database_collation = 'utf8_general_ci';
210
+        if (empty ($database_collation)) {
211
+            $database_collation = 'utf8_general_ci';
212
+        }
209 213
 
210 214
         $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
211 215
         if (!isset ($database_connection_charset) || empty ($database_connection_charset)) {
@@ -214,7 +218,9 @@  discard block
 block discarded – undo
214 218
 
215 219
         if (!isset ($database_connection_method) || empty ($database_connection_method)) {
216 220
             $database_connection_method = 'SET CHARACTER SET';
217
-            if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_connection_charset);
221
+            if (function_exists('mysqli_set_charset')) {
222
+                mysqli_set_charset($conn, $database_connection_charset);
223
+            }
218 224
         }
219 225
         if ($database_connection_method != 'SET NAMES' && $database_connection_charset != $database_charset) {
220 226
             $database_connection_method = 'SET NAMES';
Please login to merge, or discard this patch.
install/instprocessor.php 1 patch
Braces   +61 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) {
3 3
     include_once(dirname(__FILE__)."/../assets/cache/siteManager.php");
4
-}else{
4
+} else {
5 5
     define('MGR_DIR', 'manager');
6 6
 }
7 7
 define('MODX_CLI', false);
@@ -59,13 +59,15 @@  discard block
 block discarded – undo
59 59
 
60 60
 // get base path and url
61 61
 $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"])));
62
-if (count($a) > 1)
62
+if (count($a) > 1) {
63 63
     array_pop($a);
64
+}
64 65
 $url = implode("install", $a);
65 66
 reset($a);
66 67
 $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__))));
67
-if (count($a) > 1)
68
+if (count($a) > 1) {
68 69
     array_pop($a);
70
+}
69 71
 $pth = implode("install", $a);
70 72
 unset ($a);
71 73
 $base_url = $url . (substr($url, -1) != "/" ? "/" : "");
@@ -86,7 +88,9 @@  discard block
 block discarded – undo
86 88
     echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>";
87 89
     $create = true;
88 90
 } else {
89
-	if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset);
91
+	if (function_exists('mysqli_set_charset')) {
92
+	    mysqli_set_charset($conn, $database_charset);
93
+	}
90 94
     mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}");
91 95
     echo '<span class="ok">'.$_lang['ok']."</span></p>";
92 96
 }
@@ -133,7 +137,8 @@  discard block
 block discarded – undo
133 137
      * @param string $propertyString
134 138
      * @return array
135 139
      */
136
-    function parseProperties($propertyString) {
140
+    function parseProperties($propertyString)
141
+    {
137 142
         $parameter= array ();
138 143
         if (!empty ($propertyString)) {
139 144
             $tmpParams= explode("&", $propertyString);
@@ -142,11 +147,14 @@  discard block
 block discarded – undo
142 147
                 if (strpos($tmpParams[$x], '=', 0)) {
143 148
                     $pTmp= explode("=", $tmpParams[$x]);
144 149
                     $pvTmp= explode(";", trim($pTmp[1]));
145
-                    if ($pvTmp[1] == 'list' && $pvTmp[3] != "")
146
-                        $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default
150
+                    if ($pvTmp[1] == 'list' && $pvTmp[3] != "") {
151
+                                            $parameter[trim($pTmp[0])]= $pvTmp[3];
152
+                    }
153
+                    //list default
147 154
                     else
148
-                        if ($pvTmp[1] != 'list' && $pvTmp[2] != "")
149
-                            $parameter[trim($pTmp[0])]= $pvTmp[2];
155
+                        if ($pvTmp[1] != 'list' && $pvTmp[2] != "") {
156
+                                                    $parameter[trim($pTmp[0])]= $pvTmp[2];
157
+                        }
150 158
                 }
151 159
             }
152 160
         }
@@ -217,7 +225,7 @@  discard block
 block discarded – undo
217 225
 // custom or not
218 226
 if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) {
219 227
     $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");';
220
-}else{
228
+} else {
221 229
     $mgrdir = 'define(\'MGR_DIR\', \'manager\');';
222 230
 }
223 231
 
@@ -353,7 +361,9 @@  discard block
 block discarded – undo
353 361
                         echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
354 362
                         return;
355 363
                     }
356
-                    if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
364
+                    if(!is_null($save_sql_id_as)) {
365
+                        $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
366
+                    }
357 367
                     echo "<p>&nbsp;&nbsp;$name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>";
358 368
                 }
359 369
             }
@@ -447,9 +457,9 @@  discard block
 block discarded – undo
447 457
             $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]);
448 458
             $filecontent = $moduleChunk[2];
449 459
 
450
-            if (!file_exists($filecontent))
451
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
452
-            else {
460
+            if (!file_exists($filecontent)) {
461
+                            echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
462
+            } else {
453 463
 
454 464
                 // Create the category if it does not already exist
455 465
                 $category_id = getCreateDbCategory($category, $sqlParser);
@@ -501,9 +511,9 @@  discard block
 block discarded – undo
501 511
             $guid = mysqli_real_escape_string($conn, $moduleModule[4]);
502 512
             $shared = mysqli_real_escape_string($conn, $moduleModule[5]);
503 513
             $category = mysqli_real_escape_string($conn, $moduleModule[6]);
504
-            if (!file_exists($filecontent))
505
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
506
-            else {
514
+            if (!file_exists($filecontent)) {
515
+                            echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
516
+            } else {
507 517
 
508 518
                 // Create the category if it does not already exist
509 519
                 $category = getCreateDbCategory($category, $sqlParser);
@@ -553,9 +563,9 @@  discard block
 block discarded – undo
553 563
                 // parse comma-separated legacy names and prepare them for sql IN clause
554 564
                 $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'";
555 565
             }
556
-            if (!file_exists($filecontent))
557
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
558
-            else {
566
+            if (!file_exists($filecontent)) {
567
+                            echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
568
+            } else {
559 569
 
560 570
                 // disable legacy versions based on legacy_names provided
561 571
                 if(!empty($leg_names)) {
@@ -574,7 +584,7 @@  discard block
 block discarded – undo
574 584
                     $insert = true;
575 585
                     while($row = mysqli_fetch_assoc($rs)) {
576 586
                         $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
577
-                        if($row['description'] == $desc){
587
+                        if($row['description'] == $desc) {
578 588
                             if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
579 589
                                 echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
580 590
                                 return;
@@ -632,9 +642,9 @@  discard block
 block discarded – undo
632 642
             $filecontent = $moduleSnippet[2];
633 643
             $properties = $moduleSnippet[3];
634 644
             $category = mysqli_real_escape_string($conn, $moduleSnippet[4]);
635
-            if (!file_exists($filecontent))
636
-                echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
637
-            else {
645
+            if (!file_exists($filecontent)) {
646
+                            echo "<p>&nbsp;&nbsp;$name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>";
647
+            } else {
638 648
 
639 649
                 // Create the category if it does not already exist
640 650
                 $category = getCreateDbCategory($category, $sqlParser);
@@ -742,13 +752,16 @@  discard block
 block discarded – undo
742 752
 }
743 753
 
744 754
 // call back function
745
-if ($callBackFnc != "")
755
+if ($callBackFnc != "") {
746 756
     $callBackFnc ($sqlParser);
757
+}
747 758
 
748 759
 // Setup the MODX API -- needed for the cache processor
749 760
 define('MODX_API_MODE', true);
750 761
 define('MODX_BASE_PATH', $base_path);
751
-if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
762
+if (!defined('MODX_MANAGER_PATH')) {
763
+    define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
764
+}
752 765
 $database_type = 'mysqli';
753 766
 // initiate a new document parser
754 767
 include_once('../'.MGR_DIR.'/includes/document.parser.class.inc.php');
@@ -793,11 +806,12 @@  discard block
 block discarded – undo
793 806
  * @param string $old
794 807
  * @return string
795 808
  */
796
-function propUpdate($new,$old){
809
+function propUpdate($new,$old)
810
+{
797 811
     $newArr = parseProperties($new);
798 812
     $oldArr = parseProperties($old);
799
-    foreach ($oldArr as $k => $v){
800
-        if (isset($v['0']['options'])){
813
+    foreach ($oldArr as $k => $v) {
814
+        if (isset($v['0']['options'])) {
801 815
             $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options'];
802 816
         }
803 817
     }
@@ -812,12 +826,17 @@  discard block
 block discarded – undo
812 826
  * @param bool|mixed $json
813 827
  * @return string
814 828
  */
815
-function parseProperties($propertyString, $json=false) {
829
+function parseProperties($propertyString, $json=false)
830
+{
816 831
     $propertyString = str_replace('{}', '', $propertyString );
817 832
     $propertyString = str_replace('} {', ',', $propertyString );
818 833
 
819
-    if(empty($propertyString)) return array();
820
-    if($propertyString=='{}' || $propertyString=='[]') return array();
834
+    if(empty($propertyString)) {
835
+        return array();
836
+    }
837
+    if($propertyString=='{}' || $propertyString=='[]') {
838
+        return array();
839
+    }
821 840
 
822 841
     $jsonFormat = isJson($propertyString, true);
823 842
     $property = array();
@@ -859,7 +878,7 @@  discard block
 block discarded – undo
859 878
 
860 879
         }
861 880
     // new json-format
862
-    } else if(!empty($jsonFormat)){
881
+    } else if(!empty($jsonFormat)) {
863 882
         $property = $jsonFormat;
864 883
     }
865 884
     if ($json) {
@@ -874,7 +893,8 @@  discard block
 block discarded – undo
874 893
  * @param bool $returnData
875 894
  * @return bool|mixed
876 895
  */
877
-function isJson($string, $returnData=false) {
896
+function isJson($string, $returnData=false)
897
+{
878 898
     $data = json_decode($string, true);
879 899
     return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false;
880 900
 }
@@ -884,7 +904,8 @@  discard block
 block discarded – undo
884 904
  * @param SqlParser $sqlParser
885 905
  * @return int
886 906
  */
887
-function getCreateDbCategory($category, $sqlParser) {
907
+function getCreateDbCategory($category, $sqlParser)
908
+{
888 909
     $dbase = $sqlParser->dbname;
889 910
     $dbase = '`' . trim($dbase,'`') . '`';
890 911
     $table_prefix = $sqlParser->prefix;
@@ -912,7 +933,8 @@  discard block
 block discarded – undo
912 933
  * @param string $type
913 934
  * @return string
914 935
  */
915
-function removeDocblock($code, $type) {
936
+function removeDocblock($code, $type)
937
+{
916 938
 
917 939
     $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
918 940
 
@@ -933,8 +955,9 @@  discard block
 block discarded – undo
933 955
         default:
934 956
             return $cleaned;
935 957
     };
936
-    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
937
-        return $cleaned;
958
+    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') {
959
+            return $cleaned;
960
+    }
938 961
 
939 962
     // fileBinding not found - return code incl docblock
940 963
     return $code;
Please login to merge, or discard this patch.