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