Completed
Push — develop ( 4fe5da...494db2 )
by Dmytro
09:44
created
install/cli-install.php 2 patches
Spacing   +331 added lines, -332 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * php cli-install.php --database_server=localhost --database=db --database_user=dbuser --database_password=dbpass --table_prefix=evo_ --cmsadmin=admin [email protected] --cmspassword=123456 --language=ru --mode=new --installData=n --removeInstall=y 
5 5
  */
6 6
 
7
-$path = dirname(__FILE__) . '/';
7
+$path = dirname(__FILE__).'/';
8 8
 
9 9
 /*
10 10
 $autoloader = realpath(__DIR__.'/../vendor/autoload.php');
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 }*/
14 14
 
15 15
 $self = 'install/index.php';
16
-$base_path = str_replace($self,'',str_replace('\\','/', __FILE__));
16
+$base_path = str_replace($self, '', str_replace('\\', '/', __FILE__));
17 17
 define('MODX_API_MODE', true);
18 18
 define('MODX_BASE_PATH', $base_path);
19 19
 define('MODX_SITE_URL', '/');
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 if (is_file($path."../assets/cache/siteManager.php")) {
27 27
     include_once($path."../assets/cache/siteManager.php");
28 28
 }
29
-if(!defined('MGR_DIR') && is_dir($path."../manager")) {
29
+if (!defined('MGR_DIR') && is_dir($path."../manager")) {
30 30
     define('MGR_DIR', 'manager');
31 31
 }
32 32
 
@@ -40,43 +40,43 @@  discard block
 block discarded – undo
40 40
 $moduleSQLDataFile = "setup.data.sql";
41 41
 $moduleSQLResetFile = "setup.data.reset.sql";
42 42
 
43
-$moduleChunks = array (); // chunks - array : name, description, type - 0:file or 1:content, file or content
44
-$moduleTemplates = array (); // templates - array : name, description, type - 0:file or 1:content, file or content
45
-$moduleSnippets = array (); // snippets - array : name, description, type - 0:file or 1:content, file or content,properties
46
-$modulePlugins = array (); // plugins - array : name, description, type - 0:file or 1:content, file or content,properties, events,guid
47
-$moduleModules = array (); // modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid
48
-$moduleTemplates = array (); // templates - array : name, description, type - 0:file or 1:content, file or content,properties
49
-$moduleTVs = array (); // template variables - array : name, description, type - 0:file or 1:content, file or content,properties
43
+$moduleChunks = array(); // chunks - array : name, description, type - 0:file or 1:content, file or content
44
+$moduleTemplates = array(); // templates - array : name, description, type - 0:file or 1:content, file or content
45
+$moduleSnippets = array(); // snippets - array : name, description, type - 0:file or 1:content, file or content,properties
46
+$modulePlugins = array(); // plugins - array : name, description, type - 0:file or 1:content, file or content,properties, events,guid
47
+$moduleModules = array(); // modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid
48
+$moduleTemplates = array(); // templates - array : name, description, type - 0:file or 1:content, file or content,properties
49
+$moduleTVs = array(); // template variables - array : name, description, type - 0:file or 1:content, file or content,properties
50 50
 $moduleDependencies = array(); // module depedencies - array : module, table, column, type, name
51
-$errors= 0;
51
+$errors = 0;
52 52
 
53 53
 
54
-$installMode= 0;
54
+$installMode = 0;
55 55
 $installData = 0;
56 56
 $tableprefixauto = base_convert(rand(10, 20), 10, 36).substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), rand(0, 33), 3).'_';
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;
64 64
 
65 65
     //set param manual
66
-    $databasehost = readline($_lang['connection_screen_database_host']. ' [localhost] ');
67
-    $databaseloginname = readline($_lang['connection_screen_database_login']. ' ');
68
-    $databaseloginpassword = readline($_lang['connection_screen_database_pass']. ' ');
69
-    $database_name = readline($_lang['connection_screen_database_name']. ' ');
70
-    $tableprefix = readline($_lang['connection_screen_table_prefix']. ' ['.$tableprefixauto.'] ');
71
-    $database_connection_method = readline($_lang['connection_screen_connection_method']. ' [SET CHARACTER SET] ');
72
-    $database_collation = readline($_lang['connection_screen_collation']. ' [utf8_general_ci] ');
73
-    $cmsadmin = readline($_lang['connection_screen_default_admin_login']. ' [admin] ');
74
-    $cmsadminemail = readline($_lang['connection_screen_default_admin_email']. ' ');
75
-    $cmspassword = readline($_lang['connection_screen_default_admin_password']. ' ');
76
-    $managerlanguage = readline('Мanager language:' . ' [en] ');
77
-    $installData = readline('Instal demo-site (y/n):' . ' [n] ');
66
+    $databasehost = readline($_lang['connection_screen_database_host'].' [localhost] ');
67
+    $databaseloginname = readline($_lang['connection_screen_database_login'].' ');
68
+    $databaseloginpassword = readline($_lang['connection_screen_database_pass'].' ');
69
+    $database_name = readline($_lang['connection_screen_database_name'].' ');
70
+    $tableprefix = readline($_lang['connection_screen_table_prefix'].' ['.$tableprefixauto.'] ');
71
+    $database_connection_method = readline($_lang['connection_screen_connection_method'].' [SET CHARACTER SET] ');
72
+    $database_collation = readline($_lang['connection_screen_collation'].' [utf8_general_ci] ');
73
+    $cmsadmin = readline($_lang['connection_screen_default_admin_login'].' [admin] ');
74
+    $cmsadminemail = readline($_lang['connection_screen_default_admin_email'].' ');
75
+    $cmspassword = readline($_lang['connection_screen_default_admin_password'].' ');
76
+    $managerlanguage = readline('Мanager language:'.' [en] ');
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) {
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 }
108 108
 
109 109
 
110
-if ($databasehost == '') { $databasehost= 'localhost'; } 
111
-if ($tableprefix == ''){ $tableprefix = $tableprefixauto; }
110
+if ($databasehost == '') { $databasehost = 'localhost'; } 
111
+if ($tableprefix == '') { $tableprefix = $tableprefixauto; }
112 112
 if ($database_connection_method == '') { $database_connection_method = 'SET CHARACTER SET'; } 
113 113
 if ($database_collation == '') { $database_collation = 'utf8_general_ci'; } 
114
-if ($cmsadmin == ''){ $cmsadmin = 'admin'; }
114
+if ($cmsadmin == '') { $cmsadmin = 'admin'; }
115 115
 if ($managerlanguage == '') { $managerlanguage = 'en'; } 
116
-if ($installData == 'y') { $installData = 1;}
117
-if ($mode == 'upgrade') { $installMode = 1;}
116
+if ($installData == 'y') { $installData = 1; }
117
+if ($mode == 'upgrade') { $installMode = 1; }
118 118
 
119 119
 //добавить обработку языка
120 120
 
@@ -130,7 +130,7 @@  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
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
             fwrite($hnd, $data);
144 144
             fclose($hnd);
145 145
 
146
-            if(null !== $mode) chmod($path, $mode);
147
-        }catch(Exception $e){
146
+            if (null !== $mode) chmod($path, $mode);
147
+        } catch (Exception $e) {
148 148
             // Nothing, this is NOT normal
149 149
             unset($e);
150 150
         }
@@ -154,24 +154,24 @@  discard block
 block discarded – undo
154 154
 // check PHP version
155 155
 define('PHP_MIN_VERSION', '5.4.0');
156 156
 $phpMinVersion = PHP_MIN_VERSION; // Maybe not necessary. For backward compatibility
157
-echo PHP_EOL . $_lang['checking_php_version'];
157
+echo PHP_EOL.$_lang['checking_php_version'];
158 158
 // -1 if left is less, 0 if equal, +1 if left is higher
159 159
 if (version_compare(phpversion(), PHP_MIN_VERSION) < 0) {
160 160
     $errors++;
161
-    $tmp = $_lang['you_running_php'] . phpversion() . str_replace('[+min_version+]', PHP_MIN_VERSION, $_lang["modx_requires_php"]);
162
-    echo $_lang['failed'] . ' ' . $tmp . PHP_EOL;
161
+    $tmp = $_lang['you_running_php'].phpversion().str_replace('[+min_version+]', PHP_MIN_VERSION, $_lang["modx_requires_php"]);
162
+    echo $_lang['failed'].' '.$tmp.PHP_EOL;
163 163
 } else {
164
-    echo $_lang['ok'] . PHP_EOL;
164
+    echo $_lang['ok'].PHP_EOL;
165 165
 }
166 166
 
167 167
 // check directories
168 168
 // cache exists?
169 169
 echo strip_tags($_lang['checking_if_cache_exist']);
170 170
 if (!file_exists($path."../assets/cache") || !file_exists($path."../assets/cache/rss")) {
171
-    echo $_lang['failed'] . PHP_EOL;
171
+    echo $_lang['failed'].PHP_EOL;
172 172
     $errors++;
173 173
 } else {
174
-    echo $_lang['ok'] . PHP_EOL;
174
+    echo $_lang['ok'].PHP_EOL;
175 175
 }
176 176
 
177 177
 
@@ -179,82 +179,82 @@  discard block
 block discarded – undo
179 179
 echo strip_tags($_lang['checking_if_cache_writable']);
180 180
 if (!is_writable($path."../assets/cache")) {
181 181
     $errors++;
182
-    echo $_lang['failed'] . PHP_EOL;
182
+    echo $_lang['failed'].PHP_EOL;
183 183
 } else {
184
-    echo $_lang['ok'] . PHP_EOL;
184
+    echo $_lang['ok'].PHP_EOL;
185 185
 }
186 186
 
187 187
 
188 188
 // cache files writable?
189 189
 echo strip_tags($_lang['checking_if_cache_file_writable']);
190 190
 $tmp = $path."../assets/cache/siteCache.idx.php";
191
-if ( ! file_exists($tmp)) {
191
+if (!file_exists($tmp)) {
192 192
     f_owc($tmp, "<?php //EVO site cache file ?>");
193 193
 }
194
-if ( ! is_writable($tmp)) {
194
+if (!is_writable($tmp)) {
195 195
     $errors++;
196
-    echo $_lang['failed'] . PHP_EOL;
196
+    echo $_lang['failed'].PHP_EOL;
197 197
 } else {
198
-    echo $_lang['ok'] . PHP_EOL;
198
+    echo $_lang['ok'].PHP_EOL;
199 199
 }
200 200
 
201 201
 
202 202
 echo strip_tags($_lang['checking_if_cache_file2_writable']);
203
-if ( ! is_writable($path."../assets/cache/sitePublishing.idx.php")) {
203
+if (!is_writable($path."../assets/cache/sitePublishing.idx.php")) {
204 204
     $errors++;
205
-    echo $_lang['failed'] . PHP_EOL;
205
+    echo $_lang['failed'].PHP_EOL;
206 206
 } else {
207
-    echo $_lang['ok'] . PHP_EOL;
207
+    echo $_lang['ok'].PHP_EOL;
208 208
 }
209 209
 
210 210
 
211 211
 // File Browser directories exists?
212 212
 echo strip_tags($_lang['checking_if_images_exist']);
213
-switch(true){
213
+switch (true) {
214 214
     case !file_exists("../assets/images"):
215 215
     case !file_exists("../assets/files"):
216 216
     case !file_exists("../assets/backup"):
217 217
     //case !file_exists("../assets/.thumbs"):
218 218
         $errors++;
219
-        echo $_lang['failed'] . PHP_EOL;
219
+        echo $_lang['failed'].PHP_EOL;
220 220
         break;
221 221
     default:
222
-        echo $_lang['ok'] . PHP_EOL;
222
+        echo $_lang['ok'].PHP_EOL;
223 223
 }
224 224
 
225 225
 
226 226
 // File Browser directories writable?
227 227
 echo strip_tags($_lang['checking_if_images_writable']);
228
-switch(true){
228
+switch (true) {
229 229
     case !is_writable("../assets/images"):
230 230
     case !is_writable("../assets/files"):
231 231
     case !is_writable("../assets/backup"):
232 232
     //case !is_writable("../assets/.thumbs"):
233 233
         $errors++;
234
-        echo $_lang['failed'] . PHP_EOL;
234
+        echo $_lang['failed'].PHP_EOL;
235 235
         break;
236 236
     default:
237
-        echo $_lang['ok'] . PHP_EOL;
237
+        echo $_lang['ok'].PHP_EOL;
238 238
 }
239 239
 
240 240
 
241 241
 // export exists?
242 242
 echo strip_tags($_lang['checking_if_export_exists']);
243 243
 if (!file_exists("../assets/export")) {
244
-    echo $_lang['failed'] . PHP_EOL;
244
+    echo $_lang['failed'].PHP_EOL;
245 245
     $errors++;
246 246
 } else {
247
-    echo $_lang['ok'] . PHP_EOL;
247
+    echo $_lang['ok'].PHP_EOL;
248 248
 }
249 249
 
250 250
 
251 251
 // export writable?
252 252
 echo strip_tags($_lang['checking_if_export_writable']);
253 253
 if (!is_writable("../assets/export")) {
254
-    echo $_lang['failed'] . PHP_EOL;
254
+    echo $_lang['failed'].PHP_EOL;
255 255
     $errors++;
256 256
 } else {
257
-    echo $_lang['ok'] . PHP_EOL;
257
+    echo $_lang['ok'].PHP_EOL;
258 258
 }
259 259
 
260 260
 
@@ -269,9 +269,9 @@  discard block
 block discarded – undo
269 269
 $isWriteable = is_writable($tmp);
270 270
 if (!$isWriteable) {
271 271
     $errors++;
272
-    echo $_lang['failed'] . PHP_EOL;
272
+    echo $_lang['failed'].PHP_EOL;
273 273
 } else {
274
-    echo $_lang['ok'] . PHP_EOL;
274
+    echo $_lang['ok'].PHP_EOL;
275 275
 }
276 276
 
277 277
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
     $database_charset = substr($database_collation, 0, strpos($database_collation, '_') - 1);
288 288
     $database_connection_charset = $database_collation;
289 289
     $database_connection_method = $database_connection_method;
290
-    $dbase = '`' . $database_name . '`';
290
+    $dbase = '`'.$database_name.'`';
291 291
     $table_prefix = $tableprefix;
292 292
 }
293 293
 echo $_lang['creating_database_connection'];
@@ -327,33 +327,33 @@  discard block
 block discarded – undo
327 327
 
328 328
 // check table prefix
329 329
 if ($conn && $installMode == 0) {
330
-    echo $_lang['checking_table_prefix'] . $table_prefix . '`: ';
331
-    if ($rs= mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
332
-        echo $_lang['failed'] . ' ' . $_lang['table_prefix_already_inuse_note'] . PHP_EOL;
330
+    echo $_lang['checking_table_prefix'].$table_prefix.'`: ';
331
+    if ($rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) {
332
+        echo $_lang['failed'].' '.$_lang['table_prefix_already_inuse_note'].PHP_EOL;
333 333
         $errors++;
334 334
 
335 335
     } else {
336
-        echo $_lang['ok'] . PHP_EOL;
336
+        echo $_lang['ok'].PHP_EOL;
337 337
     }
338 338
 } elseif ($conn && $installMode == 2) {
339
-    echo $_lang['checking_table_prefix'] . $table_prefix . '`: ';
340
-    if (!$rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
341
-        echo $_lang['failed'] . ' ' . $_lang['table_prefix_not_exist'] . PHP_EOL;
339
+    echo $_lang['checking_table_prefix'].$table_prefix.'`: ';
340
+    if (!$rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) {
341
+        echo $_lang['failed'].' '.$_lang['table_prefix_not_exist'].PHP_EOL;
342 342
         $errors++;
343 343
 
344 344
   } else {
345
-        echo $_lang['ok'] . PHP_EOL;
345
+        echo $_lang['ok'].PHP_EOL;
346 346
   }
347 347
 }
348 348
 
349 349
 // check mysql version
350 350
 if ($conn) {
351 351
     echo $_lang['checking_mysql_version'];
352
-    if ( version_compare(mysqli_get_server_info($conn), '5.0.51', '=') ) {
353
-        echo $_lang['warning'] . ' ' . $_lang['mysql_5051'] . PHP_EOL;
354
-        echo $_lang['mysql_5051_warning'] . PHP_EOL;
352
+    if (version_compare(mysqli_get_server_info($conn), '5.0.51', '=')) {
353
+        echo $_lang['warning'].' '.$_lang['mysql_5051'].PHP_EOL;
354
+        echo $_lang['mysql_5051_warning'].PHP_EOL;
355 355
     } else {
356
-        echo $_lang['ok'] . ' ' . $_lang['mysql_version_is'] . mysqli_get_server_info($conn) . PHP_EOL;
356
+        echo $_lang['ok'].' '.$_lang['mysql_version_is'].mysqli_get_server_info($conn).PHP_EOL;
357 357
     }
358 358
 }
359 359
 
@@ -361,20 +361,20 @@  discard block
 block discarded – undo
361 361
 if ($conn) {
362 362
     echo $_lang['checking_mysql_strict_mode'];
363 363
     $mysqlmode = mysqli_query($conn, "SELECT @@global.sql_mode");
364
-    if (mysqli_num_rows($mysqlmode) > 0){
364
+    if (mysqli_num_rows($mysqlmode) > 0) {
365 365
         $modes = mysqli_fetch_array($mysqlmode, MYSQLI_NUM);
366 366
         //$modes = array("STRICT_TRANS_TABLES"); // for testing
367 367
         // print_r($modes);
368 368
         foreach ($modes as $mode) {
369 369
             if (stristr($mode, "STRICT_TRANS_TABLES") !== false || stristr($mode, "STRICT_ALL_TABLES") !== false) {
370
-                echo $_lang['warning'] . ' ' . $_lang['strict_mode'] . PHP_EOL;
371
-                echo $_lang['strict_mode_error'] . PHP_EOL;
370
+                echo $_lang['warning'].' '.$_lang['strict_mode'].PHP_EOL;
371
+                echo $_lang['strict_mode_error'].PHP_EOL;
372 372
             } else {
373
-                echo $_lang['ok'] . PHP_EOL;
373
+                echo $_lang['ok'].PHP_EOL;
374 374
             }
375 375
         }
376 376
     } else {
377
-        echo $_lang['ok'] . PHP_EOL;
377
+        echo $_lang['ok'].PHP_EOL;
378 378
     }
379 379
 }
380 380
 // Version and strict mode check end
@@ -390,17 +390,17 @@  discard block
 block discarded – undo
390 390
     f_owc("../assets/cache/installProc.inc.php", '<?php $installStartTime = '.time().'; ?>');
391 391
 }
392 392
 
393
-if($installMode > 0 && $_POST['installdata'] == "1") {
394
-    echo $_lang['sample_web_site'] . ': ' . $_lang['sample_web_site_note'] . PHP_EOL;
393
+if ($installMode > 0 && $_POST['installdata'] == "1") {
394
+    echo $_lang['sample_web_site'].': '.$_lang['sample_web_site_note'].PHP_EOL;
395 395
 }
396 396
 
397 397
 if ($errors > 0) {
398
-    echo $_lang['setup_cannot_continue'] . ' ';
398
+    echo $_lang['setup_cannot_continue'].' ';
399 399
 
400
-    if($errors > 1){
401
-        echo $errors . " " . $_lang['errors'] . $_lang['please_correct_errors'] . $_lang['and_try_again_plural'];
402
-    }else{
403
-        echo $_lang['error'] . $_lang['please_correct_error'] . $_lang['and_try_again']. PHP_EOL;
400
+    if ($errors > 1) {
401
+        echo $errors." ".$_lang['errors'].$_lang['please_correct_errors'].$_lang['and_try_again_plural'];
402
+    } else {
403
+        echo $_lang['error'].$_lang['please_correct_error'].$_lang['and_try_again'].PHP_EOL;
404 404
     }
405 405
 
406 406
     die();
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 
413 413
 if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) {
414 414
     include_once(dirname(__FILE__)."/../assets/cache/siteManager.php");
415
-}else{
415
+} else {
416 416
     define('MGR_DIR', 'manager');
417 417
 }
418 418
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
     $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
438 438
     $database_connection_charset = $database_charset;
439 439
     $database_connection_method = $database_connection_method;
440
-    $dbase = "`" .$database_name. "`";
440
+    $dbase = "`".$database_name."`";
441 441
     $table_prefix = $tableprefix;
442 442
     $adminname = $cmsadmin;
443 443
     $adminemail = $cmsadminemail;
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 
449 449
 // set session name variable
450 450
 if (!isset ($site_sessionname)) {
451
-    $site_sessionname = 'SN' . uniqid('');
451
+    $site_sessionname = 'SN'.uniqid('');
452 452
 }
453 453
 
454 454
 // get base path and url
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
     array_pop($a);
463 463
 $pth = implode("install", $a);
464 464
 unset ($a);
465
-$base_url = $url . (substr($url, -1) != "/" ? "/" : "");
466
-$base_path = $pth . (substr($pth, -1) != "/" ? "/" : "");
465
+$base_url = $url.(substr($url, -1) != "/" ? "/" : "");
466
+$base_path = $pth.(substr($pth, -1) != "/" ? "/" : "");
467 467
 
468 468
 // connect to the database
469 469
 echo $_lang['setup_database_create_connection'].': ';
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 }
476 476
 
477 477
 // select database
478
-echo $_lang['setup_database_selection']. str_replace("`", "", $dbase) . "`: ";
478
+echo $_lang['setup_database_selection'].str_replace("`", "", $dbase)."`: ";
479 479
 if (!mysqli_select_db($conn, str_replace("`", "", $dbase))) {
480 480
     echo $_lang['setup_database_selection_failed']." ".$_lang['setup_database_selection_failed_note'].PHP_EOL;
481 481
     $create = true;
@@ -487,16 +487,16 @@  discard block
 block discarded – undo
487 487
 
488 488
 // try to create the database
489 489
 if ($create) {
490
-    echo $_lang['setup_database_creation']. str_replace("`", "", $dbase) . "`: ";
490
+    echo $_lang['setup_database_creation'].str_replace("`", "", $dbase)."`: ";
491 491
     //  if(!@mysqli_create_db(str_replace("`","",$dbase), $conn)) {
492
-    if (! mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) {
492
+    if (!mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) {
493 493
         echo $_lang['setup_database_creation_failed']." ".$_lang['setup_database_creation_failed_note'].PHP_EOL;
494 494
         $errors += 1;
495 495
         
496
-        echo 'database charset: ' . $database_charset . PHP_EOL;
497
-        echo 'database collation: ' . $database_collation . PHP_EOL;
496
+        echo 'database charset: '.$database_charset.PHP_EOL;
497
+        echo 'database collation: '.$database_collation.PHP_EOL;
498 498
 
499
-        echo $_lang['setup_database_creation_failed_note2'] . PHP_EOL;
499
+        echo $_lang['setup_database_creation_failed_note2'].PHP_EOL;
500 500
 
501 501
         die();
502 502
 
@@ -507,18 +507,18 @@  discard block
 block discarded – undo
507 507
 
508 508
 // check table prefix
509 509
 if ($installMode == 0) {
510
-    echo $_lang['checking_table_prefix'] . $table_prefix . "`: ";
511
-    if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
512
-        echo $_lang['failed'] . " " . $_lang['table_prefix_already_inuse'] . PHP_EOL;
510
+    echo $_lang['checking_table_prefix'].$table_prefix."`: ";
511
+    if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) {
512
+        echo $_lang['failed']." ".$_lang['table_prefix_already_inuse'].PHP_EOL;
513 513
         $errors += 1;
514
-        echo $_lang['table_prefix_already_inuse_note'] . PHP_EOL;
514
+        echo $_lang['table_prefix_already_inuse_note'].PHP_EOL;
515 515
         return;
516 516
     } else {
517 517
         echo $_lang['ok'].PHP_EOL;
518 518
     }
519 519
 }
520 520
 
521
-if(!function_exists('parseProperties')) {
521
+if (!function_exists('parseProperties')) {
522 522
     /**
523 523
      * parses a resource property string and returns the result as an array
524 524
      * duplicate of method in documentParser class
@@ -526,20 +526,20 @@  discard block
 block discarded – undo
526 526
      * @param string $propertyString
527 527
      * @return array
528 528
      */
529
-    function parseProperties($propertyString) {
530
-        $parameter= array ();
529
+    function parseProperties($propertyString){
530
+        $parameter = array();
531 531
         if (!empty ($propertyString)) {
532
-            $tmpParams= explode("&", $propertyString);
532
+            $tmpParams = explode("&", $propertyString);
533 533
             $countParams = count($tmpParams);
534
-            for ($x= 0; $x < $countParams; $x++) {
534
+            for ($x = 0; $x < $countParams; $x++) {
535 535
                 if (strpos($tmpParams[$x], '=', 0)) {
536
-                    $pTmp= explode("=", $tmpParams[$x]);
537
-                    $pvTmp= explode(";", trim($pTmp[1]));
536
+                    $pTmp = explode("=", $tmpParams[$x]);
537
+                    $pvTmp = explode(";", trim($pTmp[1]));
538 538
                     if ($pvTmp[1] == 'list' && $pvTmp[3] != "")
539
-                        $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default
539
+                        $parameter[trim($pTmp[0])] = $pvTmp[3]; //list default
540 540
                     else
541 541
                         if ($pvTmp[1] != 'list' && $pvTmp[2] != "")
542
-                            $parameter[trim($pTmp[0])]= $pvTmp[2];
542
+                            $parameter[trim($pTmp[0])] = $pvTmp[2];
543 543
                 }
544 544
             }
545 545
         }
@@ -550,20 +550,20 @@  discard block
 block discarded – undo
550 550
 // check status of Inherit Parent Template plugin
551 551
 $auto_template_logic = 'parent';
552 552
 if ($installMode != 0) {
553
-    $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='Inherit Parent Template'");
553
+    $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`".$table_prefix."site_plugins` WHERE name='Inherit Parent Template'");
554 554
     $row = mysqli_fetch_row($rs);
555
-    if(!$row) {
555
+    if (!$row) {
556 556
         // not installed
557 557
         $auto_template_logic = 'system';
558 558
     } else {
559
-        if($row[1] == 1) {
559
+        if ($row[1] == 1) {
560 560
             // installed but disabled
561 561
             $auto_template_logic = 'system';
562 562
         } else {
563 563
             // installed, enabled .. see how it's configured
564 564
             $properties = parseProperties($row[0]);
565
-            if(isset($properties['inheritTemplate'])) {
566
-                if($properties['inheritTemplate'] == 'From First Sibling') {
565
+            if (isset($properties['inheritTemplate'])) {
566
+                if ($properties['inheritTemplate'] == 'From First Sibling') {
567 567
                     $auto_template_logic = 'sibling';
568 568
                 }
569 569
             }
@@ -585,17 +585,16 @@  discard block
 block discarded – undo
585 585
 
586 586
 // setup Template template files - array : name, description, type - 0:file or 1:content, parameters, category
587 587
 $mt = &$moduleTemplates;
588
-if(is_dir($templatePath) && is_readable($templatePath)) {
588
+if (is_dir($templatePath) && is_readable($templatePath)) {
589 589
     $d = dir($templatePath);
590 590
     while (false !== ($tplfile = $d->read()))
591 591
     {
592
-        if(substr($tplfile, -4) != '.tpl') continue;
592
+        if (substr($tplfile, -4) != '.tpl') continue;
593 593
         $params = parse_docblock($templatePath, $tplfile);
594
-        if(is_array($params) && (count($params)>0))
594
+        if (is_array($params) && (count($params) > 0))
595 595
         {
596 596
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
597
-            $mt[] = array
598
-            (
597
+            $mt[] = array(
599 598
                 $params['name'],
600 599
                 $description,
601 600
                 // Don't think this is gonna be used ... but adding it just in case 'type'
@@ -613,12 +612,12 @@  discard block
 block discarded – undo
613 612
 
614 613
 // setup Template Variable template files
615 614
 $mtv = &$moduleTVs;
616
-if(is_dir($tvPath) && is_readable($tvPath)) {
615
+if (is_dir($tvPath) && is_readable($tvPath)) {
617 616
     $d = dir($tvPath);
618 617
     while (false !== ($tplfile = $d->read())) {
619
-        if(substr($tplfile, -4) != '.tpl') continue;
618
+        if (substr($tplfile, -4) != '.tpl') continue;
620 619
         $params = parse_docblock($tvPath, $tplfile);
621
-        if(is_array($params) && (count($params)>0)) {
620
+        if (is_array($params) && (count($params) > 0)) {
622 621
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
623 622
             $mtv[] = array(
624 623
                 $params['name'],
@@ -630,9 +629,9 @@  discard block
 block discarded – undo
630 629
                 $params['output_widget'],
631 630
                 $params['output_widget_params'],
632 631
                 "$templatePath/{$params['filename']}", /* not currently used */
633
-                $params['template_assignments']!="*"?$params['template_assignments']:implode(",",array_map(create_function('$v','return $v[0];'),$mt)), /* comma-separated list of template names */
632
+                $params['template_assignments'] != "*" ? $params['template_assignments'] : implode(",", array_map(create_function('$v', 'return $v[0];'), $mt)), /* comma-separated list of template names */
634 633
                 $params['modx_category'],
635
-                $params['lock_tv'],  /* value should be 1 or 0 */
634
+                $params['lock_tv'], /* value should be 1 or 0 */
636 635
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
637 636
             );
638 637
         }
@@ -642,14 +641,14 @@  discard block
 block discarded – undo
642 641
 
643 642
 // setup chunks template files - array : name, description, type - 0:file or 1:content, file or content
644 643
 $mc = &$moduleChunks;
645
-if(is_dir($chunkPath) && is_readable($chunkPath)) {
644
+if (is_dir($chunkPath) && is_readable($chunkPath)) {
646 645
     $d = dir($chunkPath);
647 646
     while (false !== ($tplfile = $d->read())) {
648
-        if(substr($tplfile, -4) != '.tpl') {
647
+        if (substr($tplfile, -4) != '.tpl') {
649 648
             continue;
650 649
         }
651 650
         $params = parse_docblock($chunkPath, $tplfile);
652
-        if(is_array($params) && count($params) > 0) {
651
+        if (is_array($params) && count($params) > 0) {
653 652
             $mc[] = array(
654 653
                 $params['name'],
655 654
                 $params['description'],
@@ -665,14 +664,14 @@  discard block
 block discarded – undo
665 664
 
666 665
 // setup snippets template files - array : name, description, type - 0:file or 1:content, file or content,properties
667 666
 $ms = &$moduleSnippets;
668
-if(is_dir($snippetPath) && is_readable($snippetPath)) {
667
+if (is_dir($snippetPath) && is_readable($snippetPath)) {
669 668
     $d = dir($snippetPath);
670 669
     while (false !== ($tplfile = $d->read())) {
671
-        if(substr($tplfile, -4) != '.tpl') {
670
+        if (substr($tplfile, -4) != '.tpl') {
672 671
             continue;
673 672
         }
674 673
         $params = parse_docblock($snippetPath, $tplfile);
675
-        if(is_array($params) && count($params) > 0) {
674
+        if (is_array($params) && count($params) > 0) {
676 675
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
677 676
             $ms[] = array(
678 677
                 $params['name'],
@@ -689,14 +688,14 @@  discard block
 block discarded – undo
689 688
 
690 689
 // setup plugins template files - array : name, description, type - 0:file or 1:content, file or content,properties
691 690
 $mp = &$modulePlugins;
692
-if(is_dir($pluginPath) && is_readable($pluginPath)) {
691
+if (is_dir($pluginPath) && is_readable($pluginPath)) {
693 692
     $d = dir($pluginPath);
694 693
     while (false !== ($tplfile = $d->read())) {
695
-        if(substr($tplfile, -4) != '.tpl') {
694
+        if (substr($tplfile, -4) != '.tpl') {
696 695
             continue;
697 696
         }
698 697
         $params = parse_docblock($pluginPath, $tplfile);
699
-        if(is_array($params) && count($params) > 0) {
698
+        if (is_array($params) && count($params) > 0) {
700 699
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
701 700
             $mp[] = array(
702 701
                 $params['name'],
@@ -708,7 +707,7 @@  discard block
 block discarded – undo
708 707
                 $params['modx_category'],
709 708
                 $params['legacy_names'],
710 709
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false,
711
-                (int)$params['disabled']
710
+                (int) $params['disabled']
712 711
             );
713 712
         }
714 713
     }
@@ -718,14 +717,14 @@  discard block
 block discarded – undo
718 717
 // setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams
719 718
 $mm = &$moduleModules;
720 719
 $mdp = &$moduleDependencies;
721
-if(is_dir($modulePath) && is_readable($modulePath)) {
720
+if (is_dir($modulePath) && is_readable($modulePath)) {
722 721
     $d = dir($modulePath);
723 722
     while (false !== ($tplfile = $d->read())) {
724
-        if(substr($tplfile, -4) != '.tpl') {
723
+        if (substr($tplfile, -4) != '.tpl') {
725 724
             continue;
726 725
         }
727 726
         $params = parse_docblock($modulePath, $tplfile);
728
-        if(is_array($params) && count($params) > 0) {
727
+        if (is_array($params) && count($params) > 0) {
729 728
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
730 729
             $mm[] = array(
731 730
                 $params['name'],
@@ -733,12 +732,12 @@  discard block
 block discarded – undo
733 732
                 "$modulePath/{$params['filename']}",
734 733
                 $params['properties'],
735 734
                 $params['guid'],
736
-                (int)$params['shareparams'],
735
+                (int) $params['shareparams'],
737 736
                 $params['modx_category'],
738 737
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
739 738
             );
740 739
         }
741
-        if ((int)$params['shareparams'] || !empty($params['dependencies'])) {
740
+        if ((int) $params['shareparams'] || !empty($params['dependencies'])) {
742 741
             $dependencies = explode(',', $params['dependencies']);
743 742
             foreach ($dependencies as $dependency) {
744 743
                 $dependency = explode(':', $dependency);
@@ -809,103 +808,103 @@  discard block
 block discarded – undo
809 808
 // setup callback function
810 809
 $callBackFnc = "clean_up";
811 810
 
812
-function clean_up($sqlParser) {
811
+function clean_up($sqlParser){
813 812
     $ids = array();
814 813
 
815 814
     // secure web documents - privateweb
816
-    mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 0 WHERE privateweb = 1");
817
-    $sql =  "SELECT DISTINCT sc.id
815
+    mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 0 WHERE privateweb = 1");
816
+    $sql = "SELECT DISTINCT sc.id
818 817
              FROM `".$sqlParser->prefix."site_content` sc
819 818
              LEFT JOIN `".$sqlParser->prefix."document_groups` dg ON dg.document = sc.id
820 819
              LEFT JOIN `".$sqlParser->prefix."webgroup_access` wga ON wga.documentgroup = dg.document_group
821 820
              WHERE wga.id>0";
822
-    $ds = mysqli_query($sqlParser->conn,$sql);
823
-    if(!$ds) {
821
+    $ds = mysqli_query($sqlParser->conn, $sql);
822
+    if (!$ds) {
824 823
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
825 824
     }
826 825
     else {
827
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
828
-        if(count($ids)>0) {
829
-            mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")");
826
+        while ($r = mysqli_fetch_assoc($ds)) $ids[] = $r["id"];
827
+        if (count($ids) > 0) {
828
+            mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ", $ids).")");
830 829
             unset($ids);
831 830
         }
832 831
     }
833 832
 
834 833
     // secure manager documents privatemgr
835
-    mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 0 WHERE privatemgr = 1");
836
-    $sql =  "SELECT DISTINCT sc.id
834
+    mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 0 WHERE privatemgr = 1");
835
+    $sql = "SELECT DISTINCT sc.id
837 836
              FROM `".$sqlParser->prefix."site_content` sc
838 837
              LEFT JOIN `".$sqlParser->prefix."document_groups` dg ON dg.document = sc.id
839 838
              LEFT JOIN `".$sqlParser->prefix."membergroup_access` mga ON mga.documentgroup = dg.document_group
840 839
              WHERE mga.id>0";
841
-    $ds = mysqli_query($sqlParser->conn,$sql);
842
-    if(!$ds) {
840
+    $ds = mysqli_query($sqlParser->conn, $sql);
841
+    if (!$ds) {
843 842
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
844 843
     }
845 844
     else {
846
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
847
-        if(count($ids)>0) {
848
-            mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")");
845
+        while ($r = mysqli_fetch_assoc($ds)) $ids[] = $r["id"];
846
+        if (count($ids) > 0) {
847
+            mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ", $ids).")");
849 848
             unset($ids);
850 849
         }
851 850
     }
852 851
 }
853 852
 
854
-function parse_docblock($element_dir, $filename) {
853
+function parse_docblock($element_dir, $filename){
855 854
     $params = array();
856
-    $fullpath = $element_dir . '/' . $filename;
857
-    if(is_readable($fullpath)) {
855
+    $fullpath = $element_dir.'/'.$filename;
856
+    if (is_readable($fullpath)) {
858 857
         $tpl = @fopen($fullpath, "r");
859
-        if($tpl) {
858
+        if ($tpl) {
860 859
             $params['filename'] = $filename;
861 860
             $docblock_start_found = false;
862 861
             $name_found = false;
863 862
             $description_found = false;
864 863
 
865
-            while(!feof($tpl)) {
864
+            while (!feof($tpl)) {
866 865
                 $line = fgets($tpl);
867
-                if(!$docblock_start_found) {
866
+                if (!$docblock_start_found) {
868 867
                     // find docblock start
869
-                    if(strpos($line, '/**') !== false) {
868
+                    if (strpos($line, '/**') !== false) {
870 869
                         $docblock_start_found = true;
871 870
                     }
872 871
                     continue;
873
-                } elseif(!$name_found) {
872
+                } elseif (!$name_found) {
874 873
                     // find name
875 874
                     $ma = null;
876
-                    if(preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
875
+                    if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
877 876
                         $params['name'] = trim($ma[1]);
878 877
                         $name_found = !empty($params['name']);
879 878
                     }
880 879
                     continue;
881
-                } elseif(!$description_found) {
880
+                } elseif (!$description_found) {
882 881
                     // find description
883 882
                     $ma = null;
884
-                    if(preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
883
+                    if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
885 884
                         $params['description'] = trim($ma[1]);
886 885
                         $description_found = !empty($params['description']);
887 886
                     }
888 887
                     continue;
889 888
                 } else {
890 889
                     $ma = null;
891
-                    if(preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) {
890
+                    if (preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) {
892 891
                         $param = trim($ma[1]);
893 892
                         $val = trim($ma[2]);
894
-                        if(!empty($param) && !empty($val)) {
895
-                            if($param == 'internal') {
893
+                        if (!empty($param) && !empty($val)) {
894
+                            if ($param == 'internal') {
896 895
                                 $ma = null;
897
-                                if(preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) {
896
+                                if (preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) {
898 897
                                     $param = trim($ma[1]);
899 898
                                     $val = trim($ma[2]);
900 899
                                 }
901 900
                                 //if($val !== '0' && (empty($param) || empty($val))) {
902
-                                if(empty($param)) {
901
+                                if (empty($param)) {
903 902
                                     continue;
904 903
                                 }
905 904
                             }
906 905
                             $params[$param] = $val;
907 906
                         }
908
-                    } elseif(preg_match("/^\s*\*\/\s*$/", $line)) {
907
+                    } elseif (preg_match("/^\s*\*\/\s*$/", $line)) {
909 908
                         break;
910 909
                     }
911 910
                 }
@@ -936,13 +935,13 @@  discard block
 block discarded – undo
936 935
     // display database results
937 936
     if ($sqlParser->installFailed == true) {
938 937
         $errors += 1;
939
-        echo $_lang['database_alerts'] . PHP_EOL;
940
-        echo $_lang['setup_couldnt_install'] . PHP_EOL;
941
-        echo $_lang['installation_error_occured'] . PHP_EOL;
938
+        echo $_lang['database_alerts'].PHP_EOL;
939
+        echo $_lang['setup_couldnt_install'].PHP_EOL;
940
+        echo $_lang['installation_error_occured'].PHP_EOL;
942 941
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
943
-            echo $sqlParser->mysqlErrors[$i]["error"] . " " . $_lang['during_execution_of_sql'] . " " . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . PHP_EOL;
942
+            echo $sqlParser->mysqlErrors[$i]["error"]." ".$_lang['during_execution_of_sql']." ".strip_tags($sqlParser->mysqlErrors[$i]["sql"]).PHP_EOL;
944 943
         }
945
-        echo $_lang['some_tables_not_updated'] . PHP_EOL;
944
+        echo $_lang['some_tables_not_updated'].PHP_EOL;
946 945
         die();
947 946
     } else {
948 947
         echo $_lang['ok'].PHP_EOL;
@@ -952,7 +951,7 @@  discard block
 block discarded – undo
952 951
 // custom or not
953 952
 if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) {
954 953
     $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");';
955
-}else{
954
+} else {
956 955
     $mgrdir = 'define(\'MGR_DIR\', \'manager\');';
957 956
 }
958 957
 
@@ -989,16 +988,16 @@  discard block
 block discarded – undo
989 988
 $chmodSuccess = @chmod($filename, 0404);
990 989
 
991 990
 if ($configFileFailed == true) {
992
-    echo $_lang['failed'] . PHP_EOL;
991
+    echo $_lang['failed'].PHP_EOL;
993 992
     $errors += 1;
994 993
 
995
-    echo $_lang['cant_write_config_file'] . ' ' . MGR_DIR .'/includes/config.inc.php' .PHP_EOL;
994
+    echo $_lang['cant_write_config_file'].' '.MGR_DIR.'/includes/config.inc.php'.PHP_EOL;
996 995
     echo ' '.PHP_EOL;
997 996
     echo ' '.PHP_EOL;
998 997
     echo $configString;
999 998
     echo ' '.PHP_EOL;
1000 999
     echo ' '.PHP_EOL;
1001
-    echo $_lang['cant_write_config_file_note'] . PHP_EOL;
1000
+    echo $_lang['cant_write_config_file_note'].PHP_EOL;
1002 1001
     die();
1003 1002
 
1004 1003
 } else {
@@ -1008,16 +1007,16 @@  discard block
 block discarded – undo
1008 1007
 // generate new site_id and set manager theme to default
1009 1008
 if ($installMode == 0) {
1010 1009
     $siteid = uniqid('');
1011
-    mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')");
1010
+    mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')");
1012 1011
 } else {
1013 1012
     // update site_id if missing
1014
-    $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'");
1013
+    $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`".$table_prefix."system_settings` WHERE setting_name='site_id'");
1015 1014
     if ($ds) {
1016 1015
         $r = mysqli_fetch_assoc($ds);
1017 1016
         $siteid = $r['setting_value'];
1018 1017
         if ($siteid == '' || $siteid = 'MzGeQ2faT4Dw06+U49x3') {
1019 1018
             $siteid = uniqid('');
1020
-            mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')");
1019
+            mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')");
1021 1020
         }
1022 1021
     }
1023 1022
 }
@@ -1029,29 +1028,29 @@  discard block
 block discarded – undo
1029 1028
     // display database results
1030 1029
     if ($sqlParser->installFailed == true) {
1031 1030
         $errors += 1;
1032
-        echo $_lang['database_alerts'] . PHP_EOL;
1033
-        echo $_lang['setup_couldnt_install'] . PHP_EOL;
1034
-        echo $_lang['installation_error_occured'] . PHP_EOL . PHP_EOL;
1031
+        echo $_lang['database_alerts'].PHP_EOL;
1032
+        echo $_lang['setup_couldnt_install'].PHP_EOL;
1033
+        echo $_lang['installation_error_occured'].PHP_EOL.PHP_EOL;
1035 1034
         /*
1036 1035
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
1037 1036
             echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />";
1038 1037
         }
1039 1038
         echo "</p>";*/
1040
-        echo $_lang['some_tables_not_updated'] . PHP_EOL;
1039
+        echo $_lang['some_tables_not_updated'].PHP_EOL;
1041 1040
         die();
1042 1041
     } else {
1043
-        echo $_lang['ok'] . PHP_EOL;
1042
+        echo $_lang['ok'].PHP_EOL;
1044 1043
     }
1045 1044
 }
1046 1045
 
1047 1046
 // Install Templates
1048 1047
 $moduleTemplate = $mt; 
1049 1048
 if (!empty($moduleTemplate) || $installData) {
1050
-    echo PHP_EOL . $_lang['templates'] . ":" . PHP_EOL;
1049
+    echo PHP_EOL.$_lang['templates'].":".PHP_EOL;
1051 1050
     //$selTemplates = $_POST['template'];
1052 1051
     foreach ($moduleTemplates as $k=>$moduleTemplate) {
1053 1052
         $installSample = in_array('sample', $moduleTemplate[6]) && $installData == 1;
1054
-        if($installSample || is_array($moduleTemplate)) {
1053
+        if ($installSample || is_array($moduleTemplate)) {
1055 1054
             $name = mysqli_real_escape_string($conn, $moduleTemplate[0]);
1056 1055
             $desc = mysqli_real_escape_string($conn, $moduleTemplate[1]);
1057 1056
             $category = mysqli_real_escape_string($conn, $moduleTemplate[4]);
@@ -1059,7 +1058,7 @@  discard block
 block discarded – undo
1059 1058
             $filecontent = $moduleTemplate[3];
1060 1059
             $save_sql_id_as = $moduleTemplate[7]; // Nessecary for demo-site
1061 1060
             if (!file_exists($filecontent)) {
1062
-                echo "  $name: " . $_lang['unable_install_template'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1061
+                echo "  $name: ".$_lang['unable_install_template']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1063 1062
             } else {
1064 1063
                 // Create the category if it does not already exist
1065 1064
                 $category_id = getCreateDbCategory($category, $sqlParser);
@@ -1069,31 +1068,31 @@  discard block
 block discarded – undo
1069 1068
                 $template = mysqli_real_escape_string($conn, $template);
1070 1069
 
1071 1070
                 // See if the template already exists
1072
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'");
1071
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name'");
1073 1072
 
1074 1073
                 if (mysqli_num_rows($rs)) {
1075
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked'  WHERE templatename='$name' LIMIT 1;")) {
1074
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_templates` SET content='$template', description='$desc', category=$category_id, locked='$locked'  WHERE templatename='$name' LIMIT 1;")) {
1076 1075
                         $errors += 1;
1077
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1076
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1078 1077
                         return;
1079 1078
                     }
1080
-                    if(!is_null($save_sql_id_as)) {
1079
+                    if (!is_null($save_sql_id_as)) {
1081 1080
                         $sql_id = @mysqli_insert_id($sqlParser->conn);
1082
-                        if(!$sql_id) {
1083
-                            $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name' LIMIT 1;"));
1081
+                        if (!$sql_id) {
1082
+                            $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name' LIMIT 1;"));
1084 1083
                             $sql_id = $idQuery['id'];
1085 1084
                         }
1086 1085
                         $custom_placeholders[$save_sql_id_as] = $sql_id;
1087 1086
                     }
1088
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1087
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1089 1088
                 } else {
1090
-                    if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) {
1089
+                    if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) {
1091 1090
                         $errors += 1;
1092
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1091
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1093 1092
                         die();
1094 1093
                     }
1095
-                    if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1096
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1094
+                    if (!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1095
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1097 1096
                 }
1098 1097
             }
1099 1098
         }
@@ -1103,11 +1102,11 @@  discard block
 block discarded – undo
1103 1102
 // Install Template Variables
1104 1103
 $moduleTVs = $mtv;
1105 1104
 if (is_array($moduleTVs) || $installData) {
1106
-    echo PHP_EOL . $_lang['tvs'].': '.PHP_EOL;
1105
+    echo PHP_EOL.$_lang['tvs'].': '.PHP_EOL;
1107 1106
     //$selTVs = $_POST['tv'];
1108 1107
     foreach ($moduleTVs as $k=>$moduleTV) {
1109 1108
         $installSample = in_array('sample', $moduleTV[12]) && $installData == 1;
1110
-        if($installSample || is_array($moduleTVs)) {
1109
+        if ($installSample || is_array($moduleTVs)) {
1111 1110
             $name = mysqli_real_escape_string($conn, $moduleTV[0]);
1112 1111
             $caption = mysqli_real_escape_string($conn, $moduleTV[1]);
1113 1112
             $desc = mysqli_real_escape_string($conn, $moduleTV[2]);
@@ -1125,24 +1124,24 @@  discard block
 block discarded – undo
1125 1124
             // Create the category if it does not already exist
1126 1125
             $category = getCreateDbCategory($category, $sqlParser);
1127 1126
 
1128
-            $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name'");
1127
+            $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name'");
1129 1128
             if (mysqli_num_rows($rs)) {
1130 1129
                 $insert = true;
1131
-                while($row = mysqli_fetch_assoc($rs)) {
1132
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};")) {
1133
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1130
+                while ($row = mysqli_fetch_assoc($rs)) {
1131
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_tmplvars` SET type='$input_type', caption='$caption', description='$desc', category=$category, locked=$locked, elements='$input_options', display='$output_widget', display_params='$output_widget_params', default_text='$input_default' WHERE id={$row['id']};")) {
1132
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1134 1133
                         return;
1135 1134
                     }
1136 1135
                     $insert = false;
1137 1136
                 }
1138
-                echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1137
+                echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1139 1138
             } else {
1140
-                $q = "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',$category,$locked,'$input_options','$output_widget','$output_widget_params','$input_default');";
1139
+                $q = "INSERT INTO $dbase.`".$table_prefix."site_tmplvars` (type,name,caption,description,category,locked,elements,display,display_params,default_text) VALUES('$input_type','$name','$caption','$desc',$category,$locked,'$input_options','$output_widget','$output_widget_params','$input_default');";
1141 1140
                 if (!mysqli_query($sqlParser->conn, $q)) {
1142
-                    echo mysqli_error($sqlParser->conn) . PHP_EOL;
1141
+                    echo mysqli_error($sqlParser->conn).PHP_EOL;
1143 1142
                     return;
1144 1143
                 }
1145
-                echo "  $name: " . $_lang['installed'] . PHP_EOL;
1144
+                echo "  $name: ".$_lang['installed'].PHP_EOL;
1146 1145
             }
1147 1146
 
1148 1147
             // add template assignments
@@ -1151,10 +1150,10 @@  discard block
 block discarded – undo
1151 1150
             if (count($assignments) > 0) {
1152 1151
 
1153 1152
                 // remove existing tv -> template assignments
1154
-                $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';");
1153
+                $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';");
1155 1154
                 $row = mysqli_fetch_assoc($ds);
1156 1155
                 $id = $row["id"];
1157
-                mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\'');
1156
+                mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_tmplvar_templates` WHERE tmplvarid = \''.$id.'\'');
1158 1157
 
1159 1158
                 // add tv -> template assignments
1160 1159
                 foreach ($assignments as $assignment) {
@@ -1163,7 +1162,7 @@  discard block
 block discarded – undo
1163 1162
                     if ($ds && $ts) {
1164 1163
                         $tRow = mysqli_fetch_assoc($ts);
1165 1164
                         $templateId = $tRow['id'];
1166
-                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
1165
+                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
1167 1166
                    }
1168 1167
                 }
1169 1168
             }
@@ -1174,12 +1173,12 @@  discard block
 block discarded – undo
1174 1173
 
1175 1174
 $moduleChunks = $mc;
1176 1175
 // Install Chunks
1177
-if (is_array ($moduleChunks) || $installData) {
1178
-    echo PHP_EOL . $_lang['chunks'] . ": " . PHP_EOL;
1176
+if (is_array($moduleChunks) || $installData) {
1177
+    echo PHP_EOL.$_lang['chunks'].": ".PHP_EOL;
1179 1178
     foreach ($moduleChunks as $k=>$moduleChunk) {
1180 1179
         $installSample = in_array('sample', $moduleChunk[5]) && $installData == 1;
1181 1180
         $count_new_name = 0;
1182
-        if($installSample || is_array ($moduleChunks)) {
1181
+        if ($installSample || is_array($moduleChunks)) {
1183 1182
 
1184 1183
             $name = mysqli_real_escape_string($conn, $moduleChunk[0]);
1185 1184
             $desc = mysqli_real_escape_string($conn, $moduleChunk[1]);
@@ -1188,7 +1187,7 @@  discard block
 block discarded – undo
1188 1187
             $filecontent = $moduleChunk[2];
1189 1188
 
1190 1189
             if (!file_exists($filecontent))
1191
-                echo "  $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1190
+                echo "  $name: ".$_lang['unable_install_chunk']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1192 1191
             else {
1193 1192
 
1194 1193
                 // Create the category if it does not already exist
@@ -1196,31 +1195,31 @@  discard block
 block discarded – undo
1196 1195
 
1197 1196
                 $chunk = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1);
1198 1197
                 $chunk = mysqli_real_escape_string($conn, $chunk);
1199
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$name'");
1198
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$name'");
1200 1199
                 $count_original_name = mysqli_num_rows($rs);
1201
-                if($overwrite == 'false') {
1202
-                    $newname = $name . '-' . str_replace('.', '_', $modx_version);
1203
-                    $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$newname'");
1200
+                if ($overwrite == 'false') {
1201
+                    $newname = $name.'-'.str_replace('.', '_', $modx_version);
1202
+                    $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$newname'");
1204 1203
                     $count_new_name = mysqli_num_rows($rs);
1205 1204
                 }
1206 1205
                 $update = $count_original_name > 0 && $overwrite == 'true';
1207 1206
                 if ($update) {
1208
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) {
1207
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) {
1209 1208
                         $errors += 1;
1210
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1209
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1211 1210
                         return;
1212 1211
                     }
1213
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1214
-                } elseif($count_new_name == 0) {
1215
-                    if($count_original_name > 0 && $overwrite == 'false') {
1212
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1213
+                } elseif ($count_new_name == 0) {
1214
+                    if ($count_original_name > 0 && $overwrite == 'false') {
1216 1215
                         $name = $newname;
1217 1216
                     }
1218
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) {
1217
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) {
1219 1218
                         $errors += 1;
1220
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1219
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1221 1220
                         return;
1222 1221
                     }
1223
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1222
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1224 1223
                 }
1225 1224
             }
1226 1225
         }
@@ -1230,11 +1229,11 @@  discard block
 block discarded – undo
1230 1229
 // Install Modules
1231 1230
 $moduleModules = $mm;
1232 1231
 if (is_array($moduleModules) || $installData) {
1233
-    echo PHP_EOL . $_lang['modules'] . ":" . PHP_EOL;
1232
+    echo PHP_EOL.$_lang['modules'].":".PHP_EOL;
1234 1233
     //$selModules = $_POST['module'];
1235 1234
     foreach ($moduleModules as $k=>$moduleModule) {
1236 1235
         $installSample = in_array('sample', $moduleModule[7]) && $installData == 1;
1237
-        if($installSample || is_array($moduleModules)) {
1236
+        if ($installSample || is_array($moduleModules)) {
1238 1237
             $name = mysqli_real_escape_string($conn, $moduleModule[0]);
1239 1238
             $desc = mysqli_real_escape_string($conn, $moduleModule[1]);
1240 1239
             $filecontent = $moduleModule[2];
@@ -1243,7 +1242,7 @@  discard block
 block discarded – undo
1243 1242
             $shared = mysqli_real_escape_string($conn, $moduleModule[5]);
1244 1243
             $category = mysqli_real_escape_string($conn, $moduleModule[6]);
1245 1244
             if (!file_exists($filecontent))
1246
-                echo "  $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1245
+                echo "  $name: ".$_lang['unable_install_module']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1247 1246
             else {
1248 1247
 
1249 1248
                 // Create the category if it does not already exist
@@ -1252,24 +1251,24 @@  discard block
 block discarded – undo
1252 1251
                 $module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2));
1253 1252
                 // $module = removeDocblock($module, 'module'); // Modules have no fileBinding, keep docblock for info-tab
1254 1253
                 $module = mysqli_real_escape_string($conn, $module);
1255
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_modules` WHERE name='$name'");
1254
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_modules` WHERE name='$name'");
1256 1255
                 if (mysqli_num_rows($rs)) {
1257 1256
                     $row = mysqli_fetch_assoc($rs);
1258
-                    $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1259
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
1260
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1257
+                    $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
1258
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
1259
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1261 1260
                         return;
1262 1261
                     }
1263
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1262
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1264 1263
                 } else {
1265
-                    if ($properties != NULL ){
1264
+                    if ($properties != NULL) {
1266 1265
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1267 1266
                     }
1268
-                    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);")) {
1269
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
1267
+                    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);")) {
1268
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
1270 1269
                         return;
1271 1270
                     }
1272
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1271
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1273 1272
                 }
1274 1273
             }
1275 1274
         }
@@ -1279,11 +1278,11 @@  discard block
 block discarded – undo
1279 1278
 // Install Plugins
1280 1279
 $modulePlugins = $mp;
1281 1280
 if (is_array($modulePlugins) || $installData) {
1282
-    echo PHP_EOL . $_lang['plugins'] . ":" . PHP_EOL;
1281
+    echo PHP_EOL.$_lang['plugins'].":".PHP_EOL;
1283 1282
     $selPlugs = $_POST['plugin'];
1284 1283
     foreach ($modulePlugins as $k=>$modulePlugin) {
1285 1284
         //$installSample = in_array('sample', $modulePlugin[8]) && $installData == 1;
1286
-        if($installSample || is_array($modulePlugins)) {
1285
+        if ($installSample || is_array($modulePlugins)) {
1287 1286
             $name = mysqli_real_escape_string($conn, $modulePlugin[0]);
1288 1287
             $desc = mysqli_real_escape_string($conn, $modulePlugin[1]);
1289 1288
             $filecontent = $modulePlugin[2];
@@ -1293,17 +1292,17 @@  discard block
 block discarded – undo
1293 1292
             $category = mysqli_real_escape_string($conn, $modulePlugin[6]);
1294 1293
             $leg_names = '';
1295 1294
             $disabled = $modulePlugin[9];
1296
-            if(array_key_exists(7, $modulePlugin)) {
1295
+            if (array_key_exists(7, $modulePlugin)) {
1297 1296
                 // parse comma-separated legacy names and prepare them for sql IN clause
1298
-                $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'";
1297
+                $leg_names = "'".implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7])))."'";
1299 1298
             }
1300 1299
             if (!file_exists($filecontent))
1301
-                echo "  $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1300
+                echo "  $name: ".$_lang['unable_install_plugin']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1302 1301
             else {
1303 1302
 
1304 1303
                 // disable legacy versions based on legacy_names provided
1305
-                if(!empty($leg_names)) {
1306
-                    $update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);";
1304
+                if (!empty($leg_names)) {
1305
+                    $update_query = "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE name IN ($leg_names);";
1307 1306
                     $rs = mysqli_query($sqlParser->conn, $update_query);
1308 1307
                 }
1309 1308
 
@@ -1313,52 +1312,52 @@  discard block
 block discarded – undo
1313 1312
                 $plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2));
1314 1313
                 $plugin = removeDocblock($plugin, 'plugin');
1315 1314
                 $plugin = mysqli_real_escape_string($conn, $plugin);
1316
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name'");
1315
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name'");
1317 1316
                 if (mysqli_num_rows($rs)) {
1318 1317
                     $insert = true;
1319
-                    while($row = mysqli_fetch_assoc($rs)) {
1320
-                        $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1321
-                        if($row['description'] == $desc){
1322
-                            if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
1323
-                                echo mysqli_error($sqlParser->conn) . PHP_EOL;
1318
+                    while ($row = mysqli_fetch_assoc($rs)) {
1319
+                        $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
1320
+                        if ($row['description'] == $desc) {
1321
+                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
1322
+                                echo mysqli_error($sqlParser->conn).PHP_EOL;
1324 1323
                                 return;
1325 1324
                             }
1326 1325
                             $insert = false;
1327 1326
                         } else {
1328
-                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) {
1327
+                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE id={$row['id']};")) {
1329 1328
                                 echo mysqli_error($sqlParser->conn).PHP_EOL;
1330 1329
                                 return;
1331 1330
                             }
1332 1331
                         }
1333 1332
                     }
1334
-                    if($insert === true) {
1335
-                        $properties = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1336
-                        if(!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$properties','$guid','0',$category);")) {
1333
+                    if ($insert === true) {
1334
+                        $properties = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
1335
+                        if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$properties','$guid','0',$category);")) {
1337 1336
                             echo mysqli_error($sqlParser->conn).PHP_EOL;
1338 1337
                             return;
1339 1338
                         }
1340 1339
                     }
1341
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1340
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1342 1341
                 } else {
1343
-                    if ($properties != NULL ){
1342
+                    if ($properties != NULL) {
1344 1343
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1345 1344
                     }
1346
-                    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);")) {
1347
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1345
+                    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);")) {
1346
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1348 1347
                         return;
1349 1348
                     }
1350
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1349
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1351 1350
                 }
1352 1351
                 // add system events
1353 1352
                 if (count($events) > 0) {
1354
-                    $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';");
1353
+                    $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';");
1355 1354
                     if ($ds) {
1356 1355
                         $row = mysqli_fetch_assoc($ds);
1357 1356
                         $id = $row["id"];
1358 1357
                         // remove existing events
1359
-                        mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_plugin_events` WHERE pluginid = \'' . $id . '\'');
1358
+                        mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_plugin_events` WHERE pluginid = \''.$id.'\'');
1360 1359
                         // add new events
1361
-                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`" . $table_prefix . "system_eventnames` se WHERE name IN ('" . implode("','", $events) . "')");
1360
+                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_plugin_events` (pluginid, evtid) SELECT '$id' as 'pluginid',se.id as 'evtid' FROM $dbase.`".$table_prefix."system_eventnames` se WHERE name IN ('".implode("','", $events)."')");
1362 1361
                     }
1363 1362
                 }
1364 1363
             }
@@ -1369,18 +1368,18 @@  discard block
 block discarded – undo
1369 1368
 // Install Snippets
1370 1369
 $moduleSnippet = $ms;
1371 1370
 if (is_array($moduleSnippet) || $installData) {
1372
-    echo PHP_EOL . $_lang['snippets'] . ":" . PHP_EOL;
1371
+    echo PHP_EOL.$_lang['snippets'].":".PHP_EOL;
1373 1372
     //$selSnips = $_POST['snippet'];
1374 1373
     foreach ($moduleSnippets as $k=>$moduleSnippet) {
1375 1374
         $installSample = in_array('sample', $moduleSnippet[5]) && $installData == 1;
1376
-        if($installSample || is_array($moduleSnippet)) {
1375
+        if ($installSample || is_array($moduleSnippet)) {
1377 1376
             $name = mysqli_real_escape_string($conn, $moduleSnippet[0]);
1378 1377
             $desc = mysqli_real_escape_string($conn, $moduleSnippet[1]);
1379 1378
             $filecontent = $moduleSnippet[2];
1380 1379
             $properties = $moduleSnippet[3];
1381 1380
             $category = mysqli_real_escape_string($conn, $moduleSnippet[4]);
1382 1381
             if (!file_exists($filecontent))
1383
-                echo "  $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1382
+                echo "  $name: ".$_lang['unable_install_snippet']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1384 1383
             else {
1385 1384
 
1386 1385
                 // Create the category if it does not already exist
@@ -1389,24 +1388,24 @@  discard block
 block discarded – undo
1389 1388
                 $snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent)));
1390 1389
                 $snippet = removeDocblock($snippet, 'snippet');
1391 1390
                 $snippet = mysqli_real_escape_string($conn, $snippet);
1392
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_snippets` WHERE name='$name'");
1391
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_snippets` WHERE name='$name'");
1393 1392
                 if (mysqli_num_rows($rs)) {
1394 1393
                     $row = mysqli_fetch_assoc($rs);
1395
-                    $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1396
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) {
1397
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1394
+                    $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
1395
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) {
1396
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1398 1397
                         return;
1399 1398
                     }
1400
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1399
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1401 1400
                 } else {
1402
-                    if ($properties != NULL ){
1401
+                    if ($properties != NULL) {
1403 1402
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1404 1403
                     }
1405
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
1406
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1404
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
1405
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1407 1406
                         return;
1408 1407
                     }
1409
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1408
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1410 1409
                 }
1411 1410
             }
1412 1411
         }
@@ -1415,24 +1414,24 @@  discard block
 block discarded – undo
1415 1414
 
1416 1415
 // Install demo-site
1417 1416
 if ($installData && $moduleSQLDataFile) {
1418
-    echo PHP_EOL . $_lang['installing_demo_site'];
1417
+    echo PHP_EOL.$_lang['installing_demo_site'];
1419 1418
     $sqlParser->process($moduleSQLDataFile);
1420 1419
     // display database results
1421 1420
     if ($sqlParser->installFailed == true) {
1422 1421
         $errors += 1;
1423
-        echo $_lang['database_alerts'] . PHP_EOL;
1424
-        echo $_lang['setup_couldnt_install'] . PHP_EOL;
1425
-        echo $_lang['installation_error_occured'] . PHP_EOL . PHP_EOL;
1422
+        echo $_lang['database_alerts'].PHP_EOL;
1423
+        echo $_lang['setup_couldnt_install'].PHP_EOL;
1424
+        echo $_lang['installation_error_occured'].PHP_EOL.PHP_EOL;
1426 1425
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
1427
-            echo $sqlParser->mysqlErrors[$i]["error"] . " " . $_lang['during_execution_of_sql'] . " " . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . PHP_EOL;
1426
+            echo $sqlParser->mysqlErrors[$i]["error"]." ".$_lang['during_execution_of_sql']." ".strip_tags($sqlParser->mysqlErrors[$i]["sql"]).PHP_EOL;
1428 1427
         }
1429 1428
 
1430
-        echo $_lang['some_tables_not_updated'] . PHP_EOL;
1429
+        echo $_lang['some_tables_not_updated'].PHP_EOL;
1431 1430
         return;
1432 1431
     } else {
1433 1432
         $sql = sprintf("SELECT id FROM `%ssite_templates` WHERE templatename='EVO startup - Bootstrap'", $sqlParser->prefix);
1434 1433
         $rs = mysqli_query($sqlParser->conn, $sql);
1435
-        if(mysqli_num_rows($rs)) {
1434
+        if (mysqli_num_rows($rs)) {
1436 1435
             $row = mysqli_fetch_assoc($rs);
1437 1436
             $sql = sprintf('UPDATE `%ssite_content` SET template=%s WHERE template=4', $sqlParser->prefix, $row['id']);
1438 1437
             mysqli_query($sqlParser->conn, $sql);
@@ -1444,9 +1443,9 @@  discard block
 block discarded – undo
1444 1443
 // Install Dependencies
1445 1444
 $moduleDependencies = $mdp;
1446 1445
 foreach ($moduleDependencies as $dependency) {
1447
-    $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"');
1446
+    $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM '.$dbase.'`'.$sqlParser->prefix.'site_modules` WHERE name="'.$dependency['module'].'"');
1448 1447
     if (!$ds) {
1449
-        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1448
+        echo mysqli_error($sqlParser->conn).PHP_EOL;
1450 1449
         return;
1451 1450
     } else {
1452 1451
         $row = mysqli_fetch_assoc($ds);
@@ -1454,37 +1453,37 @@  discard block
 block discarded – undo
1454 1453
         $moduleGuid = $row["guid"];
1455 1454
     }
1456 1455
     // get extra id
1457
-    $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"');
1456
+    $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE '.$dependency['column'].'="'.$dependency['name'].'"');
1458 1457
     if (!$ds) {
1459
-        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1458
+        echo mysqli_error($sqlParser->conn).PHP_EOL;
1460 1459
         return;
1461 1460
     } else {
1462 1461
         $row = mysqli_fetch_assoc($ds);
1463 1462
         $extraId = $row["id"];
1464 1463
     }
1465 1464
     // setup extra as module dependency
1466
-    $ds = mysqli_query($sqlParser->conn, 'SELECT module FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type'] . ' LIMIT 1');
1465
+    $ds = mysqli_query($sqlParser->conn, 'SELECT module FROM '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` WHERE module='.$moduleId.' AND resource='.$extraId.' AND type='.$dependency['type'].' LIMIT 1');
1467 1466
     if (!$ds) {
1468
-        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1467
+        echo mysqli_error($sqlParser->conn).PHP_EOL;
1469 1468
         return;
1470 1469
     } else {
1471 1470
         if (mysqli_num_rows($ds) === 0) {
1472
-            mysqli_query($sqlParser->conn, 'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')');
1473
-            echo $dependency['module'] . ' Module: ' . $_lang['depedency_create'] . PHP_EOL;
1471
+            mysqli_query($sqlParser->conn, 'INSERT INTO '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` (module, resource, type) VALUES('.$moduleId.','.$extraId.','.$dependency['type'].')');
1472
+            echo $dependency['module'].' Module: '.$_lang['depedency_create'].PHP_EOL;
1474 1473
         } else {
1475
-            mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` SET module = ' . $moduleId . ', resource = ' . $extraId . ', type = ' . $dependency['type'] . ' WHERE module=' . $moduleId . ' AND resource=' . $extraId . ' AND type=' . $dependency['type']);
1476
-            echo $dependency['module'] . ' Module: ' . $_lang['depedency_update'] . PHP_EOL;
1474
+            mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` SET module = '.$moduleId.', resource = '.$extraId.', type = '.$dependency['type'].' WHERE module='.$moduleId.' AND resource='.$extraId.' AND type='.$dependency['type']);
1475
+            echo $dependency['module'].' Module: '.$_lang['depedency_update'].PHP_EOL;
1477 1476
         }
1478 1477
         if ($dependency['type'] == 30 || $dependency['type'] == 40) {
1479 1478
             // set extra guid for plugins and snippets
1480
-            $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1');
1479
+            $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE id='.$extraId.' LIMIT 1');
1481 1480
             if (!$ds) {
1482
-                echo mysqli_error($sqlParser->conn) . PHP_EOL;
1481
+                echo mysqli_error($sqlParser->conn).PHP_EOL;
1483 1482
                 return;
1484 1483
             } else {
1485 1484
                 if (mysqli_num_rows($ds) != 0) {
1486
-                    mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId);
1487
-                    echo $dependency['name'] . ': ' . $_lang['guid_set'] . PHP_EOL;
1485
+                    mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` SET moduleguid = '.$moduleGuid.' WHERE id='.$extraId);
1486
+                    echo $dependency['name'].': '.$_lang['guid_set'].PHP_EOL;
1488 1487
                 }
1489 1488
             }
1490 1489
         }
@@ -1493,7 +1492,7 @@  discard block
 block discarded – undo
1493 1492
 
1494 1493
 // call back function
1495 1494
 if ($callBackFnc != "")
1496
-    $callBackFnc ($sqlParser);
1495
+    $callBackFnc($sqlParser);
1497 1496
 
1498 1497
 // Setup the MODX API -- needed for the cache processor
1499 1498
 if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
@@ -1526,22 +1525,22 @@  discard block
 block discarded – undo
1526 1525
 }
1527 1526
 
1528 1527
 // setup completed!
1529
-echo PHP_EOL . $_lang['installation_successful'] . PHP_EOL . PHP_EOL;
1528
+echo PHP_EOL.$_lang['installation_successful'].PHP_EOL.PHP_EOL;
1530 1529
 //echo "<p>" . $_lang['to_log_into_content_manager'] . "</p>";
1531 1530
 if ($installMode == 0) {
1532
-   echo strip_tags($_lang['installation_note']) . PHP_EOL;
1531
+   echo strip_tags($_lang['installation_note']).PHP_EOL;
1533 1532
 } else {
1534
-   echo strip_tags($_lang['upgrade_note']) . PHP_EOL;
1533
+   echo strip_tags($_lang['upgrade_note']).PHP_EOL;
1535 1534
 }
1536 1535
 
1537 1536
 
1538
-if ( empty($args) ){
1539
-    echo PHP_EOL . 'Remove install folder?'.PHP_EOL;
1537
+if (empty($args)) {
1538
+    echo PHP_EOL.'Remove install folder?'.PHP_EOL;
1540 1539
     $removeInstall = readline("Type 'y' or 'n' to continue: ");
1541 1540
 }
1542 1541
 //remove installFolder
1543 1542
 if ($removeInstall == 'y') {
1544
-    echo 'Install folder deleted!'. PHP_EOL . PHP_EOL;
1543
+    echo 'Install folder deleted!'.PHP_EOL.PHP_EOL;
1545 1544
 }
1546 1545
 
1547 1546
 /**
@@ -1551,11 +1550,11 @@  discard block
 block discarded – undo
1551 1550
  * @param string $old
1552 1551
  * @return string
1553 1552
  */
1554
-function propUpdate($new,$old){
1553
+function propUpdate($new, $old){
1555 1554
     $newArr = parseProperties($new);
1556 1555
     $oldArr = parseProperties($old);
1557
-    foreach ($oldArr as $k => $v){
1558
-        if (isset($v['0']['options'])){
1556
+    foreach ($oldArr as $k => $v) {
1557
+        if (isset($v['0']['options'])) {
1559 1558
             $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options'];
1560 1559
         }
1561 1560
     }
@@ -1570,30 +1569,30 @@  discard block
 block discarded – undo
1570 1569
  * @param bool|mixed $json
1571 1570
  * @return string
1572 1571
  */
1573
-function parseProperties($propertyString, $json=false) {
1574
-    $propertyString = str_replace('{}', '', $propertyString );
1575
-    $propertyString = str_replace('} {', ',', $propertyString );
1572
+function parseProperties($propertyString, $json = false){
1573
+    $propertyString = str_replace('{}', '', $propertyString);
1574
+    $propertyString = str_replace('} {', ',', $propertyString);
1576 1575
 
1577
-    if(empty($propertyString)) return array();
1578
-    if($propertyString=='{}' || $propertyString=='[]') return array();
1576
+    if (empty($propertyString)) return array();
1577
+    if ($propertyString == '{}' || $propertyString == '[]') return array();
1579 1578
 
1580 1579
     $jsonFormat = isJson($propertyString, true);
1581 1580
     $property = array();
1582 1581
     // old format
1583
-    if ( $jsonFormat === false) {
1584
-        $props= explode('&', $propertyString);
1582
+    if ($jsonFormat === false) {
1583
+        $props = explode('&', $propertyString);
1585 1584
         foreach ($props as $prop) {
1586 1585
             $prop = trim($prop);
1587
-            if($prop === '') {
1586
+            if ($prop === '') {
1588 1587
                 continue;
1589 1588
             }
1590 1589
 
1591 1590
             $arr = explode(';', $prop);
1592
-            if( ! is_array($arr)) {
1591
+            if (!is_array($arr)) {
1593 1592
                 $arr = array();
1594 1593
             }
1595 1594
             $key = explode('=', isset($arr[0]) ? $arr[0] : '');
1596
-            if( ! is_array($key) || empty($key[0])) {
1595
+            if (!is_array($key) || empty($key[0])) {
1597 1596
                 continue;
1598 1597
             }
1599 1598
 
@@ -1617,7 +1616,7 @@  discard block
 block discarded – undo
1617 1616
 
1618 1617
         }
1619 1618
     // new json-format
1620
-    } else if(!empty($jsonFormat)){
1619
+    } else if (!empty($jsonFormat)) {
1621 1620
         $property = $jsonFormat;
1622 1621
     }
1623 1622
     if ($json) {
@@ -1632,7 +1631,7 @@  discard block
 block discarded – undo
1632 1631
  * @param bool $returnData
1633 1632
  * @return bool|mixed
1634 1633
  */
1635
-function isJson($string, $returnData=false) {
1634
+function isJson($string, $returnData = false){
1636 1635
     $data = json_decode($string, true);
1637 1636
     return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false;
1638 1637
 }
@@ -1642,20 +1641,20 @@  discard block
 block discarded – undo
1642 1641
  * @param SqlParser $sqlParser
1643 1642
  * @return int
1644 1643
  */
1645
-function getCreateDbCategory($category, $sqlParser) {
1644
+function getCreateDbCategory($category, $sqlParser){
1646 1645
     $dbase = $sqlParser->dbname;
1647
-    $dbase = '`' . trim($dbase,'`') . '`';
1646
+    $dbase = '`'.trim($dbase, '`').'`';
1648 1647
     $table_prefix = $sqlParser->prefix;
1649 1648
     $category_id = 0;
1650
-    if(!empty($category)) {
1649
+    if (!empty($category)) {
1651 1650
         $category = mysqli_real_escape_string($sqlParser->conn, $category);
1652 1651
         $rs = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."categories` WHERE category = '".$category."'");
1653
-        if(mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) {
1652
+        if (mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) {
1654 1653
             $category_id = $row['id'];
1655 1654
         } else {
1656 1655
             $q = "INSERT INTO $dbase.`".$table_prefix."categories` (`category`) VALUES ('{$category}');";
1657 1656
             $rs = mysqli_query($sqlParser->conn, $q);
1658
-            if($rs) {
1657
+            if ($rs) {
1659 1658
                 $category_id = mysqli_insert_id($sqlParser->conn);
1660 1659
             }
1661 1660
         }
@@ -1670,12 +1669,12 @@  discard block
 block discarded – undo
1670 1669
  * @param string $type
1671 1670
  * @return string
1672 1671
  */
1673
-function removeDocblock($code, $type) {
1672
+function removeDocblock($code, $type){
1674 1673
 
1675 1674
     $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
1676 1675
 
1677 1676
     // Procedure taken from plugin.filesource.php
1678
-    switch($type) {
1677
+    switch ($type) {
1679 1678
         case 'snippet':
1680 1679
             $elm_name = 'snippets';
1681 1680
             $include = 'return require';
@@ -1691,7 +1690,7 @@  discard block
 block discarded – undo
1691 1690
         default:
1692 1691
             return $cleaned;
1693 1692
     };
1694
-    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
1693
+    if (substr(trim($cleaned), 0, $count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
1695 1694
         return $cleaned;
1696 1695
 
1697 1696
     // fileBinding not found - return code incl docblock
Please login to merge, or discard this patch.
Braces   +102 added lines, -68 removed lines patch added patch discarded remove patch
@@ -57,10 +57,12 @@  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
-    if ($installYes != 'y') return;
63
+    if ($installYes != 'y') {
64
+        return;
65
+    }
64 66
 
65 67
     //set param manual
66 68
     $databasehost = readline($_lang['connection_screen_database_host']. ' [localhost] ');
@@ -76,7 +78,7 @@  discard block
 block discarded – undo
76 78
     $managerlanguage = readline('Мanager language:' . ' [en] ');
77 79
     $installData = readline('Instal demo-site (y/n):' . ' [n] ');
78 80
     
79
-}else{
81
+} else {
80 82
     
81 83
     $cli_variables = [];
82 84
     foreach ($args as $arg) {
@@ -130,21 +132,24 @@  discard block
 block discarded – undo
130 132
 }
131 133
 
132 134
 //////////////////////////////////////////////////////////////////////////////////////
133
-if( ! function_exists('f_owc')){
135
+if( ! function_exists('f_owc')) {
134 136
     /**
135 137
      * @param $path
136 138
      * @param $data
137 139
      * @param null|int $mode
138 140
      */
139
-    function f_owc($path, $data, $mode = null){
141
+    function f_owc($path, $data, $mode = null)
142
+    {
140 143
         try {
141 144
             // make an attempt to create the file
142 145
             $hnd = fopen($path, 'w');
143 146
             fwrite($hnd, $data);
144 147
             fclose($hnd);
145 148
 
146
-            if(null !== $mode) chmod($path, $mode);
147
-        }catch(Exception $e){
149
+            if(null !== $mode) {
150
+                chmod($path, $mode);
151
+            }
152
+        } catch(Exception $e) {
148 153
             // Nothing, this is NOT normal
149 154
             unset($e);
150 155
         }
@@ -210,7 +215,7 @@  discard block
 block discarded – undo
210 215
 
211 216
 // File Browser directories exists?
212 217
 echo strip_tags($_lang['checking_if_images_exist']);
213
-switch(true){
218
+switch(true) {
214 219
     case !file_exists("../assets/images"):
215 220
     case !file_exists("../assets/files"):
216 221
     case !file_exists("../assets/backup"):
@@ -225,7 +230,7 @@  discard block
 block discarded – undo
225 230
 
226 231
 // File Browser directories writable?
227 232
 echo strip_tags($_lang['checking_if_images_writable']);
228
-switch(true){
233
+switch(true) {
229 234
     case !is_writable("../assets/images"):
230 235
     case !is_writable("../assets/files"):
231 236
     case !is_writable("../assets/backup"):
@@ -361,7 +366,7 @@  discard block
 block discarded – undo
361 366
 if ($conn) {
362 367
     echo $_lang['checking_mysql_strict_mode'];
363 368
     $mysqlmode = mysqli_query($conn, "SELECT @@global.sql_mode");
364
-    if (mysqli_num_rows($mysqlmode) > 0){
369
+    if (mysqli_num_rows($mysqlmode) > 0) {
365 370
         $modes = mysqli_fetch_array($mysqlmode, MYSQLI_NUM);
366 371
         //$modes = array("STRICT_TRANS_TABLES"); // for testing
367 372
         // print_r($modes);
@@ -397,9 +402,9 @@  discard block
 block discarded – undo
397 402
 if ($errors > 0) {
398 403
     echo $_lang['setup_cannot_continue'] . ' ';
399 404
 
400
-    if($errors > 1){
405
+    if($errors > 1) {
401 406
         echo $errors . " " . $_lang['errors'] . $_lang['please_correct_errors'] . $_lang['and_try_again_plural'];
402
-    }else{
407
+    } else {
403 408
         echo $_lang['error'] . $_lang['please_correct_error'] . $_lang['and_try_again']. PHP_EOL;
404 409
     }
405 410
 
@@ -412,7 +417,7 @@  discard block
 block discarded – undo
412 417
 
413 418
 if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) {
414 419
     include_once(dirname(__FILE__)."/../assets/cache/siteManager.php");
415
-}else{
420
+} else {
416 421
     define('MGR_DIR', 'manager');
417 422
 }
418 423
 
@@ -453,13 +458,15 @@  discard block
 block discarded – undo
453 458
 
454 459
 // get base path and url
455 460
 $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"])));
456
-if (count($a) > 1)
461
+if (count($a) > 1) {
457 462
     array_pop($a);
463
+}
458 464
 $url = implode("install", $a);
459 465
 reset($a);
460 466
 $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__))));
461
-if (count($a) > 1)
467
+if (count($a) > 1) {
462 468
     array_pop($a);
469
+}
463 470
 $pth = implode("install", $a);
464 471
 unset ($a);
465 472
 $base_url = $url . (substr($url, -1) != "/" ? "/" : "");
@@ -480,7 +487,9 @@  discard block
 block discarded – undo
480 487
     echo $_lang['setup_database_selection_failed']." ".$_lang['setup_database_selection_failed_note'].PHP_EOL;
481 488
     $create = true;
482 489
 } else {
483
-    if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset);
490
+    if (function_exists('mysqli_set_charset')) {
491
+        mysqli_set_charset($conn, $database_charset);
492
+    }
484 493
     mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}");
485 494
     echo $_lang['ok'].PHP_EOL;
486 495
 }
@@ -526,7 +535,8 @@  discard block
 block discarded – undo
526 535
      * @param string $propertyString
527 536
      * @return array
528 537
      */
529
-    function parseProperties($propertyString) {
538
+    function parseProperties($propertyString)
539
+    {
530 540
         $parameter= array ();
531 541
         if (!empty ($propertyString)) {
532 542
             $tmpParams= explode("&", $propertyString);
@@ -535,11 +545,14 @@  discard block
 block discarded – undo
535 545
                 if (strpos($tmpParams[$x], '=', 0)) {
536 546
                     $pTmp= explode("=", $tmpParams[$x]);
537 547
                     $pvTmp= explode(";", trim($pTmp[1]));
538
-                    if ($pvTmp[1] == 'list' && $pvTmp[3] != "")
539
-                        $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default
548
+                    if ($pvTmp[1] == 'list' && $pvTmp[3] != "") {
549
+                                            $parameter[trim($pTmp[0])]= $pvTmp[3];
550
+                    }
551
+                    //list default
540 552
                     else
541
-                        if ($pvTmp[1] != 'list' && $pvTmp[2] != "")
542
-                            $parameter[trim($pTmp[0])]= $pvTmp[2];
553
+                        if ($pvTmp[1] != 'list' && $pvTmp[2] != "") {
554
+                                                    $parameter[trim($pTmp[0])]= $pvTmp[2];
555
+                        }
543 556
                 }
544 557
             }
545 558
         }
@@ -587,12 +600,12 @@  discard block
 block discarded – undo
587 600
 $mt = &$moduleTemplates;
588 601
 if(is_dir($templatePath) && is_readable($templatePath)) {
589 602
     $d = dir($templatePath);
590
-    while (false !== ($tplfile = $d->read()))
591
-    {
592
-        if(substr($tplfile, -4) != '.tpl') continue;
603
+    while (false !== ($tplfile = $d->read())) {
604
+        if(substr($tplfile, -4) != '.tpl') {
605
+            continue;
606
+        }
593 607
         $params = parse_docblock($templatePath, $tplfile);
594
-        if(is_array($params) && (count($params)>0))
595
-        {
608
+        if(is_array($params) && (count($params)>0)) {
596 609
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
597 610
             $mt[] = array
598 611
             (
@@ -616,7 +629,9 @@  discard block
 block discarded – undo
616 629
 if(is_dir($tvPath) && is_readable($tvPath)) {
617 630
     $d = dir($tvPath);
618 631
     while (false !== ($tplfile = $d->read())) {
619
-        if(substr($tplfile, -4) != '.tpl') continue;
632
+        if(substr($tplfile, -4) != '.tpl') {
633
+            continue;
634
+        }
620 635
         $params = parse_docblock($tvPath, $tplfile);
621 636
         if(is_array($params) && (count($params)>0)) {
622 637
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
@@ -809,7 +824,8 @@  discard block
 block discarded – undo
809 824
 // setup callback function
810 825
 $callBackFnc = "clean_up";
811 826
 
812
-function clean_up($sqlParser) {
827
+function clean_up($sqlParser)
828
+{
813 829
     $ids = array();
814 830
 
815 831
     // secure web documents - privateweb
@@ -822,9 +838,10 @@  discard block
 block discarded – undo
822 838
     $ds = mysqli_query($sqlParser->conn,$sql);
823 839
     if(!$ds) {
824 840
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
825
-    }
826
-    else {
827
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
841
+    } else {
842
+        while($r = mysqli_fetch_assoc($ds)) {
843
+            $ids[]=$r["id"];
844
+        }
828 845
         if(count($ids)>0) {
829 846
             mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")");
830 847
             unset($ids);
@@ -841,9 +858,10 @@  discard block
 block discarded – undo
841 858
     $ds = mysqli_query($sqlParser->conn,$sql);
842 859
     if(!$ds) {
843 860
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
844
-    }
845
-    else {
846
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
861
+    } else {
862
+        while($r = mysqli_fetch_assoc($ds)) {
863
+            $ids[]=$r["id"];
864
+        }
847 865
         if(count($ids)>0) {
848 866
             mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")");
849 867
             unset($ids);
@@ -851,7 +869,8 @@  discard block
 block discarded – undo
851 869
     }
852 870
 }
853 871
 
854
-function parse_docblock($element_dir, $filename) {
872
+function parse_docblock($element_dir, $filename)
873
+{
855 874
     $params = array();
856 875
     $fullpath = $element_dir . '/' . $filename;
857 876
     if(is_readable($fullpath)) {
@@ -952,7 +971,7 @@  discard block
 block discarded – undo
952 971
 // custom or not
953 972
 if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) {
954 973
     $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");';
955
-}else{
974
+} else {
956 975
     $mgrdir = 'define(\'MGR_DIR\', \'manager\');';
957 976
 }
958 977
 
@@ -1092,7 +1111,9 @@  discard block
 block discarded – undo
1092 1111
                         echo mysqli_error($sqlParser->conn) . PHP_EOL;
1093 1112
                         die();
1094 1113
                     }
1095
-                    if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1114
+                    if(!is_null($save_sql_id_as)) {
1115
+                        $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1116
+                    }
1096 1117
                     echo "  $name: " . $_lang['installed'] . PHP_EOL;
1097 1118
                 }
1098 1119
             }
@@ -1187,9 +1208,9 @@  discard block
 block discarded – undo
1187 1208
             $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]);
1188 1209
             $filecontent = $moduleChunk[2];
1189 1210
 
1190
-            if (!file_exists($filecontent))
1191
-                echo "  $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1192
-            else {
1211
+            if (!file_exists($filecontent)) {
1212
+                            echo "  $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1213
+            } else {
1193 1214
 
1194 1215
                 // Create the category if it does not already exist
1195 1216
                 $category_id = getCreateDbCategory($category, $sqlParser);
@@ -1242,9 +1263,9 @@  discard block
 block discarded – undo
1242 1263
             $guid = mysqli_real_escape_string($conn, $moduleModule[4]);
1243 1264
             $shared = mysqli_real_escape_string($conn, $moduleModule[5]);
1244 1265
             $category = mysqli_real_escape_string($conn, $moduleModule[6]);
1245
-            if (!file_exists($filecontent))
1246
-                echo "  $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1247
-            else {
1266
+            if (!file_exists($filecontent)) {
1267
+                            echo "  $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1268
+            } else {
1248 1269
 
1249 1270
                 // Create the category if it does not already exist
1250 1271
                 $category = getCreateDbCategory($category, $sqlParser);
@@ -1262,7 +1283,7 @@  discard block
 block discarded – undo
1262 1283
                     }
1263 1284
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1264 1285
                 } else {
1265
-                    if ($properties != NULL ){
1286
+                    if ($properties != NULL ) {
1266 1287
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1267 1288
                     }
1268 1289
                     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);")) {
@@ -1297,9 +1318,9 @@  discard block
 block discarded – undo
1297 1318
                 // parse comma-separated legacy names and prepare them for sql IN clause
1298 1319
                 $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'";
1299 1320
             }
1300
-            if (!file_exists($filecontent))
1301
-                echo "  $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1302
-            else {
1321
+            if (!file_exists($filecontent)) {
1322
+                            echo "  $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1323
+            } else {
1303 1324
 
1304 1325
                 // disable legacy versions based on legacy_names provided
1305 1326
                 if(!empty($leg_names)) {
@@ -1318,7 +1339,7 @@  discard block
 block discarded – undo
1318 1339
                     $insert = true;
1319 1340
                     while($row = mysqli_fetch_assoc($rs)) {
1320 1341
                         $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1321
-                        if($row['description'] == $desc){
1342
+                        if($row['description'] == $desc) {
1322 1343
                             if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
1323 1344
                                 echo mysqli_error($sqlParser->conn) . PHP_EOL;
1324 1345
                                 return;
@@ -1340,7 +1361,7 @@  discard block
 block discarded – undo
1340 1361
                     }
1341 1362
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1342 1363
                 } else {
1343
-                    if ($properties != NULL ){
1364
+                    if ($properties != NULL ) {
1344 1365
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1345 1366
                     }
1346 1367
                     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);")) {
@@ -1379,9 +1400,9 @@  discard block
 block discarded – undo
1379 1400
             $filecontent = $moduleSnippet[2];
1380 1401
             $properties = $moduleSnippet[3];
1381 1402
             $category = mysqli_real_escape_string($conn, $moduleSnippet[4]);
1382
-            if (!file_exists($filecontent))
1383
-                echo "  $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1384
-            else {
1403
+            if (!file_exists($filecontent)) {
1404
+                            echo "  $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1405
+            } else {
1385 1406
 
1386 1407
                 // Create the category if it does not already exist
1387 1408
                 $category = getCreateDbCategory($category, $sqlParser);
@@ -1399,7 +1420,7 @@  discard block
 block discarded – undo
1399 1420
                     }
1400 1421
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1401 1422
                 } else {
1402
-                    if ($properties != NULL ){
1423
+                    if ($properties != NULL ) {
1403 1424
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1404 1425
                     }
1405 1426
                     if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
@@ -1492,11 +1513,14 @@  discard block
 block discarded – undo
1492 1513
 }
1493 1514
 
1494 1515
 // call back function
1495
-if ($callBackFnc != "")
1516
+if ($callBackFnc != "") {
1496 1517
     $callBackFnc ($sqlParser);
1518
+}
1497 1519
 
1498 1520
 // Setup the MODX API -- needed for the cache processor
1499
-if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
1521
+if (!defined('MODX_MANAGER_PATH')) {
1522
+    define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
1523
+}
1500 1524
 $database_type = 'mysqli';
1501 1525
 // initiate a new document parser
1502 1526
 include_once('../'.MGR_DIR.'/includes/document.parser.class.inc.php');
@@ -1535,7 +1559,7 @@  discard block
 block discarded – undo
1535 1559
 }
1536 1560
 
1537 1561
 
1538
-if ( empty($args) ){
1562
+if ( empty($args) ) {
1539 1563
     echo PHP_EOL . 'Remove install folder?'.PHP_EOL;
1540 1564
     $removeInstall = readline("Type 'y' or 'n' to continue: ");
1541 1565
 }
@@ -1551,11 +1575,12 @@  discard block
 block discarded – undo
1551 1575
  * @param string $old
1552 1576
  * @return string
1553 1577
  */
1554
-function propUpdate($new,$old){
1578
+function propUpdate($new,$old)
1579
+{
1555 1580
     $newArr = parseProperties($new);
1556 1581
     $oldArr = parseProperties($old);
1557
-    foreach ($oldArr as $k => $v){
1558
-        if (isset($v['0']['options'])){
1582
+    foreach ($oldArr as $k => $v) {
1583
+        if (isset($v['0']['options'])) {
1559 1584
             $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options'];
1560 1585
         }
1561 1586
     }
@@ -1570,12 +1595,17 @@  discard block
 block discarded – undo
1570 1595
  * @param bool|mixed $json
1571 1596
  * @return string
1572 1597
  */
1573
-function parseProperties($propertyString, $json=false) {
1598
+function parseProperties($propertyString, $json=false)
1599
+{
1574 1600
     $propertyString = str_replace('{}', '', $propertyString );
1575 1601
     $propertyString = str_replace('} {', ',', $propertyString );
1576 1602
 
1577
-    if(empty($propertyString)) return array();
1578
-    if($propertyString=='{}' || $propertyString=='[]') return array();
1603
+    if(empty($propertyString)) {
1604
+        return array();
1605
+    }
1606
+    if($propertyString=='{}' || $propertyString=='[]') {
1607
+        return array();
1608
+    }
1579 1609
 
1580 1610
     $jsonFormat = isJson($propertyString, true);
1581 1611
     $property = array();
@@ -1617,7 +1647,7 @@  discard block
 block discarded – undo
1617 1647
 
1618 1648
         }
1619 1649
     // new json-format
1620
-    } else if(!empty($jsonFormat)){
1650
+    } else if(!empty($jsonFormat)) {
1621 1651
         $property = $jsonFormat;
1622 1652
     }
1623 1653
     if ($json) {
@@ -1632,7 +1662,8 @@  discard block
 block discarded – undo
1632 1662
  * @param bool $returnData
1633 1663
  * @return bool|mixed
1634 1664
  */
1635
-function isJson($string, $returnData=false) {
1665
+function isJson($string, $returnData=false)
1666
+{
1636 1667
     $data = json_decode($string, true);
1637 1668
     return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false;
1638 1669
 }
@@ -1642,7 +1673,8 @@  discard block
 block discarded – undo
1642 1673
  * @param SqlParser $sqlParser
1643 1674
  * @return int
1644 1675
  */
1645
-function getCreateDbCategory($category, $sqlParser) {
1676
+function getCreateDbCategory($category, $sqlParser)
1677
+{
1646 1678
     $dbase = $sqlParser->dbname;
1647 1679
     $dbase = '`' . trim($dbase,'`') . '`';
1648 1680
     $table_prefix = $sqlParser->prefix;
@@ -1670,7 +1702,8 @@  discard block
 block discarded – undo
1670 1702
  * @param string $type
1671 1703
  * @return string
1672 1704
  */
1673
-function removeDocblock($code, $type) {
1705
+function removeDocblock($code, $type)
1706
+{
1674 1707
 
1675 1708
     $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
1676 1709
 
@@ -1691,8 +1724,9 @@  discard block
 block discarded – undo
1691 1724
         default:
1692 1725
             return $cleaned;
1693 1726
     };
1694
-    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
1695
-        return $cleaned;
1727
+    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') {
1728
+            return $cleaned;
1729
+    }
1696 1730
 
1697 1731
     // fileBinding not found - return code incl docblock
1698 1732
     return $code;
Please login to merge, or discard this patch.