Completed
Push — develop ( 4d8ac6...f95bd9 )
by Dmytro
11:24 queued 03:15
created
install/cli-install.php 2 patches
Spacing   +330 added lines, -331 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 = $path."setup.data.sql";
41 41
 $moduleSQLResetFile = $path."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($path."../assets/images"):
215 215
     case !file_exists($path."../assets/files"):
216 216
     case !file_exists($path."../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($path."../assets/images"):
230 230
     case !is_writable($path."../assets/files"):
231 231
     case !is_writable($path."../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($path."../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($path."../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($path."../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();
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
     $database_charset = substr($database_collation, 0, strpos($database_collation, '_'));
430 430
     $database_connection_charset = $database_charset;
431 431
     $database_connection_method = $database_connection_method;
432
-    $dbase = "`" .$database_name. "`";
432
+    $dbase = "`".$database_name."`";
433 433
     $table_prefix = $tableprefix;
434 434
     $adminname = $cmsadmin;
435 435
     $adminemail = $cmsadminemail;
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 
441 441
 // set session name variable
442 442
 if (!isset ($site_sessionname)) {
443
-    $site_sessionname = 'SN' . uniqid('');
443
+    $site_sessionname = 'SN'.uniqid('');
444 444
 }
445 445
 
446 446
 // get base path and url
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
     array_pop($a);
455 455
 $pth = implode("install", $a);
456 456
 unset ($a);
457
-$base_url = $url . (substr($url, -1) != "/" ? "/" : "");
458
-$base_path = $pth . (substr($pth, -1) != "/" ? "/" : "");
457
+$base_url = $url.(substr($url, -1) != "/" ? "/" : "");
458
+$base_path = $pth.(substr($pth, -1) != "/" ? "/" : "");
459 459
 
460 460
 // connect to the database
461 461
 echo $_lang['setup_database_create_connection'].': ';
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 }
468 468
 
469 469
 // select database
470
-echo $_lang['setup_database_selection']. str_replace("`", "", $dbase) . "`: ";
470
+echo $_lang['setup_database_selection'].str_replace("`", "", $dbase)."`: ";
471 471
 if (!mysqli_select_db($conn, str_replace("`", "", $dbase))) {
472 472
     echo $_lang['setup_database_selection_failed']." ".$_lang['setup_database_selection_failed_note'].PHP_EOL;
473 473
     $create = true;
@@ -479,16 +479,16 @@  discard block
 block discarded – undo
479 479
 
480 480
 // try to create the database
481 481
 if ($create) {
482
-    echo $_lang['setup_database_creation']. str_replace("`", "", $dbase) . "`: ";
482
+    echo $_lang['setup_database_creation'].str_replace("`", "", $dbase)."`: ";
483 483
     //  if(!@mysqli_create_db(str_replace("`","",$dbase), $conn)) {
484
-    if (! mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) {
484
+    if (!mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) {
485 485
         echo $_lang['setup_database_creation_failed']." ".$_lang['setup_database_creation_failed_note'].PHP_EOL;
486 486
         $errors += 1;
487 487
         
488
-        echo 'database charset: ' . $database_charset . PHP_EOL;
489
-        echo 'database collation: ' . $database_collation . PHP_EOL;
488
+        echo 'database charset: '.$database_charset.PHP_EOL;
489
+        echo 'database collation: '.$database_collation.PHP_EOL;
490 490
 
491
-        echo $_lang['setup_database_creation_failed_note2'] . PHP_EOL;
491
+        echo $_lang['setup_database_creation_failed_note2'].PHP_EOL;
492 492
 
493 493
         die();
494 494
 
@@ -499,18 +499,18 @@  discard block
 block discarded – undo
499 499
 
500 500
 // check table prefix
501 501
 if ($installMode == 0) {
502
-    echo $_lang['checking_table_prefix'] . $table_prefix . "`: ";
503
-    if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) {
504
-        echo $_lang['failed'] . " " . $_lang['table_prefix_already_inuse'] . PHP_EOL;
502
+    echo $_lang['checking_table_prefix'].$table_prefix."`: ";
503
+    if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) {
504
+        echo $_lang['failed']." ".$_lang['table_prefix_already_inuse'].PHP_EOL;
505 505
         $errors += 1;
506
-        echo $_lang['table_prefix_already_inuse_note'] . PHP_EOL;
506
+        echo $_lang['table_prefix_already_inuse_note'].PHP_EOL;
507 507
         return;
508 508
     } else {
509 509
         echo $_lang['ok'].PHP_EOL;
510 510
     }
511 511
 }
512 512
 
513
-if(!function_exists('parseProperties')) {
513
+if (!function_exists('parseProperties')) {
514 514
     /**
515 515
      * parses a resource property string and returns the result as an array
516 516
      * duplicate of method in documentParser class
@@ -518,20 +518,20 @@  discard block
 block discarded – undo
518 518
      * @param string $propertyString
519 519
      * @return array
520 520
      */
521
-    function parseProperties($propertyString) {
522
-        $parameter= array ();
521
+    function parseProperties($propertyString){
522
+        $parameter = array();
523 523
         if (!empty ($propertyString)) {
524
-            $tmpParams= explode("&", $propertyString);
524
+            $tmpParams = explode("&", $propertyString);
525 525
             $countParams = count($tmpParams);
526
-            for ($x= 0; $x < $countParams; $x++) {
526
+            for ($x = 0; $x < $countParams; $x++) {
527 527
                 if (strpos($tmpParams[$x], '=', 0)) {
528
-                    $pTmp= explode("=", $tmpParams[$x]);
529
-                    $pvTmp= explode(";", trim($pTmp[1]));
528
+                    $pTmp = explode("=", $tmpParams[$x]);
529
+                    $pvTmp = explode(";", trim($pTmp[1]));
530 530
                     if ($pvTmp[1] == 'list' && $pvTmp[3] != "")
531
-                        $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default
531
+                        $parameter[trim($pTmp[0])] = $pvTmp[3]; //list default
532 532
                     else
533 533
                         if ($pvTmp[1] != 'list' && $pvTmp[2] != "")
534
-                            $parameter[trim($pTmp[0])]= $pvTmp[2];
534
+                            $parameter[trim($pTmp[0])] = $pvTmp[2];
535 535
                 }
536 536
             }
537 537
         }
@@ -542,20 +542,20 @@  discard block
 block discarded – undo
542 542
 // check status of Inherit Parent Template plugin
543 543
 $auto_template_logic = 'parent';
544 544
 if ($installMode != 0) {
545
-    $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='Inherit Parent Template'");
545
+    $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`".$table_prefix."site_plugins` WHERE name='Inherit Parent Template'");
546 546
     $row = mysqli_fetch_row($rs);
547
-    if(!$row) {
547
+    if (!$row) {
548 548
         // not installed
549 549
         $auto_template_logic = 'system';
550 550
     } else {
551
-        if($row[1] == 1) {
551
+        if ($row[1] == 1) {
552 552
             // installed but disabled
553 553
             $auto_template_logic = 'system';
554 554
         } else {
555 555
             // installed, enabled .. see how it's configured
556 556
             $properties = parseProperties($row[0]);
557
-            if(isset($properties['inheritTemplate'])) {
558
-                if($properties['inheritTemplate'] == 'From First Sibling') {
557
+            if (isset($properties['inheritTemplate'])) {
558
+                if ($properties['inheritTemplate'] == 'From First Sibling') {
559 559
                     $auto_template_logic = 'sibling';
560 560
                 }
561 561
             }
@@ -577,17 +577,16 @@  discard block
 block discarded – undo
577 577
 
578 578
 // setup Template template files - array : name, description, type - 0:file or 1:content, parameters, category
579 579
 $mt = &$moduleTemplates;
580
-if(is_dir($templatePath) && is_readable($templatePath)) {
580
+if (is_dir($templatePath) && is_readable($templatePath)) {
581 581
     $d = dir($templatePath);
582 582
     while (false !== ($tplfile = $d->read()))
583 583
     {
584
-        if(substr($tplfile, -4) != '.tpl') continue;
584
+        if (substr($tplfile, -4) != '.tpl') continue;
585 585
         $params = parse_docblock($templatePath, $tplfile);
586
-        if(is_array($params) && (count($params)>0))
586
+        if (is_array($params) && (count($params) > 0))
587 587
         {
588 588
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
589
-            $mt[] = array
590
-            (
589
+            $mt[] = array(
591 590
                 $params['name'],
592 591
                 $description,
593 592
                 // Don't think this is gonna be used ... but adding it just in case 'type'
@@ -605,12 +604,12 @@  discard block
 block discarded – undo
605 604
 
606 605
 // setup Template Variable template files
607 606
 $mtv = &$moduleTVs;
608
-if(is_dir($tvPath) && is_readable($tvPath)) {
607
+if (is_dir($tvPath) && is_readable($tvPath)) {
609 608
     $d = dir($tvPath);
610 609
     while (false !== ($tplfile = $d->read())) {
611
-        if(substr($tplfile, -4) != '.tpl') continue;
610
+        if (substr($tplfile, -4) != '.tpl') continue;
612 611
         $params = parse_docblock($tvPath, $tplfile);
613
-        if(is_array($params) && (count($params)>0)) {
612
+        if (is_array($params) && (count($params) > 0)) {
614 613
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
615 614
             $mtv[] = array(
616 615
                 $params['name'],
@@ -622,9 +621,9 @@  discard block
 block discarded – undo
622 621
                 $params['output_widget'],
623 622
                 $params['output_widget_params'],
624 623
                 "$templatePath/{$params['filename']}", /* not currently used */
625
-                $params['template_assignments']!="*"?$params['template_assignments']:implode(",",array_map(create_function('$v','return $v[0];'),$mt)), /* comma-separated list of template names */
624
+                $params['template_assignments'] != "*" ? $params['template_assignments'] : implode(",", array_map(create_function('$v', 'return $v[0];'), $mt)), /* comma-separated list of template names */
626 625
                 $params['modx_category'],
627
-                $params['lock_tv'],  /* value should be 1 or 0 */
626
+                $params['lock_tv'], /* value should be 1 or 0 */
628 627
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
629 628
             );
630 629
         }
@@ -634,14 +633,14 @@  discard block
 block discarded – undo
634 633
 
635 634
 // setup chunks template files - array : name, description, type - 0:file or 1:content, file or content
636 635
 $mc = &$moduleChunks;
637
-if(is_dir($chunkPath) && is_readable($chunkPath)) {
636
+if (is_dir($chunkPath) && is_readable($chunkPath)) {
638 637
     $d = dir($chunkPath);
639 638
     while (false !== ($tplfile = $d->read())) {
640
-        if(substr($tplfile, -4) != '.tpl') {
639
+        if (substr($tplfile, -4) != '.tpl') {
641 640
             continue;
642 641
         }
643 642
         $params = parse_docblock($chunkPath, $tplfile);
644
-        if(is_array($params) && count($params) > 0) {
643
+        if (is_array($params) && count($params) > 0) {
645 644
             $mc[] = array(
646 645
                 $params['name'],
647 646
                 $params['description'],
@@ -657,14 +656,14 @@  discard block
 block discarded – undo
657 656
 
658 657
 // setup snippets template files - array : name, description, type - 0:file or 1:content, file or content,properties
659 658
 $ms = &$moduleSnippets;
660
-if(is_dir($snippetPath) && is_readable($snippetPath)) {
659
+if (is_dir($snippetPath) && is_readable($snippetPath)) {
661 660
     $d = dir($snippetPath);
662 661
     while (false !== ($tplfile = $d->read())) {
663
-        if(substr($tplfile, -4) != '.tpl') {
662
+        if (substr($tplfile, -4) != '.tpl') {
664 663
             continue;
665 664
         }
666 665
         $params = parse_docblock($snippetPath, $tplfile);
667
-        if(is_array($params) && count($params) > 0) {
666
+        if (is_array($params) && count($params) > 0) {
668 667
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
669 668
             $ms[] = array(
670 669
                 $params['name'],
@@ -681,14 +680,14 @@  discard block
 block discarded – undo
681 680
 
682 681
 // setup plugins template files - array : name, description, type - 0:file or 1:content, file or content,properties
683 682
 $mp = &$modulePlugins;
684
-if(is_dir($pluginPath) && is_readable($pluginPath)) {
683
+if (is_dir($pluginPath) && is_readable($pluginPath)) {
685 684
     $d = dir($pluginPath);
686 685
     while (false !== ($tplfile = $d->read())) {
687
-        if(substr($tplfile, -4) != '.tpl') {
686
+        if (substr($tplfile, -4) != '.tpl') {
688 687
             continue;
689 688
         }
690 689
         $params = parse_docblock($pluginPath, $tplfile);
691
-        if(is_array($params) && count($params) > 0) {
690
+        if (is_array($params) && count($params) > 0) {
692 691
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
693 692
             $mp[] = array(
694 693
                 $params['name'],
@@ -700,7 +699,7 @@  discard block
 block discarded – undo
700 699
                 $params['modx_category'],
701 700
                 $params['legacy_names'],
702 701
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false,
703
-                (int)$params['disabled']
702
+                (int) $params['disabled']
704 703
             );
705 704
         }
706 705
     }
@@ -710,14 +709,14 @@  discard block
 block discarded – undo
710 709
 // setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams
711 710
 $mm = &$moduleModules;
712 711
 $mdp = &$moduleDependencies;
713
-if(is_dir($modulePath) && is_readable($modulePath)) {
712
+if (is_dir($modulePath) && is_readable($modulePath)) {
714 713
     $d = dir($modulePath);
715 714
     while (false !== ($tplfile = $d->read())) {
716
-        if(substr($tplfile, -4) != '.tpl') {
715
+        if (substr($tplfile, -4) != '.tpl') {
717 716
             continue;
718 717
         }
719 718
         $params = parse_docblock($modulePath, $tplfile);
720
-        if(is_array($params) && count($params) > 0) {
719
+        if (is_array($params) && count($params) > 0) {
721 720
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
722 721
             $mm[] = array(
723 722
                 $params['name'],
@@ -725,12 +724,12 @@  discard block
 block discarded – undo
725 724
                 "$modulePath/{$params['filename']}",
726 725
                 $params['properties'],
727 726
                 $params['guid'],
728
-                (int)$params['shareparams'],
727
+                (int) $params['shareparams'],
729 728
                 $params['modx_category'],
730 729
                 array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
731 730
             );
732 731
         }
733
-        if ((int)$params['shareparams'] || !empty($params['dependencies'])) {
732
+        if ((int) $params['shareparams'] || !empty($params['dependencies'])) {
734 733
             $dependencies = explode(',', $params['dependencies']);
735 734
             foreach ($dependencies as $dependency) {
736 735
                 $dependency = explode(':', $dependency);
@@ -801,103 +800,103 @@  discard block
 block discarded – undo
801 800
 // setup callback function
802 801
 $callBackFnc = "clean_up";
803 802
 
804
-function clean_up($sqlParser) {
803
+function clean_up($sqlParser){
805 804
     $ids = array();
806 805
 
807 806
     // secure web documents - privateweb
808
-    mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 0 WHERE privateweb = 1");
809
-    $sql =  "SELECT DISTINCT sc.id
807
+    mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 0 WHERE privateweb = 1");
808
+    $sql = "SELECT DISTINCT sc.id
810 809
              FROM `".$sqlParser->prefix."site_content` sc
811 810
              LEFT JOIN `".$sqlParser->prefix."document_groups` dg ON dg.document = sc.id
812 811
              LEFT JOIN `".$sqlParser->prefix."webgroup_access` wga ON wga.documentgroup = dg.document_group
813 812
              WHERE wga.id>0";
814
-    $ds = mysqli_query($sqlParser->conn,$sql);
815
-    if(!$ds) {
813
+    $ds = mysqli_query($sqlParser->conn, $sql);
814
+    if (!$ds) {
816 815
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
817 816
     }
818 817
     else {
819
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
820
-        if(count($ids)>0) {
821
-            mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")");
818
+        while ($r = mysqli_fetch_assoc($ds)) $ids[] = $r["id"];
819
+        if (count($ids) > 0) {
820
+            mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ", $ids).")");
822 821
             unset($ids);
823 822
         }
824 823
     }
825 824
 
826 825
     // secure manager documents privatemgr
827
-    mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 0 WHERE privatemgr = 1");
828
-    $sql =  "SELECT DISTINCT sc.id
826
+    mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 0 WHERE privatemgr = 1");
827
+    $sql = "SELECT DISTINCT sc.id
829 828
              FROM `".$sqlParser->prefix."site_content` sc
830 829
              LEFT JOIN `".$sqlParser->prefix."document_groups` dg ON dg.document = sc.id
831 830
              LEFT JOIN `".$sqlParser->prefix."membergroup_access` mga ON mga.documentgroup = dg.document_group
832 831
              WHERE mga.id>0";
833
-    $ds = mysqli_query($sqlParser->conn,$sql);
834
-    if(!$ds) {
832
+    $ds = mysqli_query($sqlParser->conn, $sql);
833
+    if (!$ds) {
835 834
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
836 835
     }
837 836
     else {
838
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
839
-        if(count($ids)>0) {
840
-            mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")");
837
+        while ($r = mysqli_fetch_assoc($ds)) $ids[] = $r["id"];
838
+        if (count($ids) > 0) {
839
+            mysqli_query($sqlParser->conn, "UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ", $ids).")");
841 840
             unset($ids);
842 841
         }
843 842
     }
844 843
 }
845 844
 
846
-function parse_docblock($element_dir, $filename) {
845
+function parse_docblock($element_dir, $filename){
847 846
     $params = array();
848
-    $fullpath = $element_dir . '/' . $filename;
849
-    if(is_readable($fullpath)) {
847
+    $fullpath = $element_dir.'/'.$filename;
848
+    if (is_readable($fullpath)) {
850 849
         $tpl = @fopen($fullpath, "r");
851
-        if($tpl) {
850
+        if ($tpl) {
852 851
             $params['filename'] = $filename;
853 852
             $docblock_start_found = false;
854 853
             $name_found = false;
855 854
             $description_found = false;
856 855
 
857
-            while(!feof($tpl)) {
856
+            while (!feof($tpl)) {
858 857
                 $line = fgets($tpl);
859
-                if(!$docblock_start_found) {
858
+                if (!$docblock_start_found) {
860 859
                     // find docblock start
861
-                    if(strpos($line, '/**') !== false) {
860
+                    if (strpos($line, '/**') !== false) {
862 861
                         $docblock_start_found = true;
863 862
                     }
864 863
                     continue;
865
-                } elseif(!$name_found) {
864
+                } elseif (!$name_found) {
866 865
                     // find name
867 866
                     $ma = null;
868
-                    if(preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
867
+                    if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
869 868
                         $params['name'] = trim($ma[1]);
870 869
                         $name_found = !empty($params['name']);
871 870
                     }
872 871
                     continue;
873
-                } elseif(!$description_found) {
872
+                } elseif (!$description_found) {
874 873
                     // find description
875 874
                     $ma = null;
876
-                    if(preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
875
+                    if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
877 876
                         $params['description'] = trim($ma[1]);
878 877
                         $description_found = !empty($params['description']);
879 878
                     }
880 879
                     continue;
881 880
                 } else {
882 881
                     $ma = null;
883
-                    if(preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) {
882
+                    if (preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) {
884 883
                         $param = trim($ma[1]);
885 884
                         $val = trim($ma[2]);
886
-                        if(!empty($param) && !empty($val)) {
887
-                            if($param == 'internal') {
885
+                        if (!empty($param) && !empty($val)) {
886
+                            if ($param == 'internal') {
888 887
                                 $ma = null;
889
-                                if(preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) {
888
+                                if (preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) {
890 889
                                     $param = trim($ma[1]);
891 890
                                     $val = trim($ma[2]);
892 891
                                 }
893 892
                                 //if($val !== '0' && (empty($param) || empty($val))) {
894
-                                if(empty($param)) {
893
+                                if (empty($param)) {
895 894
                                     continue;
896 895
                                 }
897 896
                             }
898 897
                             $params[$param] = $val;
899 898
                         }
900
-                    } elseif(preg_match("/^\s*\*\/\s*$/", $line)) {
899
+                    } elseif (preg_match("/^\s*\*\/\s*$/", $line)) {
901 900
                         break;
902 901
                     }
903 902
                 }
@@ -928,13 +927,13 @@  discard block
 block discarded – undo
928 927
     // display database results
929 928
     if ($sqlParser->installFailed == true) {
930 929
         $errors += 1;
931
-        echo $_lang['database_alerts'] . PHP_EOL;
932
-        echo $_lang['setup_couldnt_install'] . PHP_EOL;
933
-        echo $_lang['installation_error_occured'] . PHP_EOL;
930
+        echo $_lang['database_alerts'].PHP_EOL;
931
+        echo $_lang['setup_couldnt_install'].PHP_EOL;
932
+        echo $_lang['installation_error_occured'].PHP_EOL;
934 933
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
935
-            echo $sqlParser->mysqlErrors[$i]["error"] . " " . $_lang['during_execution_of_sql'] . " " . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . PHP_EOL;
934
+            echo $sqlParser->mysqlErrors[$i]["error"]." ".$_lang['during_execution_of_sql']." ".strip_tags($sqlParser->mysqlErrors[$i]["sql"]).PHP_EOL;
936 935
         }
937
-        echo $_lang['some_tables_not_updated'] . PHP_EOL;
936
+        echo $_lang['some_tables_not_updated'].PHP_EOL;
938 937
         die();
939 938
     } else {
940 939
         echo $_lang['ok'].PHP_EOL;
@@ -944,7 +943,7 @@  discard block
 block discarded – undo
944 943
 // custom or not
945 944
 if (file_exists($path."../assets/cache/siteManager.php")) {
946 945
     $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");';
947
-}else{
946
+} else {
948 947
     $mgrdir = 'define(\'MGR_DIR\', \'manager\');';
949 948
 }
950 949
 
@@ -981,16 +980,16 @@  discard block
 block discarded – undo
981 980
 $chmodSuccess = @chmod($filename, 0404);
982 981
 
983 982
 if ($configFileFailed == true) {
984
-    echo $_lang['failed'] . PHP_EOL;
983
+    echo $_lang['failed'].PHP_EOL;
985 984
     $errors += 1;
986 985
 
987
-    echo $_lang['cant_write_config_file'] . ' ' . MGR_DIR .'/includes/config.inc.php' .PHP_EOL;
986
+    echo $_lang['cant_write_config_file'].' '.MGR_DIR.'/includes/config.inc.php'.PHP_EOL;
988 987
     echo ' '.PHP_EOL;
989 988
     echo ' '.PHP_EOL;
990 989
     echo $configString;
991 990
     echo ' '.PHP_EOL;
992 991
     echo ' '.PHP_EOL;
993
-    echo $_lang['cant_write_config_file_note'] . PHP_EOL;
992
+    echo $_lang['cant_write_config_file_note'].PHP_EOL;
994 993
     die();
995 994
 
996 995
 } else {
@@ -1000,16 +999,16 @@  discard block
 block discarded – undo
1000 999
 // generate new site_id and set manager theme to default
1001 1000
 if ($installMode == 0) {
1002 1001
     $siteid = uniqid('');
1003
-    mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')");
1002
+    mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')");
1004 1003
 } else {
1005 1004
     // update site_id if missing
1006
-    $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'");
1005
+    $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`".$table_prefix."system_settings` WHERE setting_name='site_id'");
1007 1006
     if ($ds) {
1008 1007
         $r = mysqli_fetch_assoc($ds);
1009 1008
         $siteid = $r['setting_value'];
1010 1009
         if ($siteid == '' || $siteid = 'MzGeQ2faT4Dw06+U49x3') {
1011 1010
             $siteid = uniqid('');
1012
-            mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')");
1011
+            mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')");
1013 1012
         }
1014 1013
     }
1015 1014
 }
@@ -1021,29 +1020,29 @@  discard block
 block discarded – undo
1021 1020
     // display database results
1022 1021
     if ($sqlParser->installFailed == true) {
1023 1022
         $errors += 1;
1024
-        echo $_lang['database_alerts'] . PHP_EOL;
1025
-        echo $_lang['setup_couldnt_install'] . PHP_EOL;
1026
-        echo $_lang['installation_error_occured'] . PHP_EOL . PHP_EOL;
1023
+        echo $_lang['database_alerts'].PHP_EOL;
1024
+        echo $_lang['setup_couldnt_install'].PHP_EOL;
1025
+        echo $_lang['installation_error_occured'].PHP_EOL.PHP_EOL;
1027 1026
         /*
1028 1027
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
1029 1028
             echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />";
1030 1029
         }
1031 1030
         echo "</p>";*/
1032
-        echo $_lang['some_tables_not_updated'] . PHP_EOL;
1031
+        echo $_lang['some_tables_not_updated'].PHP_EOL;
1033 1032
         die();
1034 1033
     } else {
1035
-        echo $_lang['ok'] . PHP_EOL;
1034
+        echo $_lang['ok'].PHP_EOL;
1036 1035
     }
1037 1036
 }
1038 1037
 
1039 1038
 // Install Templates
1040 1039
 $moduleTemplate = $mt; 
1041 1040
 if (!empty($moduleTemplate) || $installData) {
1042
-    echo PHP_EOL . $_lang['templates'] . ":" . PHP_EOL;
1041
+    echo PHP_EOL.$_lang['templates'].":".PHP_EOL;
1043 1042
     //$selTemplates = $_POST['template'];
1044 1043
     foreach ($moduleTemplates as $k=>$moduleTemplate) {
1045 1044
         $installSample = in_array('sample', $moduleTemplate[6]) && $installData == 1;
1046
-        if($installSample || is_array($moduleTemplate)) {
1045
+        if ($installSample || is_array($moduleTemplate)) {
1047 1046
             $name = mysqli_real_escape_string($conn, $moduleTemplate[0]);
1048 1047
             $desc = mysqli_real_escape_string($conn, $moduleTemplate[1]);
1049 1048
             $category = mysqli_real_escape_string($conn, $moduleTemplate[4]);
@@ -1051,7 +1050,7 @@  discard block
 block discarded – undo
1051 1050
             $filecontent = $moduleTemplate[3];
1052 1051
             $save_sql_id_as = $moduleTemplate[7]; // Nessecary for demo-site
1053 1052
             if (!file_exists($filecontent)) {
1054
-                echo "  $name: " . $_lang['unable_install_template'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1053
+                echo "  $name: ".$_lang['unable_install_template']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1055 1054
             } else {
1056 1055
                 // Create the category if it does not already exist
1057 1056
                 $category_id = getCreateDbCategory($category, $sqlParser);
@@ -1061,31 +1060,31 @@  discard block
 block discarded – undo
1061 1060
                 $template = mysqli_real_escape_string($conn, $template);
1062 1061
 
1063 1062
                 // See if the template already exists
1064
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'");
1063
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name'");
1065 1064
 
1066 1065
                 if (mysqli_num_rows($rs)) {
1067
-                    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;")) {
1066
+                    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;")) {
1068 1067
                         $errors += 1;
1069
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1068
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1070 1069
                         return;
1071 1070
                     }
1072
-                    if(!is_null($save_sql_id_as)) {
1071
+                    if (!is_null($save_sql_id_as)) {
1073 1072
                         $sql_id = @mysqli_insert_id($sqlParser->conn);
1074
-                        if(!$sql_id) {
1075
-                            $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name' LIMIT 1;"));
1073
+                        if (!$sql_id) {
1074
+                            $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name' LIMIT 1;"));
1076 1075
                             $sql_id = $idQuery['id'];
1077 1076
                         }
1078 1077
                         $custom_placeholders[$save_sql_id_as] = $sql_id;
1079 1078
                     }
1080
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1079
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1081 1080
                 } else {
1082
-                    if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) {
1081
+                    if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) {
1083 1082
                         $errors += 1;
1084
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1083
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1085 1084
                         die();
1086 1085
                     }
1087
-                    if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1088
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1086
+                    if (!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1087
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1089 1088
                 }
1090 1089
             }
1091 1090
         }
@@ -1095,11 +1094,11 @@  discard block
 block discarded – undo
1095 1094
 // Install Template Variables
1096 1095
 $moduleTVs = $mtv;
1097 1096
 if (is_array($moduleTVs) || $installData) {
1098
-    echo PHP_EOL . $_lang['tvs'].': '.PHP_EOL;
1097
+    echo PHP_EOL.$_lang['tvs'].': '.PHP_EOL;
1099 1098
     //$selTVs = $_POST['tv'];
1100 1099
     foreach ($moduleTVs as $k=>$moduleTV) {
1101 1100
         $installSample = in_array('sample', $moduleTV[12]) && $installData == 1;
1102
-        if($installSample || is_array($moduleTVs)) {
1101
+        if ($installSample || is_array($moduleTVs)) {
1103 1102
             $name = mysqli_real_escape_string($conn, $moduleTV[0]);
1104 1103
             $caption = mysqli_real_escape_string($conn, $moduleTV[1]);
1105 1104
             $desc = mysqli_real_escape_string($conn, $moduleTV[2]);
@@ -1117,24 +1116,24 @@  discard block
 block discarded – undo
1117 1116
             // Create the category if it does not already exist
1118 1117
             $category = getCreateDbCategory($category, $sqlParser);
1119 1118
 
1120
-            $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name'");
1119
+            $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name'");
1121 1120
             if (mysqli_num_rows($rs)) {
1122 1121
                 $insert = true;
1123
-                while($row = mysqli_fetch_assoc($rs)) {
1124
-                    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']};")) {
1125
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1122
+                while ($row = mysqli_fetch_assoc($rs)) {
1123
+                    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']};")) {
1124
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1126 1125
                         return;
1127 1126
                     }
1128 1127
                     $insert = false;
1129 1128
                 }
1130
-                echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1129
+                echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1131 1130
             } else {
1132
-                $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');";
1131
+                $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');";
1133 1132
                 if (!mysqli_query($sqlParser->conn, $q)) {
1134
-                    echo mysqli_error($sqlParser->conn) . PHP_EOL;
1133
+                    echo mysqli_error($sqlParser->conn).PHP_EOL;
1135 1134
                     return;
1136 1135
                 }
1137
-                echo "  $name: " . $_lang['installed'] . PHP_EOL;
1136
+                echo "  $name: ".$_lang['installed'].PHP_EOL;
1138 1137
             }
1139 1138
 
1140 1139
             // add template assignments
@@ -1143,10 +1142,10 @@  discard block
 block discarded – undo
1143 1142
             if (count($assignments) > 0) {
1144 1143
 
1145 1144
                 // remove existing tv -> template assignments
1146
-                $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';");
1145
+                $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';");
1147 1146
                 $row = mysqli_fetch_assoc($ds);
1148 1147
                 $id = $row["id"];
1149
-                mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\'');
1148
+                mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_tmplvar_templates` WHERE tmplvarid = \''.$id.'\'');
1150 1149
 
1151 1150
                 // add tv -> template assignments
1152 1151
                 foreach ($assignments as $assignment) {
@@ -1155,7 +1154,7 @@  discard block
 block discarded – undo
1155 1154
                     if ($ds && $ts) {
1156 1155
                         $tRow = mysqli_fetch_assoc($ts);
1157 1156
                         $templateId = $tRow['id'];
1158
-                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
1157
+                        mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)");
1159 1158
                    }
1160 1159
                 }
1161 1160
             }
@@ -1166,12 +1165,12 @@  discard block
 block discarded – undo
1166 1165
 
1167 1166
 $moduleChunks = $mc;
1168 1167
 // Install Chunks
1169
-if (is_array ($moduleChunks) || $installData) {
1170
-    echo PHP_EOL . $_lang['chunks'] . ": " . PHP_EOL;
1168
+if (is_array($moduleChunks) || $installData) {
1169
+    echo PHP_EOL.$_lang['chunks'].": ".PHP_EOL;
1171 1170
     foreach ($moduleChunks as $k=>$moduleChunk) {
1172 1171
         $installSample = in_array('sample', $moduleChunk[5]) && $installData == 1;
1173 1172
         $count_new_name = 0;
1174
-        if($installSample || is_array ($moduleChunks)) {
1173
+        if ($installSample || is_array($moduleChunks)) {
1175 1174
 
1176 1175
             $name = mysqli_real_escape_string($conn, $moduleChunk[0]);
1177 1176
             $desc = mysqli_real_escape_string($conn, $moduleChunk[1]);
@@ -1180,7 +1179,7 @@  discard block
 block discarded – undo
1180 1179
             $filecontent = $moduleChunk[2];
1181 1180
 
1182 1181
             if (!file_exists($filecontent))
1183
-                echo "  $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1182
+                echo "  $name: ".$_lang['unable_install_chunk']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1184 1183
             else {
1185 1184
 
1186 1185
                 // Create the category if it does not already exist
@@ -1188,31 +1187,31 @@  discard block
 block discarded – undo
1188 1187
 
1189 1188
                 $chunk = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1);
1190 1189
                 $chunk = mysqli_real_escape_string($conn, $chunk);
1191
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$name'");
1190
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$name'");
1192 1191
                 $count_original_name = mysqli_num_rows($rs);
1193
-                if($overwrite == 'false') {
1194
-                    $newname = $name . '-' . str_replace('.', '_', $modx_version);
1195
-                    $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$newname'");
1192
+                if ($overwrite == 'false') {
1193
+                    $newname = $name.'-'.str_replace('.', '_', $modx_version);
1194
+                    $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$newname'");
1196 1195
                     $count_new_name = mysqli_num_rows($rs);
1197 1196
                 }
1198 1197
                 $update = $count_original_name > 0 && $overwrite == 'true';
1199 1198
                 if ($update) {
1200
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) {
1199
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) {
1201 1200
                         $errors += 1;
1202
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1201
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1203 1202
                         return;
1204 1203
                     }
1205
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1206
-                } elseif($count_new_name == 0) {
1207
-                    if($count_original_name > 0 && $overwrite == 'false') {
1204
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1205
+                } elseif ($count_new_name == 0) {
1206
+                    if ($count_original_name > 0 && $overwrite == 'false') {
1208 1207
                         $name = $newname;
1209 1208
                     }
1210
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) {
1209
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) {
1211 1210
                         $errors += 1;
1212
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1211
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1213 1212
                         return;
1214 1213
                     }
1215
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1214
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1216 1215
                 }
1217 1216
             }
1218 1217
         }
@@ -1222,11 +1221,11 @@  discard block
 block discarded – undo
1222 1221
 // Install Modules
1223 1222
 $moduleModules = $mm;
1224 1223
 if (is_array($moduleModules) || $installData) {
1225
-    echo PHP_EOL . $_lang['modules'] . ":" . PHP_EOL;
1224
+    echo PHP_EOL.$_lang['modules'].":".PHP_EOL;
1226 1225
     //$selModules = $_POST['module'];
1227 1226
     foreach ($moduleModules as $k=>$moduleModule) {
1228 1227
         $installSample = in_array('sample', $moduleModule[7]) && $installData == 1;
1229
-        if($installSample || is_array($moduleModules)) {
1228
+        if ($installSample || is_array($moduleModules)) {
1230 1229
             $name = mysqli_real_escape_string($conn, $moduleModule[0]);
1231 1230
             $desc = mysqli_real_escape_string($conn, $moduleModule[1]);
1232 1231
             $filecontent = $moduleModule[2];
@@ -1235,7 +1234,7 @@  discard block
 block discarded – undo
1235 1234
             $shared = mysqli_real_escape_string($conn, $moduleModule[5]);
1236 1235
             $category = mysqli_real_escape_string($conn, $moduleModule[6]);
1237 1236
             if (!file_exists($filecontent))
1238
-                echo "  $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1237
+                echo "  $name: ".$_lang['unable_install_module']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1239 1238
             else {
1240 1239
 
1241 1240
                 // Create the category if it does not already exist
@@ -1244,24 +1243,24 @@  discard block
 block discarded – undo
1244 1243
                 $module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2));
1245 1244
                 // $module = removeDocblock($module, 'module'); // Modules have no fileBinding, keep docblock for info-tab
1246 1245
                 $module = mysqli_real_escape_string($conn, $module);
1247
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_modules` WHERE name='$name'");
1246
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_modules` WHERE name='$name'");
1248 1247
                 if (mysqli_num_rows($rs)) {
1249 1248
                     $row = mysqli_fetch_assoc($rs);
1250
-                    $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1251
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
1252
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1249
+                    $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
1250
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) {
1251
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1253 1252
                         return;
1254 1253
                     }
1255
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1254
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1256 1255
                 } else {
1257
-                    if ($properties != NULL ){
1256
+                    if ($properties != NULL) {
1258 1257
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1259 1258
                     }
1260
-                    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);")) {
1261
-                        echo "<p>" . mysqli_error($sqlParser->conn) . "</p>";
1259
+                    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);")) {
1260
+                        echo "<p>".mysqli_error($sqlParser->conn)."</p>";
1262 1261
                         return;
1263 1262
                     }
1264
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1263
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1265 1264
                 }
1266 1265
             }
1267 1266
         }
@@ -1271,11 +1270,11 @@  discard block
 block discarded – undo
1271 1270
 // Install Plugins
1272 1271
 $modulePlugins = $mp;
1273 1272
 if (is_array($modulePlugins) || $installData) {
1274
-    echo PHP_EOL . $_lang['plugins'] . ":" . PHP_EOL;
1273
+    echo PHP_EOL.$_lang['plugins'].":".PHP_EOL;
1275 1274
     $selPlugs = $_POST['plugin'];
1276 1275
     foreach ($modulePlugins as $k=>$modulePlugin) {
1277 1276
         //$installSample = in_array('sample', $modulePlugin[8]) && $installData == 1;
1278
-        if($installSample || is_array($modulePlugins)) {
1277
+        if ($installSample || is_array($modulePlugins)) {
1279 1278
             $name = mysqli_real_escape_string($conn, $modulePlugin[0]);
1280 1279
             $desc = mysqli_real_escape_string($conn, $modulePlugin[1]);
1281 1280
             $filecontent = $modulePlugin[2];
@@ -1285,17 +1284,17 @@  discard block
 block discarded – undo
1285 1284
             $category = mysqli_real_escape_string($conn, $modulePlugin[6]);
1286 1285
             $leg_names = '';
1287 1286
             $disabled = $modulePlugin[9];
1288
-            if(array_key_exists(7, $modulePlugin)) {
1287
+            if (array_key_exists(7, $modulePlugin)) {
1289 1288
                 // parse comma-separated legacy names and prepare them for sql IN clause
1290
-                $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'";
1289
+                $leg_names = "'".implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7])))."'";
1291 1290
             }
1292 1291
             if (!file_exists($filecontent))
1293
-                echo "  $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1292
+                echo "  $name: ".$_lang['unable_install_plugin']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1294 1293
             else {
1295 1294
 
1296 1295
                 // disable legacy versions based on legacy_names provided
1297
-                if(!empty($leg_names)) {
1298
-                    $update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);";
1296
+                if (!empty($leg_names)) {
1297
+                    $update_query = "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE name IN ($leg_names);";
1299 1298
                     $rs = mysqli_query($sqlParser->conn, $update_query);
1300 1299
                 }
1301 1300
 
@@ -1305,52 +1304,52 @@  discard block
 block discarded – undo
1305 1304
                 $plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2));
1306 1305
                 $plugin = removeDocblock($plugin, 'plugin');
1307 1306
                 $plugin = mysqli_real_escape_string($conn, $plugin);
1308
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name'");
1307
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name'");
1309 1308
                 if (mysqli_num_rows($rs)) {
1310 1309
                     $insert = true;
1311
-                    while($row = mysqli_fetch_assoc($rs)) {
1312
-                        $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1313
-                        if($row['description'] == $desc){
1314
-                            if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
1315
-                                echo mysqli_error($sqlParser->conn) . PHP_EOL;
1310
+                    while ($row = mysqli_fetch_assoc($rs)) {
1311
+                        $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
1312
+                        if ($row['description'] == $desc) {
1313
+                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
1314
+                                echo mysqli_error($sqlParser->conn).PHP_EOL;
1316 1315
                                 return;
1317 1316
                             }
1318 1317
                             $insert = false;
1319 1318
                         } else {
1320
-                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) {
1319
+                            if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE id={$row['id']};")) {
1321 1320
                                 echo mysqli_error($sqlParser->conn).PHP_EOL;
1322 1321
                                 return;
1323 1322
                             }
1324 1323
                         }
1325 1324
                     }
1326
-                    if($insert === true) {
1327
-                        $properties = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1328
-                        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);")) {
1325
+                    if ($insert === true) {
1326
+                        $properties = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
1327
+                        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);")) {
1329 1328
                             echo mysqli_error($sqlParser->conn).PHP_EOL;
1330 1329
                             return;
1331 1330
                         }
1332 1331
                     }
1333
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1332
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1334 1333
                 } else {
1335
-                    if ($properties != NULL ){
1334
+                    if ($properties != NULL) {
1336 1335
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1337 1336
                     }
1338
-                    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);")) {
1339
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1337
+                    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);")) {
1338
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1340 1339
                         return;
1341 1340
                     }
1342
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1341
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1343 1342
                 }
1344 1343
                 // add system events
1345 1344
                 if (count($events) > 0) {
1346
-                    $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';");
1345
+                    $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';");
1347 1346
                     if ($ds) {
1348 1347
                         $row = mysqli_fetch_assoc($ds);
1349 1348
                         $id = $row["id"];
1350 1349
                         // remove existing events
1351
-                        mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_plugin_events` WHERE pluginid = \'' . $id . '\'');
1350
+                        mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_plugin_events` WHERE pluginid = \''.$id.'\'');
1352 1351
                         // add new events
1353
-                        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) . "')");
1352
+                        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)."')");
1354 1353
                     }
1355 1354
                 }
1356 1355
             }
@@ -1361,18 +1360,18 @@  discard block
 block discarded – undo
1361 1360
 // Install Snippets
1362 1361
 $moduleSnippet = $ms;
1363 1362
 if (is_array($moduleSnippet) || $installData) {
1364
-    echo PHP_EOL . $_lang['snippets'] . ":" . PHP_EOL;
1363
+    echo PHP_EOL.$_lang['snippets'].":".PHP_EOL;
1365 1364
     //$selSnips = $_POST['snippet'];
1366 1365
     foreach ($moduleSnippets as $k=>$moduleSnippet) {
1367 1366
         $installSample = in_array('sample', $moduleSnippet[5]) && $installData == 1;
1368
-        if($installSample || is_array($moduleSnippet)) {
1367
+        if ($installSample || is_array($moduleSnippet)) {
1369 1368
             $name = mysqli_real_escape_string($conn, $moduleSnippet[0]);
1370 1369
             $desc = mysqli_real_escape_string($conn, $moduleSnippet[1]);
1371 1370
             $filecontent = $moduleSnippet[2];
1372 1371
             $properties = $moduleSnippet[3];
1373 1372
             $category = mysqli_real_escape_string($conn, $moduleSnippet[4]);
1374 1373
             if (!file_exists($filecontent))
1375
-                echo "  $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1374
+                echo "  $name: ".$_lang['unable_install_snippet']." '$filecontent' ".$_lang['not_found'].PHP_EOL;
1376 1375
             else {
1377 1376
 
1378 1377
                 // Create the category if it does not already exist
@@ -1381,24 +1380,24 @@  discard block
 block discarded – undo
1381 1380
                 $snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent)));
1382 1381
                 $snippet = removeDocblock($snippet, 'snippet');
1383 1382
                 $snippet = mysqli_real_escape_string($conn, $snippet);
1384
-                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_snippets` WHERE name='$name'");
1383
+                $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_snippets` WHERE name='$name'");
1385 1384
                 if (mysqli_num_rows($rs)) {
1386 1385
                     $row = mysqli_fetch_assoc($rs);
1387
-                    $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1388
-                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) {
1389
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1386
+                    $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties']));
1387
+                    if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) {
1388
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1390 1389
                         return;
1391 1390
                     }
1392
-                    echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1391
+                    echo "  $name: ".$_lang['upgraded'].PHP_EOL;
1393 1392
                 } else {
1394
-                    if ($properties != NULL ){
1393
+                    if ($properties != NULL) {
1395 1394
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1396 1395
                     }
1397
-                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
1398
-                        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1396
+                    if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
1397
+                        echo mysqli_error($sqlParser->conn).PHP_EOL;
1399 1398
                         return;
1400 1399
                     }
1401
-                    echo "  $name: " . $_lang['installed'] . PHP_EOL;
1400
+                    echo "  $name: ".$_lang['installed'].PHP_EOL;
1402 1401
                 }
1403 1402
             }
1404 1403
         }
@@ -1407,24 +1406,24 @@  discard block
 block discarded – undo
1407 1406
 
1408 1407
 // Install demo-site
1409 1408
 if ($installData && $moduleSQLDataFile) {
1410
-    echo PHP_EOL . $_lang['installing_demo_site'];
1409
+    echo PHP_EOL.$_lang['installing_demo_site'];
1411 1410
     $sqlParser->process($moduleSQLDataFile);
1412 1411
     // display database results
1413 1412
     if ($sqlParser->installFailed == true) {
1414 1413
         $errors += 1;
1415
-        echo $_lang['database_alerts'] . PHP_EOL;
1416
-        echo $_lang['setup_couldnt_install'] . PHP_EOL;
1417
-        echo $_lang['installation_error_occured'] . PHP_EOL . PHP_EOL;
1414
+        echo $_lang['database_alerts'].PHP_EOL;
1415
+        echo $_lang['setup_couldnt_install'].PHP_EOL;
1416
+        echo $_lang['installation_error_occured'].PHP_EOL.PHP_EOL;
1418 1417
         for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) {
1419
-            echo $sqlParser->mysqlErrors[$i]["error"] . " " . $_lang['during_execution_of_sql'] . " " . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . PHP_EOL;
1418
+            echo $sqlParser->mysqlErrors[$i]["error"]." ".$_lang['during_execution_of_sql']." ".strip_tags($sqlParser->mysqlErrors[$i]["sql"]).PHP_EOL;
1420 1419
         }
1421 1420
 
1422
-        echo $_lang['some_tables_not_updated'] . PHP_EOL;
1421
+        echo $_lang['some_tables_not_updated'].PHP_EOL;
1423 1422
         return;
1424 1423
     } else {
1425 1424
         $sql = sprintf("SELECT id FROM `%ssite_templates` WHERE templatename='EVO startup - Bootstrap'", $sqlParser->prefix);
1426 1425
         $rs = mysqli_query($sqlParser->conn, $sql);
1427
-        if(mysqli_num_rows($rs)) {
1426
+        if (mysqli_num_rows($rs)) {
1428 1427
             $row = mysqli_fetch_assoc($rs);
1429 1428
             $sql = sprintf('UPDATE `%ssite_content` SET template=%s WHERE template=4', $sqlParser->prefix, $row['id']);
1430 1429
             mysqli_query($sqlParser->conn, $sql);
@@ -1436,9 +1435,9 @@  discard block
 block discarded – undo
1436 1435
 // Install Dependencies
1437 1436
 $moduleDependencies = $mdp;
1438 1437
 foreach ($moduleDependencies as $dependency) {
1439
-    $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"');
1438
+    $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM '.$dbase.'`'.$sqlParser->prefix.'site_modules` WHERE name="'.$dependency['module'].'"');
1440 1439
     if (!$ds) {
1441
-        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1440
+        echo mysqli_error($sqlParser->conn).PHP_EOL;
1442 1441
         return;
1443 1442
     } else {
1444 1443
         $row = mysqli_fetch_assoc($ds);
@@ -1446,37 +1445,37 @@  discard block
 block discarded – undo
1446 1445
         $moduleGuid = $row["guid"];
1447 1446
     }
1448 1447
     // get extra id
1449
-    $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"');
1448
+    $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE '.$dependency['column'].'="'.$dependency['name'].'"');
1450 1449
     if (!$ds) {
1451
-        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1450
+        echo mysqli_error($sqlParser->conn).PHP_EOL;
1452 1451
         return;
1453 1452
     } else {
1454 1453
         $row = mysqli_fetch_assoc($ds);
1455 1454
         $extraId = $row["id"];
1456 1455
     }
1457 1456
     // setup extra as module dependency
1458
-    $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');
1457
+    $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');
1459 1458
     if (!$ds) {
1460
-        echo mysqli_error($sqlParser->conn) . PHP_EOL;
1459
+        echo mysqli_error($sqlParser->conn).PHP_EOL;
1461 1460
         return;
1462 1461
     } else {
1463 1462
         if (mysqli_num_rows($ds) === 0) {
1464
-            mysqli_query($sqlParser->conn, 'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')');
1465
-            echo $dependency['module'] . ' Module: ' . $_lang['depedency_create'] . PHP_EOL;
1463
+            mysqli_query($sqlParser->conn, 'INSERT INTO '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` (module, resource, type) VALUES('.$moduleId.','.$extraId.','.$dependency['type'].')');
1464
+            echo $dependency['module'].' Module: '.$_lang['depedency_create'].PHP_EOL;
1466 1465
         } else {
1467
-            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']);
1468
-            echo $dependency['module'] . ' Module: ' . $_lang['depedency_update'] . PHP_EOL;
1466
+            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']);
1467
+            echo $dependency['module'].' Module: '.$_lang['depedency_update'].PHP_EOL;
1469 1468
         }
1470 1469
         if ($dependency['type'] == 30 || $dependency['type'] == 40) {
1471 1470
             // set extra guid for plugins and snippets
1472
-            $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1');
1471
+            $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE id='.$extraId.' LIMIT 1');
1473 1472
             if (!$ds) {
1474
-                echo mysqli_error($sqlParser->conn) . PHP_EOL;
1473
+                echo mysqli_error($sqlParser->conn).PHP_EOL;
1475 1474
                 return;
1476 1475
             } else {
1477 1476
                 if (mysqli_num_rows($ds) != 0) {
1478
-                    mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId);
1479
-                    echo $dependency['name'] . ': ' . $_lang['guid_set'] . PHP_EOL;
1477
+                    mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` SET moduleguid = '.$moduleGuid.' WHERE id='.$extraId);
1478
+                    echo $dependency['name'].': '.$_lang['guid_set'].PHP_EOL;
1480 1479
                 }
1481 1480
             }
1482 1481
         }
@@ -1485,7 +1484,7 @@  discard block
 block discarded – undo
1485 1484
 
1486 1485
 // call back function
1487 1486
 if ($callBackFnc != "")
1488
-    $callBackFnc ($sqlParser);
1487
+    $callBackFnc($sqlParser);
1489 1488
 
1490 1489
 // Setup the MODX API -- needed for the cache processor
1491 1490
 if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
@@ -1518,22 +1517,22 @@  discard block
 block discarded – undo
1518 1517
 }
1519 1518
 
1520 1519
 // setup completed!
1521
-echo PHP_EOL . $_lang['installation_successful'] . PHP_EOL . PHP_EOL;
1520
+echo PHP_EOL.$_lang['installation_successful'].PHP_EOL.PHP_EOL;
1522 1521
 //echo "<p>" . $_lang['to_log_into_content_manager'] . "</p>";
1523 1522
 if ($installMode == 0) {
1524
-   echo strip_tags($_lang['installation_note']) . PHP_EOL;
1523
+   echo strip_tags($_lang['installation_note']).PHP_EOL;
1525 1524
 } else {
1526
-   echo strip_tags($_lang['upgrade_note']) . PHP_EOL;
1525
+   echo strip_tags($_lang['upgrade_note']).PHP_EOL;
1527 1526
 }
1528 1527
 
1529 1528
 
1530
-if ( empty($args) ){
1531
-    echo PHP_EOL . 'Remove install folder?'.PHP_EOL;
1529
+if (empty($args)) {
1530
+    echo PHP_EOL.'Remove install folder?'.PHP_EOL;
1532 1531
     $removeInstall = readline("Type 'y' or 'n' to continue: ");
1533 1532
 }
1534 1533
 //remove installFolder
1535 1534
 if ($removeInstall == 'y') {
1536
-    echo 'Install folder deleted!'. PHP_EOL . PHP_EOL;
1535
+    echo 'Install folder deleted!'.PHP_EOL.PHP_EOL;
1537 1536
 }
1538 1537
 
1539 1538
 /**
@@ -1543,11 +1542,11 @@  discard block
 block discarded – undo
1543 1542
  * @param string $old
1544 1543
  * @return string
1545 1544
  */
1546
-function propUpdate($new,$old){
1545
+function propUpdate($new, $old){
1547 1546
     $newArr = parseProperties($new);
1548 1547
     $oldArr = parseProperties($old);
1549
-    foreach ($oldArr as $k => $v){
1550
-        if (isset($v['0']['options'])){
1548
+    foreach ($oldArr as $k => $v) {
1549
+        if (isset($v['0']['options'])) {
1551 1550
             $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options'];
1552 1551
         }
1553 1552
     }
@@ -1562,30 +1561,30 @@  discard block
 block discarded – undo
1562 1561
  * @param bool|mixed $json
1563 1562
  * @return string
1564 1563
  */
1565
-function parseProperties($propertyString, $json=false) {
1566
-    $propertyString = str_replace('{}', '', $propertyString );
1567
-    $propertyString = str_replace('} {', ',', $propertyString );
1564
+function parseProperties($propertyString, $json = false){
1565
+    $propertyString = str_replace('{}', '', $propertyString);
1566
+    $propertyString = str_replace('} {', ',', $propertyString);
1568 1567
 
1569
-    if(empty($propertyString)) return array();
1570
-    if($propertyString=='{}' || $propertyString=='[]') return array();
1568
+    if (empty($propertyString)) return array();
1569
+    if ($propertyString == '{}' || $propertyString == '[]') return array();
1571 1570
 
1572 1571
     $jsonFormat = isJson($propertyString, true);
1573 1572
     $property = array();
1574 1573
     // old format
1575
-    if ( $jsonFormat === false) {
1576
-        $props= explode('&', $propertyString);
1574
+    if ($jsonFormat === false) {
1575
+        $props = explode('&', $propertyString);
1577 1576
         foreach ($props as $prop) {
1578 1577
             $prop = trim($prop);
1579
-            if($prop === '') {
1578
+            if ($prop === '') {
1580 1579
                 continue;
1581 1580
             }
1582 1581
 
1583 1582
             $arr = explode(';', $prop);
1584
-            if( ! is_array($arr)) {
1583
+            if (!is_array($arr)) {
1585 1584
                 $arr = array();
1586 1585
             }
1587 1586
             $key = explode('=', isset($arr[0]) ? $arr[0] : '');
1588
-            if( ! is_array($key) || empty($key[0])) {
1587
+            if (!is_array($key) || empty($key[0])) {
1589 1588
                 continue;
1590 1589
             }
1591 1590
 
@@ -1609,7 +1608,7 @@  discard block
 block discarded – undo
1609 1608
 
1610 1609
         }
1611 1610
     // new json-format
1612
-    } else if(!empty($jsonFormat)){
1611
+    } else if (!empty($jsonFormat)) {
1613 1612
         $property = $jsonFormat;
1614 1613
     }
1615 1614
     if ($json) {
@@ -1624,7 +1623,7 @@  discard block
 block discarded – undo
1624 1623
  * @param bool $returnData
1625 1624
  * @return bool|mixed
1626 1625
  */
1627
-function isJson($string, $returnData=false) {
1626
+function isJson($string, $returnData = false){
1628 1627
     $data = json_decode($string, true);
1629 1628
     return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false;
1630 1629
 }
@@ -1634,20 +1633,20 @@  discard block
 block discarded – undo
1634 1633
  * @param SqlParser $sqlParser
1635 1634
  * @return int
1636 1635
  */
1637
-function getCreateDbCategory($category, $sqlParser) {
1636
+function getCreateDbCategory($category, $sqlParser){
1638 1637
     $dbase = $sqlParser->dbname;
1639
-    $dbase = '`' . trim($dbase,'`') . '`';
1638
+    $dbase = '`'.trim($dbase, '`').'`';
1640 1639
     $table_prefix = $sqlParser->prefix;
1641 1640
     $category_id = 0;
1642
-    if(!empty($category)) {
1641
+    if (!empty($category)) {
1643 1642
         $category = mysqli_real_escape_string($sqlParser->conn, $category);
1644 1643
         $rs = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."categories` WHERE category = '".$category."'");
1645
-        if(mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) {
1644
+        if (mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) {
1646 1645
             $category_id = $row['id'];
1647 1646
         } else {
1648 1647
             $q = "INSERT INTO $dbase.`".$table_prefix."categories` (`category`) VALUES ('{$category}');";
1649 1648
             $rs = mysqli_query($sqlParser->conn, $q);
1650
-            if($rs) {
1649
+            if ($rs) {
1651 1650
                 $category_id = mysqli_insert_id($sqlParser->conn);
1652 1651
             }
1653 1652
         }
@@ -1662,12 +1661,12 @@  discard block
 block discarded – undo
1662 1661
  * @param string $type
1663 1662
  * @return string
1664 1663
  */
1665
-function removeDocblock($code, $type) {
1664
+function removeDocblock($code, $type){
1666 1665
 
1667 1666
     $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
1668 1667
 
1669 1668
     // Procedure taken from plugin.filesource.php
1670
-    switch($type) {
1669
+    switch ($type) {
1671 1670
         case 'snippet':
1672 1671
             $elm_name = 'snippets';
1673 1672
             $include = 'return require';
@@ -1683,7 +1682,7 @@  discard block
 block discarded – undo
1683 1682
         default:
1684 1683
             return $cleaned;
1685 1684
     };
1686
-    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
1685
+    if (substr(trim($cleaned), 0, $count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
1687 1686
         return $cleaned;
1688 1687
 
1689 1688
     // fileBinding not found - return code incl docblock
Please login to merge, or discard this patch.
Braces   +98 added lines, -66 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
 $args = array_slice($argv, 1);
59 59
 
60
-if ( empty($args) ){
60
+if ( empty($args) ) {
61 61
     echo 'Install Evolution CMS'.PHP_EOL;
62 62
     //$installYes = readline("Type 'y' to continue: ");
63 63
     //if ($installYes != 'y') return;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     $managerlanguage = readline('Мanager language:' . ' [en] ');
77 77
     $installData = readline('Instal demo-site (y/n):' . ' [n] ');
78 78
     
79
-}else{
79
+} else {
80 80
     
81 81
     $cli_variables = [];
82 82
     foreach ($args as $arg) {
@@ -130,21 +130,24 @@  discard block
 block discarded – undo
130 130
 }
131 131
 
132 132
 //////////////////////////////////////////////////////////////////////////////////////
133
-if( ! function_exists('f_owc')){
133
+if( ! function_exists('f_owc')) {
134 134
     /**
135 135
      * @param $path
136 136
      * @param $data
137 137
      * @param null|int $mode
138 138
      */
139
-    function f_owc($path, $data, $mode = null){
139
+    function f_owc($path, $data, $mode = null)
140
+    {
140 141
         try {
141 142
             // make an attempt to create the file
142 143
             $hnd = fopen($path, 'w');
143 144
             fwrite($hnd, $data);
144 145
             fclose($hnd);
145 146
 
146
-            if(null !== $mode) chmod($path, $mode);
147
-        }catch(Exception $e){
147
+            if(null !== $mode) {
148
+                chmod($path, $mode);
149
+            }
150
+        } catch(Exception $e) {
148 151
             // Nothing, this is NOT normal
149 152
             unset($e);
150 153
         }
@@ -210,7 +213,7 @@  discard block
 block discarded – undo
210 213
 
211 214
 // File Browser directories exists?
212 215
 echo strip_tags($_lang['checking_if_images_exist']);
213
-switch(true){
216
+switch(true) {
214 217
     case !file_exists($path."../assets/images"):
215 218
     case !file_exists($path."../assets/files"):
216 219
     case !file_exists($path."../assets/backup"):
@@ -225,7 +228,7 @@  discard block
 block discarded – undo
225 228
 
226 229
 // File Browser directories writable?
227 230
 echo strip_tags($_lang['checking_if_images_writable']);
228
-switch(true){
231
+switch(true) {
229 232
     case !is_writable($path."../assets/images"):
230 233
     case !is_writable($path."../assets/files"):
231 234
     case !is_writable($path."../assets/backup"):
@@ -361,7 +364,7 @@  discard block
 block discarded – undo
361 364
 if ($conn) {
362 365
     echo $_lang['checking_mysql_strict_mode'];
363 366
     $mysqlmode = mysqli_query($conn, "SELECT @@global.sql_mode");
364
-    if (mysqli_num_rows($mysqlmode) > 0){
367
+    if (mysqli_num_rows($mysqlmode) > 0) {
365 368
         $modes = mysqli_fetch_array($mysqlmode, MYSQLI_NUM);
366 369
         //$modes = array("STRICT_TRANS_TABLES"); // for testing
367 370
         // print_r($modes);
@@ -397,9 +400,9 @@  discard block
 block discarded – undo
397 400
 if ($errors > 0) {
398 401
     echo $_lang['setup_cannot_continue'] . ' ';
399 402
 
400
-    if($errors > 1){
403
+    if($errors > 1) {
401 404
         echo $errors . " " . $_lang['errors'] . $_lang['please_correct_errors'] . $_lang['and_try_again_plural'];
402
-    }else{
405
+    } else {
403 406
         echo $_lang['error'] . $_lang['please_correct_error'] . $_lang['and_try_again']. PHP_EOL;
404 407
     }
405 408
 
@@ -445,13 +448,15 @@  discard block
 block discarded – undo
445 448
 
446 449
 // get base path and url
447 450
 $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"])));
448
-if (count($a) > 1)
451
+if (count($a) > 1) {
449 452
     array_pop($a);
453
+}
450 454
 $url = implode("install", $a);
451 455
 reset($a);
452 456
 $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__))));
453
-if (count($a) > 1)
457
+if (count($a) > 1) {
454 458
     array_pop($a);
459
+}
455 460
 $pth = implode("install", $a);
456 461
 unset ($a);
457 462
 $base_url = $url . (substr($url, -1) != "/" ? "/" : "");
@@ -472,7 +477,9 @@  discard block
 block discarded – undo
472 477
     echo $_lang['setup_database_selection_failed']." ".$_lang['setup_database_selection_failed_note'].PHP_EOL;
473 478
     $create = true;
474 479
 } else {
475
-    if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset);
480
+    if (function_exists('mysqli_set_charset')) {
481
+        mysqli_set_charset($conn, $database_charset);
482
+    }
476 483
     mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}");
477 484
     echo $_lang['ok'].PHP_EOL;
478 485
 }
@@ -518,7 +525,8 @@  discard block
 block discarded – undo
518 525
      * @param string $propertyString
519 526
      * @return array
520 527
      */
521
-    function parseProperties($propertyString) {
528
+    function parseProperties($propertyString)
529
+    {
522 530
         $parameter= array ();
523 531
         if (!empty ($propertyString)) {
524 532
             $tmpParams= explode("&", $propertyString);
@@ -527,11 +535,14 @@  discard block
 block discarded – undo
527 535
                 if (strpos($tmpParams[$x], '=', 0)) {
528 536
                     $pTmp= explode("=", $tmpParams[$x]);
529 537
                     $pvTmp= explode(";", trim($pTmp[1]));
530
-                    if ($pvTmp[1] == 'list' && $pvTmp[3] != "")
531
-                        $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default
538
+                    if ($pvTmp[1] == 'list' && $pvTmp[3] != "") {
539
+                                            $parameter[trim($pTmp[0])]= $pvTmp[3];
540
+                    }
541
+                    //list default
532 542
                     else
533
-                        if ($pvTmp[1] != 'list' && $pvTmp[2] != "")
534
-                            $parameter[trim($pTmp[0])]= $pvTmp[2];
543
+                        if ($pvTmp[1] != 'list' && $pvTmp[2] != "") {
544
+                                                    $parameter[trim($pTmp[0])]= $pvTmp[2];
545
+                        }
535 546
                 }
536 547
             }
537 548
         }
@@ -579,12 +590,12 @@  discard block
 block discarded – undo
579 590
 $mt = &$moduleTemplates;
580 591
 if(is_dir($templatePath) && is_readable($templatePath)) {
581 592
     $d = dir($templatePath);
582
-    while (false !== ($tplfile = $d->read()))
583
-    {
584
-        if(substr($tplfile, -4) != '.tpl') continue;
593
+    while (false !== ($tplfile = $d->read())) {
594
+        if(substr($tplfile, -4) != '.tpl') {
595
+            continue;
596
+        }
585 597
         $params = parse_docblock($templatePath, $tplfile);
586
-        if(is_array($params) && (count($params)>0))
587
-        {
598
+        if(is_array($params) && (count($params)>0)) {
588 599
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
589 600
             $mt[] = array
590 601
             (
@@ -608,7 +619,9 @@  discard block
 block discarded – undo
608 619
 if(is_dir($tvPath) && is_readable($tvPath)) {
609 620
     $d = dir($tvPath);
610 621
     while (false !== ($tplfile = $d->read())) {
611
-        if(substr($tplfile, -4) != '.tpl') continue;
622
+        if(substr($tplfile, -4) != '.tpl') {
623
+            continue;
624
+        }
612 625
         $params = parse_docblock($tvPath, $tplfile);
613 626
         if(is_array($params) && (count($params)>0)) {
614 627
             $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
@@ -801,7 +814,8 @@  discard block
 block discarded – undo
801 814
 // setup callback function
802 815
 $callBackFnc = "clean_up";
803 816
 
804
-function clean_up($sqlParser) {
817
+function clean_up($sqlParser)
818
+{
805 819
     $ids = array();
806 820
 
807 821
     // secure web documents - privateweb
@@ -814,9 +828,10 @@  discard block
 block discarded – undo
814 828
     $ds = mysqli_query($sqlParser->conn,$sql);
815 829
     if(!$ds) {
816 830
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
817
-    }
818
-    else {
819
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
831
+    } else {
832
+        while($r = mysqli_fetch_assoc($ds)) {
833
+            $ids[]=$r["id"];
834
+        }
820 835
         if(count($ids)>0) {
821 836
             mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")");
822 837
             unset($ids);
@@ -833,9 +848,10 @@  discard block
 block discarded – undo
833 848
     $ds = mysqli_query($sqlParser->conn,$sql);
834 849
     if(!$ds) {
835 850
         echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn);
836
-    }
837
-    else {
838
-        while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"];
851
+    } else {
852
+        while($r = mysqli_fetch_assoc($ds)) {
853
+            $ids[]=$r["id"];
854
+        }
839 855
         if(count($ids)>0) {
840 856
             mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")");
841 857
             unset($ids);
@@ -843,7 +859,8 @@  discard block
 block discarded – undo
843 859
     }
844 860
 }
845 861
 
846
-function parse_docblock($element_dir, $filename) {
862
+function parse_docblock($element_dir, $filename)
863
+{
847 864
     $params = array();
848 865
     $fullpath = $element_dir . '/' . $filename;
849 866
     if(is_readable($fullpath)) {
@@ -944,7 +961,7 @@  discard block
 block discarded – undo
944 961
 // custom or not
945 962
 if (file_exists($path."../assets/cache/siteManager.php")) {
946 963
     $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");';
947
-}else{
964
+} else {
948 965
     $mgrdir = 'define(\'MGR_DIR\', \'manager\');';
949 966
 }
950 967
 
@@ -1084,7 +1101,9 @@  discard block
 block discarded – undo
1084 1101
                         echo mysqli_error($sqlParser->conn) . PHP_EOL;
1085 1102
                         die();
1086 1103
                     }
1087
-                    if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1104
+                    if(!is_null($save_sql_id_as)) {
1105
+                        $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn);
1106
+                    }
1088 1107
                     echo "  $name: " . $_lang['installed'] . PHP_EOL;
1089 1108
                 }
1090 1109
             }
@@ -1179,9 +1198,9 @@  discard block
 block discarded – undo
1179 1198
             $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]);
1180 1199
             $filecontent = $moduleChunk[2];
1181 1200
 
1182
-            if (!file_exists($filecontent))
1183
-                echo "  $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1184
-            else {
1201
+            if (!file_exists($filecontent)) {
1202
+                            echo "  $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1203
+            } else {
1185 1204
 
1186 1205
                 // Create the category if it does not already exist
1187 1206
                 $category_id = getCreateDbCategory($category, $sqlParser);
@@ -1234,9 +1253,9 @@  discard block
 block discarded – undo
1234 1253
             $guid = mysqli_real_escape_string($conn, $moduleModule[4]);
1235 1254
             $shared = mysqli_real_escape_string($conn, $moduleModule[5]);
1236 1255
             $category = mysqli_real_escape_string($conn, $moduleModule[6]);
1237
-            if (!file_exists($filecontent))
1238
-                echo "  $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1239
-            else {
1256
+            if (!file_exists($filecontent)) {
1257
+                            echo "  $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1258
+            } else {
1240 1259
 
1241 1260
                 // Create the category if it does not already exist
1242 1261
                 $category = getCreateDbCategory($category, $sqlParser);
@@ -1254,7 +1273,7 @@  discard block
 block discarded – undo
1254 1273
                     }
1255 1274
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1256 1275
                 } else {
1257
-                    if ($properties != NULL ){
1276
+                    if ($properties != NULL ) {
1258 1277
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1259 1278
                     }
1260 1279
                     if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) {
@@ -1289,9 +1308,9 @@  discard block
 block discarded – undo
1289 1308
                 // parse comma-separated legacy names and prepare them for sql IN clause
1290 1309
                 $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'";
1291 1310
             }
1292
-            if (!file_exists($filecontent))
1293
-                echo "  $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1294
-            else {
1311
+            if (!file_exists($filecontent)) {
1312
+                            echo "  $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1313
+            } else {
1295 1314
 
1296 1315
                 // disable legacy versions based on legacy_names provided
1297 1316
                 if(!empty($leg_names)) {
@@ -1310,7 +1329,7 @@  discard block
 block discarded – undo
1310 1329
                     $insert = true;
1311 1330
                     while($row = mysqli_fetch_assoc($rs)) {
1312 1331
                         $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties']));
1313
-                        if($row['description'] == $desc){
1332
+                        if($row['description'] == $desc) {
1314 1333
                             if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) {
1315 1334
                                 echo mysqli_error($sqlParser->conn) . PHP_EOL;
1316 1335
                                 return;
@@ -1332,7 +1351,7 @@  discard block
 block discarded – undo
1332 1351
                     }
1333 1352
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1334 1353
                 } else {
1335
-                    if ($properties != NULL ){
1354
+                    if ($properties != NULL ) {
1336 1355
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1337 1356
                     }
1338 1357
                     if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);")) {
@@ -1371,9 +1390,9 @@  discard block
 block discarded – undo
1371 1390
             $filecontent = $moduleSnippet[2];
1372 1391
             $properties = $moduleSnippet[3];
1373 1392
             $category = mysqli_real_escape_string($conn, $moduleSnippet[4]);
1374
-            if (!file_exists($filecontent))
1375
-                echo "  $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1376
-            else {
1393
+            if (!file_exists($filecontent)) {
1394
+                            echo "  $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL;
1395
+            } else {
1377 1396
 
1378 1397
                 // Create the category if it does not already exist
1379 1398
                 $category = getCreateDbCategory($category, $sqlParser);
@@ -1391,7 +1410,7 @@  discard block
 block discarded – undo
1391 1410
                     }
1392 1411
                     echo "  $name: " . $_lang['upgraded'] . PHP_EOL;
1393 1412
                 } else {
1394
-                    if ($properties != NULL ){
1413
+                    if ($properties != NULL ) {
1395 1414
                         $properties = mysqli_real_escape_string($conn, parseProperties($properties, true));
1396 1415
                     }
1397 1416
                     if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) {
@@ -1484,11 +1503,14 @@  discard block
 block discarded – undo
1484 1503
 }
1485 1504
 
1486 1505
 // call back function
1487
-if ($callBackFnc != "")
1506
+if ($callBackFnc != "") {
1488 1507
     $callBackFnc ($sqlParser);
1508
+}
1489 1509
 
1490 1510
 // Setup the MODX API -- needed for the cache processor
1491
-if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
1511
+if (!defined('MODX_MANAGER_PATH')) {
1512
+    define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/');
1513
+}
1492 1514
 $database_type = 'mysqli';
1493 1515
 // initiate a new document parser
1494 1516
 include_once($path.'../'.MGR_DIR.'/includes/document.parser.class.inc.php');
@@ -1527,7 +1549,7 @@  discard block
 block discarded – undo
1527 1549
 }
1528 1550
 
1529 1551
 
1530
-if ( empty($args) ){
1552
+if ( empty($args) ) {
1531 1553
     echo PHP_EOL . 'Remove install folder?'.PHP_EOL;
1532 1554
     $removeInstall = readline("Type 'y' or 'n' to continue: ");
1533 1555
 }
@@ -1543,11 +1565,12 @@  discard block
 block discarded – undo
1543 1565
  * @param string $old
1544 1566
  * @return string
1545 1567
  */
1546
-function propUpdate($new,$old){
1568
+function propUpdate($new,$old)
1569
+{
1547 1570
     $newArr = parseProperties($new);
1548 1571
     $oldArr = parseProperties($old);
1549
-    foreach ($oldArr as $k => $v){
1550
-        if (isset($v['0']['options'])){
1572
+    foreach ($oldArr as $k => $v) {
1573
+        if (isset($v['0']['options'])) {
1551 1574
             $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options'];
1552 1575
         }
1553 1576
     }
@@ -1562,12 +1585,17 @@  discard block
 block discarded – undo
1562 1585
  * @param bool|mixed $json
1563 1586
  * @return string
1564 1587
  */
1565
-function parseProperties($propertyString, $json=false) {
1588
+function parseProperties($propertyString, $json=false)
1589
+{
1566 1590
     $propertyString = str_replace('{}', '', $propertyString );
1567 1591
     $propertyString = str_replace('} {', ',', $propertyString );
1568 1592
 
1569
-    if(empty($propertyString)) return array();
1570
-    if($propertyString=='{}' || $propertyString=='[]') return array();
1593
+    if(empty($propertyString)) {
1594
+        return array();
1595
+    }
1596
+    if($propertyString=='{}' || $propertyString=='[]') {
1597
+        return array();
1598
+    }
1571 1599
 
1572 1600
     $jsonFormat = isJson($propertyString, true);
1573 1601
     $property = array();
@@ -1609,7 +1637,7 @@  discard block
 block discarded – undo
1609 1637
 
1610 1638
         }
1611 1639
     // new json-format
1612
-    } else if(!empty($jsonFormat)){
1640
+    } else if(!empty($jsonFormat)) {
1613 1641
         $property = $jsonFormat;
1614 1642
     }
1615 1643
     if ($json) {
@@ -1624,7 +1652,8 @@  discard block
 block discarded – undo
1624 1652
  * @param bool $returnData
1625 1653
  * @return bool|mixed
1626 1654
  */
1627
-function isJson($string, $returnData=false) {
1655
+function isJson($string, $returnData=false)
1656
+{
1628 1657
     $data = json_decode($string, true);
1629 1658
     return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false;
1630 1659
 }
@@ -1634,7 +1663,8 @@  discard block
 block discarded – undo
1634 1663
  * @param SqlParser $sqlParser
1635 1664
  * @return int
1636 1665
  */
1637
-function getCreateDbCategory($category, $sqlParser) {
1666
+function getCreateDbCategory($category, $sqlParser)
1667
+{
1638 1668
     $dbase = $sqlParser->dbname;
1639 1669
     $dbase = '`' . trim($dbase,'`') . '`';
1640 1670
     $table_prefix = $sqlParser->prefix;
@@ -1662,7 +1692,8 @@  discard block
 block discarded – undo
1662 1692
  * @param string $type
1663 1693
  * @return string
1664 1694
  */
1665
-function removeDocblock($code, $type) {
1695
+function removeDocblock($code, $type)
1696
+{
1666 1697
 
1667 1698
     $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1);
1668 1699
 
@@ -1683,8 +1714,9 @@  discard block
 block discarded – undo
1683 1714
         default:
1684 1715
             return $cleaned;
1685 1716
     };
1686
-    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/')
1687
-        return $cleaned;
1717
+    if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') {
1718
+            return $cleaned;
1719
+    }
1688 1720
 
1689 1721
     // fileBinding not found - return code incl docblock
1690 1722
     return $code;
Please login to merge, or discard this patch.