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