@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * This is the main function for the languages area. |
@@ -153,11 +154,11 @@ discard block |
||
| 153 | 154 | $language_list = new xmlArray(fetch_web_data($url), true); |
| 154 | 155 | |
| 155 | 156 | // Check that the site responded and that the language exists. |
| 156 | - if (!$language_list->exists('languages')) |
|
| 157 | - $context['smf_error'] = 'no_response'; |
|
| 158 | - elseif (!$language_list->exists('languages/language')) |
|
| 159 | - $context['smf_error'] = 'no_files'; |
|
| 160 | - else |
|
| 157 | + if (!$language_list->exists('languages')) { |
|
| 158 | + $context['smf_error'] = 'no_response'; |
|
| 159 | + } elseif (!$language_list->exists('languages/language')) { |
|
| 160 | + $context['smf_error'] = 'no_files'; |
|
| 161 | + } else |
|
| 161 | 162 | { |
| 162 | 163 | $language_list = $language_list->path('languages[0]'); |
| 163 | 164 | $lang_files = $language_list->set('language'); |
@@ -165,8 +166,9 @@ discard block |
||
| 165 | 166 | foreach ($lang_files as $file) |
| 166 | 167 | { |
| 167 | 168 | // Were we searching? |
| 168 | - if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) |
|
| 169 | - continue; |
|
| 169 | + if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false) { |
|
| 170 | + continue; |
|
| 171 | + } |
|
| 170 | 172 | |
| 171 | 173 | $smf_languages[] = array( |
| 172 | 174 | 'id' => $file->fetch('id'), |
@@ -177,10 +179,11 @@ discard block |
||
| 177 | 179 | 'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>', |
| 178 | 180 | ); |
| 179 | 181 | } |
| 180 | - if (empty($smf_languages)) |
|
| 181 | - $context['smf_error'] = 'no_files'; |
|
| 182 | - else |
|
| 183 | - return $smf_languages; |
|
| 182 | + if (empty($smf_languages)) { |
|
| 183 | + $context['smf_error'] = 'no_files'; |
|
| 184 | + } else { |
|
| 185 | + return $smf_languages; |
|
| 186 | + } |
|
| 184 | 187 | } |
| 185 | 188 | } |
| 186 | 189 | |
@@ -202,8 +205,9 @@ discard block |
||
| 202 | 205 | require_once($sourcedir . '/Subs-Package.php'); |
| 203 | 206 | |
| 204 | 207 | // Clearly we need to know what to request. |
| 205 | - if (!isset($_GET['did'])) |
|
| 206 | - fatal_lang_error('no_access', false); |
|
| 208 | + if (!isset($_GET['did'])) { |
|
| 209 | + fatal_lang_error('no_access', false); |
|
| 210 | + } |
|
| 207 | 211 | |
| 208 | 212 | // Some lovely context. |
| 209 | 213 | $context['download_id'] = $_GET['did']; |
@@ -223,8 +227,9 @@ discard block |
||
| 223 | 227 | foreach ($_POST['copy_file'] as $file) |
| 224 | 228 | { |
| 225 | 229 | // Check it's not very bad. |
| 226 | - if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) |
|
| 227 | - fatal_error($txt['languages_download_illegal_paths']); |
|
| 230 | + if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file))) { |
|
| 231 | + fatal_error($txt['languages_download_illegal_paths']); |
|
| 232 | + } |
|
| 228 | 233 | |
| 229 | 234 | $chmod_files[] = $boarddir . '/' . $file; |
| 230 | 235 | $install_files[] = $file; |
@@ -235,8 +240,9 @@ discard block |
||
| 235 | 240 | $files_left = $file_status['files']['notwritable']; |
| 236 | 241 | |
| 237 | 242 | // Something not writable? |
| 238 | - if (!empty($files_left)) |
|
| 239 | - $context['error_message'] = $txt['languages_download_not_chmod']; |
|
| 243 | + if (!empty($files_left)) { |
|
| 244 | + $context['error_message'] = $txt['languages_download_not_chmod']; |
|
| 245 | + } |
|
| 240 | 246 | // Otherwise, go go go! |
| 241 | 247 | elseif (!empty($install_files)) |
| 242 | 248 | { |
@@ -250,11 +256,13 @@ discard block |
||
| 250 | 256 | } |
| 251 | 257 | |
| 252 | 258 | // Open up the old china. |
| 253 | - if (!isset($archive_content)) |
|
| 254 | - $archive_content = read_tgz_file('http://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
| 259 | + if (!isset($archive_content)) { |
|
| 260 | + $archive_content = read_tgz_file('http://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => ''))) . ';fetch=' . urlencode($_GET['did']), null); |
|
| 261 | + } |
|
| 255 | 262 | |
| 256 | - if (empty($archive_content)) |
|
| 257 | - fatal_error($txt['add_language_error_no_response']); |
|
| 263 | + if (empty($archive_content)) { |
|
| 264 | + fatal_error($txt['add_language_error_no_response']); |
|
| 265 | + } |
|
| 258 | 266 | |
| 259 | 267 | // Now for each of the files, let's do some *stuff* |
| 260 | 268 | $context['files'] = array( |
@@ -269,8 +277,9 @@ discard block |
||
| 269 | 277 | $extension = substr($filename, strrpos($filename, '.') + 1); |
| 270 | 278 | |
| 271 | 279 | // Don't do anything with files we don't understand. |
| 272 | - if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) |
|
| 273 | - continue; |
|
| 280 | + if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt'))) { |
|
| 281 | + continue; |
|
| 282 | + } |
|
| 274 | 283 | |
| 275 | 284 | // Basic data. |
| 276 | 285 | $context_data = array( |
@@ -289,8 +298,9 @@ discard block |
||
| 289 | 298 | // Does the file exist, is it different and can we overwrite? |
| 290 | 299 | if (file_exists($boarddir . '/' . $file['filename'])) |
| 291 | 300 | { |
| 292 | - if (is_writable($boarddir . '/' . $file['filename'])) |
|
| 293 | - $context_data['writable'] = true; |
|
| 301 | + if (is_writable($boarddir . '/' . $file['filename'])) { |
|
| 302 | + $context_data['writable'] = true; |
|
| 303 | + } |
|
| 294 | 304 | |
| 295 | 305 | // Finally, do we actually think the content has changed? |
| 296 | 306 | if ($file['size'] == filesize($boarddir . '/' . $file['filename']) && $file['md5'] == md5_file($boarddir . '/' . $file['filename'])) |
@@ -303,16 +313,17 @@ discard block |
||
| 303 | 313 | { |
| 304 | 314 | $context_data['exists'] = 'same'; |
| 305 | 315 | $context_data['default_copy'] = false; |
| 316 | + } else { |
|
| 317 | + $context_data['exists'] = 'different'; |
|
| 306 | 318 | } |
| 307 | - else |
|
| 308 | - $context_data['exists'] = 'different'; |
|
| 309 | 319 | } |
| 310 | 320 | // No overwrite? |
| 311 | 321 | else |
| 312 | 322 | { |
| 313 | 323 | // Can we at least stick it in the directory... |
| 314 | - if (is_writable($boarddir . '/' . $dirname)) |
|
| 315 | - $context_data['writable'] = true; |
|
| 324 | + if (is_writable($boarddir . '/' . $dirname)) { |
|
| 325 | + $context_data['writable'] = true; |
|
| 326 | + } |
|
| 316 | 327 | } |
| 317 | 328 | |
| 318 | 329 | // I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin... |
@@ -327,8 +338,9 @@ discard block |
||
| 327 | 338 | list ($name, $language) = explode('.', $filename); |
| 328 | 339 | |
| 329 | 340 | // Let's get the new version, I like versions, they tell me that I'm up to date. |
| 330 | - if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) |
|
| 331 | - $context_data['version'] = $match[1]; |
|
| 341 | + if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1) { |
|
| 342 | + $context_data['version'] = $match[1]; |
|
| 343 | + } |
|
| 332 | 344 | |
| 333 | 345 | // Now does the old file exist - if so what is it's version? |
| 334 | 346 | if (file_exists($boarddir . '/' . $file['filename'])) |
@@ -344,34 +356,35 @@ discard block |
||
| 344 | 356 | $context_data['cur_version'] = $match[1]; |
| 345 | 357 | |
| 346 | 358 | // How does this compare? |
| 347 | - if ($context_data['cur_version'] == $context_data['version']) |
|
| 348 | - $context_data['version_compare'] = 'same'; |
|
| 349 | - elseif ($context_data['cur_version'] > $context_data['version']) |
|
| 350 | - $context_data['version_compare'] = 'older'; |
|
| 359 | + if ($context_data['cur_version'] == $context_data['version']) { |
|
| 360 | + $context_data['version_compare'] = 'same'; |
|
| 361 | + } elseif ($context_data['cur_version'] > $context_data['version']) { |
|
| 362 | + $context_data['version_compare'] = 'older'; |
|
| 363 | + } |
|
| 351 | 364 | |
| 352 | 365 | // Don't recommend copying if the version is the same. |
| 353 | - if ($context_data['version_compare'] != 'newer') |
|
| 354 | - $context_data['default_copy'] = false; |
|
| 366 | + if ($context_data['version_compare'] != 'newer') { |
|
| 367 | + $context_data['default_copy'] = false; |
|
| 368 | + } |
|
| 355 | 369 | } |
| 356 | 370 | } |
| 357 | 371 | |
| 358 | 372 | // Add the context data to the main set. |
| 359 | 373 | $context['files']['lang'][] = $context_data; |
| 360 | - } |
|
| 361 | - elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
| 374 | + } elseif ($extension == '.txt' && stripos($filename, 'agreement') !== false) |
|
| 362 | 375 | { |
| 363 | 376 | // Registration agreement is a primary file |
| 364 | 377 | $context['files']['lang'][] = $context_data; |
| 365 | - } |
|
| 366 | - else |
|
| 378 | + } else |
|
| 367 | 379 | { |
| 368 | 380 | // There shouldn't be anything else, but load this into "other" in case we decide to handle it in the future |
| 369 | 381 | $context['files']['other'][] = $context_data; |
| 370 | 382 | } |
| 371 | 383 | |
| 372 | 384 | // Collect together all non-writable areas. |
| 373 | - if (!$context_data['writable']) |
|
| 374 | - $context['make_writable'][] = $context_data['destination']; |
|
| 385 | + if (!$context_data['writable']) { |
|
| 386 | + $context['make_writable'][] = $context_data['destination']; |
|
| 387 | + } |
|
| 375 | 388 | } |
| 376 | 389 | |
| 377 | 390 | // Before we go to far can we make anything writable, eh, eh? |
@@ -386,22 +399,24 @@ discard block |
||
| 386 | 399 | { |
| 387 | 400 | if ($type == 'lang') |
| 388 | 401 | { |
| 389 | - foreach ($data as $k => $file) |
|
| 390 | - if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
| 402 | + foreach ($data as $k => $file) { |
|
| 403 | + if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
|
| 391 | 404 | $context['files'][$type][$k]['writable'] = true; |
| 392 | - } |
|
| 393 | - else |
|
| 405 | + } |
|
| 406 | + } else |
|
| 394 | 407 | { |
| 395 | - foreach ($data as $theme => $files) |
|
| 396 | - foreach ($files as $k => $file) |
|
| 408 | + foreach ($data as $theme => $files) { |
|
| 409 | + foreach ($files as $k => $file) |
|
| 397 | 410 | if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable'])) |
| 398 | 411 | $context['files'][$type][$theme][$k]['writable'] = true; |
| 412 | + } |
|
| 399 | 413 | } |
| 400 | 414 | } |
| 401 | 415 | |
| 402 | 416 | // Are we going to need more language stuff? |
| 403 | - if (!empty($context['still_not_writable'])) |
|
| 404 | - loadLanguage('Packages'); |
|
| 417 | + if (!empty($context['still_not_writable'])) { |
|
| 418 | + loadLanguage('Packages'); |
|
| 419 | + } |
|
| 405 | 420 | } |
| 406 | 421 | |
| 407 | 422 | // This is the list for the main files. |
@@ -614,12 +629,13 @@ discard block |
||
| 614 | 629 | highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '");', true); |
| 615 | 630 | |
| 616 | 631 | // Display a warning if we cannot edit the default setting. |
| 617 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 618 | - $listOptions['additional_rows'][] = array( |
|
| 632 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 633 | + $listOptions['additional_rows'][] = array( |
|
| 619 | 634 | 'position' => 'after_title', |
| 620 | 635 | 'value' => $txt['language_settings_writable'], |
| 621 | 636 | 'class' => 'smalltext alert', |
| 622 | 637 | ); |
| 638 | + } |
|
| 623 | 639 | |
| 624 | 640 | require_once($sourcedir . '/Subs-List.php'); |
| 625 | 641 | createList($listOptions); |
@@ -661,10 +677,11 @@ discard block |
||
| 661 | 677 | |
| 662 | 678 | // Put them back. |
| 663 | 679 | $settings['actual_theme_dir'] = $backup_actual_theme_dir; |
| 664 | - if (!empty($backup_base_theme_dir)) |
|
| 665 | - $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
| 666 | - else |
|
| 667 | - unset($settings['base_theme_dir']); |
|
| 680 | + if (!empty($backup_base_theme_dir)) { |
|
| 681 | + $settings['base_theme_dir'] = $backup_base_theme_dir; |
|
| 682 | + } else { |
|
| 683 | + unset($settings['base_theme_dir']); |
|
| 684 | + } |
|
| 668 | 685 | |
| 669 | 686 | // Get the language files and data... |
| 670 | 687 | foreach ($context['languages'] as $lang) |
@@ -693,13 +710,15 @@ discard block |
||
| 693 | 710 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 694 | 711 | { |
| 695 | 712 | // Default? |
| 696 | - if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) |
|
| 697 | - $row['lngfile'] = $language; |
|
| 713 | + if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) { |
|
| 714 | + $row['lngfile'] = $language; |
|
| 715 | + } |
|
| 698 | 716 | |
| 699 | - if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) |
|
| 700 | - $languages['english']['count'] += $row['num_users']; |
|
| 701 | - elseif (isset($languages[$row['lngfile']])) |
|
| 702 | - $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
| 717 | + if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) { |
|
| 718 | + $languages['english']['count'] += $row['num_users']; |
|
| 719 | + } elseif (isset($languages[$row['lngfile']])) { |
|
| 720 | + $languages[$row['lngfile']]['count'] += $row['num_users']; |
|
| 721 | + } |
|
| 703 | 722 | } |
| 704 | 723 | $smcFunc['db_free_result']($request); |
| 705 | 724 | |
@@ -739,13 +758,15 @@ discard block |
||
| 739 | 758 | |
| 740 | 759 | call_integration_hook('integrate_language_settings', array(&$config_vars)); |
| 741 | 760 | |
| 742 | - if ($return_config) |
|
| 743 | - return $config_vars; |
|
| 761 | + if ($return_config) { |
|
| 762 | + return $config_vars; |
|
| 763 | + } |
|
| 744 | 764 | |
| 745 | 765 | // Get our languages. No cache and use utf8. |
| 746 | 766 | getLanguages(false, false); |
| 747 | - foreach ($context['languages'] as $lang) |
|
| 748 | - $config_vars['language'][4][$lang['filename']] = array($lang['filename'], strtr($lang['name'], array('-utf8' => ' (UTF-8)'))); |
|
| 767 | + foreach ($context['languages'] as $lang) { |
|
| 768 | + $config_vars['language'][4][$lang['filename']] = array($lang['filename'], strtr($lang['name'], array('-utf8' => ' (UTF-8)'))); |
|
| 769 | + } |
|
| 749 | 770 | |
| 750 | 771 | // Saving settings? |
| 751 | 772 | if (isset($_REQUEST['save'])) |
@@ -755,8 +776,9 @@ discard block |
||
| 755 | 776 | call_integration_hook('integrate_save_language_settings', array(&$config_vars)); |
| 756 | 777 | |
| 757 | 778 | saveSettings($config_vars); |
| 758 | - if (!$settings_not_writable && !$settings_backup_fail) |
|
| 759 | - $_SESSION['adm-save'] = true; |
|
| 779 | + if (!$settings_not_writable && !$settings_backup_fail) { |
|
| 780 | + $_SESSION['adm-save'] = true; |
|
| 781 | + } |
|
| 760 | 782 | redirectexit('action=admin;area=languages;sa=settings'); |
| 761 | 783 | } |
| 762 | 784 | |
@@ -765,10 +787,11 @@ discard block |
||
| 765 | 787 | $context['settings_title'] = $txt['language_settings']; |
| 766 | 788 | $context['save_disabled'] = $settings_not_writable; |
| 767 | 789 | |
| 768 | - if ($settings_not_writable) |
|
| 769 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 770 | - elseif ($settings_backup_fail) |
|
| 771 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 790 | + if ($settings_not_writable) { |
|
| 791 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
| 792 | + } elseif ($settings_backup_fail) { |
|
| 793 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
| 794 | + } |
|
| 772 | 795 | |
| 773 | 796 | // Fill the config array. |
| 774 | 797 | prepareServerSettingsContext($config_vars); |
@@ -815,8 +838,9 @@ discard block |
||
| 815 | 838 | 'theme_dir' => $settings['default_theme_dir'], |
| 816 | 839 | ), |
| 817 | 840 | ); |
| 818 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 819 | - $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 841 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 842 | + $themes[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 843 | + } |
|
| 820 | 844 | $smcFunc['db_free_result']($request); |
| 821 | 845 | |
| 822 | 846 | // This will be where we look |
@@ -828,14 +852,16 @@ discard block |
||
| 828 | 852 | // Check we have themes with a path and a name - just in case - and add the path. |
| 829 | 853 | foreach ($themes as $id => $data) |
| 830 | 854 | { |
| 831 | - if (count($data) != 2) |
|
| 832 | - unset($themes[$id]); |
|
| 833 | - elseif (is_dir($data['theme_dir'] . '/languages')) |
|
| 834 | - $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
| 855 | + if (count($data) != 2) { |
|
| 856 | + unset($themes[$id]); |
|
| 857 | + } elseif (is_dir($data['theme_dir'] . '/languages')) { |
|
| 858 | + $lang_dirs[$id] = $data['theme_dir'] . '/languages'; |
|
| 859 | + } |
|
| 835 | 860 | |
| 836 | 861 | // How about image directories? |
| 837 | - if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) |
|
| 838 | - $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
| 862 | + if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id'])) { |
|
| 863 | + $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id']; |
|
| 864 | + } |
|
| 839 | 865 | } |
| 840 | 866 | |
| 841 | 867 | $current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : ''; |
@@ -849,15 +875,17 @@ discard block |
||
| 849 | 875 | while ($entry = $dir->read()) |
| 850 | 876 | { |
| 851 | 877 | // We're only after the files for this language. |
| 852 | - if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) |
|
| 853 | - continue; |
|
| 878 | + if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0) { |
|
| 879 | + continue; |
|
| 880 | + } |
|
| 854 | 881 | |
| 855 | - if (!isset($context['possible_files'][$theme])) |
|
| 856 | - $context['possible_files'][$theme] = array( |
|
| 882 | + if (!isset($context['possible_files'][$theme])) { |
|
| 883 | + $context['possible_files'][$theme] = array( |
|
| 857 | 884 | 'id' => $theme, |
| 858 | 885 | 'name' => $themes[$theme]['name'], |
| 859 | 886 | 'files' => array(), |
| 860 | 887 | ); |
| 888 | + } |
|
| 861 | 889 | |
| 862 | 890 | $context['possible_files'][$theme]['files'][] = array( |
| 863 | 891 | 'id' => $matches[1], |
@@ -886,31 +914,36 @@ discard block |
||
| 886 | 914 | { |
| 887 | 915 | $_SESSION['last_backup_for'] = $context['lang_id'] . '$$$'; |
| 888 | 916 | $result = package_create_backup('backup_lang_' . $context['lang_id']); |
| 889 | - if (!$result) |
|
| 890 | - fatal_lang_error('could_not_language_backup', false); |
|
| 917 | + if (!$result) { |
|
| 918 | + fatal_lang_error('could_not_language_backup', false); |
|
| 919 | + } |
|
| 891 | 920 | } |
| 892 | 921 | |
| 893 | 922 | // Second, loop through the array to remove the files. |
| 894 | 923 | foreach ($lang_dirs as $curPath) |
| 895 | 924 | { |
| 896 | - foreach ($context['possible_files'][1]['files'] as $lang) |
|
| 897 | - if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
| 925 | + foreach ($context['possible_files'][1]['files'] as $lang) { |
|
| 926 | + if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php')) |
|
| 898 | 927 | unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'); |
| 928 | + } |
|
| 899 | 929 | |
| 900 | 930 | // Check for the email template. |
| 901 | - if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) |
|
| 902 | - unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
| 931 | + if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php')) { |
|
| 932 | + unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'); |
|
| 933 | + } |
|
| 903 | 934 | } |
| 904 | 935 | |
| 905 | 936 | // Third, the agreement file. |
| 906 | - if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) |
|
| 907 | - unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
| 937 | + if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt')) { |
|
| 938 | + unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt'); |
|
| 939 | + } |
|
| 908 | 940 | |
| 909 | 941 | // Fourth, a related images folder, if it exists... |
| 910 | - if (!empty($images_dirs)) |
|
| 911 | - foreach ($images_dirs as $curPath) |
|
| 942 | + if (!empty($images_dirs)) { |
|
| 943 | + foreach ($images_dirs as $curPath) |
|
| 912 | 944 | if (is_dir($curPath)) |
| 913 | 945 | deltree($curPath); |
| 946 | + } |
|
| 914 | 947 | |
| 915 | 948 | // Members can no longer use this language. |
| 916 | 949 | $smcFunc['db_query']('', ' |
@@ -995,8 +1028,9 @@ discard block |
||
| 995 | 1028 | foreach ($_POST['entry'] as $k => $v) |
| 996 | 1029 | { |
| 997 | 1030 | // Only try to save if it's changed! |
| 998 | - if ($_POST['entry'][$k] != $_POST['comp'][$k]) |
|
| 999 | - $save_strings[$k] = cleanLangString($v, false); |
|
| 1031 | + if ($_POST['entry'][$k] != $_POST['comp'][$k]) { |
|
| 1032 | + $save_strings[$k] = cleanLangString($v, false); |
|
| 1033 | + } |
|
| 1000 | 1034 | } |
| 1001 | 1035 | } |
| 1002 | 1036 | |
@@ -1030,12 +1064,13 @@ discard block |
||
| 1030 | 1064 | if ($multiline_cache) |
| 1031 | 1065 | { |
| 1032 | 1066 | preg_match('~\$(helptxt|txt|editortxt)\[\'(.+)\'\]\s?=\s?(.+);~ms', strtr($multiline_cache, array("\r" => '')), $matches); |
| 1033 | - if (!empty($matches[3])) |
|
| 1034 | - $entries[$matches[2]] = array( |
|
| 1067 | + if (!empty($matches[3])) { |
|
| 1068 | + $entries[$matches[2]] = array( |
|
| 1035 | 1069 | 'type' => $matches[1], |
| 1036 | 1070 | 'full' => $matches[0], |
| 1037 | 1071 | 'entry' => $matches[3], |
| 1038 | 1072 | ); |
| 1073 | + } |
|
| 1039 | 1074 | } |
| 1040 | 1075 | |
| 1041 | 1076 | // These are the entries we can definitely save. |
@@ -1046,8 +1081,9 @@ discard block |
||
| 1046 | 1081 | { |
| 1047 | 1082 | // Ignore some things we set separately. |
| 1048 | 1083 | $ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl'); |
| 1049 | - if (in_array($entryKey, $ignore_files)) |
|
| 1050 | - continue; |
|
| 1084 | + if (in_array($entryKey, $ignore_files)) { |
|
| 1085 | + continue; |
|
| 1086 | + } |
|
| 1051 | 1087 | |
| 1052 | 1088 | // These are arrays that need breaking out. |
| 1053 | 1089 | $arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short', 'happy_birthday_author', 'karlbenson1_author', 'nite0859_author', 'zwaldowski_author', 'geezmo_author', 'karlbenson2_author'); |
@@ -1080,9 +1116,9 @@ discard block |
||
| 1080 | 1116 | { |
| 1081 | 1117 | $save_cache['entries'][$cur_index] = strtr($save_strings[$entryKey . '-+- ' . $cur_index], array('\'' => '')); |
| 1082 | 1118 | $save_cache['enabled'] = true; |
| 1119 | + } else { |
|
| 1120 | + $save_cache['entries'][$cur_index] = $subValue; |
|
| 1083 | 1121 | } |
| 1084 | - else |
|
| 1085 | - $save_cache['entries'][$cur_index] = $subValue; |
|
| 1086 | 1122 | |
| 1087 | 1123 | $context['file_entries'][] = array( |
| 1088 | 1124 | 'key' => $entryKey . '-+- ' . $cur_index, |
@@ -1105,9 +1141,9 @@ discard block |
||
| 1105 | 1141 | { |
| 1106 | 1142 | $items[] = $k2 . ' => \'' . $v2 . '\''; |
| 1107 | 1143 | $cur_index = $k2; |
| 1144 | + } else { |
|
| 1145 | + $items[] = '\'' . $v2 . '\''; |
|
| 1108 | 1146 | } |
| 1109 | - else |
|
| 1110 | - $items[] = '\'' . $v2 . '\''; |
|
| 1111 | 1147 | |
| 1112 | 1148 | $cur_index++; |
| 1113 | 1149 | } |
@@ -1117,15 +1153,15 @@ discard block |
||
| 1117 | 1153 | 'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');', |
| 1118 | 1154 | ); |
| 1119 | 1155 | } |
| 1120 | - } |
|
| 1121 | - else |
|
| 1156 | + } else |
|
| 1122 | 1157 | { |
| 1123 | 1158 | // Saving? |
| 1124 | 1159 | if (isset($save_strings[$entryKey]) && $save_strings[$entryKey] != $entryValue['entry']) |
| 1125 | 1160 | { |
| 1126 | 1161 | // @todo Fix this properly. |
| 1127 | - if ($save_strings[$entryKey] == '') |
|
| 1128 | - $save_strings[$entryKey] = '\'\''; |
|
| 1162 | + if ($save_strings[$entryKey] == '') { |
|
| 1163 | + $save_strings[$entryKey] = '\'\''; |
|
| 1164 | + } |
|
| 1129 | 1165 | |
| 1130 | 1166 | // Set the new value. |
| 1131 | 1167 | $entryValue['entry'] = $save_strings[$entryKey]; |
@@ -1151,8 +1187,9 @@ discard block |
||
| 1151 | 1187 | checkSession(); |
| 1152 | 1188 | |
| 1153 | 1189 | $file_contents = implode('', file($current_file)); |
| 1154 | - foreach ($final_saves as $save) |
|
| 1155 | - $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
| 1190 | + foreach ($final_saves as $save) { |
|
| 1191 | + $file_contents = strtr($file_contents, array($save['find'] => $save['replace'])); |
|
| 1192 | + } |
|
| 1156 | 1193 | |
| 1157 | 1194 | // Save the actual changes. |
| 1158 | 1195 | $fp = fopen($current_file, 'w+'); |
@@ -1167,8 +1204,9 @@ discard block |
||
| 1167 | 1204 | } |
| 1168 | 1205 | |
| 1169 | 1206 | // If we saved, redirect. |
| 1170 | - if ($madeSave) |
|
| 1171 | - redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
| 1207 | + if ($madeSave) { |
|
| 1208 | + redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']); |
|
| 1209 | + } |
|
| 1172 | 1210 | |
| 1173 | 1211 | createToken('admin-mlang'); |
| 1174 | 1212 | } |
@@ -1200,8 +1238,9 @@ discard block |
||
| 1200 | 1238 | // Toggle the escape. |
| 1201 | 1239 | $is_escape = !$is_escape; |
| 1202 | 1240 | // If we're now escaped don't add this string. |
| 1203 | - if ($is_escape) |
|
| 1204 | - continue; |
|
| 1241 | + if ($is_escape) { |
|
| 1242 | + continue; |
|
| 1243 | + } |
|
| 1205 | 1244 | } |
| 1206 | 1245 | // Special case - parsed string with line break etc? |
| 1207 | 1246 | elseif (($string{$i} == 'n' || $string{$i} == 't') && $in_string == 2 && $is_escape) |
@@ -1218,11 +1257,13 @@ discard block |
||
| 1218 | 1257 | if ($in_string != 2 && ($in_string != 1 || !$is_escape)) |
| 1219 | 1258 | { |
| 1220 | 1259 | // Is it the end of a single quote string? |
| 1221 | - if ($in_string == 1) |
|
| 1222 | - $in_string = 0; |
|
| 1260 | + if ($in_string == 1) { |
|
| 1261 | + $in_string = 0; |
|
| 1262 | + } |
|
| 1223 | 1263 | // Otherwise it's the start! |
| 1224 | - else |
|
| 1225 | - $in_string = 1; |
|
| 1264 | + else { |
|
| 1265 | + $in_string = 1; |
|
| 1266 | + } |
|
| 1226 | 1267 | |
| 1227 | 1268 | // Don't actually include this character! |
| 1228 | 1269 | continue; |
@@ -1235,19 +1276,22 @@ discard block |
||
| 1235 | 1276 | if ($in_string != 1 && ($in_string != 2 || !$is_escape)) |
| 1236 | 1277 | { |
| 1237 | 1278 | // Is it the end of a double quote string? |
| 1238 | - if ($in_string == 2) |
|
| 1239 | - $in_string = 0; |
|
| 1279 | + if ($in_string == 2) { |
|
| 1280 | + $in_string = 0; |
|
| 1281 | + } |
|
| 1240 | 1282 | // Otherwise it's the start! |
| 1241 | - else |
|
| 1242 | - $in_string = 2; |
|
| 1283 | + else { |
|
| 1284 | + $in_string = 2; |
|
| 1285 | + } |
|
| 1243 | 1286 | |
| 1244 | 1287 | // Don't actually include this character! |
| 1245 | 1288 | continue; |
| 1246 | 1289 | } |
| 1247 | 1290 | } |
| 1248 | 1291 | // A join/space outside of a string is simply removed. |
| 1249 | - elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) |
|
| 1250 | - continue; |
|
| 1292 | + elseif ($in_string == 0 && (empty($string{$i}) || $string{$i} == '.')) { |
|
| 1293 | + continue; |
|
| 1294 | + } |
|
| 1251 | 1295 | // Start of a variable? |
| 1252 | 1296 | elseif ($in_string == 0 && $string{$i} == '$') |
| 1253 | 1297 | { |
@@ -1281,8 +1325,7 @@ discard block |
||
| 1281 | 1325 | |
| 1282 | 1326 | // Unhtml then rehtml the whole thing! |
| 1283 | 1327 | $new_string = $smcFunc['htmlspecialchars'](un_htmlspecialchars($new_string)); |
| 1284 | - } |
|
| 1285 | - else |
|
| 1328 | + } else |
|
| 1286 | 1329 | { |
| 1287 | 1330 | // Keep track of what we're doing... |
| 1288 | 1331 | $in_string = 0; |
@@ -1311,10 +1354,11 @@ discard block |
||
| 1311 | 1354 | preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches); |
| 1312 | 1355 | if (!empty($matches[1])) |
| 1313 | 1356 | { |
| 1314 | - if ($in_string == 1) |
|
| 1315 | - $new_string .= '\' . '; |
|
| 1316 | - elseif ($new_string) |
|
| 1317 | - $new_string .= ' . '; |
|
| 1357 | + if ($in_string == 1) { |
|
| 1358 | + $new_string .= '\' . '; |
|
| 1359 | + } elseif ($new_string) { |
|
| 1360 | + $new_string .= ' . '; |
|
| 1361 | + } |
|
| 1318 | 1362 | |
| 1319 | 1363 | $new_string .= $matches[1]; |
| 1320 | 1364 | $i += strlen($matches[1]) + 3; |
@@ -1327,8 +1371,9 @@ discard block |
||
| 1327 | 1371 | elseif ($string{$i} == '<') |
| 1328 | 1372 | { |
| 1329 | 1373 | // Probably HTML? |
| 1330 | - if ($string{$i + 1} != ' ') |
|
| 1331 | - $in_html = true; |
|
| 1374 | + if ($string{$i + 1} != ' ') { |
|
| 1375 | + $in_html = true; |
|
| 1376 | + } |
|
| 1332 | 1377 | // Assume we need an entity... |
| 1333 | 1378 | else |
| 1334 | 1379 | { |
@@ -1340,8 +1385,9 @@ discard block |
||
| 1340 | 1385 | elseif ($string{$i} == '>') |
| 1341 | 1386 | { |
| 1342 | 1387 | // Will it be HTML? |
| 1343 | - if ($in_html) |
|
| 1344 | - $in_html = false; |
|
| 1388 | + if ($in_html) { |
|
| 1389 | + $in_html = false; |
|
| 1390 | + } |
|
| 1345 | 1391 | // Otherwise we need an entity... |
| 1346 | 1392 | else |
| 1347 | 1393 | { |
@@ -1350,8 +1396,9 @@ discard block |
||
| 1350 | 1396 | } |
| 1351 | 1397 | } |
| 1352 | 1398 | // Is it a slash? If so escape it... |
| 1353 | - if ($string{$i} == '\\') |
|
| 1354 | - $new_string .= '\\'; |
|
| 1399 | + if ($string{$i} == '\\') { |
|
| 1400 | + $new_string .= '\\'; |
|
| 1401 | + } |
|
| 1355 | 1402 | // The infamous double quote? |
| 1356 | 1403 | elseif ($string{$i} == '"') |
| 1357 | 1404 | { |
@@ -1374,10 +1421,11 @@ discard block |
||
| 1374 | 1421 | } |
| 1375 | 1422 | |
| 1376 | 1423 | // If we ended as a string then close it off. |
| 1377 | - if ($in_string == 1) |
|
| 1378 | - $new_string .= '\''; |
|
| 1379 | - elseif ($in_string == 2) |
|
| 1380 | - $new_string .= '"'; |
|
| 1424 | + if ($in_string == 1) { |
|
| 1425 | + $new_string .= '\''; |
|
| 1426 | + } elseif ($in_string == 2) { |
|
| 1427 | + $new_string .= '"'; |
|
| 1428 | + } |
|
| 1381 | 1429 | } |
| 1382 | 1430 | |
| 1383 | 1431 | return $new_string; |
@@ -3122,94 +3122,94 @@ |
||
| 3122 | 3122 | // Translation table for the character sets not native for MySQL. |
| 3123 | 3123 | $translation_tables = array( |
| 3124 | 3124 | 'windows-1255' => array( |
| 3125 | - '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 3126 | - '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 3127 | - '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 3128 | - '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 3129 | - '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 3130 | - '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 3131 | - '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 3132 | - '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 3133 | - '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 3134 | - '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 3135 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 3136 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 3137 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 3138 | - '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 3139 | - '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 3140 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 3141 | - '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 3142 | - '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 3143 | - '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 3144 | - '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 3145 | - '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 3146 | - '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 3147 | - '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 3148 | - '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 3149 | - '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 3150 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 3151 | - '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 3152 | - '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 3153 | - '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 3154 | - '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 3155 | - '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 3156 | - '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 3157 | - '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 3158 | - '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 3159 | - '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 3160 | - '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 3161 | - '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 3162 | - '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 3163 | - '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 3164 | - '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 3165 | - '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 3166 | - '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 3125 | + '0x81' => '\'\'', '0x8A' => '\'\'', '0x8C' => '\'\'', |
|
| 3126 | + '0x8D' => '\'\'', '0x8E' => '\'\'', '0x8F' => '\'\'', |
|
| 3127 | + '0x90' => '\'\'', '0x9A' => '\'\'', '0x9C' => '\'\'', |
|
| 3128 | + '0x9D' => '\'\'', '0x9E' => '\'\'', '0x9F' => '\'\'', |
|
| 3129 | + '0xCA' => '\'\'', '0xD9' => '\'\'', '0xDA' => '\'\'', |
|
| 3130 | + '0xDB' => '\'\'', '0xDC' => '\'\'', '0xDD' => '\'\'', |
|
| 3131 | + '0xDE' => '\'\'', '0xDF' => '\'\'', '0xFB' => '0xD792', |
|
| 3132 | + '0xFC' => '0xE282AC', '0xFF' => '0xD6B2', '0xC2' => '0xFF', |
|
| 3133 | + '0x80' => '0xFC', '0xE2' => '0xFB', '0xA0' => '0xC2A0', |
|
| 3134 | + '0xA1' => '0xC2A1', '0xA2' => '0xC2A2', '0xA3' => '0xC2A3', |
|
| 3135 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 3136 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 3137 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 3138 | + '0xAF' => '0xC2AF', '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', |
|
| 3139 | + '0xB2' => '0xC2B2', '0xB3' => '0xC2B3', '0xB4' => '0xC2B4', |
|
| 3140 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 3141 | + '0xB8' => '0xC2B8', '0xB9' => '0xC2B9', '0xBB' => '0xC2BB', |
|
| 3142 | + '0xBC' => '0xC2BC', '0xBD' => '0xC2BD', '0xBE' => '0xC2BE', |
|
| 3143 | + '0xBF' => '0xC2BF', '0xD7' => '0xD7B3', '0xD1' => '0xD781', |
|
| 3144 | + '0xD4' => '0xD7B0', '0xD5' => '0xD7B1', '0xD6' => '0xD7B2', |
|
| 3145 | + '0xE0' => '0xD790', '0xEA' => '0xD79A', '0xEC' => '0xD79C', |
|
| 3146 | + '0xED' => '0xD79D', '0xEE' => '0xD79E', '0xEF' => '0xD79F', |
|
| 3147 | + '0xF0' => '0xD7A0', '0xF1' => '0xD7A1', '0xF2' => '0xD7A2', |
|
| 3148 | + '0xF3' => '0xD7A3', '0xF5' => '0xD7A5', '0xF6' => '0xD7A6', |
|
| 3149 | + '0xF7' => '0xD7A7', '0xF8' => '0xD7A8', '0xF9' => '0xD7A9', |
|
| 3150 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 3151 | + '0x86' => '0xE280A0', '0x87' => '0xE280A1', '0x89' => '0xE280B0', |
|
| 3152 | + '0x8B' => '0xE280B9', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 3153 | + '0x95' => '0xE280A2', '0x97' => '0xE28094', '0x99' => '0xE284A2', |
|
| 3154 | + '0xC0' => '0xD6B0', '0xC1' => '0xD6B1', '0xC3' => '0xD6B3', |
|
| 3155 | + '0xC4' => '0xD6B4', '0xC5' => '0xD6B5', '0xC6' => '0xD6B6', |
|
| 3156 | + '0xC7' => '0xD6B7', '0xC8' => '0xD6B8', '0xC9' => '0xD6B9', |
|
| 3157 | + '0xCB' => '0xD6BB', '0xCC' => '0xD6BC', '0xCD' => '0xD6BD', |
|
| 3158 | + '0xCE' => '0xD6BE', '0xCF' => '0xD6BF', '0xD0' => '0xD780', |
|
| 3159 | + '0xD2' => '0xD782', '0xE3' => '0xD793', '0xE4' => '0xD794', |
|
| 3160 | + '0xE5' => '0xD795', '0xE7' => '0xD797', '0xE9' => '0xD799', |
|
| 3161 | + '0xFD' => '0xE2808E', '0xFE' => '0xE2808F', '0x92' => '0xE28099', |
|
| 3162 | + '0x83' => '0xC692', '0xD3' => '0xD783', '0x88' => '0xCB86', |
|
| 3163 | + '0x98' => '0xCB9C', '0x91' => '0xE28098', '0x96' => '0xE28093', |
|
| 3164 | + '0xBA' => '0xC3B7', '0x9B' => '0xE280BA', '0xAA' => '0xC397', |
|
| 3165 | + '0xA4' => '0xE282AA', '0xE1' => '0xD791', '0xE6' => '0xD796', |
|
| 3166 | + '0xE8' => '0xD798', '0xEB' => '0xD79B', '0xF4' => '0xD7A4', |
|
| 3167 | 3167 | '0xFA' => '0xD7AA', |
| 3168 | 3168 | ), |
| 3169 | 3169 | 'windows-1253' => array( |
| 3170 | - '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 3171 | - '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 3172 | - '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 3173 | - '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 3174 | - '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 3175 | - '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 3176 | - '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 3177 | - '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 3178 | - '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 3179 | - '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 3180 | - '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 3181 | - '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 3182 | - '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 3183 | - '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 3184 | - '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 3185 | - '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 3186 | - '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 3187 | - '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 3188 | - '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 3189 | - '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 3190 | - '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 3191 | - '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 3192 | - '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 3193 | - '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 3194 | - '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 3195 | - '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 3196 | - '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 3197 | - '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 3198 | - '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 3199 | - '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 3200 | - '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 3201 | - '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 3202 | - '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 3203 | - '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 3204 | - '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 3205 | - '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 3206 | - '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 3207 | - '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 3208 | - '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 3209 | - '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 3210 | - '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 3211 | - '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 3212 | - '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 3170 | + '0x81' => '\'\'', '0x88' => '\'\'', '0x8A' => '\'\'', |
|
| 3171 | + '0x8C' => '\'\'', '0x8D' => '\'\'', '0x8E' => '\'\'', |
|
| 3172 | + '0x8F' => '\'\'', '0x90' => '\'\'', '0x98' => '\'\'', |
|
| 3173 | + '0x9A' => '\'\'', '0x9C' => '\'\'', '0x9D' => '\'\'', |
|
| 3174 | + '0x9E' => '\'\'', '0x9F' => '\'\'', '0xAA' => '\'\'', |
|
| 3175 | + '0xD2' => '0xE282AC', '0xFF' => '0xCE92', '0xCE' => '0xCE9E', |
|
| 3176 | + '0xB8' => '0xCE88', '0xBA' => '0xCE8A', '0xBC' => '0xCE8C', |
|
| 3177 | + '0xBE' => '0xCE8E', '0xBF' => '0xCE8F', '0xC0' => '0xCE90', |
|
| 3178 | + '0xC8' => '0xCE98', '0xCA' => '0xCE9A', '0xCC' => '0xCE9C', |
|
| 3179 | + '0xCD' => '0xCE9D', '0xCF' => '0xCE9F', '0xDA' => '0xCEAA', |
|
| 3180 | + '0xE8' => '0xCEB8', '0xEA' => '0xCEBA', '0xEC' => '0xCEBC', |
|
| 3181 | + '0xEE' => '0xCEBE', '0xEF' => '0xCEBF', '0xC2' => '0xFF', |
|
| 3182 | + '0xBD' => '0xC2BD', '0xED' => '0xCEBD', '0xB2' => '0xC2B2', |
|
| 3183 | + '0xA0' => '0xC2A0', '0xA3' => '0xC2A3', '0xA4' => '0xC2A4', |
|
| 3184 | + '0xA5' => '0xC2A5', '0xA6' => '0xC2A6', '0xA7' => '0xC2A7', |
|
| 3185 | + '0xA8' => '0xC2A8', '0xA9' => '0xC2A9', '0xAB' => '0xC2AB', |
|
| 3186 | + '0xAC' => '0xC2AC', '0xAD' => '0xC2AD', '0xAE' => '0xC2AE', |
|
| 3187 | + '0xB0' => '0xC2B0', '0xB1' => '0xC2B1', '0xB3' => '0xC2B3', |
|
| 3188 | + '0xB5' => '0xC2B5', '0xB6' => '0xC2B6', '0xB7' => '0xC2B7', |
|
| 3189 | + '0xBB' => '0xC2BB', '0xE2' => '0xCEB2', '0x80' => '0xD2', |
|
| 3190 | + '0x82' => '0xE2809A', '0x84' => '0xE2809E', '0x85' => '0xE280A6', |
|
| 3191 | + '0x86' => '0xE280A0', '0xA1' => '0xCE85', '0xA2' => '0xCE86', |
|
| 3192 | + '0x87' => '0xE280A1', '0x89' => '0xE280B0', '0xB9' => '0xCE89', |
|
| 3193 | + '0x8B' => '0xE280B9', '0x91' => '0xE28098', '0x99' => '0xE284A2', |
|
| 3194 | + '0x92' => '0xE28099', '0x93' => '0xE2809C', '0x94' => '0xE2809D', |
|
| 3195 | + '0x95' => '0xE280A2', '0x96' => '0xE28093', '0x97' => '0xE28094', |
|
| 3196 | + '0x9B' => '0xE280BA', '0xAF' => '0xE28095', '0xB4' => '0xCE84', |
|
| 3197 | + '0xC1' => '0xCE91', '0xC3' => '0xCE93', '0xC4' => '0xCE94', |
|
| 3198 | + '0xC5' => '0xCE95', '0xC6' => '0xCE96', '0x83' => '0xC692', |
|
| 3199 | + '0xC7' => '0xCE97', '0xC9' => '0xCE99', '0xCB' => '0xCE9B', |
|
| 3200 | + '0xD0' => '0xCEA0', '0xD1' => '0xCEA1', '0xD3' => '0xCEA3', |
|
| 3201 | + '0xD4' => '0xCEA4', '0xD5' => '0xCEA5', '0xD6' => '0xCEA6', |
|
| 3202 | + '0xD7' => '0xCEA7', '0xD8' => '0xCEA8', '0xD9' => '0xCEA9', |
|
| 3203 | + '0xDB' => '0xCEAB', '0xDC' => '0xCEAC', '0xDD' => '0xCEAD', |
|
| 3204 | + '0xDE' => '0xCEAE', '0xDF' => '0xCEAF', '0xE0' => '0xCEB0', |
|
| 3205 | + '0xE1' => '0xCEB1', '0xE3' => '0xCEB3', '0xE4' => '0xCEB4', |
|
| 3206 | + '0xE5' => '0xCEB5', '0xE6' => '0xCEB6', '0xE7' => '0xCEB7', |
|
| 3207 | + '0xE9' => '0xCEB9', '0xEB' => '0xCEBB', '0xF0' => '0xCF80', |
|
| 3208 | + '0xF1' => '0xCF81', '0xF2' => '0xCF82', '0xF3' => '0xCF83', |
|
| 3209 | + '0xF4' => '0xCF84', '0xF5' => '0xCF85', '0xF6' => '0xCF86', |
|
| 3210 | + '0xF7' => '0xCF87', '0xF8' => '0xCF88', '0xF9' => '0xCF89', |
|
| 3211 | + '0xFA' => '0xCF8A', '0xFB' => '0xCF8B', '0xFC' => '0xCF8C', |
|
| 3212 | + '0xFD' => '0xCF8D', '0xFE' => '0xCF8E', |
|
| 3213 | 3213 | ), |
| 3214 | 3214 | ); |
| 3215 | 3215 | |
@@ -390,6 +390,9 @@ discard block |
||
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | // Used to direct the user to another location. |
| 393 | +/** |
|
| 394 | + * @param string $location |
|
| 395 | + */ |
|
| 393 | 396 | function redirectLocation($location, $addForm = true) |
| 394 | 397 | { |
| 395 | 398 | global $upgradeurl, $upcontext, $command_line; |
@@ -1719,6 +1722,9 @@ discard block |
||
| 1719 | 1722 | return addslashes(preg_replace(array('~^\.([/\\\]|$)~', '~[/]+~', '~[\\\]+~', '~[/\\\]$~'), array($install_path . '$1', '/', '\\', ''), $path)); |
| 1720 | 1723 | } |
| 1721 | 1724 | |
| 1725 | +/** |
|
| 1726 | + * @param string $filename |
|
| 1727 | + */ |
|
| 1722 | 1728 | function parse_sql($filename) |
| 1723 | 1729 | { |
| 1724 | 1730 | global $db_prefix, $db_collation, $boarddir, $boardurl, $command_line, $file_steps, $step_progress, $custom_warning; |
@@ -2005,6 +2011,9 @@ discard block |
||
| 2005 | 2011 | return true; |
| 2006 | 2012 | } |
| 2007 | 2013 | |
| 2014 | +/** |
|
| 2015 | + * @param string $string |
|
| 2016 | + */ |
|
| 2008 | 2017 | function upgrade_query($string, $unbuffered = false) |
| 2009 | 2018 | { |
| 2010 | 2019 | global $db_connection, $db_server, $db_user, $db_passwd, $db_type, $command_line, $upcontext, $upgradeurl, $modSettings; |
@@ -4675,7 +4684,7 @@ discard block |
||
| 4675 | 4684 | * @param int $setSize The amount of entries after which to update the database. |
| 4676 | 4685 | * |
| 4677 | 4686 | * newCol needs to be a varbinary(16) null able field |
| 4678 | - * @return bool |
|
| 4687 | + * @return boolean|null |
|
| 4679 | 4688 | */ |
| 4680 | 4689 | function MySQLConvertOldIp($targetTable, $oldCol, $newCol, $limit = 50000, $setSize = 100) |
| 4681 | 4690 | { |
@@ -100,11 +100,14 @@ discard block |
||
| 100 | 100 | ini_set('default_socket_timeout', 900); |
| 101 | 101 | } |
| 102 | 102 | // 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++) |
|
| 103 | +if (!empty($_SERVER['argv']) && php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { |
|
| 104 | + for ($i = 1; |
|
| 105 | +} |
|
| 106 | +$i < $_SERVER['argc']; $i++) |
|
| 105 | 107 | { |
| 106 | - if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) |
|
| 107 | - $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 108 | + if (preg_match('~^--path=(.+)$~', $_SERVER['argv'][$i], $match) != 0) { |
|
| 109 | + $upgrade_path = substr($match[1], -1) == '/' ? substr($match[1], 0, -1) : $match[1]; |
|
| 110 | + } |
|
| 108 | 111 | } |
| 109 | 112 | |
| 110 | 113 | // Are we from the client? |
@@ -112,9 +115,9 @@ discard block |
||
| 112 | 115 | { |
| 113 | 116 | $command_line = true; |
| 114 | 117 | $disable_security = 1; |
| 115 | -} |
|
| 116 | -else |
|
| 118 | +} else { |
|
| 117 | 119 | $command_line = false; |
| 120 | +} |
|
| 118 | 121 | |
| 119 | 122 | // Load this now just because we can. |
| 120 | 123 | require_once($upgrade_path . '/Settings.php'); |
@@ -129,10 +132,12 @@ discard block |
||
| 129 | 132 | $upcontext['user'] = unserialize(base64_decode($upgradeData)); |
| 130 | 133 | |
| 131 | 134 | // 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; |
|
| 135 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
| 136 | + $upcontext['user']['started'] = time(); |
|
| 137 | + } |
|
| 138 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
| 139 | + $upcontext['user']['updated'] = 0; |
|
| 140 | + } |
|
| 136 | 141 | |
| 137 | 142 | $upcontext['started'] = $upcontext['user']['started']; |
| 138 | 143 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -189,8 +194,9 @@ discard block |
||
| 189 | 194 | 'db_error_skip' => true, |
| 190 | 195 | ) |
| 191 | 196 | ); |
| 192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 193 | - $modSettings[$row['variable']] = $row['value']; |
|
| 197 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 198 | + $modSettings[$row['variable']] = $row['value']; |
|
| 199 | + } |
|
| 194 | 200 | $smcFunc['db_free_result']($request); |
| 195 | 201 | } |
| 196 | 202 | |
@@ -200,10 +206,12 @@ discard block |
||
| 200 | 206 | $modSettings['theme_url'] = 'Themes/default'; |
| 201 | 207 | $modSettings['images_url'] = 'Themes/default/images'; |
| 202 | 208 | } |
| 203 | -if (!isset($settings['default_theme_url'])) |
|
| 209 | +if (!isset($settings['default_theme_url'])) { |
|
| 204 | 210 | $settings['default_theme_url'] = $modSettings['theme_url']; |
| 205 | -if (!isset($settings['default_theme_dir'])) |
|
| 211 | +} |
|
| 212 | +if (!isset($settings['default_theme_dir'])) { |
|
| 206 | 213 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
| 214 | +} |
|
| 207 | 215 | |
| 208 | 216 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
| 209 | 217 | // Default title... |
@@ -221,13 +229,15 @@ discard block |
||
| 221 | 229 | $support_js = $upcontext['upgrade_status']['js']; |
| 222 | 230 | |
| 223 | 231 | // Only set this if the upgrader status says so. |
| 224 | - if (empty($is_debug)) |
|
| 225 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 232 | + if (empty($is_debug)) { |
|
| 233 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
| 234 | + } |
|
| 226 | 235 | |
| 227 | 236 | // Load the language. |
| 228 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 229 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 230 | -} |
|
| 237 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 238 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 239 | + } |
|
| 240 | + } |
|
| 231 | 241 | // Set the defaults. |
| 232 | 242 | else |
| 233 | 243 | { |
@@ -245,15 +255,18 @@ discard block |
||
| 245 | 255 | } |
| 246 | 256 | |
| 247 | 257 | // If this isn't the first stage see whether they are logging in and resuming. |
| 248 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
| 258 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
| 249 | 259 | checkLogin(); |
| 260 | +} |
|
| 250 | 261 | |
| 251 | -if ($command_line) |
|
| 262 | +if ($command_line) { |
|
| 252 | 263 | cmdStep0(); |
| 264 | +} |
|
| 253 | 265 | |
| 254 | 266 | // Don't error if we're using xml. |
| 255 | -if (isset($_GET['xml'])) |
|
| 267 | +if (isset($_GET['xml'])) { |
|
| 256 | 268 | $upcontext['return_error'] = true; |
| 269 | +} |
|
| 257 | 270 | |
| 258 | 271 | // Loop through all the steps doing each one as required. |
| 259 | 272 | $upcontext['overall_percent'] = 0; |
@@ -274,10 +287,11 @@ discard block |
||
| 274 | 287 | } |
| 275 | 288 | |
| 276 | 289 | // Call the step and if it returns false that means pause! |
| 277 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 278 | - break; |
|
| 279 | - elseif (function_exists($step[2])) |
|
| 280 | - $upcontext['current_step']++; |
|
| 290 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 291 | + break; |
|
| 292 | + } elseif (function_exists($step[2])) { |
|
| 293 | + $upcontext['current_step']++; |
|
| 294 | + } |
|
| 281 | 295 | } |
| 282 | 296 | $upcontext['overall_percent'] += $step[3]; |
| 283 | 297 | } |
@@ -316,17 +330,18 @@ discard block |
||
| 316 | 330 | // This should not happen my dear... HELP ME DEVELOPERS!! |
| 317 | 331 | if (!empty($command_line)) |
| 318 | 332 | { |
| 319 | - if (function_exists('debug_print_backtrace')) |
|
| 320 | - debug_print_backtrace(); |
|
| 333 | + if (function_exists('debug_print_backtrace')) { |
|
| 334 | + debug_print_backtrace(); |
|
| 335 | + } |
|
| 321 | 336 | |
| 322 | 337 | 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.'; |
| 323 | 338 | flush(); |
| 324 | 339 | die(); |
| 325 | 340 | } |
| 326 | 341 | |
| 327 | - if (!isset($_GET['xml'])) |
|
| 328 | - template_upgrade_above(); |
|
| 329 | - else |
|
| 342 | + if (!isset($_GET['xml'])) { |
|
| 343 | + template_upgrade_above(); |
|
| 344 | + } else |
|
| 330 | 345 | { |
| 331 | 346 | header('Content-Type: text/xml; charset=UTF-8'); |
| 332 | 347 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -348,21 +363,24 @@ discard block |
||
| 348 | 363 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(safe_serialize($upcontext['upgrade_status'])); |
| 349 | 364 | |
| 350 | 365 | // Custom stuff to pass back? |
| 351 | - if (!empty($upcontext['query_string'])) |
|
| 352 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 366 | + if (!empty($upcontext['query_string'])) { |
|
| 367 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
| 368 | + } |
|
| 353 | 369 | |
| 354 | 370 | call_user_func('template_' . $upcontext['sub_template']); |
| 355 | 371 | } |
| 356 | 372 | |
| 357 | 373 | // Was there an error? |
| 358 | - if (!empty($upcontext['forced_error_message'])) |
|
| 359 | - echo $upcontext['forced_error_message']; |
|
| 374 | + if (!empty($upcontext['forced_error_message'])) { |
|
| 375 | + echo $upcontext['forced_error_message']; |
|
| 376 | + } |
|
| 360 | 377 | |
| 361 | 378 | // Show the footer. |
| 362 | - if (!isset($_GET['xml'])) |
|
| 363 | - template_upgrade_below(); |
|
| 364 | - else |
|
| 365 | - template_xml_below(); |
|
| 379 | + if (!isset($_GET['xml'])) { |
|
| 380 | + template_upgrade_below(); |
|
| 381 | + } else { |
|
| 382 | + template_xml_below(); |
|
| 383 | + } |
|
| 366 | 384 | } |
| 367 | 385 | |
| 368 | 386 | |
@@ -374,15 +392,19 @@ discard block |
||
| 374 | 392 | $seconds = intval($active % 60); |
| 375 | 393 | |
| 376 | 394 | $totalTime = ''; |
| 377 | - if ($hours > 0) |
|
| 378 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 379 | - if ($minutes > 0) |
|
| 380 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 381 | - if ($seconds > 0) |
|
| 382 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 395 | + if ($hours > 0) { |
|
| 396 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 397 | + } |
|
| 398 | + if ($minutes > 0) { |
|
| 399 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 400 | + } |
|
| 401 | + if ($seconds > 0) { |
|
| 402 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 403 | + } |
|
| 383 | 404 | |
| 384 | - if (!empty($totalTime)) |
|
| 385 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 405 | + if (!empty($totalTime)) { |
|
| 406 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
| 407 | + } |
|
| 386 | 408 | } |
| 387 | 409 | |
| 388 | 410 | // Bang - gone! |
@@ -395,8 +417,9 @@ discard block |
||
| 395 | 417 | global $upgradeurl, $upcontext, $command_line; |
| 396 | 418 | |
| 397 | 419 | // Command line users can't be redirected. |
| 398 | - if ($command_line) |
|
| 399 | - upgradeExit(true); |
|
| 420 | + if ($command_line) { |
|
| 421 | + upgradeExit(true); |
|
| 422 | + } |
|
| 400 | 423 | |
| 401 | 424 | // Are we providing the core info? |
| 402 | 425 | if ($addForm) |
@@ -419,19 +442,22 @@ discard block |
||
| 419 | 442 | global $modSettings, $sourcedir, $smcFunc; |
| 420 | 443 | |
| 421 | 444 | // Do the non-SSI stuff... |
| 422 | - if (function_exists('set_magic_quotes_runtime')) |
|
| 423 | - @set_magic_quotes_runtime(0); |
|
| 445 | + if (function_exists('set_magic_quotes_runtime')) { |
|
| 446 | + @set_magic_quotes_runtime(0); |
|
| 447 | + } |
|
| 424 | 448 | |
| 425 | 449 | error_reporting(E_ALL); |
| 426 | 450 | define('SMF', 1); |
| 427 | 451 | |
| 428 | 452 | // Start the session. |
| 429 | - if (@ini_get('session.save_handler') == 'user') |
|
| 430 | - @ini_set('session.save_handler', 'files'); |
|
| 453 | + if (@ini_get('session.save_handler') == 'user') { |
|
| 454 | + @ini_set('session.save_handler', 'files'); |
|
| 455 | + } |
|
| 431 | 456 | @session_start(); |
| 432 | 457 | |
| 433 | - if (empty($smcFunc)) |
|
| 434 | - $smcFunc = array(); |
|
| 458 | + if (empty($smcFunc)) { |
|
| 459 | + $smcFunc = array(); |
|
| 460 | + } |
|
| 435 | 461 | |
| 436 | 462 | // We need this for authentication and some upgrade code |
| 437 | 463 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -444,8 +470,9 @@ discard block |
||
| 444 | 470 | initialize_inputs(); |
| 445 | 471 | |
| 446 | 472 | // Get the database going! |
| 447 | - if (empty($db_type)) |
|
| 448 | - $db_type = 'mysqli'; |
|
| 473 | + if (empty($db_type)) { |
|
| 474 | + $db_type = 'mysqli'; |
|
| 475 | + } |
|
| 449 | 476 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
| 450 | 477 | { |
| 451 | 478 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -454,17 +481,19 @@ discard block |
||
| 454 | 481 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
| 455 | 482 | |
| 456 | 483 | // Oh dear god!! |
| 457 | - if ($db_connection === null) |
|
| 458 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 484 | + if ($db_connection === null) { |
|
| 485 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
| 486 | + } |
|
| 459 | 487 | |
| 460 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
| 461 | - $smcFunc['db_query']('', ' |
|
| 488 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
| 489 | + $smcFunc['db_query']('', ' |
|
| 462 | 490 | SET NAMES {string:db_character_set}', |
| 463 | 491 | array( |
| 464 | 492 | 'db_error_skip' => true, |
| 465 | 493 | 'db_character_set' => $db_character_set, |
| 466 | 494 | ) |
| 467 | 495 | ); |
| 496 | + } |
|
| 468 | 497 | |
| 469 | 498 | // Load the modSettings data... |
| 470 | 499 | $request = $smcFunc['db_query']('', ' |
@@ -475,11 +504,11 @@ discard block |
||
| 475 | 504 | ) |
| 476 | 505 | ); |
| 477 | 506 | $modSettings = array(); |
| 478 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 479 | - $modSettings[$row['variable']] = $row['value']; |
|
| 507 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 508 | + $modSettings[$row['variable']] = $row['value']; |
|
| 509 | + } |
|
| 480 | 510 | $smcFunc['db_free_result']($request); |
| 481 | - } |
|
| 482 | - else |
|
| 511 | + } else |
|
| 483 | 512 | { |
| 484 | 513 | 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.'); |
| 485 | 514 | } |
@@ -493,9 +522,10 @@ discard block |
||
| 493 | 522 | cleanRequest(); |
| 494 | 523 | } |
| 495 | 524 | |
| 496 | - if (!isset($_GET['substep'])) |
|
| 497 | - $_GET['substep'] = 0; |
|
| 498 | -} |
|
| 525 | + if (!isset($_GET['substep'])) { |
|
| 526 | + $_GET['substep'] = 0; |
|
| 527 | + } |
|
| 528 | + } |
|
| 499 | 529 | |
| 500 | 530 | function initialize_inputs() |
| 501 | 531 | { |
@@ -527,8 +557,9 @@ discard block |
||
| 527 | 557 | $dh = opendir(dirname(__FILE__)); |
| 528 | 558 | while ($file = readdir($dh)) |
| 529 | 559 | { |
| 530 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
| 531 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
| 560 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
| 561 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
| 562 | + } |
|
| 532 | 563 | } |
| 533 | 564 | closedir($dh); |
| 534 | 565 | |
@@ -558,8 +589,9 @@ discard block |
||
| 558 | 589 | { |
| 559 | 590 | $upcontext['remote_files_available'] = false; |
| 560 | 591 | $test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1); |
| 561 | - if ($test) |
|
| 562 | - $upcontext['remote_files_available'] = true; |
|
| 592 | + if ($test) { |
|
| 593 | + $upcontext['remote_files_available'] = true; |
|
| 594 | + } |
|
| 563 | 595 | @fclose($test); |
| 564 | 596 | } |
| 565 | 597 | |
@@ -567,8 +599,9 @@ discard block |
||
| 567 | 599 | $temp = 'upgrade_php?step'; |
| 568 | 600 | while (strlen($temp) > 4) |
| 569 | 601 | { |
| 570 | - if (isset($_GET[$temp])) |
|
| 571 | - unset($_GET[$temp]); |
|
| 602 | + if (isset($_GET[$temp])) { |
|
| 603 | + unset($_GET[$temp]); |
|
| 604 | + } |
|
| 572 | 605 | $temp = substr($temp, 1); |
| 573 | 606 | } |
| 574 | 607 | |
@@ -597,29 +630,36 @@ discard block |
||
| 597 | 630 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $type . '.sql'); |
| 598 | 631 | |
| 599 | 632 | // Need legacy scripts? |
| 600 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
| 601 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql'); |
|
| 602 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
| 603 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 604 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
| 605 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 633 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
| 634 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $type . '.sql'); |
|
| 635 | + } |
|
| 636 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
| 637 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
| 638 | + } |
|
| 639 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
| 640 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
| 641 | + } |
|
| 606 | 642 | |
| 607 | 643 | // This needs to exist! |
| 608 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 609 | - 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>]'); |
|
| 610 | - else |
|
| 611 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 644 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 645 | + 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>]'); |
|
| 646 | + } else { |
|
| 647 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
| 648 | + } |
|
| 612 | 649 | |
| 613 | - if (!$check) |
|
| 614 | - // 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. |
|
| 650 | + if (!$check) { |
|
| 651 | + // 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. |
|
| 615 | 652 | 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.'); |
| 653 | + } |
|
| 616 | 654 | |
| 617 | 655 | // Do they meet the install requirements? |
| 618 | - if (!php_version_check()) |
|
| 619 | - 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.'); |
|
| 656 | + if (!php_version_check()) { |
|
| 657 | + 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.'); |
|
| 658 | + } |
|
| 620 | 659 | |
| 621 | - if (!db_version_check()) |
|
| 622 | - 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.'); |
|
| 660 | + if (!db_version_check()) { |
|
| 661 | + 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.'); |
|
| 662 | + } |
|
| 623 | 663 | |
| 624 | 664 | // Do some checks to make sure they have proper privileges |
| 625 | 665 | db_extend('packages'); |
@@ -634,14 +674,16 @@ discard block |
||
| 634 | 674 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 635 | 675 | |
| 636 | 676 | // Sorry... we need CREATE, ALTER and DROP |
| 637 | - if (!$create || !$alter || !$drop) |
|
| 638 | - 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.'); |
|
| 677 | + if (!$create || !$alter || !$drop) { |
|
| 678 | + 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.'); |
|
| 679 | + } |
|
| 639 | 680 | |
| 640 | 681 | // Do a quick version spot check. |
| 641 | 682 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 642 | 683 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 643 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 644 | - 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.'); |
|
| 684 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 685 | + 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.'); |
|
| 686 | + } |
|
| 645 | 687 | |
| 646 | 688 | // What absolutely needs to be writable? |
| 647 | 689 | $writable_files = array( |
@@ -663,12 +705,13 @@ discard block |
||
| 663 | 705 | quickFileWritable($custom_av_dir); |
| 664 | 706 | |
| 665 | 707 | // Are we good now? |
| 666 | - if (!is_writable($custom_av_dir)) |
|
| 667 | - 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)); |
|
| 668 | - elseif ($need_settings_update) |
|
| 708 | + if (!is_writable($custom_av_dir)) { |
|
| 709 | + 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)); |
|
| 710 | + } elseif ($need_settings_update) |
|
| 669 | 711 | { |
| 670 | - if (!function_exists('cache_put_data')) |
|
| 671 | - require_once($sourcedir . '/Load.php'); |
|
| 712 | + if (!function_exists('cache_put_data')) { |
|
| 713 | + require_once($sourcedir . '/Load.php'); |
|
| 714 | + } |
|
| 672 | 715 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
| 673 | 716 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
| 674 | 717 | } |
@@ -677,28 +720,33 @@ discard block |
||
| 677 | 720 | |
| 678 | 721 | // Check the cache directory. |
| 679 | 722 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 680 | - if (!file_exists($cachedir_temp)) |
|
| 681 | - @mkdir($cachedir_temp); |
|
| 682 | - if (!file_exists($cachedir_temp)) |
|
| 683 | - 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.'); |
|
| 684 | - |
|
| 685 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 686 | - 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>.'); |
|
| 687 | - elseif (!isset($_GET['skiplang'])) |
|
| 723 | + if (!file_exists($cachedir_temp)) { |
|
| 724 | + @mkdir($cachedir_temp); |
|
| 725 | + } |
|
| 726 | + if (!file_exists($cachedir_temp)) { |
|
| 727 | + 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.'); |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 731 | + 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>.'); |
|
| 732 | + } elseif (!isset($_GET['skiplang'])) |
|
| 688 | 733 | { |
| 689 | 734 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 690 | 735 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 691 | 736 | |
| 692 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 693 | - 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>]'); |
|
| 737 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 738 | + 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>]'); |
|
| 739 | + } |
|
| 694 | 740 | } |
| 695 | 741 | |
| 696 | - if (!makeFilesWritable($writable_files)) |
|
| 697 | - return false; |
|
| 742 | + if (!makeFilesWritable($writable_files)) { |
|
| 743 | + return false; |
|
| 744 | + } |
|
| 698 | 745 | |
| 699 | 746 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
| 700 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 701 | - 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.'); |
|
| 747 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 748 | + 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.'); |
|
| 749 | + } |
|
| 702 | 750 | |
| 703 | 751 | // Upgrade the agreement. |
| 704 | 752 | elseif (isset($modSettings['agreement'])) |
@@ -709,8 +757,8 @@ discard block |
||
| 709 | 757 | } |
| 710 | 758 | |
| 711 | 759 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
| 712 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
| 713 | - $upcontext['warning'] = ' |
|
| 760 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
| 761 | + $upcontext['warning'] = ' |
|
| 714 | 762 | 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> |
| 715 | 763 | <ul> |
| 716 | 764 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -718,10 +766,12 @@ discard block |
||
| 718 | 766 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
| 719 | 767 | </ul> |
| 720 | 768 | 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="http://download.simplemachines.org/?tools">Repair Settings</a> tool from the Simple Machines website before continuing.'; |
| 769 | + } |
|
| 721 | 770 | |
| 722 | 771 | // Either we're logged in or we're going to present the login. |
| 723 | - if (checkLogin()) |
|
| 724 | - return true; |
|
| 772 | + if (checkLogin()) { |
|
| 773 | + return true; |
|
| 774 | + } |
|
| 725 | 775 | |
| 726 | 776 | $upcontext += createToken('login'); |
| 727 | 777 | |
@@ -735,15 +785,17 @@ discard block |
||
| 735 | 785 | global $smcFunc, $db_type, $support_js; |
| 736 | 786 | |
| 737 | 787 | // Don't bother if the security is disabled. |
| 738 | - if ($disable_security) |
|
| 739 | - return true; |
|
| 788 | + if ($disable_security) { |
|
| 789 | + return true; |
|
| 790 | + } |
|
| 740 | 791 | |
| 741 | 792 | // Are we trying to login? |
| 742 | 793 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
| 743 | 794 | { |
| 744 | 795 | // If we've disabled security pick a suitable name! |
| 745 | - if (empty($_POST['user'])) |
|
| 746 | - $_POST['user'] = 'Administrator'; |
|
| 796 | + if (empty($_POST['user'])) { |
|
| 797 | + $_POST['user'] = 'Administrator'; |
|
| 798 | + } |
|
| 747 | 799 | |
| 748 | 800 | // Before 2.0 these column names were different! |
| 749 | 801 | $oldDB = false; |
@@ -758,16 +810,17 @@ discard block |
||
| 758 | 810 | 'db_error_skip' => true, |
| 759 | 811 | ) |
| 760 | 812 | ); |
| 761 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 762 | - $oldDB = true; |
|
| 813 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 814 | + $oldDB = true; |
|
| 815 | + } |
|
| 763 | 816 | $smcFunc['db_free_result']($request); |
| 764 | 817 | } |
| 765 | 818 | |
| 766 | 819 | // Get what we believe to be their details. |
| 767 | 820 | if (!$disable_security) |
| 768 | 821 | { |
| 769 | - if ($oldDB) |
|
| 770 | - $request = $smcFunc['db_query']('', ' |
|
| 822 | + if ($oldDB) { |
|
| 823 | + $request = $smcFunc['db_query']('', ' |
|
| 771 | 824 | SELECT id_member, memberName AS member_name, passwd, id_group, |
| 772 | 825 | additionalGroups AS additional_groups, lngfile |
| 773 | 826 | FROM {db_prefix}members |
@@ -777,8 +830,8 @@ discard block |
||
| 777 | 830 | 'db_error_skip' => true, |
| 778 | 831 | ) |
| 779 | 832 | ); |
| 780 | - else |
|
| 781 | - $request = $smcFunc['db_query']('', ' |
|
| 833 | + } else { |
|
| 834 | + $request = $smcFunc['db_query']('', ' |
|
| 782 | 835 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
| 783 | 836 | FROM {db_prefix}members |
| 784 | 837 | WHERE member_name = {string:member_name}', |
@@ -787,6 +840,7 @@ discard block |
||
| 787 | 840 | 'db_error_skip' => true, |
| 788 | 841 | ) |
| 789 | 842 | ); |
| 843 | + } |
|
| 790 | 844 | if ($smcFunc['db_num_rows']($request) != 0) |
| 791 | 845 | { |
| 792 | 846 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -794,13 +848,14 @@ discard block |
||
| 794 | 848 | $groups = explode(',', $addGroups); |
| 795 | 849 | $groups[] = $id_group; |
| 796 | 850 | |
| 797 | - foreach ($groups as $k => $v) |
|
| 798 | - $groups[$k] = (int) $v; |
|
| 851 | + foreach ($groups as $k => $v) { |
|
| 852 | + $groups[$k] = (int) $v; |
|
| 853 | + } |
|
| 799 | 854 | |
| 800 | 855 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
| 856 | + } else { |
|
| 857 | + $upcontext['username_incorrect'] = true; |
|
| 801 | 858 | } |
| 802 | - else |
|
| 803 | - $upcontext['username_incorrect'] = true; |
|
| 804 | 859 | $smcFunc['db_free_result']($request); |
| 805 | 860 | } |
| 806 | 861 | $upcontext['username'] = $_POST['user']; |
@@ -810,13 +865,14 @@ discard block |
||
| 810 | 865 | { |
| 811 | 866 | $upcontext['upgrade_status']['js'] = 1; |
| 812 | 867 | $support_js = 1; |
| 868 | + } else { |
|
| 869 | + $support_js = 0; |
|
| 813 | 870 | } |
| 814 | - else |
|
| 815 | - $support_js = 0; |
|
| 816 | 871 | |
| 817 | 872 | // Note down the version we are coming from. |
| 818 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
| 819 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 873 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
| 874 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
| 875 | + } |
|
| 820 | 876 | |
| 821 | 877 | // Didn't get anywhere? |
| 822 | 878 | 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'])) |
@@ -850,15 +906,15 @@ discard block |
||
| 850 | 906 | 'db_error_skip' => true, |
| 851 | 907 | ) |
| 852 | 908 | ); |
| 853 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 854 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 909 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 910 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
| 911 | + } |
|
| 855 | 912 | $smcFunc['db_free_result']($request); |
| 856 | 913 | } |
| 857 | 914 | |
| 858 | 915 | $upcontext['user']['id'] = $id_member; |
| 859 | 916 | $upcontext['user']['name'] = $name; |
| 860 | - } |
|
| 861 | - else |
|
| 917 | + } else |
|
| 862 | 918 | { |
| 863 | 919 | $upcontext['user']['id'] = 1; |
| 864 | 920 | $upcontext['user']['name'] = 'Administrator'; |
@@ -874,11 +930,11 @@ discard block |
||
| 874 | 930 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
| 875 | 931 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 876 | 932 | |
| 877 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 878 | - $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'] . '.'; |
|
| 879 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
| 880 | - $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'] . '.'; |
|
| 881 | - else |
|
| 933 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 934 | + $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'] . '.'; |
|
| 935 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
| 936 | + $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'] . '.'; |
|
| 937 | + } else |
|
| 882 | 938 | { |
| 883 | 939 | // Set this as the new language. |
| 884 | 940 | $upcontext['language'] = $user_language; |
@@ -922,15 +978,17 @@ discard block |
||
| 922 | 978 | unset($member_columns); |
| 923 | 979 | |
| 924 | 980 | // If we've not submitted then we're done. |
| 925 | - if (empty($_POST['upcont'])) |
|
| 926 | - return false; |
|
| 981 | + if (empty($_POST['upcont'])) { |
|
| 982 | + return false; |
|
| 983 | + } |
|
| 927 | 984 | |
| 928 | 985 | require_once($sourcedir . '/Subs-Admin.php'); |
| 929 | 986 | updateSettingsFile(array('image_proxy_secret' => '\'' . substr(sha1(mt_rand()), 0, 20) . '\'')); |
| 930 | 987 | |
| 931 | 988 | // Should we update the $db_type value? |
| 932 | - if ($upcontext['update_db_type_to_mysqli']) |
|
| 933 | - updateSettingsFile(array('db_type' => '\'mysqli\'')); |
|
| 989 | + if ($upcontext['update_db_type_to_mysqli']) { |
|
| 990 | + updateSettingsFile(array('db_type' => '\'mysqli\'')); |
|
| 991 | + } |
|
| 934 | 992 | |
| 935 | 993 | // Firstly, if they're enabling SM stat collection just do it. |
| 936 | 994 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats'])) |
@@ -945,25 +1003,26 @@ discard block |
||
| 945 | 1003 | fwrite($fp, $out); |
| 946 | 1004 | |
| 947 | 1005 | $return_data = ''; |
| 948 | - while (!feof($fp)) |
|
| 949 | - $return_data .= fgets($fp, 128); |
|
| 1006 | + while (!feof($fp)) { |
|
| 1007 | + $return_data .= fgets($fp, 128); |
|
| 1008 | + } |
|
| 950 | 1009 | |
| 951 | 1010 | fclose($fp); |
| 952 | 1011 | |
| 953 | 1012 | // Get the unique site ID. |
| 954 | 1013 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 955 | 1014 | |
| 956 | - if (!empty($ID[1])) |
|
| 957 | - $smcFunc['db_insert']('replace', |
|
| 1015 | + if (!empty($ID[1])) { |
|
| 1016 | + $smcFunc['db_insert']('replace', |
|
| 958 | 1017 | $db_prefix . 'settings', |
| 959 | 1018 | array('variable' => 'string', 'value' => 'string'), |
| 960 | 1019 | array('allow_sm_stats', $ID[1]), |
| 961 | 1020 | array('variable') |
| 962 | 1021 | ); |
| 1022 | + } |
|
| 963 | 1023 | } |
| 964 | - } |
|
| 965 | - else |
|
| 966 | - $smcFunc['db_query']('', ' |
|
| 1024 | + } else { |
|
| 1025 | + $smcFunc['db_query']('', ' |
|
| 967 | 1026 | DELETE FROM {db_prefix}settings |
| 968 | 1027 | WHERE variable = {string:allow_sm_stats}', |
| 969 | 1028 | array( |
@@ -971,6 +1030,7 @@ discard block |
||
| 971 | 1030 | 'db_error_skip' => true, |
| 972 | 1031 | ) |
| 973 | 1032 | ); |
| 1033 | + } |
|
| 974 | 1034 | |
| 975 | 1035 | // Deleting old karma stuff? |
| 976 | 1036 | if (!empty($_POST['delete_karma'])) |
@@ -985,20 +1045,22 @@ discard block |
||
| 985 | 1045 | ); |
| 986 | 1046 | |
| 987 | 1047 | // Cleaning up old karma member settings. |
| 988 | - if ($upcontext['karma_installed']['good']) |
|
| 989 | - $smcFunc['db_query']('', ' |
|
| 1048 | + if ($upcontext['karma_installed']['good']) { |
|
| 1049 | + $smcFunc['db_query']('', ' |
|
| 990 | 1050 | ALTER TABLE {db_prefix}members |
| 991 | 1051 | DROP karma_good', |
| 992 | 1052 | array() |
| 993 | 1053 | ); |
| 1054 | + } |
|
| 994 | 1055 | |
| 995 | 1056 | // Does karma bad was enable? |
| 996 | - if ($upcontext['karma_installed']['bad']) |
|
| 997 | - $smcFunc['db_query']('', ' |
|
| 1057 | + if ($upcontext['karma_installed']['bad']) { |
|
| 1058 | + $smcFunc['db_query']('', ' |
|
| 998 | 1059 | ALTER TABLE {db_prefix}members |
| 999 | 1060 | DROP karma_bad', |
| 1000 | 1061 | array() |
| 1001 | 1062 | ); |
| 1063 | + } |
|
| 1002 | 1064 | |
| 1003 | 1065 | // Cleaning up old karma permissions. |
| 1004 | 1066 | $smcFunc['db_query']('', ' |
@@ -1011,18 +1073,20 @@ discard block |
||
| 1011 | 1073 | } |
| 1012 | 1074 | |
| 1013 | 1075 | // Emptying the error log? |
| 1014 | - if (!empty($_POST['empty_error'])) |
|
| 1015 | - $smcFunc['db_query']('truncate_table', ' |
|
| 1076 | + if (!empty($_POST['empty_error'])) { |
|
| 1077 | + $smcFunc['db_query']('truncate_table', ' |
|
| 1016 | 1078 | TRUNCATE {db_prefix}log_errors', |
| 1017 | 1079 | array( |
| 1018 | 1080 | ) |
| 1019 | 1081 | ); |
| 1082 | + } |
|
| 1020 | 1083 | |
| 1021 | 1084 | $changes = array(); |
| 1022 | 1085 | |
| 1023 | 1086 | // If we're overriding the language follow it through. |
| 1024 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
| 1025 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1087 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
| 1088 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
| 1089 | + } |
|
| 1026 | 1090 | |
| 1027 | 1091 | if (!empty($_POST['maint'])) |
| 1028 | 1092 | { |
@@ -1034,37 +1098,42 @@ discard block |
||
| 1034 | 1098 | { |
| 1035 | 1099 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
| 1036 | 1100 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
| 1037 | - } |
|
| 1038 | - else |
|
| 1101 | + } else |
|
| 1039 | 1102 | { |
| 1040 | 1103 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
| 1041 | 1104 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
| 1042 | 1105 | } |
| 1043 | 1106 | } |
| 1044 | 1107 | |
| 1045 | - if ($command_line) |
|
| 1046 | - echo ' * Updating Settings.php...'; |
|
| 1108 | + if ($command_line) { |
|
| 1109 | + echo ' * Updating Settings.php...'; |
|
| 1110 | + } |
|
| 1047 | 1111 | |
| 1048 | 1112 | // Backup the current one first. |
| 1049 | 1113 | copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
| 1050 | 1114 | |
| 1051 | 1115 | // Fix some old paths. |
| 1052 | - if (substr($boarddir, 0, 1) == '.') |
|
| 1053 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1116 | + if (substr($boarddir, 0, 1) == '.') { |
|
| 1117 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
| 1118 | + } |
|
| 1054 | 1119 | |
| 1055 | - if (substr($sourcedir, 0, 1) == '.') |
|
| 1056 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1120 | + if (substr($sourcedir, 0, 1) == '.') { |
|
| 1121 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
| 1122 | + } |
|
| 1057 | 1123 | |
| 1058 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
| 1059 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1124 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
| 1125 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
| 1126 | + } |
|
| 1060 | 1127 | |
| 1061 | 1128 | // Not had the database type added before? |
| 1062 | - if (empty($db_type)) |
|
| 1063 | - $changes['db_type'] = 'mysql'; |
|
| 1129 | + if (empty($db_type)) { |
|
| 1130 | + $changes['db_type'] = 'mysql'; |
|
| 1131 | + } |
|
| 1064 | 1132 | |
| 1065 | 1133 | // For now we offer a option, this may change in future versions when mysql is completely removed. |
| 1066 | - if (!empty($_POST['convertMysql']) && $db_type == 'mysql') |
|
| 1067 | - $changes['db_type'] = '\'mysqli\''; |
|
| 1134 | + if (!empty($_POST['convertMysql']) && $db_type == 'mysql') { |
|
| 1135 | + $changes['db_type'] = '\'mysqli\''; |
|
| 1136 | + } |
|
| 1068 | 1137 | |
| 1069 | 1138 | // If they have a "host:port" setup for the host, split that into separate values |
| 1070 | 1139 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1075,28 +1144,31 @@ discard block |
||
| 1075 | 1144 | $changes['db_server'] = '\'' . $db_server . '\''; |
| 1076 | 1145 | |
| 1077 | 1146 | // Only set this if we're not using the default port |
| 1078 | - if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) |
|
| 1079 | - $changes['db_port'] = (int) $db_port; |
|
| 1080 | - } |
|
| 1081 | - elseif (!empty($db_port)) |
|
| 1147 | + if ($db_port != ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) { |
|
| 1148 | + $changes['db_port'] = (int) $db_port; |
|
| 1149 | + } |
|
| 1150 | + } elseif (!empty($db_port)) |
|
| 1082 | 1151 | { |
| 1083 | 1152 | // If db_port is set and is the same as the default, set it to '' |
| 1084 | 1153 | if ($db_type == 'mysql' || $db_type == 'mysqli') |
| 1085 | 1154 | { |
| 1086 | - if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) |
|
| 1087 | - $changes['db_port'] = '\'\''; |
|
| 1088 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
| 1089 | - $changes['db_port'] = '\'\''; |
|
| 1155 | + if ($db_port == ini_get('mysql' . ($db_type == 'mysqli' || !empty($_POST['convertMysql']) ? 'i' : '') . '.default_port')) { |
|
| 1156 | + $changes['db_port'] = '\'\''; |
|
| 1157 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
| 1158 | + $changes['db_port'] = '\'\''; |
|
| 1159 | + } |
|
| 1090 | 1160 | } |
| 1091 | 1161 | } |
| 1092 | 1162 | |
| 1093 | 1163 | // Maybe we haven't had this option yet? |
| 1094 | - if (empty($packagesdir)) |
|
| 1095 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1164 | + if (empty($packagesdir)) { |
|
| 1165 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
| 1166 | + } |
|
| 1096 | 1167 | |
| 1097 | 1168 | // Add support for $tasksdir var. |
| 1098 | - if (empty($tasksdir)) |
|
| 1099 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1169 | + if (empty($tasksdir)) { |
|
| 1170 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
| 1171 | + } |
|
| 1100 | 1172 | |
| 1101 | 1173 | // @todo Maybe change the cookie name if going to 1.1, too? |
| 1102 | 1174 | |
@@ -1141,8 +1213,7 @@ discard block |
||
| 1141 | 1213 | $found_old = true; |
| 1142 | 1214 | // Replace the old line with the new code |
| 1143 | 1215 | $settings_file = str_replace('$db_last_error = ' . $db_last_error . ';', $error_catching_header . $error_catching, $settings_file); |
| 1144 | - } |
|
| 1145 | - else |
|
| 1216 | + } else |
|
| 1146 | 1217 | { |
| 1147 | 1218 | $found_old = false; |
| 1148 | 1219 | // We want the comments as well as the code... |
@@ -1173,8 +1244,9 @@ discard block |
||
| 1173 | 1244 | fclose($file); |
| 1174 | 1245 | } |
| 1175 | 1246 | |
| 1176 | - if ($command_line) |
|
| 1177 | - echo ' Successful.' . "\n"; |
|
| 1247 | + if ($command_line) { |
|
| 1248 | + echo ' Successful.' . "\n"; |
|
| 1249 | + } |
|
| 1178 | 1250 | |
| 1179 | 1251 | // Are we doing debug? |
| 1180 | 1252 | if (isset($_POST['debug'])) |
@@ -1184,8 +1256,9 @@ discard block |
||
| 1184 | 1256 | } |
| 1185 | 1257 | |
| 1186 | 1258 | // If we're not backing up then jump one. |
| 1187 | - if (empty($_POST['backup'])) |
|
| 1188 | - $upcontext['current_step']++; |
|
| 1259 | + if (empty($_POST['backup'])) { |
|
| 1260 | + $upcontext['current_step']++; |
|
| 1261 | + } |
|
| 1189 | 1262 | |
| 1190 | 1263 | // If we've got here then let's proceed to the next step! |
| 1191 | 1264 | return true; |
@@ -1200,8 +1273,9 @@ discard block |
||
| 1200 | 1273 | $upcontext['page_title'] = 'Backup Database'; |
| 1201 | 1274 | |
| 1202 | 1275 | // Done it already - js wise? |
| 1203 | - if (!empty($_POST['backup_done'])) |
|
| 1204 | - return true; |
|
| 1276 | + if (!empty($_POST['backup_done'])) { |
|
| 1277 | + return true; |
|
| 1278 | + } |
|
| 1205 | 1279 | |
| 1206 | 1280 | // Some useful stuff here. |
| 1207 | 1281 | db_extend(); |
@@ -1215,9 +1289,10 @@ discard block |
||
| 1215 | 1289 | $tables = $smcFunc['db_list_tables']($db, $filter); |
| 1216 | 1290 | |
| 1217 | 1291 | $table_names = array(); |
| 1218 | - foreach ($tables as $table) |
|
| 1219 | - if (substr($table, 0, 7) !== 'backup_') |
|
| 1292 | + foreach ($tables as $table) { |
|
| 1293 | + if (substr($table, 0, 7) !== 'backup_') |
|
| 1220 | 1294 | $table_names[] = $table; |
| 1295 | + } |
|
| 1221 | 1296 | |
| 1222 | 1297 | $upcontext['table_count'] = count($table_names); |
| 1223 | 1298 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1227,12 +1302,14 @@ discard block |
||
| 1227 | 1302 | $file_steps = $upcontext['table_count']; |
| 1228 | 1303 | |
| 1229 | 1304 | // What ones have we already done? |
| 1230 | - foreach ($table_names as $id => $table) |
|
| 1231 | - if ($id < $_GET['substep']) |
|
| 1305 | + foreach ($table_names as $id => $table) { |
|
| 1306 | + if ($id < $_GET['substep']) |
|
| 1232 | 1307 | $upcontext['previous_tables'][] = $table; |
| 1308 | + } |
|
| 1233 | 1309 | |
| 1234 | - if ($command_line) |
|
| 1235 | - echo 'Backing Up Tables.'; |
|
| 1310 | + if ($command_line) { |
|
| 1311 | + echo 'Backing Up Tables.'; |
|
| 1312 | + } |
|
| 1236 | 1313 | |
| 1237 | 1314 | // If we don't support javascript we backup here. |
| 1238 | 1315 | if (!$support_js || isset($_GET['xml'])) |
@@ -1251,8 +1328,9 @@ discard block |
||
| 1251 | 1328 | backupTable($table_names[$substep]); |
| 1252 | 1329 | |
| 1253 | 1330 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 1254 | - if (isset($_GET['xml'])) |
|
| 1255 | - return upgradeExit(); |
|
| 1331 | + if (isset($_GET['xml'])) { |
|
| 1332 | + return upgradeExit(); |
|
| 1333 | + } |
|
| 1256 | 1334 | } |
| 1257 | 1335 | |
| 1258 | 1336 | if ($command_line) |
@@ -1285,9 +1363,10 @@ discard block |
||
| 1285 | 1363 | |
| 1286 | 1364 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
| 1287 | 1365 | |
| 1288 | - if ($command_line) |
|
| 1289 | - echo ' done.'; |
|
| 1290 | -} |
|
| 1366 | + if ($command_line) { |
|
| 1367 | + echo ' done.'; |
|
| 1368 | + } |
|
| 1369 | + } |
|
| 1291 | 1370 | |
| 1292 | 1371 | // Step 2: Everything. |
| 1293 | 1372 | function DatabaseChanges() |
@@ -1296,8 +1375,9 @@ discard block |
||
| 1296 | 1375 | global $upcontext, $support_js, $db_type; |
| 1297 | 1376 | |
| 1298 | 1377 | // Have we just completed this? |
| 1299 | - if (!empty($_POST['database_done'])) |
|
| 1300 | - return true; |
|
| 1378 | + if (!empty($_POST['database_done'])) { |
|
| 1379 | + return true; |
|
| 1380 | + } |
|
| 1301 | 1381 | |
| 1302 | 1382 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
| 1303 | 1383 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1314,15 +1394,16 @@ discard block |
||
| 1314 | 1394 | ); |
| 1315 | 1395 | |
| 1316 | 1396 | // How many files are there in total? |
| 1317 | - if (isset($_GET['filecount'])) |
|
| 1318 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1319 | - else |
|
| 1397 | + if (isset($_GET['filecount'])) { |
|
| 1398 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
| 1399 | + } else |
|
| 1320 | 1400 | { |
| 1321 | 1401 | $upcontext['file_count'] = 0; |
| 1322 | 1402 | foreach ($files as $file) |
| 1323 | 1403 | { |
| 1324 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
| 1325 | - $upcontext['file_count']++; |
|
| 1404 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
| 1405 | + $upcontext['file_count']++; |
|
| 1406 | + } |
|
| 1326 | 1407 | } |
| 1327 | 1408 | } |
| 1328 | 1409 | |
@@ -1332,9 +1413,9 @@ discard block |
||
| 1332 | 1413 | $upcontext['cur_file_num'] = 0; |
| 1333 | 1414 | foreach ($files as $file) |
| 1334 | 1415 | { |
| 1335 | - if ($did_not_do) |
|
| 1336 | - $did_not_do--; |
|
| 1337 | - else |
|
| 1416 | + if ($did_not_do) { |
|
| 1417 | + $did_not_do--; |
|
| 1418 | + } else |
|
| 1338 | 1419 | { |
| 1339 | 1420 | $upcontext['cur_file_num']++; |
| 1340 | 1421 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1361,12 +1442,13 @@ discard block |
||
| 1361 | 1442 | // Flag to move on to the next. |
| 1362 | 1443 | $upcontext['completed_step'] = true; |
| 1363 | 1444 | // Did we complete the whole file? |
| 1364 | - if ($nextFile) |
|
| 1365 | - $upcontext['current_debug_item_num'] = -1; |
|
| 1445 | + if ($nextFile) { |
|
| 1446 | + $upcontext['current_debug_item_num'] = -1; |
|
| 1447 | + } |
|
| 1366 | 1448 | return upgradeExit(); |
| 1449 | + } elseif ($support_js) { |
|
| 1450 | + break; |
|
| 1367 | 1451 | } |
| 1368 | - elseif ($support_js) |
|
| 1369 | - break; |
|
| 1370 | 1452 | } |
| 1371 | 1453 | // Set the progress bar to be right as if we had - even if we hadn't... |
| 1372 | 1454 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1391,8 +1473,9 @@ discard block |
||
| 1391 | 1473 | global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
| 1392 | 1474 | |
| 1393 | 1475 | // Now it's nice to have some of the basic SMF source files. |
| 1394 | - if (!isset($_GET['ssi']) && !$command_line) |
|
| 1395 | - redirectLocation('&ssi=1'); |
|
| 1476 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
| 1477 | + redirectLocation('&ssi=1'); |
|
| 1478 | + } |
|
| 1396 | 1479 | |
| 1397 | 1480 | $upcontext['sub_template'] = 'upgrade_complete'; |
| 1398 | 1481 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1408,14 +1491,16 @@ discard block |
||
| 1408 | 1491 | // Are we in maintenance mode? |
| 1409 | 1492 | if (isset($upcontext['user']['main'])) |
| 1410 | 1493 | { |
| 1411 | - if ($command_line) |
|
| 1412 | - echo ' * '; |
|
| 1494 | + if ($command_line) { |
|
| 1495 | + echo ' * '; |
|
| 1496 | + } |
|
| 1413 | 1497 | $upcontext['removed_maintenance'] = true; |
| 1414 | 1498 | $changes['maintenance'] = $upcontext['user']['main']; |
| 1415 | 1499 | } |
| 1416 | 1500 | // Otherwise if somehow we are in 2 let's go to 1. |
| 1417 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
| 1418 | - $changes['maintenance'] = 1; |
|
| 1501 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
| 1502 | + $changes['maintenance'] = 1; |
|
| 1503 | + } |
|
| 1419 | 1504 | |
| 1420 | 1505 | // Wipe this out... |
| 1421 | 1506 | $upcontext['user'] = array(); |
@@ -1431,9 +1516,9 @@ discard block |
||
| 1431 | 1516 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
| 1432 | 1517 | |
| 1433 | 1518 | // Now is the perfect time to fetch the SM files. |
| 1434 | - if ($command_line) |
|
| 1435 | - cli_scheduled_fetchSMfiles(); |
|
| 1436 | - else |
|
| 1519 | + if ($command_line) { |
|
| 1520 | + cli_scheduled_fetchSMfiles(); |
|
| 1521 | + } else |
|
| 1437 | 1522 | { |
| 1438 | 1523 | require_once($sourcedir . '/ScheduledTasks.php'); |
| 1439 | 1524 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1441,8 +1526,9 @@ discard block |
||
| 1441 | 1526 | } |
| 1442 | 1527 | |
| 1443 | 1528 | // Log what we've done. |
| 1444 | - if (empty($user_info['id'])) |
|
| 1445 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1529 | + if (empty($user_info['id'])) { |
|
| 1530 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
| 1531 | + } |
|
| 1446 | 1532 | |
| 1447 | 1533 | // Log the action manually, so CLI still works. |
| 1448 | 1534 | $smcFunc['db_insert']('', |
@@ -1461,8 +1547,9 @@ discard block |
||
| 1461 | 1547 | |
| 1462 | 1548 | // Save the current database version. |
| 1463 | 1549 | $server_version = $smcFunc['db_server_info'](); |
| 1464 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1465 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1550 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1551 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1552 | + } |
|
| 1466 | 1553 | |
| 1467 | 1554 | if ($command_line) |
| 1468 | 1555 | { |
@@ -1474,8 +1561,9 @@ discard block |
||
| 1474 | 1561 | |
| 1475 | 1562 | // Make sure it says we're done. |
| 1476 | 1563 | $upcontext['overall_percent'] = 100; |
| 1477 | - if (isset($upcontext['step_progress'])) |
|
| 1478 | - unset($upcontext['step_progress']); |
|
| 1564 | + if (isset($upcontext['step_progress'])) { |
|
| 1565 | + unset($upcontext['step_progress']); |
|
| 1566 | + } |
|
| 1479 | 1567 | |
| 1480 | 1568 | $_GET['substep'] = 0; |
| 1481 | 1569 | return false; |
@@ -1486,8 +1574,9 @@ discard block |
||
| 1486 | 1574 | { |
| 1487 | 1575 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
| 1488 | 1576 | |
| 1489 | - if (empty($modSettings['time_format'])) |
|
| 1490 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1577 | + if (empty($modSettings['time_format'])) { |
|
| 1578 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
| 1579 | + } |
|
| 1491 | 1580 | |
| 1492 | 1581 | // What files do we want to get |
| 1493 | 1582 | $request = $smcFunc['db_query']('', ' |
@@ -1521,8 +1610,9 @@ discard block |
||
| 1521 | 1610 | $file_data = fetch_web_data($url); |
| 1522 | 1611 | |
| 1523 | 1612 | // If we got an error - give up - the site might be down. |
| 1524 | - if ($file_data === false) |
|
| 1525 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1613 | + if ($file_data === false) { |
|
| 1614 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
| 1615 | + } |
|
| 1526 | 1616 | |
| 1527 | 1617 | // Save the file to the database. |
| 1528 | 1618 | $smcFunc['db_query']('substring', ' |
@@ -1564,8 +1654,9 @@ discard block |
||
| 1564 | 1654 | $themeData = array(); |
| 1565 | 1655 | foreach ($values as $variable => $value) |
| 1566 | 1656 | { |
| 1567 | - if (!isset($value) || $value === null) |
|
| 1568 | - $value = 0; |
|
| 1657 | + if (!isset($value) || $value === null) { |
|
| 1658 | + $value = 0; |
|
| 1659 | + } |
|
| 1569 | 1660 | |
| 1570 | 1661 | $themeData[] = array(0, 1, $variable, $value); |
| 1571 | 1662 | } |
@@ -1594,8 +1685,9 @@ discard block |
||
| 1594 | 1685 | |
| 1595 | 1686 | foreach ($values as $variable => $value) |
| 1596 | 1687 | { |
| 1597 | - if (empty($modSettings[$value[0]])) |
|
| 1598 | - continue; |
|
| 1688 | + if (empty($modSettings[$value[0]])) { |
|
| 1689 | + continue; |
|
| 1690 | + } |
|
| 1599 | 1691 | |
| 1600 | 1692 | $smcFunc['db_query']('', ' |
| 1601 | 1693 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1628,8 +1720,9 @@ discard block |
||
| 1628 | 1720 | |
| 1629 | 1721 | $settingsArray = file($boarddir . '/Settings_bak.php'); |
| 1630 | 1722 | |
| 1631 | - if (count($settingsArray) == 1) |
|
| 1632 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1723 | + if (count($settingsArray) == 1) { |
|
| 1724 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1725 | + } |
|
| 1633 | 1726 | |
| 1634 | 1727 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1635 | 1728 | { |
@@ -1642,9 +1735,9 @@ discard block |
||
| 1642 | 1735 | { |
| 1643 | 1736 | if (isset($settingsArray[$i]) && strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
| 1644 | 1737 | { |
| 1645 | - if ($val == '#remove#') |
|
| 1646 | - unset($settingsArray[$i]); |
|
| 1647 | - else |
|
| 1738 | + if ($val == '#remove#') { |
|
| 1739 | + unset($settingsArray[$i]); |
|
| 1740 | + } else |
|
| 1648 | 1741 | { |
| 1649 | 1742 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
| 1650 | 1743 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
@@ -1656,22 +1749,25 @@ discard block |
||
| 1656 | 1749 | } |
| 1657 | 1750 | if (isset($settingsArray[$i])) |
| 1658 | 1751 | { |
| 1659 | - if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') |
|
| 1660 | - $end = $i; |
|
| 1752 | + if (trim(substr($settingsArray[$i], 0, 2)) == '?' . '>') { |
|
| 1753 | + $end = $i; |
|
| 1754 | + } |
|
| 1661 | 1755 | } |
| 1662 | 1756 | } |
| 1663 | 1757 | |
| 1664 | 1758 | // Assume end-of-file if the end wasn't found. |
| 1665 | - if (empty($end) || $end < 10) |
|
| 1666 | - $end = count($settingsArray); |
|
| 1759 | + if (empty($end) || $end < 10) { |
|
| 1760 | + $end = count($settingsArray); |
|
| 1761 | + } |
|
| 1667 | 1762 | |
| 1668 | 1763 | if (!empty($config_vars)) |
| 1669 | 1764 | { |
| 1670 | 1765 | $settingsArray[$end++] = ''; |
| 1671 | 1766 | foreach ($config_vars as $var => $val) |
| 1672 | 1767 | { |
| 1673 | - if ($val != '#remove#') |
|
| 1674 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 1768 | + if ($val != '#remove#') { |
|
| 1769 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
| 1770 | + } |
|
| 1675 | 1771 | } |
| 1676 | 1772 | } |
| 1677 | 1773 | // This should be the last line and even last bytes of the file. |
@@ -1684,8 +1780,9 @@ discard block |
||
| 1684 | 1780 | $fp = fopen($boarddir . '/Settings.php', 'r+'); |
| 1685 | 1781 | for ($i = 0; $i < $end; $i++) |
| 1686 | 1782 | { |
| 1687 | - if (isset($settingsArray[$i])) |
|
| 1688 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1783 | + if (isset($settingsArray[$i])) { |
|
| 1784 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1785 | + } |
|
| 1689 | 1786 | } |
| 1690 | 1787 | fwrite($fp, rtrim($settingsArray[$i])); |
| 1691 | 1788 | fclose($fp); |
@@ -1758,10 +1855,11 @@ discard block |
||
| 1758 | 1855 | { |
| 1759 | 1856 | global $support_js; |
| 1760 | 1857 | |
| 1761 | - if ($support_js) |
|
| 1762 | - return true; |
|
| 1763 | - else |
|
| 1764 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1858 | + if ($support_js) { |
|
| 1859 | + return true; |
|
| 1860 | + } else { |
|
| 1861 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
| 1862 | + } |
|
| 1765 | 1863 | } |
| 1766 | 1864 | } |
| 1767 | 1865 | |
@@ -1779,8 +1877,9 @@ discard block |
||
| 1779 | 1877 | 'db_error_skip' => true, |
| 1780 | 1878 | ) |
| 1781 | 1879 | ); |
| 1782 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 1783 | - die('Unable to find members table!'); |
|
| 1880 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 1881 | + die('Unable to find members table!'); |
|
| 1882 | + } |
|
| 1784 | 1883 | $table_status = $smcFunc['db_fetch_assoc']($request); |
| 1785 | 1884 | $smcFunc['db_free_result']($request); |
| 1786 | 1885 | |
@@ -1795,17 +1894,20 @@ discard block |
||
| 1795 | 1894 | ) |
| 1796 | 1895 | ); |
| 1797 | 1896 | // Got something? |
| 1798 | - if ($smcFunc['db_num_rows']($request) !== 0) |
|
| 1799 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 1897 | + if ($smcFunc['db_num_rows']($request) !== 0) { |
|
| 1898 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 1899 | + } |
|
| 1800 | 1900 | $smcFunc['db_free_result']($request); |
| 1801 | 1901 | |
| 1802 | 1902 | // Excellent! |
| 1803 | - if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) |
|
| 1804 | - $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
| 1903 | + if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) { |
|
| 1904 | + $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
| 1905 | + } |
|
| 1805 | 1906 | } |
| 1806 | 1907 | } |
| 1807 | - if (empty($db_collation)) |
|
| 1808 | - $db_collation = ''; |
|
| 1908 | + if (empty($db_collation)) { |
|
| 1909 | + $db_collation = ''; |
|
| 1910 | + } |
|
| 1809 | 1911 | |
| 1810 | 1912 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
| 1811 | 1913 | |
@@ -1817,8 +1919,9 @@ discard block |
||
| 1817 | 1919 | $last_step = ''; |
| 1818 | 1920 | |
| 1819 | 1921 | // Make sure all newly created tables will have the proper characters set. |
| 1820 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
| 1821 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1922 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
| 1923 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
| 1924 | + } |
|
| 1822 | 1925 | |
| 1823 | 1926 | // Count the total number of steps within this file - for progress. |
| 1824 | 1927 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1838,15 +1941,18 @@ discard block |
||
| 1838 | 1941 | $do_current = $substep >= $_GET['substep']; |
| 1839 | 1942 | |
| 1840 | 1943 | // Get rid of any comments in the beginning of the line... |
| 1841 | - if (substr(trim($line), 0, 2) === '/*') |
|
| 1842 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1944 | + if (substr(trim($line), 0, 2) === '/*') { |
|
| 1945 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
| 1946 | + } |
|
| 1843 | 1947 | |
| 1844 | 1948 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
| 1845 | - if ($is_debug && !$support_js && $command_line) |
|
| 1846 | - flush(); |
|
| 1949 | + if ($is_debug && !$support_js && $command_line) { |
|
| 1950 | + flush(); |
|
| 1951 | + } |
|
| 1847 | 1952 | |
| 1848 | - if (trim($line) === '') |
|
| 1849 | - continue; |
|
| 1953 | + if (trim($line) === '') { |
|
| 1954 | + continue; |
|
| 1955 | + } |
|
| 1850 | 1956 | |
| 1851 | 1957 | if (trim(substr($line, 0, 3)) === '---') |
| 1852 | 1958 | { |
@@ -1856,8 +1962,9 @@ discard block |
||
| 1856 | 1962 | if (trim($current_data) != '' && $type !== '}') |
| 1857 | 1963 | { |
| 1858 | 1964 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
| 1859 | - if ($command_line) |
|
| 1860 | - echo $upcontext['error_message']; |
|
| 1965 | + if ($command_line) { |
|
| 1966 | + echo $upcontext['error_message']; |
|
| 1967 | + } |
|
| 1861 | 1968 | } |
| 1862 | 1969 | |
| 1863 | 1970 | if ($type == ' ') |
@@ -1875,17 +1982,18 @@ discard block |
||
| 1875 | 1982 | if ($do_current) |
| 1876 | 1983 | { |
| 1877 | 1984 | $upcontext['actioned_items'][] = $last_step; |
| 1878 | - if ($command_line) |
|
| 1879 | - echo ' * '; |
|
| 1985 | + if ($command_line) { |
|
| 1986 | + echo ' * '; |
|
| 1987 | + } |
|
| 1880 | 1988 | } |
| 1881 | - } |
|
| 1882 | - elseif ($type == '#') |
|
| 1989 | + } elseif ($type == '#') |
|
| 1883 | 1990 | { |
| 1884 | 1991 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
| 1885 | 1992 | |
| 1886 | 1993 | $upcontext['current_debug_item_num']++; |
| 1887 | - if (trim($line) != '---#') |
|
| 1888 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1994 | + if (trim($line) != '---#') { |
|
| 1995 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 1996 | + } |
|
| 1889 | 1997 | |
| 1890 | 1998 | // Have we already done something? |
| 1891 | 1999 | if (isset($_GET['xml']) && $done_something) |
@@ -1896,34 +2004,36 @@ discard block |
||
| 1896 | 2004 | |
| 1897 | 2005 | if ($do_current) |
| 1898 | 2006 | { |
| 1899 | - if (trim($line) == '---#' && $command_line) |
|
| 1900 | - echo ' done.', $endl; |
|
| 1901 | - elseif ($command_line) |
|
| 1902 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
| 1903 | - elseif (trim($line) != '---#') |
|
| 2007 | + if (trim($line) == '---#' && $command_line) { |
|
| 2008 | + echo ' done.', $endl; |
|
| 2009 | + } elseif ($command_line) { |
|
| 2010 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
| 2011 | + } elseif (trim($line) != '---#') |
|
| 1904 | 2012 | { |
| 1905 | - if ($is_debug) |
|
| 1906 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2013 | + if ($is_debug) { |
|
| 2014 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
| 2015 | + } |
|
| 1907 | 2016 | } |
| 1908 | 2017 | } |
| 1909 | 2018 | |
| 1910 | 2019 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
| 1911 | 2020 | { |
| 1912 | - if ($command_line) |
|
| 1913 | - echo ' * '; |
|
| 1914 | - else |
|
| 1915 | - $upcontext['actioned_items'][] = $last_step; |
|
| 2021 | + if ($command_line) { |
|
| 2022 | + echo ' * '; |
|
| 2023 | + } else { |
|
| 2024 | + $upcontext['actioned_items'][] = $last_step; |
|
| 2025 | + } |
|
| 1916 | 2026 | } |
| 1917 | 2027 | |
| 1918 | 2028 | // Small step - only if we're actually doing stuff. |
| 1919 | - if ($do_current) |
|
| 1920 | - nextSubstep(++$substep); |
|
| 1921 | - else |
|
| 1922 | - $substep++; |
|
| 1923 | - } |
|
| 1924 | - elseif ($type == '{') |
|
| 1925 | - $current_type = 'code'; |
|
| 1926 | - elseif ($type == '}') |
|
| 2029 | + if ($do_current) { |
|
| 2030 | + nextSubstep(++$substep); |
|
| 2031 | + } else { |
|
| 2032 | + $substep++; |
|
| 2033 | + } |
|
| 2034 | + } elseif ($type == '{') { |
|
| 2035 | + $current_type = 'code'; |
|
| 2036 | + } elseif ($type == '}') |
|
| 1927 | 2037 | { |
| 1928 | 2038 | $current_type = 'sql'; |
| 1929 | 2039 | |
@@ -1936,8 +2046,9 @@ discard block |
||
| 1936 | 2046 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
| 1937 | 2047 | { |
| 1938 | 2048 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
| 1939 | - if ($command_line) |
|
| 1940 | - echo $upcontext['error_message']; |
|
| 2049 | + if ($command_line) { |
|
| 2050 | + echo $upcontext['error_message']; |
|
| 2051 | + } |
|
| 1941 | 2052 | } |
| 1942 | 2053 | |
| 1943 | 2054 | // Done with code! |
@@ -2017,8 +2128,9 @@ discard block |
||
| 2017 | 2128 | $db_unbuffered = false; |
| 2018 | 2129 | |
| 2019 | 2130 | // Failure?! |
| 2020 | - if ($result !== false) |
|
| 2021 | - return $result; |
|
| 2131 | + if ($result !== false) { |
|
| 2132 | + return $result; |
|
| 2133 | + } |
|
| 2022 | 2134 | |
| 2023 | 2135 | $db_error_message = $smcFunc['db_error']($db_connection); |
| 2024 | 2136 | // If MySQL we do something more clever. |
@@ -2046,54 +2158,61 @@ discard block |
||
| 2046 | 2158 | { |
| 2047 | 2159 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
| 2048 | 2160 | $result = mysqli_query($db_connection, $string); |
| 2049 | - if ($result !== false) |
|
| 2050 | - return $result; |
|
| 2161 | + if ($result !== false) { |
|
| 2162 | + return $result; |
|
| 2163 | + } |
|
| 2051 | 2164 | } |
| 2052 | - } |
|
| 2053 | - elseif ($mysqli_errno == 2013) |
|
| 2165 | + } elseif ($mysqli_errno == 2013) |
|
| 2054 | 2166 | { |
| 2055 | 2167 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
| 2056 | 2168 | mysqli_select_db($db_connection, $db_name); |
| 2057 | 2169 | if ($db_connection) |
| 2058 | 2170 | { |
| 2059 | 2171 | $result = mysqli_query($db_connection, $string); |
| 2060 | - if ($result !== false) |
|
| 2061 | - return $result; |
|
| 2172 | + if ($result !== false) { |
|
| 2173 | + return $result; |
|
| 2174 | + } |
|
| 2062 | 2175 | } |
| 2063 | 2176 | } |
| 2064 | 2177 | // Duplicate column name... should be okay ;). |
| 2065 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
| 2066 | - return false; |
|
| 2178 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
| 2179 | + return false; |
|
| 2180 | + } |
|
| 2067 | 2181 | // Duplicate insert... make sure it's the proper type of query ;). |
| 2068 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
| 2069 | - return false; |
|
| 2182 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
| 2183 | + return false; |
|
| 2184 | + } |
|
| 2070 | 2185 | // Creating an index on a non-existent column. |
| 2071 | - elseif ($mysqli_errno == 1072) |
|
| 2072 | - return false; |
|
| 2073 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
| 2074 | - return false; |
|
| 2186 | + elseif ($mysqli_errno == 1072) { |
|
| 2187 | + return false; |
|
| 2188 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
| 2189 | + return false; |
|
| 2190 | + } |
|
| 2075 | 2191 | } |
| 2076 | 2192 | // If a table already exists don't go potty. |
| 2077 | 2193 | else |
| 2078 | 2194 | { |
| 2079 | 2195 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
| 2080 | 2196 | { |
| 2081 | - if (strpos($db_error_message, 'exist') !== false) |
|
| 2082 | - return true; |
|
| 2083 | - } |
|
| 2084 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2197 | + if (strpos($db_error_message, 'exist') !== false) { |
|
| 2198 | + return true; |
|
| 2199 | + } |
|
| 2200 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
| 2085 | 2201 | { |
| 2086 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
| 2087 | - return true; |
|
| 2202 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
| 2203 | + return true; |
|
| 2204 | + } |
|
| 2088 | 2205 | } |
| 2089 | 2206 | } |
| 2090 | 2207 | |
| 2091 | 2208 | // Get the query string so we pass everything. |
| 2092 | 2209 | $query_string = ''; |
| 2093 | - foreach ($_GET as $k => $v) |
|
| 2094 | - $query_string .= ';' . $k . '=' . $v; |
|
| 2095 | - if (strlen($query_string) != 0) |
|
| 2096 | - $query_string = '?' . substr($query_string, 1); |
|
| 2210 | + foreach ($_GET as $k => $v) { |
|
| 2211 | + $query_string .= ';' . $k . '=' . $v; |
|
| 2212 | + } |
|
| 2213 | + if (strlen($query_string) != 0) { |
|
| 2214 | + $query_string = '?' . substr($query_string, 1); |
|
| 2215 | + } |
|
| 2097 | 2216 | |
| 2098 | 2217 | if ($command_line) |
| 2099 | 2218 | { |
@@ -2148,16 +2267,18 @@ discard block |
||
| 2148 | 2267 | { |
| 2149 | 2268 | $found |= 1; |
| 2150 | 2269 | // Do some checks on the data if we have it set. |
| 2151 | - if (isset($change['col_type'])) |
|
| 2152 | - $found &= $change['col_type'] === $column['type']; |
|
| 2153 | - if (isset($change['null_allowed'])) |
|
| 2154 | - $found &= $column['null'] == $change['null_allowed']; |
|
| 2155 | - if (isset($change['default'])) |
|
| 2156 | - $found &= $change['default'] === $column['default']; |
|
| 2270 | + if (isset($change['col_type'])) { |
|
| 2271 | + $found &= $change['col_type'] === $column['type']; |
|
| 2272 | + } |
|
| 2273 | + if (isset($change['null_allowed'])) { |
|
| 2274 | + $found &= $column['null'] == $change['null_allowed']; |
|
| 2275 | + } |
|
| 2276 | + if (isset($change['default'])) { |
|
| 2277 | + $found &= $change['default'] === $column['default']; |
|
| 2278 | + } |
|
| 2157 | 2279 | } |
| 2158 | 2280 | } |
| 2159 | - } |
|
| 2160 | - elseif ($change['type'] === 'index') |
|
| 2281 | + } elseif ($change['type'] === 'index') |
|
| 2161 | 2282 | { |
| 2162 | 2283 | $request = upgrade_query(' |
| 2163 | 2284 | SHOW INDEX |
@@ -2166,9 +2287,10 @@ discard block |
||
| 2166 | 2287 | { |
| 2167 | 2288 | $cur_index = array(); |
| 2168 | 2289 | |
| 2169 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2170 | - if ($row['Key_name'] === $change['name']) |
|
| 2290 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2291 | + if ($row['Key_name'] === $change['name']) |
|
| 2171 | 2292 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
| 2293 | + } |
|
| 2172 | 2294 | |
| 2173 | 2295 | ksort($cur_index, SORT_NUMERIC); |
| 2174 | 2296 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2178,14 +2300,17 @@ discard block |
||
| 2178 | 2300 | } |
| 2179 | 2301 | |
| 2180 | 2302 | // If we're trying to add and it's added, we're done. |
| 2181 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
| 2182 | - return true; |
|
| 2303 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
| 2304 | + return true; |
|
| 2305 | + } |
|
| 2183 | 2306 | // Otherwise if we're removing and it wasn't found we're also done. |
| 2184 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
| 2185 | - return true; |
|
| 2307 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
| 2308 | + return true; |
|
| 2309 | + } |
|
| 2186 | 2310 | // Otherwise is it just a test? |
| 2187 | - elseif ($is_test) |
|
| 2188 | - return false; |
|
| 2311 | + elseif ($is_test) { |
|
| 2312 | + return false; |
|
| 2313 | + } |
|
| 2189 | 2314 | |
| 2190 | 2315 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
| 2191 | 2316 | $running = false; |
@@ -2196,8 +2321,9 @@ discard block |
||
| 2196 | 2321 | SHOW FULL PROCESSLIST'); |
| 2197 | 2322 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2198 | 2323 | { |
| 2199 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
| 2200 | - $found = true; |
|
| 2324 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
| 2325 | + $found = true; |
|
| 2326 | + } |
|
| 2201 | 2327 | } |
| 2202 | 2328 | |
| 2203 | 2329 | // Can't find it? Then we need to run it fools! |
@@ -2209,8 +2335,9 @@ discard block |
||
| 2209 | 2335 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
| 2210 | 2336 | ' . $change['text'], true) !== false; |
| 2211 | 2337 | |
| 2212 | - if (!$success) |
|
| 2213 | - return false; |
|
| 2338 | + if (!$success) { |
|
| 2339 | + return false; |
|
| 2340 | + } |
|
| 2214 | 2341 | |
| 2215 | 2342 | // Return |
| 2216 | 2343 | $running = true; |
@@ -2252,8 +2379,9 @@ discard block |
||
| 2252 | 2379 | 'db_error_skip' => true, |
| 2253 | 2380 | ) |
| 2254 | 2381 | ); |
| 2255 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2256 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2382 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2383 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
| 2384 | + } |
|
| 2257 | 2385 | $table_row = $smcFunc['db_fetch_assoc']($request); |
| 2258 | 2386 | $smcFunc['db_free_result']($request); |
| 2259 | 2387 | |
@@ -2275,18 +2403,19 @@ discard block |
||
| 2275 | 2403 | ) |
| 2276 | 2404 | ); |
| 2277 | 2405 | // No results? Just forget it all together. |
| 2278 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 2279 | - unset($table_row['Collation']); |
|
| 2280 | - else |
|
| 2281 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2406 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 2407 | + unset($table_row['Collation']); |
|
| 2408 | + } else { |
|
| 2409 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
| 2410 | + } |
|
| 2282 | 2411 | $smcFunc['db_free_result']($request); |
| 2283 | 2412 | } |
| 2284 | 2413 | |
| 2285 | 2414 | if ($column_fix) |
| 2286 | 2415 | { |
| 2287 | 2416 | // Make sure there are no NULL's left. |
| 2288 | - if ($null_fix) |
|
| 2289 | - $smcFunc['db_query']('', ' |
|
| 2417 | + if ($null_fix) { |
|
| 2418 | + $smcFunc['db_query']('', ' |
|
| 2290 | 2419 | UPDATE {db_prefix}' . $change['table'] . ' |
| 2291 | 2420 | SET ' . $change['column'] . ' = {string:default} |
| 2292 | 2421 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2295,6 +2424,7 @@ discard block |
||
| 2295 | 2424 | 'db_error_skip' => true, |
| 2296 | 2425 | ) |
| 2297 | 2426 | ); |
| 2427 | + } |
|
| 2298 | 2428 | |
| 2299 | 2429 | // Do the actual alteration. |
| 2300 | 2430 | $smcFunc['db_query']('', ' |
@@ -2323,8 +2453,9 @@ discard block |
||
| 2323 | 2453 | } |
| 2324 | 2454 | |
| 2325 | 2455 | // Not a column we need to check on? |
| 2326 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
| 2327 | - return; |
|
| 2456 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
| 2457 | + return; |
|
| 2458 | + } |
|
| 2328 | 2459 | |
| 2329 | 2460 | // Break it up you (six|seven). |
| 2330 | 2461 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2343,13 +2474,13 @@ discard block |
||
| 2343 | 2474 | 'new_name' => $temp[2], |
| 2344 | 2475 | )); |
| 2345 | 2476 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2346 | - if ($smcFunc['db_num_rows'] != 1) |
|
| 2347 | - return; |
|
| 2477 | + if ($smcFunc['db_num_rows'] != 1) { |
|
| 2478 | + return; |
|
| 2479 | + } |
|
| 2348 | 2480 | |
| 2349 | 2481 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
| 2350 | 2482 | $smcFunc['db_free_result']($request); |
| 2351 | - } |
|
| 2352 | - else |
|
| 2483 | + } else |
|
| 2353 | 2484 | { |
| 2354 | 2485 | // Do this the old fashion, sure method way. |
| 2355 | 2486 | $request = $smcFunc['db_query']('', ' |
@@ -2360,21 +2491,24 @@ discard block |
||
| 2360 | 2491 | )); |
| 2361 | 2492 | // Mayday! |
| 2362 | 2493 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
| 2363 | - if ($smcFunc['db_num_rows'] == 0) |
|
| 2364 | - return; |
|
| 2494 | + if ($smcFunc['db_num_rows'] == 0) { |
|
| 2495 | + return; |
|
| 2496 | + } |
|
| 2365 | 2497 | |
| 2366 | 2498 | // Oh where, oh where has my little field gone. Oh where can it be... |
| 2367 | - while ($row = $smcFunc['db_query']($request)) |
|
| 2368 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2499 | + while ($row = $smcFunc['db_query']($request)) { |
|
| 2500 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
| 2369 | 2501 | { |
| 2370 | 2502 | $current_type = $row['Type']; |
| 2503 | + } |
|
| 2371 | 2504 | break; |
| 2372 | 2505 | } |
| 2373 | 2506 | } |
| 2374 | 2507 | |
| 2375 | 2508 | // If this doesn't match, the column may of been altered for a reason. |
| 2376 | - if (trim($current_type) != trim($temp[3])) |
|
| 2377 | - $temp[3] = $current_type; |
|
| 2509 | + if (trim($current_type) != trim($temp[3])) { |
|
| 2510 | + $temp[3] = $current_type; |
|
| 2511 | + } |
|
| 2378 | 2512 | |
| 2379 | 2513 | // Piece this back together. |
| 2380 | 2514 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2386,8 +2520,9 @@ discard block |
||
| 2386 | 2520 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
| 2387 | 2521 | global $step_progress, $is_debug, $upcontext; |
| 2388 | 2522 | |
| 2389 | - if ($_GET['substep'] < $substep) |
|
| 2390 | - $_GET['substep'] = $substep; |
|
| 2523 | + if ($_GET['substep'] < $substep) { |
|
| 2524 | + $_GET['substep'] = $substep; |
|
| 2525 | + } |
|
| 2391 | 2526 | |
| 2392 | 2527 | if ($command_line) |
| 2393 | 2528 | { |
@@ -2400,29 +2535,33 @@ discard block |
||
| 2400 | 2535 | } |
| 2401 | 2536 | |
| 2402 | 2537 | @set_time_limit(300); |
| 2403 | - if (function_exists('apache_reset_timeout')) |
|
| 2404 | - @apache_reset_timeout(); |
|
| 2538 | + if (function_exists('apache_reset_timeout')) { |
|
| 2539 | + @apache_reset_timeout(); |
|
| 2540 | + } |
|
| 2405 | 2541 | |
| 2406 | - if (time() - $start_time <= $timeLimitThreshold) |
|
| 2407 | - return; |
|
| 2542 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
| 2543 | + return; |
|
| 2544 | + } |
|
| 2408 | 2545 | |
| 2409 | 2546 | // Do we have some custom step progress stuff? |
| 2410 | 2547 | if (!empty($step_progress)) |
| 2411 | 2548 | { |
| 2412 | 2549 | $upcontext['substep_progress'] = 0; |
| 2413 | 2550 | $upcontext['substep_progress_name'] = $step_progress['name']; |
| 2414 | - if ($step_progress['current'] > $step_progress['total']) |
|
| 2415 | - $upcontext['substep_progress'] = 99.9; |
|
| 2416 | - else |
|
| 2417 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2551 | + if ($step_progress['current'] > $step_progress['total']) { |
|
| 2552 | + $upcontext['substep_progress'] = 99.9; |
|
| 2553 | + } else { |
|
| 2554 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
| 2555 | + } |
|
| 2418 | 2556 | |
| 2419 | 2557 | // Make it nicely rounded. |
| 2420 | 2558 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
| 2421 | 2559 | } |
| 2422 | 2560 | |
| 2423 | 2561 | // If this is XML we just exit right away! |
| 2424 | - if (isset($_GET['xml'])) |
|
| 2425 | - return upgradeExit(); |
|
| 2562 | + if (isset($_GET['xml'])) { |
|
| 2563 | + return upgradeExit(); |
|
| 2564 | + } |
|
| 2426 | 2565 | |
| 2427 | 2566 | // We're going to pause after this! |
| 2428 | 2567 | $upcontext['pause'] = true; |
@@ -2430,13 +2569,15 @@ discard block |
||
| 2430 | 2569 | $upcontext['query_string'] = ''; |
| 2431 | 2570 | foreach ($_GET as $k => $v) |
| 2432 | 2571 | { |
| 2433 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
| 2434 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2572 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
| 2573 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
| 2574 | + } |
|
| 2435 | 2575 | } |
| 2436 | 2576 | |
| 2437 | 2577 | // Custom warning? |
| 2438 | - if (!empty($custom_warning)) |
|
| 2439 | - $upcontext['custom_warning'] = $custom_warning; |
|
| 2578 | + if (!empty($custom_warning)) { |
|
| 2579 | + $upcontext['custom_warning'] = $custom_warning; |
|
| 2580 | + } |
|
| 2440 | 2581 | |
| 2441 | 2582 | upgradeExit(); |
| 2442 | 2583 | } |
@@ -2451,25 +2592,26 @@ discard block |
||
| 2451 | 2592 | ob_implicit_flush(true); |
| 2452 | 2593 | @set_time_limit(600); |
| 2453 | 2594 | |
| 2454 | - if (!isset($_SERVER['argv'])) |
|
| 2455 | - $_SERVER['argv'] = array(); |
|
| 2595 | + if (!isset($_SERVER['argv'])) { |
|
| 2596 | + $_SERVER['argv'] = array(); |
|
| 2597 | + } |
|
| 2456 | 2598 | $_GET['maint'] = 1; |
| 2457 | 2599 | |
| 2458 | 2600 | foreach ($_SERVER['argv'] as $i => $arg) |
| 2459 | 2601 | { |
| 2460 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
| 2461 | - $_GET['lang'] = $match[1]; |
|
| 2462 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
| 2463 | - continue; |
|
| 2464 | - elseif ($arg == '--no-maintenance') |
|
| 2465 | - $_GET['maint'] = 0; |
|
| 2466 | - elseif ($arg == '--debug') |
|
| 2467 | - $is_debug = true; |
|
| 2468 | - elseif ($arg == '--backup') |
|
| 2469 | - $_POST['backup'] = 1; |
|
| 2470 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
| 2471 | - $_GET['conv'] = 1; |
|
| 2472 | - elseif ($i != 0) |
|
| 2602 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
| 2603 | + $_GET['lang'] = $match[1]; |
|
| 2604 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
| 2605 | + continue; |
|
| 2606 | + } elseif ($arg == '--no-maintenance') { |
|
| 2607 | + $_GET['maint'] = 0; |
|
| 2608 | + } elseif ($arg == '--debug') { |
|
| 2609 | + $is_debug = true; |
|
| 2610 | + } elseif ($arg == '--backup') { |
|
| 2611 | + $_POST['backup'] = 1; |
|
| 2612 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
| 2613 | + $_GET['conv'] = 1; |
|
| 2614 | + } elseif ($i != 0) |
|
| 2473 | 2615 | { |
| 2474 | 2616 | echo 'SMF Command-line Upgrader |
| 2475 | 2617 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2483,10 +2625,12 @@ discard block |
||
| 2483 | 2625 | } |
| 2484 | 2626 | } |
| 2485 | 2627 | |
| 2486 | - if (!php_version_check()) |
|
| 2487 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2488 | - if (!db_version_check()) |
|
| 2489 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2628 | + if (!php_version_check()) { |
|
| 2629 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
| 2630 | + } |
|
| 2631 | + if (!db_version_check()) { |
|
| 2632 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
| 2633 | + } |
|
| 2490 | 2634 | |
| 2491 | 2635 | // Do some checks to make sure they have proper privileges |
| 2492 | 2636 | db_extend('packages'); |
@@ -2501,34 +2645,39 @@ discard block |
||
| 2501 | 2645 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
| 2502 | 2646 | |
| 2503 | 2647 | // Sorry... we need CREATE, ALTER and DROP |
| 2504 | - if (!$create || !$alter || !$drop) |
|
| 2505 | - 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); |
|
| 2648 | + if (!$create || !$alter || !$drop) { |
|
| 2649 | + 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); |
|
| 2650 | + } |
|
| 2506 | 2651 | |
| 2507 | 2652 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
| 2508 | 2653 | && @file_exists($sourcedir . '/QueryString.php') |
| 2509 | 2654 | && @file_exists($sourcedir . '/ManageBoards.php'); |
| 2510 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
| 2511 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2655 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
| 2656 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
| 2657 | + } |
|
| 2512 | 2658 | |
| 2513 | 2659 | // Do a quick version spot check. |
| 2514 | 2660 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
| 2515 | 2661 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
| 2516 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
| 2517 | - print_error('Error: Some files have not yet been updated properly.'); |
|
| 2662 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
| 2663 | + print_error('Error: Some files have not yet been updated properly.'); |
|
| 2664 | + } |
|
| 2518 | 2665 | |
| 2519 | 2666 | // Make sure Settings.php is writable. |
| 2520 | 2667 | quickFileWritable($boarddir . '/Settings.php'); |
| 2521 | - if (!is_writable($boarddir . '/Settings.php')) |
|
| 2522 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2668 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
| 2669 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
| 2670 | + } |
|
| 2523 | 2671 | |
| 2524 | 2672 | // Make sure Settings_bak.php is writable. |
| 2525 | 2673 | quickFileWritable($boarddir . '/Settings_bak.php'); |
| 2526 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
| 2527 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2674 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
| 2675 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
| 2676 | + } |
|
| 2528 | 2677 | |
| 2529 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
| 2530 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2531 | - elseif (isset($modSettings['agreement'])) |
|
| 2678 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
| 2679 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
| 2680 | + } elseif (isset($modSettings['agreement'])) |
|
| 2532 | 2681 | { |
| 2533 | 2682 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
| 2534 | 2683 | fwrite($fp, $modSettings['agreement']); |
@@ -2538,31 +2687,36 @@ discard block |
||
| 2538 | 2687 | // Make sure Themes is writable. |
| 2539 | 2688 | quickFileWritable($modSettings['theme_dir']); |
| 2540 | 2689 | |
| 2541 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
| 2542 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2690 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
| 2691 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
| 2692 | + } |
|
| 2543 | 2693 | |
| 2544 | 2694 | // Make sure cache directory exists and is writable! |
| 2545 | 2695 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
| 2546 | - if (!file_exists($cachedir_temp)) |
|
| 2547 | - @mkdir($cachedir_temp); |
|
| 2696 | + if (!file_exists($cachedir_temp)) { |
|
| 2697 | + @mkdir($cachedir_temp); |
|
| 2698 | + } |
|
| 2548 | 2699 | |
| 2549 | 2700 | // Make sure the cache temp dir is writable. |
| 2550 | 2701 | quickFileWritable($cachedir_temp); |
| 2551 | 2702 | |
| 2552 | - if (!is_writable($cachedir_temp)) |
|
| 2553 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2703 | + if (!is_writable($cachedir_temp)) { |
|
| 2704 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
| 2705 | + } |
|
| 2554 | 2706 | |
| 2555 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
| 2556 | - print_error('Error: Unable to find language files!', true); |
|
| 2557 | - else |
|
| 2707 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
| 2708 | + print_error('Error: Unable to find language files!', true); |
|
| 2709 | + } else |
|
| 2558 | 2710 | { |
| 2559 | 2711 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
| 2560 | 2712 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
| 2561 | 2713 | |
| 2562 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
| 2563 | - print_error('Error: Language files out of date.', true); |
|
| 2564 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
| 2565 | - print_error('Error: Install language is missing for selected language.', true); |
|
| 2714 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
| 2715 | + print_error('Error: Language files out of date.', true); |
|
| 2716 | + } |
|
| 2717 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
| 2718 | + print_error('Error: Install language is missing for selected language.', true); |
|
| 2719 | + } |
|
| 2566 | 2720 | |
| 2567 | 2721 | // Otherwise include it! |
| 2568 | 2722 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2591,8 +2745,7 @@ discard block |
||
| 2591 | 2745 | ); |
| 2592 | 2746 | |
| 2593 | 2747 | return true; |
| 2594 | - } |
|
| 2595 | - else |
|
| 2748 | + } else |
|
| 2596 | 2749 | { |
| 2597 | 2750 | $upcontext['page_title'] = 'Converting to UTF8'; |
| 2598 | 2751 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2636,8 +2789,9 @@ discard block |
||
| 2636 | 2789 | ) |
| 2637 | 2790 | ); |
| 2638 | 2791 | $db_charsets = array(); |
| 2639 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2640 | - $db_charsets[] = $row['Charset']; |
|
| 2792 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2793 | + $db_charsets[] = $row['Charset']; |
|
| 2794 | + } |
|
| 2641 | 2795 | |
| 2642 | 2796 | $smcFunc['db_free_result']($request); |
| 2643 | 2797 | |
@@ -2673,13 +2827,15 @@ discard block |
||
| 2673 | 2827 | // If there's a fulltext index, we need to drop it first... |
| 2674 | 2828 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 2675 | 2829 | { |
| 2676 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2677 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2830 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2831 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 2678 | 2832 | $upcontext['fulltext_index'][] = $row['Key_name']; |
| 2833 | + } |
|
| 2679 | 2834 | $smcFunc['db_free_result']($request); |
| 2680 | 2835 | |
| 2681 | - if (isset($upcontext['fulltext_index'])) |
|
| 2682 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2836 | + if (isset($upcontext['fulltext_index'])) { |
|
| 2837 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
| 2838 | + } |
|
| 2683 | 2839 | } |
| 2684 | 2840 | |
| 2685 | 2841 | // Drop it and make a note... |
@@ -2869,8 +3025,9 @@ discard block |
||
| 2869 | 3025 | $replace = '%field%'; |
| 2870 | 3026 | |
| 2871 | 3027 | // Build a huge REPLACE statement... |
| 2872 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
| 2873 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3028 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
| 3029 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
| 3030 | + } |
|
| 2874 | 3031 | } |
| 2875 | 3032 | |
| 2876 | 3033 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2904,8 +3061,9 @@ discard block |
||
| 2904 | 3061 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 2905 | 3062 | |
| 2906 | 3063 | // Just to make sure it doesn't time out. |
| 2907 | - if (function_exists('apache_reset_timeout')) |
|
| 2908 | - @apache_reset_timeout(); |
|
| 3064 | + if (function_exists('apache_reset_timeout')) { |
|
| 3065 | + @apache_reset_timeout(); |
|
| 3066 | + } |
|
| 2909 | 3067 | |
| 2910 | 3068 | $table_charsets = array(); |
| 2911 | 3069 | |
@@ -2926,8 +3084,9 @@ discard block |
||
| 2926 | 3084 | { |
| 2927 | 3085 | list($charset) = explode('_', $collation); |
| 2928 | 3086 | |
| 2929 | - if (!isset($table_charsets[$charset])) |
|
| 2930 | - $table_charsets[$charset] = array(); |
|
| 3087 | + if (!isset($table_charsets[$charset])) { |
|
| 3088 | + $table_charsets[$charset] = array(); |
|
| 3089 | + } |
|
| 2931 | 3090 | |
| 2932 | 3091 | $table_charsets[$charset][] = $column_info; |
| 2933 | 3092 | } |
@@ -2967,10 +3126,11 @@ discard block |
||
| 2967 | 3126 | if (isset($translation_tables[$upcontext['charset_detected']])) |
| 2968 | 3127 | { |
| 2969 | 3128 | $update = ''; |
| 2970 | - foreach ($table_charsets as $charset => $columns) |
|
| 2971 | - foreach ($columns as $column) |
|
| 3129 | + foreach ($table_charsets as $charset => $columns) { |
|
| 3130 | + foreach ($columns as $column) |
|
| 2972 | 3131 | $update .= ' |
| 2973 | 3132 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
| 3133 | + } |
|
| 2974 | 3134 | |
| 2975 | 3135 | $smcFunc['db_query']('', ' |
| 2976 | 3136 | UPDATE {raw:table_name} |
@@ -2995,8 +3155,9 @@ discard block |
||
| 2995 | 3155 | // Now do the actual conversion (if still needed). |
| 2996 | 3156 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
| 2997 | 3157 | { |
| 2998 | - if ($command_line) |
|
| 2999 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3158 | + if ($command_line) { |
|
| 3159 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
| 3160 | + } |
|
| 3000 | 3161 | |
| 3001 | 3162 | $smcFunc['db_query']('', ' |
| 3002 | 3163 | ALTER TABLE {raw:table_name} |
@@ -3006,8 +3167,9 @@ discard block |
||
| 3006 | 3167 | ) |
| 3007 | 3168 | ); |
| 3008 | 3169 | |
| 3009 | - if ($command_line) |
|
| 3010 | - echo " done.\n"; |
|
| 3170 | + if ($command_line) { |
|
| 3171 | + echo " done.\n"; |
|
| 3172 | + } |
|
| 3011 | 3173 | } |
| 3012 | 3174 | } |
| 3013 | 3175 | |
@@ -3037,8 +3199,8 @@ discard block |
||
| 3037 | 3199 | ); |
| 3038 | 3200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 3039 | 3201 | { |
| 3040 | - 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) |
|
| 3041 | - $smcFunc['db_query']('', ' |
|
| 3202 | + 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) { |
|
| 3203 | + $smcFunc['db_query']('', ' |
|
| 3042 | 3204 | UPDATE {db_prefix}log_actions |
| 3043 | 3205 | SET extra = {string:extra} |
| 3044 | 3206 | WHERE id_action = {int:current_action}', |
@@ -3047,6 +3209,7 @@ discard block |
||
| 3047 | 3209 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 3048 | 3210 | ) |
| 3049 | 3211 | ); |
| 3212 | + } |
|
| 3050 | 3213 | } |
| 3051 | 3214 | $smcFunc['db_free_result']($request); |
| 3052 | 3215 | |
@@ -3068,15 +3231,17 @@ discard block |
||
| 3068 | 3231 | // First thing's first - did we already do this? |
| 3069 | 3232 | if (!empty($modSettings['json_done'])) |
| 3070 | 3233 | { |
| 3071 | - if ($command_line) |
|
| 3072 | - return DeleteUpgrade(); |
|
| 3073 | - else |
|
| 3074 | - return true; |
|
| 3234 | + if ($command_line) { |
|
| 3235 | + return DeleteUpgrade(); |
|
| 3236 | + } else { |
|
| 3237 | + return true; |
|
| 3238 | + } |
|
| 3075 | 3239 | } |
| 3076 | 3240 | |
| 3077 | 3241 | // Done it already - js wise? |
| 3078 | - if (!empty($_POST['json_done'])) |
|
| 3079 | - return true; |
|
| 3242 | + if (!empty($_POST['json_done'])) { |
|
| 3243 | + return true; |
|
| 3244 | + } |
|
| 3080 | 3245 | |
| 3081 | 3246 | // List of tables affected by this function |
| 3082 | 3247 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -3107,12 +3272,14 @@ discard block |
||
| 3107 | 3272 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
| 3108 | 3273 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
| 3109 | 3274 | |
| 3110 | - foreach ($keys as $id => $table) |
|
| 3111 | - if ($id < $_GET['substep']) |
|
| 3275 | + foreach ($keys as $id => $table) { |
|
| 3276 | + if ($id < $_GET['substep']) |
|
| 3112 | 3277 | $upcontext['previous_tables'][] = $table; |
| 3278 | + } |
|
| 3113 | 3279 | |
| 3114 | - if ($command_line) |
|
| 3115 | - echo 'Converting data from serialize() to json_encode().'; |
|
| 3280 | + if ($command_line) { |
|
| 3281 | + echo 'Converting data from serialize() to json_encode().'; |
|
| 3282 | + } |
|
| 3116 | 3283 | |
| 3117 | 3284 | if (!$support_js || isset($_GET['xml'])) |
| 3118 | 3285 | { |
@@ -3152,8 +3319,9 @@ discard block |
||
| 3152 | 3319 | |
| 3153 | 3320 | // Loop through and fix these... |
| 3154 | 3321 | $new_settings = array(); |
| 3155 | - if ($command_line) |
|
| 3156 | - echo "\n" . 'Fixing some settings...'; |
|
| 3322 | + if ($command_line) { |
|
| 3323 | + echo "\n" . 'Fixing some settings...'; |
|
| 3324 | + } |
|
| 3157 | 3325 | |
| 3158 | 3326 | foreach ($serialized_settings as $var) |
| 3159 | 3327 | { |
@@ -3161,22 +3329,24 @@ discard block |
||
| 3161 | 3329 | { |
| 3162 | 3330 | // Attempt to unserialize the setting |
| 3163 | 3331 | $temp = @safe_unserialize($modSettings[$var]); |
| 3164 | - if (!$temp && $command_line) |
|
| 3165 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3166 | - elseif ($temp !== false) |
|
| 3167 | - $new_settings[$var] = json_encode($temp); |
|
| 3332 | + if (!$temp && $command_line) { |
|
| 3333 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
| 3334 | + } elseif ($temp !== false) { |
|
| 3335 | + $new_settings[$var] = json_encode($temp); |
|
| 3336 | + } |
|
| 3168 | 3337 | } |
| 3169 | 3338 | } |
| 3170 | 3339 | |
| 3171 | 3340 | // Update everything at once |
| 3172 | - if (!function_exists('cache_put_data')) |
|
| 3173 | - require_once($sourcedir . '/Load.php'); |
|
| 3341 | + if (!function_exists('cache_put_data')) { |
|
| 3342 | + require_once($sourcedir . '/Load.php'); |
|
| 3343 | + } |
|
| 3174 | 3344 | updateSettings($new_settings, true); |
| 3175 | 3345 | |
| 3176 | - if ($command_line) |
|
| 3177 | - echo ' done.'; |
|
| 3178 | - } |
|
| 3179 | - elseif ($table == 'themes') |
|
| 3346 | + if ($command_line) { |
|
| 3347 | + echo ' done.'; |
|
| 3348 | + } |
|
| 3349 | + } elseif ($table == 'themes') |
|
| 3180 | 3350 | { |
| 3181 | 3351 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
| 3182 | 3352 | $query = $smcFunc['db_query']('', ' |
@@ -3195,10 +3365,11 @@ discard block |
||
| 3195 | 3365 | |
| 3196 | 3366 | if ($command_line) |
| 3197 | 3367 | { |
| 3198 | - if ($temp === false) |
|
| 3199 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3200 | - else |
|
| 3201 | - echo "\n" . 'Fixing admin preferences...'; |
|
| 3368 | + if ($temp === false) { |
|
| 3369 | + echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
| 3370 | + } else { |
|
| 3371 | + echo "\n" . 'Fixing admin preferences...'; |
|
| 3372 | + } |
|
| 3202 | 3373 | } |
| 3203 | 3374 | |
| 3204 | 3375 | if ($temp !== false) |
@@ -3218,15 +3389,15 @@ discard block |
||
| 3218 | 3389 | ) |
| 3219 | 3390 | ); |
| 3220 | 3391 | |
| 3221 | - if ($command_line) |
|
| 3222 | - echo ' done.'; |
|
| 3392 | + if ($command_line) { |
|
| 3393 | + echo ' done.'; |
|
| 3394 | + } |
|
| 3223 | 3395 | } |
| 3224 | 3396 | } |
| 3225 | 3397 | |
| 3226 | 3398 | $smcFunc['db_free_result']($query); |
| 3227 | 3399 | } |
| 3228 | - } |
|
| 3229 | - else |
|
| 3400 | + } else |
|
| 3230 | 3401 | { |
| 3231 | 3402 | // First item is always the key... |
| 3232 | 3403 | $key = $info[0]; |
@@ -3237,8 +3408,7 @@ discard block |
||
| 3237 | 3408 | { |
| 3238 | 3409 | $col_select = $info[1]; |
| 3239 | 3410 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
| 3240 | - } |
|
| 3241 | - else |
|
| 3411 | + } else |
|
| 3242 | 3412 | { |
| 3243 | 3413 | $col_select = implode(', ', $info); |
| 3244 | 3414 | } |
@@ -3271,8 +3441,7 @@ discard block |
||
| 3271 | 3441 | if ($temp === false && $command_line) |
| 3272 | 3442 | { |
| 3273 | 3443 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
| 3274 | - } |
|
| 3275 | - else |
|
| 3444 | + } else |
|
| 3276 | 3445 | { |
| 3277 | 3446 | $row[$col] = json_encode($temp); |
| 3278 | 3447 | |
@@ -3297,16 +3466,18 @@ discard block |
||
| 3297 | 3466 | } |
| 3298 | 3467 | } |
| 3299 | 3468 | |
| 3300 | - if ($command_line) |
|
| 3301 | - echo ' done.'; |
|
| 3469 | + if ($command_line) { |
|
| 3470 | + echo ' done.'; |
|
| 3471 | + } |
|
| 3302 | 3472 | |
| 3303 | 3473 | // Free up some memory... |
| 3304 | 3474 | $smcFunc['db_free_result']($query); |
| 3305 | 3475 | } |
| 3306 | 3476 | } |
| 3307 | 3477 | // If this is XML to keep it nice for the user do one table at a time anyway! |
| 3308 | - if (isset($_GET['xml'])) |
|
| 3309 | - return upgradeExit(); |
|
| 3478 | + if (isset($_GET['xml'])) { |
|
| 3479 | + return upgradeExit(); |
|
| 3480 | + } |
|
| 3310 | 3481 | } |
| 3311 | 3482 | |
| 3312 | 3483 | if ($command_line) |
@@ -3321,8 +3492,9 @@ discard block |
||
| 3321 | 3492 | |
| 3322 | 3493 | $_GET['substep'] = 0; |
| 3323 | 3494 | // Make sure we move on! |
| 3324 | - if ($command_line) |
|
| 3325 | - return DeleteUpgrade(); |
|
| 3495 | + if ($command_line) { |
|
| 3496 | + return DeleteUpgrade(); |
|
| 3497 | + } |
|
| 3326 | 3498 | |
| 3327 | 3499 | return true; |
| 3328 | 3500 | } |
@@ -3342,14 +3514,16 @@ discard block |
||
| 3342 | 3514 | global $upcontext, $txt, $settings; |
| 3343 | 3515 | |
| 3344 | 3516 | // Don't call me twice! |
| 3345 | - if (!empty($upcontext['chmod_called'])) |
|
| 3346 | - return; |
|
| 3517 | + if (!empty($upcontext['chmod_called'])) { |
|
| 3518 | + return; |
|
| 3519 | + } |
|
| 3347 | 3520 | |
| 3348 | 3521 | $upcontext['chmod_called'] = true; |
| 3349 | 3522 | |
| 3350 | 3523 | // Nothing? |
| 3351 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
| 3352 | - return; |
|
| 3524 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
| 3525 | + return; |
|
| 3526 | + } |
|
| 3353 | 3527 | |
| 3354 | 3528 | // Was it a problem with Windows? |
| 3355 | 3529 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3381,11 +3555,12 @@ discard block |
||
| 3381 | 3555 | 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\'); |
| 3382 | 3556 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
| 3383 | 3557 | |
| 3384 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
| 3385 | - echo ' |
|
| 3558 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
| 3559 | + echo ' |
|
| 3386 | 3560 | content.write(\'<hr>\n\t\t\t\'); |
| 3387 | 3561 | 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\'); |
| 3388 | 3562 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
| 3563 | + } |
|
| 3389 | 3564 | |
| 3390 | 3565 | echo ' |
| 3391 | 3566 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3393,17 +3568,19 @@ discard block |
||
| 3393 | 3568 | } |
| 3394 | 3569 | </script>'; |
| 3395 | 3570 | |
| 3396 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
| 3397 | - echo ' |
|
| 3571 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
| 3572 | + echo ' |
|
| 3398 | 3573 | <div class="error_message red"> |
| 3399 | 3574 | The following error was encountered when trying to connect:<br><br> |
| 3400 | 3575 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
| 3401 | 3576 | </div> |
| 3402 | 3577 | <br>'; |
| 3578 | + } |
|
| 3403 | 3579 | |
| 3404 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3405 | - echo ' |
|
| 3580 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3581 | + echo ' |
|
| 3406 | 3582 | <form action="', $upcontext['form_url'], '" method="post">'; |
| 3583 | + } |
|
| 3407 | 3584 | |
| 3408 | 3585 | echo ' |
| 3409 | 3586 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3438,10 +3615,11 @@ discard block |
||
| 3438 | 3615 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
| 3439 | 3616 | </div>'; |
| 3440 | 3617 | |
| 3441 | - if (empty($upcontext['chmod_in_form'])) |
|
| 3442 | - echo ' |
|
| 3618 | + if (empty($upcontext['chmod_in_form'])) { |
|
| 3619 | + echo ' |
|
| 3443 | 3620 | </form>'; |
| 3444 | -} |
|
| 3621 | + } |
|
| 3622 | + } |
|
| 3445 | 3623 | |
| 3446 | 3624 | function template_upgrade_above() |
| 3447 | 3625 | { |
@@ -3501,9 +3679,10 @@ discard block |
||
| 3501 | 3679 | <h2>', $txt['upgrade_progress'], '</h2> |
| 3502 | 3680 | <ul>'; |
| 3503 | 3681 | |
| 3504 | - foreach ($upcontext['steps'] as $num => $step) |
|
| 3505 | - echo ' |
|
| 3682 | + foreach ($upcontext['steps'] as $num => $step) { |
|
| 3683 | + echo ' |
|
| 3506 | 3684 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 3685 | + } |
|
| 3507 | 3686 | |
| 3508 | 3687 | echo ' |
| 3509 | 3688 | </ul> |
@@ -3516,8 +3695,8 @@ discard block |
||
| 3516 | 3695 | </div> |
| 3517 | 3696 | </div>'; |
| 3518 | 3697 | |
| 3519 | - if (isset($upcontext['step_progress'])) |
|
| 3520 | - echo ' |
|
| 3698 | + if (isset($upcontext['step_progress'])) { |
|
| 3699 | + echo ' |
|
| 3521 | 3700 | <br> |
| 3522 | 3701 | <br> |
| 3523 | 3702 | <div id="progress_bar_step"> |
@@ -3526,6 +3705,7 @@ discard block |
||
| 3526 | 3705 | <span>', $txt['upgrade_step_progress'], '</span> |
| 3527 | 3706 | </div> |
| 3528 | 3707 | </div>'; |
| 3708 | + } |
|
| 3529 | 3709 | |
| 3530 | 3710 | echo ' |
| 3531 | 3711 | <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> |
@@ -3556,32 +3736,36 @@ discard block |
||
| 3556 | 3736 | { |
| 3557 | 3737 | global $upcontext, $txt; |
| 3558 | 3738 | |
| 3559 | - if (!empty($upcontext['pause'])) |
|
| 3560 | - echo ' |
|
| 3739 | + if (!empty($upcontext['pause'])) { |
|
| 3740 | + echo ' |
|
| 3561 | 3741 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
| 3562 | 3742 | |
| 3563 | 3743 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
| 3564 | 3744 | <h3> |
| 3565 | 3745 | ', $txt['upgrade_paused_overload'], ' |
| 3566 | 3746 | </h3>'; |
| 3747 | + } |
|
| 3567 | 3748 | |
| 3568 | - if (!empty($upcontext['custom_warning'])) |
|
| 3569 | - echo ' |
|
| 3749 | + if (!empty($upcontext['custom_warning'])) { |
|
| 3750 | + echo ' |
|
| 3570 | 3751 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3571 | 3752 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3572 | 3753 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
| 3573 | 3754 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
| 3574 | 3755 | </div>'; |
| 3756 | + } |
|
| 3575 | 3757 | |
| 3576 | 3758 | echo ' |
| 3577 | 3759 | <div class="righttext" style="margin: 1ex;">'; |
| 3578 | 3760 | |
| 3579 | - if (!empty($upcontext['continue'])) |
|
| 3580 | - echo ' |
|
| 3761 | + if (!empty($upcontext['continue'])) { |
|
| 3762 | + echo ' |
|
| 3581 | 3763 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
| 3582 | - if (!empty($upcontext['skip'])) |
|
| 3583 | - echo ' |
|
| 3764 | + } |
|
| 3765 | + if (!empty($upcontext['skip'])) { |
|
| 3766 | + echo ' |
|
| 3584 | 3767 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
| 3768 | + } |
|
| 3585 | 3769 | |
| 3586 | 3770 | echo ' |
| 3587 | 3771 | </div> |
@@ -3631,11 +3815,12 @@ discard block |
||
| 3631 | 3815 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
| 3632 | 3816 | <smf>'; |
| 3633 | 3817 | |
| 3634 | - if (!empty($upcontext['get_data'])) |
|
| 3635 | - foreach ($upcontext['get_data'] as $k => $v) |
|
| 3818 | + if (!empty($upcontext['get_data'])) { |
|
| 3819 | + foreach ($upcontext['get_data'] as $k => $v) |
|
| 3636 | 3820 | echo ' |
| 3637 | 3821 | <get key="', $k, '">', $v, '</get>'; |
| 3638 | -} |
|
| 3822 | + } |
|
| 3823 | + } |
|
| 3639 | 3824 | |
| 3640 | 3825 | function template_xml_below() |
| 3641 | 3826 | { |
@@ -3676,8 +3861,8 @@ discard block |
||
| 3676 | 3861 | template_chmod(); |
| 3677 | 3862 | |
| 3678 | 3863 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
| 3679 | - if ($upcontext['is_large_forum']) |
|
| 3680 | - echo ' |
|
| 3864 | + if ($upcontext['is_large_forum']) { |
|
| 3865 | + echo ' |
|
| 3681 | 3866 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3682 | 3867 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3683 | 3868 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3685,10 +3870,11 @@ discard block |
||
| 3685 | 3870 | ', $txt['upgrade_warning_lots_data'], ' |
| 3686 | 3871 | </div> |
| 3687 | 3872 | </div>'; |
| 3873 | + } |
|
| 3688 | 3874 | |
| 3689 | 3875 | // A warning message? |
| 3690 | - if (!empty($upcontext['warning'])) |
|
| 3691 | - echo ' |
|
| 3876 | + if (!empty($upcontext['warning'])) { |
|
| 3877 | + echo ' |
|
| 3692 | 3878 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3693 | 3879 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3694 | 3880 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3696,6 +3882,7 @@ discard block |
||
| 3696 | 3882 | ', $upcontext['warning'], ' |
| 3697 | 3883 | </div> |
| 3698 | 3884 | </div>'; |
| 3885 | + } |
|
| 3699 | 3886 | |
| 3700 | 3887 | // Paths are incorrect? |
| 3701 | 3888 | echo ' |
@@ -3711,20 +3898,22 @@ discard block |
||
| 3711 | 3898 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
| 3712 | 3899 | { |
| 3713 | 3900 | $ago = time() - $upcontext['started']; |
| 3714 | - if ($ago < 60) |
|
| 3715 | - $ago = $ago . ' seconds'; |
|
| 3716 | - elseif ($ago < 3600) |
|
| 3717 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3718 | - else |
|
| 3719 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3901 | + if ($ago < 60) { |
|
| 3902 | + $ago = $ago . ' seconds'; |
|
| 3903 | + } elseif ($ago < 3600) { |
|
| 3904 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
| 3905 | + } else { |
|
| 3906 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
| 3907 | + } |
|
| 3720 | 3908 | |
| 3721 | 3909 | $active = time() - $upcontext['updated']; |
| 3722 | - if ($active < 60) |
|
| 3723 | - $updated = $active . ' seconds'; |
|
| 3724 | - elseif ($active < 3600) |
|
| 3725 | - $updated = (int) ($active / 60) . ' minutes'; |
|
| 3726 | - else |
|
| 3727 | - $updated = (int) ($active / 3600) . ' hours'; |
|
| 3910 | + if ($active < 60) { |
|
| 3911 | + $updated = $active . ' seconds'; |
|
| 3912 | + } elseif ($active < 3600) { |
|
| 3913 | + $updated = (int) ($active / 60) . ' minutes'; |
|
| 3914 | + } else { |
|
| 3915 | + $updated = (int) ($active / 3600) . ' hours'; |
|
| 3916 | + } |
|
| 3728 | 3917 | |
| 3729 | 3918 | echo ' |
| 3730 | 3919 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3733,16 +3922,18 @@ discard block |
||
| 3733 | 3922 | <div style="padding-left: 6ex;"> |
| 3734 | 3923 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
| 3735 | 3924 | |
| 3736 | - if ($active < 600) |
|
| 3737 | - echo ' |
|
| 3925 | + if ($active < 600) { |
|
| 3926 | + echo ' |
|
| 3738 | 3927 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
| 3928 | + } |
|
| 3739 | 3929 | |
| 3740 | - if ($active > $upcontext['inactive_timeout']) |
|
| 3741 | - echo ' |
|
| 3930 | + if ($active > $upcontext['inactive_timeout']) { |
|
| 3931 | + echo ' |
|
| 3742 | 3932 | <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.'; |
| 3743 | - else |
|
| 3744 | - echo ' |
|
| 3933 | + } else { |
|
| 3934 | + echo ' |
|
| 3745 | 3935 | <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!'); |
| 3936 | + } |
|
| 3746 | 3937 | |
| 3747 | 3938 | echo ' |
| 3748 | 3939 | </div> |
@@ -3758,9 +3949,10 @@ discard block |
||
| 3758 | 3949 | <td> |
| 3759 | 3950 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
| 3760 | 3951 | |
| 3761 | - if (!empty($upcontext['username_incorrect'])) |
|
| 3762 | - echo ' |
|
| 3952 | + if (!empty($upcontext['username_incorrect'])) { |
|
| 3953 | + echo ' |
|
| 3763 | 3954 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
| 3955 | + } |
|
| 3764 | 3956 | |
| 3765 | 3957 | echo ' |
| 3766 | 3958 | </td> |
@@ -3771,9 +3963,10 @@ discard block |
||
| 3771 | 3963 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
| 3772 | 3964 | <input type="hidden" name="hash_passwrd" value="">'; |
| 3773 | 3965 | |
| 3774 | - if (!empty($upcontext['password_failed'])) |
|
| 3775 | - echo ' |
|
| 3966 | + if (!empty($upcontext['password_failed'])) { |
|
| 3967 | + echo ' |
|
| 3776 | 3968 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
| 3969 | + } |
|
| 3777 | 3970 | |
| 3778 | 3971 | echo ' |
| 3779 | 3972 | </td> |
@@ -3844,8 +4037,8 @@ discard block |
||
| 3844 | 4037 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
| 3845 | 4038 | |
| 3846 | 4039 | // Warning message? |
| 3847 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
| 3848 | - echo ' |
|
| 4040 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
| 4041 | + echo ' |
|
| 3849 | 4042 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 3850 | 4043 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 3851 | 4044 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3853,6 +4046,7 @@ discard block |
||
| 3853 | 4046 | ', $upcontext['upgrade_options_warning'], ' |
| 3854 | 4047 | </div> |
| 3855 | 4048 | </div>'; |
| 4049 | + } |
|
| 3856 | 4050 | |
| 3857 | 4051 | echo ' |
| 3858 | 4052 | <table> |
@@ -3880,8 +4074,8 @@ discard block |
||
| 3880 | 4074 | </tr>'; |
| 3881 | 4075 | |
| 3882 | 4076 | // Offer mysql users to switch to mysqli |
| 3883 | - if ($db_type == 'mysql' && function_exists('mysqli_query')) |
|
| 3884 | - echo ' |
|
| 4077 | + if ($db_type == 'mysql' && function_exists('mysqli_query')) { |
|
| 4078 | + echo ' |
|
| 3885 | 4079 | <tr valign="top"> |
| 3886 | 4080 | <td width="2%"> |
| 3887 | 4081 | <input type="checkbox" name="convertMysql" id="convertMysql" value="1" checked class="input_check"> |
@@ -3891,6 +4085,7 @@ discard block |
||
| 3891 | 4085 | <strong class="smalltext"><a href="http://wiki.simplemachines.org/smf/Upgrading-MySQLi-Functionality" target="_blank">More information about MySQLi</a></strong><br> |
| 3892 | 4086 | </td> |
| 3893 | 4087 | </tr>'; |
| 4088 | + } |
|
| 3894 | 4089 | |
| 3895 | 4090 | echo ' |
| 3896 | 4091 | <tr valign="top"> |
@@ -3910,8 +4105,8 @@ discard block |
||
| 3910 | 4105 | </td> |
| 3911 | 4106 | </tr>'; |
| 3912 | 4107 | |
| 3913 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
| 3914 | - echo ' |
|
| 4108 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
| 4109 | + echo ' |
|
| 3915 | 4110 | <tr valign="top"> |
| 3916 | 4111 | <td width="2%"> |
| 3917 | 4112 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3920,6 +4115,7 @@ discard block |
||
| 3920 | 4115 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
| 3921 | 4116 | </td> |
| 3922 | 4117 | </tr>'; |
| 4118 | + } |
|
| 3923 | 4119 | |
| 3924 | 4120 | echo ' |
| 3925 | 4121 | <tr valign="top"> |
@@ -3955,10 +4151,11 @@ discard block |
||
| 3955 | 4151 | <span id="debuginfo"></span>'; |
| 3956 | 4152 | |
| 3957 | 4153 | // Dont any tables so far? |
| 3958 | - if (!empty($upcontext['previous_tables'])) |
|
| 3959 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4154 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4155 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 3960 | 4156 | echo ' |
| 3961 | 4157 | <br>Completed Table: "', $table, '".'; |
| 4158 | + } |
|
| 3962 | 4159 | |
| 3963 | 4160 | echo ' |
| 3964 | 4161 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3995,12 +4192,13 @@ discard block |
||
| 3995 | 4192 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 3996 | 4193 | |
| 3997 | 4194 | // If debug flood the screen. |
| 3998 | - if ($is_debug) |
|
| 3999 | - echo ' |
|
| 4195 | + if ($is_debug) { |
|
| 4196 | + echo ' |
|
| 4000 | 4197 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
| 4001 | 4198 | |
| 4002 | 4199 | if (document.getElementById(\'debuginfo\').scrollHeight) |
| 4003 | 4200 | document.getElementById(\'debuginfo\').scrollTop = document.getElementById(\'debuginfo\').scrollHeight;'; |
| 4201 | + } |
|
| 4004 | 4202 | |
| 4005 | 4203 | echo ' |
| 4006 | 4204 | // Get the next update... |
@@ -4032,8 +4230,9 @@ discard block |
||
| 4032 | 4230 | { |
| 4033 | 4231 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
| 4034 | 4232 | |
| 4035 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
| 4036 | - $is_debug = true; |
|
| 4233 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
| 4234 | + $is_debug = true; |
|
| 4235 | + } |
|
| 4037 | 4236 | |
| 4038 | 4237 | echo ' |
| 4039 | 4238 | <h3>Executing database changes</h3> |
@@ -4048,8 +4247,9 @@ discard block |
||
| 4048 | 4247 | { |
| 4049 | 4248 | foreach ($upcontext['actioned_items'] as $num => $item) |
| 4050 | 4249 | { |
| 4051 | - if ($num != 0) |
|
| 4052 | - echo ' Successful!'; |
|
| 4250 | + if ($num != 0) { |
|
| 4251 | + echo ' Successful!'; |
|
| 4252 | + } |
|
| 4053 | 4253 | echo '<br>' . $item; |
| 4054 | 4254 | } |
| 4055 | 4255 | if (!empty($upcontext['changes_complete'])) |
@@ -4062,28 +4262,32 @@ discard block |
||
| 4062 | 4262 | $seconds = intval($active % 60); |
| 4063 | 4263 | |
| 4064 | 4264 | $totalTime = ''; |
| 4065 | - if ($hours > 0) |
|
| 4066 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4067 | - if ($minutes > 0) |
|
| 4068 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4069 | - if ($seconds > 0) |
|
| 4070 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4265 | + if ($hours > 0) { |
|
| 4266 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4267 | + } |
|
| 4268 | + if ($minutes > 0) { |
|
| 4269 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4270 | + } |
|
| 4271 | + if ($seconds > 0) { |
|
| 4272 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4273 | + } |
|
| 4071 | 4274 | } |
| 4072 | 4275 | |
| 4073 | - if ($is_debug && !empty($totalTime)) |
|
| 4074 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4075 | - else |
|
| 4076 | - echo ' Successful!<br><br>'; |
|
| 4276 | + if ($is_debug && !empty($totalTime)) { |
|
| 4277 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
| 4278 | + } else { |
|
| 4279 | + echo ' Successful!<br><br>'; |
|
| 4280 | + } |
|
| 4077 | 4281 | |
| 4078 | 4282 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
| 4079 | 4283 | } |
| 4080 | - } |
|
| 4081 | - else |
|
| 4284 | + } else |
|
| 4082 | 4285 | { |
| 4083 | 4286 | // Tell them how many files we have in total. |
| 4084 | - if ($upcontext['file_count'] > 1) |
|
| 4085 | - echo ' |
|
| 4287 | + if ($upcontext['file_count'] > 1) { |
|
| 4288 | + echo ' |
|
| 4086 | 4289 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
| 4290 | + } |
|
| 4087 | 4291 | |
| 4088 | 4292 | echo ' |
| 4089 | 4293 | <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> |
@@ -4099,19 +4303,23 @@ discard block |
||
| 4099 | 4303 | $seconds = intval($active % 60); |
| 4100 | 4304 | |
| 4101 | 4305 | $totalTime = ''; |
| 4102 | - if ($hours > 0) |
|
| 4103 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4104 | - if ($minutes > 0) |
|
| 4105 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4106 | - if ($seconds > 0) |
|
| 4107 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4306 | + if ($hours > 0) { |
|
| 4307 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4308 | + } |
|
| 4309 | + if ($minutes > 0) { |
|
| 4310 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4311 | + } |
|
| 4312 | + if ($seconds > 0) { |
|
| 4313 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4314 | + } |
|
| 4108 | 4315 | } |
| 4109 | 4316 | |
| 4110 | 4317 | echo ' |
| 4111 | 4318 | <br><span id="upgradeCompleted">'; |
| 4112 | 4319 | |
| 4113 | - if (!empty($totalTime)) |
|
| 4114 | - echo 'Completed in ', $totalTime, '<br>'; |
|
| 4320 | + if (!empty($totalTime)) { |
|
| 4321 | + echo 'Completed in ', $totalTime, '<br>'; |
|
| 4322 | + } |
|
| 4115 | 4323 | |
| 4116 | 4324 | echo '</span> |
| 4117 | 4325 | <div id="debug_section" style="height: 200px; overflow: auto;"> |
@@ -4148,9 +4356,10 @@ discard block |
||
| 4148 | 4356 | var getData = ""; |
| 4149 | 4357 | var debugItems = ', $upcontext['debug_items'], ';'; |
| 4150 | 4358 | |
| 4151 | - if ($is_debug) |
|
| 4152 | - echo ' |
|
| 4359 | + if ($is_debug) { |
|
| 4360 | + echo ' |
|
| 4153 | 4361 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
| 4362 | + } |
|
| 4154 | 4363 | |
| 4155 | 4364 | echo ' |
| 4156 | 4365 | function getNextItem() |
@@ -4190,9 +4399,10 @@ discard block |
||
| 4190 | 4399 | document.getElementById("error_block").style.display = ""; |
| 4191 | 4400 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
| 4192 | 4401 | |
| 4193 | - if ($is_debug) |
|
| 4194 | - echo ' |
|
| 4402 | + if ($is_debug) { |
|
| 4403 | + echo ' |
|
| 4195 | 4404 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4405 | + } |
|
| 4196 | 4406 | |
| 4197 | 4407 | echo ' |
| 4198 | 4408 | } |
@@ -4213,9 +4423,10 @@ discard block |
||
| 4213 | 4423 | document.getElementById("error_block").style.display = ""; |
| 4214 | 4424 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
| 4215 | 4425 | |
| 4216 | - if ($is_debug) |
|
| 4217 | - echo ' |
|
| 4426 | + if ($is_debug) { |
|
| 4427 | + echo ' |
|
| 4218 | 4428 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
| 4429 | + } |
|
| 4219 | 4430 | |
| 4220 | 4431 | echo ' |
| 4221 | 4432 | } |
@@ -4274,8 +4485,8 @@ discard block |
||
| 4274 | 4485 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
| 4275 | 4486 | {'; |
| 4276 | 4487 | |
| 4277 | - if ($is_debug) |
|
| 4278 | - echo ' |
|
| 4488 | + if ($is_debug) { |
|
| 4489 | + echo ' |
|
| 4279 | 4490 | document.getElementById(\'debug_section\').style.display = "none"; |
| 4280 | 4491 | |
| 4281 | 4492 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4293,6 +4504,7 @@ discard block |
||
| 4293 | 4504 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
| 4294 | 4505 | |
| 4295 | 4506 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
| 4507 | + } |
|
| 4296 | 4508 | |
| 4297 | 4509 | echo ' |
| 4298 | 4510 | |
@@ -4300,9 +4512,10 @@ discard block |
||
| 4300 | 4512 | document.getElementById(\'contbutt\').disabled = 0; |
| 4301 | 4513 | document.getElementById(\'database_done\').value = 1;'; |
| 4302 | 4514 | |
| 4303 | - if ($upcontext['file_count'] > 1) |
|
| 4304 | - echo ' |
|
| 4515 | + if ($upcontext['file_count'] > 1) { |
|
| 4516 | + echo ' |
|
| 4305 | 4517 | document.getElementById(\'info1\').style.display = "none";'; |
| 4518 | + } |
|
| 4306 | 4519 | |
| 4307 | 4520 | echo ' |
| 4308 | 4521 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4315,9 +4528,10 @@ discard block |
||
| 4315 | 4528 | lastItem = 0; |
| 4316 | 4529 | prevFile = curFile;'; |
| 4317 | 4530 | |
| 4318 | - if ($is_debug) |
|
| 4319 | - echo ' |
|
| 4531 | + if ($is_debug) { |
|
| 4532 | + echo ' |
|
| 4320 | 4533 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
| 4534 | + } |
|
| 4321 | 4535 | |
| 4322 | 4536 | echo ' |
| 4323 | 4537 | getNextItem(); |
@@ -4325,8 +4539,8 @@ discard block |
||
| 4325 | 4539 | }'; |
| 4326 | 4540 | |
| 4327 | 4541 | // If debug scroll the screen. |
| 4328 | - if ($is_debug) |
|
| 4329 | - echo ' |
|
| 4542 | + if ($is_debug) { |
|
| 4543 | + echo ' |
|
| 4330 | 4544 | if (iLastSubStepProgress == -1) |
| 4331 | 4545 | { |
| 4332 | 4546 | // Give it consistent dots. |
@@ -4345,6 +4559,7 @@ discard block |
||
| 4345 | 4559 | |
| 4346 | 4560 | if (document.getElementById(\'debug_section\').scrollHeight) |
| 4347 | 4561 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
| 4562 | + } |
|
| 4348 | 4563 | |
| 4349 | 4564 | echo ' |
| 4350 | 4565 | // Update the page. |
@@ -4405,9 +4620,10 @@ discard block |
||
| 4405 | 4620 | }'; |
| 4406 | 4621 | |
| 4407 | 4622 | // Start things off assuming we've not errored. |
| 4408 | - if (empty($upcontext['error_message'])) |
|
| 4409 | - echo ' |
|
| 4623 | + if (empty($upcontext['error_message'])) { |
|
| 4624 | + echo ' |
|
| 4410 | 4625 | getNextItem();'; |
| 4626 | + } |
|
| 4411 | 4627 | |
| 4412 | 4628 | echo ' |
| 4413 | 4629 | </script>'; |
@@ -4424,18 +4640,21 @@ discard block |
||
| 4424 | 4640 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
| 4425 | 4641 | <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>'; |
| 4426 | 4642 | |
| 4427 | - if (!empty($upcontext['error_message'])) |
|
| 4428 | - echo ' |
|
| 4643 | + if (!empty($upcontext['error_message'])) { |
|
| 4644 | + echo ' |
|
| 4429 | 4645 | <error>', $upcontext['error_message'], '</error>'; |
| 4646 | + } |
|
| 4430 | 4647 | |
| 4431 | - if (!empty($upcontext['error_string'])) |
|
| 4432 | - echo ' |
|
| 4648 | + if (!empty($upcontext['error_string'])) { |
|
| 4649 | + echo ' |
|
| 4433 | 4650 | <sql>', $upcontext['error_string'], '</sql>'; |
| 4651 | + } |
|
| 4434 | 4652 | |
| 4435 | - if ($is_debug) |
|
| 4436 | - echo ' |
|
| 4653 | + if ($is_debug) { |
|
| 4654 | + echo ' |
|
| 4437 | 4655 | <curtime>', time(), '</curtime>'; |
| 4438 | -} |
|
| 4656 | + } |
|
| 4657 | + } |
|
| 4439 | 4658 | |
| 4440 | 4659 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
| 4441 | 4660 | function template_convert_utf8() |
@@ -4452,18 +4671,20 @@ discard block |
||
| 4452 | 4671 | <span id="debuginfo"></span>'; |
| 4453 | 4672 | |
| 4454 | 4673 | // Done any tables so far? |
| 4455 | - if (!empty($upcontext['previous_tables'])) |
|
| 4456 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4674 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4675 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4457 | 4676 | echo ' |
| 4458 | 4677 | <br>Completed Table: "', $table, '".'; |
| 4678 | + } |
|
| 4459 | 4679 | |
| 4460 | 4680 | echo ' |
| 4461 | 4681 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
| 4462 | 4682 | |
| 4463 | 4683 | // If we dropped their index, let's let them know |
| 4464 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
| 4465 | - echo ' |
|
| 4684 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
| 4685 | + echo ' |
|
| 4466 | 4686 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
| 4687 | + } |
|
| 4467 | 4688 | |
| 4468 | 4689 | echo ' |
| 4469 | 4690 | <br><span id="commess" style="font-weight: bold; display: ', $upcontext['cur_table_num'] == $upcontext['table_count'] ? 'inline' : 'none', ';">Conversion Complete! Click Continue to Proceed.</span>'; |
@@ -4499,9 +4720,10 @@ discard block |
||
| 4499 | 4720 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4500 | 4721 | |
| 4501 | 4722 | // If debug flood the screen. |
| 4502 | - if ($is_debug) |
|
| 4503 | - echo ' |
|
| 4723 | + if ($is_debug) { |
|
| 4724 | + echo ' |
|
| 4504 | 4725 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
| 4726 | + } |
|
| 4505 | 4727 | |
| 4506 | 4728 | echo ' |
| 4507 | 4729 | // Get the next update... |
@@ -4543,19 +4765,21 @@ discard block |
||
| 4543 | 4765 | <span id="debuginfo"></span>'; |
| 4544 | 4766 | |
| 4545 | 4767 | // Dont any tables so far? |
| 4546 | - if (!empty($upcontext['previous_tables'])) |
|
| 4547 | - foreach ($upcontext['previous_tables'] as $table) |
|
| 4768 | + if (!empty($upcontext['previous_tables'])) { |
|
| 4769 | + foreach ($upcontext['previous_tables'] as $table) |
|
| 4548 | 4770 | echo ' |
| 4549 | 4771 | <br>Completed Table: "', $table, '".'; |
| 4772 | + } |
|
| 4550 | 4773 | |
| 4551 | 4774 | echo ' |
| 4552 | 4775 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
| 4553 | 4776 | <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>'; |
| 4554 | 4777 | |
| 4555 | 4778 | // Try to make sure substep was reset. |
| 4556 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
| 4557 | - echo ' |
|
| 4779 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
| 4780 | + echo ' |
|
| 4558 | 4781 | <input type="hidden" name="substep" id="substep" value="0">'; |
| 4782 | + } |
|
| 4559 | 4783 | |
| 4560 | 4784 | // Continue please! |
| 4561 | 4785 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4588,9 +4812,10 @@ discard block |
||
| 4588 | 4812 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
| 4589 | 4813 | |
| 4590 | 4814 | // If debug flood the screen. |
| 4591 | - if ($is_debug) |
|
| 4592 | - echo ' |
|
| 4815 | + if ($is_debug) { |
|
| 4816 | + echo ' |
|
| 4593 | 4817 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
| 4818 | + } |
|
| 4594 | 4819 | |
| 4595 | 4820 | echo ' |
| 4596 | 4821 | // Get the next update... |
@@ -4625,8 +4850,8 @@ discard block |
||
| 4625 | 4850 | <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> |
| 4626 | 4851 | <form action="', $boardurl, '/index.php">'; |
| 4627 | 4852 | |
| 4628 | - if (!empty($upcontext['can_delete_script'])) |
|
| 4629 | - echo ' |
|
| 4853 | + if (!empty($upcontext['can_delete_script'])) { |
|
| 4854 | + echo ' |
|
| 4630 | 4855 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete(this);" class="input_check"> Delete upgrade.php and its data files now</label> <em>(doesn\'t work on all servers).</em> |
| 4631 | 4856 | <script> |
| 4632 | 4857 | function doTheDelete(theCheck) |
@@ -4638,6 +4863,7 @@ discard block |
||
| 4638 | 4863 | } |
| 4639 | 4864 | </script> |
| 4640 | 4865 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
| 4866 | + } |
|
| 4641 | 4867 | |
| 4642 | 4868 | $active = time() - $upcontext['started']; |
| 4643 | 4869 | $hours = floor($active / 3600); |
@@ -4647,16 +4873,20 @@ discard block |
||
| 4647 | 4873 | if ($is_debug) |
| 4648 | 4874 | { |
| 4649 | 4875 | $totalTime = ''; |
| 4650 | - if ($hours > 0) |
|
| 4651 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4652 | - if ($minutes > 0) |
|
| 4653 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4654 | - if ($seconds > 0) |
|
| 4655 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4876 | + if ($hours > 0) { |
|
| 4877 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
| 4878 | + } |
|
| 4879 | + if ($minutes > 0) { |
|
| 4880 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
| 4881 | + } |
|
| 4882 | + if ($seconds > 0) { |
|
| 4883 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
| 4884 | + } |
|
| 4656 | 4885 | } |
| 4657 | 4886 | |
| 4658 | - if ($is_debug && !empty($totalTime)) |
|
| 4659 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4887 | + if ($is_debug && !empty($totalTime)) { |
|
| 4888 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
| 4889 | + } |
|
| 4660 | 4890 | |
| 4661 | 4891 | echo '<br> |
| 4662 | 4892 | If you had any problems with this upgrade, or have any problems using SMF, please don\'t hesitate to <a href="http://www.simplemachines.org/community/index.php">look to us for assistance</a>.<br> |
@@ -4723,16 +4953,19 @@ discard block |
||
| 4723 | 4953 | 'empty' => '', |
| 4724 | 4954 | 'limit' => $limit, |
| 4725 | 4955 | )); |
| 4726 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 4727 | - $arIp[] = $row[$oldCol]; |
|
| 4956 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 4957 | + $arIp[] = $row[$oldCol]; |
|
| 4958 | + } |
|
| 4728 | 4959 | $smcFunc['db_free_result']($request); |
| 4729 | 4960 | |
| 4730 | 4961 | // Special case, null ip could keep us in a loop. |
| 4731 | - if (is_null($arIp[0])) |
|
| 4732 | - unset($arIp[0]); |
|
| 4962 | + if (is_null($arIp[0])) { |
|
| 4963 | + unset($arIp[0]); |
|
| 4964 | + } |
|
| 4733 | 4965 | |
| 4734 | - if (empty($arIp)) |
|
| 4735 | - $is_done = true; |
|
| 4966 | + if (empty($arIp)) { |
|
| 4967 | + $is_done = true; |
|
| 4968 | + } |
|
| 4736 | 4969 | |
| 4737 | 4970 | $updates = array(); |
| 4738 | 4971 | $cases = array(); |
@@ -4741,16 +4974,18 @@ discard block |
||
| 4741 | 4974 | { |
| 4742 | 4975 | $arIp[$i] = trim($arIp[$i]); |
| 4743 | 4976 | |
| 4744 | - if (empty($arIp[$i])) |
|
| 4745 | - continue; |
|
| 4977 | + if (empty($arIp[$i])) { |
|
| 4978 | + continue; |
|
| 4979 | + } |
|
| 4746 | 4980 | |
| 4747 | 4981 | $updates['ip' . $i] = $arIp[$i]; |
| 4748 | 4982 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
| 4749 | 4983 | |
| 4750 | 4984 | if ($setSize > 0 && $i % $setSize === 0) |
| 4751 | 4985 | { |
| 4752 | - if (count($updates) == 1) |
|
| 4753 | - continue; |
|
| 4986 | + if (count($updates) == 1) { |
|
| 4987 | + continue; |
|
| 4988 | + } |
|
| 4754 | 4989 | |
| 4755 | 4990 | $updates['whereSet'] = array_values($updates); |
| 4756 | 4991 | $smcFunc['db_query']('', ' |
@@ -4784,8 +5019,7 @@ discard block |
||
| 4784 | 5019 | 'ip' => $ip |
| 4785 | 5020 | )); |
| 4786 | 5021 | } |
| 4787 | - } |
|
| 4788 | - else |
|
| 5022 | + } else |
|
| 4789 | 5023 | { |
| 4790 | 5024 | $updates['whereSet'] = array_values($updates); |
| 4791 | 5025 | $smcFunc['db_query']('', ' |
@@ -4799,9 +5033,9 @@ discard block |
||
| 4799 | 5033 | $updates |
| 4800 | 5034 | ); |
| 4801 | 5035 | } |
| 5036 | + } else { |
|
| 5037 | + $is_done = true; |
|
| 4802 | 5038 | } |
| 4803 | - else |
|
| 4804 | - $is_done = true; |
|
| 4805 | 5039 | |
| 4806 | 5040 | $_GET['a'] += $limit; |
| 4807 | 5041 | $step_progress['current'] = $_GET['a']; |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | { |
| 33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
| 34 | 35 | |
| 35 | - if (empty($topic)) |
|
| 36 | - fatal_lang_error('no_access', false); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + fatal_lang_error('no_access', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | $request = $smcFunc['db_query']('', ' |
| 39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
| 49 | 51 | $smcFunc['db_free_result']($request); |
| 50 | 52 | |
| 51 | 53 | // Can they see it - if not approved? |
| 52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
| 53 | - isAllowedTo('approve_posts'); |
|
| 54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
| 55 | + isAllowedTo('approve_posts'); |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Permission check! |
| 56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
| 59 | 62 | if ($id_member_started == $user_info['id']) |
| 60 | 63 | { |
| 61 | 64 | isAllowedTo('move_own'); |
| 65 | + } else { |
|
| 66 | + isAllowedTo('move_any'); |
|
| 62 | 67 | } |
| 63 | - else |
|
| 64 | - isAllowedTo('move_any'); |
|
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
| 83 | 86 | 'not_redirection' => true, |
| 84 | 87 | ); |
| 85 | 88 | |
| 86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
| 87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
| 90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | - if (!$context['move_any']) |
|
| 90 | - $options['included_boards'] = $boards; |
|
| 93 | + if (!$context['move_any']) { |
|
| 94 | + $options['included_boards'] = $boards; |
|
| 95 | + } |
|
| 91 | 96 | |
| 92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
| 93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
| 138 | 143 | global $txt, $board, $topic, $scripturl, $sourcedir, $modSettings, $context; |
| 139 | 144 | global $board, $language, $user_info, $smcFunc; |
| 140 | 145 | |
| 141 | - if (empty($topic)) |
|
| 142 | - fatal_lang_error('no_access', false); |
|
| 146 | + if (empty($topic)) { |
|
| 147 | + fatal_lang_error('no_access', false); |
|
| 148 | + } |
|
| 143 | 149 | |
| 144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
| 145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
| 146 | - fatal_lang_error('movetopic_no_reason', false); |
|
| 151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
| 152 | + fatal_lang_error('movetopic_no_reason', false); |
|
| 153 | + } |
|
| 147 | 154 | |
| 148 | 155 | moveTopicConcurrence(); |
| 149 | 156 | |
@@ -163,16 +170,18 @@ discard block |
||
| 163 | 170 | $smcFunc['db_free_result']($request); |
| 164 | 171 | |
| 165 | 172 | // Can they see it? |
| 166 | - if (!$context['is_approved']) |
|
| 167 | - isAllowedTo('approve_posts'); |
|
| 173 | + if (!$context['is_approved']) { |
|
| 174 | + isAllowedTo('approve_posts'); |
|
| 175 | + } |
|
| 168 | 176 | |
| 169 | 177 | // Can they move topics on this board? |
| 170 | 178 | if (!allowedTo('move_any')) |
| 171 | 179 | { |
| 172 | - if ($id_member_started == $user_info['id']) |
|
| 173 | - isAllowedTo('move_own'); |
|
| 174 | - else |
|
| 175 | - isAllowedTo('move_any'); |
|
| 180 | + if ($id_member_started == $user_info['id']) { |
|
| 181 | + isAllowedTo('move_own'); |
|
| 182 | + } else { |
|
| 183 | + isAllowedTo('move_any'); |
|
| 184 | + } |
|
| 176 | 185 | } |
| 177 | 186 | |
| 178 | 187 | checkSession(); |
@@ -197,8 +206,9 @@ discard block |
||
| 197 | 206 | 'blank_redirect' => '', |
| 198 | 207 | ) |
| 199 | 208 | ); |
| 200 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 201 | - fatal_lang_error('no_board'); |
|
| 209 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 210 | + fatal_lang_error('no_board'); |
|
| 211 | + } |
|
| 202 | 212 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
| 203 | 213 | $smcFunc['db_free_result']($request); |
| 204 | 214 | |
@@ -210,8 +220,9 @@ discard block |
||
| 210 | 220 | { |
| 211 | 221 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
| 212 | 222 | // Keep checking the length. |
| 213 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
| 214 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 223 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
| 224 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 225 | + } |
|
| 215 | 226 | |
| 216 | 227 | // If it's still valid move onwards and upwards. |
| 217 | 228 | if ($_POST['custom_subject'] != '') |
@@ -221,9 +232,9 @@ discard block |
||
| 221 | 232 | // Get a response prefix, but in the forum's default language. |
| 222 | 233 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 223 | 234 | { |
| 224 | - if ($language === $user_info['language']) |
|
| 225 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 226 | - else |
|
| 235 | + if ($language === $user_info['language']) { |
|
| 236 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 237 | + } else |
|
| 227 | 238 | { |
| 228 | 239 | loadLanguage('index', $language, false); |
| 229 | 240 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -263,8 +274,9 @@ discard block |
||
| 263 | 274 | if (isset($_POST['postRedirect'])) |
| 264 | 275 | { |
| 265 | 276 | // Should be in the boardwide language. |
| 266 | - if ($user_info['language'] != $language) |
|
| 267 | - loadLanguage('index', $language); |
|
| 277 | + if ($user_info['language'] != $language) { |
|
| 278 | + loadLanguage('index', $language); |
|
| 279 | + } |
|
| 268 | 280 | |
| 269 | 281 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
| 270 | 282 | preparsecode($_POST['reason']); |
@@ -328,8 +340,9 @@ discard block |
||
| 328 | 340 | $posters = array(); |
| 329 | 341 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 330 | 342 | { |
| 331 | - if (!isset($posters[$row['id_member']])) |
|
| 332 | - $posters[$row['id_member']] = 0; |
|
| 343 | + if (!isset($posters[$row['id_member']])) { |
|
| 344 | + $posters[$row['id_member']] = 0; |
|
| 345 | + } |
|
| 333 | 346 | |
| 334 | 347 | $posters[$row['id_member']]++; |
| 335 | 348 | } |
@@ -338,11 +351,13 @@ discard block |
||
| 338 | 351 | foreach ($posters as $id_member => $posts) |
| 339 | 352 | { |
| 340 | 353 | // The board we're moving from counted posts, but not to. |
| 341 | - if (empty($pcounter_from)) |
|
| 342 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 354 | + if (empty($pcounter_from)) { |
|
| 355 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 356 | + } |
|
| 343 | 357 | // The reverse: from didn't, to did. |
| 344 | - else |
|
| 345 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 358 | + else { |
|
| 359 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 360 | + } |
|
| 346 | 361 | } |
| 347 | 362 | } |
| 348 | 363 | |
@@ -350,17 +365,19 @@ discard block |
||
| 350 | 365 | moveTopics($topic, $_POST['toboard']); |
| 351 | 366 | |
| 352 | 367 | // Log that they moved this topic. |
| 353 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
| 354 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 368 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
| 369 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 370 | + } |
|
| 355 | 371 | // Notify people that this topic has been moved? |
| 356 | 372 | sendNotifications($topic, 'move'); |
| 357 | 373 | |
| 358 | 374 | // Why not go back to the original board in case they want to keep moving? |
| 359 | - if (!isset($_REQUEST['goback'])) |
|
| 360 | - redirectexit('board=' . $board . '.0'); |
|
| 361 | - else |
|
| 362 | - redirectexit('topic=' . $topic . '.0'); |
|
| 363 | -} |
|
| 375 | + if (!isset($_REQUEST['goback'])) { |
|
| 376 | + redirectexit('board=' . $board . '.0'); |
|
| 377 | + } else { |
|
| 378 | + redirectexit('topic=' . $topic . '.0'); |
|
| 379 | + } |
|
| 380 | + } |
|
| 364 | 381 | |
| 365 | 382 | /** |
| 366 | 383 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -376,18 +393,21 @@ discard block |
||
| 376 | 393 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
| 377 | 394 | |
| 378 | 395 | // Empty array? |
| 379 | - if (empty($topics)) |
|
| 380 | - return; |
|
| 396 | + if (empty($topics)) { |
|
| 397 | + return; |
|
| 398 | + } |
|
| 381 | 399 | |
| 382 | 400 | // Only a single topic. |
| 383 | - if (is_numeric($topics)) |
|
| 384 | - $topics = array($topics); |
|
| 401 | + if (is_numeric($topics)) { |
|
| 402 | + $topics = array($topics); |
|
| 403 | + } |
|
| 385 | 404 | |
| 386 | 405 | $fromBoards = array(); |
| 387 | 406 | |
| 388 | 407 | // Destination board empty or equal to 0? |
| 389 | - if (empty($toBoard)) |
|
| 390 | - return; |
|
| 408 | + if (empty($toBoard)) { |
|
| 409 | + return; |
|
| 410 | + } |
|
| 391 | 411 | |
| 392 | 412 | // Are we moving to the recycle board? |
| 393 | 413 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -395,8 +415,9 @@ discard block |
||
| 395 | 415 | // Callback for search APIs to do their thing |
| 396 | 416 | require_once($sourcedir . '/Search.php'); |
| 397 | 417 | $searchAPI = findSearchAPI(); |
| 398 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
| 399 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
| 418 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
| 419 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
| 420 | + } |
|
| 400 | 421 | |
| 401 | 422 | // Determine the source boards... |
| 402 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -410,8 +431,9 @@ discard block |
||
| 410 | 431 | ) |
| 411 | 432 | ); |
| 412 | 433 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
| 413 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 414 | - return; |
|
| 434 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 435 | + return; |
|
| 436 | + } |
|
| 415 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 416 | 438 | { |
| 417 | 439 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -429,10 +451,11 @@ discard block |
||
| 429 | 451 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
| 430 | 452 | |
| 431 | 453 | // Add the topics to the right type. |
| 432 | - if ($row['approved']) |
|
| 433 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 434 | - else |
|
| 435 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 454 | + if ($row['approved']) { |
|
| 455 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 456 | + } else { |
|
| 457 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 458 | + } |
|
| 436 | 459 | } |
| 437 | 460 | $smcFunc['db_free_result']($request); |
| 438 | 461 | |
@@ -558,13 +581,14 @@ discard block |
||
| 558 | 581 | ) |
| 559 | 582 | ); |
| 560 | 583 | $approval_msgs = array(); |
| 561 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 562 | - $approval_msgs[] = $row['id_msg']; |
|
| 584 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 585 | + $approval_msgs[] = $row['id_msg']; |
|
| 586 | + } |
|
| 563 | 587 | $smcFunc['db_free_result']($request); |
| 564 | 588 | |
| 565 | 589 | // Empty the approval queue for these, as we're going to approve them next. |
| 566 | - if (!empty($approval_msgs)) |
|
| 567 | - $smcFunc['db_query']('', ' |
|
| 590 | + if (!empty($approval_msgs)) { |
|
| 591 | + $smcFunc['db_query']('', ' |
|
| 568 | 592 | DELETE FROM {db_prefix}approval_queue |
| 569 | 593 | WHERE id_msg IN ({array_int:message_list}) |
| 570 | 594 | AND id_attach = {int:id_attach}', |
@@ -573,6 +597,7 @@ discard block |
||
| 573 | 597 | 'id_attach' => 0, |
| 574 | 598 | ) |
| 575 | 599 | ); |
| 600 | + } |
|
| 576 | 601 | |
| 577 | 602 | // Get all the current max and mins. |
| 578 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -606,8 +631,8 @@ discard block |
||
| 606 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 607 | 632 | { |
| 608 | 633 | // If not, update. |
| 609 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
| 610 | - $smcFunc['db_query']('', ' |
|
| 634 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
| 635 | + $smcFunc['db_query']('', ' |
|
| 611 | 636 | UPDATE {db_prefix}topics |
| 612 | 637 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
| 613 | 638 | WHERE id_topic = {int:selected_topic}', |
@@ -617,6 +642,7 @@ discard block |
||
| 617 | 642 | 'selected_topic' => $row['id_topic'], |
| 618 | 643 | ) |
| 619 | 644 | ); |
| 645 | + } |
|
| 620 | 646 | } |
| 621 | 647 | $smcFunc['db_free_result']($request); |
| 622 | 648 | } |
@@ -675,9 +701,10 @@ discard block |
||
| 675 | 701 | } |
| 676 | 702 | |
| 677 | 703 | // Update the cache? |
| 678 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
| 679 | - foreach ($topics as $topic_id) |
|
| 704 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
| 705 | + foreach ($topics as $topic_id) |
|
| 680 | 706 | cache_put_data('topic_board-' . $topic_id, null, 120); |
| 707 | + } |
|
| 681 | 708 | |
| 682 | 709 | require_once($sourcedir . '/Subs-Post.php'); |
| 683 | 710 | |
@@ -701,15 +728,17 @@ discard block |
||
| 701 | 728 | { |
| 702 | 729 | global $board, $topic, $smcFunc, $scripturl; |
| 703 | 730 | |
| 704 | - if (isset($_GET['current_board'])) |
|
| 705 | - $move_from = (int) $_GET['current_board']; |
|
| 731 | + if (isset($_GET['current_board'])) { |
|
| 732 | + $move_from = (int) $_GET['current_board']; |
|
| 733 | + } |
|
| 706 | 734 | |
| 707 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
| 708 | - return true; |
|
| 735 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
| 736 | + return true; |
|
| 737 | + } |
|
| 709 | 738 | |
| 710 | - if ($move_from == $board) |
|
| 711 | - return true; |
|
| 712 | - else |
|
| 739 | + if ($move_from == $board) { |
|
| 740 | + return true; |
|
| 741 | + } else |
|
| 713 | 742 | { |
| 714 | 743 | $request = $smcFunc['db_query']('', ' |
| 715 | 744 | SELECT m.subject, b.name |
@@ -17,8 +17,9 @@ discard block |
||
| 17 | 17 | * @version 2.1 Beta 3 |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -if (!defined('SMF')) |
|
| 20 | +if (!defined('SMF')) { |
|
| 21 | 21 | die('No direct access...'); |
| 22 | +} |
|
| 22 | 23 | |
| 23 | 24 | /** |
| 24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
| 38 | 39 | { |
| 39 | 40 | $parsed_url = parse_url($boardurl); |
| 40 | 41 | |
| 41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
| 42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
| 43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 44 | + } |
|
| 43 | 45 | } |
| 44 | 46 | // @todo Set the session cookie path? |
| 45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
| 47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
| 48 | 50 | { |
| 49 | 51 | // Attempt to end the already-started session. |
| 50 | - if (ini_get('session.auto_start') == 1) |
|
| 51 | - session_write_close(); |
|
| 52 | + if (ini_get('session.auto_start') == 1) { |
|
| 53 | + session_write_close(); |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
| 54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -65,19 +68,21 @@ discard block |
||
| 65 | 68 | @ini_set('session.serialize_handler', 'php'); |
| 66 | 69 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
| 67 | 70 | @ini_set('session.gc_probability', '1'); |
| 71 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
| 72 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
| 68 | 73 | } |
| 69 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
| 70 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
| 71 | 74 | |
| 72 | 75 | // Use cache setting sessions? |
| 73 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
| 74 | - call_integration_hook('integrate_session_handlers'); |
|
| 76 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
| 77 | + call_integration_hook('integrate_session_handlers'); |
|
| 78 | + } |
|
| 75 | 79 | |
| 76 | 80 | session_start(); |
| 77 | 81 | |
| 78 | 82 | // Change it so the cache settings are a little looser than default. |
| 79 | - if (!empty($modSettings['databaseSession_loose'])) |
|
| 80 | - header('Cache-Control: private'); |
|
| 83 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
| 84 | + header('Cache-Control: private'); |
|
| 85 | + } |
|
| 81 | 86 | } |
| 82 | 87 | |
| 83 | 88 | // Set the randomly generated code. |
@@ -123,8 +128,9 @@ discard block |
||
| 123 | 128 | { |
| 124 | 129 | global $smcFunc; |
| 125 | 130 | |
| 126 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 127 | - return ''; |
|
| 131 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 132 | + return ''; |
|
| 133 | + } |
|
| 128 | 134 | |
| 129 | 135 | // Look for it in the database. |
| 130 | 136 | $result = $smcFunc['db_query']('', ' |
@@ -153,8 +159,9 @@ discard block |
||
| 153 | 159 | { |
| 154 | 160 | global $smcFunc; |
| 155 | 161 | |
| 156 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 157 | - return false; |
|
| 162 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 163 | + return false; |
|
| 164 | + } |
|
| 158 | 165 | |
| 159 | 166 | // First try to update an existing row... |
| 160 | 167 | $smcFunc['db_query']('', ' |
@@ -169,13 +176,14 @@ discard block |
||
| 169 | 176 | ); |
| 170 | 177 | |
| 171 | 178 | // If that didn't work, try inserting a new one. |
| 172 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 173 | - $smcFunc['db_insert']('ignore', |
|
| 179 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 180 | + $smcFunc['db_insert']('ignore', |
|
| 174 | 181 | '{db_prefix}sessions', |
| 175 | 182 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
| 176 | 183 | array($session_id, $data, time()), |
| 177 | 184 | array('session_id') |
| 178 | 185 | ); |
| 186 | + } |
|
| 179 | 187 | |
| 180 | 188 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
| 181 | 189 | } |
@@ -190,8 +198,9 @@ discard block |
||
| 190 | 198 | { |
| 191 | 199 | global $smcFunc; |
| 192 | 200 | |
| 193 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 194 | - return false; |
|
| 201 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 202 | + return false; |
|
| 203 | + } |
|
| 195 | 204 | |
| 196 | 205 | // Just delete the row... |
| 197 | 206 | $smcFunc['db_query']('', ' |
@@ -217,8 +226,9 @@ discard block |
||
| 217 | 226 | global $modSettings, $smcFunc; |
| 218 | 227 | |
| 219 | 228 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
| 220 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
| 221 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
| 229 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
| 230 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
| 231 | + } |
|
| 222 | 232 | |
| 223 | 233 | // Clean up after yerself ;). |
| 224 | 234 | $smcFunc['db_query']('', ' |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | * Shows an avatar based on $_GET['attach'] |
@@ -35,11 +36,11 @@ discard block |
||
| 35 | 36 | |
| 36 | 37 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0) |
| 37 | 38 | { |
| 38 | - if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') |
|
| 39 | - $modSettings['enableCompressedOutput'] = 0; |
|
| 40 | - |
|
| 41 | - else |
|
| 42 | - ob_start('ob_gzhandler'); |
|
| 39 | + if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') { |
|
| 40 | + $modSettings['enableCompressedOutput'] = 0; |
|
| 41 | + } else { |
|
| 42 | + ob_start('ob_gzhandler'); |
|
| 43 | + } |
|
| 43 | 44 | } |
| 44 | 45 | |
| 45 | 46 | if (empty($modSettings['enableCompressedOutput'])) |
@@ -71,8 +72,9 @@ discard block |
||
| 71 | 72 | } |
| 72 | 73 | |
| 73 | 74 | // Use cache when possible. |
| 74 | - if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) |
|
| 75 | - list($file, $thumbFile) = $cache; |
|
| 75 | + if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) { |
|
| 76 | + list($file, $thumbFile) = $cache; |
|
| 77 | + } |
|
| 76 | 78 | |
| 77 | 79 | // Get the info from the DB. |
| 78 | 80 | if (empty($file) || empty($thumbFile) && !empty($file['id_thumb'])) |
@@ -80,10 +82,9 @@ discard block |
||
| 80 | 82 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
| 81 | 83 | $attachRequest = null; |
| 82 | 84 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
| 83 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
| 84 | - $request = $attachRequest; |
|
| 85 | - |
|
| 86 | - else |
|
| 85 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
| 86 | + $request = $attachRequest; |
|
| 87 | + } else |
|
| 87 | 88 | { |
| 88 | 89 | // Make sure this attachment is on this board and load its info while we are at it. |
| 89 | 90 | $request = $smcFunc['db_query']('', ' |
@@ -176,13 +177,14 @@ discard block |
||
| 176 | 177 | } |
| 177 | 178 | |
| 178 | 179 | // Cache it. |
| 179 | - if (!empty($file) || !empty($thumbFile)) |
|
| 180 | - cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
| 180 | + if (!empty($file) || !empty($thumbFile)) { |
|
| 181 | + cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
| 182 | + } |
|
| 181 | 183 | } |
| 182 | 184 | |
| 183 | 185 | // Update the download counter (unless it's a thumbnail). |
| 184 | - if ($file['attachment_type'] != 3 && empty($showThumb)) |
|
| 185 | - $smcFunc['db_query']('attach_download_increase', ' |
|
| 186 | + if ($file['attachment_type'] != 3 && empty($showThumb)) { |
|
| 187 | + $smcFunc['db_query']('attach_download_increase', ' |
|
| 186 | 188 | UPDATE LOW_PRIORITY {db_prefix}attachments |
| 187 | 189 | SET downloads = downloads + 1 |
| 188 | 190 | WHERE id_attach = {int:id_attach}', |
@@ -190,10 +192,12 @@ discard block |
||
| 190 | 192 | 'id_attach' => $attachId, |
| 191 | 193 | ) |
| 192 | 194 | ); |
| 195 | + } |
|
| 193 | 196 | |
| 194 | 197 | // Replace the normal file with its thumbnail if it has one! |
| 195 | - if (!empty($showThumb) && !empty($thumbFile)) |
|
| 196 | - $file = $thumbFile; |
|
| 198 | + if (!empty($showThumb) && !empty($thumbFile)) { |
|
| 199 | + $file = $thumbFile; |
|
| 200 | + } |
|
| 197 | 201 | |
| 198 | 202 | // No point in a nicer message, because this is supposed to be an attachment anyway... |
| 199 | 203 | if (!file_exists($file['filePath'])) |
@@ -232,8 +236,9 @@ discard block |
||
| 232 | 236 | // Send the attachment headers. |
| 233 | 237 | header('Pragma: '); |
| 234 | 238 | |
| 235 | - if (!isBrowser('gecko')) |
|
| 236 | - header('Content-Transfer-Encoding: binary'); |
|
| 239 | + if (!isBrowser('gecko')) { |
|
| 240 | + header('Content-Transfer-Encoding: binary'); |
|
| 241 | + } |
|
| 237 | 242 | |
| 238 | 243 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 239 | 244 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT'); |
@@ -242,18 +247,19 @@ discard block |
||
| 242 | 247 | header('ETag: ' . $eTag); |
| 243 | 248 | |
| 244 | 249 | // Make sure the mime type warrants an inline display. |
| 245 | - if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) |
|
| 246 | - unset($_REQUEST['image']); |
|
| 250 | + if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) { |
|
| 251 | + unset($_REQUEST['image']); |
|
| 252 | + } |
|
| 247 | 253 | |
| 248 | 254 | // Does this have a mime type? |
| 249 | - elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
| 250 | - header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 251 | - |
|
| 252 | - else |
|
| 255 | + elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
| 256 | + header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 257 | + } else |
|
| 253 | 258 | { |
| 254 | 259 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
| 255 | - if (isset($_REQUEST['image'])) |
|
| 256 | - unset($_REQUEST['image']); |
|
| 260 | + if (isset($_REQUEST['image'])) { |
|
| 261 | + unset($_REQUEST['image']); |
|
| 262 | + } |
|
| 257 | 263 | } |
| 258 | 264 | |
| 259 | 265 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -261,24 +267,22 @@ discard block |
||
| 261 | 267 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
| 262 | 268 | |
| 263 | 269 | // Different browsers like different standards... |
| 264 | - if (isBrowser('firefox')) |
|
| 265 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 266 | - |
|
| 267 | - elseif (isBrowser('opera')) |
|
| 268 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 269 | - |
|
| 270 | - elseif (isBrowser('ie')) |
|
| 271 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 272 | - |
|
| 273 | - else |
|
| 274 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 270 | + if (isBrowser('firefox')) { |
|
| 271 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 272 | + } elseif (isBrowser('opera')) { |
|
| 273 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 274 | + } elseif (isBrowser('ie')) { |
|
| 275 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 276 | + } else { |
|
| 277 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 278 | + } |
|
| 275 | 279 | |
| 276 | 280 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
| 277 | - if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
| 278 | - header('Cache-Control: no-cache'); |
|
| 279 | - |
|
| 280 | - else |
|
| 281 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 281 | + if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
| 282 | + header('Cache-Control: no-cache'); |
|
| 283 | + } else { |
|
| 284 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 285 | + } |
|
| 282 | 286 | |
| 283 | 287 | header('Content-Length: ' . filesize($file['filePath'])); |
| 284 | 288 | |
@@ -289,8 +293,9 @@ discard block |
||
| 289 | 293 | if (filesize($file['filePath']) > 4194304) |
| 290 | 294 | { |
| 291 | 295 | // Forcibly end any output buffering going on. |
| 292 | - while (@ob_get_level() > 0) |
|
| 293 | - @ob_end_clean(); |
|
| 296 | + while (@ob_get_level() > 0) { |
|
| 297 | + @ob_end_clean(); |
|
| 298 | + } |
|
| 294 | 299 | |
| 295 | 300 | $fp = fopen($file['filePath'], 'rb'); |
| 296 | 301 | while (!feof($fp)) |
@@ -302,8 +307,9 @@ discard block |
||
| 302 | 307 | } |
| 303 | 308 | |
| 304 | 309 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
| 305 | - elseif (@readfile($file['filePath']) === null) |
|
| 306 | - echo file_get_contents($file['filePath']); |
|
| 310 | + elseif (@readfile($file['filePath']) === null) { |
|
| 311 | + echo file_get_contents($file['filePath']); |
|
| 312 | + } |
|
| 307 | 313 | |
| 308 | 314 | die(); |
| 309 | 315 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Mark a board or multiple boards read. |
@@ -28,14 +29,16 @@ discard block |
||
| 28 | 29 | global $user_info, $modSettings, $smcFunc; |
| 29 | 30 | |
| 30 | 31 | // Force $boards to be an array. |
| 31 | - if (!is_array($boards)) |
|
| 32 | - $boards = array($boards); |
|
| 33 | - else |
|
| 34 | - $boards = array_unique($boards); |
|
| 32 | + if (!is_array($boards)) { |
|
| 33 | + $boards = array($boards); |
|
| 34 | + } else { |
|
| 35 | + $boards = array_unique($boards); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // No boards, nothing to mark as read. |
| 37 | - if (empty($boards)) |
|
| 38 | - return; |
|
| 39 | + if (empty($boards)) { |
|
| 40 | + return; |
|
| 41 | + } |
|
| 39 | 42 | |
| 40 | 43 | // Allow the user to mark a board as unread. |
| 41 | 44 | if ($unread) |
@@ -65,8 +68,9 @@ discard block |
||
| 65 | 68 | else |
| 66 | 69 | { |
| 67 | 70 | $markRead = array(); |
| 68 | - foreach ($boards as $board) |
|
| 69 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
| 71 | + foreach ($boards as $board) { |
|
| 72 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
| 73 | + } |
|
| 70 | 74 | |
| 71 | 75 | // Update log_mark_read and log_boards. |
| 72 | 76 | $smcFunc['db_insert']('replace', |
@@ -99,8 +103,9 @@ discard block |
||
| 99 | 103 | list ($lowest_topic) = $smcFunc['db_fetch_row']($result); |
| 100 | 104 | $smcFunc['db_free_result']($result); |
| 101 | 105 | |
| 102 | - if (empty($lowest_topic)) |
|
| 103 | - return; |
|
| 106 | + if (empty($lowest_topic)) { |
|
| 107 | + return; |
|
| 108 | + } |
|
| 104 | 109 | |
| 105 | 110 | // @todo SLOW This query seems to eat it sometimes. |
| 106 | 111 | $result = $smcFunc['db_query']('', ' |
@@ -118,12 +123,13 @@ discard block |
||
| 118 | 123 | ) |
| 119 | 124 | ); |
| 120 | 125 | $topics = array(); |
| 121 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 122 | - $topics[] = $row['id_topic']; |
|
| 126 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 127 | + $topics[] = $row['id_topic']; |
|
| 128 | + } |
|
| 123 | 129 | $smcFunc['db_free_result']($result); |
| 124 | 130 | |
| 125 | - if (!empty($topics)) |
|
| 126 | - $smcFunc['db_query']('', ' |
|
| 131 | + if (!empty($topics)) { |
|
| 132 | + $smcFunc['db_query']('', ' |
|
| 127 | 133 | DELETE FROM {db_prefix}log_topics |
| 128 | 134 | WHERE id_member = {int:current_member} |
| 129 | 135 | AND id_topic IN ({array_int:topic_list})', |
@@ -132,7 +138,8 @@ discard block |
||
| 132 | 138 | 'topic_list' => $topics, |
| 133 | 139 | ) |
| 134 | 140 | ); |
| 135 | -} |
|
| 141 | + } |
|
| 142 | + } |
|
| 136 | 143 | |
| 137 | 144 | /** |
| 138 | 145 | * Mark one or more boards as read. |
@@ -157,23 +164,26 @@ discard block |
||
| 157 | 164 | ) |
| 158 | 165 | ); |
| 159 | 166 | $boards = array(); |
| 160 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 161 | - $boards[] = $row['id_board']; |
|
| 167 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 168 | + $boards[] = $row['id_board']; |
|
| 169 | + } |
|
| 162 | 170 | $smcFunc['db_free_result']($result); |
| 163 | 171 | |
| 164 | - if (!empty($boards)) |
|
| 165 | - markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
| 172 | + if (!empty($boards)) { |
|
| 173 | + markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
| 174 | + } |
|
| 166 | 175 | |
| 167 | 176 | $_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID']; |
| 168 | - if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) |
|
| 169 | - redirectexit('action=unread'); |
|
| 177 | + if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) { |
|
| 178 | + redirectexit('action=unread'); |
|
| 179 | + } |
|
| 170 | 180 | |
| 171 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 172 | - $_SESSION['topicseen_cache'] = array(); |
|
| 181 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 182 | + $_SESSION['topicseen_cache'] = array(); |
|
| 183 | + } |
|
| 173 | 184 | |
| 174 | 185 | redirectexit(); |
| 175 | - } |
|
| 176 | - elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
| 186 | + } elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
| 177 | 187 | { |
| 178 | 188 | // Make sure all the topics are integers! |
| 179 | 189 | $topics = array_map('intval', explode('-', $_REQUEST['topics'])); |
@@ -189,13 +199,15 @@ discard block |
||
| 189 | 199 | ) |
| 190 | 200 | ); |
| 191 | 201 | $logged_topics = array(); |
| 192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 193 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 203 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 204 | + } |
|
| 194 | 205 | $smcFunc['db_free_result']($request); |
| 195 | 206 | |
| 196 | 207 | $markRead = array(); |
| 197 | - foreach ($topics as $id_topic) |
|
| 198 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 208 | + foreach ($topics as $id_topic) { |
|
| 209 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 210 | + } |
|
| 199 | 211 | |
| 200 | 212 | $smcFunc['db_insert']('replace', |
| 201 | 213 | '{db_prefix}log_topics', |
@@ -204,8 +216,9 @@ discard block |
||
| 204 | 216 | array('id_member', 'id_topic') |
| 205 | 217 | ); |
| 206 | 218 | |
| 207 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 208 | - $_SESSION['topicseen_cache'] = array(); |
|
| 219 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 220 | + $_SESSION['topicseen_cache'] = array(); |
|
| 221 | + } |
|
| 209 | 222 | |
| 210 | 223 | redirectexit('action=unreadreplies'); |
| 211 | 224 | } |
@@ -230,11 +243,13 @@ discard block |
||
| 230 | 243 | if (!empty($_GET['t'])) |
| 231 | 244 | { |
| 232 | 245 | // If they read the whole topic, go back to the beginning. |
| 233 | - if ($_GET['t'] >= $topicinfo['id_last_msg']) |
|
| 234 | - $earlyMsg = 0; |
|
| 246 | + if ($_GET['t'] >= $topicinfo['id_last_msg']) { |
|
| 247 | + $earlyMsg = 0; |
|
| 248 | + } |
|
| 235 | 249 | // If they want to mark the whole thing read, same. |
| 236 | - elseif ($_GET['t'] <= $topicinfo['id_first_msg']) |
|
| 237 | - $earlyMsg = 0; |
|
| 250 | + elseif ($_GET['t'] <= $topicinfo['id_first_msg']) { |
|
| 251 | + $earlyMsg = 0; |
|
| 252 | + } |
|
| 238 | 253 | // Otherwise, get the latest message before the named one. |
| 239 | 254 | else |
| 240 | 255 | { |
@@ -255,9 +270,9 @@ discard block |
||
| 255 | 270 | } |
| 256 | 271 | } |
| 257 | 272 | // Marking read from first page? That's the whole topic. |
| 258 | - elseif ($_REQUEST['start'] == 0) |
|
| 259 | - $earlyMsg = 0; |
|
| 260 | - else |
|
| 273 | + elseif ($_REQUEST['start'] == 0) { |
|
| 274 | + $earlyMsg = 0; |
|
| 275 | + } else |
|
| 261 | 276 | { |
| 262 | 277 | $result = $smcFunc['db_query']('', ' |
| 263 | 278 | SELECT id_msg |
@@ -285,8 +300,7 @@ discard block |
||
| 285 | 300 | ); |
| 286 | 301 | |
| 287 | 302 | redirectexit('board=' . $board . '.0'); |
| 288 | - } |
|
| 289 | - else |
|
| 303 | + } else |
|
| 290 | 304 | { |
| 291 | 305 | $categories = array(); |
| 292 | 306 | $boards = array(); |
@@ -294,17 +308,20 @@ discard block |
||
| 294 | 308 | if (isset($_REQUEST['c'])) |
| 295 | 309 | { |
| 296 | 310 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
| 297 | - foreach ($_REQUEST['c'] as $c) |
|
| 298 | - $categories[] = (int) $c; |
|
| 311 | + foreach ($_REQUEST['c'] as $c) { |
|
| 312 | + $categories[] = (int) $c; |
|
| 313 | + } |
|
| 299 | 314 | } |
| 300 | 315 | if (isset($_REQUEST['boards'])) |
| 301 | 316 | { |
| 302 | 317 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
| 303 | - foreach ($_REQUEST['boards'] as $b) |
|
| 304 | - $boards[] = (int) $b; |
|
| 318 | + foreach ($_REQUEST['boards'] as $b) { |
|
| 319 | + $boards[] = (int) $b; |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + if (!empty($board)) { |
|
| 323 | + $boards[] = (int) $board; |
|
| 305 | 324 | } |
| 306 | - if (!empty($board)) |
|
| 307 | - $boards[] = (int) $board; |
|
| 308 | 325 | |
| 309 | 326 | if (isset($_REQUEST['children']) && !empty($boards)) |
| 310 | 327 | { |
@@ -324,9 +341,10 @@ discard block |
||
| 324 | 341 | 'board_list' => $boards, |
| 325 | 342 | ) |
| 326 | 343 | ); |
| 327 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 328 | - if (in_array($row['id_parent'], $boards)) |
|
| 344 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 345 | + if (in_array($row['id_parent'], $boards)) |
|
| 329 | 346 | $boards[] = $row['id_board']; |
| 347 | + } |
|
| 330 | 348 | $smcFunc['db_free_result']($request); |
| 331 | 349 | } |
| 332 | 350 | |
@@ -343,8 +361,9 @@ discard block |
||
| 343 | 361 | $clauseParameters['board_list'] = $boards; |
| 344 | 362 | } |
| 345 | 363 | |
| 346 | - if (empty($clauses)) |
|
| 347 | - redirectexit(); |
|
| 364 | + if (empty($clauses)) { |
|
| 365 | + redirectexit(); |
|
| 366 | + } |
|
| 348 | 367 | |
| 349 | 368 | $request = $smcFunc['db_query']('', ' |
| 350 | 369 | SELECT b.id_board |
@@ -355,19 +374,22 @@ discard block |
||
| 355 | 374 | )) |
| 356 | 375 | ); |
| 357 | 376 | $boards = array(); |
| 358 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 359 | - $boards[] = $row['id_board']; |
|
| 377 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 378 | + $boards[] = $row['id_board']; |
|
| 379 | + } |
|
| 360 | 380 | $smcFunc['db_free_result']($request); |
| 361 | 381 | |
| 362 | - if (empty($boards)) |
|
| 363 | - redirectexit(); |
|
| 382 | + if (empty($boards)) { |
|
| 383 | + redirectexit(); |
|
| 384 | + } |
|
| 364 | 385 | |
| 365 | 386 | markBoardsRead($boards, isset($_REQUEST['unread'])); |
| 366 | 387 | |
| 367 | 388 | foreach ($boards as $b) |
| 368 | 389 | { |
| 369 | - if (isset($_SESSION['topicseen_cache'][$b])) |
|
| 370 | - $_SESSION['topicseen_cache'][$b] = array(); |
|
| 390 | + if (isset($_SESSION['topicseen_cache'][$b])) { |
|
| 391 | + $_SESSION['topicseen_cache'][$b] = array(); |
|
| 392 | + } |
|
| 371 | 393 | } |
| 372 | 394 | |
| 373 | 395 | if (!isset($_REQUEST['unread'])) |
@@ -385,8 +407,9 @@ discard block |
||
| 385 | 407 | if ($smcFunc['db_num_rows']($result) > 0) |
| 386 | 408 | { |
| 387 | 409 | $logBoardInserts = ''; |
| 388 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 389 | - $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
| 410 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 411 | + $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
| 412 | + } |
|
| 390 | 413 | |
| 391 | 414 | $smcFunc['db_insert']('replace', |
| 392 | 415 | '{db_prefix}log_boards', |
@@ -397,17 +420,18 @@ discard block |
||
| 397 | 420 | } |
| 398 | 421 | $smcFunc['db_free_result']($result); |
| 399 | 422 | |
| 400 | - if (empty($board)) |
|
| 401 | - redirectexit(); |
|
| 402 | - else |
|
| 403 | - redirectexit('board=' . $board . '.0'); |
|
| 404 | - } |
|
| 405 | - else |
|
| 423 | + if (empty($board)) { |
|
| 424 | + redirectexit(); |
|
| 425 | + } else { |
|
| 426 | + redirectexit('board=' . $board . '.0'); |
|
| 427 | + } |
|
| 428 | + } else |
|
| 406 | 429 | { |
| 407 | - if (empty($board_info['parent'])) |
|
| 408 | - redirectexit(); |
|
| 409 | - else |
|
| 410 | - redirectexit('board=' . $board_info['parent'] . '.0'); |
|
| 430 | + if (empty($board_info['parent'])) { |
|
| 431 | + redirectexit(); |
|
| 432 | + } else { |
|
| 433 | + redirectexit('board=' . $board_info['parent'] . '.0'); |
|
| 434 | + } |
|
| 411 | 435 | } |
| 412 | 436 | } |
| 413 | 437 | } |
@@ -432,11 +456,13 @@ discard block |
||
| 432 | 456 | 'selected_message' => (int) $messageID, |
| 433 | 457 | ) |
| 434 | 458 | ); |
| 435 | - if ($smcFunc['db_num_rows']($result) > 0) |
|
| 436 | - list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
| 459 | + if ($smcFunc['db_num_rows']($result) > 0) { |
|
| 460 | + list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
| 461 | + } |
|
| 437 | 462 | // The message doesn't even exist. |
| 438 | - else |
|
| 439 | - $memberID = 0; |
|
| 463 | + else { |
|
| 464 | + $memberID = 0; |
|
| 465 | + } |
|
| 440 | 466 | $smcFunc['db_free_result']($result); |
| 441 | 467 | |
| 442 | 468 | return (int) $memberID; |
@@ -457,8 +483,9 @@ discard block |
||
| 457 | 483 | getBoardTree(); |
| 458 | 484 | |
| 459 | 485 | // Make sure given boards and categories exist. |
| 460 | - if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) |
|
| 461 | - fatal_lang_error('no_board'); |
|
| 486 | + if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) { |
|
| 487 | + fatal_lang_error('no_board'); |
|
| 488 | + } |
|
| 462 | 489 | |
| 463 | 490 | $id = $board_id; |
| 464 | 491 | call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions)); |
@@ -486,8 +513,9 @@ discard block |
||
| 486 | 513 | $child_level = 0; |
| 487 | 514 | $id_parent = 0; |
| 488 | 515 | $after = 0; |
| 489 | - foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) |
|
| 490 | - $after = max($after, $boards[$id_board]['order']); |
|
| 516 | + foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) { |
|
| 517 | + $after = max($after, $boards[$id_board]['order']); |
|
| 518 | + } |
|
| 491 | 519 | } |
| 492 | 520 | |
| 493 | 521 | // Make the board a child of a given board. |
@@ -498,17 +526,19 @@ discard block |
||
| 498 | 526 | $id_parent = $boardOptions['target_board']; |
| 499 | 527 | |
| 500 | 528 | // People can be creative, in many ways... |
| 501 | - if (isChildOf($id_parent, $board_id)) |
|
| 502 | - fatal_lang_error('mboards_parent_own_child_error', false); |
|
| 503 | - elseif ($id_parent == $board_id) |
|
| 504 | - fatal_lang_error('mboards_board_own_child_error', false); |
|
| 529 | + if (isChildOf($id_parent, $board_id)) { |
|
| 530 | + fatal_lang_error('mboards_parent_own_child_error', false); |
|
| 531 | + } elseif ($id_parent == $board_id) { |
|
| 532 | + fatal_lang_error('mboards_board_own_child_error', false); |
|
| 533 | + } |
|
| 505 | 534 | |
| 506 | 535 | $after = $boards[$boardOptions['target_board']]['order']; |
| 507 | 536 | |
| 508 | 537 | // Check if there are already children and (if so) get the max board order. |
| 509 | - if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) |
|
| 510 | - foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
| 538 | + if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) { |
|
| 539 | + foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
| 511 | 540 | $after = max($after, $boards[$childBoard_id]['order']); |
| 541 | + } |
|
| 512 | 542 | } |
| 513 | 543 | |
| 514 | 544 | // Place a board before or after another board, on the same child level. |
@@ -521,8 +551,9 @@ discard block |
||
| 521 | 551 | } |
| 522 | 552 | |
| 523 | 553 | // Oops...? |
| 524 | - else |
|
| 525 | - trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
| 554 | + else { |
|
| 555 | + trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
| 556 | + } |
|
| 526 | 557 | |
| 527 | 558 | // Get a list of children of this board. |
| 528 | 559 | $childList = array(); |
@@ -531,14 +562,16 @@ discard block |
||
| 531 | 562 | // See if there are changes that affect children. |
| 532 | 563 | $childUpdates = array(); |
| 533 | 564 | $levelDiff = $child_level - $boards[$board_id]['level']; |
| 534 | - if ($levelDiff != 0) |
|
| 535 | - $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
| 536 | - if ($id_cat != $boards[$board_id]['category']) |
|
| 537 | - $childUpdates[] = 'id_cat = {int:category}'; |
|
| 565 | + if ($levelDiff != 0) { |
|
| 566 | + $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
| 567 | + } |
|
| 568 | + if ($id_cat != $boards[$board_id]['category']) { |
|
| 569 | + $childUpdates[] = 'id_cat = {int:category}'; |
|
| 570 | + } |
|
| 538 | 571 | |
| 539 | 572 | // Fix the children of this board. |
| 540 | - if (!empty($childList) && !empty($childUpdates)) |
|
| 541 | - $smcFunc['db_query']('', ' |
|
| 573 | + if (!empty($childList) && !empty($childUpdates)) { |
|
| 574 | + $smcFunc['db_query']('', ' |
|
| 542 | 575 | UPDATE {db_prefix}boards |
| 543 | 576 | SET ' . implode(', |
| 544 | 577 | ', $childUpdates) . ' |
@@ -549,6 +582,7 @@ discard block |
||
| 549 | 582 | 'level_diff' => $levelDiff, |
| 550 | 583 | ) |
| 551 | 584 | ); |
| 585 | + } |
|
| 552 | 586 | |
| 553 | 587 | // Make some room for this spot. |
| 554 | 588 | $smcFunc['db_query']('', ' |
@@ -644,8 +678,8 @@ discard block |
||
| 644 | 678 | call_integration_hook('integrate_modify_board', array($id, &$boardUpdates, &$boardUpdateParameters)); |
| 645 | 679 | |
| 646 | 680 | // Do the updates (if any). |
| 647 | - if (!empty($boardUpdates)) |
|
| 648 | - $smcFunc['db_query']('', ' |
|
| 681 | + if (!empty($boardUpdates)) { |
|
| 682 | + $smcFunc['db_query']('', ' |
|
| 649 | 683 | UPDATE {db_prefix}boards |
| 650 | 684 | SET |
| 651 | 685 | ' . implode(', |
@@ -655,6 +689,7 @@ discard block |
||
| 655 | 689 | 'selected_board' => $board_id, |
| 656 | 690 | )) |
| 657 | 691 | ); |
| 692 | + } |
|
| 658 | 693 | |
| 659 | 694 | // Set moderators of this board. |
| 660 | 695 | if (isset($boardOptions['moderators']) || isset($boardOptions['moderator_string']) || isset($boardOptions['moderator_groups']) || isset($boardOptions['moderator_group_string'])) |
@@ -679,13 +714,15 @@ discard block |
||
| 679 | 714 | { |
| 680 | 715 | $moderators[$k] = trim($moderators[$k]); |
| 681 | 716 | |
| 682 | - if (strlen($moderators[$k]) == 0) |
|
| 683 | - unset($moderators[$k]); |
|
| 717 | + if (strlen($moderators[$k]) == 0) { |
|
| 718 | + unset($moderators[$k]); |
|
| 719 | + } |
|
| 684 | 720 | } |
| 685 | 721 | |
| 686 | 722 | // Find all the id_member's for the member_name's in the list. |
| 687 | - if (empty($boardOptions['moderators'])) |
|
| 688 | - $boardOptions['moderators'] = array(); |
|
| 723 | + if (empty($boardOptions['moderators'])) { |
|
| 724 | + $boardOptions['moderators'] = array(); |
|
| 725 | + } |
|
| 689 | 726 | if (!empty($moderators)) |
| 690 | 727 | { |
| 691 | 728 | $request = $smcFunc['db_query']('', ' |
@@ -698,8 +735,9 @@ discard block |
||
| 698 | 735 | 'limit' => count($moderators), |
| 699 | 736 | ) |
| 700 | 737 | ); |
| 701 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 702 | - $boardOptions['moderators'][] = $row['id_member']; |
|
| 738 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 739 | + $boardOptions['moderators'][] = $row['id_member']; |
|
| 740 | + } |
|
| 703 | 741 | $smcFunc['db_free_result']($request); |
| 704 | 742 | } |
| 705 | 743 | } |
@@ -708,8 +746,9 @@ discard block |
||
| 708 | 746 | if (!empty($boardOptions['moderators'])) |
| 709 | 747 | { |
| 710 | 748 | $inserts = array(); |
| 711 | - foreach ($boardOptions['moderators'] as $moderator) |
|
| 712 | - $inserts[] = array($board_id, $moderator); |
|
| 749 | + foreach ($boardOptions['moderators'] as $moderator) { |
|
| 750 | + $inserts[] = array($board_id, $moderator); |
|
| 751 | + } |
|
| 713 | 752 | |
| 714 | 753 | $smcFunc['db_insert']('insert', |
| 715 | 754 | '{db_prefix}moderators', |
@@ -739,14 +778,16 @@ discard block |
||
| 739 | 778 | { |
| 740 | 779 | $moderator_groups[$k] = trim($moderator_groups[$k]); |
| 741 | 780 | |
| 742 | - if (strlen($moderator_groups[$k]) == 0) |
|
| 743 | - unset($moderator_groups[$k]); |
|
| 781 | + if (strlen($moderator_groups[$k]) == 0) { |
|
| 782 | + unset($moderator_groups[$k]); |
|
| 783 | + } |
|
| 744 | 784 | } |
| 745 | 785 | |
| 746 | 786 | /* Find all the id_group's for all the group names in the list |
| 747 | 787 | But skip any invalid ones (invisible/post groups/Administrator/Moderator) */ |
| 748 | - if (empty($boardOptions['moderator_groups'])) |
|
| 749 | - $boardOptions['moderator_groups'] = array(); |
|
| 788 | + if (empty($boardOptions['moderator_groups'])) { |
|
| 789 | + $boardOptions['moderator_groups'] = array(); |
|
| 790 | + } |
|
| 750 | 791 | if (!empty($moderator_groups)) |
| 751 | 792 | { |
| 752 | 793 | $request = $smcFunc['db_query']('', ' |
@@ -777,8 +818,9 @@ discard block |
||
| 777 | 818 | if (!empty($boardOptions['moderator_groups'])) |
| 778 | 819 | { |
| 779 | 820 | $inserts = array(); |
| 780 | - foreach ($boardOptions['moderator_groups'] as $moderator_group) |
|
| 781 | - $inserts[] = array($board_id, $moderator_group); |
|
| 821 | + foreach ($boardOptions['moderator_groups'] as $moderator_group) { |
|
| 822 | + $inserts[] = array($board_id, $moderator_group); |
|
| 823 | + } |
|
| 782 | 824 | |
| 783 | 825 | $smcFunc['db_insert']('insert', |
| 784 | 826 | '{db_prefix}moderator_groups', |
@@ -792,14 +834,16 @@ discard block |
||
| 792 | 834 | updateSettings(array('settings_updated' => time())); |
| 793 | 835 | } |
| 794 | 836 | |
| 795 | - if (isset($boardOptions['move_to'])) |
|
| 796 | - reorderBoards(); |
|
| 837 | + if (isset($boardOptions['move_to'])) { |
|
| 838 | + reorderBoards(); |
|
| 839 | + } |
|
| 797 | 840 | |
| 798 | 841 | clean_cache('data'); |
| 799 | 842 | |
| 800 | - if (empty($boardOptions['dont_log'])) |
|
| 801 | - logAction('edit_board', array('board' => $board_id), 'admin'); |
|
| 802 | -} |
|
| 843 | + if (empty($boardOptions['dont_log'])) { |
|
| 844 | + logAction('edit_board', array('board' => $board_id), 'admin'); |
|
| 845 | + } |
|
| 846 | + } |
|
| 803 | 847 | |
| 804 | 848 | /** |
| 805 | 849 | * Create a new board and set its properties and position. |
@@ -815,11 +859,13 @@ discard block |
||
| 815 | 859 | global $boards, $smcFunc; |
| 816 | 860 | |
| 817 | 861 | // Trigger an error if one of the required values is not set. |
| 818 | - if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) |
|
| 819 | - trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
| 862 | + if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) { |
|
| 863 | + trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
| 864 | + } |
|
| 820 | 865 | |
| 821 | - if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) |
|
| 822 | - trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
| 866 | + if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) { |
|
| 867 | + trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
| 868 | + } |
|
| 823 | 869 | |
| 824 | 870 | // Set every optional value to its default value. |
| 825 | 871 | $boardOptions += array( |
@@ -853,8 +899,9 @@ discard block |
||
| 853 | 899 | ); |
| 854 | 900 | $board_id = $smcFunc['db_insert_id']('{db_prefix}boards', 'id_board'); |
| 855 | 901 | |
| 856 | - if (empty($board_id)) |
|
| 857 | - return 0; |
|
| 902 | + if (empty($board_id)) { |
|
| 903 | + return 0; |
|
| 904 | + } |
|
| 858 | 905 | |
| 859 | 906 | // Change the board according to the given specifications. |
| 860 | 907 | modifyBoard($board_id, $boardOptions); |
@@ -917,8 +964,9 @@ discard block |
||
| 917 | 964 | global $sourcedir, $boards, $smcFunc; |
| 918 | 965 | |
| 919 | 966 | // No boards to delete? Return! |
| 920 | - if (empty($boards_to_remove)) |
|
| 921 | - return; |
|
| 967 | + if (empty($boards_to_remove)) { |
|
| 968 | + return; |
|
| 969 | + } |
|
| 922 | 970 | |
| 923 | 971 | getBoardTree(); |
| 924 | 972 | |
@@ -929,12 +977,14 @@ discard block |
||
| 929 | 977 | { |
| 930 | 978 | // Get a list of the child boards that will also be removed. |
| 931 | 979 | $child_boards_to_remove = array(); |
| 932 | - foreach ($boards_to_remove as $board_to_remove) |
|
| 933 | - recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
| 980 | + foreach ($boards_to_remove as $board_to_remove) { |
|
| 981 | + recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
| 982 | + } |
|
| 934 | 983 | |
| 935 | 984 | // Merge the children with their parents. |
| 936 | - if (!empty($child_boards_to_remove)) |
|
| 937 | - $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
| 985 | + if (!empty($child_boards_to_remove)) { |
|
| 986 | + $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
| 987 | + } |
|
| 938 | 988 | } |
| 939 | 989 | // Move the children to a safe home. |
| 940 | 990 | else |
@@ -942,10 +992,11 @@ discard block |
||
| 942 | 992 | foreach ($boards_to_remove as $id_board) |
| 943 | 993 | { |
| 944 | 994 | // @todo Separate category? |
| 945 | - if ($moveChildrenTo === 0) |
|
| 946 | - fixChildren($id_board, 0, 0); |
|
| 947 | - else |
|
| 948 | - fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
| 995 | + if ($moveChildrenTo === 0) { |
|
| 996 | + fixChildren($id_board, 0, 0); |
|
| 997 | + } else { |
|
| 998 | + fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
| 999 | + } |
|
| 949 | 1000 | } |
| 950 | 1001 | } |
| 951 | 1002 | |
@@ -959,8 +1010,9 @@ discard block |
||
| 959 | 1010 | ) |
| 960 | 1011 | ); |
| 961 | 1012 | $topics = array(); |
| 962 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 963 | - $topics[] = $row['id_topic']; |
|
| 1013 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1014 | + $topics[] = $row['id_topic']; |
|
| 1015 | + } |
|
| 964 | 1016 | $smcFunc['db_free_result']($request); |
| 965 | 1017 | |
| 966 | 1018 | require_once($sourcedir . '/RemoveTopic.php'); |
@@ -1048,8 +1100,9 @@ discard block |
||
| 1048 | 1100 | clean_cache('data'); |
| 1049 | 1101 | |
| 1050 | 1102 | // Let's do some serious logging. |
| 1051 | - foreach ($boards_to_remove as $id_board) |
|
| 1052 | - logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
| 1103 | + foreach ($boards_to_remove as $id_board) { |
|
| 1104 | + logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
| 1105 | + } |
|
| 1053 | 1106 | |
| 1054 | 1107 | reorderBoards(); |
| 1055 | 1108 | } |
@@ -1068,8 +1121,8 @@ discard block |
||
| 1068 | 1121 | $board_order = 0; |
| 1069 | 1122 | foreach ($cat_tree as $catID => $dummy) |
| 1070 | 1123 | { |
| 1071 | - foreach ($boardList[$catID] as $boardID) |
|
| 1072 | - if ($boards[$boardID]['order'] != ++$board_order) |
|
| 1124 | + foreach ($boardList[$catID] as $boardID) { |
|
| 1125 | + if ($boards[$boardID]['order'] != ++$board_order) |
|
| 1073 | 1126 | $smcFunc['db_query']('', ' |
| 1074 | 1127 | UPDATE {db_prefix}boards |
| 1075 | 1128 | SET board_order = {int:new_order} |
@@ -1079,6 +1132,7 @@ discard block |
||
| 1079 | 1132 | 'selected_board' => $boardID, |
| 1080 | 1133 | ) |
| 1081 | 1134 | ); |
| 1135 | + } |
|
| 1082 | 1136 | } |
| 1083 | 1137 | |
| 1084 | 1138 | // Empty the board order cache |
@@ -1107,8 +1161,9 @@ discard block |
||
| 1107 | 1161 | ) |
| 1108 | 1162 | ); |
| 1109 | 1163 | $children = array(); |
| 1110 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1111 | - $children[] = $row['id_board']; |
|
| 1164 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1165 | + $children[] = $row['id_board']; |
|
| 1166 | + } |
|
| 1112 | 1167 | $smcFunc['db_free_result']($result); |
| 1113 | 1168 | |
| 1114 | 1169 | // ...and set it to a new parent and child_level. |
@@ -1124,9 +1179,10 @@ discard block |
||
| 1124 | 1179 | ); |
| 1125 | 1180 | |
| 1126 | 1181 | // Recursively fix the children of the children. |
| 1127 | - foreach ($children as $child) |
|
| 1128 | - fixChildren($child, $newLevel + 1, $child); |
|
| 1129 | -} |
|
| 1182 | + foreach ($children as $child) { |
|
| 1183 | + fixChildren($child, $newLevel + 1, $child); |
|
| 1184 | + } |
|
| 1185 | + } |
|
| 1130 | 1186 | |
| 1131 | 1187 | /** |
| 1132 | 1188 | * Tries to load up the entire board order and category very very quickly |
@@ -1143,8 +1199,9 @@ discard block |
||
| 1143 | 1199 | 'boards' => array(), |
| 1144 | 1200 | ); |
| 1145 | 1201 | |
| 1146 | - if (!empty($tree_order['boards'])) |
|
| 1147 | - return $tree_order; |
|
| 1202 | + if (!empty($tree_order['boards'])) { |
|
| 1203 | + return $tree_order; |
|
| 1204 | + } |
|
| 1148 | 1205 | |
| 1149 | 1206 | if (($cached = cache_get_data('board_order', 86400)) !== null) |
| 1150 | 1207 | { |
@@ -1160,8 +1217,9 @@ discard block |
||
| 1160 | 1217 | ); |
| 1161 | 1218 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1162 | 1219 | { |
| 1163 | - if (!in_array($row['id_cat'], $tree_order['cats'])) |
|
| 1164 | - $tree_order['cats'][] = $row['id_cat']; |
|
| 1220 | + if (!in_array($row['id_cat'], $tree_order['cats'])) { |
|
| 1221 | + $tree_order['cats'][] = $row['id_cat']; |
|
| 1222 | + } |
|
| 1165 | 1223 | $tree_order['boards'][] = $row['id_board']; |
| 1166 | 1224 | } |
| 1167 | 1225 | $smcFunc['db_free_result']($request); |
@@ -1181,16 +1239,19 @@ discard block |
||
| 1181 | 1239 | $tree = getTreeOrder(); |
| 1182 | 1240 | |
| 1183 | 1241 | $ordered = array(); |
| 1184 | - foreach ($tree['boards'] as $board) |
|
| 1185 | - if (!empty($boards[$board])) |
|
| 1242 | + foreach ($tree['boards'] as $board) { |
|
| 1243 | + if (!empty($boards[$board])) |
|
| 1186 | 1244 | { |
| 1187 | 1245 | $ordered[$board] = $boards[$board]; |
| 1246 | + } |
|
| 1188 | 1247 | |
| 1189 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) |
|
| 1190 | - sortBoards($ordered[$board]['boards']); |
|
| 1248 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) { |
|
| 1249 | + sortBoards($ordered[$board]['boards']); |
|
| 1250 | + } |
|
| 1191 | 1251 | |
| 1192 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) |
|
| 1193 | - sortBoards($ordered[$board]['children']); |
|
| 1252 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) { |
|
| 1253 | + sortBoards($ordered[$board]['children']); |
|
| 1254 | + } |
|
| 1194 | 1255 | } |
| 1195 | 1256 | |
| 1196 | 1257 | $boards = $ordered; |
@@ -1206,12 +1267,14 @@ discard block |
||
| 1206 | 1267 | $tree = getTreeOrder(); |
| 1207 | 1268 | |
| 1208 | 1269 | $ordered = array(); |
| 1209 | - foreach ($tree['cats'] as $cat) |
|
| 1210 | - if (!empty($categories[$cat])) |
|
| 1270 | + foreach ($tree['cats'] as $cat) { |
|
| 1271 | + if (!empty($categories[$cat])) |
|
| 1211 | 1272 | { |
| 1212 | 1273 | $ordered[$cat] = $categories[$cat]; |
| 1213 | - if (!empty($ordered[$cat]['boards'])) |
|
| 1214 | - sortBoards($ordered[$cat]['boards']); |
|
| 1274 | + } |
|
| 1275 | + if (!empty($ordered[$cat]['boards'])) { |
|
| 1276 | + sortBoards($ordered[$cat]['boards']); |
|
| 1277 | + } |
|
| 1215 | 1278 | } |
| 1216 | 1279 | |
| 1217 | 1280 | $categories = $ordered; |
@@ -1227,8 +1290,9 @@ discard block |
||
| 1227 | 1290 | { |
| 1228 | 1291 | global $smcFunc, $scripturl, $txt; |
| 1229 | 1292 | |
| 1230 | - if (empty($boards)) |
|
| 1231 | - return array(); |
|
| 1293 | + if (empty($boards)) { |
|
| 1294 | + return array(); |
|
| 1295 | + } |
|
| 1232 | 1296 | |
| 1233 | 1297 | $request = $smcFunc['db_query']('', ' |
| 1234 | 1298 | SELECT mem.id_member, mem.real_name, mo.id_board |
@@ -1242,8 +1306,9 @@ discard block |
||
| 1242 | 1306 | $moderators = array(); |
| 1243 | 1307 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1244 | 1308 | { |
| 1245 | - if (empty($moderators[$row['id_board']])) |
|
| 1246 | - $moderators[$row['id_board']] = array(); |
|
| 1309 | + if (empty($moderators[$row['id_board']])) { |
|
| 1310 | + $moderators[$row['id_board']] = array(); |
|
| 1311 | + } |
|
| 1247 | 1312 | |
| 1248 | 1313 | $moderators[$row['id_board']][] = array( |
| 1249 | 1314 | 'id' => $row['id_member'], |
@@ -1267,8 +1332,9 @@ discard block |
||
| 1267 | 1332 | { |
| 1268 | 1333 | global $smcFunc, $scripturl, $txt; |
| 1269 | 1334 | |
| 1270 | - if (empty($boards)) |
|
| 1271 | - return array(); |
|
| 1335 | + if (empty($boards)) { |
|
| 1336 | + return array(); |
|
| 1337 | + } |
|
| 1272 | 1338 | |
| 1273 | 1339 | $request = $smcFunc['db_query']('', ' |
| 1274 | 1340 | SELECT mg.id_group, mg.group_name, bg.id_board |
@@ -1282,8 +1348,9 @@ discard block |
||
| 1282 | 1348 | $groups = array(); |
| 1283 | 1349 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1284 | 1350 | { |
| 1285 | - if (empty($groups[$row['id_board']])) |
|
| 1286 | - $groups[$row['id_board']] = array(); |
|
| 1351 | + if (empty($groups[$row['id_board']])) { |
|
| 1352 | + $groups[$row['id_board']] = array(); |
|
| 1353 | + } |
|
| 1287 | 1354 | |
| 1288 | 1355 | $groups[$row['id_board']][] = array( |
| 1289 | 1356 | 'id' => $row['id_group'], |
@@ -1345,8 +1412,9 @@ discard block |
||
| 1345 | 1412 | |
| 1346 | 1413 | if (!empty($row['id_board'])) |
| 1347 | 1414 | { |
| 1348 | - if ($row['child_level'] != $curLevel) |
|
| 1349 | - $prevBoard = 0; |
|
| 1415 | + if ($row['child_level'] != $curLevel) { |
|
| 1416 | + $prevBoard = 0; |
|
| 1417 | + } |
|
| 1350 | 1418 | |
| 1351 | 1419 | $boards[$row['id_board']] = array( |
| 1352 | 1420 | 'id' => $row['id_board'], |
@@ -1378,16 +1446,16 @@ discard block |
||
| 1378 | 1446 | 'children' => array() |
| 1379 | 1447 | ); |
| 1380 | 1448 | $boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']]; |
| 1381 | - } |
|
| 1382 | - else |
|
| 1449 | + } else |
|
| 1383 | 1450 | { |
| 1384 | 1451 | // Parent doesn't exist! |
| 1385 | - if (!isset($boards[$row['id_parent']]['tree'])) |
|
| 1386 | - fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
| 1452 | + if (!isset($boards[$row['id_parent']]['tree'])) { |
|
| 1453 | + fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
| 1454 | + } |
|
| 1387 | 1455 | |
| 1388 | 1456 | // Wrong childlevel...we can silently fix this... |
| 1389 | - if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) |
|
| 1390 | - $smcFunc['db_query']('', ' |
|
| 1457 | + if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) { |
|
| 1458 | + $smcFunc['db_query']('', ' |
|
| 1391 | 1459 | UPDATE {db_prefix}boards |
| 1392 | 1460 | SET child_level = {int:new_child_level} |
| 1393 | 1461 | WHERE id_board = {int:selected_board}', |
@@ -1396,6 +1464,7 @@ discard block |
||
| 1396 | 1464 | 'selected_board' => $row['id_board'], |
| 1397 | 1465 | ) |
| 1398 | 1466 | ); |
| 1467 | + } |
|
| 1399 | 1468 | |
| 1400 | 1469 | $boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array( |
| 1401 | 1470 | 'node' => &$boards[$row['id_board']], |
@@ -1426,8 +1495,9 @@ discard block |
||
| 1426 | 1495 | */ |
| 1427 | 1496 | function recursiveBoards(&$_boardList, &$_tree) |
| 1428 | 1497 | { |
| 1429 | - if (empty($_tree['children'])) |
|
| 1430 | - return; |
|
| 1498 | + if (empty($_tree['children'])) { |
|
| 1499 | + return; |
|
| 1500 | + } |
|
| 1431 | 1501 | |
| 1432 | 1502 | foreach ($_tree['children'] as $id => $node) |
| 1433 | 1503 | { |
@@ -1446,11 +1516,13 @@ discard block |
||
| 1446 | 1516 | { |
| 1447 | 1517 | global $boards; |
| 1448 | 1518 | |
| 1449 | - if (empty($boards[$child]['parent'])) |
|
| 1450 | - return false; |
|
| 1519 | + if (empty($boards[$child]['parent'])) { |
|
| 1520 | + return false; |
|
| 1521 | + } |
|
| 1451 | 1522 | |
| 1452 | - if ($boards[$child]['parent'] == $parent) |
|
| 1453 | - return true; |
|
| 1523 | + if ($boards[$child]['parent'] == $parent) { |
|
| 1524 | + return true; |
|
| 1525 | + } |
|
| 1454 | 1526 | |
| 1455 | 1527 | return isChildOf($boards[$child]['parent'], $parent); |
| 1456 | 1528 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 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 | /** |
@@ -44,8 +45,9 @@ discard block |
||
| 44 | 45 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_membergroups') ? 'index' : 'settings'); |
| 45 | 46 | |
| 46 | 47 | // Is it elsewhere? |
| 47 | - if (isset($subActions[$_REQUEST['sa']][2])) |
|
| 48 | - require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
| 48 | + if (isset($subActions[$_REQUEST['sa']][2])) { |
|
| 49 | + require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | // Do the permission check, you might not be allowed her. |
| 51 | 53 | isAllowedTo($subActions[$_REQUEST['sa']][1]); |
@@ -104,19 +106,20 @@ discard block |
||
| 104 | 106 | 'function' => function($rowData) use ($scripturl) |
| 105 | 107 | { |
| 106 | 108 | // Since the moderator group has no explicit members, no link is needed. |
| 107 | - if ($rowData['id_group'] == 3) |
|
| 108 | - $group_name = $rowData['group_name']; |
|
| 109 | - else |
|
| 109 | + if ($rowData['id_group'] == 3) { |
|
| 110 | + $group_name = $rowData['group_name']; |
|
| 111 | + } else |
|
| 110 | 112 | { |
| 111 | 113 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
| 112 | 114 | $group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
| 113 | 115 | } |
| 114 | 116 | |
| 115 | 117 | // Add a help option for moderator and administrator. |
| 116 | - if ($rowData['id_group'] == 1) |
|
| 117 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 118 | - elseif ($rowData['id_group'] == 3) |
|
| 119 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 118 | + if ($rowData['id_group'] == 1) { |
|
| 119 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 120 | + } elseif ($rowData['id_group'] == 3) { |
|
| 121 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 122 | + } |
|
| 120 | 123 | |
| 121 | 124 | return $group_name; |
| 122 | 125 | }, |
@@ -330,12 +333,14 @@ discard block |
||
| 330 | 333 | call_integration_hook('integrate_add_membergroup', array($id_group, $postCountBasedGroup)); |
| 331 | 334 | |
| 332 | 335 | // Update the post groups now, if this is a post group! |
| 333 | - if (isset($_POST['min_posts'])) |
|
| 334 | - updateStats('postgroups'); |
|
| 336 | + if (isset($_POST['min_posts'])) { |
|
| 337 | + updateStats('postgroups'); |
|
| 338 | + } |
|
| 335 | 339 | |
| 336 | 340 | // You cannot set permissions for post groups if they are disabled. |
| 337 | - if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) |
|
| 338 | - $_POST['perm_type'] = ''; |
|
| 341 | + if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) { |
|
| 342 | + $_POST['perm_type'] = ''; |
|
| 343 | + } |
|
| 339 | 344 | |
| 340 | 345 | if ($_POST['perm_type'] == 'predefined') |
| 341 | 346 | { |
@@ -365,8 +370,9 @@ discard block |
||
| 365 | 370 | $smcFunc['db_free_result']($request); |
| 366 | 371 | |
| 367 | 372 | // Protected groups are... well, protected! |
| 368 | - if ($copy_type == 1) |
|
| 369 | - fatal_lang_error('membergroup_does_not_exist'); |
|
| 373 | + if ($copy_type == 1) { |
|
| 374 | + fatal_lang_error('membergroup_does_not_exist'); |
|
| 375 | + } |
|
| 370 | 376 | } |
| 371 | 377 | |
| 372 | 378 | // Don't allow copying of a real priviledged person! |
@@ -384,18 +390,20 @@ discard block |
||
| 384 | 390 | $inserts = array(); |
| 385 | 391 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 386 | 392 | { |
| 387 | - if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) |
|
| 388 | - $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
| 393 | + if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) { |
|
| 394 | + $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
| 395 | + } |
|
| 389 | 396 | } |
| 390 | 397 | $smcFunc['db_free_result']($request); |
| 391 | 398 | |
| 392 | - if (!empty($inserts)) |
|
| 393 | - $smcFunc['db_insert']('insert', |
|
| 399 | + if (!empty($inserts)) { |
|
| 400 | + $smcFunc['db_insert']('insert', |
|
| 394 | 401 | '{db_prefix}permissions', |
| 395 | 402 | array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
| 396 | 403 | $inserts, |
| 397 | 404 | array('id_group', 'permission') |
| 398 | 405 | ); |
| 406 | + } |
|
| 399 | 407 | |
| 400 | 408 | $request = $smcFunc['db_query']('', ' |
| 401 | 409 | SELECT id_profile, permission, add_deny |
@@ -406,17 +414,19 @@ discard block |
||
| 406 | 414 | ) |
| 407 | 415 | ); |
| 408 | 416 | $inserts = array(); |
| 409 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 410 | - $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
| 417 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 418 | + $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
| 419 | + } |
|
| 411 | 420 | $smcFunc['db_free_result']($request); |
| 412 | 421 | |
| 413 | - if (!empty($inserts)) |
|
| 414 | - $smcFunc['db_insert']('insert', |
|
| 422 | + if (!empty($inserts)) { |
|
| 423 | + $smcFunc['db_insert']('insert', |
|
| 415 | 424 | '{db_prefix}board_permissions', |
| 416 | 425 | array('id_group' => 'int', 'id_profile' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
| 417 | 426 | $inserts, |
| 418 | 427 | array('id_group', 'id_profile', 'permission') |
| 419 | 428 | ); |
| 429 | + } |
|
| 420 | 430 | |
| 421 | 431 | // Also get some membergroup information if we're copying and not copying from guests... |
| 422 | 432 | if ($copy_id > 0 && $_POST['perm_type'] == 'copy') |
@@ -469,14 +479,15 @@ discard block |
||
| 469 | 479 | $changed_boards['allow'] = array(); |
| 470 | 480 | $changed_boards['deny'] = array(); |
| 471 | 481 | $changed_boards['ignore'] = array(); |
| 472 | - foreach ($accesses as $group_id => $action) |
|
| 473 | - $changed_boards[$action][] = (int) $group_id; |
|
| 482 | + foreach ($accesses as $group_id => $action) { |
|
| 483 | + $changed_boards[$action][] = (int) $group_id; |
|
| 484 | + } |
|
| 474 | 485 | |
| 475 | 486 | foreach (array('allow', 'deny') as $board_action) |
| 476 | 487 | { |
| 477 | 488 | // Only do this if they have special access requirements. |
| 478 | - if (!empty($changed_boards[$board_action])) |
|
| 479 | - $smcFunc['db_query']('', ' |
|
| 489 | + if (!empty($changed_boards[$board_action])) { |
|
| 490 | + $smcFunc['db_query']('', ' |
|
| 480 | 491 | UPDATE {db_prefix}boards |
| 481 | 492 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
| 482 | 493 | WHERE id_board IN ({array_int:board_list})', |
@@ -488,11 +499,13 @@ discard block |
||
| 488 | 499 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 489 | 500 | ) |
| 490 | 501 | ); |
| 502 | + } |
|
| 491 | 503 | } |
| 492 | 504 | |
| 493 | 505 | // If this is joinable then set it to show group membership in people's profiles. |
| 494 | - if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) |
|
| 495 | - updateSettings(array('show_group_membership' => 1)); |
|
| 506 | + if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) { |
|
| 507 | + updateSettings(array('show_group_membership' => 1)); |
|
| 508 | + } |
|
| 496 | 509 | |
| 497 | 510 | // Rebuild the group cache. |
| 498 | 511 | updateSettings(array( |
@@ -513,8 +526,9 @@ discard block |
||
| 513 | 526 | $context['undefined_group'] = !isset($_REQUEST['postgroup']) && !isset($_REQUEST['generalgroup']); |
| 514 | 527 | $context['allow_protected'] = allowedTo('admin_forum'); |
| 515 | 528 | |
| 516 | - if (!empty($modSettings['deny_boards_access'])) |
|
| 517 | - loadLanguage('ManagePermissions'); |
|
| 529 | + if (!empty($modSettings['deny_boards_access'])) { |
|
| 530 | + loadLanguage('ManagePermissions'); |
|
| 531 | + } |
|
| 518 | 532 | |
| 519 | 533 | $result = $smcFunc['db_query']('', ' |
| 520 | 534 | SELECT id_group, group_name |
@@ -531,11 +545,12 @@ discard block |
||
| 531 | 545 | ) |
| 532 | 546 | ); |
| 533 | 547 | $context['groups'] = array(); |
| 534 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 535 | - $context['groups'][] = array( |
|
| 548 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 549 | + $context['groups'][] = array( |
|
| 536 | 550 | 'id' => $row['id_group'], |
| 537 | 551 | 'name' => $row['group_name'] |
| 538 | 552 | ); |
| 553 | + } |
|
| 539 | 554 | $smcFunc['db_free_result']($result); |
| 540 | 555 | |
| 541 | 556 | $request = $smcFunc['db_query']('', ' |
@@ -552,12 +567,13 @@ discard block |
||
| 552 | 567 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 553 | 568 | { |
| 554 | 569 | // This category hasn't been set up yet.. |
| 555 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 556 | - $context['categories'][$row['id_cat']] = array( |
|
| 570 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 571 | + $context['categories'][$row['id_cat']] = array( |
|
| 557 | 572 | 'id' => $row['id_cat'], |
| 558 | 573 | 'name' => $row['cat_name'], |
| 559 | 574 | 'boards' => array() |
| 560 | 575 | ); |
| 576 | + } |
|
| 561 | 577 | |
| 562 | 578 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 563 | 579 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -605,8 +621,9 @@ discard block |
||
| 605 | 621 | require_once($sourcedir . '/Subs-Membergroups.php'); |
| 606 | 622 | $result = deleteMembergroups((int) $_REQUEST['group']); |
| 607 | 623 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
| 608 | - if ($result === 'group_cannot_delete_sub') |
|
| 609 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 624 | + if ($result === 'group_cannot_delete_sub') { |
|
| 625 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 626 | + } |
|
| 610 | 627 | |
| 611 | 628 | // Go back to the membergroup index. |
| 612 | 629 | redirectexit('action=admin;area=membergroups;'); |
@@ -628,8 +645,9 @@ discard block |
||
| 628 | 645 | |
| 629 | 646 | $_REQUEST['group'] = isset($_REQUEST['group']) && $_REQUEST['group'] > 0 ? (int) $_REQUEST['group'] : 0; |
| 630 | 647 | |
| 631 | - if (!empty($modSettings['deny_boards_access'])) |
|
| 632 | - loadLanguage('ManagePermissions'); |
|
| 648 | + if (!empty($modSettings['deny_boards_access'])) { |
|
| 649 | + loadLanguage('ManagePermissions'); |
|
| 650 | + } |
|
| 633 | 651 | |
| 634 | 652 | // Make sure this group is editable. |
| 635 | 653 | if (!empty($_REQUEST['group'])) |
@@ -651,8 +669,9 @@ discard block |
||
| 651 | 669 | } |
| 652 | 670 | |
| 653 | 671 | // Now, do we have a valid id? |
| 654 | - if (empty($_REQUEST['group'])) |
|
| 655 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 672 | + if (empty($_REQUEST['group'])) { |
|
| 673 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 674 | + } |
|
| 656 | 675 | |
| 657 | 676 | // People who can manage boards are a bit special. |
| 658 | 677 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -683,8 +702,9 @@ discard block |
||
| 683 | 702 | require_once($sourcedir . '/Subs-Membergroups.php'); |
| 684 | 703 | $result = deleteMembergroups($_REQUEST['group']); |
| 685 | 704 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
| 686 | - if ($result === 'group_cannot_delete_sub') |
|
| 687 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 705 | + if ($result === 'group_cannot_delete_sub') { |
|
| 706 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 707 | + } |
|
| 688 | 708 | |
| 689 | 709 | redirectexit('action=admin;area=membergroups;'); |
| 690 | 710 | } |
@@ -761,16 +781,18 @@ discard block |
||
| 761 | 781 | $request = $smcFunc['db_query']('', ' |
| 762 | 782 | SELECT id_board |
| 763 | 783 | FROM {db_prefix}boards'); |
| 764 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 765 | - $accesses[(int) $row['id_board']] = 'allow'; |
|
| 784 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 785 | + $accesses[(int) $row['id_board']] = 'allow'; |
|
| 786 | + } |
|
| 766 | 787 | $smcFunc['db_free_result']($request); |
| 767 | 788 | } |
| 768 | 789 | |
| 769 | 790 | $changed_boards['allow'] = array(); |
| 770 | 791 | $changed_boards['deny'] = array(); |
| 771 | 792 | $changed_boards['ignore'] = array(); |
| 772 | - foreach ($accesses as $group_id => $action) |
|
| 773 | - $changed_boards[$action][] = (int) $group_id; |
|
| 793 | + foreach ($accesses as $group_id => $action) { |
|
| 794 | + $changed_boards[$action][] = (int) $group_id; |
|
| 795 | + } |
|
| 774 | 796 | |
| 775 | 797 | foreach (array('allow', 'deny') as $board_action) |
| 776 | 798 | { |
@@ -786,8 +808,8 @@ discard block |
||
| 786 | 808 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 787 | 809 | ) |
| 788 | 810 | ); |
| 789 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 790 | - $smcFunc['db_query']('', ' |
|
| 811 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 812 | + $smcFunc['db_query']('', ' |
|
| 791 | 813 | UPDATE {db_prefix}boards |
| 792 | 814 | SET {raw:column} = {string:member_group_access} |
| 793 | 815 | WHERE id_board = {int:current_board}', |
@@ -797,11 +819,12 @@ discard block |
||
| 797 | 819 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 798 | 820 | ) |
| 799 | 821 | ); |
| 822 | + } |
|
| 800 | 823 | $smcFunc['db_free_result']($request); |
| 801 | 824 | |
| 802 | 825 | // Add the membergroup to all boards that hadn't been set yet. |
| 803 | - if (!empty($changed_boards[$board_action])) |
|
| 804 | - $smcFunc['db_query']('', ' |
|
| 826 | + if (!empty($changed_boards[$board_action])) { |
|
| 827 | + $smcFunc['db_query']('', ' |
|
| 805 | 828 | UPDATE {db_prefix}boards |
| 806 | 829 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
| 807 | 830 | WHERE id_board IN ({array_int:board_list}) |
@@ -815,6 +838,7 @@ discard block |
||
| 815 | 838 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 816 | 839 | ) |
| 817 | 840 | ); |
| 841 | + } |
|
| 818 | 842 | } |
| 819 | 843 | } |
| 820 | 844 | |
@@ -840,12 +864,14 @@ discard block |
||
| 840 | 864 | ) |
| 841 | 865 | ); |
| 842 | 866 | $updates = array(); |
| 843 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 844 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 867 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 868 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 869 | + } |
|
| 845 | 870 | $smcFunc['db_free_result']($request); |
| 846 | 871 | |
| 847 | - foreach ($updates as $additional_groups => $memberArray) |
|
| 848 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
| 872 | + foreach ($updates as $additional_groups => $memberArray) { |
|
| 873 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
| 874 | + } |
|
| 849 | 875 | |
| 850 | 876 | // Sorry, but post groups can't moderate boards |
| 851 | 877 | $smcFunc['db_query']('', ' |
@@ -855,8 +881,7 @@ discard block |
||
| 855 | 881 | 'current_group' => (int) $_REQUEST['group'], |
| 856 | 882 | ) |
| 857 | 883 | ); |
| 858 | - } |
|
| 859 | - elseif ($_REQUEST['group'] != 3) |
|
| 884 | + } elseif ($_REQUEST['group'] != 3) |
|
| 860 | 885 | { |
| 861 | 886 | // Making it a hidden group? If so remove everyone with it as primary group (Actually, just make them additional). |
| 862 | 887 | if ($_POST['group_hidden'] == 2) |
@@ -871,8 +896,9 @@ discard block |
||
| 871 | 896 | ) |
| 872 | 897 | ); |
| 873 | 898 | $updates = array(); |
| 874 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 875 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 899 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 900 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 901 | + } |
|
| 876 | 902 | $smcFunc['db_free_result']($request); |
| 877 | 903 | |
| 878 | 904 | foreach ($updates as $additional_groups => $memberArray) |
@@ -914,8 +940,9 @@ discard block |
||
| 914 | 940 | $smcFunc['db_free_result']($request); |
| 915 | 941 | |
| 916 | 942 | // Do we need to update the setting? |
| 917 | - if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) |
|
| 918 | - updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
| 943 | + if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) { |
|
| 944 | + updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
| 945 | + } |
|
| 919 | 946 | } |
| 920 | 947 | |
| 921 | 948 | // Do we need to set inherited permissions? |
@@ -948,8 +975,9 @@ discard block |
||
| 948 | 975 | { |
| 949 | 976 | $moderators[$k] = trim($moderators[$k]); |
| 950 | 977 | |
| 951 | - if (strlen($moderators[$k]) == 0) |
|
| 952 | - unset($moderators[$k]); |
|
| 978 | + if (strlen($moderators[$k]) == 0) { |
|
| 979 | + unset($moderators[$k]); |
|
| 980 | + } |
|
| 953 | 981 | } |
| 954 | 982 | |
| 955 | 983 | // Find all the id_member's for the member_name's in the list. |
@@ -965,8 +993,9 @@ discard block |
||
| 965 | 993 | 'count' => count($moderators), |
| 966 | 994 | ) |
| 967 | 995 | ); |
| 968 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 969 | - $group_moderators[] = $row['id_member']; |
|
| 996 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 997 | + $group_moderators[] = $row['id_member']; |
|
| 998 | + } |
|
| 970 | 999 | $smcFunc['db_free_result']($request); |
| 971 | 1000 | } |
| 972 | 1001 | } |
@@ -974,8 +1003,9 @@ discard block |
||
| 974 | 1003 | if (!empty($_POST['moderator_list'])) |
| 975 | 1004 | { |
| 976 | 1005 | $moderators = array(); |
| 977 | - foreach ($_POST['moderator_list'] as $moderator) |
|
| 978 | - $moderators[] = (int) $moderator; |
|
| 1006 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
| 1007 | + $moderators[] = (int) $moderator; |
|
| 1008 | + } |
|
| 979 | 1009 | |
| 980 | 1010 | if (!empty($moderators)) |
| 981 | 1011 | { |
@@ -989,8 +1019,9 @@ discard block |
||
| 989 | 1019 | 'num_moderators' => count($moderators), |
| 990 | 1020 | ) |
| 991 | 1021 | ); |
| 992 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 993 | - $group_moderators[] = $row['id_member']; |
|
| 1022 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1023 | + $group_moderators[] = $row['id_member']; |
|
| 1024 | + } |
|
| 994 | 1025 | $smcFunc['db_free_result']($request); |
| 995 | 1026 | } |
| 996 | 1027 | } |
@@ -1002,8 +1033,9 @@ discard block |
||
| 1002 | 1033 | if (!empty($group_moderators)) |
| 1003 | 1034 | { |
| 1004 | 1035 | $mod_insert = array(); |
| 1005 | - foreach ($group_moderators as $moderator) |
|
| 1006 | - $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
| 1036 | + foreach ($group_moderators as $moderator) { |
|
| 1037 | + $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
| 1038 | + } |
|
| 1007 | 1039 | |
| 1008 | 1040 | $smcFunc['db_insert']('insert', |
| 1009 | 1041 | '{db_prefix}group_moderators', |
@@ -1037,8 +1069,9 @@ discard block |
||
| 1037 | 1069 | 'current_group' => (int) $_REQUEST['group'], |
| 1038 | 1070 | ) |
| 1039 | 1071 | ); |
| 1040 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1041 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 1072 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1073 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 1074 | + } |
|
| 1042 | 1075 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1043 | 1076 | $smcFunc['db_free_result']($request); |
| 1044 | 1077 | |
@@ -1075,14 +1108,16 @@ discard block |
||
| 1075 | 1108 | ) |
| 1076 | 1109 | ); |
| 1077 | 1110 | $context['group']['moderators'] = array(); |
| 1078 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1079 | - $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
| 1111 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1112 | + $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
| 1113 | + } |
|
| 1080 | 1114 | $smcFunc['db_free_result']($request); |
| 1081 | 1115 | |
| 1082 | 1116 | $context['group']['moderator_list'] = empty($context['group']['moderators']) ? '' : '"' . implode('", "', $context['group']['moderators']) . '"'; |
| 1083 | 1117 | |
| 1084 | - if (!empty($context['group']['moderators'])) |
|
| 1085 | - list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
| 1118 | + if (!empty($context['group']['moderators'])) { |
|
| 1119 | + list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
| 1120 | + } |
|
| 1086 | 1121 | |
| 1087 | 1122 | // Get a list of boards this membergroup is allowed to see. |
| 1088 | 1123 | $context['boards'] = array(); |
@@ -1102,12 +1137,13 @@ discard block |
||
| 1102 | 1137 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1103 | 1138 | { |
| 1104 | 1139 | // This category hasn't been set up yet.. |
| 1105 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 1106 | - $context['categories'][$row['id_cat']] = array( |
|
| 1140 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 1141 | + $context['categories'][$row['id_cat']] = array( |
|
| 1107 | 1142 | 'id' => $row['id_cat'], |
| 1108 | 1143 | 'name' => $row['cat_name'], |
| 1109 | 1144 | 'boards' => array() |
| 1110 | 1145 | ); |
| 1146 | + } |
|
| 1111 | 1147 | |
| 1112 | 1148 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 1113 | 1149 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -1155,19 +1191,22 @@ discard block |
||
| 1155 | 1191 | $image_info = getimagesize($settings['default_theme_dir'] . '/images/membericons/' . $value); |
| 1156 | 1192 | |
| 1157 | 1193 | // If this is bigger than 128 in width or 32 in height, skip this one. |
| 1158 | - if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) |
|
| 1159 | - continue; |
|
| 1194 | + if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) { |
|
| 1195 | + continue; |
|
| 1196 | + } |
|
| 1160 | 1197 | |
| 1161 | 1198 | // Else it's valid. Add it in. |
| 1162 | - else |
|
| 1163 | - $context['possible_icons'][] = $value; |
|
| 1199 | + else { |
|
| 1200 | + $context['possible_icons'][] = $value; |
|
| 1201 | + } |
|
| 1164 | 1202 | } |
| 1165 | 1203 | } |
| 1166 | 1204 | } |
| 1167 | 1205 | |
| 1168 | 1206 | // Insert our JS, if we have possible icons. |
| 1169 | - if (!empty($context['possible_icons'])) |
|
| 1170 | - loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown'); |
|
| 1207 | + if (!empty($context['possible_icons'])) { |
|
| 1208 | + loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown'); |
|
| 1209 | + } |
|
| 1171 | 1210 | |
| 1172 | 1211 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 1173 | 1212 | |
@@ -1189,8 +1228,9 @@ discard block |
||
| 1189 | 1228 | ) |
| 1190 | 1229 | ); |
| 1191 | 1230 | $context['inheritable_groups'] = array(); |
| 1192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1193 | - $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
| 1231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1232 | + $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
| 1233 | + } |
|
| 1194 | 1234 | $smcFunc['db_free_result']($request); |
| 1195 | 1235 | |
| 1196 | 1236 | call_integration_hook('integrate_view_membergroup'); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | /** |
| 142 | 142 | * Make files writable. First try to use regular chmod, but if that fails, try to use FTP. |
| 143 | 143 | * |
| 144 | - * @param $files |
|
| 144 | + * @param string[] $files |
|
| 145 | 145 | * @return bool |
| 146 | 146 | */ |
| 147 | 147 | function makeFilesWritable(&$files) |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | /** |
| 382 | 382 | * Prints an error to stderr. |
| 383 | 383 | * |
| 384 | - * @param $message |
|
| 384 | + * @param string $message |
|
| 385 | 385 | * @param bool $fatal |
| 386 | 386 | */ |
| 387 | 387 | function print_error($message, $fatal = false) |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | /** |
| 401 | 401 | * Throws a graphical error message. |
| 402 | 402 | * |
| 403 | - * @param $message |
|
| 403 | + * @param string $message |
|
| 404 | 404 | * @return bool |
| 405 | 405 | */ |
| 406 | 406 | function throw_error($message) |
@@ -14,66 +14,66 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | if (!defined('SMF_VERSION')) |
| 17 | - die('No direct access!'); |
|
| 17 | + die('No direct access!'); |
|
| 18 | 18 | |
| 19 | 19 | if (!function_exists('un_htmlspecialchars')) |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Undo the voodoo htmlspecialchars does. |
|
| 23 | - * |
|
| 24 | - * @param $string |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - function un_htmlspecialchars($string) |
|
| 28 | - { |
|
| 29 | - return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES)) + array(''' => '\'', ' ' => ' ')); |
|
| 30 | - } |
|
| 21 | + /** |
|
| 22 | + * Undo the voodoo htmlspecialchars does. |
|
| 23 | + * |
|
| 24 | + * @param $string |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + function un_htmlspecialchars($string) |
|
| 28 | + { |
|
| 29 | + return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES)) + array(''' => '\'', ' ' => ' ')); |
|
| 30 | + } |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | if (!function_exists('text2words')) |
| 34 | 34 | { |
| 35 | - /** |
|
| 36 | - * Split a sentence into words. |
|
| 37 | - * |
|
| 38 | - * @param $text |
|
| 39 | - * @return array |
|
| 40 | - */ |
|
| 41 | - function text2words($text) |
|
| 42 | - { |
|
| 43 | - // Step 1: Remove entities/things we don't consider words: |
|
| 44 | - $words = preg_replace('~(?:[\x0B\0\xA0\t\r\s\n(){}\\[\\]<>!@$%^*.,:+=`\~\?/\\\\]+|&(?:amp|lt|gt|quot);)+~', ' ', $text); |
|
| 45 | - |
|
| 46 | - // Step 2: Entities we left to letters, where applicable, lowercase. |
|
| 47 | - $words = preg_replace('~([^&\d]|^)[#;]~', '$1 ', un_htmlspecialchars(strtolower($words))); |
|
| 48 | - |
|
| 49 | - // Step 3: Ready to split apart and index! |
|
| 50 | - $words = explode(' ', $words); |
|
| 51 | - $returned_words = array(); |
|
| 52 | - foreach ($words as $word) |
|
| 53 | - { |
|
| 54 | - $word = trim($word, '-_\''); |
|
| 55 | - |
|
| 56 | - if ($word != '') |
|
| 57 | - $returned_words[] = substr($word, 0, 20); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - return array_unique($returned_words); |
|
| 61 | - } |
|
| 35 | + /** |
|
| 36 | + * Split a sentence into words. |
|
| 37 | + * |
|
| 38 | + * @param $text |
|
| 39 | + * @return array |
|
| 40 | + */ |
|
| 41 | + function text2words($text) |
|
| 42 | + { |
|
| 43 | + // Step 1: Remove entities/things we don't consider words: |
|
| 44 | + $words = preg_replace('~(?:[\x0B\0\xA0\t\r\s\n(){}\\[\\]<>!@$%^*.,:+=`\~\?/\\\\]+|&(?:amp|lt|gt|quot);)+~', ' ', $text); |
|
| 45 | + |
|
| 46 | + // Step 2: Entities we left to letters, where applicable, lowercase. |
|
| 47 | + $words = preg_replace('~([^&\d]|^)[#;]~', '$1 ', un_htmlspecialchars(strtolower($words))); |
|
| 48 | + |
|
| 49 | + // Step 3: Ready to split apart and index! |
|
| 50 | + $words = explode(' ', $words); |
|
| 51 | + $returned_words = array(); |
|
| 52 | + foreach ($words as $word) |
|
| 53 | + { |
|
| 54 | + $word = trim($word, '-_\''); |
|
| 55 | + |
|
| 56 | + if ($word != '') |
|
| 57 | + $returned_words[] = substr($word, 0, 20); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + return array_unique($returned_words); |
|
| 61 | + } |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | if (!function_exists('md5_hmac')) |
| 65 | 65 | { |
| 66 | - /** |
|
| 67 | - * Generate an MD5 hash using the HMAC method. |
|
| 68 | - * |
|
| 69 | - * @param string $data |
|
| 70 | - * @param string $key |
|
| 71 | - * @return string |
|
| 72 | - */ |
|
| 73 | - function md5_hmac($data, $key) |
|
| 74 | - { |
|
| 75 | - return hash_hmac('md5', $data, $key); |
|
| 76 | - } |
|
| 66 | + /** |
|
| 67 | + * Generate an MD5 hash using the HMAC method. |
|
| 68 | + * |
|
| 69 | + * @param string $data |
|
| 70 | + * @param string $key |
|
| 71 | + * @return string |
|
| 72 | + */ |
|
| 73 | + function md5_hmac($data, $key) |
|
| 74 | + { |
|
| 75 | + return hash_hmac('md5', $data, $key); |
|
| 76 | + } |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -82,17 +82,17 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | function upgrade_clean_cache() |
| 84 | 84 | { |
| 85 | - global $cacheAPI, $sourcedir; |
|
| 85 | + global $cacheAPI, $sourcedir; |
|
| 86 | 86 | |
| 87 | - // Initialize the cache API if it does not have an instance yet. |
|
| 88 | - if (empty($cacheAPI)) |
|
| 89 | - { |
|
| 90 | - require_once($sourcedir . '/Load.php'); |
|
| 91 | - loadCacheAccelerator(); |
|
| 92 | - } |
|
| 87 | + // Initialize the cache API if it does not have an instance yet. |
|
| 88 | + if (empty($cacheAPI)) |
|
| 89 | + { |
|
| 90 | + require_once($sourcedir . '/Load.php'); |
|
| 91 | + loadCacheAccelerator(); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - // Just fall back to Load.php's clean_cache function. |
|
| 95 | - clean_cache(); |
|
| 94 | + // Just fall back to Load.php's clean_cache function. |
|
| 95 | + clean_cache(); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -102,40 +102,40 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | function getMemberGroups() |
| 104 | 104 | { |
| 105 | - global $smcFunc; |
|
| 106 | - static $member_groups = array(); |
|
| 105 | + global $smcFunc; |
|
| 106 | + static $member_groups = array(); |
|
| 107 | 107 | |
| 108 | - if (!empty($member_groups)) |
|
| 109 | - return $member_groups; |
|
| 108 | + if (!empty($member_groups)) |
|
| 109 | + return $member_groups; |
|
| 110 | 110 | |
| 111 | - $request = $smcFunc['db_query']('', ' |
|
| 111 | + $request = $smcFunc['db_query']('', ' |
|
| 112 | 112 | SELECT group_name, id_group |
| 113 | 113 | FROM {db_prefix}membergroups |
| 114 | 114 | WHERE id_group = {int:admin_group} OR id_group > {int:old_group}', |
| 115 | - array( |
|
| 116 | - 'admin_group' => 1, |
|
| 117 | - 'old_group' => 7, |
|
| 118 | - 'db_error_skip' => true, |
|
| 119 | - ) |
|
| 120 | - ); |
|
| 121 | - if ($request === false) |
|
| 122 | - { |
|
| 123 | - $request = $smcFunc['db_query']('', ' |
|
| 115 | + array( |
|
| 116 | + 'admin_group' => 1, |
|
| 117 | + 'old_group' => 7, |
|
| 118 | + 'db_error_skip' => true, |
|
| 119 | + ) |
|
| 120 | + ); |
|
| 121 | + if ($request === false) |
|
| 122 | + { |
|
| 123 | + $request = $smcFunc['db_query']('', ' |
|
| 124 | 124 | SELECT membergroup, id_group |
| 125 | 125 | FROM {db_prefix}membergroups |
| 126 | 126 | WHERE id_group = {int:admin_group} OR id_group > {int:old_group}', |
| 127 | - array( |
|
| 128 | - 'admin_group' => 1, |
|
| 129 | - 'old_group' => 7, |
|
| 130 | - 'db_error_skip' => true, |
|
| 131 | - ) |
|
| 132 | - ); |
|
| 133 | - } |
|
| 134 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 135 | - $member_groups[trim($row[0])] = $row[1]; |
|
| 136 | - $smcFunc['db_free_result']($request); |
|
| 137 | - |
|
| 138 | - return $member_groups; |
|
| 127 | + array( |
|
| 128 | + 'admin_group' => 1, |
|
| 129 | + 'old_group' => 7, |
|
| 130 | + 'db_error_skip' => true, |
|
| 131 | + ) |
|
| 132 | + ); |
|
| 133 | + } |
|
| 134 | + while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 135 | + $member_groups[trim($row[0])] = $row[1]; |
|
| 136 | + $smcFunc['db_free_result']($request); |
|
| 137 | + |
|
| 138 | + return $member_groups; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -146,197 +146,197 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | function makeFilesWritable(&$files) |
| 148 | 148 | { |
| 149 | - global $upcontext, $boarddir; |
|
| 150 | - |
|
| 151 | - if (empty($files)) |
|
| 152 | - return true; |
|
| 153 | - |
|
| 154 | - $failure = false; |
|
| 155 | - // On linux, it's easy - just use is_writable! |
|
| 156 | - if (substr(__FILE__, 1, 2) != ':\\') |
|
| 157 | - { |
|
| 158 | - $upcontext['systemos'] = 'linux'; |
|
| 159 | - |
|
| 160 | - foreach ($files as $k => $file) |
|
| 161 | - { |
|
| 162 | - if (!is_writable($file)) |
|
| 163 | - { |
|
| 164 | - @chmod($file, 0755); |
|
| 165 | - |
|
| 166 | - // Well, 755 hopefully worked... if not, try 777. |
|
| 167 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
| 168 | - $failure = true; |
|
| 169 | - // Otherwise remove it as it's good! |
|
| 170 | - else |
|
| 171 | - unset($files[$k]); |
|
| 172 | - } |
|
| 173 | - else |
|
| 174 | - unset($files[$k]); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - // Windows is trickier. Let's try opening for r+... |
|
| 178 | - else |
|
| 179 | - { |
|
| 180 | - $upcontext['systemos'] = 'windows'; |
|
| 181 | - |
|
| 182 | - foreach ($files as $k => $file) |
|
| 183 | - { |
|
| 184 | - // Folders can't be opened for write... but the index.php in them can ;). |
|
| 185 | - if (is_dir($file)) |
|
| 186 | - $file .= '/index.php'; |
|
| 187 | - |
|
| 188 | - // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
|
| 189 | - @chmod($file, 0777); |
|
| 190 | - $fp = @fopen($file, 'r+'); |
|
| 191 | - |
|
| 192 | - // Hmm, okay, try just for write in that case... |
|
| 193 | - if (!$fp) |
|
| 194 | - $fp = @fopen($file, 'w'); |
|
| 195 | - |
|
| 196 | - if (!$fp) |
|
| 197 | - $failure = true; |
|
| 198 | - else |
|
| 199 | - unset($files[$k]); |
|
| 200 | - @fclose($fp); |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - if (empty($files)) |
|
| 205 | - return true; |
|
| 206 | - |
|
| 207 | - if (!isset($_SERVER)) |
|
| 208 | - return !$failure; |
|
| 209 | - |
|
| 210 | - // What still needs to be done? |
|
| 211 | - $upcontext['chmod']['files'] = $files; |
|
| 212 | - |
|
| 213 | - // If it's windows it's a mess... |
|
| 214 | - if ($failure && substr(__FILE__, 1, 2) == ':\\') |
|
| 215 | - { |
|
| 216 | - $upcontext['chmod']['ftp_error'] = 'total_mess'; |
|
| 217 | - |
|
| 218 | - return false; |
|
| 219 | - } |
|
| 220 | - // We're going to have to use... FTP! |
|
| 221 | - elseif ($failure) |
|
| 222 | - { |
|
| 223 | - // Load any session data we might have... |
|
| 224 | - if (!isset($_POST['ftp_username']) && isset($_SESSION['installer_temp_ftp'])) |
|
| 225 | - { |
|
| 226 | - $upcontext['chmod']['server'] = $_SESSION['installer_temp_ftp']['server']; |
|
| 227 | - $upcontext['chmod']['port'] = $_SESSION['installer_temp_ftp']['port']; |
|
| 228 | - $upcontext['chmod']['username'] = $_SESSION['installer_temp_ftp']['username']; |
|
| 229 | - $upcontext['chmod']['password'] = $_SESSION['installer_temp_ftp']['password']; |
|
| 230 | - $upcontext['chmod']['path'] = $_SESSION['installer_temp_ftp']['path']; |
|
| 231 | - } |
|
| 232 | - // Or have we submitted? |
|
| 233 | - elseif (isset($_POST['ftp_username'])) |
|
| 234 | - { |
|
| 235 | - $upcontext['chmod']['server'] = $_POST['ftp_server']; |
|
| 236 | - $upcontext['chmod']['port'] = $_POST['ftp_port']; |
|
| 237 | - $upcontext['chmod']['username'] = $_POST['ftp_username']; |
|
| 238 | - $upcontext['chmod']['password'] = $_POST['ftp_password']; |
|
| 239 | - $upcontext['chmod']['path'] = $_POST['ftp_path']; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - if (isset($upcontext['chmod']['username'])) |
|
| 243 | - { |
|
| 244 | - $ftp = new ftp_connection($upcontext['chmod']['server'], $upcontext['chmod']['port'], $upcontext['chmod']['username'], $upcontext['chmod']['password']); |
|
| 245 | - |
|
| 246 | - if ($ftp->error === false) |
|
| 247 | - { |
|
| 248 | - // Try it without /home/abc just in case they messed up. |
|
| 249 | - if (!$ftp->chdir($upcontext['chmod']['path'])) |
|
| 250 | - { |
|
| 251 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message; |
|
| 252 | - $ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $upcontext['chmod']['path'])); |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - if (!isset($ftp) || $ftp->error !== false) |
|
| 258 | - { |
|
| 259 | - if (!isset($ftp)) |
|
| 260 | - $ftp = new ftp_connection(null); |
|
| 261 | - // Save the error so we can mess with listing... |
|
| 262 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
| 263 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 264 | - |
|
| 265 | - list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
|
| 266 | - |
|
| 267 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
| 268 | - $upcontext['chmod']['path'] = $detect_path; |
|
| 269 | - |
|
| 270 | - if (!isset($upcontext['chmod']['username'])) |
|
| 271 | - $upcontext['chmod']['username'] = $username; |
|
| 272 | - |
|
| 273 | - // Don't forget the login token. |
|
| 274 | - $upcontext += createToken('login'); |
|
| 275 | - |
|
| 276 | - return false; |
|
| 277 | - } |
|
| 278 | - else |
|
| 279 | - { |
|
| 280 | - // We want to do a relative path for FTP. |
|
| 281 | - if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
|
| 282 | - { |
|
| 283 | - $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
|
| 284 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
| 285 | - $ftp_root = substr($ftp_root, 0, -1); |
|
| 286 | - } |
|
| 287 | - else |
|
| 288 | - $ftp_root = $boarddir; |
|
| 289 | - |
|
| 290 | - // Save the info for next time! |
|
| 291 | - $_SESSION['installer_temp_ftp'] = array( |
|
| 292 | - 'server' => $upcontext['chmod']['server'], |
|
| 293 | - 'port' => $upcontext['chmod']['port'], |
|
| 294 | - 'username' => $upcontext['chmod']['username'], |
|
| 295 | - 'password' => $upcontext['chmod']['password'], |
|
| 296 | - 'path' => $upcontext['chmod']['path'], |
|
| 297 | - 'root' => $ftp_root, |
|
| 298 | - ); |
|
| 299 | - |
|
| 300 | - foreach ($files as $k => $file) |
|
| 301 | - { |
|
| 302 | - if (!is_writable($file)) |
|
| 303 | - $ftp->chmod($file, 0755); |
|
| 304 | - if (!is_writable($file)) |
|
| 305 | - $ftp->chmod($file, 0777); |
|
| 306 | - |
|
| 307 | - // Assuming that didn't work calculate the path without the boarddir. |
|
| 308 | - if (!is_writable($file)) |
|
| 309 | - { |
|
| 310 | - if (strpos($file, $boarddir) === 0) |
|
| 311 | - { |
|
| 312 | - $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
|
| 313 | - $ftp->chmod($ftp_file, 0755); |
|
| 314 | - if (!is_writable($file)) |
|
| 315 | - $ftp->chmod($ftp_file, 0777); |
|
| 316 | - // Sometimes an extra slash can help... |
|
| 317 | - $ftp_file = '/' . $ftp_file; |
|
| 318 | - if (!is_writable($file)) |
|
| 319 | - $ftp->chmod($ftp_file, 0755); |
|
| 320 | - if (!is_writable($file)) |
|
| 321 | - $ftp->chmod($ftp_file, 0777); |
|
| 322 | - } |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - if (is_writable($file)) |
|
| 326 | - unset($files[$k]); |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - $ftp->close(); |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - // What remains? |
|
| 334 | - $upcontext['chmod']['files'] = $files; |
|
| 335 | - |
|
| 336 | - if (empty($files)) |
|
| 337 | - return true; |
|
| 338 | - |
|
| 339 | - return false; |
|
| 149 | + global $upcontext, $boarddir; |
|
| 150 | + |
|
| 151 | + if (empty($files)) |
|
| 152 | + return true; |
|
| 153 | + |
|
| 154 | + $failure = false; |
|
| 155 | + // On linux, it's easy - just use is_writable! |
|
| 156 | + if (substr(__FILE__, 1, 2) != ':\\') |
|
| 157 | + { |
|
| 158 | + $upcontext['systemos'] = 'linux'; |
|
| 159 | + |
|
| 160 | + foreach ($files as $k => $file) |
|
| 161 | + { |
|
| 162 | + if (!is_writable($file)) |
|
| 163 | + { |
|
| 164 | + @chmod($file, 0755); |
|
| 165 | + |
|
| 166 | + // Well, 755 hopefully worked... if not, try 777. |
|
| 167 | + if (!is_writable($file) && !@chmod($file, 0777)) |
|
| 168 | + $failure = true; |
|
| 169 | + // Otherwise remove it as it's good! |
|
| 170 | + else |
|
| 171 | + unset($files[$k]); |
|
| 172 | + } |
|
| 173 | + else |
|
| 174 | + unset($files[$k]); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + // Windows is trickier. Let's try opening for r+... |
|
| 178 | + else |
|
| 179 | + { |
|
| 180 | + $upcontext['systemos'] = 'windows'; |
|
| 181 | + |
|
| 182 | + foreach ($files as $k => $file) |
|
| 183 | + { |
|
| 184 | + // Folders can't be opened for write... but the index.php in them can ;). |
|
| 185 | + if (is_dir($file)) |
|
| 186 | + $file .= '/index.php'; |
|
| 187 | + |
|
| 188 | + // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
|
| 189 | + @chmod($file, 0777); |
|
| 190 | + $fp = @fopen($file, 'r+'); |
|
| 191 | + |
|
| 192 | + // Hmm, okay, try just for write in that case... |
|
| 193 | + if (!$fp) |
|
| 194 | + $fp = @fopen($file, 'w'); |
|
| 195 | + |
|
| 196 | + if (!$fp) |
|
| 197 | + $failure = true; |
|
| 198 | + else |
|
| 199 | + unset($files[$k]); |
|
| 200 | + @fclose($fp); |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + if (empty($files)) |
|
| 205 | + return true; |
|
| 206 | + |
|
| 207 | + if (!isset($_SERVER)) |
|
| 208 | + return !$failure; |
|
| 209 | + |
|
| 210 | + // What still needs to be done? |
|
| 211 | + $upcontext['chmod']['files'] = $files; |
|
| 212 | + |
|
| 213 | + // If it's windows it's a mess... |
|
| 214 | + if ($failure && substr(__FILE__, 1, 2) == ':\\') |
|
| 215 | + { |
|
| 216 | + $upcontext['chmod']['ftp_error'] = 'total_mess'; |
|
| 217 | + |
|
| 218 | + return false; |
|
| 219 | + } |
|
| 220 | + // We're going to have to use... FTP! |
|
| 221 | + elseif ($failure) |
|
| 222 | + { |
|
| 223 | + // Load any session data we might have... |
|
| 224 | + if (!isset($_POST['ftp_username']) && isset($_SESSION['installer_temp_ftp'])) |
|
| 225 | + { |
|
| 226 | + $upcontext['chmod']['server'] = $_SESSION['installer_temp_ftp']['server']; |
|
| 227 | + $upcontext['chmod']['port'] = $_SESSION['installer_temp_ftp']['port']; |
|
| 228 | + $upcontext['chmod']['username'] = $_SESSION['installer_temp_ftp']['username']; |
|
| 229 | + $upcontext['chmod']['password'] = $_SESSION['installer_temp_ftp']['password']; |
|
| 230 | + $upcontext['chmod']['path'] = $_SESSION['installer_temp_ftp']['path']; |
|
| 231 | + } |
|
| 232 | + // Or have we submitted? |
|
| 233 | + elseif (isset($_POST['ftp_username'])) |
|
| 234 | + { |
|
| 235 | + $upcontext['chmod']['server'] = $_POST['ftp_server']; |
|
| 236 | + $upcontext['chmod']['port'] = $_POST['ftp_port']; |
|
| 237 | + $upcontext['chmod']['username'] = $_POST['ftp_username']; |
|
| 238 | + $upcontext['chmod']['password'] = $_POST['ftp_password']; |
|
| 239 | + $upcontext['chmod']['path'] = $_POST['ftp_path']; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + if (isset($upcontext['chmod']['username'])) |
|
| 243 | + { |
|
| 244 | + $ftp = new ftp_connection($upcontext['chmod']['server'], $upcontext['chmod']['port'], $upcontext['chmod']['username'], $upcontext['chmod']['password']); |
|
| 245 | + |
|
| 246 | + if ($ftp->error === false) |
|
| 247 | + { |
|
| 248 | + // Try it without /home/abc just in case they messed up. |
|
| 249 | + if (!$ftp->chdir($upcontext['chmod']['path'])) |
|
| 250 | + { |
|
| 251 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message; |
|
| 252 | + $ftp->chdir(preg_replace('~^/home[2]?/[^/]+?~', '', $upcontext['chmod']['path'])); |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + if (!isset($ftp) || $ftp->error !== false) |
|
| 258 | + { |
|
| 259 | + if (!isset($ftp)) |
|
| 260 | + $ftp = new ftp_connection(null); |
|
| 261 | + // Save the error so we can mess with listing... |
|
| 262 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
| 263 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 264 | + |
|
| 265 | + list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
|
| 266 | + |
|
| 267 | + if ($found_path || !isset($upcontext['chmod']['path'])) |
|
| 268 | + $upcontext['chmod']['path'] = $detect_path; |
|
| 269 | + |
|
| 270 | + if (!isset($upcontext['chmod']['username'])) |
|
| 271 | + $upcontext['chmod']['username'] = $username; |
|
| 272 | + |
|
| 273 | + // Don't forget the login token. |
|
| 274 | + $upcontext += createToken('login'); |
|
| 275 | + |
|
| 276 | + return false; |
|
| 277 | + } |
|
| 278 | + else |
|
| 279 | + { |
|
| 280 | + // We want to do a relative path for FTP. |
|
| 281 | + if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
|
| 282 | + { |
|
| 283 | + $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
|
| 284 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
| 285 | + $ftp_root = substr($ftp_root, 0, -1); |
|
| 286 | + } |
|
| 287 | + else |
|
| 288 | + $ftp_root = $boarddir; |
|
| 289 | + |
|
| 290 | + // Save the info for next time! |
|
| 291 | + $_SESSION['installer_temp_ftp'] = array( |
|
| 292 | + 'server' => $upcontext['chmod']['server'], |
|
| 293 | + 'port' => $upcontext['chmod']['port'], |
|
| 294 | + 'username' => $upcontext['chmod']['username'], |
|
| 295 | + 'password' => $upcontext['chmod']['password'], |
|
| 296 | + 'path' => $upcontext['chmod']['path'], |
|
| 297 | + 'root' => $ftp_root, |
|
| 298 | + ); |
|
| 299 | + |
|
| 300 | + foreach ($files as $k => $file) |
|
| 301 | + { |
|
| 302 | + if (!is_writable($file)) |
|
| 303 | + $ftp->chmod($file, 0755); |
|
| 304 | + if (!is_writable($file)) |
|
| 305 | + $ftp->chmod($file, 0777); |
|
| 306 | + |
|
| 307 | + // Assuming that didn't work calculate the path without the boarddir. |
|
| 308 | + if (!is_writable($file)) |
|
| 309 | + { |
|
| 310 | + if (strpos($file, $boarddir) === 0) |
|
| 311 | + { |
|
| 312 | + $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
|
| 313 | + $ftp->chmod($ftp_file, 0755); |
|
| 314 | + if (!is_writable($file)) |
|
| 315 | + $ftp->chmod($ftp_file, 0777); |
|
| 316 | + // Sometimes an extra slash can help... |
|
| 317 | + $ftp_file = '/' . $ftp_file; |
|
| 318 | + if (!is_writable($file)) |
|
| 319 | + $ftp->chmod($ftp_file, 0755); |
|
| 320 | + if (!is_writable($file)) |
|
| 321 | + $ftp->chmod($ftp_file, 0777); |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + if (is_writable($file)) |
|
| 326 | + unset($files[$k]); |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + $ftp->close(); |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + // What remains? |
|
| 334 | + $upcontext['chmod']['files'] = $files; |
|
| 335 | + |
|
| 336 | + if (empty($files)) |
|
| 337 | + return true; |
|
| 338 | + |
|
| 339 | + return false; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /** |
@@ -347,24 +347,24 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | function quickFileWritable($file) |
| 349 | 349 | { |
| 350 | - if (is_writable($file)) |
|
| 351 | - return true; |
|
| 350 | + if (is_writable($file)) |
|
| 351 | + return true; |
|
| 352 | 352 | |
| 353 | - @chmod($file, 0755); |
|
| 353 | + @chmod($file, 0755); |
|
| 354 | 354 | |
| 355 | - // Try 755 and 775 first since 777 doesn't always work and could be a risk... |
|
| 356 | - $chmod_values = array(0755, 0775, 0777); |
|
| 355 | + // Try 755 and 775 first since 777 doesn't always work and could be a risk... |
|
| 356 | + $chmod_values = array(0755, 0775, 0777); |
|
| 357 | 357 | |
| 358 | - foreach ($chmod_values as $val) |
|
| 359 | - { |
|
| 360 | - // If it's writable, break out of the loop |
|
| 361 | - if (is_writable($file)) |
|
| 362 | - break; |
|
| 363 | - else |
|
| 364 | - @chmod($file, $val); |
|
| 365 | - } |
|
| 358 | + foreach ($chmod_values as $val) |
|
| 359 | + { |
|
| 360 | + // If it's writable, break out of the loop |
|
| 361 | + if (is_writable($file)) |
|
| 362 | + break; |
|
| 363 | + else |
|
| 364 | + @chmod($file, $val); |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | - return is_writable($file); |
|
| 367 | + return is_writable($file); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | function smf_strtolower($string) |
| 377 | 377 | { |
| 378 | - return mb_strtolower($string, 'UTF-8'); |
|
| 378 | + return mb_strtolower($string, 'UTF-8'); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -386,15 +386,15 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | function print_error($message, $fatal = false) |
| 388 | 388 | { |
| 389 | - static $fp = null; |
|
| 389 | + static $fp = null; |
|
| 390 | 390 | |
| 391 | - if ($fp === null) |
|
| 392 | - $fp = fopen('php://stderr', 'wb'); |
|
| 391 | + if ($fp === null) |
|
| 392 | + $fp = fopen('php://stderr', 'wb'); |
|
| 393 | 393 | |
| 394 | - fwrite($fp, $message . "\n"); |
|
| 394 | + fwrite($fp, $message . "\n"); |
|
| 395 | 395 | |
| 396 | - if ($fatal) |
|
| 397 | - exit; |
|
| 396 | + if ($fatal) |
|
| 397 | + exit; |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -405,12 +405,12 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | function throw_error($message) |
| 407 | 407 | { |
| 408 | - global $upcontext; |
|
| 408 | + global $upcontext; |
|
| 409 | 409 | |
| 410 | - $upcontext['error_msg'] = $message; |
|
| 411 | - $upcontext['sub_template'] = 'error_message'; |
|
| 410 | + $upcontext['error_msg'] = $message; |
|
| 411 | + $upcontext['sub_template'] = 'error_message'; |
|
| 412 | 412 | |
| 413 | - return false; |
|
| 413 | + return false; |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | function smf_mysql_fetch_assoc($rs) |
| 424 | 424 | { |
| 425 | - return mysqli_fetch_assoc($rs); |
|
| 425 | + return mysqli_fetch_assoc($rs); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | /** |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | */ |
| 432 | 432 | function smf_mysql_fetch_row($rs) |
| 433 | 433 | { |
| 434 | - return mysqli_fetch_row($rs); |
|
| 434 | + return mysqli_fetch_row($rs); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | */ |
| 440 | 440 | function smf_mysql_free_result($rs) |
| 441 | 441 | { |
| 442 | - mysqli_free_result($rs); |
|
| 442 | + mysqli_free_result($rs); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | */ |
| 449 | 449 | function smf_mysql_insert_id($rs) |
| 450 | 450 | { |
| 451 | - return mysqli_insert_id($rs); |
|
| 451 | + return mysqli_insert_id($rs); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | */ |
| 458 | 458 | function smf_mysql_num_rows($rs) |
| 459 | 459 | { |
| 460 | - return mysqli_num_rows($rs); |
|
| 460 | + return mysqli_num_rows($rs); |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | /** |
@@ -465,6 +465,6 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | function smf_mysql_real_escape_string($string) |
| 467 | 467 | { |
| 468 | - global $db_connection; |
|
| 469 | - mysqli_real_escape_string($db_connection, $string); |
|
| 468 | + global $db_connection; |
|
| 469 | + mysqli_real_escape_string($db_connection, $string); |
|
| 470 | 470 | } |
| 471 | 471 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * This file contains helper functions for upgrade.php |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF_VERSION')) |
|
| 16 | +if (!defined('SMF_VERSION')) { |
|
| 17 | 17 | die('No direct access!'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | if (!function_exists('un_htmlspecialchars')) |
| 20 | 21 | { |
@@ -53,8 +54,9 @@ discard block |
||
| 53 | 54 | { |
| 54 | 55 | $word = trim($word, '-_\''); |
| 55 | 56 | |
| 56 | - if ($word != '') |
|
| 57 | - $returned_words[] = substr($word, 0, 20); |
|
| 57 | + if ($word != '') { |
|
| 58 | + $returned_words[] = substr($word, 0, 20); |
|
| 59 | + } |
|
| 58 | 60 | } |
| 59 | 61 | |
| 60 | 62 | return array_unique($returned_words); |
@@ -105,8 +107,9 @@ discard block |
||
| 105 | 107 | global $smcFunc; |
| 106 | 108 | static $member_groups = array(); |
| 107 | 109 | |
| 108 | - if (!empty($member_groups)) |
|
| 109 | - return $member_groups; |
|
| 110 | + if (!empty($member_groups)) { |
|
| 111 | + return $member_groups; |
|
| 112 | + } |
|
| 110 | 113 | |
| 111 | 114 | $request = $smcFunc['db_query']('', ' |
| 112 | 115 | SELECT group_name, id_group |
@@ -131,8 +134,9 @@ discard block |
||
| 131 | 134 | ) |
| 132 | 135 | ); |
| 133 | 136 | } |
| 134 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 135 | - $member_groups[trim($row[0])] = $row[1]; |
|
| 137 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 138 | + $member_groups[trim($row[0])] = $row[1]; |
|
| 139 | + } |
|
| 136 | 140 | $smcFunc['db_free_result']($request); |
| 137 | 141 | |
| 138 | 142 | return $member_groups; |
@@ -148,8 +152,9 @@ discard block |
||
| 148 | 152 | { |
| 149 | 153 | global $upcontext, $boarddir; |
| 150 | 154 | |
| 151 | - if (empty($files)) |
|
| 152 | - return true; |
|
| 155 | + if (empty($files)) { |
|
| 156 | + return true; |
|
| 157 | + } |
|
| 153 | 158 | |
| 154 | 159 | $failure = false; |
| 155 | 160 | // On linux, it's easy - just use is_writable! |
@@ -164,14 +169,16 @@ discard block |
||
| 164 | 169 | @chmod($file, 0755); |
| 165 | 170 | |
| 166 | 171 | // Well, 755 hopefully worked... if not, try 777. |
| 167 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
| 168 | - $failure = true; |
|
| 172 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
| 173 | + $failure = true; |
|
| 174 | + } |
|
| 169 | 175 | // Otherwise remove it as it's good! |
| 170 | - else |
|
| 171 | - unset($files[$k]); |
|
| 176 | + else { |
|
| 177 | + unset($files[$k]); |
|
| 178 | + } |
|
| 179 | + } else { |
|
| 180 | + unset($files[$k]); |
|
| 172 | 181 | } |
| 173 | - else |
|
| 174 | - unset($files[$k]); |
|
| 175 | 182 | } |
| 176 | 183 | } |
| 177 | 184 | // Windows is trickier. Let's try opening for r+... |
@@ -182,30 +189,35 @@ discard block |
||
| 182 | 189 | foreach ($files as $k => $file) |
| 183 | 190 | { |
| 184 | 191 | // Folders can't be opened for write... but the index.php in them can ;). |
| 185 | - if (is_dir($file)) |
|
| 186 | - $file .= '/index.php'; |
|
| 192 | + if (is_dir($file)) { |
|
| 193 | + $file .= '/index.php'; |
|
| 194 | + } |
|
| 187 | 195 | |
| 188 | 196 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 189 | 197 | @chmod($file, 0777); |
| 190 | 198 | $fp = @fopen($file, 'r+'); |
| 191 | 199 | |
| 192 | 200 | // Hmm, okay, try just for write in that case... |
| 193 | - if (!$fp) |
|
| 194 | - $fp = @fopen($file, 'w'); |
|
| 201 | + if (!$fp) { |
|
| 202 | + $fp = @fopen($file, 'w'); |
|
| 203 | + } |
|
| 195 | 204 | |
| 196 | - if (!$fp) |
|
| 197 | - $failure = true; |
|
| 198 | - else |
|
| 199 | - unset($files[$k]); |
|
| 205 | + if (!$fp) { |
|
| 206 | + $failure = true; |
|
| 207 | + } else { |
|
| 208 | + unset($files[$k]); |
|
| 209 | + } |
|
| 200 | 210 | @fclose($fp); |
| 201 | 211 | } |
| 202 | 212 | } |
| 203 | 213 | |
| 204 | - if (empty($files)) |
|
| 205 | - return true; |
|
| 214 | + if (empty($files)) { |
|
| 215 | + return true; |
|
| 216 | + } |
|
| 206 | 217 | |
| 207 | - if (!isset($_SERVER)) |
|
| 208 | - return !$failure; |
|
| 218 | + if (!isset($_SERVER)) { |
|
| 219 | + return !$failure; |
|
| 220 | + } |
|
| 209 | 221 | |
| 210 | 222 | // What still needs to be done? |
| 211 | 223 | $upcontext['chmod']['files'] = $files; |
@@ -256,36 +268,40 @@ discard block |
||
| 256 | 268 | |
| 257 | 269 | if (!isset($ftp) || $ftp->error !== false) |
| 258 | 270 | { |
| 259 | - if (!isset($ftp)) |
|
| 260 | - $ftp = new ftp_connection(null); |
|
| 271 | + if (!isset($ftp)) { |
|
| 272 | + $ftp = new ftp_connection(null); |
|
| 273 | + } |
|
| 261 | 274 | // Save the error so we can mess with listing... |
| 262 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
| 263 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 275 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
| 276 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
| 277 | + } |
|
| 264 | 278 | |
| 265 | 279 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 266 | 280 | |
| 267 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
| 268 | - $upcontext['chmod']['path'] = $detect_path; |
|
| 281 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
| 282 | + $upcontext['chmod']['path'] = $detect_path; |
|
| 283 | + } |
|
| 269 | 284 | |
| 270 | - if (!isset($upcontext['chmod']['username'])) |
|
| 271 | - $upcontext['chmod']['username'] = $username; |
|
| 285 | + if (!isset($upcontext['chmod']['username'])) { |
|
| 286 | + $upcontext['chmod']['username'] = $username; |
|
| 287 | + } |
|
| 272 | 288 | |
| 273 | 289 | // Don't forget the login token. |
| 274 | 290 | $upcontext += createToken('login'); |
| 275 | 291 | |
| 276 | 292 | return false; |
| 277 | - } |
|
| 278 | - else |
|
| 293 | + } else |
|
| 279 | 294 | { |
| 280 | 295 | // We want to do a relative path for FTP. |
| 281 | 296 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
| 282 | 297 | { |
| 283 | 298 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
| 284 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
| 285 | - $ftp_root = substr($ftp_root, 0, -1); |
|
| 299 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
| 300 | + $ftp_root = substr($ftp_root, 0, -1); |
|
| 301 | + } |
|
| 302 | + } else { |
|
| 303 | + $ftp_root = $boarddir; |
|
| 286 | 304 | } |
| 287 | - else |
|
| 288 | - $ftp_root = $boarddir; |
|
| 289 | 305 | |
| 290 | 306 | // Save the info for next time! |
| 291 | 307 | $_SESSION['installer_temp_ftp'] = array( |
@@ -299,10 +315,12 @@ discard block |
||
| 299 | 315 | |
| 300 | 316 | foreach ($files as $k => $file) |
| 301 | 317 | { |
| 302 | - if (!is_writable($file)) |
|
| 303 | - $ftp->chmod($file, 0755); |
|
| 304 | - if (!is_writable($file)) |
|
| 305 | - $ftp->chmod($file, 0777); |
|
| 318 | + if (!is_writable($file)) { |
|
| 319 | + $ftp->chmod($file, 0755); |
|
| 320 | + } |
|
| 321 | + if (!is_writable($file)) { |
|
| 322 | + $ftp->chmod($file, 0777); |
|
| 323 | + } |
|
| 306 | 324 | |
| 307 | 325 | // Assuming that didn't work calculate the path without the boarddir. |
| 308 | 326 | if (!is_writable($file)) |
@@ -311,19 +329,23 @@ discard block |
||
| 311 | 329 | { |
| 312 | 330 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
| 313 | 331 | $ftp->chmod($ftp_file, 0755); |
| 314 | - if (!is_writable($file)) |
|
| 315 | - $ftp->chmod($ftp_file, 0777); |
|
| 332 | + if (!is_writable($file)) { |
|
| 333 | + $ftp->chmod($ftp_file, 0777); |
|
| 334 | + } |
|
| 316 | 335 | // Sometimes an extra slash can help... |
| 317 | 336 | $ftp_file = '/' . $ftp_file; |
| 318 | - if (!is_writable($file)) |
|
| 319 | - $ftp->chmod($ftp_file, 0755); |
|
| 320 | - if (!is_writable($file)) |
|
| 321 | - $ftp->chmod($ftp_file, 0777); |
|
| 337 | + if (!is_writable($file)) { |
|
| 338 | + $ftp->chmod($ftp_file, 0755); |
|
| 339 | + } |
|
| 340 | + if (!is_writable($file)) { |
|
| 341 | + $ftp->chmod($ftp_file, 0777); |
|
| 342 | + } |
|
| 322 | 343 | } |
| 323 | 344 | } |
| 324 | 345 | |
| 325 | - if (is_writable($file)) |
|
| 326 | - unset($files[$k]); |
|
| 346 | + if (is_writable($file)) { |
|
| 347 | + unset($files[$k]); |
|
| 348 | + } |
|
| 327 | 349 | } |
| 328 | 350 | |
| 329 | 351 | $ftp->close(); |
@@ -333,8 +355,9 @@ discard block |
||
| 333 | 355 | // What remains? |
| 334 | 356 | $upcontext['chmod']['files'] = $files; |
| 335 | 357 | |
| 336 | - if (empty($files)) |
|
| 337 | - return true; |
|
| 358 | + if (empty($files)) { |
|
| 359 | + return true; |
|
| 360 | + } |
|
| 338 | 361 | |
| 339 | 362 | return false; |
| 340 | 363 | } |
@@ -347,8 +370,9 @@ discard block |
||
| 347 | 370 | */ |
| 348 | 371 | function quickFileWritable($file) |
| 349 | 372 | { |
| 350 | - if (is_writable($file)) |
|
| 351 | - return true; |
|
| 373 | + if (is_writable($file)) { |
|
| 374 | + return true; |
|
| 375 | + } |
|
| 352 | 376 | |
| 353 | 377 | @chmod($file, 0755); |
| 354 | 378 | |
@@ -358,10 +382,11 @@ discard block |
||
| 358 | 382 | foreach ($chmod_values as $val) |
| 359 | 383 | { |
| 360 | 384 | // If it's writable, break out of the loop |
| 361 | - if (is_writable($file)) |
|
| 362 | - break; |
|
| 363 | - else |
|
| 364 | - @chmod($file, $val); |
|
| 385 | + if (is_writable($file)) { |
|
| 386 | + break; |
|
| 387 | + } else { |
|
| 388 | + @chmod($file, $val); |
|
| 389 | + } |
|
| 365 | 390 | } |
| 366 | 391 | |
| 367 | 392 | return is_writable($file); |
@@ -388,14 +413,16 @@ discard block |
||
| 388 | 413 | { |
| 389 | 414 | static $fp = null; |
| 390 | 415 | |
| 391 | - if ($fp === null) |
|
| 392 | - $fp = fopen('php://stderr', 'wb'); |
|
| 416 | + if ($fp === null) { |
|
| 417 | + $fp = fopen('php://stderr', 'wb'); |
|
| 418 | + } |
|
| 393 | 419 | |
| 394 | 420 | fwrite($fp, $message . "\n"); |
| 395 | 421 | |
| 396 | - if ($fatal) |
|
| 397 | - exit; |
|
| 398 | -} |
|
| 422 | + if ($fatal) { |
|
| 423 | + exit; |
|
| 424 | + } |
|
| 425 | + } |
|
| 399 | 426 | |
| 400 | 427 | /** |
| 401 | 428 | * Throws a graphical error message. |