@@ -183,53 +183,53 @@ |
||
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | switch($installMode){ |
| 186 | - case 0: |
|
| 187 | - case 2: |
|
| 188 | - $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci'; |
|
| 189 | - $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
|
| 190 | - $_POST['database_connection_charset'] = $database_charset; |
|
| 191 | - if(!empty($_POST['databaseloginpassword'])) |
|
| 192 | - $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
|
| 193 | - if(!empty($_POST['databaseloginname'])) |
|
| 194 | - $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
|
| 195 | - break; |
|
| 196 | - case 1: |
|
| 197 | - include $base_path . MGR_DIR . '/includes/config.inc.php'; |
|
| 198 | - if (@ $conn = mysqli_connect($database_server, $database_user, $database_password)) { |
|
| 199 | - if (@ mysqli_query($conn, "USE {$dbase}")) { |
|
| 200 | - if (!$rs = mysqli_query($conn, "show session variables like 'collation_database'")) { |
|
| 201 | - $rs = mysqli_query($conn, "show session variables like 'collation_server'"); |
|
| 202 | - } |
|
| 203 | - if ($rs && $collation = mysqli_fetch_row($rs)) { |
|
| 204 | - $database_collation = trim($collation[1]); |
|
| 186 | + case 0: |
|
| 187 | + case 2: |
|
| 188 | + $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci'; |
|
| 189 | + $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
|
| 190 | + $_POST['database_connection_charset'] = $database_charset; |
|
| 191 | + if(!empty($_POST['databaseloginpassword'])) |
|
| 192 | + $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
|
| 193 | + if(!empty($_POST['databaseloginname'])) |
|
| 194 | + $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
|
| 195 | + break; |
|
| 196 | + case 1: |
|
| 197 | + include $base_path . MGR_DIR . '/includes/config.inc.php'; |
|
| 198 | + if (@ $conn = mysqli_connect($database_server, $database_user, $database_password)) { |
|
| 199 | + if (@ mysqli_query($conn, "USE {$dbase}")) { |
|
| 200 | + if (!$rs = mysqli_query($conn, "show session variables like 'collation_database'")) { |
|
| 201 | + $rs = mysqli_query($conn, "show session variables like 'collation_server'"); |
|
| 202 | + } |
|
| 203 | + if ($rs && $collation = mysqli_fetch_row($rs)) { |
|
| 204 | + $database_collation = trim($collation[1]); |
|
| 205 | + } |
|
| 205 | 206 | } |
| 206 | 207 | } |
| 207 | - } |
|
| 208 | - if (empty ($database_collation)) $database_collation = 'utf8_general_ci'; |
|
| 208 | + if (empty ($database_collation)) $database_collation = 'utf8_general_ci'; |
|
| 209 | 209 | |
| 210 | - $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
|
| 211 | - if (!isset ($database_connection_charset) || empty ($database_connection_charset)) { |
|
| 212 | - $database_connection_charset = $database_charset; |
|
| 213 | - } |
|
| 210 | + $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
|
| 211 | + if (!isset ($database_connection_charset) || empty ($database_connection_charset)) { |
|
| 212 | + $database_connection_charset = $database_charset; |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - if (!isset ($database_connection_method) || empty ($database_connection_method)) { |
|
| 216 | - $database_connection_method = 'SET CHARACTER SET'; |
|
| 217 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_connection_charset); |
|
| 218 | - } |
|
| 219 | - if ($database_connection_method != 'SET NAMES' && $database_connection_charset != $database_charset) { |
|
| 220 | - $database_connection_method = 'SET NAMES'; |
|
| 221 | - } |
|
| 215 | + if (!isset ($database_connection_method) || empty ($database_connection_method)) { |
|
| 216 | + $database_connection_method = 'SET CHARACTER SET'; |
|
| 217 | + if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_connection_charset); |
|
| 218 | + } |
|
| 219 | + if ($database_connection_method != 'SET NAMES' && $database_connection_charset != $database_charset) { |
|
| 220 | + $database_connection_method = 'SET NAMES'; |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - $_POST['database_name'] = $dbase; |
|
| 224 | - $_POST['tableprefix'] = $table_prefix; |
|
| 225 | - $_POST['database_connection_charset'] = $database_connection_charset; |
|
| 226 | - $_POST['database_connection_method'] = $database_connection_method; |
|
| 227 | - $_POST['databasehost'] = $database_server; |
|
| 228 | - $_SESSION['databaseloginname'] = $database_user; |
|
| 229 | - $_SESSION['databaseloginpassword'] = $database_password; |
|
| 230 | - break; |
|
| 231 | - default: |
|
| 232 | - throw new Exception('installmode is undefined'); |
|
| 223 | + $_POST['database_name'] = $dbase; |
|
| 224 | + $_POST['tableprefix'] = $table_prefix; |
|
| 225 | + $_POST['database_connection_charset'] = $database_connection_charset; |
|
| 226 | + $_POST['database_connection_method'] = $database_connection_method; |
|
| 227 | + $_POST['databasehost'] = $database_server; |
|
| 228 | + $_SESSION['databaseloginname'] = $database_user; |
|
| 229 | + $_SESSION['databaseloginpassword'] = $database_password; |
|
| 230 | + break; |
|
| 231 | + default: |
|
| 232 | + throw new Exception('installmode is undefined'); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | $ph['install_language'] = $install_language; |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -$installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0; |
|
| 2 | +$installMode = isset($_POST['installmode']) ? (int) $_POST['installmode'] : 0; |
|
| 3 | 3 | |
| 4 | -if( ! function_exists('getTemplates')) { |
|
| 4 | +if (!function_exists('getTemplates')) { |
|
| 5 | 5 | /** |
| 6 | 6 | * @param array $presets |
| 7 | 7 | * @return string |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | $_[] = parse($tpl, $ph); |
| 26 | 26 | $i++; |
| 27 | 27 | } |
| 28 | - return (0 < count($_)) ? '<h3>[%templates%]</h3>' . implode("\n", $_) : ''; |
|
| 28 | + return (0 < count($_)) ? '<h3>[%templates%]</h3>'.implode("\n", $_) : ''; |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -if( ! function_exists('getTVs')) { |
|
| 32 | +if (!function_exists('getTVs')) { |
|
| 33 | 33 | /** |
| 34 | 34 | * @param array $presets |
| 35 | 35 | * @return string |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | $_[] = parse($tpl, $ph); |
| 55 | 55 | $i++; |
| 56 | 56 | } |
| 57 | - return (0 < count($_)) ? '<h3>[%tvs%]</h3>' . implode("\n", $_) : ''; |
|
| 57 | + return (0 < count($_)) ? '<h3>[%tvs%]</h3>'.implode("\n", $_) : ''; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | -if( ! function_exists('getChunks')) { |
|
| 61 | +if (!function_exists('getChunks')) { |
|
| 62 | 62 | /** |
| 63 | 63 | * display chunks |
| 64 | 64 | * |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | $_[] = parse($tpl, $ph); |
| 85 | 85 | $i++; |
| 86 | 86 | } |
| 87 | - return (0 < count($_)) ? '<h3>[%chunks%]</h3>' . implode("\n", $_) : ''; |
|
| 87 | + return (0 < count($_)) ? '<h3>[%chunks%]</h3>'.implode("\n", $_) : ''; |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | -if( ! function_exists('getModules')) { |
|
| 91 | +if (!function_exists('getModules')) { |
|
| 92 | 92 | /** |
| 93 | 93 | * display modules |
| 94 | 94 | * |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | $_[] = parse($tpl, $ph); |
| 115 | 115 | $i++; |
| 116 | 116 | } |
| 117 | - return (0 < count($_)) ? '<h3>[%modules%]</h3>' . implode("\n", $_) : ''; |
|
| 117 | + return (0 < count($_)) ? '<h3>[%modules%]</h3>'.implode("\n", $_) : ''; |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | -if( ! function_exists('getPlugins')) { |
|
| 121 | +if (!function_exists('getPlugins')) { |
|
| 122 | 122 | /** |
| 123 | 123 | * display plugins |
| 124 | 124 | * |
@@ -148,11 +148,11 @@ discard block |
||
| 148 | 148 | $_[] = parse($tpl, $ph); |
| 149 | 149 | $i++; |
| 150 | 150 | } |
| 151 | - return (0 < count($_)) ? '<h3>[%plugins%]</h3>' . implode("\n", $_) : ''; |
|
| 151 | + return (0 < count($_)) ? '<h3>[%plugins%]</h3>'.implode("\n", $_) : ''; |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | -if( ! function_exists('getSnippets')) { |
|
| 155 | +if (!function_exists('getSnippets')) { |
|
| 156 | 156 | /** |
| 157 | 157 | * display snippets |
| 158 | 158 | * |
@@ -178,23 +178,23 @@ discard block |
||
| 178 | 178 | $_[] = parse($tpl, $ph); |
| 179 | 179 | $i++; |
| 180 | 180 | } |
| 181 | - return (0 < count($_)) ? '<h3>[%snippets%]</h3>' . implode("\n", $_) : ''; |
|
| 181 | + return (0 < count($_)) ? '<h3>[%snippets%]</h3>'.implode("\n", $_) : ''; |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | -switch($installMode){ |
|
| 185 | +switch ($installMode) { |
|
| 186 | 186 | case 0: |
| 187 | 187 | case 2: |
| 188 | 188 | $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci'; |
| 189 | 189 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
| 190 | 190 | $_POST['database_connection_charset'] = $database_charset; |
| 191 | - if(!empty($_POST['databaseloginpassword'])) |
|
| 191 | + if (!empty($_POST['databaseloginpassword'])) |
|
| 192 | 192 | $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
| 193 | - if(!empty($_POST['databaseloginname'])) |
|
| 193 | + if (!empty($_POST['databaseloginname'])) |
|
| 194 | 194 | $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
| 195 | 195 | break; |
| 196 | 196 | case 1: |
| 197 | - include $base_path . MGR_DIR . '/includes/config.inc.php'; |
|
| 197 | + include $base_path.MGR_DIR.'/includes/config.inc.php'; |
|
| 198 | 198 | if (@ $conn = mysqli_connect($database_server, $database_user, $database_password)) { |
| 199 | 199 | if (@ mysqli_query($conn, "USE {$dbase}")) { |
| 200 | 200 | if (!$rs = mysqli_query($conn, "show session variables like 'collation_database'")) { |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $ph['checked'] = isset ($_POST['installdata']) && $_POST['installdata'] == "1" ? 'checked' : ''; |
| 250 | 250 | |
| 251 | 251 | # load setup information file |
| 252 | -include($base_path . 'install/setup.info.php'); |
|
| 252 | +include($base_path.'install/setup.info.php'); |
|
| 253 | 253 | $ph['templates'] = getTemplates($moduleTemplates); |
| 254 | 254 | $ph['tvs'] = getTVs($moduleTVs); |
| 255 | 255 | $ph['chunks'] = getChunks($moduleChunks); |
@@ -259,6 +259,6 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | $ph['action'] = ($installMode == 1) ? 'mode' : 'connection'; |
| 261 | 261 | |
| 262 | -$tpl = file_get_contents($base_path . 'install/actions/tpl_options.html'); |
|
| 263 | -$content = parse($tpl,$ph); |
|
| 264 | -echo parse($content,$_lang,'[%','%]'); |
|
| 262 | +$tpl = file_get_contents($base_path.'install/actions/tpl_options.html'); |
|
| 263 | +$content = parse($tpl, $ph); |
|
| 264 | +echo parse($content, $_lang, '[%', '%]'); |
|
@@ -182,16 +182,18 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | -switch($installMode){ |
|
| 185 | +switch($installMode) { |
|
| 186 | 186 | case 0: |
| 187 | 187 | case 2: |
| 188 | 188 | $database_collation = isset($_POST['database_collation']) ? $_POST['database_collation'] : 'utf8_general_ci'; |
| 189 | 189 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
| 190 | 190 | $_POST['database_connection_charset'] = $database_charset; |
| 191 | - if(!empty($_POST['databaseloginpassword'])) |
|
| 192 | - $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
|
| 193 | - if(!empty($_POST['databaseloginname'])) |
|
| 194 | - $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
|
| 191 | + if(!empty($_POST['databaseloginpassword'])) { |
|
| 192 | + $_SESSION['databaseloginpassword'] = $_POST['databaseloginpassword']; |
|
| 193 | + } |
|
| 194 | + if(!empty($_POST['databaseloginname'])) { |
|
| 195 | + $_SESSION['databaseloginname'] = $_POST['databaseloginname']; |
|
| 196 | + } |
|
| 195 | 197 | break; |
| 196 | 198 | case 1: |
| 197 | 199 | include $base_path . MGR_DIR . '/includes/config.inc.php'; |
@@ -205,7 +207,9 @@ discard block |
||
| 205 | 207 | } |
| 206 | 208 | } |
| 207 | 209 | } |
| 208 | - if (empty ($database_collation)) $database_collation = 'utf8_general_ci'; |
|
| 210 | + if (empty ($database_collation)) { |
|
| 211 | + $database_collation = 'utf8_general_ci'; |
|
| 212 | + } |
|
| 209 | 213 | |
| 210 | 214 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
| 211 | 215 | if (!isset ($database_connection_charset) || empty ($database_connection_charset)) { |
@@ -214,7 +218,9 @@ discard block |
||
| 214 | 218 | |
| 215 | 219 | if (!isset ($database_connection_method) || empty ($database_connection_method)) { |
| 216 | 220 | $database_connection_method = 'SET CHARACTER SET'; |
| 217 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_connection_charset); |
|
| 221 | + if (function_exists('mysqli_set_charset')) { |
|
| 222 | + mysqli_set_charset($conn, $database_connection_charset); |
|
| 223 | + } |
|
| 218 | 224 | } |
| 219 | 225 | if ($database_connection_method != 'SET NAMES' && $database_connection_charset != $database_charset) { |
| 220 | 226 | $database_connection_method = 'SET NAMES'; |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) { |
| 3 | 3 | include_once(dirname(__FILE__)."/../assets/cache/siteManager.php"); |
| 4 | -}else{ |
|
| 4 | +} else { |
|
| 5 | 5 | define('MGR_DIR', 'manager'); |
| 6 | 6 | } |
| 7 | 7 | define('MODX_CLI', false); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | echo "<p>{$_lang['setup_database']}</p>\n"; |
| 31 | 31 | |
| 32 | -$installMode= (int)$_POST['installmode']; |
|
| 32 | +$installMode = (int) $_POST['installmode']; |
|
| 33 | 33 | $installData = $_POST['installdata'] == "1" ? 1 : 0; |
| 34 | 34 | |
| 35 | 35 | //if ($installMode == 1) { |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); |
| 44 | 44 | $database_connection_charset = $_POST['database_connection_charset']; |
| 45 | 45 | $database_connection_method = $_POST['database_connection_method']; |
| 46 | -$dbase = "`" . $_POST['database_name'] . "`"; |
|
| 46 | +$dbase = "`".$_POST['database_name']."`"; |
|
| 47 | 47 | $table_prefix = $_POST['tableprefix']; |
| 48 | 48 | $adminname = $_POST['cmsadmin']; |
| 49 | 49 | $adminemail = $_POST['cmsadminemail']; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | // set session name variable |
| 56 | 56 | if (!isset ($site_sessionname)) { |
| 57 | - $site_sessionname = 'SN' . uniqid(''); |
|
| 57 | + $site_sessionname = 'SN'.uniqid(''); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // get base path and url |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | array_pop($a); |
| 69 | 69 | $pth = implode("install", $a); |
| 70 | 70 | unset ($a); |
| 71 | -$base_url = $url . (substr($url, -1) != "/" ? "/" : ""); |
|
| 72 | -$base_path = $pth . (substr($pth, -1) != "/" ? "/" : ""); |
|
| 71 | +$base_url = $url.(substr($url, -1) != "/" ? "/" : ""); |
|
| 72 | +$base_path = $pth.(substr($pth, -1) != "/" ? "/" : ""); |
|
| 73 | 73 | |
| 74 | 74 | // connect to the database |
| 75 | -echo "<p>". $_lang['setup_database_create_connection']; |
|
| 75 | +echo "<p>".$_lang['setup_database_create_connection']; |
|
| 76 | 76 | if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) { |
| 77 | 77 | echo '<span class="notok">'.$_lang["setup_database_create_connection_failed"]."</span></p><p>".$_lang['setup_database_create_connection_failed_note']."</p>"; |
| 78 | 78 | return; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // select database |
| 84 | -echo "<p>".$_lang['setup_database_selection']. str_replace("`", "", $dbase) . "`: "; |
|
| 84 | +echo "<p>".$_lang['setup_database_selection'].str_replace("`", "", $dbase)."`: "; |
|
| 85 | 85 | if (!mysqli_select_db($conn, str_replace("`", "", $dbase))) { |
| 86 | 86 | echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>"; |
| 87 | 87 | $create = true; |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | // try to create the database |
| 95 | 95 | if ($create) { |
| 96 | - echo "<p>".$_lang['setup_database_creation']. str_replace("`", "", $dbase) . "`: "; |
|
| 96 | + echo "<p>".$_lang['setup_database_creation'].str_replace("`", "", $dbase)."`: "; |
|
| 97 | 97 | // if(!@mysqli_create_db(str_replace("`","",$dbase), $conn)) { |
| 98 | - if (! mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) { |
|
| 98 | + if (!mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) { |
|
| 99 | 99 | echo '<span class="notok">'.$_lang['setup_database_creation_failed']."</span>".$_lang['setup_database_creation_failed_note']."</p>"; |
| 100 | 100 | $errors += 1; |
| 101 | 101 | ?> |
@@ -114,18 +114,18 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | // check table prefix |
| 116 | 116 | if ($installMode == 0) { |
| 117 | - echo "<p>" . $_lang['checking_table_prefix'] . $table_prefix . "`: "; |
|
| 118 | - if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) { |
|
| 119 | - echo '<span class="notok">' . $_lang['failed'] . "</span>" . $_lang['table_prefix_already_inuse'] . "</p>"; |
|
| 117 | + echo "<p>".$_lang['checking_table_prefix'].$table_prefix."`: "; |
|
| 118 | + if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`".$table_prefix."site_content`")) { |
|
| 119 | + echo '<span class="notok">'.$_lang['failed']."</span>".$_lang['table_prefix_already_inuse']."</p>"; |
|
| 120 | 120 | $errors += 1; |
| 121 | - echo "<p>" . $_lang['table_prefix_already_inuse_note'] . "</p>"; |
|
| 121 | + echo "<p>".$_lang['table_prefix_already_inuse_note']."</p>"; |
|
| 122 | 122 | return; |
| 123 | 123 | } else { |
| 124 | 124 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | -if(!function_exists('parseProperties')) { |
|
| 128 | +if (!function_exists('parseProperties')) { |
|
| 129 | 129 | /** |
| 130 | 130 | * parses a resource property string and returns the result as an array |
| 131 | 131 | * duplicate of method in documentParser class |
@@ -133,20 +133,20 @@ discard block |
||
| 133 | 133 | * @param string $propertyString |
| 134 | 134 | * @return array |
| 135 | 135 | */ |
| 136 | - function parseProperties($propertyString) { |
|
| 137 | - $parameter= array (); |
|
| 136 | + function parseProperties($propertyString){ |
|
| 137 | + $parameter = array(); |
|
| 138 | 138 | if (!empty ($propertyString)) { |
| 139 | - $tmpParams= explode("&", $propertyString); |
|
| 139 | + $tmpParams = explode("&", $propertyString); |
|
| 140 | 140 | $countParams = count($tmpParams); |
| 141 | - for ($x= 0; $x < $countParams; $x++) { |
|
| 141 | + for ($x = 0; $x < $countParams; $x++) { |
|
| 142 | 142 | if (strpos($tmpParams[$x], '=', 0)) { |
| 143 | - $pTmp= explode("=", $tmpParams[$x]); |
|
| 144 | - $pvTmp= explode(";", trim($pTmp[1])); |
|
| 143 | + $pTmp = explode("=", $tmpParams[$x]); |
|
| 144 | + $pvTmp = explode(";", trim($pTmp[1])); |
|
| 145 | 145 | if ($pvTmp[1] == 'list' && $pvTmp[3] != "") |
| 146 | - $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default |
|
| 146 | + $parameter[trim($pTmp[0])] = $pvTmp[3]; //list default |
|
| 147 | 147 | else |
| 148 | 148 | if ($pvTmp[1] != 'list' && $pvTmp[2] != "") |
| 149 | - $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 149 | + $parameter[trim($pTmp[0])] = $pvTmp[2]; |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | } |
@@ -157,20 +157,20 @@ discard block |
||
| 157 | 157 | // check status of Inherit Parent Template plugin |
| 158 | 158 | $auto_template_logic = 'parent'; |
| 159 | 159 | if ($installMode != 0) { |
| 160 | - $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='Inherit Parent Template'"); |
|
| 160 | + $rs = mysqli_query($conn, "SELECT properties, disabled FROM $dbase.`".$table_prefix."site_plugins` WHERE name='Inherit Parent Template'"); |
|
| 161 | 161 | $row = mysqli_fetch_row($rs); |
| 162 | - if(!$row) { |
|
| 162 | + if (!$row) { |
|
| 163 | 163 | // not installed |
| 164 | 164 | $auto_template_logic = 'system'; |
| 165 | 165 | } else { |
| 166 | - if($row[1] == 1) { |
|
| 166 | + if ($row[1] == 1) { |
|
| 167 | 167 | // installed but disabled |
| 168 | 168 | $auto_template_logic = 'system'; |
| 169 | 169 | } else { |
| 170 | 170 | // installed, enabled .. see how it's configured |
| 171 | 171 | $properties = parseProperties($row[0]); |
| 172 | - if(isset($properties['inheritTemplate'])) { |
|
| 173 | - if($properties['inheritTemplate'] == 'From First Sibling') { |
|
| 172 | + if (isset($properties['inheritTemplate'])) { |
|
| 173 | + if ($properties['inheritTemplate'] == 'From First Sibling') { |
|
| 174 | 174 | $auto_template_logic = 'sibling'; |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -194,20 +194,20 @@ discard block |
||
| 194 | 194 | $sqlParser->connect(); |
| 195 | 195 | |
| 196 | 196 | // install/update database |
| 197 | -echo "<p>" . $_lang['setup_database_creating_tables']; |
|
| 197 | +echo "<p>".$_lang['setup_database_creating_tables']; |
|
| 198 | 198 | if ($moduleSQLBaseFile) { |
| 199 | 199 | $sqlParser->process($moduleSQLBaseFile); |
| 200 | 200 | // display database results |
| 201 | 201 | if ($sqlParser->installFailed == true) { |
| 202 | 202 | $errors += 1; |
| 203 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
| 204 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
| 205 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
| 203 | + echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>"; |
|
| 204 | + echo "<p>".$_lang['setup_couldnt_install']."</p>"; |
|
| 205 | + echo "<p>".$_lang['installation_error_occured']."<br /><br />"; |
|
| 206 | 206 | for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
| 207 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
| 207 | + echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />"; |
|
| 208 | 208 | } |
| 209 | 209 | echo "</p>"; |
| 210 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
| 210 | + echo "<p>".$_lang['some_tables_not_updated']."</p>"; |
|
| 211 | 211 | return; |
| 212 | 212 | } else { |
| 213 | 213 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
@@ -217,12 +217,12 @@ discard block |
||
| 217 | 217 | // custom or not |
| 218 | 218 | if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) { |
| 219 | 219 | $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");'; |
| 220 | -}else{ |
|
| 220 | +} else { |
|
| 221 | 221 | $mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // write the config.inc.php file if new installation |
| 225 | -echo "<p>" . $_lang['writing_config_file']; |
|
| 225 | +echo "<p>".$_lang['writing_config_file']; |
|
| 226 | 226 | |
| 227 | 227 | $confph = array(); |
| 228 | 228 | $confph['database_server'] = $database_server; |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $chmodSuccess = @chmod($filename, 0404); |
| 255 | 255 | |
| 256 | 256 | if ($configFileFailed == true) { |
| 257 | - echo '<span class="notok">' . $_lang['failed'] . "</span></p>"; |
|
| 257 | + echo '<span class="notok">'.$_lang['failed']."</span></p>"; |
|
| 258 | 258 | $errors += 1; |
| 259 | 259 | ?> |
| 260 | 260 | <p><?php echo $_lang['cant_write_config_file']?><span class="mono"><?php echo MGR_DIR; ?>/includes/config.inc.php</span></p> |
@@ -271,35 +271,35 @@ discard block |
||
| 271 | 271 | // generate new site_id and set manager theme to default |
| 272 | 272 | if ($installMode == 0) { |
| 273 | 273 | $siteid = uniqid(''); |
| 274 | - mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')"); |
|
| 274 | + mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid'),('manager_theme','default')"); |
|
| 275 | 275 | } else { |
| 276 | 276 | // update site_id if missing |
| 277 | - $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`" . $table_prefix . "system_settings` WHERE setting_name='site_id'"); |
|
| 277 | + $ds = mysqli_query($sqlParser->conn, "SELECT setting_name,setting_value FROM $dbase.`".$table_prefix."system_settings` WHERE setting_name='site_id'"); |
|
| 278 | 278 | if ($ds) { |
| 279 | 279 | $r = mysqli_fetch_assoc($ds); |
| 280 | 280 | $siteid = $r['setting_value']; |
| 281 | 281 | if ($siteid == '' || $siteid = 'MzGeQ2faT4Dw06+U49x3') { |
| 282 | 282 | $siteid = uniqid(''); |
| 283 | - mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`" . $table_prefix . "system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')"); |
|
| 283 | + mysqli_query($sqlParser->conn, "REPLACE INTO $dbase.`".$table_prefix."system_settings` (setting_name,setting_value) VALUES('site_id','$siteid')"); |
|
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | // Reset database for installation of demo-site |
| 289 | 289 | if ($installData && $moduleSQLDataFile && $moduleSQLResetFile) { |
| 290 | - echo "<p>" . $_lang['resetting_database']; |
|
| 290 | + echo "<p>".$_lang['resetting_database']; |
|
| 291 | 291 | $sqlParser->process($moduleSQLResetFile); |
| 292 | 292 | // display database results |
| 293 | 293 | if ($sqlParser->installFailed == true) { |
| 294 | 294 | $errors += 1; |
| 295 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
| 296 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
| 297 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
| 295 | + echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>"; |
|
| 296 | + echo "<p>".$_lang['setup_couldnt_install']."</p>"; |
|
| 297 | + echo "<p>".$_lang['installation_error_occured']."<br /><br />"; |
|
| 298 | 298 | for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
| 299 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
| 299 | + echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />"; |
|
| 300 | 300 | } |
| 301 | 301 | echo "</p>"; |
| 302 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
| 302 | + echo "<p>".$_lang['some_tables_not_updated']."</p>"; |
|
| 303 | 303 | return; |
| 304 | 304 | } else { |
| 305 | 305 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
@@ -308,11 +308,11 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | // Install Templates |
| 310 | 310 | if (isset ($_POST['template']) || $installData) { |
| 311 | - echo "<h3>" . $_lang['templates'] . ":</h3> "; |
|
| 311 | + echo "<h3>".$_lang['templates'].":</h3> "; |
|
| 312 | 312 | $selTemplates = $_POST['template']; |
| 313 | 313 | foreach ($moduleTemplates as $k=>$moduleTemplate) { |
| 314 | 314 | $installSample = in_array('sample', $moduleTemplate[6]) && $installData == 1; |
| 315 | - if($installSample || in_array($k, $selTemplates)) { |
|
| 315 | + if ($installSample || in_array($k, $selTemplates)) { |
|
| 316 | 316 | $name = mysqli_real_escape_string($conn, $moduleTemplate[0]); |
| 317 | 317 | $desc = mysqli_real_escape_string($conn, $moduleTemplate[1]); |
| 318 | 318 | $category = mysqli_real_escape_string($conn, $moduleTemplate[4]); |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | $filecontent = $moduleTemplate[3]; |
| 321 | 321 | $save_sql_id_as = $moduleTemplate[7]; // Nessecary for demo-site |
| 322 | 322 | if (!file_exists($filecontent)) { |
| 323 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_template'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 323 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_template']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 324 | 324 | } else { |
| 325 | 325 | // Create the category if it does not already exist |
| 326 | 326 | $category_id = getCreateDbCategory($category, $sqlParser); |
@@ -330,31 +330,31 @@ discard block |
||
| 330 | 330 | $template = mysqli_real_escape_string($conn, $template); |
| 331 | 331 | |
| 332 | 332 | // See if the template already exists |
| 333 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name'"); |
|
| 333 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name'"); |
|
| 334 | 334 | |
| 335 | 335 | if (mysqli_num_rows($rs)) { |
| 336 | - 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;")) { |
|
| 336 | + 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;")) { |
|
| 337 | 337 | $errors += 1; |
| 338 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 338 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 339 | 339 | return; |
| 340 | 340 | } |
| 341 | - if(!is_null($save_sql_id_as)) { |
|
| 341 | + if (!is_null($save_sql_id_as)) { |
|
| 342 | 342 | $sql_id = @mysqli_insert_id($sqlParser->conn); |
| 343 | - if(!$sql_id) { |
|
| 344 | - $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`" . $table_prefix . "site_templates` WHERE templatename='$name' LIMIT 1;")); |
|
| 343 | + if (!$sql_id) { |
|
| 344 | + $idQuery = mysqli_fetch_assoc(mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$name' LIMIT 1;")); |
|
| 345 | 345 | $sql_id = $idQuery['id']; |
| 346 | 346 | } |
| 347 | 347 | $custom_placeholders[$save_sql_id_as] = $sql_id; |
| 348 | 348 | } |
| 349 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 349 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 350 | 350 | } else { |
| 351 | - if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) { |
|
| 351 | + if (!@ mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_templates` (templatename,description,content,category,locked) VALUES('$name','$desc','$template',$category_id,'$locked');")) { |
|
| 352 | 352 | $errors += 1; |
| 353 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 353 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 354 | 354 | return; |
| 355 | 355 | } |
| 356 | - if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 357 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 356 | + if (!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 357 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | } |
@@ -363,11 +363,11 @@ discard block |
||
| 363 | 363 | |
| 364 | 364 | // Install Template Variables |
| 365 | 365 | if (isset ($_POST['tv']) || $installData) { |
| 366 | - echo "<h3>" . $_lang['tvs'] . ":</h3> "; |
|
| 366 | + echo "<h3>".$_lang['tvs'].":</h3> "; |
|
| 367 | 367 | $selTVs = $_POST['tv']; |
| 368 | 368 | foreach ($moduleTVs as $k=>$moduleTV) { |
| 369 | 369 | $installSample = in_array('sample', $moduleTV[12]) && $installData == 1; |
| 370 | - if($installSample || in_array($k, $selTVs)) { |
|
| 370 | + if ($installSample || in_array($k, $selTVs)) { |
|
| 371 | 371 | $name = mysqli_real_escape_string($conn, $moduleTV[0]); |
| 372 | 372 | $caption = mysqli_real_escape_string($conn, $moduleTV[1]); |
| 373 | 373 | $desc = mysqli_real_escape_string($conn, $moduleTV[2]); |
@@ -385,25 +385,25 @@ discard block |
||
| 385 | 385 | // Create the category if it does not already exist |
| 386 | 386 | $category = getCreateDbCategory($category, $sqlParser); |
| 387 | 387 | |
| 388 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_tmplvars` WHERE name='$name'"); |
|
| 388 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name'"); |
|
| 389 | 389 | if (mysqli_num_rows($rs)) { |
| 390 | 390 | $insert = true; |
| 391 | - while($row = mysqli_fetch_assoc($rs)) { |
|
| 392 | - 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']};")) { |
|
| 393 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 391 | + while ($row = mysqli_fetch_assoc($rs)) { |
|
| 392 | + 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']};")) { |
|
| 393 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 394 | 394 | return; |
| 395 | 395 | } |
| 396 | 396 | $insert = false; |
| 397 | 397 | } |
| 398 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 398 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 399 | 399 | } else { |
| 400 | 400 | //$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',(SELECT (CASE COUNT(*) WHEN 0 THEN 0 ELSE `id` END) `id` FROM $dbase.`" . $table_prefix . "categories` WHERE `category` = '$category'),$locked,'$input_options','$output_widget','$output_widget_params','$input_default');"; |
| 401 | - $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');"; |
|
| 401 | + $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');"; |
|
| 402 | 402 | if (!mysqli_query($sqlParser->conn, $q)) { |
| 403 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 403 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 404 | 404 | return; |
| 405 | 405 | } |
| 406 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 406 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | // add template assignments |
@@ -412,10 +412,10 @@ discard block |
||
| 412 | 412 | if (count($assignments) > 0) { |
| 413 | 413 | |
| 414 | 414 | // remove existing tv -> template assignments |
| 415 | - $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';"); |
|
| 415 | + $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_tmplvars` WHERE name='$name' AND description='$desc';"); |
|
| 416 | 416 | $row = mysqli_fetch_assoc($ds); |
| 417 | 417 | $id = $row["id"]; |
| 418 | - mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_tmplvar_templates` WHERE tmplvarid = \'' . $id . '\''); |
|
| 418 | + mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_tmplvar_templates` WHERE tmplvarid = \''.$id.'\''); |
|
| 419 | 419 | |
| 420 | 420 | // add tv -> template assignments |
| 421 | 421 | foreach ($assignments as $assignment) { |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | if ($ds && $ts) { |
| 425 | 425 | $tRow = mysqli_fetch_assoc($ts); |
| 426 | 426 | $templateId = $tRow['id']; |
| 427 | - mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); |
|
| 427 | + mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); |
|
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | 430 | } |
@@ -434,12 +434,12 @@ discard block |
||
| 434 | 434 | |
| 435 | 435 | // Install Chunks |
| 436 | 436 | if (isset ($_POST['chunk']) || $installData) { |
| 437 | - echo "<h3>" . $_lang['chunks'] . ":</h3> "; |
|
| 437 | + echo "<h3>".$_lang['chunks'].":</h3> "; |
|
| 438 | 438 | $selChunks = $_POST['chunk']; |
| 439 | 439 | foreach ($moduleChunks as $k=>$moduleChunk) { |
| 440 | 440 | $installSample = in_array('sample', $moduleChunk[5]) && $installData == 1; |
| 441 | 441 | $count_new_name = 0; |
| 442 | - if($installSample || in_array($k, $selChunks)) { |
|
| 442 | + if ($installSample || in_array($k, $selChunks)) { |
|
| 443 | 443 | |
| 444 | 444 | $name = mysqli_real_escape_string($conn, $moduleChunk[0]); |
| 445 | 445 | $desc = mysqli_real_escape_string($conn, $moduleChunk[1]); |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | $filecontent = $moduleChunk[2]; |
| 449 | 449 | |
| 450 | 450 | if (!file_exists($filecontent)) |
| 451 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 451 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_chunk']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 452 | 452 | else { |
| 453 | 453 | |
| 454 | 454 | // Create the category if it does not already exist |
@@ -456,31 +456,31 @@ discard block |
||
| 456 | 456 | |
| 457 | 457 | $chunk = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', file_get_contents($filecontent), 1); |
| 458 | 458 | $chunk = mysqli_real_escape_string($conn, $chunk); |
| 459 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$name'"); |
|
| 459 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$name'"); |
|
| 460 | 460 | $count_original_name = mysqli_num_rows($rs); |
| 461 | - if($overwrite == 'false') { |
|
| 462 | - $newname = $name . '-' . str_replace('.', '_', $modx_version); |
|
| 463 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_htmlsnippets` WHERE name='$newname'"); |
|
| 461 | + if ($overwrite == 'false') { |
|
| 462 | + $newname = $name.'-'.str_replace('.', '_', $modx_version); |
|
| 463 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_htmlsnippets` WHERE name='$newname'"); |
|
| 464 | 464 | $count_new_name = mysqli_num_rows($rs); |
| 465 | 465 | } |
| 466 | 466 | $update = $count_original_name > 0 && $overwrite == 'true'; |
| 467 | 467 | if ($update) { |
| 468 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) { |
|
| 468 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_htmlsnippets` SET snippet='$chunk', description='$desc', category=$category_id WHERE name='$name';")) { |
|
| 469 | 469 | $errors += 1; |
| 470 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 470 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 471 | 471 | return; |
| 472 | 472 | } |
| 473 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 474 | - } elseif($count_new_name == 0) { |
|
| 475 | - if($count_original_name > 0 && $overwrite == 'false') { |
|
| 473 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 474 | + } elseif ($count_new_name == 0) { |
|
| 475 | + if ($count_original_name > 0 && $overwrite == 'false') { |
|
| 476 | 476 | $name = $newname; |
| 477 | 477 | } |
| 478 | - if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) { |
|
| 478 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_htmlsnippets` (name,description,snippet,category) VALUES('$name','$desc','$chunk',$category_id);")) { |
|
| 479 | 479 | $errors += 1; |
| 480 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 480 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 481 | 481 | return; |
| 482 | 482 | } |
| 483 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 483 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | } |
@@ -489,11 +489,11 @@ discard block |
||
| 489 | 489 | |
| 490 | 490 | // Install Modules |
| 491 | 491 | if (isset ($_POST['module']) || $installData) { |
| 492 | - echo "<h3>" . $_lang['modules'] . ":</h3> "; |
|
| 492 | + echo "<h3>".$_lang['modules'].":</h3> "; |
|
| 493 | 493 | $selModules = $_POST['module']; |
| 494 | 494 | foreach ($moduleModules as $k=>$moduleModule) { |
| 495 | 495 | $installSample = in_array('sample', $moduleModule[7]) && $installData == 1; |
| 496 | - if($installSample || in_array($k, $selModules)) { |
|
| 496 | + if ($installSample || in_array($k, $selModules)) { |
|
| 497 | 497 | $name = mysqli_real_escape_string($conn, $moduleModule[0]); |
| 498 | 498 | $desc = mysqli_real_escape_string($conn, $moduleModule[1]); |
| 499 | 499 | $filecontent = $moduleModule[2]; |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
| 503 | 503 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
| 504 | 504 | if (!file_exists($filecontent)) |
| 505 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 505 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_module']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 506 | 506 | else { |
| 507 | 507 | |
| 508 | 508 | // Create the category if it does not already exist |
@@ -511,22 +511,22 @@ discard block |
||
| 511 | 511 | $module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
| 512 | 512 | // $module = removeDocblock($module, 'module'); // Modules have no fileBinding, keep docblock for info-tab |
| 513 | 513 | $module = mysqli_real_escape_string($conn, $module); |
| 514 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_modules` WHERE name='$name'"); |
|
| 514 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_modules` WHERE name='$name'"); |
|
| 515 | 515 | if (mysqli_num_rows($rs)) { |
| 516 | 516 | $row = mysqli_fetch_assoc($rs); |
| 517 | - $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
| 518 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
|
| 519 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 517 | + $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
| 518 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_modules` SET modulecode='$module', description='$desc', properties='$props', enable_sharedparams='$shared' WHERE name='$name';")) { |
|
| 519 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 520 | 520 | return; |
| 521 | 521 | } |
| 522 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 522 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 523 | 523 | } else { |
| 524 | 524 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
| 525 | - 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);")) { |
|
| 526 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 525 | + 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);")) { |
|
| 526 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 527 | 527 | return; |
| 528 | 528 | } |
| 529 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 529 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 530 | 530 | } |
| 531 | 531 | } |
| 532 | 532 | } |
@@ -535,11 +535,11 @@ discard block |
||
| 535 | 535 | |
| 536 | 536 | // Install Plugins |
| 537 | 537 | if (isset ($_POST['plugin']) || $installData) { |
| 538 | - echo "<h3>" . $_lang['plugins'] . ":</h3> "; |
|
| 538 | + echo "<h3>".$_lang['plugins'].":</h3> "; |
|
| 539 | 539 | $selPlugs = $_POST['plugin']; |
| 540 | 540 | foreach ($modulePlugins as $k=>$modulePlugin) { |
| 541 | 541 | $installSample = in_array('sample', $modulePlugin[8]) && $installData == 1; |
| 542 | - if($installSample || in_array($k, $selPlugs)) { |
|
| 542 | + if ($installSample || in_array($k, $selPlugs)) { |
|
| 543 | 543 | $name = mysqli_real_escape_string($conn, $modulePlugin[0]); |
| 544 | 544 | $desc = mysqli_real_escape_string($conn, $modulePlugin[1]); |
| 545 | 545 | $filecontent = $modulePlugin[2]; |
@@ -549,17 +549,17 @@ discard block |
||
| 549 | 549 | $category = mysqli_real_escape_string($conn, $modulePlugin[6]); |
| 550 | 550 | $leg_names = ''; |
| 551 | 551 | $disabled = $modulePlugin[9]; |
| 552 | - if(array_key_exists(7, $modulePlugin)) { |
|
| 552 | + if (array_key_exists(7, $modulePlugin)) { |
|
| 553 | 553 | // parse comma-separated legacy names and prepare them for sql IN clause |
| 554 | - $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
|
| 554 | + $leg_names = "'".implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7])))."'"; |
|
| 555 | 555 | } |
| 556 | 556 | if (!file_exists($filecontent)) |
| 557 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 557 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_plugin']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 558 | 558 | else { |
| 559 | 559 | |
| 560 | 560 | // disable legacy versions based on legacy_names provided |
| 561 | - if(!empty($leg_names)) { |
|
| 562 | - $update_query = "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE name IN ($leg_names);"; |
|
| 561 | + if (!empty($leg_names)) { |
|
| 562 | + $update_query = "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE name IN ($leg_names);"; |
|
| 563 | 563 | $rs = mysqli_query($sqlParser->conn, $update_query); |
| 564 | 564 | } |
| 565 | 565 | |
@@ -569,50 +569,50 @@ discard block |
||
| 569 | 569 | $plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); |
| 570 | 570 | $plugin = removeDocblock($plugin, 'plugin'); |
| 571 | 571 | $plugin = mysqli_real_escape_string($conn, $plugin); |
| 572 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_plugins` WHERE name='$name'"); |
|
| 572 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name'"); |
|
| 573 | 573 | if (mysqli_num_rows($rs)) { |
| 574 | 574 | $insert = true; |
| 575 | - while($row = mysqli_fetch_assoc($rs)) { |
|
| 576 | - $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
| 577 | - if($row['description'] == $desc){ |
|
| 578 | - if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
|
| 579 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 575 | + while ($row = mysqli_fetch_assoc($rs)) { |
|
| 576 | + $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
| 577 | + if ($row['description'] == $desc) { |
|
| 578 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
|
| 579 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 580 | 580 | return; |
| 581 | 581 | } |
| 582 | 582 | $insert = false; |
| 583 | 583 | } else { |
| 584 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET disabled='1' WHERE id={$row['id']};")) { |
|
| 584 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_plugins` SET disabled='1' WHERE id={$row['id']};")) { |
|
| 585 | 585 | echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
| 586 | 586 | return; |
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | 589 | } |
| 590 | - if($insert === true) { |
|
| 591 | - $properties = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
| 592 | - 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);")) { |
|
| 590 | + if ($insert === true) { |
|
| 591 | + $properties = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
| 592 | + 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);")) { |
|
| 593 | 593 | echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
| 594 | 594 | return; |
| 595 | 595 | } |
| 596 | 596 | } |
| 597 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 597 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 598 | 598 | } else { |
| 599 | 599 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
| 600 | - 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);")) { |
|
| 601 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 600 | + 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);")) { |
|
| 601 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 602 | 602 | return; |
| 603 | 603 | } |
| 604 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 604 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 605 | 605 | } |
| 606 | 606 | // add system events |
| 607 | 607 | if (count($events) > 0) { |
| 608 | - $ds=mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';"); |
|
| 608 | + $ds = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_plugins` WHERE name='$name' AND description='$desc';"); |
|
| 609 | 609 | if ($ds) { |
| 610 | 610 | $row = mysqli_fetch_assoc($ds); |
| 611 | 611 | $id = $row["id"]; |
| 612 | 612 | // remove existing events |
| 613 | - mysqli_query($sqlParser->conn, 'DELETE FROM ' . $dbase . '.`' . $table_prefix . 'site_plugin_events` WHERE pluginid = \'' . $id . '\''); |
|
| 613 | + mysqli_query($sqlParser->conn, 'DELETE FROM '.$dbase.'.`'.$table_prefix.'site_plugin_events` WHERE pluginid = \''.$id.'\''); |
|
| 614 | 614 | // add new events |
| 615 | - 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) . "')"); |
|
| 615 | + 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)."')"); |
|
| 616 | 616 | } |
| 617 | 617 | } |
| 618 | 618 | } |
@@ -622,18 +622,18 @@ discard block |
||
| 622 | 622 | |
| 623 | 623 | // Install Snippets |
| 624 | 624 | if (isset ($_POST['snippet']) || $installData) { |
| 625 | - echo "<h3>" . $_lang['snippets'] . ":</h3> "; |
|
| 625 | + echo "<h3>".$_lang['snippets'].":</h3> "; |
|
| 626 | 626 | $selSnips = $_POST['snippet']; |
| 627 | 627 | foreach ($moduleSnippets as $k=>$moduleSnippet) { |
| 628 | 628 | $installSample = in_array('sample', $moduleSnippet[5]) && $installData == 1; |
| 629 | - if($installSample || in_array($k, $selSnips)) { |
|
| 629 | + if ($installSample || in_array($k, $selSnips)) { |
|
| 630 | 630 | $name = mysqli_real_escape_string($conn, $moduleSnippet[0]); |
| 631 | 631 | $desc = mysqli_real_escape_string($conn, $moduleSnippet[1]); |
| 632 | 632 | $filecontent = $moduleSnippet[2]; |
| 633 | 633 | $properties = $moduleSnippet[3]; |
| 634 | 634 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
| 635 | 635 | if (!file_exists($filecontent)) |
| 636 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 636 | + echo "<p> $name: <span class=\"notok\">".$_lang['unable_install_snippet']." '$filecontent' ".$_lang['not_found'].".</span></p>"; |
|
| 637 | 637 | else { |
| 638 | 638 | |
| 639 | 639 | // Create the category if it does not already exist |
@@ -642,22 +642,22 @@ discard block |
||
| 642 | 642 | $snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent))); |
| 643 | 643 | $snippet = removeDocblock($snippet, 'snippet'); |
| 644 | 644 | $snippet = mysqli_real_escape_string($conn, $snippet); |
| 645 | - $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`" . $table_prefix . "site_snippets` WHERE name='$name'"); |
|
| 645 | + $rs = mysqli_query($sqlParser->conn, "SELECT * FROM $dbase.`".$table_prefix."site_snippets` WHERE name='$name'"); |
|
| 646 | 646 | if (mysqli_num_rows($rs)) { |
| 647 | 647 | $row = mysqli_fetch_assoc($rs); |
| 648 | - $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
|
| 649 | - if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
|
| 650 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 648 | + $props = mysqli_real_escape_string($conn, propUpdate($properties, $row['properties'])); |
|
| 649 | + if (!mysqli_query($sqlParser->conn, "UPDATE $dbase.`".$table_prefix."site_snippets` SET snippet='$snippet', description='$desc', properties='$props' WHERE name='$name';")) { |
|
| 650 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 651 | 651 | return; |
| 652 | 652 | } |
| 653 | - echo "<p> $name: <span class=\"ok\">" . $_lang['upgraded'] . "</span></p>"; |
|
| 653 | + echo "<p> $name: <span class=\"ok\">".$_lang['upgraded']."</span></p>"; |
|
| 654 | 654 | } else { |
| 655 | 655 | $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); |
| 656 | - if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) { |
|
| 657 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 656 | + if (!mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`".$table_prefix."site_snippets` (name,description,snippet,properties,category) VALUES('$name','$desc','$snippet','$properties',$category);")) { |
|
| 657 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 658 | 658 | return; |
| 659 | 659 | } |
| 660 | - echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
|
| 660 | + echo "<p> $name: <span class=\"ok\">".$_lang['installed']."</span></p>"; |
|
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | 663 | } |
@@ -666,24 +666,24 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | // Install demo-site |
| 668 | 668 | if ($installData && $moduleSQLDataFile) { |
| 669 | - echo "<p>" . $_lang['installing_demo_site']; |
|
| 669 | + echo "<p>".$_lang['installing_demo_site']; |
|
| 670 | 670 | $sqlParser->process($moduleSQLDataFile); |
| 671 | 671 | // display database results |
| 672 | 672 | if ($sqlParser->installFailed == true) { |
| 673 | 673 | $errors += 1; |
| 674 | - echo "<span class=\"notok\"><b>" . $_lang['database_alerts'] . "</span></p>"; |
|
| 675 | - echo "<p>" . $_lang['setup_couldnt_install'] . "</p>"; |
|
| 676 | - echo "<p>" . $_lang['installation_error_occured'] . "<br /><br />"; |
|
| 674 | + echo "<span class=\"notok\"><b>".$_lang['database_alerts']."</span></p>"; |
|
| 675 | + echo "<p>".$_lang['setup_couldnt_install']."</p>"; |
|
| 676 | + echo "<p>".$_lang['installation_error_occured']."<br /><br />"; |
|
| 677 | 677 | for ($i = 0; $i < count($sqlParser->mysqlErrors); $i++) { |
| 678 | - echo "<em>" . $sqlParser->mysqlErrors[$i]["error"] . "</em>" . $_lang['during_execution_of_sql'] . "<span class='mono'>" . strip_tags($sqlParser->mysqlErrors[$i]["sql"]) . "</span>.<hr />"; |
|
| 678 | + echo "<em>".$sqlParser->mysqlErrors[$i]["error"]."</em>".$_lang['during_execution_of_sql']."<span class='mono'>".strip_tags($sqlParser->mysqlErrors[$i]["sql"])."</span>.<hr />"; |
|
| 679 | 679 | } |
| 680 | 680 | echo "</p>"; |
| 681 | - echo "<p>" . $_lang['some_tables_not_updated'] . "</p>"; |
|
| 681 | + echo "<p>".$_lang['some_tables_not_updated']."</p>"; |
|
| 682 | 682 | return; |
| 683 | 683 | } else { |
| 684 | 684 | $sql = sprintf("SELECT id FROM `%ssite_templates` WHERE templatename='EVO startup - Bootstrap'", $sqlParser->prefix); |
| 685 | 685 | $rs = mysqli_query($sqlParser->conn, $sql); |
| 686 | - if(mysqli_num_rows($rs)) { |
|
| 686 | + if (mysqli_num_rows($rs)) { |
|
| 687 | 687 | $row = mysqli_fetch_assoc($rs); |
| 688 | 688 | $sql = sprintf('UPDATE `%ssite_content` SET template=%s WHERE template=4', $sqlParser->prefix, $row['id']); |
| 689 | 689 | mysqli_query($sqlParser->conn, $sql); |
@@ -694,9 +694,9 @@ discard block |
||
| 694 | 694 | |
| 695 | 695 | // Install Dependencies |
| 696 | 696 | foreach ($moduleDependencies as $dependency) { |
| 697 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_modules` WHERE name="' . $dependency['module'] . '"'); |
|
| 697 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id, guid FROM '.$dbase.'`'.$sqlParser->prefix.'site_modules` WHERE name="'.$dependency['module'].'"'); |
|
| 698 | 698 | if (!$ds) { |
| 699 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 699 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 700 | 700 | return; |
| 701 | 701 | } else { |
| 702 | 702 | $row = mysqli_fetch_assoc($ds); |
@@ -704,37 +704,37 @@ discard block |
||
| 704 | 704 | $moduleGuid = $row["guid"]; |
| 705 | 705 | } |
| 706 | 706 | // get extra id |
| 707 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE ' . $dependency['column'] . '="' . $dependency['name'] . '"'); |
|
| 707 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE '.$dependency['column'].'="'.$dependency['name'].'"'); |
|
| 708 | 708 | if (!$ds) { |
| 709 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 709 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 710 | 710 | return; |
| 711 | 711 | } else { |
| 712 | 712 | $row = mysqli_fetch_assoc($ds); |
| 713 | 713 | $extraId = $row["id"]; |
| 714 | 714 | } |
| 715 | 715 | // setup extra as module dependency |
| 716 | - $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'); |
|
| 716 | + $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'); |
|
| 717 | 717 | if (!$ds) { |
| 718 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 718 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 719 | 719 | return; |
| 720 | 720 | } else { |
| 721 | 721 | if (mysqli_num_rows($ds) === 0) { |
| 722 | - mysqli_query($sqlParser->conn, 'INSERT INTO ' . $dbase . '`' . $sqlParser->prefix . 'site_module_depobj` (module, resource, type) VALUES(' . $moduleId . ',' . $extraId . ',' . $dependency['type'] . ')'); |
|
| 723 | - echo '<p> ' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_create'] . '</span></p>'; |
|
| 722 | + mysqli_query($sqlParser->conn, 'INSERT INTO '.$dbase.'`'.$sqlParser->prefix.'site_module_depobj` (module, resource, type) VALUES('.$moduleId.','.$extraId.','.$dependency['type'].')'); |
|
| 723 | + echo '<p> '.$dependency['module'].' Module: <span class="ok">'.$_lang['depedency_create'].'</span></p>'; |
|
| 724 | 724 | } else { |
| 725 | - 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']); |
|
| 726 | - echo '<p> ' . $dependency['module'] . ' Module: <span class="ok">' . $_lang['depedency_update'] . '</span></p>'; |
|
| 725 | + 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']); |
|
| 726 | + echo '<p> '.$dependency['module'].' Module: <span class="ok">'.$_lang['depedency_update'].'</span></p>'; |
|
| 727 | 727 | } |
| 728 | 728 | if ($dependency['type'] == 30 || $dependency['type'] == 40) { |
| 729 | 729 | // set extra guid for plugins and snippets |
| 730 | - $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` WHERE id=' . $extraId . ' LIMIT 1'); |
|
| 730 | + $ds = mysqli_query($sqlParser->conn, 'SELECT id FROM '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` WHERE id='.$extraId.' LIMIT 1'); |
|
| 731 | 731 | if (!$ds) { |
| 732 | - echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
|
| 732 | + echo "<p>".mysqli_error($sqlParser->conn)."</p>"; |
|
| 733 | 733 | return; |
| 734 | 734 | } else { |
| 735 | 735 | if (mysqli_num_rows($ds) != 0) { |
| 736 | - mysqli_query($sqlParser->conn, 'UPDATE ' . $dbase . '`' . $sqlParser->prefix . 'site_' . $dependency['table'] . '` SET moduleguid = ' . $moduleGuid . ' WHERE id=' . $extraId); |
|
| 737 | - echo '<p> ' . $dependency['name'] . ': <span class="ok">' . $_lang['guid_set'] . '</span></p>'; |
|
| 736 | + mysqli_query($sqlParser->conn, 'UPDATE '.$dbase.'`'.$sqlParser->prefix.'site_'.$dependency['table'].'` SET moduleguid = '.$moduleGuid.' WHERE id='.$extraId); |
|
| 737 | + echo '<p> '.$dependency['name'].': <span class="ok">'.$_lang['guid_set'].'</span></p>'; |
|
| 738 | 738 | } |
| 739 | 739 | } |
| 740 | 740 | } |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | |
| 744 | 744 | // call back function |
| 745 | 745 | if ($callBackFnc != "") |
| 746 | - $callBackFnc ($sqlParser); |
|
| 746 | + $callBackFnc($sqlParser); |
|
| 747 | 747 | |
| 748 | 748 | // Setup the MODX API -- needed for the cache processor |
| 749 | 749 | define('MODX_API_MODE', true); |
@@ -778,12 +778,12 @@ discard block |
||
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | // setup completed! |
| 781 | -echo "<p><b>" . $_lang['installation_successful'] . "</b></p>"; |
|
| 782 | -echo "<p>" . $_lang['to_log_into_content_manager'] . "</p>"; |
|
| 781 | +echo "<p><b>".$_lang['installation_successful']."</b></p>"; |
|
| 782 | +echo "<p>".$_lang['to_log_into_content_manager']."</p>"; |
|
| 783 | 783 | if ($installMode == 0) { |
| 784 | - echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />" . $_lang['installation_note'] . "</p>"; |
|
| 784 | + echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />".$_lang['installation_note']."</p>"; |
|
| 785 | 785 | } else { |
| 786 | - echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />" . $_lang['upgrade_note'] . "</p>"; |
|
| 786 | + echo "<p><img src=\"img/ico_info.png\" width=\"40\" height=\"42\" align=\"left\" style=\"margin-right:10px;\" />".$_lang['upgrade_note']."</p>"; |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | /** |
@@ -793,11 +793,11 @@ discard block |
||
| 793 | 793 | * @param string $old |
| 794 | 794 | * @return string |
| 795 | 795 | */ |
| 796 | -function propUpdate($new,$old){ |
|
| 796 | +function propUpdate($new, $old){ |
|
| 797 | 797 | $newArr = parseProperties($new); |
| 798 | 798 | $oldArr = parseProperties($old); |
| 799 | - foreach ($oldArr as $k => $v){ |
|
| 800 | - if (isset($v['0']['options'])){ |
|
| 799 | + foreach ($oldArr as $k => $v) { |
|
| 800 | + if (isset($v['0']['options'])) { |
|
| 801 | 801 | $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options']; |
| 802 | 802 | } |
| 803 | 803 | } |
@@ -812,30 +812,30 @@ discard block |
||
| 812 | 812 | * @param bool|mixed $json |
| 813 | 813 | * @return string |
| 814 | 814 | */ |
| 815 | -function parseProperties($propertyString, $json=false) { |
|
| 816 | - $propertyString = str_replace('{}', '', $propertyString ); |
|
| 817 | - $propertyString = str_replace('} {', ',', $propertyString ); |
|
| 815 | +function parseProperties($propertyString, $json = false){ |
|
| 816 | + $propertyString = str_replace('{}', '', $propertyString); |
|
| 817 | + $propertyString = str_replace('} {', ',', $propertyString); |
|
| 818 | 818 | |
| 819 | - if(empty($propertyString)) return array(); |
|
| 820 | - if($propertyString=='{}' || $propertyString=='[]') return array(); |
|
| 819 | + if (empty($propertyString)) return array(); |
|
| 820 | + if ($propertyString == '{}' || $propertyString == '[]') return array(); |
|
| 821 | 821 | |
| 822 | 822 | $jsonFormat = isJson($propertyString, true); |
| 823 | 823 | $property = array(); |
| 824 | 824 | // old format |
| 825 | - if ( $jsonFormat === false) { |
|
| 826 | - $props= explode('&', $propertyString); |
|
| 825 | + if ($jsonFormat === false) { |
|
| 826 | + $props = explode('&', $propertyString); |
|
| 827 | 827 | foreach ($props as $prop) { |
| 828 | 828 | $prop = trim($prop); |
| 829 | - if($prop === '') { |
|
| 829 | + if ($prop === '') { |
|
| 830 | 830 | continue; |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | $arr = explode(';', $prop); |
| 834 | - if( ! is_array($arr)) { |
|
| 834 | + if (!is_array($arr)) { |
|
| 835 | 835 | $arr = array(); |
| 836 | 836 | } |
| 837 | 837 | $key = explode('=', isset($arr[0]) ? $arr[0] : ''); |
| 838 | - if( ! is_array($key) || empty($key[0])) { |
|
| 838 | + if (!is_array($key) || empty($key[0])) { |
|
| 839 | 839 | continue; |
| 840 | 840 | } |
| 841 | 841 | |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | |
| 860 | 860 | } |
| 861 | 861 | // new json-format |
| 862 | - } else if(!empty($jsonFormat)){ |
|
| 862 | + } else if (!empty($jsonFormat)) { |
|
| 863 | 863 | $property = $jsonFormat; |
| 864 | 864 | } |
| 865 | 865 | if ($json) { |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | * @param bool $returnData |
| 875 | 875 | * @return bool|mixed |
| 876 | 876 | */ |
| 877 | -function isJson($string, $returnData=false) { |
|
| 877 | +function isJson($string, $returnData = false){ |
|
| 878 | 878 | $data = json_decode($string, true); |
| 879 | 879 | return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false; |
| 880 | 880 | } |
@@ -884,20 +884,20 @@ discard block |
||
| 884 | 884 | * @param SqlParser $sqlParser |
| 885 | 885 | * @return int |
| 886 | 886 | */ |
| 887 | -function getCreateDbCategory($category, $sqlParser) { |
|
| 887 | +function getCreateDbCategory($category, $sqlParser){ |
|
| 888 | 888 | $dbase = $sqlParser->dbname; |
| 889 | - $dbase = '`' . trim($dbase,'`') . '`'; |
|
| 889 | + $dbase = '`'.trim($dbase, '`').'`'; |
|
| 890 | 890 | $table_prefix = $sqlParser->prefix; |
| 891 | 891 | $category_id = 0; |
| 892 | - if(!empty($category)) { |
|
| 892 | + if (!empty($category)) { |
|
| 893 | 893 | $category = mysqli_real_escape_string($sqlParser->conn, $category); |
| 894 | 894 | $rs = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."categories` WHERE category = '".$category."'"); |
| 895 | - if(mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) { |
|
| 895 | + if (mysqli_num_rows($rs) && ($row = mysqli_fetch_assoc($rs))) { |
|
| 896 | 896 | $category_id = $row['id']; |
| 897 | 897 | } else { |
| 898 | 898 | $q = "INSERT INTO $dbase.`".$table_prefix."categories` (`category`) VALUES ('{$category}');"; |
| 899 | 899 | $rs = mysqli_query($sqlParser->conn, $q); |
| 900 | - if($rs) { |
|
| 900 | + if ($rs) { |
|
| 901 | 901 | $category_id = mysqli_insert_id($sqlParser->conn); |
| 902 | 902 | } |
| 903 | 903 | } |
@@ -912,12 +912,12 @@ discard block |
||
| 912 | 912 | * @param string $type |
| 913 | 913 | * @return string |
| 914 | 914 | */ |
| 915 | -function removeDocblock($code, $type) { |
|
| 915 | +function removeDocblock($code, $type){ |
|
| 916 | 916 | |
| 917 | 917 | $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1); |
| 918 | 918 | |
| 919 | 919 | // Procedure taken from plugin.filesource.php |
| 920 | - switch($type) { |
|
| 920 | + switch ($type) { |
|
| 921 | 921 | case 'snippet': |
| 922 | 922 | $elm_name = 'snippets'; |
| 923 | 923 | $include = 'return require'; |
@@ -933,7 +933,7 @@ discard block |
||
| 933 | 933 | default: |
| 934 | 934 | return $cleaned; |
| 935 | 935 | }; |
| 936 | - if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
| 936 | + if (substr(trim($cleaned), 0, $count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
| 937 | 937 | return $cleaned; |
| 938 | 938 | |
| 939 | 939 | // fileBinding not found - return code incl docblock |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if (file_exists(dirname(__FILE__)."/../assets/cache/siteManager.php")) { |
| 3 | 3 | include_once(dirname(__FILE__)."/../assets/cache/siteManager.php"); |
| 4 | -}else{ |
|
| 4 | +} else { |
|
| 5 | 5 | define('MGR_DIR', 'manager'); |
| 6 | 6 | } |
| 7 | 7 | define('MODX_CLI', false); |
@@ -59,13 +59,15 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | // get base path and url |
| 61 | 61 | $a = explode("install", str_replace("\\", "/", dirname($_SERVER["PHP_SELF"]))); |
| 62 | -if (count($a) > 1) |
|
| 62 | +if (count($a) > 1) { |
|
| 63 | 63 | array_pop($a); |
| 64 | +} |
|
| 64 | 65 | $url = implode("install", $a); |
| 65 | 66 | reset($a); |
| 66 | 67 | $a = explode("install", str_replace("\\", "/", realpath(dirname(__FILE__)))); |
| 67 | -if (count($a) > 1) |
|
| 68 | +if (count($a) > 1) { |
|
| 68 | 69 | array_pop($a); |
| 70 | +} |
|
| 69 | 71 | $pth = implode("install", $a); |
| 70 | 72 | unset ($a); |
| 71 | 73 | $base_url = $url . (substr($url, -1) != "/" ? "/" : ""); |
@@ -86,7 +88,9 @@ discard block |
||
| 86 | 88 | echo "<span class=\"notok\" style='color:#707070'>".$_lang['setup_database_selection_failed']."</span>".$_lang['setup_database_selection_failed_note']."</p>"; |
| 87 | 89 | $create = true; |
| 88 | 90 | } else { |
| 89 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset); |
|
| 91 | + if (function_exists('mysqli_set_charset')) { |
|
| 92 | + mysqli_set_charset($conn, $database_charset); |
|
| 93 | + } |
|
| 90 | 94 | mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); |
| 91 | 95 | echo '<span class="ok">'.$_lang['ok']."</span></p>"; |
| 92 | 96 | } |
@@ -133,7 +137,8 @@ discard block |
||
| 133 | 137 | * @param string $propertyString |
| 134 | 138 | * @return array |
| 135 | 139 | */ |
| 136 | - function parseProperties($propertyString) { |
|
| 140 | + function parseProperties($propertyString) |
|
| 141 | + { |
|
| 137 | 142 | $parameter= array (); |
| 138 | 143 | if (!empty ($propertyString)) { |
| 139 | 144 | $tmpParams= explode("&", $propertyString); |
@@ -142,11 +147,14 @@ discard block |
||
| 142 | 147 | if (strpos($tmpParams[$x], '=', 0)) { |
| 143 | 148 | $pTmp= explode("=", $tmpParams[$x]); |
| 144 | 149 | $pvTmp= explode(";", trim($pTmp[1])); |
| 145 | - if ($pvTmp[1] == 'list' && $pvTmp[3] != "") |
|
| 146 | - $parameter[trim($pTmp[0])]= $pvTmp[3]; //list default |
|
| 150 | + if ($pvTmp[1] == 'list' && $pvTmp[3] != "") { |
|
| 151 | + $parameter[trim($pTmp[0])]= $pvTmp[3]; |
|
| 152 | + } |
|
| 153 | + //list default |
|
| 147 | 154 | else |
| 148 | - if ($pvTmp[1] != 'list' && $pvTmp[2] != "") |
|
| 149 | - $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 155 | + if ($pvTmp[1] != 'list' && $pvTmp[2] != "") { |
|
| 156 | + $parameter[trim($pTmp[0])]= $pvTmp[2]; |
|
| 157 | + } |
|
| 150 | 158 | } |
| 151 | 159 | } |
| 152 | 160 | } |
@@ -217,7 +225,7 @@ discard block |
||
| 217 | 225 | // custom or not |
| 218 | 226 | if (file_exists(dirname(__FILE__)."/../../assets/cache/siteManager.php")) { |
| 219 | 227 | $mgrdir = 'include_once(dirname(__FILE__)."/../../assets/cache/siteManager.php");'; |
| 220 | -}else{ |
|
| 228 | +} else { |
|
| 221 | 229 | $mgrdir = 'define(\'MGR_DIR\', \'manager\');'; |
| 222 | 230 | } |
| 223 | 231 | |
@@ -353,7 +361,9 @@ discard block |
||
| 353 | 361 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 354 | 362 | return; |
| 355 | 363 | } |
| 356 | - if(!is_null($save_sql_id_as)) $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 364 | + if(!is_null($save_sql_id_as)) { |
|
| 365 | + $custom_placeholders[$save_sql_id_as] = @mysqli_insert_id($sqlParser->conn); |
|
| 366 | + } |
|
| 357 | 367 | echo "<p> $name: <span class=\"ok\">" . $_lang['installed'] . "</span></p>"; |
| 358 | 368 | } |
| 359 | 369 | } |
@@ -447,9 +457,9 @@ discard block |
||
| 447 | 457 | $overwrite = mysqli_real_escape_string($conn, $moduleChunk[4]); |
| 448 | 458 | $filecontent = $moduleChunk[2]; |
| 449 | 459 | |
| 450 | - if (!file_exists($filecontent)) |
|
| 451 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 452 | - else { |
|
| 460 | + if (!file_exists($filecontent)) { |
|
| 461 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_chunk'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 462 | + } else { |
|
| 453 | 463 | |
| 454 | 464 | // Create the category if it does not already exist |
| 455 | 465 | $category_id = getCreateDbCategory($category, $sqlParser); |
@@ -501,9 +511,9 @@ discard block |
||
| 501 | 511 | $guid = mysqli_real_escape_string($conn, $moduleModule[4]); |
| 502 | 512 | $shared = mysqli_real_escape_string($conn, $moduleModule[5]); |
| 503 | 513 | $category = mysqli_real_escape_string($conn, $moduleModule[6]); |
| 504 | - if (!file_exists($filecontent)) |
|
| 505 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 506 | - else { |
|
| 514 | + if (!file_exists($filecontent)) { |
|
| 515 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_module'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 516 | + } else { |
|
| 507 | 517 | |
| 508 | 518 | // Create the category if it does not already exist |
| 509 | 519 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -553,9 +563,9 @@ discard block |
||
| 553 | 563 | // parse comma-separated legacy names and prepare them for sql IN clause |
| 554 | 564 | $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; |
| 555 | 565 | } |
| 556 | - if (!file_exists($filecontent)) |
|
| 557 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 558 | - else { |
|
| 566 | + if (!file_exists($filecontent)) { |
|
| 567 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 568 | + } else { |
|
| 559 | 569 | |
| 560 | 570 | // disable legacy versions based on legacy_names provided |
| 561 | 571 | if(!empty($leg_names)) { |
@@ -574,7 +584,7 @@ discard block |
||
| 574 | 584 | $insert = true; |
| 575 | 585 | while($row = mysqli_fetch_assoc($rs)) { |
| 576 | 586 | $props = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); |
| 577 | - if($row['description'] == $desc){ |
|
| 587 | + if($row['description'] == $desc) { |
|
| 578 | 588 | if (! mysqli_query($sqlParser->conn, "UPDATE $dbase.`" . $table_prefix . "site_plugins` SET plugincode='$plugin', description='$desc', properties='$props' WHERE id={$row['id']};")) { |
| 579 | 589 | echo "<p>" . mysqli_error($sqlParser->conn) . "</p>"; |
| 580 | 590 | return; |
@@ -632,9 +642,9 @@ discard block |
||
| 632 | 642 | $filecontent = $moduleSnippet[2]; |
| 633 | 643 | $properties = $moduleSnippet[3]; |
| 634 | 644 | $category = mysqli_real_escape_string($conn, $moduleSnippet[4]); |
| 635 | - if (!file_exists($filecontent)) |
|
| 636 | - echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 637 | - else { |
|
| 645 | + if (!file_exists($filecontent)) { |
|
| 646 | + echo "<p> $name: <span class=\"notok\">" . $_lang['unable_install_snippet'] . " '$filecontent' " . $_lang['not_found'] . ".</span></p>"; |
|
| 647 | + } else { |
|
| 638 | 648 | |
| 639 | 649 | // Create the category if it does not already exist |
| 640 | 650 | $category = getCreateDbCategory($category, $sqlParser); |
@@ -742,13 +752,16 @@ discard block |
||
| 742 | 752 | } |
| 743 | 753 | |
| 744 | 754 | // call back function |
| 745 | -if ($callBackFnc != "") |
|
| 755 | +if ($callBackFnc != "") { |
|
| 746 | 756 | $callBackFnc ($sqlParser); |
| 757 | +} |
|
| 747 | 758 | |
| 748 | 759 | // Setup the MODX API -- needed for the cache processor |
| 749 | 760 | define('MODX_API_MODE', true); |
| 750 | 761 | define('MODX_BASE_PATH', $base_path); |
| 751 | -if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
| 762 | +if (!defined('MODX_MANAGER_PATH')) { |
|
| 763 | + define('MODX_MANAGER_PATH', $base_path.MGR_DIR.'/'); |
|
| 764 | +} |
|
| 752 | 765 | $database_type = 'mysqli'; |
| 753 | 766 | // initiate a new document parser |
| 754 | 767 | include_once('../'.MGR_DIR.'/includes/document.parser.class.inc.php'); |
@@ -793,11 +806,12 @@ discard block |
||
| 793 | 806 | * @param string $old |
| 794 | 807 | * @return string |
| 795 | 808 | */ |
| 796 | -function propUpdate($new,$old){ |
|
| 809 | +function propUpdate($new,$old) |
|
| 810 | +{ |
|
| 797 | 811 | $newArr = parseProperties($new); |
| 798 | 812 | $oldArr = parseProperties($old); |
| 799 | - foreach ($oldArr as $k => $v){ |
|
| 800 | - if (isset($v['0']['options'])){ |
|
| 813 | + foreach ($oldArr as $k => $v) { |
|
| 814 | + if (isset($v['0']['options'])) { |
|
| 801 | 815 | $oldArr[$k]['0']['options'] = $newArr[$k]['0']['options']; |
| 802 | 816 | } |
| 803 | 817 | } |
@@ -812,12 +826,17 @@ discard block |
||
| 812 | 826 | * @param bool|mixed $json |
| 813 | 827 | * @return string |
| 814 | 828 | */ |
| 815 | -function parseProperties($propertyString, $json=false) { |
|
| 829 | +function parseProperties($propertyString, $json=false) |
|
| 830 | +{ |
|
| 816 | 831 | $propertyString = str_replace('{}', '', $propertyString ); |
| 817 | 832 | $propertyString = str_replace('} {', ',', $propertyString ); |
| 818 | 833 | |
| 819 | - if(empty($propertyString)) return array(); |
|
| 820 | - if($propertyString=='{}' || $propertyString=='[]') return array(); |
|
| 834 | + if(empty($propertyString)) { |
|
| 835 | + return array(); |
|
| 836 | + } |
|
| 837 | + if($propertyString=='{}' || $propertyString=='[]') { |
|
| 838 | + return array(); |
|
| 839 | + } |
|
| 821 | 840 | |
| 822 | 841 | $jsonFormat = isJson($propertyString, true); |
| 823 | 842 | $property = array(); |
@@ -859,7 +878,7 @@ discard block |
||
| 859 | 878 | |
| 860 | 879 | } |
| 861 | 880 | // new json-format |
| 862 | - } else if(!empty($jsonFormat)){ |
|
| 881 | + } else if(!empty($jsonFormat)) { |
|
| 863 | 882 | $property = $jsonFormat; |
| 864 | 883 | } |
| 865 | 884 | if ($json) { |
@@ -874,7 +893,8 @@ discard block |
||
| 874 | 893 | * @param bool $returnData |
| 875 | 894 | * @return bool|mixed |
| 876 | 895 | */ |
| 877 | -function isJson($string, $returnData=false) { |
|
| 896 | +function isJson($string, $returnData=false) |
|
| 897 | +{ |
|
| 878 | 898 | $data = json_decode($string, true); |
| 879 | 899 | return (json_last_error() == JSON_ERROR_NONE) ? ($returnData ? $data : true) : false; |
| 880 | 900 | } |
@@ -884,7 +904,8 @@ discard block |
||
| 884 | 904 | * @param SqlParser $sqlParser |
| 885 | 905 | * @return int |
| 886 | 906 | */ |
| 887 | -function getCreateDbCategory($category, $sqlParser) { |
|
| 907 | +function getCreateDbCategory($category, $sqlParser) |
|
| 908 | +{ |
|
| 888 | 909 | $dbase = $sqlParser->dbname; |
| 889 | 910 | $dbase = '`' . trim($dbase,'`') . '`'; |
| 890 | 911 | $table_prefix = $sqlParser->prefix; |
@@ -912,7 +933,8 @@ discard block |
||
| 912 | 933 | * @param string $type |
| 913 | 934 | * @return string |
| 914 | 935 | */ |
| 915 | -function removeDocblock($code, $type) { |
|
| 936 | +function removeDocblock($code, $type) |
|
| 937 | +{ |
|
| 916 | 938 | |
| 917 | 939 | $cleaned = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $code, 1); |
| 918 | 940 | |
@@ -933,8 +955,9 @@ discard block |
||
| 933 | 955 | default: |
| 934 | 956 | return $cleaned; |
| 935 | 957 | }; |
| 936 | - if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') |
|
| 937 | - return $cleaned; |
|
| 958 | + if(substr(trim($cleaned),0,$count) == $include.' MODX_BASE_PATH.\'assets/'.$elm_name.'/') { |
|
| 959 | + return $cleaned; |
|
| 960 | + } |
|
| 938 | 961 | |
| 939 | 962 | // fileBinding not found - return code incl docblock |
| 940 | 963 | return $code; |