@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array The truncated array |
| 25 | 25 | */ |
| 26 | -function truncateArray($arr, $max_length=1900) |
|
| 26 | +function truncateArray($arr, $max_length = 1900) |
|
| 27 | 27 | { |
| 28 | 28 | $curr_length = array_sum(array_map("strlen", $arr)); |
| 29 | 29 | if ($curr_length <= $max_length) |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | else |
| 32 | 32 | { |
| 33 | 33 | // Truncate each element's value to a reasonable length |
| 34 | - $param_max = floor($max_length/count($arr)); |
|
| 34 | + $param_max = floor($max_length / count($arr)); |
|
| 35 | 35 | foreach ($arr as $key => &$value) |
| 36 | 36 | $value = substr($value, 0, $param_max - strlen($key) - 5); |
| 37 | 37 | return $arr; |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | if (filemtime($cachedir . '/db_last_error.php') === $last_db_error_change) |
| 198 | 198 | { |
| 199 | 199 | // Write the change |
| 200 | - $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
| 200 | + $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
| 201 | 201 | $written_bytes = file_put_contents($cachedir . '/db_last_error.php', $write_db_change, LOCK_EX); |
| 202 | 202 | |
| 203 | 203 | // survey says ... |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | ', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br> |
| 271 | 271 | ', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br> |
| 272 | 272 | ', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br> |
| 273 | - ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
|
| 273 | + ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">' . $txt['debug_show'] . '</a><span id="debug_instances" style="display: none;"><em>' . implode('</em>, <em>', array_keys($context['debug']['instances'])) . '</em></span>)' . '<br>') : ''), ' |
|
| 274 | 274 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 275 | 275 | |
| 276 | 276 | if (function_exists('memory_get_peak_usage')) |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Truncate the GET array to a specified length |
@@ -26,14 +27,15 @@ discard block |
||
| 26 | 27 | function truncateArray($arr, $max_length=1900) |
| 27 | 28 | { |
| 28 | 29 | $curr_length = array_sum(array_map("strlen", $arr)); |
| 29 | - if ($curr_length <= $max_length) |
|
| 30 | - return $arr; |
|
| 31 | - else |
|
| 30 | + if ($curr_length <= $max_length) { |
|
| 31 | + return $arr; |
|
| 32 | + } else |
|
| 32 | 33 | { |
| 33 | 34 | // Truncate each element's value to a reasonable length |
| 34 | 35 | $param_max = floor($max_length/count($arr)); |
| 35 | - foreach ($arr as $key => &$value) |
|
| 36 | - $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
| 36 | + foreach ($arr as $key => &$value) { |
|
| 37 | + $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
| 38 | + } |
|
| 37 | 39 | return $arr; |
| 38 | 40 | } |
| 39 | 41 | } |
@@ -55,8 +57,9 @@ discard block |
||
| 55 | 57 | // Don't update for every page - this isn't wholly accurate but who cares. |
| 56 | 58 | if ($topic) |
| 57 | 59 | { |
| 58 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
| 59 | - $force = false; |
|
| 60 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
| 61 | + $force = false; |
|
| 62 | + } |
|
| 60 | 63 | $_SESSION['last_topic_id'] = $topic; |
| 61 | 64 | } |
| 62 | 65 | } |
@@ -69,22 +72,24 @@ discard block |
||
| 69 | 72 | } |
| 70 | 73 | |
| 71 | 74 | // Don't mark them as online more than every so often. |
| 72 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
| 73 | - return; |
|
| 75 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
| 76 | + return; |
|
| 77 | + } |
|
| 74 | 78 | |
| 75 | 79 | if (!empty($modSettings['who_enabled'])) |
| 76 | 80 | { |
| 77 | 81 | $encoded_get = truncateArray($_GET) + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
| 78 | 82 | |
| 79 | 83 | // In the case of a dlattach action, session_var may not be set. |
| 80 | - if (!isset($context['session_var'])) |
|
| 81 | - $context['session_var'] = $_SESSION['session_var']; |
|
| 84 | + if (!isset($context['session_var'])) { |
|
| 85 | + $context['session_var'] = $_SESSION['session_var']; |
|
| 86 | + } |
|
| 82 | 87 | |
| 83 | 88 | unset($encoded_get['sesc'], $encoded_get[$context['session_var']]); |
| 84 | 89 | $encoded_get = $smcFunc['json_encode']($encoded_get); |
| 90 | + } else { |
|
| 91 | + $encoded_get = ''; |
|
| 85 | 92 | } |
| 86 | - else |
|
| 87 | - $encoded_get = ''; |
|
| 88 | 93 | |
| 89 | 94 | // Guests use 0, members use their session ID. |
| 90 | 95 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -124,17 +129,18 @@ discard block |
||
| 124 | 129 | ); |
| 125 | 130 | |
| 126 | 131 | // Guess it got deleted. |
| 127 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 132 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 133 | + $_SESSION['log_time'] = 0; |
|
| 134 | + } |
|
| 135 | + } else { |
|
| 128 | 136 | $_SESSION['log_time'] = 0; |
| 129 | 137 | } |
| 130 | - else |
|
| 131 | - $_SESSION['log_time'] = 0; |
|
| 132 | 138 | |
| 133 | 139 | // Otherwise, we have to delete and insert. |
| 134 | 140 | if (empty($_SESSION['log_time'])) |
| 135 | 141 | { |
| 136 | - if ($do_delete || !empty($user_info['id'])) |
|
| 137 | - $smcFunc['db_query']('', ' |
|
| 142 | + if ($do_delete || !empty($user_info['id'])) { |
|
| 143 | + $smcFunc['db_query']('', ' |
|
| 138 | 144 | DELETE FROM {db_prefix}log_online |
| 139 | 145 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
| 140 | 146 | array( |
@@ -142,6 +148,7 @@ discard block |
||
| 142 | 148 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
| 143 | 149 | ) |
| 144 | 150 | ); |
| 151 | + } |
|
| 145 | 152 | |
| 146 | 153 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
| 147 | 154 | '{db_prefix}log_online', |
@@ -155,21 +162,24 @@ discard block |
||
| 155 | 162 | $_SESSION['log_time'] = time(); |
| 156 | 163 | |
| 157 | 164 | // Well, they are online now. |
| 158 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
| 159 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 165 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
| 166 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 167 | + } |
|
| 160 | 168 | |
| 161 | 169 | // Set their login time, if not already done within the last minute. |
| 162 | 170 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
| 163 | 171 | { |
| 164 | 172 | // Don't count longer than 15 minutes. |
| 165 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
| 166 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
| 173 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
| 174 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
| 175 | + } |
|
| 167 | 176 | |
| 168 | 177 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 169 | 178 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
| 170 | 179 | |
| 171 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
| 172 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 180 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
| 181 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
| 182 | + } |
|
| 173 | 183 | |
| 174 | 184 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
| 175 | 185 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -206,8 +216,7 @@ discard block |
||
| 206 | 216 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
| 207 | 217 | // Copy the file back and run for your life! |
| 208 | 218 | @copy($cachedir . '/db_last_error_bak.php', $cachedir . '/db_last_error.php'); |
| 209 | - } |
|
| 210 | - else |
|
| 219 | + } else |
|
| 211 | 220 | { |
| 212 | 221 | @touch($boarddir . '/' . 'Settings.php'); |
| 213 | 222 | return true; |
@@ -227,22 +236,27 @@ discard block |
||
| 227 | 236 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
| 228 | 237 | |
| 229 | 238 | // Add to Settings.php if you want to show the debugging information. |
| 230 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
| 231 | - return; |
|
| 239 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
| 240 | + return; |
|
| 241 | + } |
|
| 232 | 242 | |
| 233 | - if (empty($_SESSION['view_queries'])) |
|
| 234 | - $_SESSION['view_queries'] = 0; |
|
| 235 | - if (empty($context['debug']['language_files'])) |
|
| 236 | - $context['debug']['language_files'] = array(); |
|
| 237 | - if (empty($context['debug']['sheets'])) |
|
| 238 | - $context['debug']['sheets'] = array(); |
|
| 243 | + if (empty($_SESSION['view_queries'])) { |
|
| 244 | + $_SESSION['view_queries'] = 0; |
|
| 245 | + } |
|
| 246 | + if (empty($context['debug']['language_files'])) { |
|
| 247 | + $context['debug']['language_files'] = array(); |
|
| 248 | + } |
|
| 249 | + if (empty($context['debug']['sheets'])) { |
|
| 250 | + $context['debug']['sheets'] = array(); |
|
| 251 | + } |
|
| 239 | 252 | |
| 240 | 253 | $files = get_included_files(); |
| 241 | 254 | $total_size = 0; |
| 242 | 255 | for ($i = 0, $n = count($files); $i < $n; $i++) |
| 243 | 256 | { |
| 244 | - if (file_exists($files[$i])) |
|
| 245 | - $total_size += filesize($files[$i]); |
|
| 257 | + if (file_exists($files[$i])) { |
|
| 258 | + $total_size += filesize($files[$i]); |
|
| 259 | + } |
|
| 246 | 260 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
| 247 | 261 | } |
| 248 | 262 | |
@@ -251,8 +265,9 @@ discard block |
||
| 251 | 265 | { |
| 252 | 266 | foreach ($db_cache as $q => $qq) |
| 253 | 267 | { |
| 254 | - if (!empty($qq['w'])) |
|
| 255 | - $warnings += count($qq['w']); |
|
| 268 | + if (!empty($qq['w'])) { |
|
| 269 | + $warnings += count($qq['w']); |
|
| 270 | + } |
|
| 256 | 271 | } |
| 257 | 272 | |
| 258 | 273 | $_SESSION['debug'] = &$db_cache; |
@@ -273,12 +288,14 @@ discard block |
||
| 273 | 288 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
| 274 | 289 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
| 275 | 290 | |
| 276 | - if (function_exists('memory_get_peak_usage')) |
|
| 277 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 291 | + if (function_exists('memory_get_peak_usage')) { |
|
| 292 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
| 293 | + } |
|
| 278 | 294 | |
| 279 | 295 | // What tokens are active? |
| 280 | - if (isset($_SESSION['token'])) |
|
| 281 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 296 | + if (isset($_SESSION['token'])) { |
|
| 297 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
| 298 | + } |
|
| 282 | 299 | |
| 283 | 300 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
| 284 | 301 | { |
@@ -292,10 +309,12 @@ discard block |
||
| 292 | 309 | $total_t += $cache_hit['t']; |
| 293 | 310 | $total_s += $cache_hit['s']; |
| 294 | 311 | } |
| 295 | - if (!isset($cache_misses)) |
|
| 296 | - $cache_misses = array(); |
|
| 297 | - foreach ($cache_misses as $missed) |
|
| 298 | - $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
| 312 | + if (!isset($cache_misses)) { |
|
| 313 | + $cache_misses = array(); |
|
| 314 | + } |
|
| 315 | + foreach ($cache_misses as $missed) { |
|
| 316 | + $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
| 317 | + } |
|
| 299 | 318 | |
| 300 | 319 | echo ' |
| 301 | 320 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -306,38 +325,44 @@ discard block |
||
| 306 | 325 | <a href="', $scripturl, '?action=viewquery" target="_blank">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
| 307 | 326 | <br>'; |
| 308 | 327 | |
| 309 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
| 310 | - foreach ($db_cache as $q => $qq) |
|
| 328 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
| 329 | + foreach ($db_cache as $q => $qq) |
|
| 311 | 330 | { |
| 312 | 331 | $is_select = strpos(trim($qq['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($qq['q'])) != 0; |
| 332 | + } |
|
| 313 | 333 | // Temporary tables created in earlier queries are not explainable. |
| 314 | 334 | if ($is_select) |
| 315 | 335 | { |
| 316 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
| 317 | - if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 336 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
| 337 | + if (strpos(trim($qq['q']), $tmp) !== false) |
|
| 318 | 338 | { |
| 319 | 339 | $is_select = false; |
| 340 | + } |
|
| 320 | 341 | break; |
| 321 | 342 | } |
| 322 | 343 | } |
| 323 | 344 | // But actual creation of the temporary tables are. |
| 324 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) |
|
| 325 | - $is_select = true; |
|
| 345 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) { |
|
| 346 | + $is_select = true; |
|
| 347 | + } |
|
| 326 | 348 | |
| 327 | 349 | // Make the filenames look a bit better. |
| 328 | - if (isset($qq['f'])) |
|
| 329 | - $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 350 | + if (isset($qq['f'])) { |
|
| 351 | + $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']); |
|
| 352 | + } |
|
| 330 | 353 | |
| 331 | 354 | echo ' |
| 332 | 355 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
| 333 | 356 | '; |
| 334 | - if (!empty($qq['f']) && !empty($qq['l'])) |
|
| 335 | - echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 357 | + if (!empty($qq['f']) && !empty($qq['l'])) { |
|
| 358 | + echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']); |
|
| 359 | + } |
|
| 336 | 360 | |
| 337 | - if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) |
|
| 338 | - echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 339 | - elseif (isset($qq['t'])) |
|
| 340 | - echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 361 | + if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) { |
|
| 362 | + echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br>'; |
|
| 363 | + } elseif (isset($qq['t'])) { |
|
| 364 | + echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br>'; |
|
| 365 | + } |
|
| 341 | 366 | echo ' |
| 342 | 367 | <br>'; |
| 343 | 368 | } |
@@ -362,12 +387,14 @@ discard block |
||
| 362 | 387 | global $modSettings, $smcFunc; |
| 363 | 388 | static $cache_stats = array(); |
| 364 | 389 | |
| 365 | - if (empty($modSettings['trackStats'])) |
|
| 366 | - return false; |
|
| 367 | - if (!empty($stats)) |
|
| 368 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
| 369 | - elseif (empty($cache_stats)) |
|
| 370 | - return false; |
|
| 390 | + if (empty($modSettings['trackStats'])) { |
|
| 391 | + return false; |
|
| 392 | + } |
|
| 393 | + if (!empty($stats)) { |
|
| 394 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
| 395 | + } elseif (empty($cache_stats)) { |
|
| 396 | + return false; |
|
| 397 | + } |
|
| 371 | 398 | |
| 372 | 399 | $setStringUpdate = ''; |
| 373 | 400 | $insert_keys = array(); |
@@ -380,10 +407,11 @@ discard block |
||
| 380 | 407 | $setStringUpdate .= ' |
| 381 | 408 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
| 382 | 409 | |
| 383 | - if ($change === '+') |
|
| 384 | - $cache_stats[$field] = 1; |
|
| 385 | - else |
|
| 386 | - $update_parameters[$field] = $change; |
|
| 410 | + if ($change === '+') { |
|
| 411 | + $cache_stats[$field] = 1; |
|
| 412 | + } else { |
|
| 413 | + $update_parameters[$field] = $change; |
|
| 414 | + } |
|
| 387 | 415 | $insert_keys[$field] = 'int'; |
| 388 | 416 | } |
| 389 | 417 | |
@@ -447,43 +475,50 @@ discard block |
||
| 447 | 475 | ); |
| 448 | 476 | |
| 449 | 477 | // Make sure this particular log is enabled first... |
| 450 | - if (empty($modSettings['modlog_enabled'])) |
|
| 451 | - unset ($log_types['moderate']); |
|
| 452 | - if (empty($modSettings['userlog_enabled'])) |
|
| 453 | - unset ($log_types['user']); |
|
| 454 | - if (empty($modSettings['adminlog_enabled'])) |
|
| 455 | - unset ($log_types['admin']); |
|
| 478 | + if (empty($modSettings['modlog_enabled'])) { |
|
| 479 | + unset ($log_types['moderate']); |
|
| 480 | + } |
|
| 481 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 482 | + unset ($log_types['user']); |
|
| 483 | + } |
|
| 484 | + if (empty($modSettings['adminlog_enabled'])) { |
|
| 485 | + unset ($log_types['admin']); |
|
| 486 | + } |
|
| 456 | 487 | |
| 457 | 488 | call_integration_hook('integrate_log_types', array(&$log_types)); |
| 458 | 489 | |
| 459 | 490 | foreach ($logs as $log) |
| 460 | 491 | { |
| 461 | - if (!isset($log_types[$log['log_type']])) |
|
| 462 | - return false; |
|
| 492 | + if (!isset($log_types[$log['log_type']])) { |
|
| 493 | + return false; |
|
| 494 | + } |
|
| 463 | 495 | |
| 464 | - if (!is_array($log['extra'])) |
|
| 465 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 496 | + if (!is_array($log['extra'])) { |
|
| 497 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
| 498 | + } |
|
| 466 | 499 | |
| 467 | 500 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
| 468 | 501 | if (isset($log['extra']['topic'])) |
| 469 | 502 | { |
| 470 | - if (!is_numeric($log['extra']['topic'])) |
|
| 471 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 503 | + if (!is_numeric($log['extra']['topic'])) { |
|
| 504 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
| 505 | + } |
|
| 472 | 506 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
| 473 | 507 | unset($log['extra']['topic']); |
| 508 | + } else { |
|
| 509 | + $topic_id = 0; |
|
| 474 | 510 | } |
| 475 | - else |
|
| 476 | - $topic_id = 0; |
|
| 477 | 511 | |
| 478 | 512 | if (isset($log['extra']['message'])) |
| 479 | 513 | { |
| 480 | - if (!is_numeric($log['extra']['message'])) |
|
| 481 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 514 | + if (!is_numeric($log['extra']['message'])) { |
|
| 515 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
| 516 | + } |
|
| 482 | 517 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
| 483 | 518 | unset($log['extra']['message']); |
| 519 | + } else { |
|
| 520 | + $msg_id = 0; |
|
| 484 | 521 | } |
| 485 | - else |
|
| 486 | - $msg_id = 0; |
|
| 487 | 522 | |
| 488 | 523 | // @todo cache this? |
| 489 | 524 | // Is there an associated report on this? |
@@ -510,23 +545,26 @@ discard block |
||
| 510 | 545 | $smcFunc['db_free_result']($request); |
| 511 | 546 | } |
| 512 | 547 | |
| 513 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
| 514 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 548 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
| 549 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
| 550 | + } |
|
| 515 | 551 | |
| 516 | 552 | if (isset($log['extra']['board'])) |
| 517 | 553 | { |
| 518 | - if (!is_numeric($log['extra']['board'])) |
|
| 519 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 554 | + if (!is_numeric($log['extra']['board'])) { |
|
| 555 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
| 556 | + } |
|
| 520 | 557 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
| 521 | 558 | unset($log['extra']['board']); |
| 559 | + } else { |
|
| 560 | + $board_id = 0; |
|
| 522 | 561 | } |
| 523 | - else |
|
| 524 | - $board_id = 0; |
|
| 525 | 562 | |
| 526 | 563 | if (isset($log['extra']['board_to'])) |
| 527 | 564 | { |
| 528 | - if (!is_numeric($log['extra']['board_to'])) |
|
| 529 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 565 | + if (!is_numeric($log['extra']['board_to'])) { |
|
| 566 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
| 567 | + } |
|
| 530 | 568 | if (empty($board_id)) |
| 531 | 569 | { |
| 532 | 570 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -534,10 +572,11 @@ discard block |
||
| 534 | 572 | } |
| 535 | 573 | } |
| 536 | 574 | |
| 537 | - if (isset($log['extra']['member_affected'])) |
|
| 538 | - $memID = $log['extra']['member_affected']; |
|
| 539 | - else |
|
| 540 | - $memID = $user_info['id']; |
|
| 575 | + if (isset($log['extra']['member_affected'])) { |
|
| 576 | + $memID = $log['extra']['member_affected']; |
|
| 577 | + } else { |
|
| 578 | + $memID = $user_info['id']; |
|
| 579 | + } |
|
| 541 | 580 | |
| 542 | 581 | $inserts[] = array( |
| 543 | 582 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |
@@ -185,17 +185,21 @@ |
||
| 185 | 185 | $tasksdir = $sourcedir . '/tasks'; |
| 186 | 186 | |
| 187 | 187 | # Make sure the paths are correct... at least try to fix them. |
| 188 | -if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) |
|
| 188 | +if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt')) { |
|
| 189 | 189 | $boarddir = dirname(__FILE__); |
| 190 | -if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) |
|
| 190 | +} |
|
| 191 | +if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources')) { |
|
| 191 | 192 | $sourcedir = $boarddir . '/Sources'; |
| 192 | -if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) |
|
| 193 | +} |
|
| 194 | +if (!file_exists($cachedir) && file_exists($boarddir . '/cache')) { |
|
| 193 | 195 | $cachedir = $boarddir . '/cache'; |
| 196 | +} |
|
| 194 | 197 | |
| 195 | 198 | ########## Error-Catching ########## |
| 196 | 199 | # Note: You shouldn't touch these settings. |
| 197 | -if (file_exists($cachedir . '/db_last_error.php')) |
|
| 200 | +if (file_exists($cachedir . '/db_last_error.php')) { |
|
| 198 | 201 | include($cachedir . '/db_last_error.php'); |
| 202 | +} |
|
| 199 | 203 | |
| 200 | 204 | if (!isset($db_last_error)) |
| 201 | 205 | { |
@@ -75,8 +75,9 @@ discard block |
||
| 75 | 75 | $upcontext['inactive_timeout'] = 10; |
| 76 | 76 | |
| 77 | 77 | // The helper is crucial. Include it first thing. |
| 78 | -if (!file_exists($upgrade_path . '/upgrade-helper.php')) |
|
| 78 | +if (!file_exists($upgrade_path . '/upgrade-helper.php')) { |
|
| 79 | 79 | die('upgrade-helper.php not found where it was expected: ' . $upgrade_path . '/upgrade-helper.php! Make sure you have uploaded ALL files from the upgrade package. The upgrader cannot continue.'); |
| 80 | +} |
|
| 80 | 81 | |
| 81 | 82 | require_once($upgrade_path . '/upgrade-helper.php'); |
| 82 | 83 | |
@@ -100,11 +101,14 @@ discard block |
||
| 100 | 101 | ini_set('default_socket_timeout', 900); |
| 101 | 102 | } |
| 102 | 103 | // Clean the upgrade path if this is from the client. |
| 103 | -if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) |
|
| 104 | - for ($i = 1; $i < $_SERVER['argc']; $i++) |
|
| 104 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 105 | + for ($i = 1; |
|
| 106 | +} |
|
| 107 | +$i < $_SERVER['argc']; $i++) |
|
| 105 | 108 | { |
| 106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 109 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 110 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 111 | + } |
|
| 108 | 112 | } |
| 109 | 113 | |
| 110 | 114 | // Are we from the client? |
@@ -112,16 +116,17 @@ discard block |
||
| 112 | 116 | { |
| 113 | 117 | $command_line = true; |
| 114 | 118 | $disable_security = true; |
| 115 | -} |
|
| 116 | -else |
|
| 119 | +} else { |
|
| 117 | 120 | $command_line = false; |
| 121 | +} |
|
| 118 | 122 | |
| 119 | 123 | // Load this now just because we can. |
| 120 | 124 | require_once($upgrade_path . '/Settings.php'); |
| 121 | 125 | |
| 122 | 126 | // We don't use "-utf8" anymore... Tweak the entry that may have been loaded by Settings.php |
| 123 | -if (isset($language)) |
|
| 127 | +if (isset($language)) { |
|
| 124 | 128 | $language = str_ireplace('-utf8', '', $language); |
| 129 | +} |
|
| 125 | 130 | |
| 126 | 131 | // Are we logged in? |
| 127 | 132 | if (isset($upgradeData)) |
@@ -129,10 +134,12 @@ discard block |
||
| 129 | 134 | $upcontext['user'] = json_decode(base64_decode($upgradeData), true); |
| 130 | 135 | |
| 131 | 136 | // Check for sensible values. |
| 132 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
| 133 | - $upcontext['user']['started'] = time(); |
|
| 134 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
| 135 | - $upcontext['user']['updated'] = 0; |
|
| 137 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 138 | + $upcontext['user']['started'] = time(); |
|
| 139 | + } |
|
| 140 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 141 | + $upcontext['user']['updated'] = 0; |
|
| 142 | + } |
|
| 136 | 143 | |
| 137 | 144 | $upcontext['started'] = $upcontext['user']['started']; |
| 138 | 145 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -197,8 +204,9 @@ discard block |
||
| 197 | 204 | 'db_error_skip' => true, |
| 198 | 205 | ) |
| 199 | 206 | ); |
| 200 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 201 | - $modSettings[$row['variable']] = $row['value']; |
|
| 207 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 208 | + $modSettings[$row['variable']] = $row['value']; |
|
| 209 | + } |
|
| 202 | 210 | $smcFunc['db_free_result']($request); |
| 203 | 211 | } |
| 204 | 212 | |
@@ -208,10 +216,12 @@ discard block |
||
| 208 | 216 | $modSettings['theme_url'] = 'Themes/default'; |
| 209 | 217 | $modSettings['images_url'] = 'Themes/default/images'; |
| 210 | 218 | } |
| 211 | -if (!isset($settings['default_theme_url'])) |
|
| 219 | +if (!isset($settings['default_theme_url'])) { |
|
| 212 | 220 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 213 | -if (!isset($settings['default_theme_dir'])) |
|
| 221 | +} |
|
| 222 | +if (!isset($settings['default_theme_dir'])) { |
|
| 214 | 223 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 224 | +} |
|
| 215 | 225 | |
| 216 | 226 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 217 | 227 | // Default title... |
@@ -229,13 +239,15 @@ discard block |
||
| 229 | 239 | $support_js = $upcontext['upgrade_status']['js']; |
| 230 | 240 | |
| 231 | 241 | // Only set this if the upgrader status says so. |
| 232 | - if (empty($is_debug)) |
|
| 233 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 242 | + if (empty($is_debug)) { |
|
| 243 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 244 | + } |
|
| 234 | 245 | |
| 235 | 246 | // Load the language. |
| 236 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 237 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 238 | -} |
|
| 247 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 248 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 249 | + } |
|
| 250 | + } |
|
| 239 | 251 | // Set the defaults. |
| 240 | 252 | else |
| 241 | 253 | { |
@@ -253,15 +265,18 @@ discard block |
||
| 253 | 265 | } |
| 254 | 266 | |
| 255 | 267 | // If this isn't the first stage see whether they are logging in and resuming. |
| 256 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 268 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 257 | 269 | checkLogin(); |
| 270 | +} |
|
| 258 | 271 | |
| 259 | -if ($command_line) |
|
| 272 | +if ($command_line) { |
|
| 260 | 273 | cmdStep0(); |
| 274 | +} |
|
| 261 | 275 | |
| 262 | 276 | // Don't error if we're using xml. |
| 263 | -if (isset($_GET['xml'])) |
|
| 277 | +if (isset($_GET['xml'])) { |
|
| 264 | 278 | $upcontext['return_error'] = true; |
| 279 | +} |
|
| 265 | 280 | |
| 266 | 281 | // Loop through all the steps doing each one as required. |
| 267 | 282 | $upcontext['overall_percent'] = 0; |
@@ -282,9 +297,9 @@ discard block |
||
| 282 | 297 | } |
| 283 | 298 | |
| 284 | 299 | // Call the step and if it returns false that means pause! |
| 285 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 286 | - break; |
|
| 287 | - elseif (function_exists($step[2])) { |
|
| 300 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 301 | + break; |
|
| 302 | + } elseif (function_exists($step[2])) { |
|
| 288 | 303 | //Start each new step with this unset, so the 'normal' template is called first |
| 289 | 304 | unset($_GET['xml']); |
| 290 | 305 | //Clear out warnings at the start of each step |
@@ -330,17 +345,18 @@ discard block |
||
| 330 | 345 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 331 | 346 | if (!empty($command_line)) |
| 332 | 347 | { |
| 333 | - if (function_exists('debug_print_backtrace')) |
|
| 334 | - debug_print_backtrace(); |
|
| 348 | + if (function_exists('debug_print_backtrace')) { |
|
| 349 | + debug_print_backtrace(); |
|
| 350 | + } |
|
| 335 | 351 | |
| 336 | 352 | echo "\n" . 'Error: Unexpected call to use the ' . (isset($upcontext['sub_template']) ? $upcontext['sub_template'] : '') . ' template. Please copy and paste all the text above and visit the SMF support forum to tell the Developers that they\'ve made a boo boo; they\'ll get you up and running again.'; |
| 337 | 353 | flush(); |
| 338 | 354 | die(); |
| 339 | 355 | } |
| 340 | 356 | |
| 341 | - if (!isset($_GET['xml'])) |
|
| 342 | - template_upgrade_above(); |
|
| 343 | - else |
|
| 357 | + if (!isset($_GET['xml'])) { |
|
| 358 | + template_upgrade_above(); |
|
| 359 | + } else |
|
| 344 | 360 | { |
| 345 | 361 | header('Content-Type: text/xml; charset=UTF-8'); |
| 346 | 362 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -362,25 +378,29 @@ discard block |
||
| 362 | 378 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(json_encode($upcontext['upgrade_status'])); |
| 363 | 379 | |
| 364 | 380 | // Custom stuff to pass back? |
| 365 | - if (!empty($upcontext['query_string'])) |
|
| 366 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 381 | + if (!empty($upcontext['query_string'])) { |
|
| 382 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 383 | + } |
|
| 367 | 384 | |
| 368 | 385 | // Call the appropriate subtemplate |
| 369 | - if (is_callable('template_' . $upcontext['sub_template'])) |
|
| 370 | - call_user_func('template_' . $upcontext['sub_template']); |
|
| 371 | - else |
|
| 372 | - die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 386 | + if (is_callable('template_' . $upcontext['sub_template'])) { |
|
| 387 | + call_user_func('template_' . $upcontext['sub_template']); |
|
| 388 | + } else { |
|
| 389 | + die('Upgrade aborted! Invalid template: template_' . $upcontext['sub_template']); |
|
| 390 | + } |
|
| 373 | 391 | } |
| 374 | 392 | |
| 375 | 393 | // Was there an error? |
| 376 | - if (!empty($upcontext['forced_error_message'])) |
|
| 377 | - echo $upcontext['forced_error_message']; |
|
| 394 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 395 | + echo $upcontext['forced_error_message']; |
|
| 396 | + } |
|
| 378 | 397 | |
| 379 | 398 | // Show the footer. |
| 380 | - if (!isset($_GET['xml'])) |
|
| 381 | - template_upgrade_below(); |
|
| 382 | - else |
|
| 383 | - template_xml_below(); |
|
| 399 | + if (!isset($_GET['xml'])) { |
|
| 400 | + template_upgrade_below(); |
|
| 401 | + } else { |
|
| 402 | + template_xml_below(); |
|
| 403 | + } |
|
| 384 | 404 | } |
| 385 | 405 | |
| 386 | 406 | |
@@ -392,15 +412,19 @@ discard block |
||
| 392 | 412 | $seconds = intval($active % 60); |
| 393 | 413 | |
| 394 | 414 | $totalTime = ''; |
| 395 | - if ($hours > 0) |
|
| 396 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 397 | - if ($minutes > 0) |
|
| 398 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 399 | - if ($seconds > 0) |
|
| 400 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 415 | + if ($hours > 0) { |
|
| 416 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 417 | + } |
|
| 418 | + if ($minutes > 0) { |
|
| 419 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 420 | + } |
|
| 421 | + if ($seconds > 0) { |
|
| 422 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 423 | + } |
|
| 401 | 424 | |
| 402 | - if (!empty($totalTime)) |
|
| 403 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 425 | + if (!empty($totalTime)) { |
|
| 426 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 427 | + } |
|
| 404 | 428 | } |
| 405 | 429 | |
| 406 | 430 | // Bang - gone! |
@@ -413,8 +437,9 @@ discard block |
||
| 413 | 437 | global $upgradeurl, $upcontext, $command_line; |
| 414 | 438 | |
| 415 | 439 | // Command line users can't be redirected. |
| 416 | - if ($command_line) |
|
| 417 | - upgradeExit(true); |
|
| 440 | + if ($command_line) { |
|
| 441 | + upgradeExit(true); |
|
| 442 | + } |
|
| 418 | 443 | |
| 419 | 444 | // Are we providing the core info? |
| 420 | 445 | if ($addForm) |
@@ -440,12 +465,14 @@ discard block |
||
| 440 | 465 | define('SMF', 1); |
| 441 | 466 | |
| 442 | 467 | // Start the session. |
| 443 | - if (@ini_get('session.save_handler') == 'user') |
|
| 444 | - @ini_set('session.save_handler', 'files'); |
|
| 468 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 469 | + @ini_set('session.save_handler', 'files'); |
|
| 470 | + } |
|
| 445 | 471 | @session_start(); |
| 446 | 472 | |
| 447 | - if (empty($smcFunc)) |
|
| 448 | - $smcFunc = array(); |
|
| 473 | + if (empty($smcFunc)) { |
|
| 474 | + $smcFunc = array(); |
|
| 475 | + } |
|
| 449 | 476 | |
| 450 | 477 | // We need this for authentication and some upgrade code |
| 451 | 478 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -472,24 +499,27 @@ discard block |
||
| 472 | 499 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 473 | 500 | |
| 474 | 501 | // Make the connection... |
| 475 | - if (empty($db_connection)) |
|
| 476 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 477 | - else |
|
| 478 | - // If we've returned here, ping/reconnect to be safe |
|
| 502 | + if (empty($db_connection)) { |
|
| 503 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
|
| 504 | + } else { |
|
| 505 | + // If we've returned here, ping/reconnect to be safe |
|
| 479 | 506 | $smcFunc['db_ping']($db_connection); |
| 507 | + } |
|
| 480 | 508 | |
| 481 | 509 | // Oh dear god!! |
| 482 | - if ($db_connection === null) |
|
| 483 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 510 | + if ($db_connection === null) { |
|
| 511 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 512 | + } |
|
| 484 | 513 | |
| 485 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 486 | - $smcFunc['db_query']('', ' |
|
| 514 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 515 | + $smcFunc['db_query']('', ' |
|
| 487 | 516 | SET NAMES {string:db_character_set}', |
| 488 | 517 | array( |
| 489 | 518 | 'db_error_skip' => true, |
| 490 | 519 | 'db_character_set' => $db_character_set, |
| 491 | 520 | ) |
| 492 | 521 | ); |
| 522 | + } |
|
| 493 | 523 | |
| 494 | 524 | // Load the modSettings data... |
| 495 | 525 | $request = $smcFunc['db_query']('', ' |
@@ -500,11 +530,11 @@ discard block |
||
| 500 | 530 | ) |
| 501 | 531 | ); |
| 502 | 532 | $modSettings = array(); |
| 503 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 504 | - $modSettings[$row['variable']] = $row['value']; |
|
| 533 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 534 | + $modSettings[$row['variable']] = $row['value']; |
|
| 535 | + } |
|
| 505 | 536 | $smcFunc['db_free_result']($request); |
| 506 | - } |
|
| 507 | - else |
|
| 537 | + } else |
|
| 508 | 538 | { |
| 509 | 539 | return throw_error('Cannot find ' . $sourcedir . '/Subs-Db-' . $db_type . '.php' . '. Please check you have uploaded all source files and have the correct paths set.'); |
| 510 | 540 | } |
@@ -518,9 +548,10 @@ discard block |
||
| 518 | 548 | cleanRequest(); |
| 519 | 549 | } |
| 520 | 550 | |
| 521 | - if (!isset($_GET['substep'])) |
|
| 522 | - $_GET['substep'] = 0; |
|
| 523 | -} |
|
| 551 | + if (!isset($_GET['substep'])) { |
|
| 552 | + $_GET['substep'] = 0; |
|
| 553 | + } |
|
| 554 | + } |
|
| 524 | 555 | |
| 525 | 556 | function initialize_inputs() |
| 526 | 557 | { |
@@ -550,8 +581,9 @@ discard block |
||
| 550 | 581 | $dh = opendir(dirname(__FILE__)); |
| 551 | 582 | while ($file = readdir($dh)) |
| 552 | 583 | { |
| 553 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 554 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 584 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 585 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 586 | + } |
|
| 555 | 587 | } |
| 556 | 588 | closedir($dh); |
| 557 | 589 | |
@@ -580,8 +612,9 @@ discard block |
||
| 580 | 612 | $temp = 'upgrade_php?step'; |
| 581 | 613 | while (strlen($temp) > 4) |
| 582 | 614 | { |
| 583 | - if (isset($_GET[$temp])) |
|
| 584 | - unset($_GET[$temp]); |
|
| 615 | + if (isset($_GET[$temp])) { |
|
| 616 | + unset($_GET[$temp]); |
|
| 617 | + } |
|
| 585 | 618 | $temp = substr($temp, 1); |
| 586 | 619 | } |
| 587 | 620 | |
@@ -608,32 +641,39 @@ discard block |
||
| 608 | 641 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
| 609 | 642 | |
| 610 | 643 | // Need legacy scripts? |
| 611 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 612 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 613 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 614 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 615 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 616 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 644 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 645 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
| 646 | + } |
|
| 647 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 648 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 649 | + } |
|
| 650 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 651 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 652 | + } |
|
| 617 | 653 | |
| 618 | 654 | // We don't need "-utf8" files anymore... |
| 619 | 655 | $upcontext['language'] = str_ireplace('-utf8', '', $upcontext['language']); |
| 620 | 656 | |
| 621 | 657 | // This needs to exist! |
| 622 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 623 | - return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 624 | - else |
|
| 625 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 658 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 659 | + return throw_error('The upgrader could not find the "Install" language file for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 660 | + } else { |
|
| 661 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 662 | + } |
|
| 626 | 663 | |
| 627 | - if (!$check) |
|
| 628 | - // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 664 | + if (!$check) { |
|
| 665 | + // Don't tell them what files exactly because it's a spot check - just like teachers don't tell which problems they are spot checking, that's dumb. |
|
| 629 | 666 | return throw_error('The upgrader was unable to find some crucial files.<br><br>Please make sure you uploaded all of the files included in the package, including the Themes, Sources, and other directories.'); |
| 667 | + } |
|
| 630 | 668 | |
| 631 | 669 | // Do they meet the install requirements? |
| 632 | - if (!php_version_check()) |
|
| 633 | - return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 670 | + if (!php_version_check()) { |
|
| 671 | + return throw_error('Warning! You do not appear to have a version of PHP installed on your webserver that meets SMF\'s minimum installations requirements.<br><br>Please ask your host to upgrade.'); |
|
| 672 | + } |
|
| 634 | 673 | |
| 635 | - if (!db_version_check()) |
|
| 636 | - return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 674 | + if (!db_version_check()) { |
|
| 675 | + return throw_error('Your ' . $databases[$db_type]['name'] . ' version does not meet the minimum requirements of SMF.<br><br>Please ask your host to upgrade.'); |
|
| 676 | + } |
|
| 637 | 677 | |
| 638 | 678 | // Do some checks to make sure they have proper privileges |
| 639 | 679 | db_extend('packages'); |
@@ -648,14 +688,16 @@ discard block |
||
| 648 | 688 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 649 | 689 | |
| 650 | 690 | // Sorry... we need CREATE, ALTER and DROP |
| 651 | - if (!$create || !$alter || !$drop) |
|
| 652 | - return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 691 | + if (!$create || !$alter || !$drop) { |
|
| 692 | + return throw_error('The ' . $databases[$db_type]['name'] . ' user you have set in Settings.php does not have proper privileges.<br><br>Please ask your host to give this user the ALTER, CREATE, and DROP privileges.'); |
|
| 693 | + } |
|
| 653 | 694 | |
| 654 | 695 | // Do a quick version spot check. |
| 655 | 696 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 656 | 697 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 657 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 658 | - return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 698 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 699 | + return throw_error('The upgrader found some old or outdated files.<br><br>Please make certain you uploaded the new versions of all the files included in the package.'); |
|
| 700 | + } |
|
| 659 | 701 | |
| 660 | 702 | // What absolutely needs to be writable? |
| 661 | 703 | $writable_files = array( |
@@ -664,12 +706,13 @@ discard block |
||
| 664 | 706 | ); |
| 665 | 707 | |
| 666 | 708 | // Only check for minified writable files if we have it enabled or not set. |
| 667 | - if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) |
|
| 668 | - $writable_files += array( |
|
| 709 | + if (!empty($modSettings['minimize_files']) || !isset($modSettings['minimize_files'])) { |
|
| 710 | + $writable_files += array( |
|
| 669 | 711 | $modSettings['theme_dir'] . '/css/minified.css', |
| 670 | 712 | $modSettings['theme_dir'] . '/scripts/minified.js', |
| 671 | 713 | $modSettings['theme_dir'] . '/scripts/minified_deferred.js', |
| 672 | 714 | ); |
| 715 | + } |
|
| 673 | 716 | |
| 674 | 717 | // Do we need to add this setting? |
| 675 | 718 | $need_settings_update = empty($modSettings['custom_avatar_dir']); |
@@ -681,12 +724,13 @@ discard block |
||
| 681 | 724 | quickFileWritable($custom_av_dir); |
| 682 | 725 | |
| 683 | 726 | // Are we good now? |
| 684 | - if (!is_writable($custom_av_dir)) |
|
| 685 | - return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 686 | - elseif ($need_settings_update) |
|
| 727 | + if (!is_writable($custom_av_dir)) { |
|
| 728 | + return throw_error(sprintf('The directory: %1$s has to be writable to continue the upgrade. Please make sure permissions are correctly set to allow this.', $custom_av_dir)); |
|
| 729 | + } elseif ($need_settings_update) |
|
| 687 | 730 | { |
| 688 | - if (!function_exists('cache_put_data')) |
|
| 689 | - require_once($sourcedir . '/Load.php'); |
|
| 731 | + if (!function_exists('cache_put_data')) { |
|
| 732 | + require_once($sourcedir . '/Load.php'); |
|
| 733 | + } |
|
| 690 | 734 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 691 | 735 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 692 | 736 | } |
@@ -695,28 +739,33 @@ discard block |
||
| 695 | 739 | |
| 696 | 740 | // Check the cache directory. |
| 697 | 741 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 698 | - if (!file_exists($cachedir_temp)) |
|
| 699 | - @mkdir($cachedir_temp); |
|
| 700 | - if (!file_exists($cachedir_temp)) |
|
| 701 | - return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 702 | - |
|
| 703 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 704 | - return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 705 | - elseif (!isset($_GET['skiplang'])) |
|
| 742 | + if (!file_exists($cachedir_temp)) { |
|
| 743 | + @mkdir($cachedir_temp); |
|
| 744 | + } |
|
| 745 | + if (!file_exists($cachedir_temp)) { |
|
| 746 | + return throw_error('The cache directory could not be found.<br><br>Please make sure you have a directory called "cache" in your forum directory before continuing.'); |
|
| 747 | + } |
|
| 748 | + |
|
| 749 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 750 | + return throw_error('The upgrader was unable to find language files for the language specified in Settings.php.<br>SMF will not work without the primary language files installed.<br><br>Please either install them, or <a href="' . $upgradeurl . '?step=0;lang=english">use english instead</a>.'); |
|
| 751 | + } elseif (!isset($_GET['skiplang'])) |
|
| 706 | 752 | { |
| 707 | 753 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 708 | 754 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 709 | 755 | |
| 710 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 711 | - return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 756 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 757 | + return throw_error('The upgrader found some old or outdated language files, for the forum default language, ' . $upcontext['language'] . '.<br><br>Please make certain you uploaded the new versions of all the files included in the package, even the theme and language files for the default theme.<br> [<a href="' . $upgradeurl . '?skiplang">SKIP</a>] [<a href="' . $upgradeurl . '?lang=english">Try English</a>]'); |
|
| 758 | + } |
|
| 712 | 759 | } |
| 713 | 760 | |
| 714 | - if (!makeFilesWritable($writable_files)) |
|
| 715 | - return false; |
|
| 761 | + if (!makeFilesWritable($writable_files)) { |
|
| 762 | + return false; |
|
| 763 | + } |
|
| 716 | 764 | |
| 717 | 765 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 718 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 719 | - return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 766 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 767 | + return throw_error('The upgrader was unable to obtain write access to agreement.txt.<br><br>If you are using a linux or unix based server, please ensure that the file is chmod\'d to 777, or if it does not exist that the directory this upgrader is in is 777.<br>If your server is running Windows, please ensure that the internet guest account has the proper permissions on it or its folder.'); |
|
| 768 | + } |
|
| 720 | 769 | |
| 721 | 770 | // Upgrade the agreement. |
| 722 | 771 | elseif (isset($modSettings['agreement'])) |
@@ -727,8 +776,8 @@ discard block |
||
| 727 | 776 | } |
| 728 | 777 | |
| 729 | 778 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 730 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 731 | - $upcontext['warning'] = ' |
|
| 779 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 780 | + $upcontext['warning'] = ' |
|
| 732 | 781 | It looks as if your board directory settings <em>might</em> be incorrect. Your board directory is currently set to "' . $boarddir . '" but should probably be "' . dirname(__FILE__) . '". Settings.php currently lists your paths as:<br> |
| 733 | 782 | <ul> |
| 734 | 783 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -736,19 +785,23 @@ discard block |
||
| 736 | 785 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 737 | 786 | </ul> |
| 738 | 787 | If these seem incorrect please open Settings.php in a text editor before proceeding with this upgrade. If they are incorrect due to you moving your forum to a new location please download and execute the <a href="https://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 788 | + } |
|
| 739 | 789 | |
| 740 | 790 | // Confirm mbstring is loaded... |
| 741 | - if (!extension_loaded('mbstring')) |
|
| 742 | - return throw_error($txt['install_no_mbstring']); |
|
| 791 | + if (!extension_loaded('mbstring')) { |
|
| 792 | + return throw_error($txt['install_no_mbstring']); |
|
| 793 | + } |
|
| 743 | 794 | |
| 744 | 795 | // Check for https stream support. |
| 745 | 796 | $supported_streams = stream_get_wrappers(); |
| 746 | - if (!in_array('https', $supported_streams)) |
|
| 747 | - $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 797 | + if (!in_array('https', $supported_streams)) { |
|
| 798 | + $upcontext['custom_warning'] = $txt['install_no_https']; |
|
| 799 | + } |
|
| 748 | 800 | |
| 749 | 801 | // Either we're logged in or we're going to present the login. |
| 750 | - if (checkLogin()) |
|
| 751 | - return true; |
|
| 802 | + if (checkLogin()) { |
|
| 803 | + return true; |
|
| 804 | + } |
|
| 752 | 805 | |
| 753 | 806 | $upcontext += createToken('login'); |
| 754 | 807 | |
@@ -762,15 +815,17 @@ discard block |
||
| 762 | 815 | global $smcFunc, $db_type, $support_js; |
| 763 | 816 | |
| 764 | 817 | // Don't bother if the security is disabled. |
| 765 | - if ($disable_security) |
|
| 766 | - return true; |
|
| 818 | + if ($disable_security) { |
|
| 819 | + return true; |
|
| 820 | + } |
|
| 767 | 821 | |
| 768 | 822 | // Are we trying to login? |
| 769 | 823 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 770 | 824 | { |
| 771 | 825 | // If we've disabled security pick a suitable name! |
| 772 | - if (empty($_POST['user'])) |
|
| 773 | - $_POST['user'] = 'Administrator'; |
|
| 826 | + if (empty($_POST['user'])) { |
|
| 827 | + $_POST['user'] = 'Administrator'; |
|
| 828 | + } |
|
| 774 | 829 | |
| 775 | 830 | // Before 2.0 these column names were different! |
| 776 | 831 | $oldDB = false; |
@@ -785,16 +840,17 @@ discard block |
||
| 785 | 840 | 'db_error_skip' => true, |
| 786 | 841 | ) |
| 787 | 842 | ); |
| 788 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 789 | - $oldDB = true; |
|
| 843 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 844 | + $oldDB = true; |
|
| 845 | + } |
|
| 790 | 846 | $smcFunc['db_free_result']($request); |
| 791 | 847 | } |
| 792 | 848 | |
| 793 | 849 | // Get what we believe to be their details. |
| 794 | 850 | if (!$disable_security) |
| 795 | 851 | { |
| 796 | - if ($oldDB) |
|
| 797 | - $request = $smcFunc['db_query']('', ' |
|
| 852 | + if ($oldDB) { |
|
| 853 | + $request = $smcFunc['db_query']('', ' |
|
| 798 | 854 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 799 | 855 | additionalGroups AS additional_groups, lngfile |
| 800 | 856 | FROM {db_prefix}members |
@@ -804,8 +860,8 @@ discard block |
||
| 804 | 860 | 'db_error_skip' => true, |
| 805 | 861 | ) |
| 806 | 862 | ); |
| 807 | - else |
|
| 808 | - $request = $smcFunc['db_query']('', ' |
|
| 863 | + } else { |
|
| 864 | + $request = $smcFunc['db_query']('', ' |
|
| 809 | 865 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 810 | 866 | FROM {db_prefix}members |
| 811 | 867 | WHERE member_name = {string:member_name}', |
@@ -814,6 +870,7 @@ discard block |
||
| 814 | 870 | 'db_error_skip' => true, |
| 815 | 871 | ) |
| 816 | 872 | ); |
| 873 | + } |
|
| 817 | 874 | if ($smcFunc['db_num_rows']($request) != 0) |
| 818 | 875 | { |
| 819 | 876 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -821,16 +878,17 @@ discard block |
||
| 821 | 878 | $groups = explode(',', $addGroups); |
| 822 | 879 | $groups[] = $id_group; |
| 823 | 880 | |
| 824 | - foreach ($groups as $k => $v) |
|
| 825 | - $groups[$k] = (int) $v; |
|
| 881 | + foreach ($groups as $k => $v) { |
|
| 882 | + $groups[$k] = (int) $v; |
|
| 883 | + } |
|
| 826 | 884 | |
| 827 | 885 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 828 | 886 | |
| 829 | 887 | // We don't use "-utf8" anymore... |
| 830 | 888 | $user_language = str_ireplace('-utf8', '', $user_language); |
| 889 | + } else { |
|
| 890 | + $upcontext['username_incorrect'] = true; |
|
| 831 | 891 | } |
| 832 | - else |
|
| 833 | - $upcontext['username_incorrect'] = true; |
|
| 834 | 892 | $smcFunc['db_free_result']($request); |
| 835 | 893 | } |
| 836 | 894 | $upcontext['username'] = $_POST['user']; |
@@ -840,13 +898,14 @@ discard block |
||
| 840 | 898 | { |
| 841 | 899 | $upcontext['upgrade_status']['js'] = 1; |
| 842 | 900 | $support_js = 1; |
| 901 | + } else { |
|
| 902 | + $support_js = 0; |
|
| 843 | 903 | } |
| 844 | - else |
|
| 845 | - $support_js = 0; |
|
| 846 | 904 | |
| 847 | 905 | // Note down the version we are coming from. |
| 848 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 849 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 906 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 907 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 908 | + } |
|
| 850 | 909 | |
| 851 | 910 | // Didn't get anywhere? |
| 852 | 911 | if (!$disable_security && (empty($sha_passwd) || (!empty($password) ? $password : '') != $sha_passwd) && !hash_verify_password((!empty($name) ? $name : ''), $_REQUEST['passwrd'], (!empty($password) ? $password : '')) && empty($upcontext['username_incorrect'])) |
@@ -880,15 +939,15 @@ discard block |
||
| 880 | 939 | 'db_error_skip' => true, |
| 881 | 940 | ) |
| 882 | 941 | ); |
| 883 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 884 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 942 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 943 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 944 | + } |
|
| 885 | 945 | $smcFunc['db_free_result']($request); |
| 886 | 946 | } |
| 887 | 947 | |
| 888 | 948 | $upcontext['user']['id'] = $id_member; |
| 889 | 949 | $upcontext['user']['name'] = $name; |
| 890 | - } |
|
| 891 | - else |
|
| 950 | + } else |
|
| 892 | 951 | { |
| 893 | 952 | $upcontext['user']['id'] = 1; |
| 894 | 953 | $upcontext['user']['name'] = 'Administrator'; |
@@ -904,11 +963,11 @@ discard block |
||
| 904 | 963 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 905 | 964 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 906 | 965 | |
| 907 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 908 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 909 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 910 | - $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 911 | - else |
|
| 966 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 967 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been updated to the latest version. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 968 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 969 | + $upcontext['upgrade_options_warning'] = 'The language files for your selected language, ' . $user_language . ', have not been uploaded/updated as the "Install" language file is missing. Upgrade will continue with the forum default, ' . $upcontext['language'] . '.'; |
|
| 970 | + } else |
|
| 912 | 971 | { |
| 913 | 972 | // Set this as the new language. |
| 914 | 973 | $upcontext['language'] = $user_language; |
@@ -952,8 +1011,9 @@ discard block |
||
| 952 | 1011 | unset($member_columns); |
| 953 | 1012 | |
| 954 | 1013 | // If we've not submitted then we're done. |
| 955 | - if (empty($_POST['upcont'])) |
|
| 956 | - return false; |
|
| 1014 | + if (empty($_POST['upcont'])) { |
|
| 1015 | + return false; |
|
| 1016 | + } |
|
| 957 | 1017 | |
| 958 | 1018 | // Firstly, if they're enabling SM stat collection just do it. |
| 959 | 1019 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats'])) |
@@ -973,16 +1033,17 @@ discard block |
||
| 973 | 1033 | fwrite($fp, $out); |
| 974 | 1034 | |
| 975 | 1035 | $return_data = ''; |
| 976 | - while (!feof($fp)) |
|
| 977 | - $return_data .= fgets($fp, 128); |
|
| 1036 | + while (!feof($fp)) { |
|
| 1037 | + $return_data .= fgets($fp, 128); |
|
| 1038 | + } |
|
| 978 | 1039 | |
| 979 | 1040 | fclose($fp); |
| 980 | 1041 | |
| 981 | 1042 | // Get the unique site ID. |
| 982 | 1043 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 983 | 1044 | |
| 984 | - if (!empty($ID[1])) |
|
| 985 | - $smcFunc['db_insert']('replace', |
|
| 1045 | + if (!empty($ID[1])) { |
|
| 1046 | + $smcFunc['db_insert']('replace', |
|
| 986 | 1047 | $db_prefix . 'settings', |
| 987 | 1048 | array('variable' => 'string', 'value' => 'string'), |
| 988 | 1049 | array( |
@@ -991,9 +1052,9 @@ discard block |
||
| 991 | 1052 | ), |
| 992 | 1053 | array('variable') |
| 993 | 1054 | ); |
| 1055 | + } |
|
| 994 | 1056 | } |
| 995 | - } |
|
| 996 | - else |
|
| 1057 | + } else |
|
| 997 | 1058 | { |
| 998 | 1059 | $smcFunc['db_insert']('replace', |
| 999 | 1060 | $db_prefix . 'settings', |
@@ -1004,8 +1065,8 @@ discard block |
||
| 1004 | 1065 | } |
| 1005 | 1066 | } |
| 1006 | 1067 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1007 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1008 | - $smcFunc['db_query']('', ' |
|
| 1068 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1069 | + $smcFunc['db_query']('', ' |
|
| 1009 | 1070 | DELETE FROM {db_prefix}settings |
| 1010 | 1071 | WHERE variable = {string:enable_sm_stats}', |
| 1011 | 1072 | array( |
@@ -1013,6 +1074,7 @@ discard block |
||
| 1013 | 1074 | 'db_error_skip' => true, |
| 1014 | 1075 | ) |
| 1015 | 1076 | ); |
| 1077 | + } |
|
| 1016 | 1078 | |
| 1017 | 1079 | // Deleting old karma stuff? |
| 1018 | 1080 | if (!empty($_POST['delete_karma'])) |
@@ -1027,20 +1089,22 @@ discard block |
||
| 1027 | 1089 | ); |
| 1028 | 1090 | |
| 1029 | 1091 | // Cleaning up old karma member settings. |
| 1030 | - if ($upcontext['karma_installed']['good']) |
|
| 1031 | - $smcFunc['db_query']('', ' |
|
| 1092 | + if ($upcontext['karma_installed']['good']) { |
|
| 1093 | + $smcFunc['db_query']('', ' |
|
| 1032 | 1094 | ALTER TABLE {db_prefix}members |
| 1033 | 1095 | DROP karma_good', |
| 1034 | 1096 | array() |
| 1035 | 1097 | ); |
| 1098 | + } |
|
| 1036 | 1099 | |
| 1037 | 1100 | // Does karma bad was enable? |
| 1038 | - if ($upcontext['karma_installed']['bad']) |
|
| 1039 | - $smcFunc['db_query']('', ' |
|
| 1101 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1102 | + $smcFunc['db_query']('', ' |
|
| 1040 | 1103 | ALTER TABLE {db_prefix}members |
| 1041 | 1104 | DROP karma_bad', |
| 1042 | 1105 | array() |
| 1043 | 1106 | ); |
| 1107 | + } |
|
| 1044 | 1108 | |
| 1045 | 1109 | // Cleaning up old karma permissions. |
| 1046 | 1110 | $smcFunc['db_query']('', ' |
@@ -1053,32 +1117,37 @@ discard block |
||
| 1053 | 1117 | } |
| 1054 | 1118 | |
| 1055 | 1119 | // Emptying the error log? |
| 1056 | - if (!empty($_POST['empty_error'])) |
|
| 1057 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1120 | + if (!empty($_POST['empty_error'])) { |
|
| 1121 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1058 | 1122 | TRUNCATE {db_prefix}log_errors', |
| 1059 | 1123 | array( |
| 1060 | 1124 | ) |
| 1061 | 1125 | ); |
| 1126 | + } |
|
| 1062 | 1127 | |
| 1063 | 1128 | $changes = array(); |
| 1064 | 1129 | |
| 1065 | 1130 | // Add proxy settings. |
| 1066 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
| 1067 | - $changes += array( |
|
| 1131 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
| 1132 | + $changes += array( |
|
| 1068 | 1133 | 'image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'', |
| 1069 | 1134 | 'image_proxy_maxsize' => 5190, |
| 1070 | 1135 | 'image_proxy_enabled' => 0, |
| 1071 | 1136 | ); |
| 1137 | + } |
|
| 1072 | 1138 | |
| 1073 | 1139 | // If $boardurl reflects https, set force_ssl |
| 1074 | - if (!function_exists('cache_put_data')) |
|
| 1075 | - require_once($sourcedir . '/Load.php'); |
|
| 1076 | - if (stripos($boardurl, 'https://') !== false) |
|
| 1077 | - updateSettings(array('force_ssl' => '2')); |
|
| 1140 | + if (!function_exists('cache_put_data')) { |
|
| 1141 | + require_once($sourcedir . '/Load.php'); |
|
| 1142 | + } |
|
| 1143 | + if (stripos($boardurl, 'https://') !== false) { |
|
| 1144 | + updateSettings(array('force_ssl' => '2')); |
|
| 1145 | + } |
|
| 1078 | 1146 | |
| 1079 | 1147 | // If we're overriding the language follow it through. |
| 1080 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1081 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1148 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1149 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1150 | + } |
|
| 1082 | 1151 | |
| 1083 | 1152 | if (!empty($_POST['maint'])) |
| 1084 | 1153 | { |
@@ -1090,26 +1159,29 @@ discard block |
||
| 1090 | 1159 | { |
| 1091 | 1160 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1092 | 1161 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1093 | - } |
|
| 1094 | - else |
|
| 1162 | + } else |
|
| 1095 | 1163 | { |
| 1096 | 1164 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1097 | 1165 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1098 | 1166 | } |
| 1099 | 1167 | } |
| 1100 | 1168 | |
| 1101 | - if ($command_line) |
|
| 1102 | - echo ' * Updating Settings.php...'; |
|
| 1169 | + if ($command_line) { |
|
| 1170 | + echo ' * Updating Settings.php...'; |
|
| 1171 | + } |
|
| 1103 | 1172 | |
| 1104 | 1173 | // Fix some old paths. |
| 1105 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1106 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1174 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1175 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1176 | + } |
|
| 1107 | 1177 | |
| 1108 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1109 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1178 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1179 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1180 | + } |
|
| 1110 | 1181 | |
| 1111 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1112 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1182 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1183 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1184 | + } |
|
| 1113 | 1185 | |
| 1114 | 1186 | // If they have a "host:port" setup for the host, split that into separate values |
| 1115 | 1187 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1120,32 +1192,36 @@ discard block |
||
| 1120 | 1192 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1121 | 1193 | |
| 1122 | 1194 | // Only set this if we're not using the default port |
| 1123 | - if ($db_port != ini_get('mysqli.default_port')) |
|
| 1124 | - $changes['db_port'] = (int) $db_port; |
|
| 1125 | - } |
|
| 1126 | - elseif (!empty($db_port)) |
|
| 1195 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
| 1196 | + $changes['db_port'] = (int) $db_port; |
|
| 1197 | + } |
|
| 1198 | + } elseif (!empty($db_port)) |
|
| 1127 | 1199 | { |
| 1128 | 1200 | // If db_port is set and is the same as the default, set it to '' |
| 1129 | 1201 | if ($db_type == 'mysql') |
| 1130 | 1202 | { |
| 1131 | - if ($db_port == ini_get('mysqli.default_port')) |
|
| 1132 | - $changes['db_port'] = '\'\''; |
|
| 1133 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1134 | - $changes['db_port'] = '\'\''; |
|
| 1203 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
| 1204 | + $changes['db_port'] = '\'\''; |
|
| 1205 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1206 | + $changes['db_port'] = '\'\''; |
|
| 1207 | + } |
|
| 1135 | 1208 | } |
| 1136 | 1209 | } |
| 1137 | 1210 | |
| 1138 | 1211 | // Maybe we haven't had this option yet? |
| 1139 | - if (empty($packagesdir)) |
|
| 1140 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1212 | + if (empty($packagesdir)) { |
|
| 1213 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1214 | + } |
|
| 1141 | 1215 | |
| 1142 | 1216 | // Add support for $tasksdir var. |
| 1143 | - if (empty($tasksdir)) |
|
| 1144 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1217 | + if (empty($tasksdir)) { |
|
| 1218 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1219 | + } |
|
| 1145 | 1220 | |
| 1146 | 1221 | // Make sure we fix the language as well. |
| 1147 | - if (stristr($language, '-utf8')) |
|
| 1148 | - $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1222 | + if (stristr($language, '-utf8')) { |
|
| 1223 | + $changes['language'] = '\'' . str_ireplace('-utf8', '', $language) . '\''; |
|
| 1224 | + } |
|
| 1149 | 1225 | |
| 1150 | 1226 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1151 | 1227 | |
@@ -1153,8 +1229,9 @@ discard block |
||
| 1153 | 1229 | require_once($sourcedir . '/Subs-Admin.php'); |
| 1154 | 1230 | updateSettingsFile($changes); |
| 1155 | 1231 | |
| 1156 | - if ($command_line) |
|
| 1157 | - echo ' Successful.' . "\n"; |
|
| 1232 | + if ($command_line) { |
|
| 1233 | + echo ' Successful.' . "\n"; |
|
| 1234 | + } |
|
| 1158 | 1235 | |
| 1159 | 1236 | // Are we doing debug? |
| 1160 | 1237 | if (isset($_POST['debug'])) |
@@ -1164,8 +1241,9 @@ discard block |
||
| 1164 | 1241 | } |
| 1165 | 1242 | |
| 1166 | 1243 | // If we're not backing up then jump one. |
| 1167 | - if (empty($_POST['backup'])) |
|
| 1168 | - $upcontext['current_step']++; |
|
| 1244 | + if (empty($_POST['backup'])) { |
|
| 1245 | + $upcontext['current_step']++; |
|
| 1246 | + } |
|
| 1169 | 1247 | |
| 1170 | 1248 | // If we've got here then let's proceed to the next step! |
| 1171 | 1249 | return true; |
@@ -1180,8 +1258,9 @@ discard block |
||
| 1180 | 1258 | $upcontext['page_title'] = 'Backup Database'; |
| 1181 | 1259 | |
| 1182 | 1260 | // Done it already - js wise? |
| 1183 | - if (!empty($_POST['backup_done'])) |
|
| 1184 | - return true; |
|
| 1261 | + if (!empty($_POST['backup_done'])) { |
|
| 1262 | + return true; |
|
| 1263 | + } |
|
| 1185 | 1264 | |
| 1186 | 1265 | // Some useful stuff here. |
| 1187 | 1266 | db_extend(); |
@@ -1195,9 +1274,10 @@ discard block |
||
| 1195 | 1274 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1196 | 1275 | |
| 1197 | 1276 | $table_names = array(); |
| 1198 | - foreach ($tables as $table) |
|
| 1199 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1277 | + foreach ($tables as $table) { |
|
| 1278 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1200 | 1279 | $table_names[] = $table; |
| 1280 | + } |
|
| 1201 | 1281 | |
| 1202 | 1282 | $upcontext['table_count'] = count($table_names); |
| 1203 | 1283 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1207,12 +1287,14 @@ discard block |
||
| 1207 | 1287 | $file_steps = $upcontext['table_count']; |
| 1208 | 1288 | |
| 1209 | 1289 | // What ones have we already done? |
| 1210 | - foreach ($table_names as $id => $table) |
|
| 1211 | - if ($id < $_GET['substep']) |
|
| 1290 | + foreach ($table_names as $id => $table) { |
|
| 1291 | + if ($id < $_GET['substep']) |
|
| 1212 | 1292 | $upcontext['previous_tables'][] = $table; |
| 1293 | + } |
|
| 1213 | 1294 | |
| 1214 | - if ($command_line) |
|
| 1215 | - echo 'Backing Up Tables.'; |
|
| 1295 | + if ($command_line) { |
|
| 1296 | + echo 'Backing Up Tables.'; |
|
| 1297 | + } |
|
| 1216 | 1298 | |
| 1217 | 1299 | // If we don't support javascript we backup here. |
| 1218 | 1300 | if (!$support_js || isset($_GET['xml'])) |
@@ -1231,8 +1313,9 @@ discard block |
||
| 1231 | 1313 | backupTable($table_names[$substep]); |
| 1232 | 1314 | |
| 1233 | 1315 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1234 | - if (isset($_GET['xml'])) |
|
| 1235 | - return upgradeExit(); |
|
| 1316 | + if (isset($_GET['xml'])) { |
|
| 1317 | + return upgradeExit(); |
|
| 1318 | + } |
|
| 1236 | 1319 | } |
| 1237 | 1320 | |
| 1238 | 1321 | if ($command_line) |
@@ -1265,9 +1348,10 @@ discard block |
||
| 1265 | 1348 | |
| 1266 | 1349 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1267 | 1350 | |
| 1268 | - if ($command_line) |
|
| 1269 | - echo ' done.'; |
|
| 1270 | -} |
|
| 1351 | + if ($command_line) { |
|
| 1352 | + echo ' done.'; |
|
| 1353 | + } |
|
| 1354 | + } |
|
| 1271 | 1355 | |
| 1272 | 1356 | // Step 2: Everything. |
| 1273 | 1357 | function DatabaseChanges() |
@@ -1276,8 +1360,9 @@ discard block |
||
| 1276 | 1360 | global $upcontext, $support_js, $db_type; |
| 1277 | 1361 | |
| 1278 | 1362 | // Have we just completed this? |
| 1279 | - if (!empty($_POST['database_done'])) |
|
| 1280 | - return true; |
|
| 1363 | + if (!empty($_POST['database_done'])) { |
|
| 1364 | + return true; |
|
| 1365 | + } |
|
| 1281 | 1366 | |
| 1282 | 1367 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1283 | 1368 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1292,15 +1377,16 @@ discard block |
||
| 1292 | 1377 | ); |
| 1293 | 1378 | |
| 1294 | 1379 | // How many files are there in total? |
| 1295 | - if (isset($_GET['filecount'])) |
|
| 1296 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1297 | - else |
|
| 1380 | + if (isset($_GET['filecount'])) { |
|
| 1381 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1382 | + } else |
|
| 1298 | 1383 | { |
| 1299 | 1384 | $upcontext['file_count'] = 0; |
| 1300 | 1385 | foreach ($files as $file) |
| 1301 | 1386 | { |
| 1302 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1303 | - $upcontext['file_count']++; |
|
| 1387 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1388 | + $upcontext['file_count']++; |
|
| 1389 | + } |
|
| 1304 | 1390 | } |
| 1305 | 1391 | } |
| 1306 | 1392 | |
@@ -1310,9 +1396,9 @@ discard block |
||
| 1310 | 1396 | $upcontext['cur_file_num'] = 0; |
| 1311 | 1397 | foreach ($files as $file) |
| 1312 | 1398 | { |
| 1313 | - if ($did_not_do) |
|
| 1314 | - $did_not_do--; |
|
| 1315 | - else |
|
| 1399 | + if ($did_not_do) { |
|
| 1400 | + $did_not_do--; |
|
| 1401 | + } else |
|
| 1316 | 1402 | { |
| 1317 | 1403 | $upcontext['cur_file_num']++; |
| 1318 | 1404 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1339,12 +1425,13 @@ discard block |
||
| 1339 | 1425 | // Flag to move on to the next. |
| 1340 | 1426 | $upcontext['completed_step'] = true; |
| 1341 | 1427 | // Did we complete the whole file? |
| 1342 | - if ($nextFile) |
|
| 1343 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1428 | + if ($nextFile) { |
|
| 1429 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1430 | + } |
|
| 1344 | 1431 | return upgradeExit(); |
| 1432 | + } elseif ($support_js) { |
|
| 1433 | + break; |
|
| 1345 | 1434 | } |
| 1346 | - elseif ($support_js) |
|
| 1347 | - break; |
|
| 1348 | 1435 | } |
| 1349 | 1436 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1350 | 1437 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1369,8 +1456,9 @@ discard block |
||
| 1369 | 1456 | global $command_line, $language, $upcontext, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1370 | 1457 | |
| 1371 | 1458 | // Now it's nice to have some of the basic SMF source files. |
| 1372 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1373 | - redirectLocation('&ssi=1'); |
|
| 1459 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1460 | + redirectLocation('&ssi=1'); |
|
| 1461 | + } |
|
| 1374 | 1462 | |
| 1375 | 1463 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1376 | 1464 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1386,14 +1474,16 @@ discard block |
||
| 1386 | 1474 | // Are we in maintenance mode? |
| 1387 | 1475 | if (isset($upcontext['user']['main'])) |
| 1388 | 1476 | { |
| 1389 | - if ($command_line) |
|
| 1390 | - echo ' * '; |
|
| 1477 | + if ($command_line) { |
|
| 1478 | + echo ' * '; |
|
| 1479 | + } |
|
| 1391 | 1480 | $upcontext['removed_maintenance'] = true; |
| 1392 | 1481 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1393 | 1482 | } |
| 1394 | 1483 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1395 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1396 | - $changes['maintenance'] = 1; |
|
| 1484 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1485 | + $changes['maintenance'] = 1; |
|
| 1486 | + } |
|
| 1397 | 1487 | |
| 1398 | 1488 | // Wipe this out... |
| 1399 | 1489 | $upcontext['user'] = array(); |
@@ -1408,9 +1498,9 @@ discard block |
||
| 1408 | 1498 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1409 | 1499 | |
| 1410 | 1500 | // Now is the perfect time to fetch the SM files. |
| 1411 | - if ($command_line) |
|
| 1412 | - cli_scheduled_fetchSMfiles(); |
|
| 1413 | - else |
|
| 1501 | + if ($command_line) { |
|
| 1502 | + cli_scheduled_fetchSMfiles(); |
|
| 1503 | + } else |
|
| 1414 | 1504 | { |
| 1415 | 1505 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1416 | 1506 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1418,8 +1508,9 @@ discard block |
||
| 1418 | 1508 | } |
| 1419 | 1509 | |
| 1420 | 1510 | // Log what we've done. |
| 1421 | - if (empty($user_info['id'])) |
|
| 1422 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1511 | + if (empty($user_info['id'])) { |
|
| 1512 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1513 | + } |
|
| 1423 | 1514 | |
| 1424 | 1515 | // Log the action manually, so CLI still works. |
| 1425 | 1516 | $smcFunc['db_insert']('', |
@@ -1438,8 +1529,9 @@ discard block |
||
| 1438 | 1529 | |
| 1439 | 1530 | // Save the current database version. |
| 1440 | 1531 | $server_version = $smcFunc['db_server_info'](); |
| 1441 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1442 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1532 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1533 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1534 | + } |
|
| 1443 | 1535 | |
| 1444 | 1536 | if ($command_line) |
| 1445 | 1537 | { |
@@ -1451,8 +1543,9 @@ discard block |
||
| 1451 | 1543 | |
| 1452 | 1544 | // Make sure it says we're done. |
| 1453 | 1545 | $upcontext['overall_percent'] = 100; |
| 1454 | - if (isset($upcontext['step_progress'])) |
|
| 1455 | - unset($upcontext['step_progress']); |
|
| 1546 | + if (isset($upcontext['step_progress'])) { |
|
| 1547 | + unset($upcontext['step_progress']); |
|
| 1548 | + } |
|
| 1456 | 1549 | |
| 1457 | 1550 | $_GET['substep'] = 0; |
| 1458 | 1551 | return false; |
@@ -1463,8 +1556,9 @@ discard block |
||
| 1463 | 1556 | { |
| 1464 | 1557 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1465 | 1558 | |
| 1466 | - if (empty($modSettings['time_format'])) |
|
| 1467 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1559 | + if (empty($modSettings['time_format'])) { |
|
| 1560 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1561 | + } |
|
| 1468 | 1562 | |
| 1469 | 1563 | // What files do we want to get |
| 1470 | 1564 | $request = $smcFunc['db_query']('', ' |
@@ -1498,8 +1592,9 @@ discard block |
||
| 1498 | 1592 | $file_data = fetch_web_data($url); |
| 1499 | 1593 | |
| 1500 | 1594 | // If we got an error - give up - the site might be down. |
| 1501 | - if ($file_data === false) |
|
| 1502 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1595 | + if ($file_data === false) { |
|
| 1596 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1597 | + } |
|
| 1503 | 1598 | |
| 1504 | 1599 | // Save the file to the database. |
| 1505 | 1600 | $smcFunc['db_query']('substring', ' |
@@ -1541,8 +1636,9 @@ discard block |
||
| 1541 | 1636 | $themeData = array(); |
| 1542 | 1637 | foreach ($values as $variable => $value) |
| 1543 | 1638 | { |
| 1544 | - if (!isset($value) || $value === null) |
|
| 1545 | - $value = 0; |
|
| 1639 | + if (!isset($value) || $value === null) { |
|
| 1640 | + $value = 0; |
|
| 1641 | + } |
|
| 1546 | 1642 | |
| 1547 | 1643 | $themeData[] = array(0, 1, $variable, $value); |
| 1548 | 1644 | } |
@@ -1571,8 +1667,9 @@ discard block |
||
| 1571 | 1667 | |
| 1572 | 1668 | foreach ($values as $variable => $value) |
| 1573 | 1669 | { |
| 1574 | - if (empty($modSettings[$value[0]])) |
|
| 1575 | - continue; |
|
| 1670 | + if (empty($modSettings[$value[0]])) { |
|
| 1671 | + continue; |
|
| 1672 | + } |
|
| 1576 | 1673 | |
| 1577 | 1674 | $smcFunc['db_query']('', ' |
| 1578 | 1675 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1658,19 +1755,21 @@ discard block |
||
| 1658 | 1755 | set_error_handler( |
| 1659 | 1756 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
| 1660 | 1757 | { |
| 1661 | - if ($support_js) |
|
| 1662 | - return true; |
|
| 1663 | - else |
|
| 1664 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1758 | + if ($support_js) { |
|
| 1759 | + return true; |
|
| 1760 | + } else { |
|
| 1761 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1762 | + } |
|
| 1665 | 1763 | } |
| 1666 | 1764 | ); |
| 1667 | 1765 | |
| 1668 | 1766 | // If we're on MySQL, set {db_collation}; this approach is used throughout upgrade_2-0_mysql.php to set new tables to utf8 |
| 1669 | 1767 | // Note it is expected to be in the format: ENGINE=MyISAM{$db_collation}; |
| 1670 | - if ($db_type == 'mysql') |
|
| 1671 | - $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1672 | - else |
|
| 1673 | - $db_collation = ''; |
|
| 1768 | + if ($db_type == 'mysql') { |
|
| 1769 | + $db_collation = ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
| 1770 | + } else { |
|
| 1771 | + $db_collation = ''; |
|
| 1772 | + } |
|
| 1674 | 1773 | |
| 1675 | 1774 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1676 | 1775 | |
@@ -1682,8 +1781,9 @@ discard block |
||
| 1682 | 1781 | $last_step = ''; |
| 1683 | 1782 | |
| 1684 | 1783 | // Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php |
| 1685 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1686 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1784 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1785 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1786 | + } |
|
| 1687 | 1787 | |
| 1688 | 1788 | // Count the total number of steps within this file - for progress. |
| 1689 | 1789 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1703,15 +1803,18 @@ discard block |
||
| 1703 | 1803 | $do_current = $substep >= $_GET['substep']; |
| 1704 | 1804 | |
| 1705 | 1805 | // Get rid of any comments in the beginning of the line... |
| 1706 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1707 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1806 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1807 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1808 | + } |
|
| 1708 | 1809 | |
| 1709 | 1810 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1710 | - if ($is_debug && !$support_js && $command_line) |
|
| 1711 | - flush(); |
|
| 1811 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1812 | + flush(); |
|
| 1813 | + } |
|
| 1712 | 1814 | |
| 1713 | - if (trim($line) === '') |
|
| 1714 | - continue; |
|
| 1815 | + if (trim($line) === '') { |
|
| 1816 | + continue; |
|
| 1817 | + } |
|
| 1715 | 1818 | |
| 1716 | 1819 | if (trim(substr($line, 0, 3)) === '---') |
| 1717 | 1820 | { |
@@ -1721,8 +1824,9 @@ discard block |
||
| 1721 | 1824 | if (trim($current_data) != '' && $type !== '}') |
| 1722 | 1825 | { |
| 1723 | 1826 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1724 | - if ($command_line) |
|
| 1725 | - echo $upcontext['error_message']; |
|
| 1827 | + if ($command_line) { |
|
| 1828 | + echo $upcontext['error_message']; |
|
| 1829 | + } |
|
| 1726 | 1830 | } |
| 1727 | 1831 | |
| 1728 | 1832 | if ($type == ' ') |
@@ -1740,17 +1844,18 @@ discard block |
||
| 1740 | 1844 | if ($do_current) |
| 1741 | 1845 | { |
| 1742 | 1846 | $upcontext['actioned_items'][] = $last_step; |
| 1743 | - if ($command_line) |
|
| 1744 | - echo ' * '; |
|
| 1847 | + if ($command_line) { |
|
| 1848 | + echo ' * '; |
|
| 1849 | + } |
|
| 1745 | 1850 | } |
| 1746 | - } |
|
| 1747 | - elseif ($type == '#') |
|
| 1851 | + } elseif ($type == '#') |
|
| 1748 | 1852 | { |
| 1749 | 1853 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1750 | 1854 | |
| 1751 | 1855 | $upcontext['current_debug_item_num']++; |
| 1752 | - if (trim($line) != '---#') |
|
| 1753 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1856 | + if (trim($line) != '---#') { |
|
| 1857 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1858 | + } |
|
| 1754 | 1859 | |
| 1755 | 1860 | // Have we already done something? |
| 1756 | 1861 | if (isset($_GET['xml']) && $done_something) |
@@ -1761,34 +1866,36 @@ discard block |
||
| 1761 | 1866 | |
| 1762 | 1867 | if ($do_current) |
| 1763 | 1868 | { |
| 1764 | - if (trim($line) == '---#' && $command_line) |
|
| 1765 | - echo ' done.', $endl; |
|
| 1766 | - elseif ($command_line) |
|
| 1767 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1768 | - elseif (trim($line) != '---#') |
|
| 1869 | + if (trim($line) == '---#' && $command_line) { |
|
| 1870 | + echo ' done.', $endl; |
|
| 1871 | + } elseif ($command_line) { |
|
| 1872 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1873 | + } elseif (trim($line) != '---#') |
|
| 1769 | 1874 | { |
| 1770 | - if ($is_debug) |
|
| 1771 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1875 | + if ($is_debug) { |
|
| 1876 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1877 | + } |
|
| 1772 | 1878 | } |
| 1773 | 1879 | } |
| 1774 | 1880 | |
| 1775 | 1881 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1776 | 1882 | { |
| 1777 | - if ($command_line) |
|
| 1778 | - echo ' * '; |
|
| 1779 | - else |
|
| 1780 | - $upcontext['actioned_items'][] = $last_step; |
|
| 1883 | + if ($command_line) { |
|
| 1884 | + echo ' * '; |
|
| 1885 | + } else { |
|
| 1886 | + $upcontext['actioned_items'][] = $last_step; |
|
| 1887 | + } |
|
| 1781 | 1888 | } |
| 1782 | 1889 | |
| 1783 | 1890 | // Small step - only if we're actually doing stuff. |
| 1784 | - if ($do_current) |
|
| 1785 | - nextSubstep(++$substep); |
|
| 1786 | - else |
|
| 1787 | - $substep++; |
|
| 1788 | - } |
|
| 1789 | - elseif ($type == '{') |
|
| 1790 | - $current_type = 'code'; |
|
| 1791 | - elseif ($type == '}') |
|
| 1891 | + if ($do_current) { |
|
| 1892 | + nextSubstep(++$substep); |
|
| 1893 | + } else { |
|
| 1894 | + $substep++; |
|
| 1895 | + } |
|
| 1896 | + } elseif ($type == '{') { |
|
| 1897 | + $current_type = 'code'; |
|
| 1898 | + } elseif ($type == '}') |
|
| 1792 | 1899 | { |
| 1793 | 1900 | $current_type = 'sql'; |
| 1794 | 1901 | |
@@ -1801,8 +1908,9 @@ discard block |
||
| 1801 | 1908 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1802 | 1909 | { |
| 1803 | 1910 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1804 | - if ($command_line) |
|
| 1805 | - echo $upcontext['error_message']; |
|
| 1911 | + if ($command_line) { |
|
| 1912 | + echo $upcontext['error_message']; |
|
| 1913 | + } |
|
| 1806 | 1914 | } |
| 1807 | 1915 | |
| 1808 | 1916 | // Done with code! |
@@ -1882,8 +1990,9 @@ discard block |
||
| 1882 | 1990 | $db_unbuffered = false; |
| 1883 | 1991 | |
| 1884 | 1992 | // Failure?! |
| 1885 | - if ($result !== false) |
|
| 1886 | - return $result; |
|
| 1993 | + if ($result !== false) { |
|
| 1994 | + return $result; |
|
| 1995 | + } |
|
| 1887 | 1996 | |
| 1888 | 1997 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 1889 | 1998 | // If MySQL we do something more clever. |
@@ -1911,54 +2020,61 @@ discard block |
||
| 1911 | 2020 | { |
| 1912 | 2021 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 1913 | 2022 | $result = mysqli_query($db_connection, $string); |
| 1914 | - if ($result !== false) |
|
| 1915 | - return $result; |
|
| 2023 | + if ($result !== false) { |
|
| 2024 | + return $result; |
|
| 2025 | + } |
|
| 1916 | 2026 | } |
| 1917 | - } |
|
| 1918 | - elseif ($mysqli_errno == 2013) |
|
| 2027 | + } elseif ($mysqli_errno == 2013) |
|
| 1919 | 2028 | { |
| 1920 | 2029 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 1921 | 2030 | mysqli_select_db($db_connection, $db_name); |
| 1922 | 2031 | if ($db_connection) |
| 1923 | 2032 | { |
| 1924 | 2033 | $result = mysqli_query($db_connection, $string); |
| 1925 | - if ($result !== false) |
|
| 1926 | - return $result; |
|
| 2034 | + if ($result !== false) { |
|
| 2035 | + return $result; |
|
| 2036 | + } |
|
| 1927 | 2037 | } |
| 1928 | 2038 | } |
| 1929 | 2039 | // Duplicate column name... should be okay ;). |
| 1930 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 1931 | - return false; |
|
| 2040 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2041 | + return false; |
|
| 2042 | + } |
|
| 1932 | 2043 | // Duplicate insert... make sure it's the proper type of query ;). |
| 1933 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 1934 | - return false; |
|
| 2044 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2045 | + return false; |
|
| 2046 | + } |
|
| 1935 | 2047 | // Creating an index on a non-existent column. |
| 1936 | - elseif ($mysqli_errno == 1072) |
|
| 1937 | - return false; |
|
| 1938 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 1939 | - return false; |
|
| 2048 | + elseif ($mysqli_errno == 1072) { |
|
| 2049 | + return false; |
|
| 2050 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2051 | + return false; |
|
| 2052 | + } |
|
| 1940 | 2053 | } |
| 1941 | 2054 | // If a table already exists don't go potty. |
| 1942 | 2055 | else |
| 1943 | 2056 | { |
| 1944 | 2057 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 1945 | 2058 | { |
| 1946 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 1947 | - return true; |
|
| 1948 | - } |
|
| 1949 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2059 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2060 | + return true; |
|
| 2061 | + } |
|
| 2062 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 1950 | 2063 | { |
| 1951 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 1952 | - return true; |
|
| 2064 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2065 | + return true; |
|
| 2066 | + } |
|
| 1953 | 2067 | } |
| 1954 | 2068 | } |
| 1955 | 2069 | |
| 1956 | 2070 | // Get the query string so we pass everything. |
| 1957 | 2071 | $query_string = ''; |
| 1958 | - foreach ($_GET as $k => $v) |
|
| 1959 | - $query_string .= ';' . $k . '=' . $v; |
|
| 1960 | - if (strlen($query_string) != 0) |
|
| 1961 | - $query_string = '?' . substr($query_string, 1); |
|
| 2072 | + foreach ($_GET as $k => $v) { |
|
| 2073 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2074 | + } |
|
| 2075 | + if (strlen($query_string) != 0) { |
|
| 2076 | + $query_string = '?' . substr($query_string, 1); |
|
| 2077 | + } |
|
| 1962 | 2078 | |
| 1963 | 2079 | if ($command_line) |
| 1964 | 2080 | { |
@@ -2013,16 +2129,18 @@ discard block |
||
| 2013 | 2129 | { |
| 2014 | 2130 | $found |= 1; |
| 2015 | 2131 | // Do some checks on the data if we have it set. |
| 2016 | - if (isset($change['col_type'])) |
|
| 2017 | - $found &= $change['col_type'] === $column['type']; |
|
| 2018 | - if (isset($change['null_allowed'])) |
|
| 2019 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2020 | - if (isset($change['default'])) |
|
| 2021 | - $found &= $change['default'] === $column['default']; |
|
| 2132 | + if (isset($change['col_type'])) { |
|
| 2133 | + $found &= $change['col_type'] === $column['type']; |
|
| 2134 | + } |
|
| 2135 | + if (isset($change['null_allowed'])) { |
|
| 2136 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2137 | + } |
|
| 2138 | + if (isset($change['default'])) { |
|
| 2139 | + $found &= $change['default'] === $column['default']; |
|
| 2140 | + } |
|
| 2022 | 2141 | } |
| 2023 | 2142 | } |
| 2024 | - } |
|
| 2025 | - elseif ($change['type'] === 'index') |
|
| 2143 | + } elseif ($change['type'] === 'index') |
|
| 2026 | 2144 | { |
| 2027 | 2145 | $request = upgrade_query(' |
| 2028 | 2146 | SHOW INDEX |
@@ -2031,9 +2149,10 @@ discard block |
||
| 2031 | 2149 | { |
| 2032 | 2150 | $cur_index = array(); |
| 2033 | 2151 | |
| 2034 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2035 | - if ($row['Key_name'] === $change['name']) |
|
| 2152 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2153 | + if ($row['Key_name'] === $change['name']) |
|
| 2036 | 2154 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2155 | + } |
|
| 2037 | 2156 | |
| 2038 | 2157 | ksort($cur_index, SORT_NUMERIC); |
| 2039 | 2158 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2043,14 +2162,17 @@ discard block |
||
| 2043 | 2162 | } |
| 2044 | 2163 | |
| 2045 | 2164 | // If we're trying to add and it's added, we're done. |
| 2046 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2047 | - return true; |
|
| 2165 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2166 | + return true; |
|
| 2167 | + } |
|
| 2048 | 2168 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2049 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2050 | - return true; |
|
| 2169 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2170 | + return true; |
|
| 2171 | + } |
|
| 2051 | 2172 | // Otherwise is it just a test? |
| 2052 | - elseif ($is_test) |
|
| 2053 | - return false; |
|
| 2173 | + elseif ($is_test) { |
|
| 2174 | + return false; |
|
| 2175 | + } |
|
| 2054 | 2176 | |
| 2055 | 2177 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2056 | 2178 | $running = false; |
@@ -2061,8 +2183,9 @@ discard block |
||
| 2061 | 2183 | SHOW FULL PROCESSLIST'); |
| 2062 | 2184 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2063 | 2185 | { |
| 2064 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2065 | - $found = true; |
|
| 2186 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2187 | + $found = true; |
|
| 2188 | + } |
|
| 2066 | 2189 | } |
| 2067 | 2190 | |
| 2068 | 2191 | // Can't find it? Then we need to run it fools! |
@@ -2074,8 +2197,9 @@ discard block |
||
| 2074 | 2197 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2075 | 2198 | ' . $change['text'], true) !== false; |
| 2076 | 2199 | |
| 2077 | - if (!$success) |
|
| 2078 | - return false; |
|
| 2200 | + if (!$success) { |
|
| 2201 | + return false; |
|
| 2202 | + } |
|
| 2079 | 2203 | |
| 2080 | 2204 | // Return |
| 2081 | 2205 | $running = true; |
@@ -2117,8 +2241,9 @@ discard block |
||
| 2117 | 2241 | 'db_error_skip' => true, |
| 2118 | 2242 | ) |
| 2119 | 2243 | ); |
| 2120 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2121 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2244 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2245 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2246 | + } |
|
| 2122 | 2247 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2123 | 2248 | $smcFunc['db_free_result']($request); |
| 2124 | 2249 | |
@@ -2140,18 +2265,19 @@ discard block |
||
| 2140 | 2265 | ) |
| 2141 | 2266 | ); |
| 2142 | 2267 | // No results? Just forget it all together. |
| 2143 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2144 | - unset($table_row['Collation']); |
|
| 2145 | - else |
|
| 2146 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2268 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2269 | + unset($table_row['Collation']); |
|
| 2270 | + } else { |
|
| 2271 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2272 | + } |
|
| 2147 | 2273 | $smcFunc['db_free_result']($request); |
| 2148 | 2274 | } |
| 2149 | 2275 | |
| 2150 | 2276 | if ($column_fix) |
| 2151 | 2277 | { |
| 2152 | 2278 | // Make sure there are no NULL's left. |
| 2153 | - if ($null_fix) |
|
| 2154 | - $smcFunc['db_query']('', ' |
|
| 2279 | + if ($null_fix) { |
|
| 2280 | + $smcFunc['db_query']('', ' |
|
| 2155 | 2281 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2156 | 2282 | SET ' . $change['column'] . ' = {string:default} |
| 2157 | 2283 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2160,6 +2286,7 @@ discard block |
||
| 2160 | 2286 | 'db_error_skip' => true, |
| 2161 | 2287 | ) |
| 2162 | 2288 | ); |
| 2289 | + } |
|
| 2163 | 2290 | |
| 2164 | 2291 | // Do the actual alteration. |
| 2165 | 2292 | $smcFunc['db_query']('', ' |
@@ -2188,8 +2315,9 @@ discard block |
||
| 2188 | 2315 | } |
| 2189 | 2316 | |
| 2190 | 2317 | // Not a column we need to check on? |
| 2191 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2192 | - return; |
|
| 2318 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2319 | + return; |
|
| 2320 | + } |
|
| 2193 | 2321 | |
| 2194 | 2322 | // Break it up you (six|seven). |
| 2195 | 2323 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2208,13 +2336,13 @@ discard block |
||
| 2208 | 2336 | 'new_name' => $temp[2], |
| 2209 | 2337 | )); |
| 2210 | 2338 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2211 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2212 | - return; |
|
| 2339 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2340 | + return; |
|
| 2341 | + } |
|
| 2213 | 2342 | |
| 2214 | 2343 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2215 | 2344 | $smcFunc['db_free_result']($request); |
| 2216 | - } |
|
| 2217 | - else |
|
| 2345 | + } else |
|
| 2218 | 2346 | { |
| 2219 | 2347 | // Do this the old fashion, sure method way. |
| 2220 | 2348 | $request = $smcFunc['db_query']('', ' |
@@ -2225,21 +2353,24 @@ discard block |
||
| 2225 | 2353 | )); |
| 2226 | 2354 | // Mayday! |
| 2227 | 2355 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2228 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2229 | - return; |
|
| 2356 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2357 | + return; |
|
| 2358 | + } |
|
| 2230 | 2359 | |
| 2231 | 2360 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2232 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2233 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2361 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2362 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2234 | 2363 | { |
| 2235 | 2364 | $current_type = $row['Type']; |
| 2365 | + } |
|
| 2236 | 2366 | break; |
| 2237 | 2367 | } |
| 2238 | 2368 | } |
| 2239 | 2369 | |
| 2240 | 2370 | // If this doesn't match, the column may of been altered for a reason. |
| 2241 | - if (trim($current_type) != trim($temp[3])) |
|
| 2242 | - $temp[3] = $current_type; |
|
| 2371 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2372 | + $temp[3] = $current_type; |
|
| 2373 | + } |
|
| 2243 | 2374 | |
| 2244 | 2375 | // Piece this back together. |
| 2245 | 2376 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2251,8 +2382,9 @@ discard block |
||
| 2251 | 2382 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2252 | 2383 | global $step_progress, $is_debug, $upcontext; |
| 2253 | 2384 | |
| 2254 | - if ($_GET['substep'] < $substep) |
|
| 2255 | - $_GET['substep'] = $substep; |
|
| 2385 | + if ($_GET['substep'] < $substep) { |
|
| 2386 | + $_GET['substep'] = $substep; |
|
| 2387 | + } |
|
| 2256 | 2388 | |
| 2257 | 2389 | if ($command_line) |
| 2258 | 2390 | { |
@@ -2265,29 +2397,33 @@ discard block |
||
| 2265 | 2397 | } |
| 2266 | 2398 | |
| 2267 | 2399 | @set_time_limit(300); |
| 2268 | - if (function_exists('apache_reset_timeout')) |
|
| 2269 | - @apache_reset_timeout(); |
|
| 2400 | + if (function_exists('apache_reset_timeout')) { |
|
| 2401 | + @apache_reset_timeout(); |
|
| 2402 | + } |
|
| 2270 | 2403 | |
| 2271 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2272 | - return; |
|
| 2404 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2405 | + return; |
|
| 2406 | + } |
|
| 2273 | 2407 | |
| 2274 | 2408 | // Do we have some custom step progress stuff? |
| 2275 | 2409 | if (!empty($step_progress)) |
| 2276 | 2410 | { |
| 2277 | 2411 | $upcontext['substep_progress'] = 0; |
| 2278 | 2412 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2279 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2280 | - $upcontext['substep_progress'] = 99.9; |
|
| 2281 | - else |
|
| 2282 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2413 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2414 | + $upcontext['substep_progress'] = 99.9; |
|
| 2415 | + } else { |
|
| 2416 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2417 | + } |
|
| 2283 | 2418 | |
| 2284 | 2419 | // Make it nicely rounded. |
| 2285 | 2420 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2286 | 2421 | } |
| 2287 | 2422 | |
| 2288 | 2423 | // If this is XML we just exit right away! |
| 2289 | - if (isset($_GET['xml'])) |
|
| 2290 | - return upgradeExit(); |
|
| 2424 | + if (isset($_GET['xml'])) { |
|
| 2425 | + return upgradeExit(); |
|
| 2426 | + } |
|
| 2291 | 2427 | |
| 2292 | 2428 | // We're going to pause after this! |
| 2293 | 2429 | $upcontext['pause'] = true; |
@@ -2295,13 +2431,15 @@ discard block |
||
| 2295 | 2431 | $upcontext['query_string'] = ''; |
| 2296 | 2432 | foreach ($_GET as $k => $v) |
| 2297 | 2433 | { |
| 2298 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2299 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2434 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2435 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2436 | + } |
|
| 2300 | 2437 | } |
| 2301 | 2438 | |
| 2302 | 2439 | // Custom warning? |
| 2303 | - if (!empty($custom_warning)) |
|
| 2304 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2440 | + if (!empty($custom_warning)) { |
|
| 2441 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2442 | + } |
|
| 2305 | 2443 | |
| 2306 | 2444 | upgradeExit(); |
| 2307 | 2445 | } |
@@ -2316,25 +2454,26 @@ discard block |
||
| 2316 | 2454 | ob_implicit_flush(true); |
| 2317 | 2455 | @set_time_limit(600); |
| 2318 | 2456 | |
| 2319 | - if (!isset($_SERVER['argv'])) |
|
| 2320 | - $_SERVER['argv'] = array(); |
|
| 2457 | + if (!isset($_SERVER['argv'])) { |
|
| 2458 | + $_SERVER['argv'] = array(); |
|
| 2459 | + } |
|
| 2321 | 2460 | $_GET['maint'] = 1; |
| 2322 | 2461 | |
| 2323 | 2462 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2324 | 2463 | { |
| 2325 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2326 | - $_GET['lang'] = $match[1]; |
|
| 2327 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2328 | - continue; |
|
| 2329 | - elseif ($arg == '--no-maintenance') |
|
| 2330 | - $_GET['maint'] = 0; |
|
| 2331 | - elseif ($arg == '--debug') |
|
| 2332 | - $is_debug = true; |
|
| 2333 | - elseif ($arg == '--backup') |
|
| 2334 | - $_POST['backup'] = 1; |
|
| 2335 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2336 | - $_GET['conv'] = 1; |
|
| 2337 | - elseif ($i != 0) |
|
| 2464 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2465 | + $_GET['lang'] = $match[1]; |
|
| 2466 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2467 | + continue; |
|
| 2468 | + } elseif ($arg == '--no-maintenance') { |
|
| 2469 | + $_GET['maint'] = 0; |
|
| 2470 | + } elseif ($arg == '--debug') { |
|
| 2471 | + $is_debug = true; |
|
| 2472 | + } elseif ($arg == '--backup') { |
|
| 2473 | + $_POST['backup'] = 1; |
|
| 2474 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2475 | + $_GET['conv'] = 1; |
|
| 2476 | + } elseif ($i != 0) |
|
| 2338 | 2477 | { |
| 2339 | 2478 | echo 'SMF Command-line Upgrader |
| 2340 | 2479 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2348,10 +2487,12 @@ discard block |
||
| 2348 | 2487 | } |
| 2349 | 2488 | } |
| 2350 | 2489 | |
| 2351 | - if (!php_version_check()) |
|
| 2352 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2353 | - if (!db_version_check()) |
|
| 2354 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2490 | + if (!php_version_check()) { |
|
| 2491 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2492 | + } |
|
| 2493 | + if (!db_version_check()) { |
|
| 2494 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2495 | + } |
|
| 2355 | 2496 | |
| 2356 | 2497 | // Do some checks to make sure they have proper privileges |
| 2357 | 2498 | db_extend('packages'); |
@@ -2366,34 +2507,39 @@ discard block |
||
| 2366 | 2507 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2367 | 2508 | |
| 2368 | 2509 | // Sorry... we need CREATE, ALTER and DROP |
| 2369 | - if (!$create || !$alter || !$drop) |
|
| 2370 | - print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2510 | + if (!$create || !$alter || !$drop) { |
|
| 2511 | + print_error("The " . $databases[$db_type]['name'] . " user you have set in Settings.php does not have proper privileges.\n\nPlease ask your host to give this user the ALTER, CREATE, and DROP privileges.", true); |
|
| 2512 | + } |
|
| 2371 | 2513 | |
| 2372 | 2514 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2373 | 2515 | && @file_exists($sourcedir . '/QueryString.php') |
| 2374 | 2516 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2375 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2376 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2517 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2518 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2519 | + } |
|
| 2377 | 2520 | |
| 2378 | 2521 | // Do a quick version spot check. |
| 2379 | 2522 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2380 | 2523 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2381 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2382 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2524 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2525 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2526 | + } |
|
| 2383 | 2527 | |
| 2384 | 2528 | // Make sure Settings.php is writable. |
| 2385 | 2529 | quickFileWritable($boarddir . '/Settings.php'); |
| 2386 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2387 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2530 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2531 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2532 | + } |
|
| 2388 | 2533 | |
| 2389 | 2534 | // Make sure Settings_bak.php is writable. |
| 2390 | 2535 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2391 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2392 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2536 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2537 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2538 | + } |
|
| 2393 | 2539 | |
| 2394 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2395 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2396 | - elseif (isset($modSettings['agreement'])) |
|
| 2540 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2541 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2542 | + } elseif (isset($modSettings['agreement'])) |
|
| 2397 | 2543 | { |
| 2398 | 2544 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2399 | 2545 | fwrite($fp, $modSettings['agreement']); |
@@ -2403,36 +2549,42 @@ discard block |
||
| 2403 | 2549 | // Make sure Themes is writable. |
| 2404 | 2550 | quickFileWritable($modSettings['theme_dir']); |
| 2405 | 2551 | |
| 2406 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2407 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2552 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2553 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2554 | + } |
|
| 2408 | 2555 | |
| 2409 | 2556 | // Make sure cache directory exists and is writable! |
| 2410 | 2557 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2411 | - if (!file_exists($cachedir_temp)) |
|
| 2412 | - @mkdir($cachedir_temp); |
|
| 2558 | + if (!file_exists($cachedir_temp)) { |
|
| 2559 | + @mkdir($cachedir_temp); |
|
| 2560 | + } |
|
| 2413 | 2561 | |
| 2414 | 2562 | // Make sure the cache temp dir is writable. |
| 2415 | 2563 | quickFileWritable($cachedir_temp); |
| 2416 | 2564 | |
| 2417 | - if (!is_writable($cachedir_temp)) |
|
| 2418 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2565 | + if (!is_writable($cachedir_temp)) { |
|
| 2566 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2567 | + } |
|
| 2419 | 2568 | |
| 2420 | 2569 | // Make sure db_last_error.php is writable. |
| 2421 | 2570 | quickFileWritable($cachedir_temp . '/db_last_error.php'); |
| 2422 | - if (!is_writable($cachedir_temp . '/db_last_error.php')) |
|
| 2423 | - print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2571 | + if (!is_writable($cachedir_temp . '/db_last_error.php')) { |
|
| 2572 | + print_error('Error: Unable to obtain write access to "db_last_error.php".'); |
|
| 2573 | + } |
|
| 2424 | 2574 | |
| 2425 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2426 | - print_error('Error: Unable to find language files!', true); |
|
| 2427 | - else |
|
| 2575 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2576 | + print_error('Error: Unable to find language files!', true); |
|
| 2577 | + } else |
|
| 2428 | 2578 | { |
| 2429 | 2579 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2430 | 2580 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2431 | 2581 | |
| 2432 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2433 | - print_error('Error: Language files out of date.', true); |
|
| 2434 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2435 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2582 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2583 | + print_error('Error: Language files out of date.', true); |
|
| 2584 | + } |
|
| 2585 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2586 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2587 | + } |
|
| 2436 | 2588 | |
| 2437 | 2589 | // Otherwise include it! |
| 2438 | 2590 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2451,8 +2603,9 @@ discard block |
||
| 2451 | 2603 | global $upcontext, $db_character_set, $sourcedir, $smcFunc, $modSettings, $language, $db_prefix, $db_type, $command_line, $support_js; |
| 2452 | 2604 | |
| 2453 | 2605 | // Done it already? |
| 2454 | - if (!empty($_POST['utf8_done'])) |
|
| 2455 | - return true; |
|
| 2606 | + if (!empty($_POST['utf8_done'])) { |
|
| 2607 | + return true; |
|
| 2608 | + } |
|
| 2456 | 2609 | |
| 2457 | 2610 | // First make sure they aren't already on UTF-8 before we go anywhere... |
| 2458 | 2611 | if ($db_type == 'postgresql' || ($db_character_set === 'utf8' && !empty($modSettings['global_character_set']) && $modSettings['global_character_set'] === 'UTF-8')) |
@@ -2465,8 +2618,7 @@ discard block |
||
| 2465 | 2618 | ); |
| 2466 | 2619 | |
| 2467 | 2620 | return true; |
| 2468 | - } |
|
| 2469 | - else |
|
| 2621 | + } else |
|
| 2470 | 2622 | { |
| 2471 | 2623 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2472 | 2624 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2510,8 +2662,9 @@ discard block |
||
| 2510 | 2662 | ) |
| 2511 | 2663 | ); |
| 2512 | 2664 | $db_charsets = array(); |
| 2513 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2514 | - $db_charsets[] = $row['Charset']; |
|
| 2665 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2666 | + $db_charsets[] = $row['Charset']; |
|
| 2667 | + } |
|
| 2515 | 2668 | |
| 2516 | 2669 | $smcFunc['db_free_result']($request); |
| 2517 | 2670 | |
@@ -2547,13 +2700,15 @@ discard block |
||
| 2547 | 2700 | // If there's a fulltext index, we need to drop it first... |
| 2548 | 2701 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2549 | 2702 | { |
| 2550 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2551 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2703 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2704 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2552 | 2705 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2706 | + } |
|
| 2553 | 2707 | $smcFunc['db_free_result']($request); |
| 2554 | 2708 | |
| 2555 | - if (isset($upcontext['fulltext_index'])) |
|
| 2556 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2709 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2710 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2711 | + } |
|
| 2557 | 2712 | } |
| 2558 | 2713 | |
| 2559 | 2714 | // Drop it and make a note... |
@@ -2743,8 +2898,9 @@ discard block |
||
| 2743 | 2898 | $replace = '%field%'; |
| 2744 | 2899 | |
| 2745 | 2900 | // Build a huge REPLACE statement... |
| 2746 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2747 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2901 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 2902 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 2903 | + } |
|
| 2748 | 2904 | } |
| 2749 | 2905 | |
| 2750 | 2906 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2754,9 +2910,10 @@ discard block |
||
| 2754 | 2910 | $upcontext['table_count'] = count($queryTables); |
| 2755 | 2911 | |
| 2756 | 2912 | // What ones have we already done? |
| 2757 | - foreach ($queryTables as $id => $table) |
|
| 2758 | - if ($id < $_GET['substep']) |
|
| 2913 | + foreach ($queryTables as $id => $table) { |
|
| 2914 | + if ($id < $_GET['substep']) |
|
| 2759 | 2915 | $upcontext['previous_tables'][] = $table; |
| 2916 | + } |
|
| 2760 | 2917 | |
| 2761 | 2918 | $upcontext['cur_table_num'] = $_GET['substep']; |
| 2762 | 2919 | $upcontext['cur_table_name'] = str_replace($db_prefix, '', $queryTables[$_GET['substep']]); |
@@ -2793,8 +2950,9 @@ discard block |
||
| 2793 | 2950 | nextSubstep($substep); |
| 2794 | 2951 | |
| 2795 | 2952 | // Just to make sure it doesn't time out. |
| 2796 | - if (function_exists('apache_reset_timeout')) |
|
| 2797 | - @apache_reset_timeout(); |
|
| 2953 | + if (function_exists('apache_reset_timeout')) { |
|
| 2954 | + @apache_reset_timeout(); |
|
| 2955 | + } |
|
| 2798 | 2956 | |
| 2799 | 2957 | $table_charsets = array(); |
| 2800 | 2958 | |
@@ -2817,8 +2975,9 @@ discard block |
||
| 2817 | 2975 | |
| 2818 | 2976 | // Build structure of columns to operate on organized by charset; only operate on columns not yet utf8 |
| 2819 | 2977 | if ($charset != 'utf8') { |
| 2820 | - if (!isset($table_charsets[$charset])) |
|
| 2821 | - $table_charsets[$charset] = array(); |
|
| 2978 | + if (!isset($table_charsets[$charset])) { |
|
| 2979 | + $table_charsets[$charset] = array(); |
|
| 2980 | + } |
|
| 2822 | 2981 | |
| 2823 | 2982 | $table_charsets[$charset][] = $column_info; |
| 2824 | 2983 | } |
@@ -2859,10 +3018,11 @@ discard block |
||
| 2859 | 3018 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2860 | 3019 | { |
| 2861 | 3020 | $update = ''; |
| 2862 | - foreach ($table_charsets as $charset => $columns) |
|
| 2863 | - foreach ($columns as $column) |
|
| 3021 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3022 | + foreach ($columns as $column) |
|
| 2864 | 3023 | $update .= ' |
| 2865 | 3024 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3025 | + } |
|
| 2866 | 3026 | |
| 2867 | 3027 | $smcFunc['db_query']('', ' |
| 2868 | 3028 | UPDATE {raw:table_name} |
@@ -2887,8 +3047,9 @@ discard block |
||
| 2887 | 3047 | // Now do the actual conversion (if still needed). |
| 2888 | 3048 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2889 | 3049 | { |
| 2890 | - if ($command_line) |
|
| 2891 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3050 | + if ($command_line) { |
|
| 3051 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3052 | + } |
|
| 2892 | 3053 | |
| 2893 | 3054 | $smcFunc['db_query']('', ' |
| 2894 | 3055 | ALTER TABLE {raw:table_name} |
@@ -2898,12 +3059,14 @@ discard block |
||
| 2898 | 3059 | ) |
| 2899 | 3060 | ); |
| 2900 | 3061 | |
| 2901 | - if ($command_line) |
|
| 2902 | - echo " done.\n"; |
|
| 3062 | + if ($command_line) { |
|
| 3063 | + echo " done.\n"; |
|
| 3064 | + } |
|
| 2903 | 3065 | } |
| 2904 | 3066 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 2905 | - if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) |
|
| 2906 | - return upgradeExit(); |
|
| 3067 | + if (isset($_GET['xml']) && $upcontext['cur_table_num'] < $upcontext['table_count']) { |
|
| 3068 | + return upgradeExit(); |
|
| 3069 | + } |
|
| 2907 | 3070 | } |
| 2908 | 3071 | |
| 2909 | 3072 | $prev_charset = empty($translation_tables[$upcontext['charset_detected']]) ? $charsets[$upcontext['charset_detected']] : $translation_tables[$upcontext['charset_detected']]; |
@@ -2932,8 +3095,8 @@ discard block |
||
| 2932 | 3095 | ); |
| 2933 | 3096 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2934 | 3097 | { |
| 2935 | - if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
| 2936 | - $smcFunc['db_query']('', ' |
|
| 3098 | + if (@safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
| 3099 | + $smcFunc['db_query']('', ' |
|
| 2937 | 3100 | UPDATE {db_prefix}log_actions |
| 2938 | 3101 | SET extra = {string:extra} |
| 2939 | 3102 | WHERE id_action = {int:current_action}', |
@@ -2942,6 +3105,7 @@ discard block |
||
| 2942 | 3105 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 2943 | 3106 | ) |
| 2944 | 3107 | ); |
| 3108 | + } |
|
| 2945 | 3109 | } |
| 2946 | 3110 | $smcFunc['db_free_result']($request); |
| 2947 | 3111 | |
@@ -2963,15 +3127,17 @@ discard block |
||
| 2963 | 3127 | // First thing's first - did we already do this? |
| 2964 | 3128 | if (!empty($modSettings['json_done'])) |
| 2965 | 3129 | { |
| 2966 | - if ($command_line) |
|
| 2967 | - return DeleteUpgrade(); |
|
| 2968 | - else |
|
| 2969 | - return true; |
|
| 3130 | + if ($command_line) { |
|
| 3131 | + return DeleteUpgrade(); |
|
| 3132 | + } else { |
|
| 3133 | + return true; |
|
| 3134 | + } |
|
| 2970 | 3135 | } |
| 2971 | 3136 | |
| 2972 | 3137 | // Done it already - js wise? |
| 2973 | - if (!empty($_POST['json_done'])) |
|
| 2974 | - return true; |
|
| 3138 | + if (!empty($_POST['json_done'])) { |
|
| 3139 | + return true; |
|
| 3140 | + } |
|
| 2975 | 3141 | |
| 2976 | 3142 | // List of tables affected by this function |
| 2977 | 3143 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3003,12 +3169,14 @@ discard block |
||
| 3003 | 3169 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3004 | 3170 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3005 | 3171 | |
| 3006 | - foreach ($keys as $id => $table) |
|
| 3007 | - if ($id < $_GET['substep']) |
|
| 3172 | + foreach ($keys as $id => $table) { |
|
| 3173 | + if ($id < $_GET['substep']) |
|
| 3008 | 3174 | $upcontext['previous_tables'][] = $table; |
| 3175 | + } |
|
| 3009 | 3176 | |
| 3010 | - if ($command_line) |
|
| 3011 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3177 | + if ($command_line) { |
|
| 3178 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3179 | + } |
|
| 3012 | 3180 | |
| 3013 | 3181 | if (!$support_js || isset($_GET['xml'])) |
| 3014 | 3182 | { |
@@ -3048,8 +3216,9 @@ discard block |
||
| 3048 | 3216 | |
| 3049 | 3217 | // Loop through and fix these... |
| 3050 | 3218 | $new_settings = array(); |
| 3051 | - if ($command_line) |
|
| 3052 | - echo "\n" . 'Fixing some settings...'; |
|
| 3219 | + if ($command_line) { |
|
| 3220 | + echo "\n" . 'Fixing some settings...'; |
|
| 3221 | + } |
|
| 3053 | 3222 | |
| 3054 | 3223 | foreach ($serialized_settings as $var) |
| 3055 | 3224 | { |
@@ -3057,22 +3226,24 @@ discard block |
||
| 3057 | 3226 | { |
| 3058 | 3227 | // Attempt to unserialize the setting |
| 3059 | 3228 | $temp = @safe_unserialize($modSettings[$var]); |
| 3060 | - if (!$temp && $command_line) |
|
| 3061 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3062 | - elseif ($temp !== false) |
|
| 3063 | - $new_settings[$var] = json_encode($temp); |
|
| 3229 | + if (!$temp && $command_line) { |
|
| 3230 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3231 | + } elseif ($temp !== false) { |
|
| 3232 | + $new_settings[$var] = json_encode($temp); |
|
| 3233 | + } |
|
| 3064 | 3234 | } |
| 3065 | 3235 | } |
| 3066 | 3236 | |
| 3067 | 3237 | // Update everything at once |
| 3068 | - if (!function_exists('cache_put_data')) |
|
| 3069 | - require_once($sourcedir . '/Load.php'); |
|
| 3238 | + if (!function_exists('cache_put_data')) { |
|
| 3239 | + require_once($sourcedir . '/Load.php'); |
|
| 3240 | + } |
|
| 3070 | 3241 | updateSettings($new_settings, true); |
| 3071 | 3242 | |
| 3072 | - if ($command_line) |
|
| 3073 | - echo ' done.'; |
|
| 3074 | - } |
|
| 3075 | - elseif ($table == 'themes') |
|
| 3243 | + if ($command_line) { |
|
| 3244 | + echo ' done.'; |
|
| 3245 | + } |
|
| 3246 | + } elseif ($table == 'themes') |
|
| 3076 | 3247 | { |
| 3077 | 3248 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3078 | 3249 | $query = $smcFunc['db_query']('', ' |
@@ -3091,10 +3262,11 @@ discard block |
||
| 3091 | 3262 | |
| 3092 | 3263 | if ($command_line) |
| 3093 | 3264 | { |
| 3094 | - if ($temp === false) |
|
| 3095 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3096 | - else |
|
| 3097 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3265 | + if ($temp === false) { |
|
| 3266 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3267 | + } else { |
|
| 3268 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3269 | + } |
|
| 3098 | 3270 | } |
| 3099 | 3271 | |
| 3100 | 3272 | if ($temp !== false) |
@@ -3116,15 +3288,15 @@ discard block |
||
| 3116 | 3288 | ) |
| 3117 | 3289 | ); |
| 3118 | 3290 | |
| 3119 | - if ($command_line) |
|
| 3120 | - echo ' done.'; |
|
| 3291 | + if ($command_line) { |
|
| 3292 | + echo ' done.'; |
|
| 3293 | + } |
|
| 3121 | 3294 | } |
| 3122 | 3295 | } |
| 3123 | 3296 | |
| 3124 | 3297 | $smcFunc['db_free_result']($query); |
| 3125 | 3298 | } |
| 3126 | - } |
|
| 3127 | - else |
|
| 3299 | + } else |
|
| 3128 | 3300 | { |
| 3129 | 3301 | // First item is always the key... |
| 3130 | 3302 | $key = $info[0]; |
@@ -3135,8 +3307,7 @@ discard block |
||
| 3135 | 3307 | { |
| 3136 | 3308 | $col_select = $info[1]; |
| 3137 | 3309 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3138 | - } |
|
| 3139 | - else |
|
| 3310 | + } else |
|
| 3140 | 3311 | { |
| 3141 | 3312 | $col_select = implode(', ', $info); |
| 3142 | 3313 | } |
@@ -3169,8 +3340,7 @@ discard block |
||
| 3169 | 3340 | if ($temp === false && $command_line) |
| 3170 | 3341 | { |
| 3171 | 3342 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3172 | - } |
|
| 3173 | - else |
|
| 3343 | + } else |
|
| 3174 | 3344 | { |
| 3175 | 3345 | $row[$col] = json_encode($temp); |
| 3176 | 3346 | |
@@ -3195,16 +3365,18 @@ discard block |
||
| 3195 | 3365 | } |
| 3196 | 3366 | } |
| 3197 | 3367 | |
| 3198 | - if ($command_line) |
|
| 3199 | - echo ' done.'; |
|
| 3368 | + if ($command_line) { |
|
| 3369 | + echo ' done.'; |
|
| 3370 | + } |
|
| 3200 | 3371 | |
| 3201 | 3372 | // Free up some memory... |
| 3202 | 3373 | $smcFunc['db_free_result']($query); |
| 3203 | 3374 | } |
| 3204 | 3375 | } |
| 3205 | 3376 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3206 | - if (isset($_GET['xml'])) |
|
| 3207 | - return upgradeExit(); |
|
| 3377 | + if (isset($_GET['xml'])) { |
|
| 3378 | + return upgradeExit(); |
|
| 3379 | + } |
|
| 3208 | 3380 | } |
| 3209 | 3381 | |
| 3210 | 3382 | if ($command_line) |
@@ -3219,8 +3391,9 @@ discard block |
||
| 3219 | 3391 | |
| 3220 | 3392 | $_GET['substep'] = 0; |
| 3221 | 3393 | // Make sure we move on! |
| 3222 | - if ($command_line) |
|
| 3223 | - return DeleteUpgrade(); |
|
| 3394 | + if ($command_line) { |
|
| 3395 | + return DeleteUpgrade(); |
|
| 3396 | + } |
|
| 3224 | 3397 | |
| 3225 | 3398 | return true; |
| 3226 | 3399 | } |
@@ -3240,14 +3413,16 @@ discard block |
||
| 3240 | 3413 | global $upcontext, $txt, $settings; |
| 3241 | 3414 | |
| 3242 | 3415 | // Don't call me twice! |
| 3243 | - if (!empty($upcontext['chmod_called'])) |
|
| 3244 | - return; |
|
| 3416 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3417 | + return; |
|
| 3418 | + } |
|
| 3245 | 3419 | |
| 3246 | 3420 | $upcontext['chmod_called'] = true; |
| 3247 | 3421 | |
| 3248 | 3422 | // Nothing? |
| 3249 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3250 | - return; |
|
| 3423 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3424 | + return; |
|
| 3425 | + } |
|
| 3251 | 3426 | |
| 3252 | 3427 | // Was it a problem with Windows? |
| 3253 | 3428 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3279,11 +3454,12 @@ discard block |
||
| 3279 | 3454 | content.write(\'<div class="windowbg description">\n\t\t\t<h4>The following files needs to be made writable to continue:</h4>\n\t\t\t\'); |
| 3280 | 3455 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3281 | 3456 | |
| 3282 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3283 | - echo ' |
|
| 3457 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3458 | + echo ' |
|
| 3284 | 3459 | content.write(\'<hr>\n\t\t\t\'); |
| 3285 | 3460 | content.write(\'<p>If you have a shell account, the convenient below command can automatically correct permissions on these files</p>\n\t\t\t\'); |
| 3286 | 3461 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3462 | + } |
|
| 3287 | 3463 | |
| 3288 | 3464 | echo ' |
| 3289 | 3465 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3291,17 +3467,19 @@ discard block |
||
| 3291 | 3467 | } |
| 3292 | 3468 | </script>'; |
| 3293 | 3469 | |
| 3294 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3295 | - echo ' |
|
| 3470 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3471 | + echo ' |
|
| 3296 | 3472 | <div class="error_message red"> |
| 3297 | 3473 | The following error was encountered when trying to connect:<br><br> |
| 3298 | 3474 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3299 | 3475 | </div> |
| 3300 | 3476 | <br>'; |
| 3477 | + } |
|
| 3301 | 3478 | |
| 3302 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3303 | - echo ' |
|
| 3479 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3480 | + echo ' |
|
| 3304 | 3481 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3482 | + } |
|
| 3305 | 3483 | |
| 3306 | 3484 | echo ' |
| 3307 | 3485 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3336,10 +3514,11 @@ discard block |
||
| 3336 | 3514 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button"></div> |
| 3337 | 3515 | </div>'; |
| 3338 | 3516 | |
| 3339 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3340 | - echo ' |
|
| 3517 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3518 | + echo ' |
|
| 3341 | 3519 | </form>'; |
| 3342 | -} |
|
| 3520 | + } |
|
| 3521 | + } |
|
| 3343 | 3522 | |
| 3344 | 3523 | function template_upgrade_above() |
| 3345 | 3524 | { |
@@ -3399,9 +3578,10 @@ discard block |
||
| 3399 | 3578 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3400 | 3579 | <ul>'; |
| 3401 | 3580 | |
| 3402 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3403 | - echo ' |
|
| 3581 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3582 | + echo ' |
|
| 3404 | 3583 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3584 | + } |
|
| 3405 | 3585 | |
| 3406 | 3586 | echo ' |
| 3407 | 3587 | </ul> |
@@ -3414,8 +3594,8 @@ discard block |
||
| 3414 | 3594 | </div> |
| 3415 | 3595 | </div>'; |
| 3416 | 3596 | |
| 3417 | - if (isset($upcontext['step_progress'])) |
|
| 3418 | - echo ' |
|
| 3597 | + if (isset($upcontext['step_progress'])) { |
|
| 3598 | + echo ' |
|
| 3419 | 3599 | <br> |
| 3420 | 3600 | <br> |
| 3421 | 3601 | <div id="progress_bar_step"> |
@@ -3424,6 +3604,7 @@ discard block |
||
| 3424 | 3604 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3425 | 3605 | </div> |
| 3426 | 3606 | </div>'; |
| 3607 | + } |
|
| 3427 | 3608 | |
| 3428 | 3609 | echo ' |
| 3429 | 3610 | <div id="substep_bar_div" class="smalltext" style="float: left;width: 50%;margin-top: 0.6em;display: ', isset($upcontext['substep_progress']) ? '' : 'none', ';">', isset($upcontext['substep_progress_name']) ? trim(strtr($upcontext['substep_progress_name'], array('.' => ''))) : '', ':</div> |
@@ -3454,32 +3635,36 @@ discard block |
||
| 3454 | 3635 | { |
| 3455 | 3636 | global $upcontext, $txt; |
| 3456 | 3637 | |
| 3457 | - if (!empty($upcontext['pause'])) |
|
| 3458 | - echo ' |
|
| 3638 | + if (!empty($upcontext['pause'])) { |
|
| 3639 | + echo ' |
|
| 3459 | 3640 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3460 | 3641 | |
| 3461 | 3642 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3462 | 3643 | <h3> |
| 3463 | 3644 | ', $txt['upgrade_paused_overload'], ' |
| 3464 | 3645 | </h3>'; |
| 3646 | + } |
|
| 3465 | 3647 | |
| 3466 | - if (!empty($upcontext['custom_warning'])) |
|
| 3467 | - echo ' |
|
| 3648 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3649 | + echo ' |
|
| 3468 | 3650 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3469 | 3651 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3470 | 3652 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3471 | 3653 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3472 | 3654 | </div>'; |
| 3655 | + } |
|
| 3473 | 3656 | |
| 3474 | 3657 | echo ' |
| 3475 | 3658 | <div class="righttext" style="margin: 1ex;">'; |
| 3476 | 3659 | |
| 3477 | - if (!empty($upcontext['continue'])) |
|
| 3478 | - echo ' |
|
| 3660 | + if (!empty($upcontext['continue'])) { |
|
| 3661 | + echo ' |
|
| 3479 | 3662 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button">'; |
| 3480 | - if (!empty($upcontext['skip'])) |
|
| 3481 | - echo ' |
|
| 3663 | + } |
|
| 3664 | + if (!empty($upcontext['skip'])) { |
|
| 3665 | + echo ' |
|
| 3482 | 3666 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button">'; |
| 3667 | + } |
|
| 3483 | 3668 | |
| 3484 | 3669 | echo ' |
| 3485 | 3670 | </div> |
@@ -3529,11 +3714,12 @@ discard block |
||
| 3529 | 3714 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3530 | 3715 | <smf>'; |
| 3531 | 3716 | |
| 3532 | - if (!empty($upcontext['get_data'])) |
|
| 3533 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3717 | + if (!empty($upcontext['get_data'])) { |
|
| 3718 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3534 | 3719 | echo ' |
| 3535 | 3720 | <get key="', $k, '">', $v, '</get>'; |
| 3536 | -} |
|
| 3721 | + } |
|
| 3722 | + } |
|
| 3537 | 3723 | |
| 3538 | 3724 | function template_xml_below() |
| 3539 | 3725 | { |
@@ -3574,8 +3760,8 @@ discard block |
||
| 3574 | 3760 | template_chmod(); |
| 3575 | 3761 | |
| 3576 | 3762 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3577 | - if ($upcontext['is_large_forum']) |
|
| 3578 | - echo ' |
|
| 3763 | + if ($upcontext['is_large_forum']) { |
|
| 3764 | + echo ' |
|
| 3579 | 3765 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3580 | 3766 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3581 | 3767 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3583,10 +3769,11 @@ discard block |
||
| 3583 | 3769 | ', $txt['upgrade_warning_lots_data'], ' |
| 3584 | 3770 | </div> |
| 3585 | 3771 | </div>'; |
| 3772 | + } |
|
| 3586 | 3773 | |
| 3587 | 3774 | // A warning message? |
| 3588 | - if (!empty($upcontext['warning'])) |
|
| 3589 | - echo ' |
|
| 3775 | + if (!empty($upcontext['warning'])) { |
|
| 3776 | + echo ' |
|
| 3590 | 3777 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3591 | 3778 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3592 | 3779 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3594,6 +3781,7 @@ discard block |
||
| 3594 | 3781 | ', $upcontext['warning'], ' |
| 3595 | 3782 | </div> |
| 3596 | 3783 | </div>'; |
| 3784 | + } |
|
| 3597 | 3785 | |
| 3598 | 3786 | // Paths are incorrect? |
| 3599 | 3787 | echo ' |
@@ -3609,20 +3797,22 @@ discard block |
||
| 3609 | 3797 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3610 | 3798 | { |
| 3611 | 3799 | $ago = time() - $upcontext['started']; |
| 3612 | - if ($ago < 60) |
|
| 3613 | - $ago = $ago . ' seconds'; |
|
| 3614 | - elseif ($ago < 3600) |
|
| 3615 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3616 | - else |
|
| 3617 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3800 | + if ($ago < 60) { |
|
| 3801 | + $ago = $ago . ' seconds'; |
|
| 3802 | + } elseif ($ago < 3600) { |
|
| 3803 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3804 | + } else { |
|
| 3805 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3806 | + } |
|
| 3618 | 3807 | |
| 3619 | 3808 | $active = time() - $upcontext['updated']; |
| 3620 | - if ($active < 60) |
|
| 3621 | - $updated = $active . ' seconds'; |
|
| 3622 | - elseif ($active < 3600) |
|
| 3623 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3624 | - else |
|
| 3625 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3809 | + if ($active < 60) { |
|
| 3810 | + $updated = $active . ' seconds'; |
|
| 3811 | + } elseif ($active < 3600) { |
|
| 3812 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3813 | + } else { |
|
| 3814 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3815 | + } |
|
| 3626 | 3816 | |
| 3627 | 3817 | echo ' |
| 3628 | 3818 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3631,16 +3821,18 @@ discard block |
||
| 3631 | 3821 | <div style="padding-left: 6ex;"> |
| 3632 | 3822 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3633 | 3823 | |
| 3634 | - if ($active < 600) |
|
| 3635 | - echo ' |
|
| 3824 | + if ($active < 600) { |
|
| 3825 | + echo ' |
|
| 3636 | 3826 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 3827 | + } |
|
| 3637 | 3828 | |
| 3638 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3639 | - echo ' |
|
| 3829 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3830 | + echo ' |
|
| 3640 | 3831 | <br><br>You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.'; |
| 3641 | - else |
|
| 3642 | - echo ' |
|
| 3832 | + } else { |
|
| 3833 | + echo ' |
|
| 3643 | 3834 | <br><br>This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', ($upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!'); |
| 3835 | + } |
|
| 3644 | 3836 | |
| 3645 | 3837 | echo ' |
| 3646 | 3838 | </div> |
@@ -3656,9 +3848,10 @@ discard block |
||
| 3656 | 3848 | <td> |
| 3657 | 3849 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', '>'; |
| 3658 | 3850 | |
| 3659 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3660 | - echo ' |
|
| 3851 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3852 | + echo ' |
|
| 3661 | 3853 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 3854 | + } |
|
| 3662 | 3855 | |
| 3663 | 3856 | echo ' |
| 3664 | 3857 | </td> |
@@ -3669,9 +3862,10 @@ discard block |
||
| 3669 | 3862 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', '> |
| 3670 | 3863 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3671 | 3864 | |
| 3672 | - if (!empty($upcontext['password_failed'])) |
|
| 3673 | - echo ' |
|
| 3865 | + if (!empty($upcontext['password_failed'])) { |
|
| 3866 | + echo ' |
|
| 3674 | 3867 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 3868 | + } |
|
| 3675 | 3869 | |
| 3676 | 3870 | echo ' |
| 3677 | 3871 | </td> |
@@ -3742,8 +3936,8 @@ discard block |
||
| 3742 | 3936 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3743 | 3937 | |
| 3744 | 3938 | // Warning message? |
| 3745 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3746 | - echo ' |
|
| 3939 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 3940 | + echo ' |
|
| 3747 | 3941 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3748 | 3942 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3749 | 3943 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3751,6 +3945,7 @@ discard block |
||
| 3751 | 3945 | ', $upcontext['upgrade_options_warning'], ' |
| 3752 | 3946 | </div> |
| 3753 | 3947 | </div>'; |
| 3948 | + } |
|
| 3754 | 3949 | |
| 3755 | 3950 | echo ' |
| 3756 | 3951 | <table> |
@@ -3793,8 +3988,8 @@ discard block |
||
| 3793 | 3988 | </td> |
| 3794 | 3989 | </tr>'; |
| 3795 | 3990 | |
| 3796 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3797 | - echo ' |
|
| 3991 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 3992 | + echo ' |
|
| 3798 | 3993 | <tr valign="top"> |
| 3799 | 3994 | <td width="2%"> |
| 3800 | 3995 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1"> |
@@ -3803,6 +3998,7 @@ discard block |
||
| 3803 | 3998 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 3804 | 3999 | </td> |
| 3805 | 4000 | </tr>'; |
| 4001 | + } |
|
| 3806 | 4002 | |
| 3807 | 4003 | echo ' |
| 3808 | 4004 | <tr valign="top"> |
@@ -3840,10 +4036,11 @@ discard block |
||
| 3840 | 4036 | </div>'; |
| 3841 | 4037 | |
| 3842 | 4038 | // Dont any tables so far? |
| 3843 | - if (!empty($upcontext['previous_tables'])) |
|
| 3844 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4039 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4040 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3845 | 4041 | echo ' |
| 3846 | 4042 | <br>Completed Table: "', $table, '".'; |
| 4043 | + } |
|
| 3847 | 4044 | |
| 3848 | 4045 | echo ' |
| 3849 | 4046 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3880,12 +4077,13 @@ discard block |
||
| 3880 | 4077 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3881 | 4078 | |
| 3882 | 4079 | // If debug flood the screen. |
| 3883 | - if ($is_debug) |
|
| 3884 | - echo ' |
|
| 4080 | + if ($is_debug) { |
|
| 4081 | + echo ' |
|
| 3885 | 4082 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 3886 | 4083 | |
| 3887 | 4084 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 3888 | 4085 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4086 | + } |
|
| 3889 | 4087 | |
| 3890 | 4088 | echo ' |
| 3891 | 4089 | // Get the next update... |
@@ -3918,8 +4116,9 @@ discard block |
||
| 3918 | 4116 | { |
| 3919 | 4117 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 3920 | 4118 | |
| 3921 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 3922 | - $is_debug = true; |
|
| 4119 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4120 | + $is_debug = true; |
|
| 4121 | + } |
|
| 3923 | 4122 | |
| 3924 | 4123 | echo ' |
| 3925 | 4124 | <h3>Executing database changes</h3> |
@@ -3934,8 +4133,9 @@ discard block |
||
| 3934 | 4133 | { |
| 3935 | 4134 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 3936 | 4135 | { |
| 3937 | - if ($num != 0) |
|
| 3938 | - echo ' Successful!'; |
|
| 4136 | + if ($num != 0) { |
|
| 4137 | + echo ' Successful!'; |
|
| 4138 | + } |
|
| 3939 | 4139 | echo '<br>' . $item; |
| 3940 | 4140 | } |
| 3941 | 4141 | if (!empty($upcontext['changes_complete'])) |
@@ -3948,28 +4148,32 @@ discard block |
||
| 3948 | 4148 | $seconds = intval($active % 60); |
| 3949 | 4149 | |
| 3950 | 4150 | $totalTime = ''; |
| 3951 | - if ($hours > 0) |
|
| 3952 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3953 | - if ($minutes > 0) |
|
| 3954 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3955 | - if ($seconds > 0) |
|
| 3956 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4151 | + if ($hours > 0) { |
|
| 4152 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4153 | + } |
|
| 4154 | + if ($minutes > 0) { |
|
| 4155 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4156 | + } |
|
| 4157 | + if ($seconds > 0) { |
|
| 4158 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4159 | + } |
|
| 3957 | 4160 | } |
| 3958 | 4161 | |
| 3959 | - if ($is_debug && !empty($totalTime)) |
|
| 3960 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 3961 | - else |
|
| 3962 | - echo ' Successful!<br><br>'; |
|
| 4162 | + if ($is_debug && !empty($totalTime)) { |
|
| 4163 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4164 | + } else { |
|
| 4165 | + echo ' Successful!<br><br>'; |
|
| 4166 | + } |
|
| 3963 | 4167 | |
| 3964 | 4168 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 3965 | 4169 | } |
| 3966 | - } |
|
| 3967 | - else |
|
| 4170 | + } else |
|
| 3968 | 4171 | { |
| 3969 | 4172 | // Tell them how many files we have in total. |
| 3970 | - if ($upcontext['file_count'] > 1) |
|
| 3971 | - echo ' |
|
| 4173 | + if ($upcontext['file_count'] > 1) { |
|
| 4174 | + echo ' |
|
| 3972 | 4175 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4176 | + } |
|
| 3973 | 4177 | |
| 3974 | 4178 | echo ' |
| 3975 | 4179 | <h3 id="info2"><strong>Executing:</strong> "<span id="cur_item_name">', $upcontext['current_item_name'], '</span>" (<span id="item_num">', $upcontext['current_item_num'], '</span> of <span id="total_items"><span id="item_count">', $upcontext['total_items'], '</span>', $upcontext['file_count'] > 1 ? ' - of this script' : '', ')</span></h3> |
@@ -3985,19 +4189,23 @@ discard block |
||
| 3985 | 4189 | $seconds = intval($active % 60); |
| 3986 | 4190 | |
| 3987 | 4191 | $totalTime = ''; |
| 3988 | - if ($hours > 0) |
|
| 3989 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 3990 | - if ($minutes > 0) |
|
| 3991 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 3992 | - if ($seconds > 0) |
|
| 3993 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4192 | + if ($hours > 0) { |
|
| 4193 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4194 | + } |
|
| 4195 | + if ($minutes > 0) { |
|
| 4196 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4197 | + } |
|
| 4198 | + if ($seconds > 0) { |
|
| 4199 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4200 | + } |
|
| 3994 | 4201 | } |
| 3995 | 4202 | |
| 3996 | 4203 | echo ' |
| 3997 | 4204 | <br><span id="upgradeCompleted">'; |
| 3998 | 4205 | |
| 3999 | - if (!empty($totalTime)) |
|
| 4000 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4206 | + if (!empty($totalTime)) { |
|
| 4207 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4208 | + } |
|
| 4001 | 4209 | |
| 4002 | 4210 | echo '</span> |
| 4003 | 4211 | <div id="debug_section" style="height: 59px; overflow: auto;"> |
@@ -4034,9 +4242,10 @@ discard block |
||
| 4034 | 4242 | var getData = ""; |
| 4035 | 4243 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4036 | 4244 | |
| 4037 | - if ($is_debug) |
|
| 4038 | - echo ' |
|
| 4245 | + if ($is_debug) { |
|
| 4246 | + echo ' |
|
| 4039 | 4247 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4248 | + } |
|
| 4040 | 4249 | |
| 4041 | 4250 | echo ' |
| 4042 | 4251 | function getNextItem() |
@@ -4076,9 +4285,10 @@ discard block |
||
| 4076 | 4285 | document.getElementById("error_block").style.display = ""; |
| 4077 | 4286 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4078 | 4287 | |
| 4079 | - if ($is_debug) |
|
| 4080 | - echo ' |
|
| 4288 | + if ($is_debug) { |
|
| 4289 | + echo ' |
|
| 4081 | 4290 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4291 | + } |
|
| 4082 | 4292 | |
| 4083 | 4293 | echo ' |
| 4084 | 4294 | } |
@@ -4099,9 +4309,10 @@ discard block |
||
| 4099 | 4309 | document.getElementById("error_block").style.display = ""; |
| 4100 | 4310 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4101 | 4311 | |
| 4102 | - if ($is_debug) |
|
| 4103 | - echo ' |
|
| 4312 | + if ($is_debug) { |
|
| 4313 | + echo ' |
|
| 4104 | 4314 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4315 | + } |
|
| 4105 | 4316 | |
| 4106 | 4317 | echo ' |
| 4107 | 4318 | } |
@@ -4160,8 +4371,8 @@ discard block |
||
| 4160 | 4371 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4161 | 4372 | {'; |
| 4162 | 4373 | |
| 4163 | - if ($is_debug) |
|
| 4164 | - echo ' |
|
| 4374 | + if ($is_debug) { |
|
| 4375 | + echo ' |
|
| 4165 | 4376 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4166 | 4377 | |
| 4167 | 4378 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4179,6 +4390,7 @@ discard block |
||
| 4179 | 4390 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4180 | 4391 | |
| 4181 | 4392 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4393 | + } |
|
| 4182 | 4394 | |
| 4183 | 4395 | echo ' |
| 4184 | 4396 | |
@@ -4186,9 +4398,10 @@ discard block |
||
| 4186 | 4398 | document.getElementById(\'contbutt\').disabled = 0; |
| 4187 | 4399 | document.getElementById(\'database_done\').value = 1;'; |
| 4188 | 4400 | |
| 4189 | - if ($upcontext['file_count'] > 1) |
|
| 4190 | - echo ' |
|
| 4401 | + if ($upcontext['file_count'] > 1) { |
|
| 4402 | + echo ' |
|
| 4191 | 4403 | document.getElementById(\'info1\').style.display = "none";'; |
| 4404 | + } |
|
| 4192 | 4405 | |
| 4193 | 4406 | echo ' |
| 4194 | 4407 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4201,9 +4414,10 @@ discard block |
||
| 4201 | 4414 | lastItem = 0; |
| 4202 | 4415 | prevFile = curFile;'; |
| 4203 | 4416 | |
| 4204 | - if ($is_debug) |
|
| 4205 | - echo ' |
|
| 4417 | + if ($is_debug) { |
|
| 4418 | + echo ' |
|
| 4206 | 4419 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4420 | + } |
|
| 4207 | 4421 | |
| 4208 | 4422 | echo ' |
| 4209 | 4423 | getNextItem(); |
@@ -4211,8 +4425,8 @@ discard block |
||
| 4211 | 4425 | }'; |
| 4212 | 4426 | |
| 4213 | 4427 | // If debug scroll the screen. |
| 4214 | - if ($is_debug) |
|
| 4215 | - echo ' |
|
| 4428 | + if ($is_debug) { |
|
| 4429 | + echo ' |
|
| 4216 | 4430 | if (iLastSubStepProgress == -1) |
| 4217 | 4431 | { |
| 4218 | 4432 | // Give it consistent dots. |
@@ -4231,6 +4445,7 @@ discard block |
||
| 4231 | 4445 | |
| 4232 | 4446 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4233 | 4447 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4448 | + } |
|
| 4234 | 4449 | |
| 4235 | 4450 | echo ' |
| 4236 | 4451 | // Update the page. |
@@ -4291,9 +4506,10 @@ discard block |
||
| 4291 | 4506 | }'; |
| 4292 | 4507 | |
| 4293 | 4508 | // Start things off assuming we've not errored. |
| 4294 | - if (empty($upcontext['error_message'])) |
|
| 4295 | - echo ' |
|
| 4509 | + if (empty($upcontext['error_message'])) { |
|
| 4510 | + echo ' |
|
| 4296 | 4511 | getNextItem();'; |
| 4512 | + } |
|
| 4297 | 4513 | |
| 4298 | 4514 | echo ' |
| 4299 | 4515 | //# sourceURL=dynamicScript-dbch.js |
@@ -4311,18 +4527,21 @@ discard block |
||
| 4311 | 4527 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4312 | 4528 | <debug num="', $upcontext['current_debug_item_num'], '" percent="', isset($upcontext['substep_progress']) ? $upcontext['substep_progress'] : '-1', '" complete="', empty($upcontext['completed_step']) ? 0 : 1, '">', $upcontext['current_debug_item_name'], '</debug>'; |
| 4313 | 4529 | |
| 4314 | - if (!empty($upcontext['error_message'])) |
|
| 4315 | - echo ' |
|
| 4530 | + if (!empty($upcontext['error_message'])) { |
|
| 4531 | + echo ' |
|
| 4316 | 4532 | <error>', $upcontext['error_message'], '</error>'; |
| 4533 | + } |
|
| 4317 | 4534 | |
| 4318 | - if (!empty($upcontext['error_string'])) |
|
| 4319 | - echo ' |
|
| 4535 | + if (!empty($upcontext['error_string'])) { |
|
| 4536 | + echo ' |
|
| 4320 | 4537 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4538 | + } |
|
| 4321 | 4539 | |
| 4322 | - if ($is_debug) |
|
| 4323 | - echo ' |
|
| 4540 | + if ($is_debug) { |
|
| 4541 | + echo ' |
|
| 4324 | 4542 | <curtime>', time(), '</curtime>'; |
| 4325 | -} |
|
| 4543 | + } |
|
| 4544 | + } |
|
| 4326 | 4545 | |
| 4327 | 4546 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4328 | 4547 | function template_convert_utf8() |
@@ -4341,18 +4560,20 @@ discard block |
||
| 4341 | 4560 | </div>'; |
| 4342 | 4561 | |
| 4343 | 4562 | // Done any tables so far? |
| 4344 | - if (!empty($upcontext['previous_tables'])) |
|
| 4345 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4563 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4564 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4346 | 4565 | echo ' |
| 4347 | 4566 | <br>Completed Table: "', $table, '".'; |
| 4567 | + } |
|
| 4348 | 4568 | |
| 4349 | 4569 | echo ' |
| 4350 | 4570 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4351 | 4571 | |
| 4352 | 4572 | // If we dropped their index, let's let them know |
| 4353 | - if ($upcontext['dropping_index']) |
|
| 4354 | - echo ' |
|
| 4573 | + if ($upcontext['dropping_index']) { |
|
| 4574 | + echo ' |
|
| 4355 | 4575 | <br><span id="indexmsg" style="font-weight: bold; font-style: italic; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated in the admin area after the upgrade is complete.</span>'; |
| 4576 | + } |
|
| 4356 | 4577 | |
| 4357 | 4578 | // Completion notification |
| 4358 | 4579 | echo ' |
@@ -4389,12 +4610,13 @@ discard block |
||
| 4389 | 4610 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4390 | 4611 | |
| 4391 | 4612 | // If debug flood the screen. |
| 4392 | - if ($is_debug) |
|
| 4393 | - echo ' |
|
| 4613 | + if ($is_debug) { |
|
| 4614 | + echo ' |
|
| 4394 | 4615 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4395 | 4616 | |
| 4396 | 4617 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4397 | 4618 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4619 | + } |
|
| 4398 | 4620 | |
| 4399 | 4621 | echo ' |
| 4400 | 4622 | // Get the next update... |
@@ -4442,19 +4664,21 @@ discard block |
||
| 4442 | 4664 | </div>'; |
| 4443 | 4665 | |
| 4444 | 4666 | // Dont any tables so far? |
| 4445 | - if (!empty($upcontext['previous_tables'])) |
|
| 4446 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4667 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4668 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4447 | 4669 | echo ' |
| 4448 | 4670 | <br>Completed Table: "', $table, '".'; |
| 4671 | + } |
|
| 4449 | 4672 | |
| 4450 | 4673 | echo ' |
| 4451 | 4674 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4452 | 4675 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Convert to JSON Complete! Click Continue to Proceed.</span>'; |
| 4453 | 4676 | |
| 4454 | 4677 | // Try to make sure substep was reset. |
| 4455 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4456 | - echo ' |
|
| 4678 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4679 | + echo ' |
|
| 4457 | 4680 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4681 | + } |
|
| 4458 | 4682 | |
| 4459 | 4683 | // Continue please! |
| 4460 | 4684 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4487,12 +4711,13 @@ discard block |
||
| 4487 | 4711 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4488 | 4712 | |
| 4489 | 4713 | // If debug flood the screen. |
| 4490 | - if ($is_debug) |
|
| 4491 | - echo ' |
|
| 4714 | + if ($is_debug) { |
|
| 4715 | + echo ' |
|
| 4492 | 4716 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4493 | 4717 | |
| 4494 | 4718 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4495 | 4719 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4720 | + } |
|
| 4496 | 4721 | |
| 4497 | 4722 | echo ' |
| 4498 | 4723 | // Get the next update... |
@@ -4528,8 +4753,8 @@ discard block |
||
| 4528 | 4753 | <h3>That wasn\'t so hard, was it? Now you are ready to use <a href="', $boardurl, '/index.php">your installation of SMF</a>. Hope you like it!</h3> |
| 4529 | 4754 | <form action="', $boardurl, '/index.php">'; |
| 4530 | 4755 | |
| 4531 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4532 | - echo ' |
|
| 4756 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4757 | + echo ' |
|
| 4533 | 4758 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
| 4534 | 4759 | <script> |
| 4535 | 4760 | function doTheDelete(theCheck) |
@@ -4541,6 +4766,7 @@ discard block |
||
| 4541 | 4766 | } |
| 4542 | 4767 | </script> |
| 4543 | 4768 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4769 | + } |
|
| 4544 | 4770 | |
| 4545 | 4771 | $active = time() - $upcontext['started']; |
| 4546 | 4772 | $hours = floor($active / 3600); |
@@ -4550,16 +4776,20 @@ discard block |
||
| 4550 | 4776 | if ($is_debug) |
| 4551 | 4777 | { |
| 4552 | 4778 | $totalTime = ''; |
| 4553 | - if ($hours > 0) |
|
| 4554 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4555 | - if ($minutes > 0) |
|
| 4556 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4557 | - if ($seconds > 0) |
|
| 4558 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4779 | + if ($hours > 0) { |
|
| 4780 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4781 | + } |
|
| 4782 | + if ($minutes > 0) { |
|
| 4783 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4784 | + } |
|
| 4785 | + if ($seconds > 0) { |
|
| 4786 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4787 | + } |
|
| 4559 | 4788 | } |
| 4560 | 4789 | |
| 4561 | - if ($is_debug && !empty($totalTime)) |
|
| 4562 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4790 | + if ($is_debug && !empty($totalTime)) { |
|
| 4791 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4792 | + } |
|
| 4563 | 4793 | |
| 4564 | 4794 | echo '<br> |
| 4565 | 4795 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="https://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4586,8 +4816,9 @@ discard block |
||
| 4586 | 4816 | |
| 4587 | 4817 | $current_substep = $_GET['substep']; |
| 4588 | 4818 | |
| 4589 | - if (empty($_GET['a'])) |
|
| 4590 | - $_GET['a'] = 0; |
|
| 4819 | + if (empty($_GET['a'])) { |
|
| 4820 | + $_GET['a'] = 0; |
|
| 4821 | + } |
|
| 4591 | 4822 | $step_progress['name'] = 'Converting ips'; |
| 4592 | 4823 | $step_progress['current'] = $_GET['a']; |
| 4593 | 4824 | |
@@ -4630,16 +4861,19 @@ discard block |
||
| 4630 | 4861 | 'empty' => '', |
| 4631 | 4862 | 'limit' => $limit, |
| 4632 | 4863 | )); |
| 4633 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4634 | - $arIp[] = $row[$oldCol]; |
|
| 4864 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4865 | + $arIp[] = $row[$oldCol]; |
|
| 4866 | + } |
|
| 4635 | 4867 | $smcFunc['db_free_result']($request); |
| 4636 | 4868 | |
| 4637 | 4869 | // Special case, null ip could keep us in a loop. |
| 4638 | - if (is_null($arIp[0])) |
|
| 4639 | - unset($arIp[0]); |
|
| 4870 | + if (is_null($arIp[0])) { |
|
| 4871 | + unset($arIp[0]); |
|
| 4872 | + } |
|
| 4640 | 4873 | |
| 4641 | - if (empty($arIp)) |
|
| 4642 | - $is_done = true; |
|
| 4874 | + if (empty($arIp)) { |
|
| 4875 | + $is_done = true; |
|
| 4876 | + } |
|
| 4643 | 4877 | |
| 4644 | 4878 | $updates = array(); |
| 4645 | 4879 | $cases = array(); |
@@ -4648,16 +4882,18 @@ discard block |
||
| 4648 | 4882 | { |
| 4649 | 4883 | $arIp[$i] = trim($arIp[$i]); |
| 4650 | 4884 | |
| 4651 | - if (empty($arIp[$i])) |
|
| 4652 | - continue; |
|
| 4885 | + if (empty($arIp[$i])) { |
|
| 4886 | + continue; |
|
| 4887 | + } |
|
| 4653 | 4888 | |
| 4654 | 4889 | $updates['ip' . $i] = $arIp[$i]; |
| 4655 | 4890 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4656 | 4891 | |
| 4657 | 4892 | if ($setSize > 0 && $i % $setSize === 0) |
| 4658 | 4893 | { |
| 4659 | - if (count($updates) == 1) |
|
| 4660 | - continue; |
|
| 4894 | + if (count($updates) == 1) { |
|
| 4895 | + continue; |
|
| 4896 | + } |
|
| 4661 | 4897 | |
| 4662 | 4898 | $updates['whereSet'] = array_values($updates); |
| 4663 | 4899 | $smcFunc['db_query']('', ' |
@@ -4691,8 +4927,7 @@ discard block |
||
| 4691 | 4927 | 'ip' => $ip |
| 4692 | 4928 | )); |
| 4693 | 4929 | } |
| 4694 | - } |
|
| 4695 | - else |
|
| 4930 | + } else |
|
| 4696 | 4931 | { |
| 4697 | 4932 | $updates['whereSet'] = array_values($updates); |
| 4698 | 4933 | $smcFunc['db_query']('', ' |
@@ -4706,9 +4941,9 @@ discard block |
||
| 4706 | 4941 | $updates |
| 4707 | 4942 | ); |
| 4708 | 4943 | } |
| 4944 | + } else { |
|
| 4945 | + $is_done = true; |
|
| 4709 | 4946 | } |
| 4710 | - else |
|
| 4711 | - $is_done = true; |
|
| 4712 | 4947 | |
| 4713 | 4948 | $_GET['a'] += $limit; |
| 4714 | 4949 | $step_progress['current'] = $_GET['a']; |
@@ -4734,10 +4969,11 @@ discard block |
||
| 4734 | 4969 | |
| 4735 | 4970 | $columns = $smcFunc['db_list_columns']($targetTable, true); |
| 4736 | 4971 | |
| 4737 | - if (isset($columns[$column])) |
|
| 4738 | - return $columns[$column]; |
|
| 4739 | - else |
|
| 4740 | - return null; |
|
| 4741 | -} |
|
| 4972 | + if (isset($columns[$column])) { |
|
| 4973 | + return $columns[$column]; |
|
| 4974 | + } else { |
|
| 4975 | + return null; |
|
| 4976 | + } |
|
| 4977 | + } |
|
| 4742 | 4978 | |
| 4743 | 4979 | ?> |
| 4744 | 4980 | \ No newline at end of file |
@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
| 21 | 21 | |
| 22 | 22 | // Let's pull in useful classes |
| 23 | -if (!defined('SMF')) |
|
| 23 | +if (!defined('SMF')) { |
|
| 24 | 24 | define('SMF', 1); |
| 25 | +} |
|
| 25 | 26 | |
| 26 | 27 | require_once('Sources/Class-Package.php'); |
| 27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
| 63 | 64 | |
| 64 | 65 | list ($charcode) = pg_fetch_row($request); |
| 65 | 66 | |
| 66 | - if ($charcode == 'UTF8') |
|
| 67 | - return true; |
|
| 68 | - else |
|
| 69 | - return false; |
|
| 67 | + if ($charcode == 'UTF8') { |
|
| 68 | + return true; |
|
| 69 | + } else { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 70 | 72 | }, |
| 71 | 73 | 'utf8_version' => '8.0', |
| 72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
| 76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
| 77 | 79 | |
| 78 | 80 | // Is it reserved? |
| 79 | - if ($value == 'pg_') |
|
| 80 | - return $txt['error_db_prefix_reserved']; |
|
| 81 | + if ($value == 'pg_') { |
|
| 82 | + return $txt['error_db_prefix_reserved']; |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | // Is the prefix numeric? |
| 83 | - if (preg_match('~^\d~', $value)) |
|
| 84 | - return $txt['error_db_prefix_numeric']; |
|
| 86 | + if (preg_match('~^\d~', $value)) { |
|
| 87 | + return $txt['error_db_prefix_numeric']; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | 90 | return true; |
| 87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
| 128 | 132 | $incontext['skip'] = false; |
| 129 | 133 | |
| 130 | 134 | // Call the step and if it returns false that means pause! |
| 131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 132 | - break; |
|
| 133 | - elseif (function_exists($step[2])) |
|
| 134 | - $incontext['current_step']++; |
|
| 135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 136 | + break; |
|
| 137 | + } elseif (function_exists($step[2])) { |
|
| 138 | + $incontext['current_step']++; |
|
| 139 | + } |
|
| 135 | 140 | |
| 136 | 141 | // No warnings pass on. |
| 137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
| 147 | 152 | global $databases; |
| 148 | 153 | |
| 149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
| 150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
| 151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
| 156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 157 | + } |
|
| 152 | 158 | |
| 153 | 159 | // Enable error reporting for fatal errors. |
| 154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
| 164 | 170 | { |
| 165 | 171 | ob_start(); |
| 166 | 172 | |
| 167 | - if (ini_get('session.save_handler') == 'user') |
|
| 168 | - @ini_set('session.save_handler', 'files'); |
|
| 169 | - if (function_exists('session_start')) |
|
| 170 | - @session_start(); |
|
| 171 | - } |
|
| 172 | - else |
|
| 173 | + if (ini_get('session.save_handler') == 'user') { |
|
| 174 | + @ini_set('session.save_handler', 'files'); |
|
| 175 | + } |
|
| 176 | + if (function_exists('session_start')) { |
|
| 177 | + @session_start(); |
|
| 178 | + } |
|
| 179 | + } else |
|
| 173 | 180 | { |
| 174 | 181 | ob_start('ob_gzhandler'); |
| 175 | 182 | |
| 176 | - if (ini_get('session.save_handler') == 'user') |
|
| 177 | - @ini_set('session.save_handler', 'files'); |
|
| 183 | + if (ini_get('session.save_handler') == 'user') { |
|
| 184 | + @ini_set('session.save_handler', 'files'); |
|
| 185 | + } |
|
| 178 | 186 | session_start(); |
| 179 | 187 | |
| 180 | - if (!headers_sent()) |
|
| 181 | - echo '<!DOCTYPE html> |
|
| 188 | + if (!headers_sent()) { |
|
| 189 | + echo '<!DOCTYPE html> |
|
| 182 | 190 | <html> |
| 183 | 191 | <head> |
| 184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
| 187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
| 188 | 196 | </body> |
| 189 | 197 | </html>'; |
| 198 | + } |
|
| 190 | 199 | exit; |
| 191 | 200 | } |
| 192 | 201 | |
| 193 | 202 | // Add slashes, as long as they aren't already being added. |
| 194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
| 195 | - foreach ($_POST as $k => $v) |
|
| 203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
| 204 | + foreach ($_POST as $k => $v) |
|
| 196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
| 197 | 206 | $_POST[$k] = addslashes($v); |
| 207 | + } |
|
| 198 | 208 | |
| 199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
| 200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
| 215 | 225 | $ftp->close(); |
| 216 | 226 | |
| 217 | 227 | unset($_SESSION['installer_temp_ftp']); |
| 218 | - } |
|
| 219 | - else |
|
| 228 | + } else |
|
| 220 | 229 | { |
| 221 | 230 | @unlink(__FILE__); |
| 222 | 231 | |
@@ -237,10 +246,11 @@ discard block |
||
| 237 | 246 | { |
| 238 | 247 | // Get PHP's default timezone, if set |
| 239 | 248 | $ini_tz = ini_get('date.timezone'); |
| 240 | - if (!empty($ini_tz)) |
|
| 241 | - $timezone_id = $ini_tz; |
|
| 242 | - else |
|
| 243 | - $timezone_id = ''; |
|
| 249 | + if (!empty($ini_tz)) { |
|
| 250 | + $timezone_id = $ini_tz; |
|
| 251 | + } else { |
|
| 252 | + $timezone_id = ''; |
|
| 253 | + } |
|
| 244 | 254 | |
| 245 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 246 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -270,8 +280,9 @@ discard block |
||
| 270 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 271 | 281 | while ($entry = $dir->read()) |
| 272 | 282 | { |
| 273 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 274 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 283 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 284 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 285 | + } |
|
| 275 | 286 | } |
| 276 | 287 | $dir->close(); |
| 277 | 288 | } |
@@ -306,10 +317,11 @@ discard block |
||
| 306 | 317 | } |
| 307 | 318 | |
| 308 | 319 | // Override the language file? |
| 309 | - if (isset($_GET['lang_file'])) |
|
| 310 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 311 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 312 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 320 | + if (isset($_GET['lang_file'])) { |
|
| 321 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 322 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 323 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 324 | + } |
|
| 313 | 325 | |
| 314 | 326 | // Make sure it exists, if it doesn't reset it. |
| 315 | 327 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -318,8 +330,9 @@ discard block |
||
| 318 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 319 | 331 | |
| 320 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 321 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 322 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 333 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 334 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 335 | + } |
|
| 323 | 336 | } |
| 324 | 337 | |
| 325 | 338 | // And now include the actual language file itself. |
@@ -332,15 +345,18 @@ discard block |
||
| 332 | 345 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
| 333 | 346 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
| 334 | 347 | |
| 335 | - if (empty($sourcedir)) |
|
| 336 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 348 | + if (empty($sourcedir)) { |
|
| 349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 350 | + } |
|
| 337 | 351 | |
| 338 | 352 | // Need this to check whether we need the database password. |
| 339 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
| 340 | - if (!defined('SMF')) |
|
| 341 | - define('SMF', 1); |
|
| 342 | - if (empty($smcFunc)) |
|
| 343 | - $smcFunc = array(); |
|
| 354 | + if (!defined('SMF')) { |
|
| 355 | + define('SMF', 1); |
|
| 356 | + } |
|
| 357 | + if (empty($smcFunc)) { |
|
| 358 | + $smcFunc = array(); |
|
| 359 | + } |
|
| 344 | 360 | |
| 345 | 361 | $modSettings['disableQueryCheck'] = true; |
| 346 | 362 | |
@@ -348,8 +364,9 @@ discard block |
||
| 348 | 364 | if (!$db_connection) |
| 349 | 365 | { |
| 350 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 351 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 352 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 369 | + } |
|
| 353 | 370 | |
| 354 | 371 | $db_options = array('persist' => $db_persist); |
| 355 | 372 | $port = ''; |
@@ -360,19 +377,20 @@ discard block |
||
| 360 | 377 | if ($db_type == 'mysql') |
| 361 | 378 | { |
| 362 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
| 363 | - } |
|
| 364 | - elseif ($db_type == 'postgresql') |
|
| 380 | + } elseif ($db_type == 'postgresql') |
|
| 365 | 381 | { |
| 366 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
| 367 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
| 368 | 384 | } |
| 369 | 385 | } |
| 370 | 386 | |
| 371 | - if (!empty($port)) |
|
| 372 | - $db_options['port'] = $port; |
|
| 387 | + if (!empty($port)) { |
|
| 388 | + $db_options['port'] = $port; |
|
| 389 | + } |
|
| 373 | 390 | |
| 374 | - if (!$db_connection) |
|
| 375 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 391 | + if (!$db_connection) { |
|
| 392 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 393 | + } |
|
| 376 | 394 | } |
| 377 | 395 | } |
| 378 | 396 | |
@@ -400,8 +418,9 @@ discard block |
||
| 400 | 418 | // @todo REMOVE THIS!! |
| 401 | 419 | else |
| 402 | 420 | { |
| 403 | - if (function_exists('doStep' . $_GET['step'])) |
|
| 404 | - call_user_func('doStep' . $_GET['step']); |
|
| 421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
| 422 | + call_user_func('doStep' . $_GET['step']); |
|
| 423 | + } |
|
| 405 | 424 | } |
| 406 | 425 | // Show the footer. |
| 407 | 426 | template_install_below(); |
@@ -419,8 +438,9 @@ discard block |
||
| 419 | 438 | $incontext['sub_template'] = 'welcome_message'; |
| 420 | 439 | |
| 421 | 440 | // Done the submission? |
| 422 | - if (isset($_POST['contbutt'])) |
|
| 423 | - return true; |
|
| 441 | + if (isset($_POST['contbutt'])) { |
|
| 442 | + return true; |
|
| 443 | + } |
|
| 424 | 444 | |
| 425 | 445 | // See if we think they have already installed it? |
| 426 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -428,14 +448,17 @@ discard block |
||
| 428 | 448 | $probably_installed = 0; |
| 429 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
| 430 | 450 | { |
| 431 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
| 432 | - $probably_installed++; |
|
| 433 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
| 434 | - $probably_installed++; |
|
| 451 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
| 452 | + $probably_installed++; |
|
| 453 | + } |
|
| 454 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
| 455 | + $probably_installed++; |
|
| 456 | + } |
|
| 435 | 457 | } |
| 436 | 458 | |
| 437 | - if ($probably_installed == 2) |
|
| 438 | - $incontext['warning'] = $txt['error_already_installed']; |
|
| 459 | + if ($probably_installed == 2) { |
|
| 460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
| 461 | + } |
|
| 439 | 462 | } |
| 440 | 463 | |
| 441 | 464 | // Is some database support even compiled in? |
@@ -450,45 +473,54 @@ discard block |
||
| 450 | 473 | $databases[$key]['supported'] = false; |
| 451 | 474 | $notFoundSQLFile = true; |
| 452 | 475 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
| 476 | + } else { |
|
| 477 | + $incontext['supported_databases'][] = $db; |
|
| 453 | 478 | } |
| 454 | - else |
|
| 455 | - $incontext['supported_databases'][] = $db; |
|
| 456 | 479 | } |
| 457 | 480 | } |
| 458 | 481 | |
| 459 | 482 | // Check the PHP version. |
| 460 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
| 461 | - $error = 'error_php_too_low'; |
|
| 483 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
| 484 | + $error = 'error_php_too_low'; |
|
| 485 | + } |
|
| 462 | 486 | // Make sure we have a supported database |
| 463 | - elseif (empty($incontext['supported_databases'])) |
|
| 464 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 487 | + elseif (empty($incontext['supported_databases'])) { |
|
| 488 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 489 | + } |
|
| 465 | 490 | // How about session support? Some crazy sysadmin remove it? |
| 466 | - elseif (!function_exists('session_start')) |
|
| 467 | - $error = 'error_session_missing'; |
|
| 491 | + elseif (!function_exists('session_start')) { |
|
| 492 | + $error = 'error_session_missing'; |
|
| 493 | + } |
|
| 468 | 494 | // Make sure they uploaded all the files. |
| 469 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
| 470 | - $error = 'error_missing_files'; |
|
| 495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
| 496 | + $error = 'error_missing_files'; |
|
| 497 | + } |
|
| 471 | 498 | // Very simple check on the session.save_path for Windows. |
| 472 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
| 473 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
| 474 | - $error = 'error_session_save_path'; |
|
| 500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
| 501 | + $error = 'error_session_save_path'; |
|
| 502 | + } |
|
| 475 | 503 | |
| 476 | 504 | // Since each of the three messages would look the same, anyway... |
| 477 | - if (isset($error)) |
|
| 478 | - $incontext['error'] = $txt[$error]; |
|
| 505 | + if (isset($error)) { |
|
| 506 | + $incontext['error'] = $txt[$error]; |
|
| 507 | + } |
|
| 479 | 508 | |
| 480 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
| 481 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
| 482 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 510 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
| 511 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 512 | + } |
|
| 483 | 513 | |
| 484 | 514 | // Confirm mbstring is loaded... |
| 485 | - if (!extension_loaded('mbstring')) |
|
| 486 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
| 515 | + if (!extension_loaded('mbstring')) { |
|
| 516 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
| 517 | + } |
|
| 487 | 518 | |
| 488 | 519 | // Check for https stream support. |
| 489 | 520 | $supported_streams = stream_get_wrappers(); |
| 490 | - if (!in_array('https', $supported_streams)) |
|
| 491 | - $incontext['warning'] = $txt['install_no_https']; |
|
| 521 | + if (!in_array('https', $supported_streams)) { |
|
| 522 | + $incontext['warning'] = $txt['install_no_https']; |
|
| 523 | + } |
|
| 492 | 524 | |
| 493 | 525 | return false; |
| 494 | 526 | } |
@@ -513,12 +545,14 @@ discard block |
||
| 513 | 545 | 'Settings_bak.php', |
| 514 | 546 | ); |
| 515 | 547 | |
| 516 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
| 517 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 548 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
| 549 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 550 | + } |
|
| 518 | 551 | |
| 519 | 552 | // With mod_security installed, we could attempt to fix it with .htaccess. |
| 520 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
| 521 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 553 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
| 554 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 555 | + } |
|
| 522 | 556 | |
| 523 | 557 | $failed_files = array(); |
| 524 | 558 | |
@@ -530,20 +564,23 @@ discard block |
||
| 530 | 564 | foreach ($writable_files as $file) |
| 531 | 565 | { |
| 532 | 566 | // Some files won't exist, try to address up front |
| 533 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
| 534 | - @touch(dirname(__FILE__) . '/' . $file); |
|
| 567 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
| 568 | + @touch(dirname(__FILE__) . '/' . $file); |
|
| 569 | + } |
|
| 535 | 570 | // NOW do the writable check... |
| 536 | 571 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 537 | 572 | { |
| 538 | 573 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
| 539 | 574 | |
| 540 | 575 | // Well, 755 hopefully worked... if not, try 777. |
| 541 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
| 542 | - $failed_files[] = $file; |
|
| 576 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
| 577 | + $failed_files[] = $file; |
|
| 578 | + } |
|
| 543 | 579 | } |
| 544 | 580 | } |
| 545 | - foreach ($extra_files as $file) |
|
| 546 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 581 | + foreach ($extra_files as $file) { |
|
| 582 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 583 | + } |
|
| 547 | 584 | } |
| 548 | 585 | // Windows is trickier. Let's try opening for r+... |
| 549 | 586 | else |
@@ -553,30 +590,35 @@ discard block |
||
| 553 | 590 | foreach ($writable_files as $file) |
| 554 | 591 | { |
| 555 | 592 | // Folders can't be opened for write... but the index.php in them can ;) |
| 556 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
| 557 | - $file .= '/index.php'; |
|
| 593 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
| 594 | + $file .= '/index.php'; |
|
| 595 | + } |
|
| 558 | 596 | |
| 559 | 597 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 560 | 598 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
| 561 | 599 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
| 562 | 600 | |
| 563 | 601 | // Hmm, okay, try just for write in that case... |
| 564 | - if (!is_resource($fp)) |
|
| 565 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 602 | + if (!is_resource($fp)) { |
|
| 603 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 604 | + } |
|
| 566 | 605 | |
| 567 | - if (!is_resource($fp)) |
|
| 568 | - $failed_files[] = $file; |
|
| 606 | + if (!is_resource($fp)) { |
|
| 607 | + $failed_files[] = $file; |
|
| 608 | + } |
|
| 569 | 609 | |
| 570 | 610 | @fclose($fp); |
| 571 | 611 | } |
| 572 | - foreach ($extra_files as $file) |
|
| 573 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 612 | + foreach ($extra_files as $file) { |
|
| 613 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 614 | + } |
|
| 574 | 615 | } |
| 575 | 616 | |
| 576 | 617 | $failure = count($failed_files) >= 1; |
| 577 | 618 | |
| 578 | - if (!isset($_SERVER)) |
|
| 579 | - return !$failure; |
|
| 619 | + if (!isset($_SERVER)) { |
|
| 620 | + return !$failure; |
|
| 621 | + } |
|
| 580 | 622 | |
| 581 | 623 | // Put the list into context. |
| 582 | 624 | $incontext['failed_files'] = $failed_files; |
@@ -624,19 +666,23 @@ discard block |
||
| 624 | 666 | |
| 625 | 667 | if (!isset($ftp) || $ftp->error !== false) |
| 626 | 668 | { |
| 627 | - if (!isset($ftp)) |
|
| 628 | - $ftp = new ftp_connection(null); |
|
| 669 | + if (!isset($ftp)) { |
|
| 670 | + $ftp = new ftp_connection(null); |
|
| 671 | + } |
|
| 629 | 672 | // Save the error so we can mess with listing... |
| 630 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
| 631 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 673 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
| 674 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 675 | + } |
|
| 632 | 676 | |
| 633 | 677 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 634 | 678 | |
| 635 | - if (empty($_POST['ftp_path']) && $found_path) |
|
| 636 | - $_POST['ftp_path'] = $detect_path; |
|
| 679 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
| 680 | + $_POST['ftp_path'] = $detect_path; |
|
| 681 | + } |
|
| 637 | 682 | |
| 638 | - if (!isset($_POST['ftp_username'])) |
|
| 639 | - $_POST['ftp_username'] = $username; |
|
| 683 | + if (!isset($_POST['ftp_username'])) { |
|
| 684 | + $_POST['ftp_username'] = $username; |
|
| 685 | + } |
|
| 640 | 686 | |
| 641 | 687 | // Set the username etc, into context. |
| 642 | 688 | $incontext['ftp'] = array( |
@@ -648,8 +694,7 @@ discard block |
||
| 648 | 694 | ); |
| 649 | 695 | |
| 650 | 696 | return false; |
| 651 | - } |
|
| 652 | - else |
|
| 697 | + } else |
|
| 653 | 698 | { |
| 654 | 699 | $_SESSION['installer_temp_ftp'] = array( |
| 655 | 700 | 'server' => $_POST['ftp_server'], |
@@ -663,10 +708,12 @@ discard block |
||
| 663 | 708 | |
| 664 | 709 | foreach ($failed_files as $file) |
| 665 | 710 | { |
| 666 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 667 | - $ftp->chmod($file, 0755); |
|
| 668 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 669 | - $ftp->chmod($file, 0777); |
|
| 711 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 712 | + $ftp->chmod($file, 0755); |
|
| 713 | + } |
|
| 714 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 715 | + $ftp->chmod($file, 0777); |
|
| 716 | + } |
|
| 670 | 717 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 671 | 718 | { |
| 672 | 719 | $failed_files_updated[] = $file; |
@@ -722,15 +769,17 @@ discard block |
||
| 722 | 769 | |
| 723 | 770 | if (!$foundOne) |
| 724 | 771 | { |
| 725 | - if (isset($db['default_host'])) |
|
| 726 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 772 | + if (isset($db['default_host'])) { |
|
| 773 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 774 | + } |
|
| 727 | 775 | if (isset($db['default_user'])) |
| 728 | 776 | { |
| 729 | 777 | $incontext['db']['user'] = ini_get($db['default_user']); |
| 730 | 778 | $incontext['db']['name'] = ini_get($db['default_user']); |
| 731 | 779 | } |
| 732 | - if (isset($db['default_password'])) |
|
| 733 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 780 | + if (isset($db['default_password'])) { |
|
| 781 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 782 | + } |
|
| 734 | 783 | |
| 735 | 784 | // For simplicity and less confusion, leave the port blank by default |
| 736 | 785 | $incontext['db']['port'] = ''; |
@@ -749,10 +798,10 @@ discard block |
||
| 749 | 798 | $incontext['db']['server'] = $_POST['db_server']; |
| 750 | 799 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
| 751 | 800 | |
| 752 | - if (!empty($_POST['db_port'])) |
|
| 753 | - $incontext['db']['port'] = $_POST['db_port']; |
|
| 754 | - } |
|
| 755 | - else |
|
| 801 | + if (!empty($_POST['db_port'])) { |
|
| 802 | + $incontext['db']['port'] = $_POST['db_port']; |
|
| 803 | + } |
|
| 804 | + } else |
|
| 756 | 805 | { |
| 757 | 806 | $incontext['db']['prefix'] = 'smf_'; |
| 758 | 807 | } |
@@ -788,10 +837,11 @@ discard block |
||
| 788 | 837 | if (!empty($_POST['db_port'])) |
| 789 | 838 | { |
| 790 | 839 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
| 791 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
| 792 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 793 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
| 794 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 840 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
| 841 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 842 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
| 843 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 844 | + } |
|
| 795 | 845 | } |
| 796 | 846 | |
| 797 | 847 | // God I hope it saved! |
@@ -804,8 +854,9 @@ discard block |
||
| 804 | 854 | // Make sure it works. |
| 805 | 855 | require(dirname(__FILE__) . '/Settings.php'); |
| 806 | 856 | |
| 807 | - if (empty($sourcedir)) |
|
| 808 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 857 | + if (empty($sourcedir)) { |
|
| 858 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 859 | + } |
|
| 809 | 860 | |
| 810 | 861 | // Better find the database file! |
| 811 | 862 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -815,18 +866,21 @@ discard block |
||
| 815 | 866 | } |
| 816 | 867 | |
| 817 | 868 | // Now include it for database functions! |
| 818 | - if (!defined('SMF')) |
|
| 819 | - define('SMF', 1); |
|
| 869 | + if (!defined('SMF')) { |
|
| 870 | + define('SMF', 1); |
|
| 871 | + } |
|
| 820 | 872 | |
| 821 | 873 | $modSettings['disableQueryCheck'] = true; |
| 822 | - if (empty($smcFunc)) |
|
| 823 | - $smcFunc = array(); |
|
| 874 | + if (empty($smcFunc)) { |
|
| 875 | + $smcFunc = array(); |
|
| 876 | + } |
|
| 824 | 877 | |
| 825 | 878 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 826 | 879 | |
| 827 | 880 | // What - running PHP4? The shame! |
| 828 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 829 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 881 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 882 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 883 | + } |
|
| 830 | 884 | |
| 831 | 885 | // Attempt a connection. |
| 832 | 886 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -914,12 +968,14 @@ discard block |
||
| 914 | 968 | $incontext['page_title'] = $txt['install_settings']; |
| 915 | 969 | |
| 916 | 970 | // Let's see if we got the database type correct. |
| 917 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
| 918 | - $db_type = $_POST['db_type']; |
|
| 971 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
| 972 | + $db_type = $_POST['db_type']; |
|
| 973 | + } |
|
| 919 | 974 | |
| 920 | 975 | // Else we'd better be able to get the connection. |
| 921 | - else |
|
| 922 | - load_database(); |
|
| 976 | + else { |
|
| 977 | + load_database(); |
|
| 978 | + } |
|
| 923 | 979 | |
| 924 | 980 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
| 925 | 981 | |
@@ -956,18 +1012,21 @@ discard block |
||
| 956 | 1012 | // Submitting? |
| 957 | 1013 | if (isset($_POST['boardurl'])) |
| 958 | 1014 | { |
| 959 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 960 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 961 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 962 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 963 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 964 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1015 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1016 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1017 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1018 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1019 | + } |
|
| 1020 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1021 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1022 | + } |
|
| 965 | 1023 | |
| 966 | 1024 | //Make sure boardurl is aligned with ssl setting |
| 967 | - if (empty($_POST['force_ssl'])) |
|
| 968 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 969 | - else |
|
| 970 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1025 | + if (empty($_POST['force_ssl'])) { |
|
| 1026 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 1027 | + } else { |
|
| 1028 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1029 | + } |
|
| 971 | 1030 | |
| 972 | 1031 | // Save these variables. |
| 973 | 1032 | $vars = array( |
@@ -1006,10 +1065,10 @@ discard block |
||
| 1006 | 1065 | { |
| 1007 | 1066 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
| 1008 | 1067 | return false; |
| 1009 | - } |
|
| 1010 | - else |
|
| 1011 | - // Set the character set here. |
|
| 1068 | + } else { |
|
| 1069 | + // Set the character set here. |
|
| 1012 | 1070 | updateSettingsFile(array('db_character_set' => 'utf8')); |
| 1071 | + } |
|
| 1013 | 1072 | } |
| 1014 | 1073 | |
| 1015 | 1074 | // Good, skip on. |
@@ -1029,8 +1088,9 @@ discard block |
||
| 1029 | 1088 | $incontext['continue'] = 1; |
| 1030 | 1089 | |
| 1031 | 1090 | // Already done? |
| 1032 | - if (isset($_POST['pop_done'])) |
|
| 1033 | - return true; |
|
| 1091 | + if (isset($_POST['pop_done'])) { |
|
| 1092 | + return true; |
|
| 1093 | + } |
|
| 1034 | 1094 | |
| 1035 | 1095 | // Reload settings. |
| 1036 | 1096 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1048,8 +1108,9 @@ discard block |
||
| 1048 | 1108 | $modSettings = array(); |
| 1049 | 1109 | if ($result !== false) |
| 1050 | 1110 | { |
| 1051 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1052 | - $modSettings[$row['variable']] = $row['value']; |
|
| 1111 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1112 | + $modSettings[$row['variable']] = $row['value']; |
|
| 1113 | + } |
|
| 1053 | 1114 | $smcFunc['db_free_result']($result); |
| 1054 | 1115 | |
| 1055 | 1116 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1062,20 +1123,22 @@ discard block |
||
| 1062 | 1123 | $modSettings['disableQueryCheck'] = true; |
| 1063 | 1124 | |
| 1064 | 1125 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
| 1065 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
| 1066 | - $smcFunc['db_query']('', ' |
|
| 1126 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1127 | + $smcFunc['db_query']('', ' |
|
| 1067 | 1128 | SET NAMES {string:utf8}', |
| 1068 | 1129 | array( |
| 1069 | 1130 | 'db_error_skip' => true, |
| 1070 | 1131 | 'utf8' => 'utf8', |
| 1071 | 1132 | ) |
| 1072 | 1133 | ); |
| 1134 | + } |
|
| 1073 | 1135 | |
| 1074 | 1136 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
| 1075 | - if (substr(__DIR__, -1) == '\\') |
|
| 1076 | - $attachdir = __DIR__ . 'attachments'; |
|
| 1077 | - else |
|
| 1078 | - $attachdir = __DIR__ . '/attachments'; |
|
| 1137 | + if (substr(__DIR__, -1) == '\\') { |
|
| 1138 | + $attachdir = __DIR__ . 'attachments'; |
|
| 1139 | + } else { |
|
| 1140 | + $attachdir = __DIR__ . '/attachments'; |
|
| 1141 | + } |
|
| 1079 | 1142 | |
| 1080 | 1143 | $replaces = array( |
| 1081 | 1144 | '{$db_prefix}' => $db_prefix, |
@@ -1092,8 +1155,9 @@ discard block |
||
| 1092 | 1155 | |
| 1093 | 1156 | foreach ($txt as $key => $value) |
| 1094 | 1157 | { |
| 1095 | - if (substr($key, 0, 8) == 'default_') |
|
| 1096 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1158 | + if (substr($key, 0, 8) == 'default_') { |
|
| 1159 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1160 | + } |
|
| 1097 | 1161 | } |
| 1098 | 1162 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
| 1099 | 1163 | |
@@ -1108,8 +1172,9 @@ discard block |
||
| 1108 | 1172 | |
| 1109 | 1173 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
| 1110 | 1174 | { |
| 1111 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
| 1112 | - $engines[] = $row['Engine']; |
|
| 1175 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
| 1176 | + $engines[] = $row['Engine']; |
|
| 1177 | + } |
|
| 1113 | 1178 | } |
| 1114 | 1179 | |
| 1115 | 1180 | // Done with this now |
@@ -1133,8 +1198,7 @@ discard block |
||
| 1133 | 1198 | $replaces['START TRANSACTION;'] = ''; |
| 1134 | 1199 | $replaces['COMMIT;'] = ''; |
| 1135 | 1200 | } |
| 1136 | - } |
|
| 1137 | - else |
|
| 1201 | + } else |
|
| 1138 | 1202 | { |
| 1139 | 1203 | $has_innodb = false; |
| 1140 | 1204 | } |
@@ -1156,21 +1220,24 @@ discard block |
||
| 1156 | 1220 | foreach ($sql_lines as $count => $line) |
| 1157 | 1221 | { |
| 1158 | 1222 | // No comments allowed! |
| 1159 | - if (substr(trim($line), 0, 1) != '#') |
|
| 1160 | - $current_statement .= "\n" . rtrim($line); |
|
| 1223 | + if (substr(trim($line), 0, 1) != '#') { |
|
| 1224 | + $current_statement .= "\n" . rtrim($line); |
|
| 1225 | + } |
|
| 1161 | 1226 | |
| 1162 | 1227 | // Is this the end of the query string? |
| 1163 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
| 1164 | - continue; |
|
| 1228 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
| 1229 | + continue; |
|
| 1230 | + } |
|
| 1165 | 1231 | |
| 1166 | 1232 | // Does this table already exist? If so, don't insert more data into it! |
| 1167 | 1233 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
| 1168 | 1234 | { |
| 1169 | 1235 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1170 | - if (!empty($matches[0])) |
|
| 1171 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1172 | - else |
|
| 1173 | - $incontext['sql_results']['insert_dups']++; |
|
| 1236 | + if (!empty($matches[0])) { |
|
| 1237 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1238 | + } else { |
|
| 1239 | + $incontext['sql_results']['insert_dups']++; |
|
| 1240 | + } |
|
| 1174 | 1241 | |
| 1175 | 1242 | $current_statement = ''; |
| 1176 | 1243 | continue; |
@@ -1179,8 +1246,9 @@ discard block |
||
| 1179 | 1246 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
| 1180 | 1247 | { |
| 1181 | 1248 | // Use the appropriate function based on the DB type |
| 1182 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
| 1183 | - $db_errorno = $db_type . '_errno'; |
|
| 1249 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
| 1250 | + $db_errorno = $db_type . '_errno'; |
|
| 1251 | + } |
|
| 1184 | 1252 | |
| 1185 | 1253 | // Error 1050: Table already exists! |
| 1186 | 1254 | // @todo Needs to be made better! |
@@ -1195,18 +1263,18 @@ discard block |
||
| 1195 | 1263 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
| 1196 | 1264 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
| 1197 | 1265 | } |
| 1198 | - } |
|
| 1199 | - else |
|
| 1266 | + } else |
|
| 1200 | 1267 | { |
| 1201 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1202 | - $incontext['sql_results']['tables']++; |
|
| 1203 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1268 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
| 1269 | + $incontext['sql_results']['tables']++; |
|
| 1270 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1204 | 1271 | { |
| 1205 | 1272 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1206 | - if (!empty($matches[0])) |
|
| 1207 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1208 | - else |
|
| 1209 | - $incontext['sql_results']['inserts']++; |
|
| 1273 | + if (!empty($matches[0])) { |
|
| 1274 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1275 | + } else { |
|
| 1276 | + $incontext['sql_results']['inserts']++; |
|
| 1277 | + } |
|
| 1210 | 1278 | } |
| 1211 | 1279 | } |
| 1212 | 1280 | |
@@ -1219,15 +1287,17 @@ discard block |
||
| 1219 | 1287 | // Sort out the context for the SQL. |
| 1220 | 1288 | foreach ($incontext['sql_results'] as $key => $number) |
| 1221 | 1289 | { |
| 1222 | - if ($number == 0) |
|
| 1223 | - unset($incontext['sql_results'][$key]); |
|
| 1224 | - else |
|
| 1225 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1290 | + if ($number == 0) { |
|
| 1291 | + unset($incontext['sql_results'][$key]); |
|
| 1292 | + } else { |
|
| 1293 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1294 | + } |
|
| 1226 | 1295 | } |
| 1227 | 1296 | |
| 1228 | 1297 | // Make sure UTF will be used globally. |
| 1229 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
| 1230 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1298 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
| 1299 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1300 | + } |
|
| 1231 | 1301 | |
| 1232 | 1302 | // Maybe we can auto-detect better cookie settings? |
| 1233 | 1303 | preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches); |
@@ -1238,16 +1308,20 @@ discard block |
||
| 1238 | 1308 | $globalCookies = false; |
| 1239 | 1309 | |
| 1240 | 1310 | // Okay... let's see. Using a subdomain other than www.? (not a perfect check.) |
| 1241 | - if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) |
|
| 1242 | - $globalCookies = true; |
|
| 1311 | + if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) { |
|
| 1312 | + $globalCookies = true; |
|
| 1313 | + } |
|
| 1243 | 1314 | // If there's a / in the middle of the path, or it starts with ~... we want local. |
| 1244 | - if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) |
|
| 1245 | - $localCookies = true; |
|
| 1315 | + if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) { |
|
| 1316 | + $localCookies = true; |
|
| 1317 | + } |
|
| 1246 | 1318 | |
| 1247 | - if ($globalCookies) |
|
| 1248 | - $newSettings[] = array('globalCookies', '1'); |
|
| 1249 | - if ($localCookies) |
|
| 1250 | - $newSettings[] = array('localCookies', '1'); |
|
| 1319 | + if ($globalCookies) { |
|
| 1320 | + $newSettings[] = array('globalCookies', '1'); |
|
| 1321 | + } |
|
| 1322 | + if ($localCookies) { |
|
| 1323 | + $newSettings[] = array('localCookies', '1'); |
|
| 1324 | + } |
|
| 1251 | 1325 | } |
| 1252 | 1326 | |
| 1253 | 1327 | // Are we allowing stat collection? |
@@ -1265,16 +1339,17 @@ discard block |
||
| 1265 | 1339 | fwrite($fp, $out); |
| 1266 | 1340 | |
| 1267 | 1341 | $return_data = ''; |
| 1268 | - while (!feof($fp)) |
|
| 1269 | - $return_data .= fgets($fp, 128); |
|
| 1342 | + while (!feof($fp)) { |
|
| 1343 | + $return_data .= fgets($fp, 128); |
|
| 1344 | + } |
|
| 1270 | 1345 | |
| 1271 | 1346 | fclose($fp); |
| 1272 | 1347 | |
| 1273 | 1348 | // Get the unique site ID. |
| 1274 | 1349 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1275 | 1350 | |
| 1276 | - if (!empty($ID[1])) |
|
| 1277 | - $smcFunc['db_insert']('replace', |
|
| 1351 | + if (!empty($ID[1])) { |
|
| 1352 | + $smcFunc['db_insert']('replace', |
|
| 1278 | 1353 | $db_prefix . 'settings', |
| 1279 | 1354 | array('variable' => 'string', 'value' => 'string'), |
| 1280 | 1355 | array( |
@@ -1283,11 +1358,12 @@ discard block |
||
| 1283 | 1358 | ), |
| 1284 | 1359 | array('variable') |
| 1285 | 1360 | ); |
| 1361 | + } |
|
| 1286 | 1362 | } |
| 1287 | 1363 | } |
| 1288 | 1364 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1289 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1290 | - $smcFunc['db_query']('', ' |
|
| 1365 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1366 | + $smcFunc['db_query']('', ' |
|
| 1291 | 1367 | DELETE FROM {db_prefix}settings |
| 1292 | 1368 | WHERE variable = {string:enable_sm_stats}', |
| 1293 | 1369 | array( |
@@ -1295,20 +1371,23 @@ discard block |
||
| 1295 | 1371 | 'db_error_skip' => true, |
| 1296 | 1372 | ) |
| 1297 | 1373 | ); |
| 1374 | + } |
|
| 1298 | 1375 | |
| 1299 | 1376 | // Are we enabling SSL? |
| 1300 | - if (!empty($_POST['force_ssl'])) |
|
| 1301 | - $newSettings[] = array('force_ssl', 2); |
|
| 1377 | + if (!empty($_POST['force_ssl'])) { |
|
| 1378 | + $newSettings[] = array('force_ssl', 2); |
|
| 1379 | + } |
|
| 1302 | 1380 | |
| 1303 | 1381 | // Setting a timezone is required. |
| 1304 | 1382 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
| 1305 | 1383 | { |
| 1306 | 1384 | // Get PHP's default timezone, if set |
| 1307 | 1385 | $ini_tz = ini_get('date.timezone'); |
| 1308 | - if (!empty($ini_tz)) |
|
| 1309 | - $timezone_id = $ini_tz; |
|
| 1310 | - else |
|
| 1311 | - $timezone_id = ''; |
|
| 1386 | + if (!empty($ini_tz)) { |
|
| 1387 | + $timezone_id = $ini_tz; |
|
| 1388 | + } else { |
|
| 1389 | + $timezone_id = ''; |
|
| 1390 | + } |
|
| 1312 | 1391 | |
| 1313 | 1392 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 1314 | 1393 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1317,8 +1396,9 @@ discard block |
||
| 1317 | 1396 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
| 1318 | 1397 | } |
| 1319 | 1398 | |
| 1320 | - if (date_default_timezone_set($timezone_id)) |
|
| 1321 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1399 | + if (date_default_timezone_set($timezone_id)) { |
|
| 1400 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1401 | + } |
|
| 1322 | 1402 | } |
| 1323 | 1403 | |
| 1324 | 1404 | if (!empty($newSettings)) |
@@ -1349,16 +1429,18 @@ discard block |
||
| 1349 | 1429 | } |
| 1350 | 1430 | |
| 1351 | 1431 | // MySQL specific stuff |
| 1352 | - if (substr($db_type, 0, 5) != 'mysql') |
|
| 1353 | - return false; |
|
| 1432 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
| 1433 | + return false; |
|
| 1434 | + } |
|
| 1354 | 1435 | |
| 1355 | 1436 | // Find database user privileges. |
| 1356 | 1437 | $privs = array(); |
| 1357 | 1438 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
| 1358 | 1439 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
| 1359 | 1440 | { |
| 1360 | - if ($row['Privilege'] == 'Alter') |
|
| 1361 | - $privs[] = $row['Privilege']; |
|
| 1441 | + if ($row['Privilege'] == 'Alter') { |
|
| 1442 | + $privs[] = $row['Privilege']; |
|
| 1443 | + } |
|
| 1362 | 1444 | } |
| 1363 | 1445 | $smcFunc['db_free_result']($get_privs); |
| 1364 | 1446 | |
@@ -1388,8 +1470,9 @@ discard block |
||
| 1388 | 1470 | $incontext['continue'] = 1; |
| 1389 | 1471 | |
| 1390 | 1472 | // Skipping? |
| 1391 | - if (!empty($_POST['skip'])) |
|
| 1392 | - return true; |
|
| 1473 | + if (!empty($_POST['skip'])) { |
|
| 1474 | + return true; |
|
| 1475 | + } |
|
| 1393 | 1476 | |
| 1394 | 1477 | // Need this to check whether we need the database password. |
| 1395 | 1478 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1406,18 +1489,22 @@ discard block |
||
| 1406 | 1489 | // We need this to properly hash the password for Admin |
| 1407 | 1490 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
| 1408 | 1491 | global $sourcedir; |
| 1409 | - if (function_exists('mb_strtolower')) |
|
| 1410 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1492 | + if (function_exists('mb_strtolower')) { |
|
| 1493 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1494 | + } |
|
| 1411 | 1495 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1412 | 1496 | return utf8_strtolower($string); |
| 1413 | 1497 | }; |
| 1414 | 1498 | |
| 1415 | - if (!isset($_POST['username'])) |
|
| 1416 | - $_POST['username'] = ''; |
|
| 1417 | - if (!isset($_POST['email'])) |
|
| 1418 | - $_POST['email'] = ''; |
|
| 1419 | - if (!isset($_POST['server_email'])) |
|
| 1420 | - $_POST['server_email'] = ''; |
|
| 1499 | + if (!isset($_POST['username'])) { |
|
| 1500 | + $_POST['username'] = ''; |
|
| 1501 | + } |
|
| 1502 | + if (!isset($_POST['email'])) { |
|
| 1503 | + $_POST['email'] = ''; |
|
| 1504 | + } |
|
| 1505 | + if (!isset($_POST['server_email'])) { |
|
| 1506 | + $_POST['server_email'] = ''; |
|
| 1507 | + } |
|
| 1421 | 1508 | |
| 1422 | 1509 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
| 1423 | 1510 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1436,8 +1523,9 @@ discard block |
||
| 1436 | 1523 | 'admin_group' => 1, |
| 1437 | 1524 | ) |
| 1438 | 1525 | ); |
| 1439 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1440 | - $incontext['skip'] = 1; |
|
| 1526 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1527 | + $incontext['skip'] = 1; |
|
| 1528 | + } |
|
| 1441 | 1529 | $smcFunc['db_free_result']($request); |
| 1442 | 1530 | |
| 1443 | 1531 | // Trying to create an account? |
@@ -1468,8 +1556,9 @@ discard block |
||
| 1468 | 1556 | } |
| 1469 | 1557 | |
| 1470 | 1558 | // Update the webmaster's email? |
| 1471 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
| 1472 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1559 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
| 1560 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1561 | + } |
|
| 1473 | 1562 | |
| 1474 | 1563 | // Work out whether we're going to have dodgy characters and remove them. |
| 1475 | 1564 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1492,32 +1581,27 @@ discard block |
||
| 1492 | 1581 | $smcFunc['db_free_result']($result); |
| 1493 | 1582 | |
| 1494 | 1583 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
| 1495 | - } |
|
| 1496 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1584 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1497 | 1585 | { |
| 1498 | 1586 | // Try the previous step again. |
| 1499 | 1587 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
| 1500 | 1588 | return false; |
| 1501 | - } |
|
| 1502 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1589 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1503 | 1590 | { |
| 1504 | 1591 | // Try the previous step again. |
| 1505 | 1592 | $incontext['error'] = $txt['error_invalid_characters_username']; |
| 1506 | 1593 | return false; |
| 1507 | - } |
|
| 1508 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1594 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1509 | 1595 | { |
| 1510 | 1596 | // One step back, this time fill out a proper admin email address. |
| 1511 | 1597 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
| 1512 | 1598 | return false; |
| 1513 | - } |
|
| 1514 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1599 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1515 | 1600 | { |
| 1516 | 1601 | // One step back, this time fill out a proper admin email address. |
| 1517 | 1602 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
| 1518 | 1603 | return false; |
| 1519 | - } |
|
| 1520 | - elseif ($_POST['username'] != '') |
|
| 1604 | + } elseif ($_POST['username'] != '') |
|
| 1521 | 1605 | { |
| 1522 | 1606 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
| 1523 | 1607 | |
@@ -1585,17 +1669,19 @@ discard block |
||
| 1585 | 1669 | reloadSettings(); |
| 1586 | 1670 | |
| 1587 | 1671 | // Bring a warning over. |
| 1588 | - if (!empty($incontext['account_existed'])) |
|
| 1589 | - $incontext['warning'] = $incontext['account_existed']; |
|
| 1672 | + if (!empty($incontext['account_existed'])) { |
|
| 1673 | + $incontext['warning'] = $incontext['account_existed']; |
|
| 1674 | + } |
|
| 1590 | 1675 | |
| 1591 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
| 1592 | - $smcFunc['db_query']('', ' |
|
| 1676 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1677 | + $smcFunc['db_query']('', ' |
|
| 1593 | 1678 | SET NAMES {string:db_character_set}', |
| 1594 | 1679 | array( |
| 1595 | 1680 | 'db_character_set' => $db_character_set, |
| 1596 | 1681 | 'db_error_skip' => true, |
| 1597 | 1682 | ) |
| 1598 | 1683 | ); |
| 1684 | + } |
|
| 1599 | 1685 | |
| 1600 | 1686 | // As track stats is by default enabled let's add some activity. |
| 1601 | 1687 | $smcFunc['db_insert']('ignore', |
@@ -1616,14 +1702,16 @@ discard block |
||
| 1616 | 1702 | // Only proceed if we can load the data. |
| 1617 | 1703 | if ($request) |
| 1618 | 1704 | { |
| 1619 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1620 | - $modSettings[$row[0]] = $row[1]; |
|
| 1705 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1706 | + $modSettings[$row[0]] = $row[1]; |
|
| 1707 | + } |
|
| 1621 | 1708 | $smcFunc['db_free_result']($request); |
| 1622 | 1709 | } |
| 1623 | 1710 | |
| 1624 | 1711 | // Automatically log them in ;) |
| 1625 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
| 1626 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1712 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
| 1713 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1714 | + } |
|
| 1627 | 1715 | |
| 1628 | 1716 | $result = $smcFunc['db_query']('', ' |
| 1629 | 1717 | SELECT value |
@@ -1634,13 +1722,14 @@ discard block |
||
| 1634 | 1722 | 'db_error_skip' => true, |
| 1635 | 1723 | ) |
| 1636 | 1724 | ); |
| 1637 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1638 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1725 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1726 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1727 | + } |
|
| 1639 | 1728 | $smcFunc['db_free_result']($result); |
| 1640 | 1729 | |
| 1641 | - if (empty($db_sessions)) |
|
| 1642 | - $_SESSION['admin_time'] = time(); |
|
| 1643 | - else |
|
| 1730 | + if (empty($db_sessions)) { |
|
| 1731 | + $_SESSION['admin_time'] = time(); |
|
| 1732 | + } else |
|
| 1644 | 1733 | { |
| 1645 | 1734 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
| 1646 | 1735 | |
@@ -1664,8 +1753,9 @@ discard block |
||
| 1664 | 1753 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
| 1665 | 1754 | function($string){ |
| 1666 | 1755 | global $sourcedir; |
| 1667 | - if (function_exists('mb_strtolower')) |
|
| 1668 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1756 | + if (function_exists('mb_strtolower')) { |
|
| 1757 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1758 | + } |
|
| 1669 | 1759 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1670 | 1760 | return utf8_strtolower($string); |
| 1671 | 1761 | }; |
@@ -1681,8 +1771,9 @@ discard block |
||
| 1681 | 1771 | ) |
| 1682 | 1772 | ); |
| 1683 | 1773 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
| 1684 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1685 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1774 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1775 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1776 | + } |
|
| 1686 | 1777 | $smcFunc['db_free_result']($request); |
| 1687 | 1778 | |
| 1688 | 1779 | // Now is the perfect time to fetch the SM files. |
@@ -1701,8 +1792,9 @@ discard block |
||
| 1701 | 1792 | |
| 1702 | 1793 | // Check if we need some stupid MySQL fix. |
| 1703 | 1794 | $server_version = $smcFunc['db_server_info'](); |
| 1704 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1705 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1795 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1796 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1797 | + } |
|
| 1706 | 1798 | |
| 1707 | 1799 | // Some final context for the template. |
| 1708 | 1800 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1722,8 +1814,9 @@ discard block |
||
| 1722 | 1814 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
| 1723 | 1815 | |
| 1724 | 1816 | // @todo Do we just want to read the file in clean, and split it this way always? |
| 1725 | - if (count($settingsArray) == 1) |
|
| 1726 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1817 | + if (count($settingsArray) == 1) { |
|
| 1818 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1819 | + } |
|
| 1727 | 1820 | |
| 1728 | 1821 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1729 | 1822 | { |
@@ -1738,19 +1831,22 @@ discard block |
||
| 1738 | 1831 | continue; |
| 1739 | 1832 | } |
| 1740 | 1833 | |
| 1741 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
| 1742 | - $settingsArray[$i] = ''; |
|
| 1834 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
| 1835 | + $settingsArray[$i] = ''; |
|
| 1836 | + } |
|
| 1743 | 1837 | |
| 1744 | 1838 | // Don't trim or bother with it if it's not a variable. |
| 1745 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 1746 | - continue; |
|
| 1839 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 1840 | + continue; |
|
| 1841 | + } |
|
| 1747 | 1842 | |
| 1748 | 1843 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
| 1749 | 1844 | |
| 1750 | - foreach ($vars as $var => $val) |
|
| 1751 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1845 | + foreach ($vars as $var => $val) { |
|
| 1846 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1752 | 1847 | { |
| 1753 | 1848 | $comment = strstr($settingsArray[$i], '#'); |
| 1849 | + } |
|
| 1754 | 1850 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
| 1755 | 1851 | unset($vars[$var]); |
| 1756 | 1852 | } |
@@ -1760,36 +1856,41 @@ discard block |
||
| 1760 | 1856 | if (!empty($vars)) |
| 1761 | 1857 | { |
| 1762 | 1858 | $settingsArray[$i++] = ''; |
| 1763 | - foreach ($vars as $var => $val) |
|
| 1764 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1859 | + foreach ($vars as $var => $val) { |
|
| 1860 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1861 | + } |
|
| 1765 | 1862 | } |
| 1766 | 1863 | |
| 1767 | 1864 | // Blank out the file - done to fix a oddity with some servers. |
| 1768 | 1865 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
| 1769 | - if (!$fp) |
|
| 1770 | - return false; |
|
| 1866 | + if (!$fp) { |
|
| 1867 | + return false; |
|
| 1868 | + } |
|
| 1771 | 1869 | fclose($fp); |
| 1772 | 1870 | |
| 1773 | 1871 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
| 1774 | 1872 | |
| 1775 | 1873 | // Gotta have one of these ;) |
| 1776 | - if (trim($settingsArray[0]) != '<?php') |
|
| 1777 | - fwrite($fp, "<?php\n"); |
|
| 1874 | + if (trim($settingsArray[0]) != '<?php') { |
|
| 1875 | + fwrite($fp, "<?php\n"); |
|
| 1876 | + } |
|
| 1778 | 1877 | |
| 1779 | 1878 | $lines = count($settingsArray); |
| 1780 | 1879 | for ($i = 0; $i < $lines - 1; $i++) |
| 1781 | 1880 | { |
| 1782 | 1881 | // Don't just write a bunch of blank lines. |
| 1783 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
| 1784 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1882 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
| 1883 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1884 | + } |
|
| 1785 | 1885 | } |
| 1786 | 1886 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
| 1787 | 1887 | fclose($fp); |
| 1788 | 1888 | |
| 1789 | 1889 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 1790 | 1890 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 1791 | - if (function_exists('opcache_invalidate')) |
|
| 1792 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1891 | + if (function_exists('opcache_invalidate')) { |
|
| 1892 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1893 | + } |
|
| 1793 | 1894 | |
| 1794 | 1895 | return true; |
| 1795 | 1896 | } |
@@ -1799,10 +1900,11 @@ discard block |
||
| 1799 | 1900 | global $cachedir; |
| 1800 | 1901 | |
| 1801 | 1902 | // Write out the db_last_error file with the error timestamp |
| 1802 | - if (!empty($cachedir) && is_writable($cachedir)) |
|
| 1803 | - file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1804 | - else |
|
| 1805 | - file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1903 | + if (!empty($cachedir) && is_writable($cachedir)) { |
|
| 1904 | + file_put_contents($cachedir . '/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1905 | + } else { |
|
| 1906 | + file_put_contents(dirname(__FILE__) . '/cache/db_last_error.php', '<' . '?' . "php\n" . '$db_last_error = 0;' . "\n" . '?' . '>'); |
|
| 1907 | + } |
|
| 1806 | 1908 | |
| 1807 | 1909 | return true; |
| 1808 | 1910 | } |
@@ -1819,9 +1921,9 @@ discard block |
||
| 1819 | 1921 | SecFilterScanPOST Off |
| 1820 | 1922 | </IfModule>'; |
| 1821 | 1923 | |
| 1822 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
| 1823 | - return true; |
|
| 1824 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1924 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
| 1925 | + return true; |
|
| 1926 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1825 | 1927 | { |
| 1826 | 1928 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
| 1827 | 1929 | |
@@ -1833,29 +1935,28 @@ discard block |
||
| 1833 | 1935 | fwrite($ht_handle, $htaccess_addition); |
| 1834 | 1936 | fclose($ht_handle); |
| 1835 | 1937 | return true; |
| 1938 | + } else { |
|
| 1939 | + return false; |
|
| 1836 | 1940 | } |
| 1837 | - else |
|
| 1838 | - return false; |
|
| 1941 | + } else { |
|
| 1942 | + return true; |
|
| 1839 | 1943 | } |
| 1840 | - else |
|
| 1841 | - return true; |
|
| 1842 | - } |
|
| 1843 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
| 1844 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1845 | - elseif (is_writable(dirname(__FILE__))) |
|
| 1944 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
| 1945 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1946 | + } elseif (is_writable(dirname(__FILE__))) |
|
| 1846 | 1947 | { |
| 1847 | 1948 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
| 1848 | 1949 | { |
| 1849 | 1950 | fwrite($ht_handle, $htaccess_addition); |
| 1850 | 1951 | fclose($ht_handle); |
| 1851 | 1952 | return true; |
| 1953 | + } else { |
|
| 1954 | + return false; |
|
| 1852 | 1955 | } |
| 1853 | - else |
|
| 1956 | + } else { |
|
| 1854 | 1957 | return false; |
| 1855 | 1958 | } |
| 1856 | - else |
|
| 1857 | - return false; |
|
| 1858 | -} |
|
| 1959 | + } |
|
| 1859 | 1960 | |
| 1860 | 1961 | function template_install_above() |
| 1861 | 1962 | { |
@@ -1893,9 +1994,10 @@ discard block |
||
| 1893 | 1994 | <label for="installer_language">', $txt['installer_language'], ':</label> |
| 1894 | 1995 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
| 1895 | 1996 | |
| 1896 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
| 1897 | - echo ' |
|
| 1997 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
| 1998 | + echo ' |
|
| 1898 | 1999 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
| 2000 | + } |
|
| 1899 | 2001 | |
| 1900 | 2002 | echo ' |
| 1901 | 2003 | </select> |
@@ -1915,9 +2017,10 @@ discard block |
||
| 1915 | 2017 | <h2>', $txt['upgrade_progress'], '</h2> |
| 1916 | 2018 | <ul>'; |
| 1917 | 2019 | |
| 1918 | - foreach ($incontext['steps'] as $num => $step) |
|
| 1919 | - echo ' |
|
| 2020 | + foreach ($incontext['steps'] as $num => $step) { |
|
| 2021 | + echo ' |
|
| 1920 | 2022 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 2023 | + } |
|
| 1921 | 2024 | |
| 1922 | 2025 | echo ' |
| 1923 | 2026 | </ul> |
@@ -1942,20 +2045,23 @@ discard block |
||
| 1942 | 2045 | echo ' |
| 1943 | 2046 | <div class="floatright">'; |
| 1944 | 2047 | |
| 1945 | - if (!empty($incontext['continue'])) |
|
| 1946 | - echo ' |
|
| 2048 | + if (!empty($incontext['continue'])) { |
|
| 2049 | + echo ' |
|
| 1947 | 2050 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button" />'; |
| 1948 | - if (!empty($incontext['skip'])) |
|
| 1949 | - echo ' |
|
| 2051 | + } |
|
| 2052 | + if (!empty($incontext['skip'])) { |
|
| 2053 | + echo ' |
|
| 1950 | 2054 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button" />'; |
| 2055 | + } |
|
| 1951 | 2056 | echo ' |
| 1952 | 2057 | </div>'; |
| 1953 | 2058 | } |
| 1954 | 2059 | |
| 1955 | 2060 | // Show the closing form tag and other data only if not in the last step |
| 1956 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
| 1957 | - echo ' |
|
| 2061 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
| 2062 | + echo ' |
|
| 1958 | 2063 | </form>'; |
| 2064 | + } |
|
| 1959 | 2065 | |
| 1960 | 2066 | echo ' |
| 1961 | 2067 | </div> |
@@ -1990,13 +2096,15 @@ discard block |
||
| 1990 | 2096 | </div>'; |
| 1991 | 2097 | |
| 1992 | 2098 | // Show the warnings, or not. |
| 1993 | - if (template_warning_divs()) |
|
| 1994 | - echo ' |
|
| 2099 | + if (template_warning_divs()) { |
|
| 2100 | + echo ' |
|
| 1995 | 2101 | <h3>', $txt['install_all_lovely'], '</h3>'; |
| 2102 | + } |
|
| 1996 | 2103 | |
| 1997 | 2104 | // Say we want the continue button! |
| 1998 | - if (empty($incontext['error'])) |
|
| 1999 | - $incontext['continue'] = 1; |
|
| 2105 | + if (empty($incontext['error'])) { |
|
| 2106 | + $incontext['continue'] = 1; |
|
| 2107 | + } |
|
| 2000 | 2108 | |
| 2001 | 2109 | // For the latest version stuff. |
| 2002 | 2110 | echo ' |
@@ -2030,8 +2138,8 @@ discard block |
||
| 2030 | 2138 | global $txt, $incontext; |
| 2031 | 2139 | |
| 2032 | 2140 | // Errors are very serious.. |
| 2033 | - if (!empty($incontext['error'])) |
|
| 2034 | - echo ' |
|
| 2141 | + if (!empty($incontext['error'])) { |
|
| 2142 | + echo ' |
|
| 2035 | 2143 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2036 | 2144 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2037 | 2145 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -2039,9 +2147,10 @@ discard block |
||
| 2039 | 2147 | ', $incontext['error'], ' |
| 2040 | 2148 | </div> |
| 2041 | 2149 | </div>'; |
| 2150 | + } |
|
| 2042 | 2151 | // A warning message? |
| 2043 | - elseif (!empty($incontext['warning'])) |
|
| 2044 | - echo ' |
|
| 2152 | + elseif (!empty($incontext['warning'])) { |
|
| 2153 | + echo ' |
|
| 2045 | 2154 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2046 | 2155 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2047 | 2156 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -2049,6 +2158,7 @@ discard block |
||
| 2049 | 2158 | ', $incontext['warning'], ' |
| 2050 | 2159 | </div> |
| 2051 | 2160 | </div>'; |
| 2161 | + } |
|
| 2052 | 2162 | |
| 2053 | 2163 | return empty($incontext['error']) && empty($incontext['warning']); |
| 2054 | 2164 | } |
@@ -2064,27 +2174,30 @@ discard block |
||
| 2064 | 2174 | <li>', $incontext['failed_files']), '</li> |
| 2065 | 2175 | </ul>'; |
| 2066 | 2176 | |
| 2067 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
| 2068 | - echo ' |
|
| 2177 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
| 2178 | + echo ' |
|
| 2069 | 2179 | <hr> |
| 2070 | 2180 | <p>', $txt['chmod_linux_info'], '</p> |
| 2071 | 2181 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
| 2182 | + } |
|
| 2072 | 2183 | |
| 2073 | 2184 | // This is serious! |
| 2074 | - if (!template_warning_divs()) |
|
| 2075 | - return; |
|
| 2185 | + if (!template_warning_divs()) { |
|
| 2186 | + return; |
|
| 2187 | + } |
|
| 2076 | 2188 | |
| 2077 | 2189 | echo ' |
| 2078 | 2190 | <hr> |
| 2079 | 2191 | <p>', $txt['ftp_setup_info'], '</p>'; |
| 2080 | 2192 | |
| 2081 | - if (!empty($incontext['ftp_errors'])) |
|
| 2082 | - echo ' |
|
| 2193 | + if (!empty($incontext['ftp_errors'])) { |
|
| 2194 | + echo ' |
|
| 2083 | 2195 | <div class="error_message"> |
| 2084 | 2196 | ', $txt['error_ftp_no_connect'], '<br><br> |
| 2085 | 2197 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
| 2086 | 2198 | </div> |
| 2087 | 2199 | <br>'; |
| 2200 | + } |
|
| 2088 | 2201 | |
| 2089 | 2202 | echo ' |
| 2090 | 2203 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2144,17 +2257,17 @@ discard block |
||
| 2144 | 2257 | <td> |
| 2145 | 2258 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
| 2146 | 2259 | |
| 2147 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
| 2148 | - echo ' |
|
| 2260 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
| 2261 | + echo ' |
|
| 2149 | 2262 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
| 2263 | + } |
|
| 2150 | 2264 | |
| 2151 | 2265 | echo ' |
| 2152 | 2266 | </select> |
| 2153 | 2267 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
| 2154 | 2268 | </td> |
| 2155 | 2269 | </tr>'; |
| 2156 | - } |
|
| 2157 | - else |
|
| 2270 | + } else |
|
| 2158 | 2271 | { |
| 2159 | 2272 | echo ' |
| 2160 | 2273 | <tr style="display: none;"> |
@@ -2347,9 +2460,10 @@ discard block |
||
| 2347 | 2460 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
| 2348 | 2461 | <ul>'; |
| 2349 | 2462 | |
| 2350 | - foreach ($incontext['failures'] as $line => $fail) |
|
| 2351 | - echo ' |
|
| 2463 | + foreach ($incontext['failures'] as $line => $fail) { |
|
| 2464 | + echo ' |
|
| 2352 | 2465 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
| 2466 | + } |
|
| 2353 | 2467 | |
| 2354 | 2468 | echo ' |
| 2355 | 2469 | </ul>'; |
@@ -2410,15 +2524,16 @@ discard block |
||
| 2410 | 2524 | </tr> |
| 2411 | 2525 | </table>'; |
| 2412 | 2526 | |
| 2413 | - if ($incontext['require_db_confirm']) |
|
| 2414 | - echo ' |
|
| 2527 | + if ($incontext['require_db_confirm']) { |
|
| 2528 | + echo ' |
|
| 2415 | 2529 | <h2>', $txt['user_settings_database'], '</h2> |
| 2416 | 2530 | <p>', $txt['user_settings_database_info'], '</p> |
| 2417 | 2531 | |
| 2418 | 2532 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
| 2419 | 2533 | <input type="password" name="password3" size="30" /> |
| 2420 | 2534 | </div>'; |
| 2421 | -} |
|
| 2535 | + } |
|
| 2536 | + } |
|
| 2422 | 2537 | |
| 2423 | 2538 | // Tell them it's done, and to delete. |
| 2424 | 2539 | function template_delete_install() |
@@ -2431,14 +2546,15 @@ discard block |
||
| 2431 | 2546 | template_warning_divs(); |
| 2432 | 2547 | |
| 2433 | 2548 | // Install directory still writable? |
| 2434 | - if ($incontext['dir_still_writable']) |
|
| 2435 | - echo ' |
|
| 2549 | + if ($incontext['dir_still_writable']) { |
|
| 2550 | + echo ' |
|
| 2436 | 2551 | <em>', $txt['still_writable'], '</em><br> |
| 2437 | 2552 | <br>'; |
| 2553 | + } |
|
| 2438 | 2554 | |
| 2439 | 2555 | // Don't show the box if it's like 99% sure it won't work :P. |
| 2440 | - if ($incontext['probably_delete_install']) |
|
| 2441 | - echo ' |
|
| 2556 | + if ($incontext['probably_delete_install']) { |
|
| 2557 | + echo ' |
|
| 2442 | 2558 | <div style="margin: 1ex; font-weight: bold;"> |
| 2443 | 2559 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
| 2444 | 2560 | </div> |
@@ -2454,6 +2570,7 @@ discard block |
||
| 2454 | 2570 | } |
| 2455 | 2571 | </script> |
| 2456 | 2572 | <br>'; |
| 2573 | + } |
|
| 2457 | 2574 | |
| 2458 | 2575 | echo ' |
| 2459 | 2576 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |