@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | $args = array_slice($argv, 1); |
59 | 59 | |
60 | -if ( empty($args) ){ |
|
60 | +if ( empty($args) ) { |
|
61 | 61 | echo 'Install Evolution CMS'.PHP_EOL; |
62 | 62 | //$installYes = readline("Type 'y' to continue: "); |
63 | 63 | //if ($installYes != 'y') return; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $managerlanguage = readline('Мanager language:' . ' [en] '); |
77 | 77 | $installData = readline('Instal demo-site (y/n):' . ' [n] '); |
78 | 78 | |
79 | -}else{ |
|
79 | +} else { |
|
80 | 80 | |
81 | 81 | $cli_variables = []; |
82 | 82 | foreach ($args as $arg) { |
@@ -130,21 +130,24 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | ////////////////////////////////////////////////////////////////////////////////////// |
133 | -if( ! function_exists('f_owc')){ |
|
133 | +if( ! function_exists('f_owc')) { |
|
134 | 134 | /** |
135 | 135 | * @param $path |
136 | 136 | * @param $data |
137 | 137 | * @param null|int $mode |
138 | 138 | */ |
139 | - function f_owc($path, $data, $mode = null){ |
|
139 | + function f_owc($path, $data, $mode = null) |
|
140 | + { |
|
140 | 141 | try { |
141 | 142 | // make an attempt to create the file |
142 | 143 | $hnd = fopen($path, 'w'); |
143 | 144 | fwrite($hnd, $data); |
144 | 145 | fclose($hnd); |
145 | 146 | |
146 | - if(null !== $mode) chmod($path, $mode); |
|
147 | - }catch(Exception $e){ |
|
147 | + if(null !== $mode) { |
|
148 | + chmod($path, $mode); |
|
149 | + } |
|
150 | + } catch(Exception $e) { |
|
148 | 151 | // Nothing, this is NOT normal |
149 | 152 | unset($e); |
150 | 153 | } |
@@ -210,7 +213,7 @@ discard block |
||
210 | 213 | |
211 | 214 | // File Browser directories exists? |
212 | 215 | echo strip_tags($_lang['checking_if_images_exist']); |
213 | -switch(true){ |
|
216 | +switch(true) { |
|
214 | 217 | case !file_exists($path."../assets/images"): |
215 | 218 | case !file_exists($path."../assets/files"): |
216 | 219 | case !file_exists($path."../assets/backup"): |
@@ -225,7 +228,7 @@ discard block |
||
225 | 228 | |
226 | 229 | // File Browser directories writable? |
227 | 230 | echo strip_tags($_lang['checking_if_images_writable']); |
228 | -switch(true){ |
|
231 | +switch(true) { |
|
229 | 232 | case !is_writable($path."../assets/images"): |
230 | 233 | case !is_writable($path."../assets/files"): |
231 | 234 | case !is_writable($path."../assets/backup"): |
@@ -361,7 +364,7 @@ discard block |
||
361 | 364 | if ($conn) { |
362 | 365 | echo $_lang['checking_mysql_strict_mode']; |
363 | 366 | $mysqlmode = mysqli_query($conn, "SELECT @@global.sql_mode"); |
364 | - if (mysqli_num_rows($mysqlmode) > 0){ |
|
367 | + if (mysqli_num_rows($mysqlmode) > 0) { |
|
365 | 368 | $modes = mysqli_fetch_array($mysqlmode, MYSQLI_NUM); |
366 | 369 | //$modes = array("STRICT_TRANS_TABLES"); // for testing |
367 | 370 | // print_r($modes); |
@@ -397,9 +400,9 @@ discard block |
||
397 | 400 | if ($errors > 0) { |
398 | 401 | echo $_lang['setup_cannot_continue'] . ' '; |
399 | 402 | |
400 | - if($errors > 1){ |
|
403 | + if($errors > 1) { |
|
401 | 404 | echo $errors . " " . $_lang['errors'] . $_lang['please_correct_errors'] . $_lang['and_try_again_plural']; |
402 | - }else{ |
|
405 | + } else { |
|
403 | 406 | echo $_lang['error'] . $_lang['please_correct_error'] . $_lang['and_try_again']. PHP_EOL; |
404 | 407 | } |
405 | 408 | |
@@ -445,13 +448,15 @@ discard block |
||
445 | 448 | |
446 | 449 | // get base path and url |
447 | 450 | $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"]))); |
448 | -if (count($a) > 1) |
|
451 | +if (count($a) > 1) { |
|
449 | 452 | array_pop($a); |
453 | +} |
|
450 | 454 | $url = implode("install", $a); |
451 | 455 | reset($a); |
452 | 456 | $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__)))); |
453 | -if (count($a) > 1) |
|
457 | +if (count($a) > 1) { |
|
454 | 458 | array_pop($a); |
459 | +} |
|
455 | 460 | $pth = implode("install", $a); |
456 | 461 | unset ($a); |
457 | 462 | $base_url = $url . (substr($url, -1) != "/" ? "/" : ""); |
@@ -472,7 +477,9 @@ discard block |
||
472 | 477 | echo $_lang['setup_database_selection_failed']." ".$_lang['setup_database_selection_failed_note'].PHP_EOL; |
473 | 478 | $create = true; |
474 | 479 | } else { |
475 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset); |
|
480 | + if (function_exists('mysqli_set_charset')) { |
|
481 | + mysqli_set_charset($conn, $database_charset); |
|
482 | + } |
|
476 | 483 | mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); |
477 | 484 | echo $_lang['ok'].PHP_EOL; |
478 | 485 | } |
@@ -518,7 +525,8 @@ discard block |
||
518 | 525 | * @param string $propertyString |
519 | 526 | * @return array |
520 | 527 | */ |
521 | - function parseProperties($propertyString) { |
|
528 | + function parseProperties($propertyString) |
|
529 | + { |
|
522 | 530 | $parameter= array (); |
523 | 531 | if (!empty ($propertyString)) { |
524 | 532 | $tmpParams= explode("&", $propertyString); |
@@ -527,11 +535,14 @@ discard block |
||
527 | 535 | if (strpos($tmpParams[$x], '=', 0)) { |
528 | 536 | $pTmp= explode("=", $tmpParams[$x]); |
529 | 537 | $pvTmp= explode(";", trim($pTmp[1])); |
530 | - if ($pvTmp[1] == 'list' && $pvTmp[3] != "") |
|
531 | - $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default |
|
538 | + if ($pvTmp[1] == 'list' && $pvTmp[3] != "") { |
|
539 | + $parameter[trim($pTmp[0])]= $pvTmp[3]; |
|
540 | + } |
|
541 | + //list default |
|
532 | 542 | else |
533 | - if ($pvTmp[1] != 'list' && $pvTmp[2] != "") |
|
534 | - $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
543 | + if ($pvTmp[1] != 'list' && $pvTmp[2] != "") { |
|
544 | + $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
545 | + } |
|
535 | 546 | } |
536 | 547 | } |
537 | 548 | } |
@@ -579,12 +590,12 @@ discard block |
||
579 | 590 | $mt = &$moduleTemplates; |
580 | 591 | if(is_dir($templatePath) && is_readable($templatePath)) { |
581 | 592 | $d = dir($templatePath); |
582 | - while (false !== ($tplfile = $d->read())) |
|
583 | - { |
|
584 | - if(substr($tplfile, -4) != '.tpl') continue; |
|
593 | + while (false !== ($tplfile = $d->read())) { |
|
594 | + if(substr($tplfile, -4) != '.tpl') { |
|
595 | + continue; |
|
596 | + } |
|
585 | 597 | $params = parse_docblock($templatePath, $tplfile); |
586 | - if(is_array($params) && (count($params)>0)) |
|
587 | - { |
|
598 | + if(is_array($params) && (count($params)>0)) { |
|
588 | 599 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
589 | 600 | $mt[] = array |
590 | 601 | ( |
@@ -608,7 +619,9 @@ discard block |
||
608 | 619 | if(is_dir($tvPath) && is_readable($tvPath)) { |
609 | 620 | $d = dir($tvPath); |
610 | 621 | while (false !== ($tplfile = $d->read())) { |
611 | - if(substr($tplfile, -4) != '.tpl') continue; |
|
622 | + if(substr($tplfile, -4) != '.tpl') { |
|
623 | + continue; |
|
624 | + } |
|
612 | 625 | $params = parse_docblock($tvPath, $tplfile); |
613 | 626 | if(is_array($params) && (count($params)>0)) { |
614 | 627 | $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}"; |
@@ -801,7 +814,8 @@ discard block |
||
801 | 814 | // setup callback function |
802 | 815 | $callBackFnc = "clean_up"; |
803 | 816 | |
804 | -function clean_up($sqlParser) { |
|
817 | +function clean_up($sqlParser) |
|
818 | +{ |
|
805 | 819 | $ids = array(); |
806 | 820 | |
807 | 821 | // secure web documents - privateweb |
@@ -814,9 +828,10 @@ discard block |
||
814 | 828 | $ds = mysqli_query($sqlParser->conn,$sql); |
815 | 829 | if(!$ds) { |
816 | 830 | echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); |
817 | - } |
|
818 | - else { |
|
819 | - while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; |
|
831 | + } else { |
|
832 | + while($r = mysqli_fetch_assoc($ds)) { |
|
833 | + $ids[]=$r["id"]; |
|
834 | + } |
|
820 | 835 | if(count($ids)>0) { |
821 | 836 | mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privateweb = 1 WHERE id IN (".implode(", ",$ids).")"); |
822 | 837 | unset($ids); |
@@ -833,9 +848,10 @@ discard block |
||
833 | 848 | $ds = mysqli_query($sqlParser->conn,$sql); |
834 | 849 | if(!$ds) { |
835 | 850 | echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); |
836 | - } |
|
837 | - else { |
|
838 | - while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; |
|
851 | + } else { |
|
852 | + while($r = mysqli_fetch_assoc($ds)) { |
|
853 | + $ids[]=$r["id"]; |
|
854 | + } |
|
839 | 855 | if(count($ids)>0) { |
840 | 856 | mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")"); |
841 | 857 | unset($ids); |
@@ -843,7 +859,8 @@ discard block |
||
843 | 859 | } |
844 | 860 | } |
845 | 861 | |
846 | -function parse_docblock($element_dir, $filename) { |
|
862 | +function parse_docblock($element_dir, $filename) |
|
863 | +{ |
|
847 | 864 | $params = array(); |
848 | 865 | $fullpath = $element_dir . '/' . $filename; |
849 | 866 | if(is_readable($fullpath)) { |
@@ -944,7 +961,7 @@ discard block |
||
944 | 961 | // custom or not |
945 | 962 | if (file_exists($path."../assets/cache/siteManager.php")) { |
946 | 963 | $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");'; |
947 | -}else{ |
|
964 | +} else { |
|
948 | 965 | $mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
949 | 966 | } |
950 | 967 | |
@@ -1084,7 +1101,9 @@ discard block |
||
1084 | 1101 | echo mysqli_error($sqlParser->conn) . PHP_EOL; |
1085 | 1102 | die(); |
1086 | 1103 | } |
1087 | - if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
1104 | + if(!is_null($save_sql_id_as)) { |
|
1105 | + $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
1106 | + } |
|
1088 | 1107 | echo " $name: " . $_lang['installed'] . PHP_EOL; |
1089 | 1108 | } |
1090 | 1109 | } |
@@ -1179,9 +1198,9 @@ discard block |
||
1179 | 1198 | $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]); |
1180 | 1199 | $filecontent = $moduleChunk[2]; |
1181 | 1200 | |
1182 | - if (!file_exists($filecontent)) |
|
1183 | - echo " $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
1184 | - else { |
|
1201 | + if (!file_exists($filecontent)) { |
|
1202 | + echo " $name: " . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
1203 | + } else { |
|
1185 | 1204 | |
1186 | 1205 | // Create the category if it does not already exist |
1187 | 1206 | $category_id = getCreateDbCategory($category, $sqlParser); |
@@ -1234,9 +1253,9 @@ discard block |
||
1234 | 1253 | $guid = mysqli_real_escape_string($conn, $moduleModule[4]); |
1235 | 1254 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
1236 | 1255 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
1237 | - if (!file_exists($filecontent)) |
|
1238 | - echo " $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
1239 | - else { |
|
1256 | + if (!file_exists($filecontent)) { |
|
1257 | + echo " $name: " . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
1258 | + } else { |
|
1240 | 1259 | |
1241 | 1260 | // Create the category if it does not already exist |
1242 | 1261 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -1254,7 +1273,7 @@ discard block |
||
1254 | 1273 | } |
1255 | 1274 | echo " $name: " . $_lang['upgraded'] . PHP_EOL; |
1256 | 1275 | } else { |
1257 | - if ($properties != NULL ){ |
|
1276 | + if ($properties != NULL ) { |
|
1258 | 1277 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
1259 | 1278 | } |
1260 | 1279 | if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_modules` (name,description,modulecode,properties,guid,enable_sharedparams,category) VALUES('$name','$desc','$module','$properties','$guid','$shared', $category);")) { |
@@ -1289,9 +1308,9 @@ discard block |
||
1289 | 1308 | // parse comma-separated legacy names and prepare them for sql IN clause |
1290 | 1309 | $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
1291 | 1310 | } |
1292 | - if (!file_exists($filecontent)) |
|
1293 | - echo " $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
1294 | - else { |
|
1311 | + if (!file_exists($filecontent)) { |
|
1312 | + echo " $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
1313 | + } else { |
|
1295 | 1314 | |
1296 | 1315 | // disable legacy versions based on legacy_names provided |
1297 | 1316 | if(!empty($leg_names)) { |
@@ -1310,7 +1329,7 @@ discard block |
||
1310 | 1329 | $insert = true; |
1311 | 1330 | while($row = mysqli_fetch_assoc($rs)) { |
1312 | 1331 | $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
1313 | - if($row['description'] == $desc){ |
|
1332 | + if($row['description'] == $desc) { |
|
1314 | 1333 | if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
1315 | 1334 | echo mysqli_error($sqlParser->conn) . PHP_EOL; |
1316 | 1335 | return; |
@@ -1332,7 +1351,7 @@ discard block |
||
1332 | 1351 | } |
1333 | 1352 | echo " $name: " . $_lang['upgraded'] . PHP_EOL; |
1334 | 1353 | } else { |
1335 | - if ($properties != NULL ){ |
|
1354 | + if ($properties != NULL ) { |
|
1336 | 1355 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
1337 | 1356 | } |
1338 | 1357 | if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_plugins` (name,description,plugincode,properties,moduleguid,category,disabled) VALUES('$name','$desc','$plugin','$properties','$guid',$category,$disabled);")) { |
@@ -1371,9 +1390,9 @@ discard block |
||
1371 | 1390 | $filecontent = $moduleSnippet[2]; |
1372 | 1391 | $properties = $moduleSnippet[3]; |
1373 | 1392 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
1374 | - if (!file_exists($filecontent)) |
|
1375 | - echo " $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
1376 | - else { |
|
1393 | + if (!file_exists($filecontent)) { |
|
1394 | + echo " $name: " . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . PHP_EOL; |
|
1395 | + } else { |
|
1377 | 1396 | |
1378 | 1397 | // Create the category if it does not already exist |
1379 | 1398 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -1391,7 +1410,7 @@ discard block |
||
1391 | 1410 | } |
1392 | 1411 | echo " $name: " . $_lang['upgraded'] . PHP_EOL; |
1393 | 1412 | } else { |
1394 | - if ($properties != NULL ){ |
|
1413 | + if ($properties != NULL ) { |
|
1395 | 1414 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
1396 | 1415 | } |
1397 | 1416 | if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) { |
@@ -1484,11 +1503,14 @@ discard block |
||
1484 | 1503 | } |
1485 | 1504 | |
1486 | 1505 | // call back function |
1487 | -if ($callBackFnc != "") |
|
1506 | +if ($callBackFnc != "") { |
|
1488 | 1507 | $callBackFnc ($sqlParser); |
1508 | +} |
|
1489 | 1509 | |
1490 | 1510 | // Setup the MODX API -- needed for the cache processor |
1491 | -if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
1511 | +if (!defined('MODX_MANAGER_PATH')) { |
|
1512 | + define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
1513 | +} |
|
1492 | 1514 | $database_type = 'mysqli'; |
1493 | 1515 | // initiate a new document parser |
1494 | 1516 | include_once($path.'../'.MGR_DIR.'/includes/document.parser.class.inc.php'); |
@@ -1527,7 +1549,7 @@ discard block |
||
1527 | 1549 | } |
1528 | 1550 | |
1529 | 1551 | |
1530 | -if ( empty($args) ){ |
|
1552 | +if ( empty($args) ) { |
|
1531 | 1553 | echo PHP_EOL . 'Remove install folder?'.PHP_EOL; |
1532 | 1554 | $removeInstall = readline("Type 'y' or 'n' to continue: "); |
1533 | 1555 | } |
@@ -1543,11 +1565,12 @@ discard block |
||
1543 | 1565 | * @param string $old |
1544 | 1566 | * @return string |
1545 | 1567 | */ |
1546 | -function propUpdate($new,$old){ |
|
1568 | +function propUpdate($new,$old) |
|
1569 | +{ |
|
1547 | 1570 | $newArr = parseProperties($new); |
1548 | 1571 | $oldArr = parseProperties($old); |
1549 | - foreach ($oldArr as $k => $v){ |
|
1550 | - if (isset($v['0']['options'])){ |
|
1572 | + foreach ($oldArr as $k => $v) { |
|
1573 | + if (isset($v['0']['options'])) { |
|
1551 | 1574 | $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options']; |
1552 | 1575 | } |
1553 | 1576 | } |
@@ -1562,12 +1585,17 @@ discard block |
||
1562 | 1585 | * @param bool|mixed $json |
1563 | 1586 | * @return string |
1564 | 1587 | */ |
1565 | -function parseProperties($propertyString, $json=false) { |
|
1588 | +function parseProperties($propertyString, $json=false) |
|
1589 | +{ |
|
1566 | 1590 | $propertyString = str_replace('{}', '', $propertyString ); |
1567 | 1591 | $propertyString = str_replace('} {', ',', $propertyString ); |
1568 | 1592 | |
1569 | - if(empty($propertyString)) return array(); |
|
1570 | - if($propertyString=='{}' || $propertyString=='[]') return array(); |
|
1593 | + if(empty($propertyString)) { |
|
1594 | + return array(); |
|
1595 | + } |
|
1596 | + if($propertyString=='{}' || $propertyString=='[]') { |
|
1597 | + return array(); |
|
1598 | + } |
|
1571 | 1599 | |
1572 | 1600 | $jsonFormat = isJson($propertyString, true); |
1573 | 1601 | $property = array(); |
@@ -1609,7 +1637,7 @@ discard block |
||
1609 | 1637 | |
1610 | 1638 | } |
1611 | 1639 | // new json-format |
1612 | - } else if(!empty($jsonFormat)){ |
|
1640 | + } else if(!empty($jsonFormat)) { |
|
1613 | 1641 | $property = $jsonFormat; |
1614 | 1642 | } |
1615 | 1643 | if ($json) { |
@@ -1624,7 +1652,8 @@ discard block |
||
1624 | 1652 | * @param bool $returnData |
1625 | 1653 | * @return bool|mixed |
1626 | 1654 | */ |
1627 | -function isJson($string, $returnData=false) { |
|
1655 | +function isJson($string, $returnData=false) |
|
1656 | +{ |
|
1628 | 1657 | $data = json_decode($string, true); |
1629 | 1658 | return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false; |
1630 | 1659 | } |
@@ -1634,7 +1663,8 @@ discard block |
||
1634 | 1663 | * @param SqlParser $sqlParser |
1635 | 1664 | * @return int |
1636 | 1665 | */ |
1637 | -function getCreateDbCategory($category, $sqlParser) { |
|
1666 | +function getCreateDbCategory($category, $sqlParser) |
|
1667 | +{ |
|
1638 | 1668 | $dbase = $sqlParser->dbname; |
1639 | 1669 | $dbase = '`' . trim($dbase,'`') . '`'; |
1640 | 1670 | $table_prefix = $sqlParser->prefix; |
@@ -1662,7 +1692,8 @@ discard block |
||
1662 | 1692 | * @param string $type |
1663 | 1693 | * @return string |
1664 | 1694 | */ |
1665 | -function removeDocblock($code, $type) { |
|
1695 | +function removeDocblock($code, $type) |
|
1696 | +{ |
|
1666 | 1697 | |
1667 | 1698 | $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1); |
1668 | 1699 | |
@@ -1683,8 +1714,9 @@ discard block |
||
1683 | 1714 | default: |
1684 | 1715 | return $cleaned; |
1685 | 1716 | }; |
1686 | - if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
1687 | - return $cleaned; |
|
1717 | + if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') { |
|
1718 | + return $cleaned; |
|
1719 | + } |
|
1688 | 1720 | |
1689 | 1721 | // fileBinding not found - return code incl docblock |
1690 | 1722 | return $code; |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | $MODX_SITE_HOSTNAMES = MODX_SITE_HOSTNAMES; // Fix for PHP 5.4 |
3 | - if(empty($valid_hostnames) && empty($MODX_SITE_HOSTNAMES)) { |
|
3 | + if(empty($valid_hostnames) && empty($MODX_SITE_HOSTNAMES)) { |
|
4 | 4 | $valid_hostnames = $_SERVER['HTTP_HOST']; |
5 | - } else { |
|
5 | + } else { |
|
6 | 6 | $valid_hostnames = $MODX_SITE_HOSTNAMES; |
7 | 7 | } |
8 | 8 | ?> |
@@ -157,7 +157,9 @@ discard block |
||
157 | 157 | <th><?php echo $_lang['pwd_hash_algo_title'] ?><br><small>[(pwd_hash_algo)]</small></th> |
158 | 158 | <td> |
159 | 159 | <?php |
160 | -if(empty($pwd_hash_algo)) $phm['sel']['UNCRYPT'] = 1; |
|
160 | +if(empty($pwd_hash_algo)) { |
|
161 | + $phm['sel']['UNCRYPT'] = 1; |
|
162 | +} |
|
161 | 163 | $phm['e']['BLOWFISH_Y'] = $modx->manager->checkHashAlgorithm('BLOWFISH_Y') ? 0:1; |
162 | 164 | $phm['e']['BLOWFISH_A'] = $modx->manager->checkHashAlgorithm('BLOWFISH_A') ? 0:1; |
163 | 165 | $phm['e']['SHA512'] = $modx->manager->checkHashAlgorithm('SHA512') ? 0:1; |
@@ -186,7 +188,9 @@ discard block |
||
186 | 188 | ?> |
187 | 189 | <?php |
188 | 190 | $gdAvailable = extension_loaded('gd'); |
189 | -if(!$gdAvailable) $use_captcha = 0; |
|
191 | +if(!$gdAvailable) { |
|
192 | + $use_captcha = 0; |
|
193 | +} |
|
190 | 194 | ?> |
191 | 195 | <tr> |
192 | 196 | <td nowrap class="warning"><?php echo $_lang['captcha_title'] ?><br><small>[(use_captcha)]</small></td> |
@@ -226,7 +230,9 @@ discard block |
||
226 | 230 | <?php |
227 | 231 | // invoke OnMiscSettingsRender event |
228 | 232 | $evtOut = $modx->invokeEvent('OnSecuritySettingsRender'); |
229 | - if(is_array($evtOut)) echo implode("",$evtOut); |
|
233 | + if(is_array($evtOut)) { |
|
234 | + echo implode("",$evtOut); |
|
235 | + } |
|
230 | 236 | ?> |
231 | 237 | </td> |
232 | 238 | </tr> |
@@ -113,7 +113,9 @@ |
||
113 | 113 | <?php |
114 | 114 | // invoke OnMiscSettingsRender event |
115 | 115 | $evtOut = $modx->invokeEvent('OnFileManagerSettingsRender'); |
116 | - if(is_array($evtOut)) echo implode("",$evtOut); |
|
116 | + if(is_array($evtOut)) { |
|
117 | + echo implode("",$evtOut); |
|
118 | + } |
|
117 | 119 | ?> |
118 | 120 | </td> |
119 | 121 | </tr> |
@@ -9,39 +9,27 @@ discard block |
||
9 | 9 | // lose the POST now, gets rid of quirky issue with Safari 3 - see FS#972 |
10 | 10 | unset($_POST); |
11 | 11 | |
12 | -if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) |
|
13 | -{ |
|
12 | +if($data['friendly_urls']==='1' && strpos($_SERVER['SERVER_SOFTWARE'],'IIS')===false) { |
|
14 | 13 | $htaccess = $modx->config['base_path'] . '.htaccess'; |
15 | 14 | $sample_htaccess = $modx->config['base_path'] . 'ht.access'; |
16 | 15 | $dir = '/' . trim($modx->config['base_url'],'/'); |
17 | - if(is_file($htaccess)) |
|
18 | - { |
|
16 | + if(is_file($htaccess)) { |
|
19 | 17 | $_ = file_get_contents($htaccess); |
20 | - if(strpos($_,'RewriteBase')===false) |
|
21 | - { |
|
18 | + if(strpos($_,'RewriteBase')===false) { |
|
22 | 19 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
23 | - } |
|
24 | - elseif(is_writable($htaccess)) |
|
25 | - { |
|
20 | + } elseif(is_writable($htaccess)) { |
|
26 | 21 | $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
27 | - if(!@file_put_contents($htaccess,$_)) |
|
28 | - { |
|
22 | + if(!@file_put_contents($htaccess,$_)) { |
|
29 | 23 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
30 | 24 | } |
31 | 25 | } |
32 | - } |
|
33 | - elseif(is_file($sample_htaccess)) |
|
34 | - { |
|
35 | - if(!@rename($sample_htaccess,$htaccess)) |
|
36 | - { |
|
26 | + } elseif(is_file($sample_htaccess)) { |
|
27 | + if(!@rename($sample_htaccess,$htaccess)) { |
|
37 | 28 | $warnings[] = $_lang["settings_friendlyurls_alert"]; |
38 | - } |
|
39 | - elseif($modx->config['base_url']!=='/') |
|
40 | - { |
|
29 | + } elseif($modx->config['base_url']!=='/') { |
|
41 | 30 | $_ = file_get_contents($htaccess); |
42 | 31 | $_ = preg_replace('@RewriteBase.+@',"RewriteBase {$dir}", $_); |
43 | - if(!@file_put_contents($htaccess,$_)) |
|
44 | - { |
|
32 | + if(!@file_put_contents($htaccess,$_)) { |
|
45 | 33 | $warnings[] = $_lang["settings_friendlyurls_alert2"]; |
46 | 34 | } |
47 | 35 | } |
@@ -73,7 +61,7 @@ discard block |
||
73 | 61 | $v = htmlspecialchars($v); |
74 | 62 | break; |
75 | 63 | case 'settings_version':{ |
76 | - if($modx->getVersionData('version')!=$data['settings_version']){ |
|
64 | + if($modx->getVersionData('version')!=$data['settings_version']) { |
|
77 | 65 | $modx->logEvent(17,2,'<pre>'.var_export($data['settings_version'],true).'</pre>','fake settings_version'); |
78 | 66 | $v = $modx->getVersionData('version'); |
79 | 67 | } |
@@ -134,7 +122,9 @@ discard block |
||
134 | 122 | |
135 | 123 | $modx->config[$k] = $v; |
136 | 124 | |
137 | - if(!empty($k)) $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
125 | + if(!empty($k)) { |
|
126 | + $savethese[] = '(\''.$modx->db->escape($k).'\', \''.$modx->db->escape($v).'\')'; |
|
127 | + } |
|
138 | 128 | } |
139 | 129 | |
140 | 130 | // Run a single query to save all the values |
@@ -148,8 +138,11 @@ discard block |
||
148 | 138 | $oldtemplate = (int)$data['old_template']; |
149 | 139 | $tbl = $modx->getFullTableName('site_content'); |
150 | 140 | $reset = $data['reset_template']; |
151 | - if($reset==1) $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
152 | - else if($reset==2) $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
141 | + if($reset==1) { |
|
142 | + $modx->db->update(array('template' => $newtemplate), $tbl, "type='document'"); |
|
143 | + } else if($reset==2) { |
|
144 | + $modx->db->update(array('template' => $newtemplate), $tbl, "template='{$oldtemplate}'"); |
|
145 | + } |
|
153 | 146 | } |
154 | 147 | |
155 | 148 | // empty cache |
@@ -39,7 +39,9 @@ discard block |
||
39 | 39 | // get user settings |
40 | 40 | $rs = $modx->db->select('*', $modx->getFullTableName('user_settings'), "user = '{$user}'"); |
41 | 41 | $usersettings = array(); |
42 | - while($row = $modx->db->getRow($rs)) $usersettings[$row['setting_name']] = $row['setting_value']; |
|
42 | + while($row = $modx->db->getRow($rs)) { |
|
43 | + $usersettings[$row['setting_name']] = $row['setting_value']; |
|
44 | + } |
|
43 | 45 | // manually extract so that user display settings are not overwritten |
44 | 46 | foreach($usersettings as $k => $v) { |
45 | 47 | if($k != 'manager_language' && $k != 'manager_theme') { |
@@ -763,13 +765,16 @@ discard block |
||
763 | 765 | |
764 | 766 | $groupsarray = array(); |
765 | 767 | |
766 | - if($modx->manager->action == '12') { // only do this bit if the user is being edited |
|
768 | + if($modx->manager->action == '12') { |
|
769 | +// only do this bit if the user is being edited |
|
767 | 770 | $rs = $modx->db->select('user_group', $modx->getFullTableName('member_groups'), "member='{$user}'"); |
768 | 771 | $groupsarray = $modx->db->getColumn('user_group', $rs); |
769 | 772 | } |
770 | 773 | // retain selected doc groups between post |
771 | 774 | if(is_array($_POST['user_groups'])) { |
772 | - foreach($_POST['user_groups'] as $n => $v) $groupsarray[] = $v; |
|
775 | + foreach($_POST['user_groups'] as $n => $v) { |
|
776 | + $groupsarray[] = $v; |
|
777 | + } |
|
773 | 778 | } |
774 | 779 | ?> |
775 | 780 | <div class="tab-page" id="tabAccess"> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br /> |
4 | 4 | Please use the EVO Content Manager instead of accessing this file directly."); |
5 | 5 | } |
@@ -10,26 +10,26 @@ discard block |
||
10 | 10 | $modx_textdir = isset($modx_textdir) ? $modx_textdir : null; |
11 | 11 | $onManagerMainFrameHeaderHTMLBlock = is_array($evtOut) ? implode("\n", $evtOut) : ''; |
12 | 12 | $textdir = $modx_textdir === 'rtl' ? 'rtl' : 'ltr'; |
13 | -if (!isset($modx->config['mgr_jquery_path'])) { |
|
13 | +if (!isset($modx->config['mgr_jquery_path'])) { |
|
14 | 14 | $modx->config['mgr_jquery_path'] = 'media/script/jquery/jquery.min.js'; |
15 | 15 | } |
16 | -if (!isset($modx->config['mgr_date_picker_path'])) { |
|
16 | +if (!isset($modx->config['mgr_date_picker_path'])) { |
|
17 | 17 | $modx->config['mgr_date_picker_path'] = 'media/script/air-datepicker/datepicker.inc.php'; |
18 | 18 | } |
19 | 19 | |
20 | 20 | $body_class = ''; |
21 | 21 | $theme_modes = array('', 'lightness', 'light', 'dark', 'darkness'); |
22 | -if (!empty($theme_modes[$_COOKIE['MODX_themeMode']])) { |
|
22 | +if (!empty($theme_modes[$_COOKIE['MODX_themeMode']])) { |
|
23 | 23 | $body_class .= ' ' . $theme_modes[$_COOKIE['MODX_themeMode']]; |
24 | -} elseif (!empty($theme_modes[$modx->config['manager_theme_mode']])) { |
|
24 | +} elseif (!empty($theme_modes[$modx->config['manager_theme_mode']])) { |
|
25 | 25 | $body_class .= ' ' . $theme_modes[$modx->config['manager_theme_mode']]; |
26 | 26 | } |
27 | 27 | |
28 | 28 | $css = 'media/style/' . $modx->config['manager_theme'] . '/style.css?v=' . $lastInstallTime; |
29 | 29 | |
30 | -if ($modx->config['manager_theme'] == 'default') { |
|
30 | +if ($modx->config['manager_theme'] == 'default') { |
|
31 | 31 | if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') |
32 | - && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) { |
|
32 | + && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) { |
|
33 | 33 | $files = array( |
34 | 34 | 'bootstrap' => MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css', |
35 | 35 | 'font-awesome' => MODX_MANAGER_PATH . 'media/style/common/font-awesome/css/font-awesome.min.css', |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'source' => 'manager', |
49 | 49 | 'theme' => $modx->config['manager_theme'] |
50 | 50 | )); |
51 | - switch (true) { |
|
51 | + switch (true) { |
|
52 | 52 | case empty($evtOut): |
53 | 53 | case is_array($evtOut) && count($evtOut) === 0: |
54 | 54 | break; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $css |
67 | 67 | ); |
68 | 68 | } |
69 | - if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
|
69 | + if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { |
|
70 | 70 | $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime; |
71 | 71 | } |
72 | 72 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | <script src="media/script/main.js"></script> |
125 | 125 | <script> |
126 | 126 | <?php |
127 | - if (isset($_REQUEST['r']) && preg_match('@^[0-9]+$@', $_REQUEST['r'])) { |
|
127 | + if (isset($_REQUEST['r']) && preg_match('@^[0-9]+$@', $_REQUEST['r'])) { |
|
128 | 128 | echo 'doRefresh(' . $_REQUEST['r'] . ");\n"; |
129 | 129 | } |
130 | 130 | ?> |
@@ -182,16 +182,18 @@ discard block |
||
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | -switch($installMode){ |
|
185 | +switch($installMode) { |
|
186 | 186 | case 0: |
187 | 187 | case 2: |
188 | 188 | $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci'; |
189 | 189 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
190 | 190 | $_POST['database_connection_charset'] = $database_charset; |
191 | - if(!empty($_POST['databaseloginpassword'])) |
|
192 | - $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
|
193 | - if(!empty($_POST['databaseloginname'])) |
|
194 | - $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
|
191 | + if(!empty($_POST['databaseloginpassword'])) { |
|
192 | + $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
|
193 | + } |
|
194 | + if(!empty($_POST['databaseloginname'])) { |
|
195 | + $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
|
196 | + } |
|
195 | 197 | break; |
196 | 198 | case 1: |
197 | 199 | include $base_path . MGR_DIR . '/includes/config.inc.php'; |
@@ -205,7 +207,9 @@ discard block |
||
205 | 207 | } |
206 | 208 | } |
207 | 209 | } |
208 | - if (empty ($database_collation)) $database_collation = 'utf8_general_ci'; |
|
210 | + if (empty ($database_collation)) { |
|
211 | + $database_collation = 'utf8_general_ci'; |
|
212 | + } |
|
209 | 213 | |
210 | 214 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
211 | 215 | if (!isset ($database_connection_charset) || empty ($database_connection_charset)) { |
@@ -214,7 +218,9 @@ discard block |
||
214 | 218 | |
215 | 219 | if (!isset ($database_connection_method) || empty ($database_connection_method)) { |
216 | 220 | $database_connection_method = 'SET CHARACTER SET'; |
217 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_connection_charset); |
|
221 | + if (function_exists('mysqli_set_charset')) { |
|
222 | + mysqli_set_charset($conn, $database_connection_charset); |
|
223 | + } |
|
218 | 224 | } |
219 | 225 | if ($database_connection_method != 'SET NAMES' && $database_connection_charset != $database_charset) { |
220 | 226 | $database_connection_method = 'SET NAMES'; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) { |
3 | 3 | include_once(dirname(__FILE__)."/../assets/cache/siteManager.php"); |
4 | -}else{ |
|
4 | +} else { |
|
5 | 5 | define('MGR_DIR', 'manager'); |
6 | 6 | } |
7 | 7 | define('MODX_CLI', false); |
@@ -59,13 +59,15 @@ discard block |
||
59 | 59 | |
60 | 60 | // get base path and url |
61 | 61 | $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"]))); |
62 | -if (count($a) > 1) |
|
62 | +if (count($a) > 1) { |
|
63 | 63 | array_pop($a); |
64 | +} |
|
64 | 65 | $url = implode("install", $a); |
65 | 66 | reset($a); |
66 | 67 | $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__)))); |
67 | -if (count($a) > 1) |
|
68 | +if (count($a) > 1) { |
|
68 | 69 | array_pop($a); |
70 | +} |
|
69 | 71 | $pth = implode("install", $a); |
70 | 72 | unset ($a); |
71 | 73 | $base_url = $url . (substr($url, -1) != "/" ? "/" : ""); |
@@ -86,7 +88,9 @@ discard block |
||
86 | 88 | echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>"; |
87 | 89 | $create = true; |
88 | 90 | } else { |
89 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset); |
|
91 | + if (function_exists('mysqli_set_charset')) { |
|
92 | + mysqli_set_charset($conn, $database_charset); |
|
93 | + } |
|
90 | 94 | mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); |
91 | 95 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
92 | 96 | } |
@@ -133,7 +137,8 @@ discard block |
||
133 | 137 | * @param string $propertyString |
134 | 138 | * @return array |
135 | 139 | */ |
136 | - function parseProperties($propertyString) { |
|
140 | + function parseProperties($propertyString) |
|
141 | + { |
|
137 | 142 | $parameter= array (); |
138 | 143 | if (!empty ($propertyString)) { |
139 | 144 | $tmpParams= explode("&", $propertyString); |
@@ -142,11 +147,14 @@ discard block |
||
142 | 147 | if (strpos($tmpParams[$x], '=', 0)) { |
143 | 148 | $pTmp= explode("=", $tmpParams[$x]); |
144 | 149 | $pvTmp= explode(";", trim($pTmp[1])); |
145 | - if ($pvTmp[1] == 'list' && $pvTmp[3] != "") |
|
146 | - $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default |
|
150 | + if ($pvTmp[1] == 'list' && $pvTmp[3] != "") { |
|
151 | + $parameter[trim($pTmp[0])]= $pvTmp[3]; |
|
152 | + } |
|
153 | + //list default |
|
147 | 154 | else |
148 | - if ($pvTmp[1] != 'list' && $pvTmp[2] != "") |
|
149 | - $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
155 | + if ($pvTmp[1] != 'list' && $pvTmp[2] != "") { |
|
156 | + $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
157 | + } |
|
150 | 158 | } |
151 | 159 | } |
152 | 160 | } |
@@ -217,7 +225,7 @@ discard block |
||
217 | 225 | // custom or not |
218 | 226 | if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) { |
219 | 227 | $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");'; |
220 | -}else{ |
|
228 | +} else { |
|
221 | 229 | $mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
222 | 230 | } |
223 | 231 | |
@@ -353,7 +361,9 @@ discard block |
||
353 | 361 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
354 | 362 | return; |
355 | 363 | } |
356 | - if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
364 | + if(!is_null($save_sql_id_as)) { |
|
365 | + $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
366 | + } |
|
357 | 367 | echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
358 | 368 | } |
359 | 369 | } |
@@ -447,9 +457,9 @@ discard block |
||
447 | 457 | $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]); |
448 | 458 | $filecontent = $moduleChunk[2]; |
449 | 459 | |
450 | - if (!file_exists($filecontent)) |
|
451 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
452 | - else { |
|
460 | + if (!file_exists($filecontent)) { |
|
461 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
462 | + } else { |
|
453 | 463 | |
454 | 464 | // Create the category if it does not already exist |
455 | 465 | $category_id = getCreateDbCategory($category, $sqlParser); |
@@ -501,9 +511,9 @@ discard block |
||
501 | 511 | $guid = mysqli_real_escape_string($conn, $moduleModule[4]); |
502 | 512 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
503 | 513 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
504 | - if (!file_exists($filecontent)) |
|
505 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
506 | - else { |
|
514 | + if (!file_exists($filecontent)) { |
|
515 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
516 | + } else { |
|
507 | 517 | |
508 | 518 | // Create the category if it does not already exist |
509 | 519 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -553,9 +563,9 @@ discard block |
||
553 | 563 | // parse comma-separated legacy names and prepare them for sql IN clause |
554 | 564 | $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
555 | 565 | } |
556 | - if (!file_exists($filecontent)) |
|
557 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
558 | - else { |
|
566 | + if (!file_exists($filecontent)) { |
|
567 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
568 | + } else { |
|
559 | 569 | |
560 | 570 | // disable legacy versions based on legacy_names provided |
561 | 571 | if(!empty($leg_names)) { |
@@ -574,7 +584,7 @@ discard block |
||
574 | 584 | $insert = true; |
575 | 585 | while($row = mysqli_fetch_assoc($rs)) { |
576 | 586 | $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
577 | - if($row['description'] == $desc){ |
|
587 | + if($row['description'] == $desc) { |
|
578 | 588 | if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
579 | 589 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
580 | 590 | return; |
@@ -632,9 +642,9 @@ discard block |
||
632 | 642 | $filecontent = $moduleSnippet[2]; |
633 | 643 | $properties = $moduleSnippet[3]; |
634 | 644 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
635 | - if (!file_exists($filecontent)) |
|
636 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
637 | - else { |
|
645 | + if (!file_exists($filecontent)) { |
|
646 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
647 | + } else { |
|
638 | 648 | |
639 | 649 | // Create the category if it does not already exist |
640 | 650 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -742,13 +752,16 @@ discard block |
||
742 | 752 | } |
743 | 753 | |
744 | 754 | // call back function |
745 | -if ($callBackFnc != "") |
|
755 | +if ($callBackFnc != "") { |
|
746 | 756 | $callBackFnc ($sqlParser); |
757 | +} |
|
747 | 758 | |
748 | 759 | // Setup the MODX API -- needed for the cache processor |
749 | 760 | define('MODX_API_MODE', true); |
750 | 761 | define('MODX_BASE_PATH', $base_path); |
751 | -if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
762 | +if (!defined('MODX_MANAGER_PATH')) { |
|
763 | + define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
764 | +} |
|
752 | 765 | $database_type = 'mysqli'; |
753 | 766 | // initiate a new document parser |
754 | 767 | include_once('../'.MGR_DIR.'/includes/document.parser.class.inc.php'); |
@@ -793,11 +806,12 @@ discard block |
||
793 | 806 | * @param string $old |
794 | 807 | * @return string |
795 | 808 | */ |
796 | -function propUpdate($new,$old){ |
|
809 | +function propUpdate($new,$old) |
|
810 | +{ |
|
797 | 811 | $newArr = parseProperties($new); |
798 | 812 | $oldArr = parseProperties($old); |
799 | - foreach ($oldArr as $k => $v){ |
|
800 | - if (isset($v['0']['options'])){ |
|
813 | + foreach ($oldArr as $k => $v) { |
|
814 | + if (isset($v['0']['options'])) { |
|
801 | 815 | $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options']; |
802 | 816 | } |
803 | 817 | } |
@@ -812,12 +826,17 @@ discard block |
||
812 | 826 | * @param bool|mixed $json |
813 | 827 | * @return string |
814 | 828 | */ |
815 | -function parseProperties($propertyString, $json=false) { |
|
829 | +function parseProperties($propertyString, $json=false) |
|
830 | +{ |
|
816 | 831 | $propertyString = str_replace('{}', '', $propertyString ); |
817 | 832 | $propertyString = str_replace('} {', ',', $propertyString ); |
818 | 833 | |
819 | - if(empty($propertyString)) return array(); |
|
820 | - if($propertyString=='{}' || $propertyString=='[]') return array(); |
|
834 | + if(empty($propertyString)) { |
|
835 | + return array(); |
|
836 | + } |
|
837 | + if($propertyString=='{}' || $propertyString=='[]') { |
|
838 | + return array(); |
|
839 | + } |
|
821 | 840 | |
822 | 841 | $jsonFormat = isJson($propertyString, true); |
823 | 842 | $property = array(); |
@@ -859,7 +878,7 @@ discard block |
||
859 | 878 | |
860 | 879 | } |
861 | 880 | // new json-format |
862 | - } else if(!empty($jsonFormat)){ |
|
881 | + } else if(!empty($jsonFormat)) { |
|
863 | 882 | $property = $jsonFormat; |
864 | 883 | } |
865 | 884 | if ($json) { |
@@ -874,7 +893,8 @@ discard block |
||
874 | 893 | * @param bool $returnData |
875 | 894 | * @return bool|mixed |
876 | 895 | */ |
877 | -function isJson($string, $returnData=false) { |
|
896 | +function isJson($string, $returnData=false) |
|
897 | +{ |
|
878 | 898 | $data = json_decode($string, true); |
879 | 899 | return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false; |
880 | 900 | } |
@@ -884,7 +904,8 @@ discard block |
||
884 | 904 | * @param SqlParser $sqlParser |
885 | 905 | * @return int |
886 | 906 | */ |
887 | -function getCreateDbCategory($category, $sqlParser) { |
|
907 | +function getCreateDbCategory($category, $sqlParser) |
|
908 | +{ |
|
888 | 909 | $dbase = $sqlParser->dbname; |
889 | 910 | $dbase = '`' . trim($dbase,'`') . '`'; |
890 | 911 | $table_prefix = $sqlParser->prefix; |
@@ -912,7 +933,8 @@ discard block |
||
912 | 933 | * @param string $type |
913 | 934 | * @return string |
914 | 935 | */ |
915 | -function removeDocblock($code, $type) { |
|
936 | +function removeDocblock($code, $type) |
|
937 | +{ |
|
916 | 938 | |
917 | 939 | $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1); |
918 | 940 | |
@@ -933,8 +955,9 @@ discard block |
||
933 | 955 | default: |
934 | 956 | return $cleaned; |
935 | 957 | }; |
936 | - if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
937 | - return $cleaned; |
|
958 | + if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') { |
|
959 | + return $cleaned; |
|
960 | + } |
|
938 | 961 | |
939 | 962 | // fileBinding not found - return code incl docblock |
940 | 963 | return $code; |
@@ -5,7 +5,8 @@ |
||
5 | 5 | * @deprecated EvolutionCMS\Legacy\ErrorHandler |
6 | 6 | * @todo could be unnecessary |
7 | 7 | */ |
8 | -class errorHandler extends EvolutionCMS\Legacy\ErrorHandler { |
|
8 | +class errorHandler extends EvolutionCMS\Legacy\ErrorHandler |
|
9 | +{ |
|
9 | 10 | public function include_lang($context = 'common') |
10 | 11 | { |
11 | 12 | parent::includeLang($context); |