@@ -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 | * Main dispatcher, the maintenance access point. |
@@ -96,14 +97,16 @@ discard block |
||
96 | 97 | call_integration_hook('integrate_manage_maintenance', array(&$subActions)); |
97 | 98 | |
98 | 99 | // Yep, sub-action time! |
99 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
100 | - $subAction = $_REQUEST['sa']; |
|
101 | - else |
|
102 | - $subAction = 'routine'; |
|
100 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
101 | + $subAction = $_REQUEST['sa']; |
|
102 | + } else { |
|
103 | + $subAction = 'routine'; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | // Doing something special? |
105 | - if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) |
|
106 | - $activity = $_REQUEST['activity']; |
|
107 | + if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) { |
|
108 | + $activity = $_REQUEST['activity']; |
|
109 | + } |
|
107 | 110 | |
108 | 111 | // Set a few things. |
109 | 112 | $context['page_title'] = $txt['maintain_title']; |
@@ -114,12 +117,14 @@ discard block |
||
114 | 117 | call_helper($subActions[$subAction]['function']); |
115 | 118 | |
116 | 119 | // Any special activity? |
117 | - if (isset($activity)) |
|
118 | - call_helper($subActions[$subAction]['activities'][$activity]); |
|
120 | + if (isset($activity)) { |
|
121 | + call_helper($subActions[$subAction]['activities'][$activity]); |
|
122 | + } |
|
119 | 123 | |
120 | 124 | //converted to UTF-8? show a small maintenance info |
121 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
122 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
125 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
126 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
127 | + } |
|
123 | 128 | |
124 | 129 | // Create a maintenance token. Kinda hard to do it any other way. |
125 | 130 | createToken('admin-maint'); |
@@ -141,19 +146,22 @@ discard block |
||
141 | 146 | db_extend('packages'); |
142 | 147 | |
143 | 148 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
144 | - foreach ($colData as $column) |
|
145 | - if ($column['name'] == 'body') |
|
149 | + foreach ($colData as $column) { |
|
150 | + if ($column['name'] == 'body') |
|
146 | 151 | $body_type = $column['type']; |
152 | + } |
|
147 | 153 | |
148 | 154 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
149 | 155 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
150 | 156 | } |
151 | 157 | |
152 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
153 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
154 | - if (isset($_GET['done']) && $_GET['done'] == 'convertentities') |
|
155 | - $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
156 | -} |
|
158 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
159 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
160 | + } |
|
161 | + if (isset($_GET['done']) && $_GET['done'] == 'convertentities') { |
|
162 | + $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
163 | + } |
|
164 | + } |
|
157 | 165 | |
158 | 166 | /** |
159 | 167 | * Supporting function for the routine maintenance area. |
@@ -162,9 +170,10 @@ discard block |
||
162 | 170 | { |
163 | 171 | global $context, $txt; |
164 | 172 | |
165 | - if (isset($_GET['done']) && $_GET['done'] == 'recount') |
|
166 | - $context['maintenance_finished'] = $txt['maintain_recount']; |
|
167 | -} |
|
173 | + if (isset($_GET['done']) && $_GET['done'] == 'recount') { |
|
174 | + $context['maintenance_finished'] = $txt['maintain_recount']; |
|
175 | + } |
|
176 | + } |
|
168 | 177 | |
169 | 178 | /** |
170 | 179 | * Supporting function for the members maintenance area. |
@@ -195,8 +204,9 @@ discard block |
||
195 | 204 | } |
196 | 205 | $smcFunc['db_free_result']($result); |
197 | 206 | |
198 | - if (isset($_GET['done']) && $_GET['done'] == 'recountposts') |
|
199 | - $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
207 | + if (isset($_GET['done']) && $_GET['done'] == 'recountposts') { |
|
208 | + $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
209 | + } |
|
200 | 210 | |
201 | 211 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
202 | 212 | } |
@@ -222,11 +232,12 @@ discard block |
||
222 | 232 | $context['categories'] = array(); |
223 | 233 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
224 | 234 | { |
225 | - if (!isset($context['categories'][$row['id_cat']])) |
|
226 | - $context['categories'][$row['id_cat']] = array( |
|
235 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
236 | + $context['categories'][$row['id_cat']] = array( |
|
227 | 237 | 'name' => $row['cat_name'], |
228 | 238 | 'boards' => array() |
229 | 239 | ); |
240 | + } |
|
230 | 241 | |
231 | 242 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
232 | 243 | 'id' => $row['id_board'], |
@@ -239,11 +250,12 @@ discard block |
||
239 | 250 | require_once($sourcedir . '/Subs-Boards.php'); |
240 | 251 | sortCategories($context['categories']); |
241 | 252 | |
242 | - if (isset($_GET['done']) && $_GET['done'] == 'purgeold') |
|
243 | - $context['maintenance_finished'] = $txt['maintain_old']; |
|
244 | - elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') |
|
245 | - $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
246 | -} |
|
253 | + if (isset($_GET['done']) && $_GET['done'] == 'purgeold') { |
|
254 | + $context['maintenance_finished'] = $txt['maintain_old']; |
|
255 | + } elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') { |
|
256 | + $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
257 | + } |
|
258 | + } |
|
247 | 259 | |
248 | 260 | /** |
249 | 261 | * Find and fix all errors on the forum. |
@@ -351,15 +363,17 @@ discard block |
||
351 | 363 | // Show me your badge! |
352 | 364 | isAllowedTo('admin_forum'); |
353 | 365 | |
354 | - if ($db_type != 'mysql') |
|
355 | - return; |
|
366 | + if ($db_type != 'mysql') { |
|
367 | + return; |
|
368 | + } |
|
356 | 369 | |
357 | 370 | db_extend('packages'); |
358 | 371 | |
359 | 372 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
360 | - foreach ($colData as $column) |
|
361 | - if ($column['name'] == 'body') |
|
373 | + foreach ($colData as $column) { |
|
374 | + if ($column['name'] == 'body') |
|
362 | 375 | $body_type = $column['type']; |
376 | + } |
|
363 | 377 | |
364 | 378 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
365 | 379 | |
@@ -369,33 +383,36 @@ discard block |
||
369 | 383 | validateToken('admin-maint'); |
370 | 384 | |
371 | 385 | // Make it longer so we can do their limit. |
372 | - if ($body_type == 'text') |
|
373 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
386 | + if ($body_type == 'text') { |
|
387 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
388 | + } |
|
374 | 389 | // Shorten the column so we can have a bit (literally per record) less space occupied |
375 | - else |
|
376 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
390 | + else { |
|
391 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
392 | + } |
|
377 | 393 | |
378 | 394 | // 3rd party integrations may be interested in knowning about this. |
379 | 395 | call_integration_hook('integrate_convert_msgbody', array($body_type)); |
380 | 396 | |
381 | 397 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
382 | - foreach ($colData as $column) |
|
383 | - if ($column['name'] == 'body') |
|
398 | + foreach ($colData as $column) { |
|
399 | + if ($column['name'] == 'body') |
|
384 | 400 | $body_type = $column['type']; |
401 | + } |
|
385 | 402 | |
386 | 403 | $context['maintenance_finished'] = $txt[$context['convert_to'] . '_title']; |
387 | 404 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
388 | 405 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
389 | 406 | |
390 | 407 | return; |
391 | - } |
|
392 | - elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
408 | + } elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
393 | 409 | { |
394 | 410 | checkSession(); |
395 | - if (empty($_REQUEST['start'])) |
|
396 | - validateToken('admin-maint'); |
|
397 | - else |
|
398 | - validateToken('admin-convertMsg'); |
|
411 | + if (empty($_REQUEST['start'])) { |
|
412 | + validateToken('admin-maint'); |
|
413 | + } else { |
|
414 | + validateToken('admin-convertMsg'); |
|
415 | + } |
|
399 | 416 | |
400 | 417 | $context['page_title'] = $txt['not_done_title']; |
401 | 418 | $context['continue_post_data'] = ''; |
@@ -427,8 +444,9 @@ discard block |
||
427 | 444 | 'increment' => $increment - 1, |
428 | 445 | ) |
429 | 446 | ); |
430 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
431 | - $id_msg_exceeding[] = $row['id_msg']; |
|
447 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
448 | + $id_msg_exceeding[] = $row['id_msg']; |
|
449 | + } |
|
432 | 450 | $smcFunc['db_free_result']($request); |
433 | 451 | |
434 | 452 | $_REQUEST['start'] += $increment; |
@@ -457,9 +475,9 @@ discard block |
||
457 | 475 | { |
458 | 476 | $query_msg = array_slice($id_msg_exceeding, 0, 100); |
459 | 477 | $context['exceeding_messages_morethan'] = sprintf($txt['exceeding_messages_morethan'], count($id_msg_exceeding)); |
478 | + } else { |
|
479 | + $query_msg = $id_msg_exceeding; |
|
460 | 480 | } |
461 | - else |
|
462 | - $query_msg = $id_msg_exceeding; |
|
463 | 481 | |
464 | 482 | $context['exceeding_messages'] = array(); |
465 | 483 | $request = $smcFunc['db_query']('', ' |
@@ -470,8 +488,9 @@ discard block |
||
470 | 488 | 'messages' => $query_msg, |
471 | 489 | ) |
472 | 490 | ); |
473 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
474 | - $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
491 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
492 | + $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
493 | + } |
|
475 | 494 | $smcFunc['db_free_result']($request); |
476 | 495 | } |
477 | 496 | } |
@@ -495,8 +514,9 @@ discard block |
||
495 | 514 | isAllowedTo('admin_forum'); |
496 | 515 | |
497 | 516 | // Check to see if UTF-8 is currently the default character set. |
498 | - if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') |
|
499 | - fatal_lang_error('entity_convert_only_utf8'); |
|
517 | + if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') { |
|
518 | + fatal_lang_error('entity_convert_only_utf8'); |
|
519 | + } |
|
500 | 520 | |
501 | 521 | // Some starting values. |
502 | 522 | $context['table'] = empty($_REQUEST['table']) ? 0 : (int) $_REQUEST['table']; |
@@ -558,8 +578,9 @@ discard block |
||
558 | 578 | // Make sure we keep stuff unique! |
559 | 579 | $primary_keys = array(); |
560 | 580 | |
561 | - if (function_exists('apache_reset_timeout')) |
|
562 | - @apache_reset_timeout(); |
|
581 | + if (function_exists('apache_reset_timeout')) { |
|
582 | + @apache_reset_timeout(); |
|
583 | + } |
|
563 | 584 | |
564 | 585 | // Get a list of text columns. |
565 | 586 | $columns = array(); |
@@ -570,9 +591,10 @@ discard block |
||
570 | 591 | 'cur_table' => $cur_table, |
571 | 592 | ) |
572 | 593 | ); |
573 | - while ($column_info = $smcFunc['db_fetch_assoc']($request)) |
|
574 | - if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
594 | + while ($column_info = $smcFunc['db_fetch_assoc']($request)) { |
|
595 | + if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
575 | 596 | $columns[] = strtolower($column_info['Field']); |
597 | + } |
|
576 | 598 | |
577 | 599 | // Get the column with the (first) primary key. |
578 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -586,8 +608,9 @@ discard block |
||
586 | 608 | { |
587 | 609 | if ($row['Key_name'] === 'PRIMARY') |
588 | 610 | { |
589 | - if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) |
|
590 | - $primary_key = $row['Column_name']; |
|
611 | + if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) { |
|
612 | + $primary_key = $row['Column_name']; |
|
613 | + } |
|
591 | 614 | |
592 | 615 | $primary_keys[] = $row['Column_name']; |
593 | 616 | } |
@@ -596,8 +619,9 @@ discard block |
||
596 | 619 | |
597 | 620 | // No primary key, no glory. |
598 | 621 | // Same for columns. Just to be sure we've work to do! |
599 | - if (empty($primary_key) || empty($columns)) |
|
600 | - continue; |
|
622 | + if (empty($primary_key) || empty($columns)) { |
|
623 | + continue; |
|
624 | + } |
|
601 | 625 | |
602 | 626 | // Get the maximum value for the primary key. |
603 | 627 | $request = $smcFunc['db_query']('', ' |
@@ -611,8 +635,9 @@ discard block |
||
611 | 635 | list($max_value) = $smcFunc['db_fetch_row']($request); |
612 | 636 | $smcFunc['db_free_result']($request); |
613 | 637 | |
614 | - if (empty($max_value)) |
|
615 | - continue; |
|
638 | + if (empty($max_value)) { |
|
639 | + continue; |
|
640 | + } |
|
616 | 641 | |
617 | 642 | while ($context['start'] <= $max_value) |
618 | 643 | { |
@@ -636,10 +661,11 @@ discard block |
||
636 | 661 | { |
637 | 662 | $insertion_variables = array(); |
638 | 663 | $changes = array(); |
639 | - foreach ($row as $column_name => $column_value) |
|
640 | - if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
664 | + foreach ($row as $column_name => $column_value) { |
|
665 | + if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
641 | 666 | { |
642 | 667 | $changes[] = $column_name . ' = {string:changes_' . $column_name . '}'; |
668 | + } |
|
643 | 669 | $insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~', 'fixchar__callback', $column_value); |
644 | 670 | } |
645 | 671 | |
@@ -651,8 +677,8 @@ discard block |
||
651 | 677 | } |
652 | 678 | |
653 | 679 | // Update the row. |
654 | - if (!empty($changes)) |
|
655 | - $smcFunc['db_query']('', ' |
|
680 | + if (!empty($changes)) { |
|
681 | + $smcFunc['db_query']('', ' |
|
656 | 682 | UPDATE {db_prefix}' . $cur_table . ' |
657 | 683 | SET |
658 | 684 | ' . implode(', |
@@ -660,6 +686,7 @@ discard block |
||
660 | 686 | WHERE ' . implode(' AND ', $where), |
661 | 687 | $insertion_variables |
662 | 688 | ); |
689 | + } |
|
663 | 690 | } |
664 | 691 | $smcFunc['db_free_result']($request); |
665 | 692 | $context['start'] += 500; |
@@ -704,10 +731,11 @@ discard block |
||
704 | 731 | |
705 | 732 | checkSession('request'); |
706 | 733 | |
707 | - if (!isset($_SESSION['optimized_tables'])) |
|
708 | - validateToken('admin-maint'); |
|
709 | - else |
|
710 | - validateToken('admin-optimize', 'post', false); |
|
734 | + if (!isset($_SESSION['optimized_tables'])) { |
|
735 | + validateToken('admin-maint'); |
|
736 | + } else { |
|
737 | + validateToken('admin-optimize', 'post', false); |
|
738 | + } |
|
711 | 739 | |
712 | 740 | ignore_user_abort(true); |
713 | 741 | db_extend(); |
@@ -723,13 +751,15 @@ discard block |
||
723 | 751 | // Get a list of tables, as well as how many there are. |
724 | 752 | $temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%'); |
725 | 753 | $tables = array(); |
726 | - foreach ($temp_tables as $table) |
|
727 | - $tables[] = array('table_name' => $table); |
|
754 | + foreach ($temp_tables as $table) { |
|
755 | + $tables[] = array('table_name' => $table); |
|
756 | + } |
|
728 | 757 | |
729 | 758 | // If there aren't any tables then I believe that would mean the world has exploded... |
730 | 759 | $context['num_tables'] = count($tables); |
731 | - if ($context['num_tables'] == 0) |
|
732 | - fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
760 | + if ($context['num_tables'] == 0) { |
|
761 | + fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
762 | + } |
|
733 | 763 | |
734 | 764 | $_REQUEST['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
735 | 765 | |
@@ -740,8 +770,9 @@ discard block |
||
740 | 770 | $_SESSION['optimized_tables'] = !empty($_SESSION['optimized_tables']) ? $_SESSION['optimized_tables'] : array(); |
741 | 771 | for ($key = $_REQUEST['start']; $context['num_tables'] - 1; $key++) |
742 | 772 | { |
743 | - if (empty($tables[$key])) |
|
744 | - break; |
|
773 | + if (empty($tables[$key])) { |
|
774 | + break; |
|
775 | + } |
|
745 | 776 | |
746 | 777 | // Continue? |
747 | 778 | if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 10) |
@@ -755,8 +786,9 @@ discard block |
||
755 | 786 | createToken('admin-optimize'); |
756 | 787 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-optimize_token_var'] . '" value="' . $context['admin-optimize_token'] . '">'; |
757 | 788 | |
758 | - if (function_exists('apache_reset_timeout')) |
|
759 | - apache_reset_timeout(); |
|
789 | + if (function_exists('apache_reset_timeout')) { |
|
790 | + apache_reset_timeout(); |
|
791 | + } |
|
760 | 792 | |
761 | 793 | return; |
762 | 794 | } |
@@ -764,11 +796,12 @@ discard block |
||
764 | 796 | // Optimize the table! We use backticks here because it might be a custom table. |
765 | 797 | $data_freed = $smcFunc['db_optimize_table']($tables[$key]['table_name']); |
766 | 798 | |
767 | - if ($data_freed > 0) |
|
768 | - $_SESSION['optimized_tables'][] = array( |
|
799 | + if ($data_freed > 0) { |
|
800 | + $_SESSION['optimized_tables'][] = array( |
|
769 | 801 | 'name' => $tables[$key]['table_name'], |
770 | 802 | 'data_freed' => $data_freed, |
771 | 803 | ); |
804 | + } |
|
772 | 805 | } |
773 | 806 | |
774 | 807 | // Number of tables, etc... |
@@ -803,10 +836,11 @@ discard block |
||
803 | 836 | checkSession('request'); |
804 | 837 | |
805 | 838 | // validate the request or the loop |
806 | - if (!isset($_REQUEST['step'])) |
|
807 | - validateToken('admin-maint'); |
|
808 | - else |
|
809 | - validateToken('admin-boardrecount'); |
|
839 | + if (!isset($_REQUEST['step'])) { |
|
840 | + validateToken('admin-maint'); |
|
841 | + } else { |
|
842 | + validateToken('admin-boardrecount'); |
|
843 | + } |
|
810 | 844 | |
811 | 845 | $context['page_title'] = $txt['not_done_title']; |
812 | 846 | $context['continue_post_data'] = ''; |
@@ -827,8 +861,9 @@ discard block |
||
827 | 861 | $smcFunc['db_free_result']($request); |
828 | 862 | |
829 | 863 | $increment = min(max(50, ceil($max_topics / 4)), 2000); |
830 | - if (empty($_REQUEST['start'])) |
|
831 | - $_REQUEST['start'] = 0; |
|
864 | + if (empty($_REQUEST['start'])) { |
|
865 | + $_REQUEST['start'] = 0; |
|
866 | + } |
|
832 | 867 | |
833 | 868 | $total_steps = 8; |
834 | 869 | |
@@ -855,8 +890,8 @@ discard block |
||
855 | 890 | 'max_id' => $_REQUEST['start'] + $increment, |
856 | 891 | ) |
857 | 892 | ); |
858 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
859 | - $smcFunc['db_query']('', ' |
|
893 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
894 | + $smcFunc['db_query']('', ' |
|
860 | 895 | UPDATE {db_prefix}topics |
861 | 896 | SET num_replies = {int:num_replies} |
862 | 897 | WHERE id_topic = {int:id_topic}', |
@@ -865,6 +900,7 @@ discard block |
||
865 | 900 | 'id_topic' => $row['id_topic'], |
866 | 901 | ) |
867 | 902 | ); |
903 | + } |
|
868 | 904 | $smcFunc['db_free_result']($request); |
869 | 905 | |
870 | 906 | // Recount unapproved messages |
@@ -883,8 +919,8 @@ discard block |
||
883 | 919 | 'max_id' => $_REQUEST['start'] + $increment, |
884 | 920 | ) |
885 | 921 | ); |
886 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
887 | - $smcFunc['db_query']('', ' |
|
922 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
923 | + $smcFunc['db_query']('', ' |
|
888 | 924 | UPDATE {db_prefix}topics |
889 | 925 | SET unapproved_posts = {int:unapproved_posts} |
890 | 926 | WHERE id_topic = {int:id_topic}', |
@@ -893,6 +929,7 @@ discard block |
||
893 | 929 | 'id_topic' => $row['id_topic'], |
894 | 930 | ) |
895 | 931 | ); |
932 | + } |
|
896 | 933 | $smcFunc['db_free_result']($request); |
897 | 934 | |
898 | 935 | $_REQUEST['start'] += $increment; |
@@ -915,8 +952,8 @@ discard block |
||
915 | 952 | // Update the post count of each board. |
916 | 953 | if ($_REQUEST['step'] <= 1) |
917 | 954 | { |
918 | - if (empty($_REQUEST['start'])) |
|
919 | - $smcFunc['db_query']('', ' |
|
955 | + if (empty($_REQUEST['start'])) { |
|
956 | + $smcFunc['db_query']('', ' |
|
920 | 957 | UPDATE {db_prefix}boards |
921 | 958 | SET num_posts = {int:num_posts} |
922 | 959 | WHERE redirect = {string:redirect}', |
@@ -925,6 +962,7 @@ discard block |
||
925 | 962 | 'redirect' => '', |
926 | 963 | ) |
927 | 964 | ); |
965 | + } |
|
928 | 966 | |
929 | 967 | while ($_REQUEST['start'] < $max_topics) |
930 | 968 | { |
@@ -941,8 +979,8 @@ discard block |
||
941 | 979 | 'is_approved' => 1, |
942 | 980 | ) |
943 | 981 | ); |
944 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
945 | - $smcFunc['db_query']('', ' |
|
982 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
983 | + $smcFunc['db_query']('', ' |
|
946 | 984 | UPDATE {db_prefix}boards |
947 | 985 | SET num_posts = num_posts + {int:real_num_posts} |
948 | 986 | WHERE id_board = {int:id_board}', |
@@ -951,6 +989,7 @@ discard block |
||
951 | 989 | 'real_num_posts' => $row['real_num_posts'], |
952 | 990 | ) |
953 | 991 | ); |
992 | + } |
|
954 | 993 | $smcFunc['db_free_result']($request); |
955 | 994 | |
956 | 995 | $_REQUEST['start'] += $increment; |
@@ -973,14 +1012,15 @@ discard block |
||
973 | 1012 | // Update the topic count of each board. |
974 | 1013 | if ($_REQUEST['step'] <= 2) |
975 | 1014 | { |
976 | - if (empty($_REQUEST['start'])) |
|
977 | - $smcFunc['db_query']('', ' |
|
1015 | + if (empty($_REQUEST['start'])) { |
|
1016 | + $smcFunc['db_query']('', ' |
|
978 | 1017 | UPDATE {db_prefix}boards |
979 | 1018 | SET num_topics = {int:num_topics}', |
980 | 1019 | array( |
981 | 1020 | 'num_topics' => 0, |
982 | 1021 | ) |
983 | 1022 | ); |
1023 | + } |
|
984 | 1024 | |
985 | 1025 | while ($_REQUEST['start'] < $max_topics) |
986 | 1026 | { |
@@ -997,8 +1037,8 @@ discard block |
||
997 | 1037 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
998 | 1038 | ) |
999 | 1039 | ); |
1000 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1001 | - $smcFunc['db_query']('', ' |
|
1040 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1041 | + $smcFunc['db_query']('', ' |
|
1002 | 1042 | UPDATE {db_prefix}boards |
1003 | 1043 | SET num_topics = num_topics + {int:real_num_topics} |
1004 | 1044 | WHERE id_board = {int:id_board}', |
@@ -1007,6 +1047,7 @@ discard block |
||
1007 | 1047 | 'real_num_topics' => $row['real_num_topics'], |
1008 | 1048 | ) |
1009 | 1049 | ); |
1050 | + } |
|
1010 | 1051 | $smcFunc['db_free_result']($request); |
1011 | 1052 | |
1012 | 1053 | $_REQUEST['start'] += $increment; |
@@ -1029,14 +1070,15 @@ discard block |
||
1029 | 1070 | // Update the unapproved post count of each board. |
1030 | 1071 | if ($_REQUEST['step'] <= 3) |
1031 | 1072 | { |
1032 | - if (empty($_REQUEST['start'])) |
|
1033 | - $smcFunc['db_query']('', ' |
|
1073 | + if (empty($_REQUEST['start'])) { |
|
1074 | + $smcFunc['db_query']('', ' |
|
1034 | 1075 | UPDATE {db_prefix}boards |
1035 | 1076 | SET unapproved_posts = {int:unapproved_posts}', |
1036 | 1077 | array( |
1037 | 1078 | 'unapproved_posts' => 0, |
1038 | 1079 | ) |
1039 | 1080 | ); |
1081 | + } |
|
1040 | 1082 | |
1041 | 1083 | while ($_REQUEST['start'] < $max_topics) |
1042 | 1084 | { |
@@ -1053,8 +1095,8 @@ discard block |
||
1053 | 1095 | 'is_approved' => 0, |
1054 | 1096 | ) |
1055 | 1097 | ); |
1056 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1057 | - $smcFunc['db_query']('', ' |
|
1098 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1099 | + $smcFunc['db_query']('', ' |
|
1058 | 1100 | UPDATE {db_prefix}boards |
1059 | 1101 | SET unapproved_posts = unapproved_posts + {int:unapproved_posts} |
1060 | 1102 | WHERE id_board = {int:id_board}', |
@@ -1063,6 +1105,7 @@ discard block |
||
1063 | 1105 | 'unapproved_posts' => $row['real_unapproved_posts'], |
1064 | 1106 | ) |
1065 | 1107 | ); |
1108 | + } |
|
1066 | 1109 | $smcFunc['db_free_result']($request); |
1067 | 1110 | |
1068 | 1111 | $_REQUEST['start'] += $increment; |
@@ -1085,14 +1128,15 @@ discard block |
||
1085 | 1128 | // Update the unapproved topic count of each board. |
1086 | 1129 | if ($_REQUEST['step'] <= 4) |
1087 | 1130 | { |
1088 | - if (empty($_REQUEST['start'])) |
|
1089 | - $smcFunc['db_query']('', ' |
|
1131 | + if (empty($_REQUEST['start'])) { |
|
1132 | + $smcFunc['db_query']('', ' |
|
1090 | 1133 | UPDATE {db_prefix}boards |
1091 | 1134 | SET unapproved_topics = {int:unapproved_topics}', |
1092 | 1135 | array( |
1093 | 1136 | 'unapproved_topics' => 0, |
1094 | 1137 | ) |
1095 | 1138 | ); |
1139 | + } |
|
1096 | 1140 | |
1097 | 1141 | while ($_REQUEST['start'] < $max_topics) |
1098 | 1142 | { |
@@ -1109,8 +1153,8 @@ discard block |
||
1109 | 1153 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
1110 | 1154 | ) |
1111 | 1155 | ); |
1112 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1113 | - $smcFunc['db_query']('', ' |
|
1156 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1157 | + $smcFunc['db_query']('', ' |
|
1114 | 1158 | UPDATE {db_prefix}boards |
1115 | 1159 | SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics} |
1116 | 1160 | WHERE id_board = {int:id_board}', |
@@ -1119,6 +1163,7 @@ discard block |
||
1119 | 1163 | 'real_unapproved_topics' => $row['real_unapproved_topics'], |
1120 | 1164 | ) |
1121 | 1165 | ); |
1166 | + } |
|
1122 | 1167 | $smcFunc['db_free_result']($request); |
1123 | 1168 | |
1124 | 1169 | $_REQUEST['start'] += $increment; |
@@ -1152,8 +1197,9 @@ discard block |
||
1152 | 1197 | 'is_not_deleted' => 0, |
1153 | 1198 | ) |
1154 | 1199 | ); |
1155 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1156 | - updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
1200 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1201 | + updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
1202 | + } |
|
1157 | 1203 | $smcFunc['db_free_result']($request); |
1158 | 1204 | |
1159 | 1205 | $request = $smcFunc['db_query']('', ' |
@@ -1168,8 +1214,9 @@ discard block |
||
1168 | 1214 | 'is_not_read' => 0, |
1169 | 1215 | ) |
1170 | 1216 | ); |
1171 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1172 | - updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
1217 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1218 | + updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
1219 | + } |
|
1173 | 1220 | $smcFunc['db_free_result']($request); |
1174 | 1221 | |
1175 | 1222 | if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)) > 3) |
@@ -1201,12 +1248,13 @@ discard block |
||
1201 | 1248 | ) |
1202 | 1249 | ); |
1203 | 1250 | $boards = array(); |
1204 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1205 | - $boards[$row['id_board']][] = $row['id_msg']; |
|
1251 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1252 | + $boards[$row['id_board']][] = $row['id_msg']; |
|
1253 | + } |
|
1206 | 1254 | $smcFunc['db_free_result']($request); |
1207 | 1255 | |
1208 | - foreach ($boards as $board_id => $messages) |
|
1209 | - $smcFunc['db_query']('', ' |
|
1256 | + foreach ($boards as $board_id => $messages) { |
|
1257 | + $smcFunc['db_query']('', ' |
|
1210 | 1258 | UPDATE {db_prefix}messages |
1211 | 1259 | SET id_board = {int:id_board} |
1212 | 1260 | WHERE id_msg IN ({array_int:id_msg_array})', |
@@ -1215,6 +1263,7 @@ discard block |
||
1215 | 1263 | 'id_board' => $board_id, |
1216 | 1264 | ) |
1217 | 1265 | ); |
1266 | + } |
|
1218 | 1267 | |
1219 | 1268 | $_REQUEST['start'] += $increment; |
1220 | 1269 | |
@@ -1244,8 +1293,9 @@ discard block |
||
1244 | 1293 | ) |
1245 | 1294 | ); |
1246 | 1295 | $realBoardCounts = array(); |
1247 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1248 | - $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
1296 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1297 | + $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
1298 | + } |
|
1249 | 1299 | $smcFunc['db_free_result']($request); |
1250 | 1300 | |
1251 | 1301 | $request = $smcFunc['db_query']('', ' |
@@ -1265,18 +1315,20 @@ discard block |
||
1265 | 1315 | krsort($resort_me); |
1266 | 1316 | |
1267 | 1317 | $lastModifiedMsg = array(); |
1268 | - foreach ($resort_me as $rows) |
|
1269 | - foreach ($rows as $row) |
|
1318 | + foreach ($resort_me as $rows) { |
|
1319 | + foreach ($rows as $row) |
|
1270 | 1320 | { |
1271 | 1321 | // The latest message is the latest of the current board and its children. |
1272 | 1322 | if (isset($lastModifiedMsg[$row['id_board']])) |
1273 | 1323 | $curLastModifiedMsg = max($row['local_last_msg'], $lastModifiedMsg[$row['id_board']]); |
1274 | - else |
|
1275 | - $curLastModifiedMsg = $row['local_last_msg']; |
|
1324 | + } |
|
1325 | + else { |
|
1326 | + $curLastModifiedMsg = $row['local_last_msg']; |
|
1327 | + } |
|
1276 | 1328 | |
1277 | 1329 | // If what is and what should be the latest message differ, an update is necessary. |
1278 | - if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) |
|
1279 | - $smcFunc['db_query']('', ' |
|
1330 | + if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) { |
|
1331 | + $smcFunc['db_query']('', ' |
|
1280 | 1332 | UPDATE {db_prefix}boards |
1281 | 1333 | SET id_last_msg = {int:id_last_msg}, id_msg_updated = {int:id_msg_updated} |
1282 | 1334 | WHERE id_board = {int:id_board}', |
@@ -1286,12 +1338,14 @@ discard block |
||
1286 | 1338 | 'id_board' => $row['id_board'], |
1287 | 1339 | ) |
1288 | 1340 | ); |
1341 | + } |
|
1289 | 1342 | |
1290 | 1343 | // Parent boards inherit the latest modified message of their children. |
1291 | - if (isset($lastModifiedMsg[$row['id_parent']])) |
|
1292 | - $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
1293 | - else |
|
1294 | - $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
1344 | + if (isset($lastModifiedMsg[$row['id_parent']])) { |
|
1345 | + $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
1346 | + } else { |
|
1347 | + $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
1348 | + } |
|
1295 | 1349 | } |
1296 | 1350 | |
1297 | 1351 | // Update all the basic statistics. |
@@ -1363,8 +1417,9 @@ discard block |
||
1363 | 1417 | require_once($sourcedir . '/Subs-Auth.php'); |
1364 | 1418 | $members = findMembers($_POST['to']); |
1365 | 1419 | |
1366 | - if (empty($members)) |
|
1367 | - fatal_lang_error('reattribute_cannot_find_member'); |
|
1420 | + if (empty($members)) { |
|
1421 | + fatal_lang_error('reattribute_cannot_find_member'); |
|
1422 | + } |
|
1368 | 1423 | |
1369 | 1424 | $memID = array_shift($members); |
1370 | 1425 | $memID = $memID['id']; |
@@ -1394,8 +1449,9 @@ discard block |
||
1394 | 1449 | validateToken('admin-maint'); |
1395 | 1450 | |
1396 | 1451 | $groups = array(); |
1397 | - foreach ($_POST['groups'] as $id => $dummy) |
|
1398 | - $groups[] = (int) $id; |
|
1452 | + foreach ($_POST['groups'] as $id => $dummy) { |
|
1453 | + $groups[] = (int) $id; |
|
1454 | + } |
|
1399 | 1455 | $time_limit = (time() - ($_POST['maxdays'] * 24 * 3600)); |
1400 | 1456 | $where_vars = array( |
1401 | 1457 | 'time_limit' => $time_limit, |
@@ -1404,9 +1460,9 @@ discard block |
||
1404 | 1460 | { |
1405 | 1461 | $where = 'mem.date_registered < {int:time_limit} AND mem.is_activated = {int:is_activated}'; |
1406 | 1462 | $where_vars['is_activated'] = 0; |
1463 | + } else { |
|
1464 | + $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
1407 | 1465 | } |
1408 | - else |
|
1409 | - $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
1410 | 1466 | |
1411 | 1467 | // Need to get *all* groups then work out which (if any) we avoid. |
1412 | 1468 | $request = $smcFunc['db_query']('', ' |
@@ -1425,8 +1481,7 @@ discard block |
||
1425 | 1481 | { |
1426 | 1482 | $where .= ' AND mem.id_post_group != {int:id_post_group_' . $row['id_group'] . '}'; |
1427 | 1483 | $where_vars['id_post_group_' . $row['id_group']] = $row['id_group']; |
1428 | - } |
|
1429 | - else |
|
1484 | + } else |
|
1430 | 1485 | { |
1431 | 1486 | $where .= ' AND mem.id_group != {int:id_group_' . $row['id_group'] . '} AND FIND_IN_SET({int:id_group_' . $row['id_group'] . '}, mem.additional_groups) = 0'; |
1432 | 1487 | $where_vars['id_group_' . $row['id_group']] = $row['id_group']; |
@@ -1453,8 +1508,9 @@ discard block |
||
1453 | 1508 | $members = array(); |
1454 | 1509 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1455 | 1510 | { |
1456 | - if (!$row['is_mod'] || !in_array(3, $groups)) |
|
1457 | - $members[] = $row['id_member']; |
|
1511 | + if (!$row['is_mod'] || !in_array(3, $groups)) { |
|
1512 | + $members[] = $row['id_member']; |
|
1513 | + } |
|
1458 | 1514 | } |
1459 | 1515 | $smcFunc['db_free_result']($request); |
1460 | 1516 | |
@@ -1501,8 +1557,9 @@ discard block |
||
1501 | 1557 | ) |
1502 | 1558 | ); |
1503 | 1559 | |
1504 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1505 | - $drafts[] = (int) $row[0]; |
|
1560 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1561 | + $drafts[] = (int) $row[0]; |
|
1562 | + } |
|
1506 | 1563 | $smcFunc['db_free_result']($request); |
1507 | 1564 | |
1508 | 1565 | // If we have old drafts, remove them |
@@ -1545,8 +1602,9 @@ discard block |
||
1545 | 1602 | $sticky = isset($_POST['move_type_sticky']) || isset($_GET['sticky']); |
1546 | 1603 | |
1547 | 1604 | // No boards then this is your stop. |
1548 | - if (empty($id_board_from) || empty($id_board_to)) |
|
1549 | - return; |
|
1605 | + if (empty($id_board_from) || empty($id_board_to)) { |
|
1606 | + return; |
|
1607 | + } |
|
1550 | 1608 | |
1551 | 1609 | // The big WHERE clause |
1552 | 1610 | $conditions = 'WHERE t.id_board = {int:id_board_from} |
@@ -1594,18 +1652,20 @@ discard block |
||
1594 | 1652 | ); |
1595 | 1653 | list ($total_topics) = $smcFunc['db_fetch_row']($request); |
1596 | 1654 | $smcFunc['db_free_result']($request); |
1655 | + } else { |
|
1656 | + $total_topics = (int) $_REQUEST['totaltopics']; |
|
1597 | 1657 | } |
1598 | - else |
|
1599 | - $total_topics = (int) $_REQUEST['totaltopics']; |
|
1600 | 1658 | |
1601 | 1659 | // Seems like we need this here. |
1602 | 1660 | $context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';max_days=' . $max_days; |
1603 | 1661 | |
1604 | - if ($locked) |
|
1605 | - $context['continue_get_data'] .= ';locked'; |
|
1662 | + if ($locked) { |
|
1663 | + $context['continue_get_data'] .= ';locked'; |
|
1664 | + } |
|
1606 | 1665 | |
1607 | - if ($sticky) |
|
1608 | - $context['continue_get_data'] .= ';sticky'; |
|
1666 | + if ($sticky) { |
|
1667 | + $context['continue_get_data'] .= ';sticky'; |
|
1668 | + } |
|
1609 | 1669 | |
1610 | 1670 | $context['continue_get_data'] .= ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1611 | 1671 | |
@@ -1626,8 +1686,9 @@ discard block |
||
1626 | 1686 | |
1627 | 1687 | // Get the ids. |
1628 | 1688 | $topics = array(); |
1629 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1630 | - $topics[] = $row['id_topic']; |
|
1689 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1690 | + $topics[] = $row['id_topic']; |
|
1691 | + } |
|
1631 | 1692 | |
1632 | 1693 | // Just return if we don't have any topics left to move. |
1633 | 1694 | if (empty($topics)) |
@@ -1718,9 +1779,9 @@ discard block |
||
1718 | 1779 | // save it so we don't do this again for this task |
1719 | 1780 | list ($_SESSION['total_members']) = $smcFunc['db_fetch_row']($request); |
1720 | 1781 | $smcFunc['db_free_result']($request); |
1782 | + } else { |
|
1783 | + validateToken('admin-recountposts'); |
|
1721 | 1784 | } |
1722 | - else |
|
1723 | - validateToken('admin-recountposts'); |
|
1724 | 1785 | |
1725 | 1786 | // Lets get a group of members and determine their post count (from the boards that have post count enabled of course). |
1726 | 1787 | $request = $smcFunc['db_query']('', ' |
@@ -1766,8 +1827,9 @@ discard block |
||
1766 | 1827 | createToken('admin-recountposts'); |
1767 | 1828 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-recountposts_token_var'] . '" value="' . $context['admin-recountposts_token'] . '">'; |
1768 | 1829 | |
1769 | - if (function_exists('apache_reset_timeout')) |
|
1770 | - apache_reset_timeout(); |
|
1830 | + if (function_exists('apache_reset_timeout')) { |
|
1831 | + apache_reset_timeout(); |
|
1832 | + } |
|
1771 | 1833 | return; |
1772 | 1834 | } |
1773 | 1835 | |
@@ -1853,10 +1915,9 @@ discard block |
||
1853 | 1915 | checkSession('request'); |
1854 | 1916 | validateToken('admin-hook', 'request'); |
1855 | 1917 | |
1856 | - if ($_REQUEST['do'] == 'remove') |
|
1857 | - remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
1858 | - |
|
1859 | - else |
|
1918 | + if ($_REQUEST['do'] == 'remove') { |
|
1919 | + remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
1920 | + } else |
|
1860 | 1921 | { |
1861 | 1922 | $function_remove = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '' : '!'); |
1862 | 1923 | $function_add = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '!' : ''); |
@@ -1906,11 +1967,11 @@ discard block |
||
1906 | 1967 | // Show a nice icon to indicate this is an instance. |
1907 | 1968 | $instance = (!empty($data['instance']) ? '<span class="generic_icons news" title="' . $txt['hooks_field_function_method'] . '"></span> ' : ''); |
1908 | 1969 | |
1909 | - if (!empty($data['included_file'])) |
|
1910 | - return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
1911 | - |
|
1912 | - else |
|
1913 | - return $instance . $data['real_function']; |
|
1970 | + if (!empty($data['included_file'])) { |
|
1971 | + return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
1972 | + } else { |
|
1973 | + return $instance . $data['real_function']; |
|
1974 | + } |
|
1914 | 1975 | }, |
1915 | 1976 | ), |
1916 | 1977 | 'sort' => array( |
@@ -1975,11 +2036,12 @@ discard block |
||
1975 | 2036 | 'data' => array( |
1976 | 2037 | 'function' => function($data) use ($txt, $scripturl, $context) |
1977 | 2038 | { |
1978 | - if (!$data['hook_exists']) |
|
1979 | - return ' |
|
2039 | + if (!$data['hook_exists']) { |
|
2040 | + return ' |
|
1980 | 2041 | <a href="' . $scripturl . '?action=admin;area=maintain;sa=hooks;do=remove;hook=' . $data['hook_name'] . ';function=' . urlencode($data['function_name']) . $context['filter_url'] . ';' . $context['admin-hook_token_var'] . '=' . $context['admin-hook_token'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['quickmod_confirm'] . '" class="you_sure"> |
1981 | 2042 | <span class="generic_icons delete" title="' . $txt['hooks_button_remove'] . '"></span> |
1982 | 2043 | </a>'; |
2044 | + } |
|
1983 | 2045 | }, |
1984 | 2046 | 'class' => 'centertext', |
1985 | 2047 | ), |
@@ -2014,10 +2076,11 @@ discard block |
||
2014 | 2076 | { |
2015 | 2077 | if ($file != '.' && $file != '..') |
2016 | 2078 | { |
2017 | - if (is_dir($dir_path . '/' . $file)) |
|
2018 | - $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
2019 | - else |
|
2020 | - $files[] = array('dir' => $dir_path, 'name' => $file); |
|
2079 | + if (is_dir($dir_path . '/' . $file)) { |
|
2080 | + $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
2081 | + } else { |
|
2082 | + $files[] = array('dir' => $dir_path, 'name' => $file); |
|
2083 | + } |
|
2021 | 2084 | } |
2022 | 2085 | } |
2023 | 2086 | } |
@@ -2066,16 +2129,16 @@ discard block |
||
2066 | 2129 | // I need to know if there is at least one function called in this file. |
2067 | 2130 | $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
2068 | 2131 | unset($temp_hooks[$hook][$rawFunc]); |
2069 | - } |
|
2070 | - elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
2132 | + } elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
2071 | 2133 | { |
2072 | 2134 | $hook_status[$hook][$hookParsedData['pureFunc']] = $hookParsedData; |
2073 | 2135 | $hook_status[$hook][$hookParsedData['pureFunc']]['exists'] = true; |
2074 | 2136 | $hook_status[$hook][$hookParsedData['pureFunc']]['in_file'] = (!empty($file['name']) ? $file['name'] : (!empty($hookParsedData['hookFile']) ? $hookParsedData['hookFile'] : '')); |
2075 | 2137 | |
2076 | 2138 | // Does the hook has its own file? |
2077 | - if (!empty($hookParsedData['hookFile'])) |
|
2078 | - $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
2139 | + if (!empty($hookParsedData['hookFile'])) { |
|
2140 | + $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
2141 | + } |
|
2079 | 2142 | |
2080 | 2143 | // I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too) |
2081 | 2144 | $temp_data['function'][$file['name']][$hookParsedData['pureFunc']] = $hookParsedData['enabled']; |
@@ -2102,15 +2165,17 @@ discard block |
||
2102 | 2165 | $sort = array(); |
2103 | 2166 | $hooks_filters = array(); |
2104 | 2167 | |
2105 | - foreach ($hooks as $hook => $functions) |
|
2106 | - $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
2168 | + foreach ($hooks as $hook => $functions) { |
|
2169 | + $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
2170 | + } |
|
2107 | 2171 | |
2108 | - if (!empty($hooks_filters)) |
|
2109 | - $context['insert_after_template'] .= ' |
|
2172 | + if (!empty($hooks_filters)) { |
|
2173 | + $context['insert_after_template'] .= ' |
|
2110 | 2174 | <script> |
2111 | 2175 | var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\'); |
2112 | 2176 | hook_name_header.innerHTML += ' . JavaScriptEscape('<select style="margin-left:15px;" onchange="window.location=(\'' . $scripturl . '?action=admin;area=maintain;sa=hooks\' + (this.value ? \';filter=\' + this.value : \'\'));"><option value="">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>') . '; |
2113 | 2177 | </script>'; |
2178 | + } |
|
2114 | 2179 | |
2115 | 2180 | $temp_data = array(); |
2116 | 2181 | $id = 0; |
@@ -2152,10 +2217,11 @@ discard block |
||
2152 | 2217 | |
2153 | 2218 | foreach ($temp_data as $data) |
2154 | 2219 | { |
2155 | - if (++$counter < $start) |
|
2156 | - continue; |
|
2157 | - elseif ($counter == $start + $per_page) |
|
2158 | - break; |
|
2220 | + if (++$counter < $start) { |
|
2221 | + continue; |
|
2222 | + } elseif ($counter == $start + $per_page) { |
|
2223 | + break; |
|
2224 | + } |
|
2159 | 2225 | |
2160 | 2226 | $hooks_data[] = $data; |
2161 | 2227 | } |
@@ -2177,13 +2243,15 @@ discard block |
||
2177 | 2243 | $hooks_count = 0; |
2178 | 2244 | |
2179 | 2245 | $context['filter'] = false; |
2180 | - if (isset($_GET['filter'])) |
|
2181 | - $context['filter'] = $_GET['filter']; |
|
2246 | + if (isset($_GET['filter'])) { |
|
2247 | + $context['filter'] = $_GET['filter']; |
|
2248 | + } |
|
2182 | 2249 | |
2183 | 2250 | foreach ($hooks as $hook => $functions) |
2184 | 2251 | { |
2185 | - if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) |
|
2186 | - $hooks_count += count($functions); |
|
2252 | + if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) { |
|
2253 | + $hooks_count += count($functions); |
|
2254 | + } |
|
2187 | 2255 | } |
2188 | 2256 | |
2189 | 2257 | return $hooks_count; |
@@ -2204,8 +2272,9 @@ discard block |
||
2204 | 2272 | $integration_hooks = array(); |
2205 | 2273 | foreach ($modSettings as $key => $value) |
2206 | 2274 | { |
2207 | - if (!empty($value) && substr($key, 0, 10) === 'integrate_') |
|
2208 | - $integration_hooks[$key] = explode(',', $value); |
|
2275 | + if (!empty($value) && substr($key, 0, 10) === 'integrate_') { |
|
2276 | + $integration_hooks[$key] = explode(',', $value); |
|
2277 | + } |
|
2209 | 2278 | } |
2210 | 2279 | } |
2211 | 2280 | |
@@ -2236,8 +2305,9 @@ discard block |
||
2236 | 2305 | ); |
2237 | 2306 | |
2238 | 2307 | // Meh... |
2239 | - if (empty($rawData)) |
|
2240 | - return $hookData; |
|
2308 | + if (empty($rawData)) { |
|
2309 | + return $hookData; |
|
2310 | + } |
|
2241 | 2311 | |
2242 | 2312 | // For convenience purposes only! |
2243 | 2313 | $modFunc = $rawData; |
@@ -2248,11 +2318,11 @@ discard block |
||
2248 | 2318 | list ($hookData['hookFile'], $modFunc) = explode('|', $modFunc); |
2249 | 2319 | |
2250 | 2320 | // Does the file exists? who knows! |
2251 | - if (empty($settings['theme_dir'])) |
|
2252 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
2253 | - |
|
2254 | - else |
|
2255 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
2321 | + if (empty($settings['theme_dir'])) { |
|
2322 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
2323 | + } else { |
|
2324 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
2325 | + } |
|
2256 | 2326 | |
2257 | 2327 | $hookData['fileExists'] = file_exists($hookData['absPath']); |
2258 | 2328 | $hookData['hookFile'] = basename($hookData['hookFile']); |
@@ -2277,11 +2347,10 @@ discard block |
||
2277 | 2347 | { |
2278 | 2348 | list ($hookData['class'], $hookData['method']) = explode('::', $modFunc); |
2279 | 2349 | $hookData['pureFunc'] = $hookData['method']; |
2350 | + } else { |
|
2351 | + $hookData['pureFunc'] = $modFunc; |
|
2280 | 2352 | } |
2281 | 2353 | |
2282 | - else |
|
2283 | - $hookData['pureFunc'] = $modFunc; |
|
2284 | - |
|
2285 | 2354 | return $hookData; |
2286 | 2355 | } |
2287 | 2356 |
@@ -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 function works out what to do! |
@@ -24,9 +25,9 @@ discard block |
||
24 | 25 | global $time_start, $smcFunc, $modSettings; |
25 | 26 | |
26 | 27 | // Special case for doing the mail queue. |
27 | - if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') |
|
28 | - ReduceMailQueue(); |
|
29 | - else |
|
28 | + if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') { |
|
29 | + ReduceMailQueue(); |
|
30 | + } else |
|
30 | 31 | { |
31 | 32 | $task_string = ''; |
32 | 33 | |
@@ -53,18 +54,20 @@ discard block |
||
53 | 54 | |
54 | 55 | // How long in seconds it the gap? |
55 | 56 | $duration = $row['time_regularity']; |
56 | - if ($row['time_unit'] == 'm') |
|
57 | - $duration *= 60; |
|
58 | - elseif ($row['time_unit'] == 'h') |
|
59 | - $duration *= 3600; |
|
60 | - elseif ($row['time_unit'] == 'd') |
|
61 | - $duration *= 86400; |
|
62 | - elseif ($row['time_unit'] == 'w') |
|
63 | - $duration *= 604800; |
|
57 | + if ($row['time_unit'] == 'm') { |
|
58 | + $duration *= 60; |
|
59 | + } elseif ($row['time_unit'] == 'h') { |
|
60 | + $duration *= 3600; |
|
61 | + } elseif ($row['time_unit'] == 'd') { |
|
62 | + $duration *= 86400; |
|
63 | + } elseif ($row['time_unit'] == 'w') { |
|
64 | + $duration *= 604800; |
|
65 | + } |
|
64 | 66 | |
65 | 67 | // If we were really late running this task actually skip the next one. |
66 | - if (time() + ($duration / 2) > $next_time) |
|
67 | - $next_time += $duration; |
|
68 | + if (time() + ($duration / 2) > $next_time) { |
|
69 | + $next_time += $duration; |
|
70 | + } |
|
68 | 71 | |
69 | 72 | // Update it now, so no others run this! |
70 | 73 | $smcFunc['db_query']('', ' |
@@ -81,16 +84,19 @@ discard block |
||
81 | 84 | $affected_rows = $smcFunc['db_affected_rows'](); |
82 | 85 | |
83 | 86 | // What kind of task are we handling? |
84 | - if (!empty($row['callable'])) |
|
85 | - $task_string = $row['callable']; |
|
87 | + if (!empty($row['callable'])) { |
|
88 | + $task_string = $row['callable']; |
|
89 | + } |
|
86 | 90 | |
87 | 91 | // Default SMF task or old mods? |
88 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
89 | - $task_string = 'scheduled_' . $row['task']; |
|
92 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
93 | + $task_string = 'scheduled_' . $row['task']; |
|
94 | + } |
|
90 | 95 | |
91 | 96 | // One last resource, the task name. |
92 | - elseif (!empty($row['task'])) |
|
93 | - $task_string = $row['task']; |
|
97 | + elseif (!empty($row['task'])) { |
|
98 | + $task_string = $row['task']; |
|
99 | + } |
|
94 | 100 | |
95 | 101 | // The function must exist or we are wasting our time, plus do some timestamp checking, and database check! |
96 | 102 | if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) |
@@ -101,11 +107,11 @@ discard block |
||
101 | 107 | $callable_task = call_helper($task_string, true); |
102 | 108 | |
103 | 109 | // Perform the task. |
104 | - if (!empty($callable_task)) |
|
105 | - $completed = call_user_func($callable_task); |
|
106 | - |
|
107 | - else |
|
108 | - $completed = false; |
|
110 | + if (!empty($callable_task)) { |
|
111 | + $completed = call_user_func($callable_task); |
|
112 | + } else { |
|
113 | + $completed = false; |
|
114 | + } |
|
109 | 115 | |
110 | 116 | // Log that we did it ;) |
111 | 117 | if ($completed) |
@@ -138,18 +144,20 @@ discard block |
||
138 | 144 | ) |
139 | 145 | ); |
140 | 146 | // No new task scheduled yet? |
141 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
142 | - $nextEvent = time() + 86400; |
|
143 | - else |
|
144 | - list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
147 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
148 | + $nextEvent = time() + 86400; |
|
149 | + } else { |
|
150 | + list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
151 | + } |
|
145 | 152 | $smcFunc['db_free_result']($request); |
146 | 153 | |
147 | 154 | updateSettings(array('next_task_time' => $nextEvent)); |
148 | 155 | } |
149 | 156 | |
150 | 157 | // Shall we return? |
151 | - if (!isset($_GET['scheduled'])) |
|
152 | - return true; |
|
158 | + if (!isset($_GET['scheduled'])) { |
|
159 | + return true; |
|
160 | + } |
|
153 | 161 | |
154 | 162 | // Finally, send some stuff... |
155 | 163 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -181,16 +189,18 @@ discard block |
||
181 | 189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
182 | 190 | { |
183 | 191 | // If this is no longer around we'll ignore it. |
184 | - if (empty($row['id_topic'])) |
|
185 | - continue; |
|
192 | + if (empty($row['id_topic'])) { |
|
193 | + continue; |
|
194 | + } |
|
186 | 195 | |
187 | 196 | // What type is it? |
188 | - if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) |
|
189 | - $type = 'topic'; |
|
190 | - elseif ($row['id_attach']) |
|
191 | - $type = 'attach'; |
|
192 | - else |
|
193 | - $type = 'msg'; |
|
197 | + if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) { |
|
198 | + $type = 'topic'; |
|
199 | + } elseif ($row['id_attach']) { |
|
200 | + $type = 'attach'; |
|
201 | + } else { |
|
202 | + $type = 'msg'; |
|
203 | + } |
|
194 | 204 | |
195 | 205 | // Add it to the array otherwise. |
196 | 206 | $notices[$row['id_board']][$type][] = array( |
@@ -211,8 +221,9 @@ discard block |
||
211 | 221 | ); |
212 | 222 | |
213 | 223 | // If nothing quit now. |
214 | - if (empty($notices)) |
|
215 | - return true; |
|
224 | + if (empty($notices)) { |
|
225 | + return true; |
|
226 | + } |
|
216 | 227 | |
217 | 228 | // Now we need to think about finding out *who* can approve - this is hard! |
218 | 229 | |
@@ -231,14 +242,16 @@ discard block |
||
231 | 242 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
232 | 243 | { |
233 | 244 | // Sorry guys, but we have to ignore guests AND members - it would be too many otherwise. |
234 | - if ($row['id_group'] < 2) |
|
235 | - continue; |
|
245 | + if ($row['id_group'] < 2) { |
|
246 | + continue; |
|
247 | + } |
|
236 | 248 | |
237 | 249 | $perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group']; |
238 | 250 | |
239 | 251 | // Anyone who can access has to be considered. |
240 | - if ($row['add_deny']) |
|
241 | - $addGroups[] = $row['id_group']; |
|
252 | + if ($row['add_deny']) { |
|
253 | + $addGroups[] = $row['id_group']; |
|
254 | + } |
|
242 | 255 | } |
243 | 256 | $smcFunc['db_free_result']($request); |
244 | 257 | |
@@ -283,8 +296,9 @@ discard block |
||
283 | 296 | if (!empty($row['mod_prefs'])) |
284 | 297 | { |
285 | 298 | list(,, $pref_binary) = explode('|', $row['mod_prefs']); |
286 | - if (!($pref_binary & 4)) |
|
287 | - continue; |
|
299 | + if (!($pref_binary & 4)) { |
|
300 | + continue; |
|
301 | + } |
|
288 | 302 | } |
289 | 303 | |
290 | 304 | $members[$row['id_member']] = array( |
@@ -309,8 +323,9 @@ discard block |
||
309 | 323 | $emailbody = ''; |
310 | 324 | |
311 | 325 | // Load the language file as required. |
312 | - if (empty($current_language) || $current_language != $member['language']) |
|
313 | - $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
326 | + if (empty($current_language) || $current_language != $member['language']) { |
|
327 | + $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
328 | + } |
|
314 | 329 | |
315 | 330 | // Loop through each notice... |
316 | 331 | foreach ($notices as $board => $notice) |
@@ -318,29 +333,34 @@ discard block |
||
318 | 333 | $access = false; |
319 | 334 | |
320 | 335 | // Can they mod in this board? |
321 | - if (isset($mods[$id][$board])) |
|
322 | - $access = true; |
|
336 | + if (isset($mods[$id][$board])) { |
|
337 | + $access = true; |
|
338 | + } |
|
323 | 339 | |
324 | 340 | // Do the group check... |
325 | 341 | if (!$access && isset($perms[$profiles[$board]]['add'])) |
326 | 342 | { |
327 | 343 | // They can access?! |
328 | - if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) |
|
329 | - $access = true; |
|
344 | + if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) { |
|
345 | + $access = true; |
|
346 | + } |
|
330 | 347 | |
331 | 348 | // If they have deny rights don't consider them! |
332 | - if (isset($perms[$profiles[$board]]['deny'])) |
|
333 | - if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
349 | + if (isset($perms[$profiles[$board]]['deny'])) { |
|
350 | + if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
334 | 351 | $access = false; |
352 | + } |
|
335 | 353 | } |
336 | 354 | |
337 | 355 | // Finally, fix it for admins! |
338 | - if (in_array(1, $member['groups'])) |
|
339 | - $access = true; |
|
356 | + if (in_array(1, $member['groups'])) { |
|
357 | + $access = true; |
|
358 | + } |
|
340 | 359 | |
341 | 360 | // If they can't access it then give it a break! |
342 | - if (!$access) |
|
343 | - continue; |
|
361 | + if (!$access) { |
|
362 | + continue; |
|
363 | + } |
|
344 | 364 | |
345 | 365 | foreach ($notice as $type => $items) |
346 | 366 | { |
@@ -348,15 +368,17 @@ discard block |
||
348 | 368 | $emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" . |
349 | 369 | '------------------------------------------------------' . "\n"; |
350 | 370 | |
351 | - foreach ($items as $item) |
|
352 | - $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
371 | + foreach ($items as $item) { |
|
372 | + $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
373 | + } |
|
353 | 374 | |
354 | 375 | $emailbody .= "\n"; |
355 | 376 | } |
356 | 377 | } |
357 | 378 | |
358 | - if ($emailbody == '') |
|
359 | - continue; |
|
379 | + if ($emailbody == '') { |
|
380 | + continue; |
|
381 | + } |
|
360 | 382 | |
361 | 383 | $replacements = array( |
362 | 384 | 'REALNAME' => $member['name'], |
@@ -397,8 +419,9 @@ discard block |
||
397 | 419 | ) |
398 | 420 | ); |
399 | 421 | $members = array(); |
400 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
401 | - $members[$row['id_member']] = $row['warning']; |
|
422 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
423 | + $members[$row['id_member']] = $row['warning']; |
|
424 | + } |
|
402 | 425 | $smcFunc['db_free_result']($request); |
403 | 426 | |
404 | 427 | // Have some members to check? |
@@ -420,17 +443,18 @@ discard block |
||
420 | 443 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
421 | 444 | { |
422 | 445 | // More than 24 hours ago? |
423 | - if ($row['last_warning'] <= time() - 86400) |
|
424 | - $member_changes[] = array( |
|
446 | + if ($row['last_warning'] <= time() - 86400) { |
|
447 | + $member_changes[] = array( |
|
425 | 448 | 'id' => $row['id_recipient'], |
426 | 449 | 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0, |
427 | 450 | ); |
451 | + } |
|
428 | 452 | } |
429 | 453 | $smcFunc['db_free_result']($request); |
430 | 454 | |
431 | 455 | // Have some members to change? |
432 | - if (!empty($member_changes)) |
|
433 | - foreach ($member_changes as $change) |
|
456 | + if (!empty($member_changes)) { |
|
457 | + foreach ($member_changes as $change) |
|
434 | 458 | $smcFunc['db_query']('', ' |
435 | 459 | UPDATE {db_prefix}members |
436 | 460 | SET warning = {int:warning} |
@@ -440,6 +464,7 @@ discard block |
||
440 | 464 | 'id_member' => $change['id'], |
441 | 465 | ) |
442 | 466 | ); |
467 | + } |
|
443 | 468 | } |
444 | 469 | } |
445 | 470 | |
@@ -452,16 +477,17 @@ discard block |
||
452 | 477 | |
453 | 478 | // Check the database version - for some buggy MySQL version. |
454 | 479 | $server_version = $smcFunc['db_server_info'](); |
455 | - if (($db_type == 'mysql') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
456 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
457 | - elseif (!empty($modSettings['db_mysql_group_by_fix'])) |
|
458 | - $smcFunc['db_query']('', ' |
|
480 | + if (($db_type == 'mysql') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
481 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
482 | + } elseif (!empty($modSettings['db_mysql_group_by_fix'])) { |
|
483 | + $smcFunc['db_query']('', ' |
|
459 | 484 | DELETE FROM {db_prefix}settings |
460 | 485 | WHERE variable = {string:mysql_fix}', |
461 | 486 | array( |
462 | 487 | 'mysql_fix' => 'db_mysql_group_by_fix', |
463 | 488 | ) |
464 | 489 | ); |
490 | + } |
|
465 | 491 | |
466 | 492 | // Clean up some old login history information. |
467 | 493 | $smcFunc['db_query']('', ' |
@@ -519,15 +545,17 @@ discard block |
||
519 | 545 | |
520 | 546 | // Store this useful data! |
521 | 547 | $boards[$row['id_board']] = $row['id_board']; |
522 | - if ($row['id_topic']) |
|
523 | - $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
524 | - else |
|
525 | - $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
548 | + if ($row['id_topic']) { |
|
549 | + $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
550 | + } else { |
|
551 | + $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
552 | + } |
|
526 | 553 | } |
527 | 554 | $smcFunc['db_free_result']($request); |
528 | 555 | |
529 | - if (empty($boards)) |
|
530 | - return true; |
|
556 | + if (empty($boards)) { |
|
557 | + return true; |
|
558 | + } |
|
531 | 559 | |
532 | 560 | // Just get the board names. |
533 | 561 | $request = $smcFunc['db_query']('', ' |
@@ -539,12 +567,14 @@ discard block |
||
539 | 567 | ) |
540 | 568 | ); |
541 | 569 | $boards = array(); |
542 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
543 | - $boards[$row['id_board']] = $row['name']; |
|
570 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
571 | + $boards[$row['id_board']] = $row['name']; |
|
572 | + } |
|
544 | 573 | $smcFunc['db_free_result']($request); |
545 | 574 | |
546 | - if (empty($boards)) |
|
547 | - return true; |
|
575 | + if (empty($boards)) { |
|
576 | + return true; |
|
577 | + } |
|
548 | 578 | |
549 | 579 | // Get the actual topics... |
550 | 580 | $request = $smcFunc['db_query']('', ' |
@@ -564,52 +594,57 @@ discard block |
||
564 | 594 | $types = array(); |
565 | 595 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
566 | 596 | { |
567 | - if (!isset($types[$row['note_type']][$row['id_board']])) |
|
568 | - $types[$row['note_type']][$row['id_board']] = array( |
|
597 | + if (!isset($types[$row['note_type']][$row['id_board']])) { |
|
598 | + $types[$row['note_type']][$row['id_board']] = array( |
|
569 | 599 | 'lines' => array(), |
570 | 600 | 'name' => $row['board_name'], |
571 | 601 | 'id' => $row['id_board'], |
572 | 602 | ); |
603 | + } |
|
573 | 604 | |
574 | 605 | if ($row['note_type'] == 'reply') |
575 | 606 | { |
576 | - if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
577 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
578 | - else |
|
579 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
607 | + if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
608 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
609 | + } else { |
|
610 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
580 | 611 | 'id' => $row['id_topic'], |
581 | 612 | 'subject' => un_htmlspecialchars($row['subject']), |
582 | 613 | 'count' => 1, |
583 | 614 | ); |
584 | - } |
|
585 | - elseif ($row['note_type'] == 'topic') |
|
615 | + } |
|
616 | + } elseif ($row['note_type'] == 'topic') |
|
586 | 617 | { |
587 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
588 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
618 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
619 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
589 | 620 | 'id' => $row['id_topic'], |
590 | 621 | 'subject' => un_htmlspecialchars($row['subject']), |
591 | 622 | ); |
592 | - } |
|
593 | - else |
|
623 | + } |
|
624 | + } else |
|
594 | 625 | { |
595 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
596 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
626 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
627 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
597 | 628 | 'id' => $row['id_topic'], |
598 | 629 | 'subject' => un_htmlspecialchars($row['subject']), |
599 | 630 | 'starter' => $row['id_member_started'], |
600 | 631 | ); |
632 | + } |
|
601 | 633 | } |
602 | 634 | |
603 | 635 | $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array(); |
604 | - if (!empty($notify['topics'][$row['id_topic']])) |
|
605 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
606 | - if (!empty($notify['boards'][$row['id_board']])) |
|
607 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
636 | + if (!empty($notify['topics'][$row['id_topic']])) { |
|
637 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
638 | + } |
|
639 | + if (!empty($notify['boards'][$row['id_board']])) { |
|
640 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
641 | + } |
|
608 | 642 | } |
609 | 643 | $smcFunc['db_free_result']($request); |
610 | 644 | |
611 | - if (empty($types)) |
|
612 | - return true; |
|
645 | + if (empty($types)) { |
|
646 | + return true; |
|
647 | + } |
|
613 | 648 | |
614 | 649 | // Let's load all the languages into a cache thingy. |
615 | 650 | $langtxt = array(); |
@@ -650,8 +685,9 @@ discard block |
||
650 | 685 | $notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1; |
651 | 686 | |
652 | 687 | // Did they not elect to choose this? |
653 | - if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) |
|
654 | - continue; |
|
688 | + if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) { |
|
689 | + continue; |
|
690 | + } |
|
655 | 691 | |
656 | 692 | // Right character set! |
657 | 693 | $context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set']; |
@@ -667,39 +703,43 @@ discard block |
||
667 | 703 | if (isset($types['topic'])) |
668 | 704 | { |
669 | 705 | $titled = false; |
670 | - foreach ($types['topic'] as $id => $board) |
|
671 | - foreach ($board['lines'] as $topic) |
|
706 | + foreach ($types['topic'] as $id => $board) { |
|
707 | + foreach ($board['lines'] as $topic) |
|
672 | 708 | if (in_array($mid, $topic['members'])) |
673 | 709 | { |
674 | 710 | if (!$titled) |
675 | 711 | { |
676 | 712 | $email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------'; |
713 | + } |
|
677 | 714 | $titled = true; |
678 | 715 | } |
679 | 716 | $email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']); |
680 | 717 | } |
681 | - if ($titled) |
|
682 | - $email['body'] .= "\n"; |
|
718 | + if ($titled) { |
|
719 | + $email['body'] .= "\n"; |
|
720 | + } |
|
683 | 721 | } |
684 | 722 | |
685 | 723 | // What about replies? |
686 | 724 | if (isset($types['reply'])) |
687 | 725 | { |
688 | 726 | $titled = false; |
689 | - foreach ($types['reply'] as $id => $board) |
|
690 | - foreach ($board['lines'] as $topic) |
|
727 | + foreach ($types['reply'] as $id => $board) { |
|
728 | + foreach ($board['lines'] as $topic) |
|
691 | 729 | if (in_array($mid, $topic['members'])) |
692 | 730 | { |
693 | 731 | if (!$titled) |
694 | 732 | { |
695 | 733 | $email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------'; |
734 | + } |
|
696 | 735 | $titled = true; |
697 | 736 | } |
698 | 737 | $email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject'])); |
699 | 738 | } |
700 | 739 | |
701 | - if ($titled) |
|
702 | - $email['body'] .= "\n"; |
|
740 | + if ($titled) { |
|
741 | + $email['body'] .= "\n"; |
|
742 | + } |
|
703 | 743 | } |
704 | 744 | |
705 | 745 | // Finally, moderation actions! |
@@ -708,24 +748,27 @@ discard block |
||
708 | 748 | $titled = false; |
709 | 749 | foreach ($types as $note_type => $type) |
710 | 750 | { |
711 | - if ($note_type == 'topic' || $note_type == 'reply') |
|
712 | - continue; |
|
751 | + if ($note_type == 'topic' || $note_type == 'reply') { |
|
752 | + continue; |
|
753 | + } |
|
713 | 754 | |
714 | - foreach ($type as $id => $board) |
|
715 | - foreach ($board['lines'] as $topic) |
|
755 | + foreach ($type as $id => $board) { |
|
756 | + foreach ($board['lines'] as $topic) |
|
716 | 757 | if (in_array($mid, $topic['members'])) |
717 | 758 | { |
718 | 759 | if (!$titled) |
719 | 760 | { |
720 | 761 | $email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------'; |
762 | + } |
|
721 | 763 | $titled = true; |
722 | 764 | } |
723 | 765 | $email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']); |
724 | 766 | } |
725 | 767 | } |
726 | 768 | } |
727 | - if ($titled) |
|
728 | - $email['body'] .= "\n"; |
|
769 | + if ($titled) { |
|
770 | + $email['body'] .= "\n"; |
|
771 | + } |
|
729 | 772 | |
730 | 773 | // Then just say our goodbyes! |
731 | 774 | $email['body'] .= "\n\n" . $txt['regards_team']; |
@@ -753,8 +796,7 @@ discard block |
||
753 | 796 | 'not_daily' => 0, |
754 | 797 | ) |
755 | 798 | ); |
756 | - } |
|
757 | - else |
|
799 | + } else |
|
758 | 800 | { |
759 | 801 | // Clear any only weekly ones, and stop us from sending daily again. |
760 | 802 | $smcFunc['db_query']('', ' |
@@ -816,16 +858,19 @@ discard block |
||
816 | 858 | global $modSettings, $smcFunc, $sourcedir; |
817 | 859 | |
818 | 860 | // Are we intending another script to be sending out the queue? |
819 | - if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) |
|
820 | - return false; |
|
861 | + if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) { |
|
862 | + return false; |
|
863 | + } |
|
821 | 864 | |
822 | 865 | // By default send 5 at once. |
823 | - if (!$number) |
|
824 | - $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
866 | + if (!$number) { |
|
867 | + $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
868 | + } |
|
825 | 869 | |
826 | 870 | // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us. |
827 | - if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) |
|
828 | - return false; |
|
871 | + if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) { |
|
872 | + return false; |
|
873 | + } |
|
829 | 874 | |
830 | 875 | // By default move the next sending on by 10 seconds, and require an affected row. |
831 | 876 | if (!$override_limit) |
@@ -842,8 +887,9 @@ discard block |
||
842 | 887 | 'last_send' => $modSettings['mail_next_send'], |
843 | 888 | ) |
844 | 889 | ); |
845 | - if ($smcFunc['db_affected_rows']() == 0) |
|
846 | - return false; |
|
890 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
891 | + return false; |
|
892 | + } |
|
847 | 893 | $modSettings['mail_next_send'] = time() + $delay; |
848 | 894 | } |
849 | 895 | |
@@ -864,8 +910,9 @@ discard block |
||
864 | 910 | $mn += $number; |
865 | 911 | } |
866 | 912 | // No more I'm afraid, return! |
867 | - else |
|
868 | - return false; |
|
913 | + else { |
|
914 | + return false; |
|
915 | + } |
|
869 | 916 | |
870 | 917 | // Reflect that we're about to send some, do it now to be safe. |
871 | 918 | updateSettings(array('mail_recent' => $mt . '|' . $mn)); |
@@ -900,14 +947,15 @@ discard block |
||
900 | 947 | $smcFunc['db_free_result']($request); |
901 | 948 | |
902 | 949 | // Delete, delete, delete!!! |
903 | - if (!empty($ids)) |
|
904 | - $smcFunc['db_query']('', ' |
|
950 | + if (!empty($ids)) { |
|
951 | + $smcFunc['db_query']('', ' |
|
905 | 952 | DELETE FROM {db_prefix}mail_queue |
906 | 953 | WHERE id_mail IN ({array_int:mail_list})', |
907 | 954 | array( |
908 | 955 | 'mail_list' => $ids, |
909 | 956 | ) |
910 | 957 | ); |
958 | + } |
|
911 | 959 | |
912 | 960 | // Don't believe we have any left? |
913 | 961 | if (count($ids) < $number) |
@@ -925,11 +973,13 @@ discard block |
||
925 | 973 | ); |
926 | 974 | } |
927 | 975 | |
928 | - if (empty($ids)) |
|
929 | - return false; |
|
976 | + if (empty($ids)) { |
|
977 | + return false; |
|
978 | + } |
|
930 | 979 | |
931 | - if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') |
|
932 | - require_once($sourcedir . '/Subs-Post.php'); |
|
980 | + if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') { |
|
981 | + require_once($sourcedir . '/Subs-Post.php'); |
|
982 | + } |
|
933 | 983 | |
934 | 984 | // Send each email, yea! |
935 | 985 | $failed_emails = array(); |
@@ -949,15 +999,17 @@ discard block |
||
949 | 999 | |
950 | 1000 | // Try to stop a timeout, this would be bad... |
951 | 1001 | @set_time_limit(300); |
952 | - if (function_exists('apache_reset_timeout')) |
|
953 | - @apache_reset_timeout(); |
|
1002 | + if (function_exists('apache_reset_timeout')) { |
|
1003 | + @apache_reset_timeout(); |
|
1004 | + } |
|
1005 | + } else { |
|
1006 | + $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
954 | 1007 | } |
955 | - else |
|
956 | - $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
957 | 1008 | |
958 | 1009 | // Hopefully it sent? |
959 | - if (!$result) |
|
960 | - $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
1010 | + if (!$result) { |
|
1011 | + $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
1012 | + } |
|
961 | 1013 | } |
962 | 1014 | |
963 | 1015 | // Any emails that didn't send? |
@@ -972,8 +1024,8 @@ discard block |
||
972 | 1024 | ); |
973 | 1025 | |
974 | 1026 | // If we have failed to many times, tell mail to wait a bit and try again. |
975 | - if ($modSettings['mail_failed_attempts'] > 5) |
|
976 | - $smcFunc['db_query']('', ' |
|
1027 | + if ($modSettings['mail_failed_attempts'] > 5) { |
|
1028 | + $smcFunc['db_query']('', ' |
|
977 | 1029 | UPDATE {db_prefix}settings |
978 | 1030 | SET value = {string:next_mail_send} |
979 | 1031 | WHERE variable = {literal:mail_next_send} |
@@ -982,6 +1034,7 @@ discard block |
||
982 | 1034 | 'next_mail_send' => time() + 60, |
983 | 1035 | 'last_send' => $modSettings['mail_next_send'], |
984 | 1036 | )); |
1037 | + } |
|
985 | 1038 | |
986 | 1039 | // Add our email back to the queue, manually. |
987 | 1040 | $smcFunc['db_insert']('insert', |
@@ -994,8 +1047,8 @@ discard block |
||
994 | 1047 | return false; |
995 | 1048 | } |
996 | 1049 | // We where unable to send the email, clear our failed attempts. |
997 | - elseif (!empty($modSettings['mail_failed_attempts'])) |
|
998 | - $smcFunc['db_query']('', ' |
|
1050 | + elseif (!empty($modSettings['mail_failed_attempts'])) { |
|
1051 | + $smcFunc['db_query']('', ' |
|
999 | 1052 | UPDATE {db_prefix}settings |
1000 | 1053 | SET value = {string:zero} |
1001 | 1054 | WHERE variable = {string:mail_failed_attempts}', |
@@ -1003,6 +1056,7 @@ discard block |
||
1003 | 1056 | 'zero' => '0', |
1004 | 1057 | 'mail_failed_attempts' => 'mail_failed_attempts', |
1005 | 1058 | )); |
1059 | + } |
|
1006 | 1060 | |
1007 | 1061 | // Had something to send... |
1008 | 1062 | return true; |
@@ -1019,16 +1073,18 @@ discard block |
||
1019 | 1073 | global $modSettings, $smcFunc; |
1020 | 1074 | |
1021 | 1075 | $task_query = ''; |
1022 | - if (!is_array($tasks)) |
|
1023 | - $tasks = array($tasks); |
|
1076 | + if (!is_array($tasks)) { |
|
1077 | + $tasks = array($tasks); |
|
1078 | + } |
|
1024 | 1079 | |
1025 | 1080 | // Actually have something passed? |
1026 | 1081 | if (!empty($tasks)) |
1027 | 1082 | { |
1028 | - if (!isset($tasks[0]) || is_numeric($tasks[0])) |
|
1029 | - $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
1030 | - else |
|
1031 | - $task_query = ' AND task IN ({array_string:tasks})'; |
|
1083 | + if (!isset($tasks[0]) || is_numeric($tasks[0])) { |
|
1084 | + $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
1085 | + } else { |
|
1086 | + $task_query = ' AND task IN ({array_string:tasks})'; |
|
1087 | + } |
|
1032 | 1088 | } |
1033 | 1089 | $nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time']; |
1034 | 1090 | |
@@ -1049,20 +1105,22 @@ discard block |
||
1049 | 1105 | $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']); |
1050 | 1106 | |
1051 | 1107 | // Only bother moving the task if it's out of place or we're forcing it! |
1052 | - if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) |
|
1053 | - $tasks[$row['id_task']] = $next_time; |
|
1054 | - else |
|
1055 | - $next_time = $row['next_time']; |
|
1108 | + if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) { |
|
1109 | + $tasks[$row['id_task']] = $next_time; |
|
1110 | + } else { |
|
1111 | + $next_time = $row['next_time']; |
|
1112 | + } |
|
1056 | 1113 | |
1057 | 1114 | // If this is sooner than the current next task, make this the next task. |
1058 | - if ($next_time < $nextTaskTime) |
|
1059 | - $nextTaskTime = $next_time; |
|
1115 | + if ($next_time < $nextTaskTime) { |
|
1116 | + $nextTaskTime = $next_time; |
|
1117 | + } |
|
1060 | 1118 | } |
1061 | 1119 | $smcFunc['db_free_result']($request); |
1062 | 1120 | |
1063 | 1121 | // Now make the changes! |
1064 | - foreach ($tasks as $id => $time) |
|
1065 | - $smcFunc['db_query']('', ' |
|
1122 | + foreach ($tasks as $id => $time) { |
|
1123 | + $smcFunc['db_query']('', ' |
|
1066 | 1124 | UPDATE {db_prefix}scheduled_tasks |
1067 | 1125 | SET next_time = {int:next_time} |
1068 | 1126 | WHERE id_task = {int:id_task}', |
@@ -1071,11 +1129,13 @@ discard block |
||
1071 | 1129 | 'id_task' => $id, |
1072 | 1130 | ) |
1073 | 1131 | ); |
1132 | + } |
|
1074 | 1133 | |
1075 | 1134 | // If the next task is now different update. |
1076 | - if ($modSettings['next_task_time'] != $nextTaskTime) |
|
1077 | - updateSettings(array('next_task_time' => $nextTaskTime)); |
|
1078 | -} |
|
1135 | + if ($modSettings['next_task_time'] != $nextTaskTime) { |
|
1136 | + updateSettings(array('next_task_time' => $nextTaskTime)); |
|
1137 | + } |
|
1138 | + } |
|
1079 | 1139 | |
1080 | 1140 | /** |
1081 | 1141 | * Simply returns a time stamp of the next instance of these time parameters. |
@@ -1088,8 +1148,9 @@ discard block |
||
1088 | 1148 | function next_time($regularity, $unit, $offset) |
1089 | 1149 | { |
1090 | 1150 | // Just in case! |
1091 | - if ($regularity == 0) |
|
1092 | - $regularity = 2; |
|
1151 | + if ($regularity == 0) { |
|
1152 | + $regularity = 2; |
|
1153 | + } |
|
1093 | 1154 | |
1094 | 1155 | $curMin = date('i', time()); |
1095 | 1156 | |
@@ -1099,15 +1160,16 @@ discard block |
||
1099 | 1160 | $off = date('i', $offset); |
1100 | 1161 | |
1101 | 1162 | // If it's now just pretend it ain't, |
1102 | - if ($off == $curMin) |
|
1103 | - $next_time = time() + $regularity; |
|
1104 | - else |
|
1163 | + if ($off == $curMin) { |
|
1164 | + $next_time = time() + $regularity; |
|
1165 | + } else |
|
1105 | 1166 | { |
1106 | 1167 | // Make sure that the offset is always in the past. |
1107 | 1168 | $off = $off > $curMin ? $off - 60 : $off; |
1108 | 1169 | |
1109 | - while ($off <= $curMin) |
|
1110 | - $off += $regularity; |
|
1170 | + while ($off <= $curMin) { |
|
1171 | + $off += $regularity; |
|
1172 | + } |
|
1111 | 1173 | |
1112 | 1174 | // Now we know when the time should be! |
1113 | 1175 | $next_time = time() + 60 * ($off - $curMin); |
@@ -1127,11 +1189,13 @@ discard block |
||
1127 | 1189 | // Default we'll jump in hours. |
1128 | 1190 | $applyOffset = 3600; |
1129 | 1191 | // 24 hours = 1 day. |
1130 | - if ($unit == 'd') |
|
1131 | - $applyOffset = 86400; |
|
1192 | + if ($unit == 'd') { |
|
1193 | + $applyOffset = 86400; |
|
1194 | + } |
|
1132 | 1195 | // Otherwise a week. |
1133 | - if ($unit == 'w') |
|
1134 | - $applyOffset = 604800; |
|
1196 | + if ($unit == 'w') { |
|
1197 | + $applyOffset = 604800; |
|
1198 | + } |
|
1135 | 1199 | |
1136 | 1200 | $applyOffset *= $regularity; |
1137 | 1201 | |
@@ -1168,8 +1232,9 @@ discard block |
||
1168 | 1232 | $settings[$row['variable']] = $row['value']; |
1169 | 1233 | |
1170 | 1234 | // Is this the default theme? |
1171 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') |
|
1172 | - $settings['default_' . $row['variable']] = $row['value']; |
|
1235 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') { |
|
1236 | + $settings['default_' . $row['variable']] = $row['value']; |
|
1237 | + } |
|
1173 | 1238 | } |
1174 | 1239 | $smcFunc['db_free_result']($result); |
1175 | 1240 | |
@@ -1179,12 +1244,14 @@ discard block |
||
1179 | 1244 | $settings['template_dirs'] = array($settings['theme_dir']); |
1180 | 1245 | |
1181 | 1246 | // Based on theme (if there is one). |
1182 | - if (!empty($settings['base_theme_dir'])) |
|
1183 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1247 | + if (!empty($settings['base_theme_dir'])) { |
|
1248 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1249 | + } |
|
1184 | 1250 | |
1185 | 1251 | // Lastly the default theme. |
1186 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1187 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1252 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1253 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1254 | + } |
|
1188 | 1255 | } |
1189 | 1256 | |
1190 | 1257 | // Assume we want this. |
@@ -1330,8 +1397,9 @@ discard block |
||
1330 | 1397 | // Ok should we prune the logs? |
1331 | 1398 | if (!empty($modSettings['pruningOptions'])) |
1332 | 1399 | { |
1333 | - if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) |
|
1334 | - list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
1400 | + if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) { |
|
1401 | + list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
1402 | + } |
|
1335 | 1403 | |
1336 | 1404 | if (!empty($modSettings['pruneErrorLog'])) |
1337 | 1405 | { |
@@ -1397,8 +1465,9 @@ discard block |
||
1397 | 1465 | ) |
1398 | 1466 | ); |
1399 | 1467 | |
1400 | - while ($row = $smcFunc['db_fetch_row']($result)) |
|
1401 | - $reports[] = $row[0]; |
|
1468 | + while ($row = $smcFunc['db_fetch_row']($result)) { |
|
1469 | + $reports[] = $row[0]; |
|
1470 | + } |
|
1402 | 1471 | |
1403 | 1472 | $smcFunc['db_free_result']($result); |
1404 | 1473 | |
@@ -1560,8 +1629,9 @@ discard block |
||
1560 | 1629 | $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); |
1561 | 1630 | |
1562 | 1631 | // Send the actual email. |
1563 | - if ($notifyPrefs[$row['id_member']] & 0x02) |
|
1564 | - sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
1632 | + if ($notifyPrefs[$row['id_member']] & 0x02) { |
|
1633 | + sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
1634 | + } |
|
1565 | 1635 | |
1566 | 1636 | if ($notifyPrefs[$row['id_member']] & 0x01) |
1567 | 1637 | { |
@@ -1584,18 +1654,19 @@ discard block |
||
1584 | 1654 | } |
1585 | 1655 | |
1586 | 1656 | // Insert the alerts if any |
1587 | - if (!empty($alert_rows)) |
|
1588 | - $smcFunc['db_insert']('', |
|
1657 | + if (!empty($alert_rows)) { |
|
1658 | + $smcFunc['db_insert']('', |
|
1589 | 1659 | '{db_prefix}user_alerts', |
1590 | 1660 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
1591 | 1661 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
1592 | 1662 | $alert_rows, |
1593 | 1663 | array() |
1594 | 1664 | ); |
1665 | + } |
|
1595 | 1666 | |
1596 | 1667 | // Mark the reminder as sent. |
1597 | - if (!empty($subs_reminded)) |
|
1598 | - $smcFunc['db_query']('', ' |
|
1668 | + if (!empty($subs_reminded)) { |
|
1669 | + $smcFunc['db_query']('', ' |
|
1599 | 1670 | UPDATE {db_prefix}log_subscribed |
1600 | 1671 | SET reminder_sent = {int:reminder_sent} |
1601 | 1672 | WHERE id_sublog IN ({array_int:subscription_list})', |
@@ -1604,6 +1675,7 @@ discard block |
||
1604 | 1675 | 'reminder_sent' => 1, |
1605 | 1676 | ) |
1606 | 1677 | ); |
1678 | + } |
|
1607 | 1679 | |
1608 | 1680 | return true; |
1609 | 1681 | } |
@@ -1619,13 +1691,13 @@ discard block |
||
1619 | 1691 | // We need to know where this thing is going. |
1620 | 1692 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
1621 | 1693 | { |
1622 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
1623 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
1694 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
1695 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
1696 | + } |
|
1624 | 1697 | |
1625 | 1698 | // Just use the current path for temp files. |
1626 | 1699 | $attach_dirs = $modSettings['attachmentUploadDir']; |
1627 | - } |
|
1628 | - else |
|
1700 | + } else |
|
1629 | 1701 | { |
1630 | 1702 | $attach_dirs = array($modSettings['attachmentUploadDir']); |
1631 | 1703 | } |
@@ -1644,14 +1716,16 @@ discard block |
||
1644 | 1716 | |
1645 | 1717 | while ($file = readdir($dir)) |
1646 | 1718 | { |
1647 | - if ($file == '.' || $file == '..') |
|
1648 | - continue; |
|
1719 | + if ($file == '.' || $file == '..') { |
|
1720 | + continue; |
|
1721 | + } |
|
1649 | 1722 | |
1650 | 1723 | if (strpos($file, 'post_tmp_') !== false) |
1651 | 1724 | { |
1652 | 1725 | // Temp file is more than 5 hours old! |
1653 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
1654 | - @unlink($attach_dir . '/' . $file); |
|
1726 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
1727 | + @unlink($attach_dir . '/' . $file); |
|
1728 | + } |
|
1655 | 1729 | } |
1656 | 1730 | } |
1657 | 1731 | closedir($dir); |
@@ -1684,8 +1758,9 @@ discard block |
||
1684 | 1758 | ) |
1685 | 1759 | ); |
1686 | 1760 | |
1687 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1688 | - $topics[] = $row[0]; |
|
1761 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1762 | + $topics[] = $row[0]; |
|
1763 | + } |
|
1689 | 1764 | $smcFunc['db_free_result']($request); |
1690 | 1765 | |
1691 | 1766 | // Zap, your gone |
@@ -1705,8 +1780,9 @@ discard block |
||
1705 | 1780 | { |
1706 | 1781 | global $smcFunc, $sourcedir, $modSettings; |
1707 | 1782 | |
1708 | - if (empty($modSettings['drafts_keep_days'])) |
|
1709 | - return true; |
|
1783 | + if (empty($modSettings['drafts_keep_days'])) { |
|
1784 | + return true; |
|
1785 | + } |
|
1710 | 1786 | |
1711 | 1787 | // init |
1712 | 1788 | $drafts = array(); |
@@ -1724,8 +1800,9 @@ discard block |
||
1724 | 1800 | ) |
1725 | 1801 | ); |
1726 | 1802 | |
1727 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1728 | - $drafts[] = (int) $row[0]; |
|
1803 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1804 | + $drafts[] = (int) $row[0]; |
|
1805 | + } |
|
1729 | 1806 | $smcFunc['db_free_result']($request); |
1730 | 1807 | |
1731 | 1808 | // If we have old one, remove them |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -54,9 +54,10 @@ discard block |
||
54 | 54 | <dd> |
55 | 55 | <div id="known_themes_list">'; |
56 | 56 | |
57 | - foreach ($context['themes'] as $theme) |
|
58 | - echo ' |
|
57 | + foreach ($context['themes'] as $theme) { |
|
58 | + echo ' |
|
59 | 59 | <label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked' : '', ' class="input_check"> ', $theme['name'], '</label><br>'; |
60 | + } |
|
60 | 61 | |
61 | 62 | echo ' |
62 | 63 | </div> |
@@ -73,9 +74,10 @@ discard block |
||
73 | 74 | <select name="options[theme_guests]" id="theme_guests">'; |
74 | 75 | |
75 | 76 | // Put an option for each theme in the select box. |
76 | - foreach ($context['themes'] as $theme) |
|
77 | - echo ' |
|
77 | + foreach ($context['themes'] as $theme) { |
|
78 | + echo ' |
|
78 | 79 | <option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>'; |
80 | + } |
|
79 | 81 | |
80 | 82 | echo ' |
81 | 83 | </select> |
@@ -90,9 +92,10 @@ discard block |
||
90 | 92 | <option value="0">', $txt['theme_forum_default'], '</option>'; |
91 | 93 | |
92 | 94 | // Same thing, this time for changing the theme of everyone. |
93 | - foreach ($context['themes'] as $theme) |
|
94 | - echo ' |
|
95 | + foreach ($context['themes'] as $theme) { |
|
96 | + echo ' |
|
95 | 97 | <option value="', $theme['id'], '">', $theme['name'], '</option>'; |
98 | + } |
|
96 | 99 | |
97 | 100 | echo ' |
98 | 101 | </select> |
@@ -189,11 +192,12 @@ discard block |
||
189 | 192 | global $context, $scripturl, $txt; |
190 | 193 | |
191 | 194 | // Show a nice confirmation message. |
192 | - if (isset($_GET['done'])) |
|
193 | - echo ' |
|
195 | + if (isset($_GET['done'])) { |
|
196 | + echo ' |
|
194 | 197 | <div class="infobox"> |
195 | 198 | ', $txt['theme_confirmed_' . $_GET['done']], ' |
196 | 199 | </div>'; |
200 | + } |
|
197 | 201 | |
198 | 202 | echo ' |
199 | 203 | <div id="admincenter">'; |
@@ -353,22 +357,24 @@ discard block |
||
353 | 357 | <dt ', $context['theme_options_reset'] ? 'style="width:50%"' : '', '>'; |
354 | 358 | |
355 | 359 | // Show the change option box ? |
356 | - if ($context['theme_options_reset']) |
|
357 | - echo ' |
|
360 | + if ($context['theme_options_reset']) { |
|
361 | + echo ' |
|
358 | 362 | <span class="floatleft"><select name="', !empty($setting['default']) ? 'default_' : '', 'options_master[', $setting['id'], ']" onchange="this.form.options_', $setting['id'], '.disabled = this.selectedIndex != 1;"> |
359 | 363 | <option value="0" selected>', $txt['themeadmin_reset_options_none'], '</option> |
360 | 364 | <option value="1">', $txt['themeadmin_reset_options_change'], '</option> |
361 | 365 | <option value="2">', $txt['themeadmin_reset_options_default'], '</option> |
362 | 366 | </select> </span>'; |
367 | + } |
|
363 | 368 | |
364 | 369 | // display checkbox options |
365 | 370 | if ($setting['type'] == 'checkbox') |
366 | 371 | { |
367 | 372 | echo ' |
368 | 373 | <label for="options_', $setting['id'], '">', $setting['label'], '</label>'; |
369 | - if (isset($setting['description'])) |
|
370 | - echo ' |
|
374 | + if (isset($setting['description'])) { |
|
375 | + echo ' |
|
371 | 376 | <br><span class="smalltext">', $setting['description'], '</span>'; |
377 | + } |
|
372 | 378 | echo ' |
373 | 379 | </dt> |
374 | 380 | <dd ', $context['theme_options_reset'] ? 'style="width:40%"' : '', '> |
@@ -380,9 +386,10 @@ discard block |
||
380 | 386 | { |
381 | 387 | echo ' |
382 | 388 | <label for="options_', $setting['id'], '">', $setting['label'], '</label>'; |
383 | - if (isset($setting['description'])) |
|
384 | - echo ' |
|
389 | + if (isset($setting['description'])) { |
|
390 | + echo ' |
|
385 | 391 | <br><span class="smalltext">', $setting['description'], '</span>'; |
392 | + } |
|
386 | 393 | echo ' |
387 | 394 | </dt> |
388 | 395 | <dd ', $context['theme_options_reset'] ? 'style="width:40%"' : '', '> |
@@ -402,9 +409,10 @@ discard block |
||
402 | 409 | { |
403 | 410 | echo ' |
404 | 411 | <label for="options_', $setting['id'], '">', $setting['label'], '</label>'; |
405 | - if (isset($setting['description'])) |
|
406 | - echo ' |
|
412 | + if (isset($setting['description'])) { |
|
413 | + echo ' |
|
407 | 414 | <br><span class="smalltext">', $setting['description'], '</span>'; |
415 | + } |
|
408 | 416 | echo ' |
409 | 417 | </dt> |
410 | 418 | <dd ', $context['theme_options_reset'] ? 'style="width:40%"' : '', '>'; |
@@ -417,13 +425,11 @@ discard block |
||
417 | 425 | |
418 | 426 | echo ' |
419 | 427 | <input type="number"', $min . $max . $step; |
420 | - } |
|
421 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
428 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
422 | 429 | { |
423 | 430 | echo' |
424 | 431 | <input type="url"'; |
425 | - } |
|
426 | - else |
|
432 | + } else |
|
427 | 433 | { |
428 | 434 | echo ' |
429 | 435 | <input type="text"'; |
@@ -467,8 +473,8 @@ discard block |
||
467 | 473 | <br>'; |
468 | 474 | |
469 | 475 | // @todo Why can't I edit the default theme popup. |
470 | - if ($context['theme_settings']['theme_id'] != 1) |
|
471 | - echo ' |
|
476 | + if ($context['theme_settings']['theme_id'] != 1) { |
|
477 | + echo ' |
|
472 | 478 | <div class="cat_bar"> |
473 | 479 | <h3 class="catbg config_hd"> |
474 | 480 | ', $txt['theme_edit'], ' |
@@ -484,6 +490,7 @@ discard block |
||
484 | 490 | </li> |
485 | 491 | </ul> |
486 | 492 | </div>'; |
493 | + } |
|
487 | 494 | |
488 | 495 | echo ' |
489 | 496 | <div class="cat_bar"> |
@@ -537,9 +544,10 @@ discard block |
||
537 | 544 | <dd> |
538 | 545 | <select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">'; |
539 | 546 | |
540 | - foreach ($context['theme_variants'] as $key => $variant) |
|
541 | - echo ' |
|
547 | + foreach ($context['theme_variants'] as $key => $variant) { |
|
548 | + echo ' |
|
542 | 549 | <option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>'; |
550 | + } |
|
543 | 551 | |
544 | 552 | echo ' |
545 | 553 | </select> |
@@ -582,9 +590,10 @@ discard block |
||
582 | 590 | <dt> |
583 | 591 | <label for="', $setting['id'], '">', $setting['label'], '</label>:'; |
584 | 592 | |
585 | - if (isset($setting['description'])) |
|
586 | - echo '<br> |
|
593 | + if (isset($setting['description'])) { |
|
594 | + echo '<br> |
|
587 | 595 | <span class="smalltext">', $setting['description'], '</span>'; |
596 | + } |
|
588 | 597 | |
589 | 598 | echo ' |
590 | 599 | </dt> |
@@ -600,18 +609,20 @@ discard block |
||
600 | 609 | <dt> |
601 | 610 | <label for="', $setting['id'], '">', $setting['label'], '</label>:'; |
602 | 611 | |
603 | - if (isset($setting['description'])) |
|
604 | - echo '<br> |
|
612 | + if (isset($setting['description'])) { |
|
613 | + echo '<br> |
|
605 | 614 | <span class="smalltext">', $setting['description'], '</span>'; |
615 | + } |
|
606 | 616 | |
607 | 617 | echo ' |
608 | 618 | </dt> |
609 | 619 | <dd> |
610 | 620 | <select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">'; |
611 | 621 | |
612 | - foreach ($setting['options'] as $value => $label) |
|
613 | - echo ' |
|
622 | + foreach ($setting['options'] as $value => $label) { |
|
623 | + echo ' |
|
614 | 624 | <option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>'; |
625 | + } |
|
615 | 626 | |
616 | 627 | echo ' |
617 | 628 | </select> |
@@ -624,9 +635,10 @@ discard block |
||
624 | 635 | <dt> |
625 | 636 | <label for="', $setting['id'], '">', $setting['label'], '</label>:'; |
626 | 637 | |
627 | - if (isset($setting['description'])) |
|
628 | - echo '<br> |
|
638 | + if (isset($setting['description'])) { |
|
639 | + echo '<br> |
|
629 | 640 | <span class="smalltext">', $setting['description'], '</span>'; |
641 | + } |
|
630 | 642 | echo ' |
631 | 643 | </dt> |
632 | 644 | <dd> |
@@ -641,9 +653,10 @@ discard block |
||
641 | 653 | <dt> |
642 | 654 | <label for="', $setting['id'], '">', $setting['label'], '</label>:'; |
643 | 655 | |
644 | - if (isset($setting['description'])) |
|
645 | - echo '<br> |
|
656 | + if (isset($setting['description'])) { |
|
657 | + echo '<br> |
|
646 | 658 | <span class="smalltext">', $setting['description'], '</span>'; |
659 | + } |
|
647 | 660 | |
648 | 661 | echo ' |
649 | 662 | </dt> |
@@ -657,13 +670,11 @@ discard block |
||
657 | 670 | |
658 | 671 | echo ' |
659 | 672 | <input type="number"', $min . $max . $step; |
660 | - } |
|
661 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
673 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
662 | 674 | { |
663 | 675 | echo' |
664 | 676 | <input type="url"'; |
665 | - } |
|
666 | - else |
|
677 | + } else |
|
667 | 678 | { |
668 | 679 | echo ' |
669 | 680 | <input type="text"'; |
@@ -816,21 +827,23 @@ discard block |
||
816 | 827 | <div class="windowbg">'; |
817 | 828 | |
818 | 829 | // Oops! there was an error :( |
819 | - if (!empty($context['error_message'])) |
|
820 | - echo ' |
|
830 | + if (!empty($context['error_message'])) { |
|
831 | + echo ' |
|
821 | 832 | <p> |
822 | 833 | ', $context['error_message'], ' |
823 | 834 | </p>'; |
835 | + } |
|
824 | 836 | |
825 | 837 | // Not much to show except a link back... |
826 | - else |
|
827 | - echo ' |
|
838 | + else { |
|
839 | + echo ' |
|
828 | 840 | <p> |
829 | 841 | <a href="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['installed_theme']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['installed_theme']['name'], '</a> ', $txt['theme_' . (isset($context['installed_theme']['updated']) ? 'updated' : 'installed') . '_message'], ' |
830 | 842 | </p> |
831 | 843 | <p> |
832 | 844 | <a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a> |
833 | 845 | </p>'; |
846 | + } |
|
834 | 847 | |
835 | 848 | echo ' |
836 | 849 | </div> |
@@ -897,10 +910,11 @@ discard block |
||
897 | 910 | <span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span> |
898 | 911 | <span class="floatright">'; |
899 | 912 | |
900 | - if ($template['can_copy']) |
|
901 | - echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>'; |
|
902 | - else |
|
903 | - echo $txt['themeadmin_edit_no_copy']; |
|
913 | + if ($template['can_copy']) { |
|
914 | + echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>'; |
|
915 | + } else { |
|
916 | + echo $txt['themeadmin_edit_no_copy']; |
|
917 | + } |
|
904 | 918 | |
905 | 919 | echo ' |
906 | 920 | </span> |
@@ -923,11 +937,12 @@ discard block |
||
923 | 937 | echo ' |
924 | 938 | <div id="admincenter">'; |
925 | 939 | |
926 | - if (!empty($context['browse_title'])) |
|
927 | - echo ' |
|
940 | + if (!empty($context['browse_title'])) { |
|
941 | + echo ' |
|
928 | 942 | <div class="cat_bar"> |
929 | 943 | <h3 class="catbg">', $context['browse_title'], '</h3> |
930 | 944 | </div>'; |
945 | + } |
|
931 | 946 | |
932 | 947 | echo ' |
933 | 948 | <table class="table_grid tborder"> |
@@ -947,14 +962,13 @@ discard block |
||
947 | 962 | <tr class="windowbg"> |
948 | 963 | <td>'; |
949 | 964 | |
950 | - if ($file['is_editable']) |
|
951 | - echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>'; |
|
952 | - |
|
953 | - elseif ($file['is_directory']) |
|
954 | - echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>'; |
|
955 | - |
|
956 | - else |
|
957 | - echo $file['filename']; |
|
965 | + if ($file['is_editable']) { |
|
966 | + echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>'; |
|
967 | + } elseif ($file['is_directory']) { |
|
968 | + echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>'; |
|
969 | + } else { |
|
970 | + echo $file['filename']; |
|
971 | + } |
|
958 | 972 | |
959 | 973 | echo ' |
960 | 974 | </td> |
@@ -976,11 +990,12 @@ discard block |
||
976 | 990 | { |
977 | 991 | global $context, $settings, $scripturl, $txt; |
978 | 992 | |
979 | - if ($context['session_error']) |
|
980 | - echo ' |
|
993 | + if ($context['session_error']) { |
|
994 | + echo ' |
|
981 | 995 | <div class="errorbox"> |
982 | 996 | ', $txt['error_session_timeout'], ' |
983 | 997 | </div>'; |
998 | + } |
|
984 | 999 | |
985 | 1000 | // From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com. |
986 | 1001 | echo ' |
@@ -1043,17 +1058,18 @@ discard block |
||
1043 | 1058 | try |
1044 | 1059 | { |
1045 | 1060 | '; |
1046 | - if (isBrowser('is_ie')) |
|
1047 | - echo ' |
|
1061 | + if (isBrowser('is_ie')) { |
|
1062 | + echo ' |
|
1048 | 1063 | var sheets = frames["css_preview_box"].document.styleSheets; |
1049 | 1064 | for (var j = 0; j < sheets.length; j++) |
1050 | 1065 | { |
1051 | 1066 | if (sheets[j].id == "css_preview_box") |
1052 | 1067 | sheets[j].cssText = document.forms.stylesheetForm.entire_file.value; |
1053 | 1068 | }'; |
1054 | - else |
|
1055 | - echo ' |
|
1069 | + } else { |
|
1070 | + echo ' |
|
1056 | 1071 | setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);'; |
1072 | + } |
|
1057 | 1073 | echo ' |
1058 | 1074 | } |
1059 | 1075 | catch (e) |
@@ -1105,9 +1121,10 @@ discard block |
||
1105 | 1121 | </div> |
1106 | 1122 | <div class="windowbg">'; |
1107 | 1123 | |
1108 | - if (!$context['allow_save']) |
|
1109 | - echo ' |
|
1124 | + if (!$context['allow_save']) { |
|
1125 | + echo ' |
|
1110 | 1126 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>'; |
1127 | + } |
|
1111 | 1128 | |
1112 | 1129 | echo ' |
1113 | 1130 | <textarea name="entire_file" cols="80" rows="20" style="width: 96%; font-family: monospace; margin-top: 1ex; white-space: pre;" onkeyup="setPreviewTimeout();" onchange="refreshPreview(true);">', $context['entire_file'], '</textarea><br> |
@@ -1120,9 +1137,10 @@ discard block |
||
1120 | 1137 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
1121 | 1138 | |
1122 | 1139 | // Hopefully it exists. |
1123 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
1124 | - echo ' |
|
1140 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
1141 | + echo ' |
|
1125 | 1142 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
1143 | + } |
|
1126 | 1144 | |
1127 | 1145 | echo ' |
1128 | 1146 | </form> |
@@ -1136,18 +1154,20 @@ discard block |
||
1136 | 1154 | { |
1137 | 1155 | global $context, $scripturl, $txt; |
1138 | 1156 | |
1139 | - if ($context['session_error']) |
|
1140 | - echo ' |
|
1157 | + if ($context['session_error']) { |
|
1158 | + echo ' |
|
1141 | 1159 | <div class="errorbox"> |
1142 | 1160 | ', $txt['error_session_timeout'], ' |
1143 | 1161 | </div>'; |
1162 | + } |
|
1144 | 1163 | |
1145 | - if (isset($context['parse_error'])) |
|
1146 | - echo ' |
|
1164 | + if (isset($context['parse_error'])) { |
|
1165 | + echo ' |
|
1147 | 1166 | <div class="errorbox"> |
1148 | 1167 | ', $txt['themeadmin_edit_error'], ' |
1149 | 1168 | <div><pre>', $context['parse_error'], '</pre></div> |
1150 | 1169 | </div>'; |
1170 | + } |
|
1151 | 1171 | |
1152 | 1172 | // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.) |
1153 | 1173 | echo ' |
@@ -1158,16 +1178,18 @@ discard block |
||
1158 | 1178 | </div> |
1159 | 1179 | <div class="windowbg">'; |
1160 | 1180 | |
1161 | - if (!$context['allow_save']) |
|
1162 | - echo ' |
|
1181 | + if (!$context['allow_save']) { |
|
1182 | + echo ' |
|
1163 | 1183 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>'; |
1184 | + } |
|
1164 | 1185 | |
1165 | - foreach ($context['file_parts'] as $part) |
|
1166 | - echo ' |
|
1186 | + foreach ($context['file_parts'] as $part) { |
|
1187 | + echo ' |
|
1167 | 1188 | <label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br> |
1168 | 1189 | <div class="centertext"> |
1169 | 1190 | <textarea id="on_line', $part['line'], '" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea> |
1170 | 1191 | </div>'; |
1192 | + } |
|
1171 | 1193 | |
1172 | 1194 | echo ' |
1173 | 1195 | <div class="padding righttext"> |
@@ -1176,9 +1198,10 @@ discard block |
||
1176 | 1198 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
1177 | 1199 | |
1178 | 1200 | // Hopefully it exists. |
1179 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
1180 | - echo ' |
|
1201 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
1202 | + echo ' |
|
1181 | 1203 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
1204 | + } |
|
1182 | 1205 | |
1183 | 1206 | echo ' |
1184 | 1207 | </div> |
@@ -1194,18 +1217,20 @@ discard block |
||
1194 | 1217 | { |
1195 | 1218 | global $context, $scripturl, $txt; |
1196 | 1219 | |
1197 | - if ($context['session_error']) |
|
1198 | - echo ' |
|
1220 | + if ($context['session_error']) { |
|
1221 | + echo ' |
|
1199 | 1222 | <div class="errorbox"> |
1200 | 1223 | ', $txt['error_session_timeout'], ' |
1201 | 1224 | </div>'; |
1225 | + } |
|
1202 | 1226 | |
1203 | 1227 | //Is this file writeable? |
1204 | - if (!$context['allow_save']) |
|
1205 | - echo ' |
|
1228 | + if (!$context['allow_save']) { |
|
1229 | + echo ' |
|
1206 | 1230 | <div class="errorbox"> |
1207 | 1231 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], ' |
1208 | 1232 | </div>'; |
1233 | + } |
|
1209 | 1234 | |
1210 | 1235 | // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.) |
1211 | 1236 | echo ' |
@@ -1221,9 +1246,10 @@ discard block |
||
1221 | 1246 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
1222 | 1247 | |
1223 | 1248 | // Hopefully it exists. |
1224 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
1225 | - echo ' |
|
1249 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
1250 | + echo ' |
|
1226 | 1251 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
1252 | + } |
|
1227 | 1253 | |
1228 | 1254 | echo ' |
1229 | 1255 | </div> |
@@ -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'); |
@@ -125,10 +128,12 @@ discard block |
||
125 | 128 | $upcontext['user'] = unserialize(base64_decode($upgradeData)); |
126 | 129 | |
127 | 130 | // Check for sensible values. |
128 | - if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) |
|
129 | - $upcontext['user']['started'] = time(); |
|
130 | - if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) |
|
131 | - $upcontext['user']['updated'] = 0; |
|
131 | + if (empty($upcontext['user']['started']) || $upcontext['user']['started'] < time() - 86400) { |
|
132 | + $upcontext['user']['started'] = time(); |
|
133 | + } |
|
134 | + if (empty($upcontext['user']['updated']) || $upcontext['user']['updated'] < time() - 86400) { |
|
135 | + $upcontext['user']['updated'] = 0; |
|
136 | + } |
|
132 | 137 | |
133 | 138 | $upcontext['started'] = $upcontext['user']['started']; |
134 | 139 | $upcontext['updated'] = $upcontext['user']['updated']; |
@@ -187,8 +192,9 @@ discard block |
||
187 | 192 | 'db_error_skip' => true, |
188 | 193 | ) |
189 | 194 | ); |
190 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
191 | - $modSettings[$row['variable']] = $row['value']; |
|
195 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
196 | + $modSettings[$row['variable']] = $row['value']; |
|
197 | + } |
|
192 | 198 | $smcFunc['db_free_result']($request); |
193 | 199 | } |
194 | 200 | |
@@ -198,10 +204,12 @@ discard block |
||
198 | 204 | $modSettings['theme_url'] = 'Themes/default'; |
199 | 205 | $modSettings['images_url'] = 'Themes/default/images'; |
200 | 206 | } |
201 | -if (!isset($settings['default_theme_url'])) |
|
207 | +if (!isset($settings['default_theme_url'])) { |
|
202 | 208 | $settings['default_theme_url'] = $modSettings['theme_url']; |
203 | -if (!isset($settings['default_theme_dir'])) |
|
209 | +} |
|
210 | +if (!isset($settings['default_theme_dir'])) { |
|
204 | 211 | $settings['default_theme_dir'] = $modSettings['theme_dir']; |
212 | +} |
|
205 | 213 | |
206 | 214 | $upcontext['is_large_forum'] = (empty($modSettings['smfVersion']) || $modSettings['smfVersion'] <= '1.1 RC1') && !empty($modSettings['totalMessages']) && $modSettings['totalMessages'] > 75000; |
207 | 215 | // Default title... |
@@ -219,13 +227,15 @@ discard block |
||
219 | 227 | $support_js = $upcontext['upgrade_status']['js']; |
220 | 228 | |
221 | 229 | // Only set this if the upgrader status says so. |
222 | - if (empty($is_debug)) |
|
223 | - $is_debug = $upcontext['upgrade_status']['debug']; |
|
230 | + if (empty($is_debug)) { |
|
231 | + $is_debug = $upcontext['upgrade_status']['debug']; |
|
232 | + } |
|
224 | 233 | |
225 | 234 | // Load the language. |
226 | - if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
227 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
228 | -} |
|
235 | + if (file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
236 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
237 | + } |
|
238 | + } |
|
229 | 239 | // Set the defaults. |
230 | 240 | else |
231 | 241 | { |
@@ -243,15 +253,18 @@ discard block |
||
243 | 253 | } |
244 | 254 | |
245 | 255 | // If this isn't the first stage see whether they are logging in and resuming. |
246 | -if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) |
|
256 | +if ($upcontext['current_step'] != 0 || !empty($upcontext['user']['step'])) { |
|
247 | 257 | checkLogin(); |
258 | +} |
|
248 | 259 | |
249 | -if ($command_line) |
|
260 | +if ($command_line) { |
|
250 | 261 | cmdStep0(); |
262 | +} |
|
251 | 263 | |
252 | 264 | // Don't error if we're using xml. |
253 | -if (isset($_GET['xml'])) |
|
265 | +if (isset($_GET['xml'])) { |
|
254 | 266 | $upcontext['return_error'] = true; |
267 | +} |
|
255 | 268 | |
256 | 269 | // Loop through all the steps doing each one as required. |
257 | 270 | $upcontext['overall_percent'] = 0; |
@@ -272,10 +285,11 @@ discard block |
||
272 | 285 | } |
273 | 286 | |
274 | 287 | // Call the step and if it returns false that means pause! |
275 | - if (function_exists($step[2]) && $step[2]() === false) |
|
276 | - break; |
|
277 | - elseif (function_exists($step[2])) |
|
278 | - $upcontext['current_step']++; |
|
288 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
289 | + break; |
|
290 | + } elseif (function_exists($step[2])) { |
|
291 | + $upcontext['current_step']++; |
|
292 | + } |
|
279 | 293 | } |
280 | 294 | $upcontext['overall_percent'] += $step[3]; |
281 | 295 | } |
@@ -314,17 +328,18 @@ discard block |
||
314 | 328 | // This should not happen my dear... HELP ME DEVELOPERS!! |
315 | 329 | if (!empty($command_line)) |
316 | 330 | { |
317 | - if (function_exists('debug_print_backtrace')) |
|
318 | - debug_print_backtrace(); |
|
331 | + if (function_exists('debug_print_backtrace')) { |
|
332 | + debug_print_backtrace(); |
|
333 | + } |
|
319 | 334 | |
320 | 335 | 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.'; |
321 | 336 | flush(); |
322 | 337 | die(); |
323 | 338 | } |
324 | 339 | |
325 | - if (!isset($_GET['xml'])) |
|
326 | - template_upgrade_above(); |
|
327 | - else |
|
340 | + if (!isset($_GET['xml'])) { |
|
341 | + template_upgrade_above(); |
|
342 | + } else |
|
328 | 343 | { |
329 | 344 | header('Content-Type: text/xml; charset=UTF-8'); |
330 | 345 | // Sadly we need to retain the $_GET data thanks to the old upgrade scripts. |
@@ -346,21 +361,24 @@ discard block |
||
346 | 361 | $upcontext['form_url'] = $upgradeurl . '?step=' . $upcontext['current_step'] . '&substep=' . $_GET['substep'] . '&data=' . base64_encode(safe_serialize($upcontext['upgrade_status'])); |
347 | 362 | |
348 | 363 | // Custom stuff to pass back? |
349 | - if (!empty($upcontext['query_string'])) |
|
350 | - $upcontext['form_url'] .= $upcontext['query_string']; |
|
364 | + if (!empty($upcontext['query_string'])) { |
|
365 | + $upcontext['form_url'] .= $upcontext['query_string']; |
|
366 | + } |
|
351 | 367 | |
352 | 368 | call_user_func('template_' . $upcontext['sub_template']); |
353 | 369 | } |
354 | 370 | |
355 | 371 | // Was there an error? |
356 | - if (!empty($upcontext['forced_error_message'])) |
|
357 | - echo $upcontext['forced_error_message']; |
|
372 | + if (!empty($upcontext['forced_error_message'])) { |
|
373 | + echo $upcontext['forced_error_message']; |
|
374 | + } |
|
358 | 375 | |
359 | 376 | // Show the footer. |
360 | - if (!isset($_GET['xml'])) |
|
361 | - template_upgrade_below(); |
|
362 | - else |
|
363 | - template_xml_below(); |
|
377 | + if (!isset($_GET['xml'])) { |
|
378 | + template_upgrade_below(); |
|
379 | + } else { |
|
380 | + template_xml_below(); |
|
381 | + } |
|
364 | 382 | } |
365 | 383 | |
366 | 384 | |
@@ -372,15 +390,19 @@ discard block |
||
372 | 390 | $seconds = intval($active % 60); |
373 | 391 | |
374 | 392 | $totalTime = ''; |
375 | - if ($hours > 0) |
|
376 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
377 | - if ($minutes > 0) |
|
378 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
379 | - if ($seconds > 0) |
|
380 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
393 | + if ($hours > 0) { |
|
394 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
395 | + } |
|
396 | + if ($minutes > 0) { |
|
397 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
398 | + } |
|
399 | + if ($seconds > 0) { |
|
400 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
401 | + } |
|
381 | 402 | |
382 | - if (!empty($totalTime)) |
|
383 | - echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
403 | + if (!empty($totalTime)) { |
|
404 | + echo "\n" . 'Upgrade completed in ' . $totalTime . "\n"; |
|
405 | + } |
|
384 | 406 | } |
385 | 407 | |
386 | 408 | // Bang - gone! |
@@ -393,8 +415,9 @@ discard block |
||
393 | 415 | global $upgradeurl, $upcontext, $command_line; |
394 | 416 | |
395 | 417 | // Command line users can't be redirected. |
396 | - if ($command_line) |
|
397 | - upgradeExit(true); |
|
418 | + if ($command_line) { |
|
419 | + upgradeExit(true); |
|
420 | + } |
|
398 | 421 | |
399 | 422 | // Are we providing the core info? |
400 | 423 | if ($addForm) |
@@ -417,19 +440,22 @@ discard block |
||
417 | 440 | global $modSettings, $sourcedir, $smcFunc; |
418 | 441 | |
419 | 442 | // Do the non-SSI stuff... |
420 | - if (function_exists('set_magic_quotes_runtime')) |
|
421 | - @set_magic_quotes_runtime(0); |
|
443 | + if (function_exists('set_magic_quotes_runtime')) { |
|
444 | + @set_magic_quotes_runtime(0); |
|
445 | + } |
|
422 | 446 | |
423 | 447 | error_reporting(E_ALL); |
424 | 448 | define('SMF', 1); |
425 | 449 | |
426 | 450 | // Start the session. |
427 | - if (@ini_get('session.save_handler') == 'user') |
|
428 | - @ini_set('session.save_handler', 'files'); |
|
451 | + if (@ini_get('session.save_handler') == 'user') { |
|
452 | + @ini_set('session.save_handler', 'files'); |
|
453 | + } |
|
429 | 454 | @session_start(); |
430 | 455 | |
431 | - if (empty($smcFunc)) |
|
432 | - $smcFunc = array(); |
|
456 | + if (empty($smcFunc)) { |
|
457 | + $smcFunc = array(); |
|
458 | + } |
|
433 | 459 | |
434 | 460 | // We need this for authentication and some upgrade code |
435 | 461 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -441,8 +467,9 @@ discard block |
||
441 | 467 | initialize_inputs(); |
442 | 468 | |
443 | 469 | // Get the database going! |
444 | - if (empty($db_type)) |
|
445 | - $db_type = 'mysql'; |
|
470 | + if (empty($db_type)) { |
|
471 | + $db_type = 'mysql'; |
|
472 | + } |
|
446 | 473 | if (file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
447 | 474 | { |
448 | 475 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -451,17 +478,19 @@ discard block |
||
451 | 478 | $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('non_fatal' => true)); |
452 | 479 | |
453 | 480 | // Oh dear god!! |
454 | - if ($db_connection === null) |
|
455 | - die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
481 | + if ($db_connection === null) { |
|
482 | + die('Unable to connect to database - please check username and password are correct in Settings.php'); |
|
483 | + } |
|
456 | 484 | |
457 | - if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) |
|
458 | - $smcFunc['db_query']('', ' |
|
485 | + if ($db_type == 'mysql' && isset($db_character_set) && preg_match('~^\w+$~', $db_character_set) === 1) { |
|
486 | + $smcFunc['db_query']('', ' |
|
459 | 487 | SET NAMES {string:db_character_set}', |
460 | 488 | array( |
461 | 489 | 'db_error_skip' => true, |
462 | 490 | 'db_character_set' => $db_character_set, |
463 | 491 | ) |
464 | 492 | ); |
493 | + } |
|
465 | 494 | |
466 | 495 | // Load the modSettings data... |
467 | 496 | $request = $smcFunc['db_query']('', ' |
@@ -472,11 +501,11 @@ discard block |
||
472 | 501 | ) |
473 | 502 | ); |
474 | 503 | $modSettings = array(); |
475 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
476 | - $modSettings[$row['variable']] = $row['value']; |
|
504 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
505 | + $modSettings[$row['variable']] = $row['value']; |
|
506 | + } |
|
477 | 507 | $smcFunc['db_free_result']($request); |
478 | - } |
|
479 | - else |
|
508 | + } else |
|
480 | 509 | { |
481 | 510 | 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.'); |
482 | 511 | } |
@@ -490,9 +519,10 @@ discard block |
||
490 | 519 | cleanRequest(); |
491 | 520 | } |
492 | 521 | |
493 | - if (!isset($_GET['substep'])) |
|
494 | - $_GET['substep'] = 0; |
|
495 | -} |
|
522 | + if (!isset($_GET['substep'])) { |
|
523 | + $_GET['substep'] = 0; |
|
524 | + } |
|
525 | + } |
|
496 | 526 | |
497 | 527 | function initialize_inputs() |
498 | 528 | { |
@@ -522,8 +552,9 @@ discard block |
||
522 | 552 | $dh = opendir(dirname(__FILE__)); |
523 | 553 | while ($file = readdir($dh)) |
524 | 554 | { |
525 | - if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) |
|
526 | - @unlink(dirname(__FILE__) . '/' . $file); |
|
555 | + if (preg_match('~upgrade_\d-\d_([A-Za-z])+\.sql~i', $file, $matches) && isset($matches[1])) { |
|
556 | + @unlink(dirname(__FILE__) . '/' . $file); |
|
557 | + } |
|
527 | 558 | } |
528 | 559 | closedir($dh); |
529 | 560 | |
@@ -553,8 +584,9 @@ discard block |
||
553 | 584 | { |
554 | 585 | $upcontext['remote_files_available'] = false; |
555 | 586 | $test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1); |
556 | - if ($test) |
|
557 | - $upcontext['remote_files_available'] = true; |
|
587 | + if ($test) { |
|
588 | + $upcontext['remote_files_available'] = true; |
|
589 | + } |
|
558 | 590 | @fclose($test); |
559 | 591 | } |
560 | 592 | |
@@ -562,8 +594,9 @@ discard block |
||
562 | 594 | $temp = 'upgrade_php?step'; |
563 | 595 | while (strlen($temp) > 4) |
564 | 596 | { |
565 | - if (isset($_GET[$temp])) |
|
566 | - unset($_GET[$temp]); |
|
597 | + if (isset($_GET[$temp])) { |
|
598 | + unset($_GET[$temp]); |
|
599 | + } |
|
567 | 600 | $temp = substr($temp, 1); |
568 | 601 | } |
569 | 602 | |
@@ -590,29 +623,36 @@ discard block |
||
590 | 623 | && @file_exists(dirname(__FILE__) . '/upgrade_2-1_' . $db_type . '.sql'); |
591 | 624 | |
592 | 625 | // Need legacy scripts? |
593 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) |
|
594 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
595 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) |
|
596 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
597 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) |
|
598 | - $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
626 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.1) { |
|
627 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_2-0_' . $db_type . '.sql'); |
|
628 | + } |
|
629 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 2.0) { |
|
630 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-1.sql'); |
|
631 | + } |
|
632 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < 1.1) { |
|
633 | + $check &= @file_exists(dirname(__FILE__) . '/upgrade_1-0.sql'); |
|
634 | + } |
|
599 | 635 | |
600 | 636 | // This needs to exist! |
601 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
602 | - 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>]'); |
|
603 | - else |
|
604 | - require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
637 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
638 | + 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>]'); |
|
639 | + } else { |
|
640 | + require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
|
641 | + } |
|
605 | 642 | |
606 | - if (!$check) |
|
607 | - // 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. |
|
643 | + if (!$check) { |
|
644 | + // 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. |
|
608 | 645 | 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.'); |
646 | + } |
|
609 | 647 | |
610 | 648 | // Do they meet the install requirements? |
611 | - if (!php_version_check()) |
|
612 | - 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.'); |
|
649 | + if (!php_version_check()) { |
|
650 | + 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.'); |
|
651 | + } |
|
613 | 652 | |
614 | - if (!db_version_check()) |
|
615 | - 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.'); |
|
653 | + if (!db_version_check()) { |
|
654 | + 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.'); |
|
655 | + } |
|
616 | 656 | |
617 | 657 | // Do some checks to make sure they have proper privileges |
618 | 658 | db_extend('packages'); |
@@ -627,14 +667,16 @@ discard block |
||
627 | 667 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
628 | 668 | |
629 | 669 | // Sorry... we need CREATE, ALTER and DROP |
630 | - if (!$create || !$alter || !$drop) |
|
631 | - 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.'); |
|
670 | + if (!$create || !$alter || !$drop) { |
|
671 | + 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.'); |
|
672 | + } |
|
632 | 673 | |
633 | 674 | // Do a quick version spot check. |
634 | 675 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
635 | 676 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
636 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
637 | - 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.'); |
|
677 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
678 | + 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.'); |
|
679 | + } |
|
638 | 680 | |
639 | 681 | // What absolutely needs to be writable? |
640 | 682 | $writable_files = array( |
@@ -656,12 +698,13 @@ discard block |
||
656 | 698 | quickFileWritable($custom_av_dir); |
657 | 699 | |
658 | 700 | // Are we good now? |
659 | - if (!is_writable($custom_av_dir)) |
|
660 | - 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)); |
|
661 | - elseif ($need_settings_update) |
|
701 | + if (!is_writable($custom_av_dir)) { |
|
702 | + 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)); |
|
703 | + } elseif ($need_settings_update) |
|
662 | 704 | { |
663 | - if (!function_exists('cache_put_data')) |
|
664 | - require_once($sourcedir . '/Load.php'); |
|
705 | + if (!function_exists('cache_put_data')) { |
|
706 | + require_once($sourcedir . '/Load.php'); |
|
707 | + } |
|
665 | 708 | updateSettings(array('custom_avatar_dir' => $custom_av_dir)); |
666 | 709 | updateSettings(array('custom_avatar_url' => $custom_av_url)); |
667 | 710 | } |
@@ -670,28 +713,33 @@ discard block |
||
670 | 713 | |
671 | 714 | // Check the cache directory. |
672 | 715 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
673 | - if (!file_exists($cachedir_temp)) |
|
674 | - @mkdir($cachedir_temp); |
|
675 | - if (!file_exists($cachedir_temp)) |
|
676 | - 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.'); |
|
677 | - |
|
678 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
679 | - 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>.'); |
|
680 | - elseif (!isset($_GET['skiplang'])) |
|
716 | + if (!file_exists($cachedir_temp)) { |
|
717 | + @mkdir($cachedir_temp); |
|
718 | + } |
|
719 | + if (!file_exists($cachedir_temp)) { |
|
720 | + 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.'); |
|
721 | + } |
|
722 | + |
|
723 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
724 | + 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>.'); |
|
725 | + } elseif (!isset($_GET['skiplang'])) |
|
681 | 726 | { |
682 | 727 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
683 | 728 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
684 | 729 | |
685 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
686 | - 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>]'); |
|
730 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
731 | + 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>]'); |
|
732 | + } |
|
687 | 733 | } |
688 | 734 | |
689 | - if (!makeFilesWritable($writable_files)) |
|
690 | - return false; |
|
735 | + if (!makeFilesWritable($writable_files)) { |
|
736 | + return false; |
|
737 | + } |
|
691 | 738 | |
692 | 739 | // Check agreement.txt. (it may not exist, in which case $boarddir must be writable.) |
693 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
694 | - 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.'); |
|
740 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
741 | + 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.'); |
|
742 | + } |
|
695 | 743 | |
696 | 744 | // Upgrade the agreement. |
697 | 745 | elseif (isset($modSettings['agreement'])) |
@@ -702,8 +750,8 @@ discard block |
||
702 | 750 | } |
703 | 751 | |
704 | 752 | // We're going to check that their board dir setting is right in case they've been moving stuff around. |
705 | - if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) |
|
706 | - $upcontext['warning'] = ' |
|
753 | + if (strtr($boarddir, array('/' => '', '\\' => '')) != strtr(dirname(__FILE__), array('/' => '', '\\' => ''))) { |
|
754 | + $upcontext['warning'] = ' |
|
707 | 755 | 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> |
708 | 756 | <ul> |
709 | 757 | <li>Board Directory: ' . $boarddir . '</li> |
@@ -711,10 +759,12 @@ discard block |
||
711 | 759 | <li>Cache Directory: ' . $cachedir_temp . '</li> |
712 | 760 | </ul> |
713 | 761 | 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.'; |
762 | + } |
|
714 | 763 | |
715 | 764 | // Either we're logged in or we're going to present the login. |
716 | - if (checkLogin()) |
|
717 | - return true; |
|
765 | + if (checkLogin()) { |
|
766 | + return true; |
|
767 | + } |
|
718 | 768 | |
719 | 769 | $upcontext += createToken('login'); |
720 | 770 | |
@@ -728,15 +778,17 @@ discard block |
||
728 | 778 | global $smcFunc, $db_type, $support_js; |
729 | 779 | |
730 | 780 | // Don't bother if the security is disabled. |
731 | - if ($disable_security) |
|
732 | - return true; |
|
781 | + if ($disable_security) { |
|
782 | + return true; |
|
783 | + } |
|
733 | 784 | |
734 | 785 | // Are we trying to login? |
735 | 786 | if (isset($_POST['contbutt']) && (!empty($_POST['user']))) |
736 | 787 | { |
737 | 788 | // If we've disabled security pick a suitable name! |
738 | - if (empty($_POST['user'])) |
|
739 | - $_POST['user'] = 'Administrator'; |
|
789 | + if (empty($_POST['user'])) { |
|
790 | + $_POST['user'] = 'Administrator'; |
|
791 | + } |
|
740 | 792 | |
741 | 793 | // Before 2.0 these column names were different! |
742 | 794 | $oldDB = false; |
@@ -751,16 +803,17 @@ discard block |
||
751 | 803 | 'db_error_skip' => true, |
752 | 804 | ) |
753 | 805 | ); |
754 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
755 | - $oldDB = true; |
|
806 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
807 | + $oldDB = true; |
|
808 | + } |
|
756 | 809 | $smcFunc['db_free_result']($request); |
757 | 810 | } |
758 | 811 | |
759 | 812 | // Get what we believe to be their details. |
760 | 813 | if (!$disable_security) |
761 | 814 | { |
762 | - if ($oldDB) |
|
763 | - $request = $smcFunc['db_query']('', ' |
|
815 | + if ($oldDB) { |
|
816 | + $request = $smcFunc['db_query']('', ' |
|
764 | 817 | SELECT id_member, memberName AS member_name, passwd, id_group, |
765 | 818 | additionalGroups AS additional_groups, lngfile |
766 | 819 | FROM {db_prefix}members |
@@ -770,8 +823,8 @@ discard block |
||
770 | 823 | 'db_error_skip' => true, |
771 | 824 | ) |
772 | 825 | ); |
773 | - else |
|
774 | - $request = $smcFunc['db_query']('', ' |
|
826 | + } else { |
|
827 | + $request = $smcFunc['db_query']('', ' |
|
775 | 828 | SELECT id_member, member_name, passwd, id_group, additional_groups, lngfile |
776 | 829 | FROM {db_prefix}members |
777 | 830 | WHERE member_name = {string:member_name}', |
@@ -780,6 +833,7 @@ discard block |
||
780 | 833 | 'db_error_skip' => true, |
781 | 834 | ) |
782 | 835 | ); |
836 | + } |
|
783 | 837 | if ($smcFunc['db_num_rows']($request) != 0) |
784 | 838 | { |
785 | 839 | list ($id_member, $name, $password, $id_group, $addGroups, $user_language) = $smcFunc['db_fetch_row']($request); |
@@ -787,13 +841,14 @@ discard block |
||
787 | 841 | $groups = explode(',', $addGroups); |
788 | 842 | $groups[] = $id_group; |
789 | 843 | |
790 | - foreach ($groups as $k => $v) |
|
791 | - $groups[$k] = (int) $v; |
|
844 | + foreach ($groups as $k => $v) { |
|
845 | + $groups[$k] = (int) $v; |
|
846 | + } |
|
792 | 847 | |
793 | 848 | $sha_passwd = sha1(strtolower($name) . un_htmlspecialchars($_REQUEST['passwrd'])); |
849 | + } else { |
|
850 | + $upcontext['username_incorrect'] = true; |
|
794 | 851 | } |
795 | - else |
|
796 | - $upcontext['username_incorrect'] = true; |
|
797 | 852 | $smcFunc['db_free_result']($request); |
798 | 853 | } |
799 | 854 | $upcontext['username'] = $_POST['user']; |
@@ -803,13 +858,14 @@ discard block |
||
803 | 858 | { |
804 | 859 | $upcontext['upgrade_status']['js'] = 1; |
805 | 860 | $support_js = 1; |
861 | + } else { |
|
862 | + $support_js = 0; |
|
806 | 863 | } |
807 | - else |
|
808 | - $support_js = 0; |
|
809 | 864 | |
810 | 865 | // Note down the version we are coming from. |
811 | - if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) |
|
812 | - $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
866 | + if (!empty($modSettings['smfVersion']) && empty($upcontext['user']['version'])) { |
|
867 | + $upcontext['user']['version'] = $modSettings['smfVersion']; |
|
868 | + } |
|
813 | 869 | |
814 | 870 | // Didn't get anywhere? |
815 | 871 | 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'])) |
@@ -843,15 +899,15 @@ discard block |
||
843 | 899 | 'db_error_skip' => true, |
844 | 900 | ) |
845 | 901 | ); |
846 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
847 | - return throw_error('You need to be an admin to perform an upgrade!'); |
|
902 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
903 | + return throw_error('You need to be an admin to perform an upgrade!'); |
|
904 | + } |
|
848 | 905 | $smcFunc['db_free_result']($request); |
849 | 906 | } |
850 | 907 | |
851 | 908 | $upcontext['user']['id'] = $id_member; |
852 | 909 | $upcontext['user']['name'] = $name; |
853 | - } |
|
854 | - else |
|
910 | + } else |
|
855 | 911 | { |
856 | 912 | $upcontext['user']['id'] = 1; |
857 | 913 | $upcontext['user']['name'] = 'Administrator'; |
@@ -867,11 +923,11 @@ discard block |
||
867 | 923 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $user_language . '.php')), 0, 4096); |
868 | 924 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
869 | 925 | |
870 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
871 | - $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'] . '.'; |
|
872 | - elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) |
|
873 | - $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'] . '.'; |
|
874 | - else |
|
926 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
927 | + $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'] . '.'; |
|
928 | + } elseif (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . basename($user_language, '.lng') . '.php')) { |
|
929 | + $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'] . '.'; |
|
930 | + } else |
|
875 | 931 | { |
876 | 932 | // Set this as the new language. |
877 | 933 | $upcontext['language'] = $user_language; |
@@ -915,8 +971,9 @@ discard block |
||
915 | 971 | unset($member_columns); |
916 | 972 | |
917 | 973 | // If we've not submitted then we're done. |
918 | - if (empty($_POST['upcont'])) |
|
919 | - return false; |
|
974 | + if (empty($_POST['upcont'])) { |
|
975 | + return false; |
|
976 | + } |
|
920 | 977 | |
921 | 978 | // Firstly, if they're enabling SM stat collection just do it. |
922 | 979 | if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats'])) |
@@ -931,25 +988,26 @@ discard block |
||
931 | 988 | fwrite($fp, $out); |
932 | 989 | |
933 | 990 | $return_data = ''; |
934 | - while (!feof($fp)) |
|
935 | - $return_data .= fgets($fp, 128); |
|
991 | + while (!feof($fp)) { |
|
992 | + $return_data .= fgets($fp, 128); |
|
993 | + } |
|
936 | 994 | |
937 | 995 | fclose($fp); |
938 | 996 | |
939 | 997 | // Get the unique site ID. |
940 | 998 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
941 | 999 | |
942 | - if (!empty($ID[1])) |
|
943 | - $smcFunc['db_insert']('replace', |
|
1000 | + if (!empty($ID[1])) { |
|
1001 | + $smcFunc['db_insert']('replace', |
|
944 | 1002 | $db_prefix . 'settings', |
945 | 1003 | array('variable' => 'string', 'value' => 'string'), |
946 | 1004 | array('allow_sm_stats', $ID[1]), |
947 | 1005 | array('variable') |
948 | 1006 | ); |
1007 | + } |
|
949 | 1008 | } |
950 | - } |
|
951 | - else |
|
952 | - $smcFunc['db_query']('', ' |
|
1009 | + } else { |
|
1010 | + $smcFunc['db_query']('', ' |
|
953 | 1011 | DELETE FROM {db_prefix}settings |
954 | 1012 | WHERE variable = {string:allow_sm_stats}', |
955 | 1013 | array( |
@@ -957,6 +1015,7 @@ discard block |
||
957 | 1015 | 'db_error_skip' => true, |
958 | 1016 | ) |
959 | 1017 | ); |
1018 | + } |
|
960 | 1019 | |
961 | 1020 | // Deleting old karma stuff? |
962 | 1021 | if (!empty($_POST['delete_karma'])) |
@@ -971,20 +1030,22 @@ discard block |
||
971 | 1030 | ); |
972 | 1031 | |
973 | 1032 | // Cleaning up old karma member settings. |
974 | - if ($upcontext['karma_installed']['good']) |
|
975 | - $smcFunc['db_query']('', ' |
|
1033 | + if ($upcontext['karma_installed']['good']) { |
|
1034 | + $smcFunc['db_query']('', ' |
|
976 | 1035 | ALTER TABLE {db_prefix}members |
977 | 1036 | DROP karma_good', |
978 | 1037 | array() |
979 | 1038 | ); |
1039 | + } |
|
980 | 1040 | |
981 | 1041 | // Does karma bad was enable? |
982 | - if ($upcontext['karma_installed']['bad']) |
|
983 | - $smcFunc['db_query']('', ' |
|
1042 | + if ($upcontext['karma_installed']['bad']) { |
|
1043 | + $smcFunc['db_query']('', ' |
|
984 | 1044 | ALTER TABLE {db_prefix}members |
985 | 1045 | DROP karma_bad', |
986 | 1046 | array() |
987 | 1047 | ); |
1048 | + } |
|
988 | 1049 | |
989 | 1050 | // Cleaning up old karma permissions. |
990 | 1051 | $smcFunc['db_query']('', ' |
@@ -997,26 +1058,29 @@ discard block |
||
997 | 1058 | } |
998 | 1059 | |
999 | 1060 | // Emptying the error log? |
1000 | - if (!empty($_POST['empty_error'])) |
|
1001 | - $smcFunc['db_query']('truncate_table', ' |
|
1061 | + if (!empty($_POST['empty_error'])) { |
|
1062 | + $smcFunc['db_query']('truncate_table', ' |
|
1002 | 1063 | TRUNCATE {db_prefix}log_errors', |
1003 | 1064 | array( |
1004 | 1065 | ) |
1005 | 1066 | ); |
1067 | + } |
|
1006 | 1068 | |
1007 | 1069 | $changes = array(); |
1008 | 1070 | |
1009 | 1071 | // Add proxy settings. |
1010 | - if (!isset($GLOBALS['image_proxy_maxsize'])) |
|
1011 | - $changes += array( |
|
1072 | + if (!isset($GLOBALS['image_proxy_maxsize'])) { |
|
1073 | + $changes += array( |
|
1012 | 1074 | 'image_proxy_secret' => substr(sha1(mt_rand()), 0, 20), |
1013 | 1075 | 'image_proxy_maxsize' => 5190, |
1014 | 1076 | 'image_proxy_enabled' => 0, |
1015 | 1077 | ); |
1078 | + } |
|
1016 | 1079 | |
1017 | 1080 | // If we're overriding the language follow it through. |
1018 | - if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) |
|
1019 | - $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1081 | + if (isset($_GET['lang']) && file_exists($modSettings['theme_dir'] . '/languages/index.' . $_GET['lang'] . '.php')) { |
|
1082 | + $changes['language'] = '\'' . $_GET['lang'] . '\''; |
|
1083 | + } |
|
1020 | 1084 | |
1021 | 1085 | if (!empty($_POST['maint'])) |
1022 | 1086 | { |
@@ -1028,30 +1092,34 @@ discard block |
||
1028 | 1092 | { |
1029 | 1093 | $changes['mtitle'] = '\'' . addslashes($_POST['maintitle']) . '\''; |
1030 | 1094 | $changes['mmessage'] = '\'' . addslashes($_POST['mainmessage']) . '\''; |
1031 | - } |
|
1032 | - else |
|
1095 | + } else |
|
1033 | 1096 | { |
1034 | 1097 | $changes['mtitle'] = '\'Upgrading the forum...\''; |
1035 | 1098 | $changes['mmessage'] = '\'Don\\\'t worry, we will be back shortly with an updated forum. It will only be a minute ;).\''; |
1036 | 1099 | } |
1037 | 1100 | } |
1038 | 1101 | |
1039 | - if ($command_line) |
|
1040 | - echo ' * Updating Settings.php...'; |
|
1102 | + if ($command_line) { |
|
1103 | + echo ' * Updating Settings.php...'; |
|
1104 | + } |
|
1041 | 1105 | |
1042 | 1106 | // Fix some old paths. |
1043 | - if (substr($boarddir, 0, 1) == '.') |
|
1044 | - $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1107 | + if (substr($boarddir, 0, 1) == '.') { |
|
1108 | + $changes['boarddir'] = '\'' . fixRelativePath($boarddir) . '\''; |
|
1109 | + } |
|
1045 | 1110 | |
1046 | - if (substr($sourcedir, 0, 1) == '.') |
|
1047 | - $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1111 | + if (substr($sourcedir, 0, 1) == '.') { |
|
1112 | + $changes['sourcedir'] = '\'' . fixRelativePath($sourcedir) . '\''; |
|
1113 | + } |
|
1048 | 1114 | |
1049 | - if (empty($cachedir) || substr($cachedir, 0, 1) == '.') |
|
1050 | - $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1115 | + if (empty($cachedir) || substr($cachedir, 0, 1) == '.') { |
|
1116 | + $changes['cachedir'] = '\'' . fixRelativePath($boarddir) . '/cache\''; |
|
1117 | + } |
|
1051 | 1118 | |
1052 | 1119 | // Not had the database type added before? |
1053 | - if (empty($db_type)) |
|
1054 | - $changes['db_type'] = 'mysql'; |
|
1120 | + if (empty($db_type)) { |
|
1121 | + $changes['db_type'] = 'mysql'; |
|
1122 | + } |
|
1055 | 1123 | |
1056 | 1124 | // If they have a "host:port" setup for the host, split that into separate values |
1057 | 1125 | // You should never have a : in the hostname if you're not on MySQL, but better safe than sorry |
@@ -1062,28 +1130,31 @@ discard block |
||
1062 | 1130 | $changes['db_server'] = '\'' . $db_server . '\''; |
1063 | 1131 | |
1064 | 1132 | // Only set this if we're not using the default port |
1065 | - if ($db_port != ini_get('mysqli.default_port')) |
|
1066 | - $changes['db_port'] = (int) $db_port; |
|
1067 | - } |
|
1068 | - elseif (!empty($db_port)) |
|
1133 | + if ($db_port != ini_get('mysqli.default_port')) { |
|
1134 | + $changes['db_port'] = (int) $db_port; |
|
1135 | + } |
|
1136 | + } elseif (!empty($db_port)) |
|
1069 | 1137 | { |
1070 | 1138 | // If db_port is set and is the same as the default, set it to '' |
1071 | 1139 | if ($db_type == 'mysql') |
1072 | 1140 | { |
1073 | - if ($db_port == ini_get('mysqli.default_port')) |
|
1074 | - $changes['db_port'] = '\'\''; |
|
1075 | - elseif ($db_type == 'postgresql' && $db_port == 5432) |
|
1076 | - $changes['db_port'] = '\'\''; |
|
1141 | + if ($db_port == ini_get('mysqli.default_port')) { |
|
1142 | + $changes['db_port'] = '\'\''; |
|
1143 | + } elseif ($db_type == 'postgresql' && $db_port == 5432) { |
|
1144 | + $changes['db_port'] = '\'\''; |
|
1145 | + } |
|
1077 | 1146 | } |
1078 | 1147 | } |
1079 | 1148 | |
1080 | 1149 | // Maybe we haven't had this option yet? |
1081 | - if (empty($packagesdir)) |
|
1082 | - $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1150 | + if (empty($packagesdir)) { |
|
1151 | + $changes['packagesdir'] = '\'' . fixRelativePath($boarddir) . '/Packages\''; |
|
1152 | + } |
|
1083 | 1153 | |
1084 | 1154 | // Add support for $tasksdir var. |
1085 | - if (empty($tasksdir)) |
|
1086 | - $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1155 | + if (empty($tasksdir)) { |
|
1156 | + $changes['tasksdir'] = '\'' . fixRelativePath($sourcedir) . '/tasks\''; |
|
1157 | + } |
|
1087 | 1158 | |
1088 | 1159 | // @todo Maybe change the cookie name if going to 1.1, too? |
1089 | 1160 | |
@@ -1091,8 +1162,9 @@ discard block |
||
1091 | 1162 | require_once($sourcedir . '/Subs-Admin.php'); |
1092 | 1163 | updateSettingsFile($changes); |
1093 | 1164 | |
1094 | - if ($command_line) |
|
1095 | - echo ' Successful.' . "\n"; |
|
1165 | + if ($command_line) { |
|
1166 | + echo ' Successful.' . "\n"; |
|
1167 | + } |
|
1096 | 1168 | |
1097 | 1169 | // Are we doing debug? |
1098 | 1170 | if (isset($_POST['debug'])) |
@@ -1102,8 +1174,9 @@ discard block |
||
1102 | 1174 | } |
1103 | 1175 | |
1104 | 1176 | // If we're not backing up then jump one. |
1105 | - if (empty($_POST['backup'])) |
|
1106 | - $upcontext['current_step']++; |
|
1177 | + if (empty($_POST['backup'])) { |
|
1178 | + $upcontext['current_step']++; |
|
1179 | + } |
|
1107 | 1180 | |
1108 | 1181 | // If we've got here then let's proceed to the next step! |
1109 | 1182 | return true; |
@@ -1118,8 +1191,9 @@ discard block |
||
1118 | 1191 | $upcontext['page_title'] = 'Backup Database'; |
1119 | 1192 | |
1120 | 1193 | // Done it already - js wise? |
1121 | - if (!empty($_POST['backup_done'])) |
|
1122 | - return true; |
|
1194 | + if (!empty($_POST['backup_done'])) { |
|
1195 | + return true; |
|
1196 | + } |
|
1123 | 1197 | |
1124 | 1198 | // Some useful stuff here. |
1125 | 1199 | db_extend(); |
@@ -1133,9 +1207,10 @@ discard block |
||
1133 | 1207 | $tables = $smcFunc['db_list_tables']($db, $filter); |
1134 | 1208 | |
1135 | 1209 | $table_names = array(); |
1136 | - foreach ($tables as $table) |
|
1137 | - if (substr($table, 0, 7) !== 'backup_') |
|
1210 | + foreach ($tables as $table) { |
|
1211 | + if (substr($table, 0, 7) !== 'backup_') |
|
1138 | 1212 | $table_names[] = $table; |
1213 | + } |
|
1139 | 1214 | |
1140 | 1215 | $upcontext['table_count'] = count($table_names); |
1141 | 1216 | $upcontext['cur_table_num'] = $_GET['substep']; |
@@ -1145,12 +1220,14 @@ discard block |
||
1145 | 1220 | $file_steps = $upcontext['table_count']; |
1146 | 1221 | |
1147 | 1222 | // What ones have we already done? |
1148 | - foreach ($table_names as $id => $table) |
|
1149 | - if ($id < $_GET['substep']) |
|
1223 | + foreach ($table_names as $id => $table) { |
|
1224 | + if ($id < $_GET['substep']) |
|
1150 | 1225 | $upcontext['previous_tables'][] = $table; |
1226 | + } |
|
1151 | 1227 | |
1152 | - if ($command_line) |
|
1153 | - echo 'Backing Up Tables.'; |
|
1228 | + if ($command_line) { |
|
1229 | + echo 'Backing Up Tables.'; |
|
1230 | + } |
|
1154 | 1231 | |
1155 | 1232 | // If we don't support javascript we backup here. |
1156 | 1233 | if (!$support_js || isset($_GET['xml'])) |
@@ -1169,8 +1246,9 @@ discard block |
||
1169 | 1246 | backupTable($table_names[$substep]); |
1170 | 1247 | |
1171 | 1248 | // If this is XML to keep it nice for the user do one table at a time anyway! |
1172 | - if (isset($_GET['xml'])) |
|
1173 | - return upgradeExit(); |
|
1249 | + if (isset($_GET['xml'])) { |
|
1250 | + return upgradeExit(); |
|
1251 | + } |
|
1174 | 1252 | } |
1175 | 1253 | |
1176 | 1254 | if ($command_line) |
@@ -1203,9 +1281,10 @@ discard block |
||
1203 | 1281 | |
1204 | 1282 | $smcFunc['db_backup_table']($table, 'backup_' . $table); |
1205 | 1283 | |
1206 | - if ($command_line) |
|
1207 | - echo ' done.'; |
|
1208 | -} |
|
1284 | + if ($command_line) { |
|
1285 | + echo ' done.'; |
|
1286 | + } |
|
1287 | + } |
|
1209 | 1288 | |
1210 | 1289 | // Step 2: Everything. |
1211 | 1290 | function DatabaseChanges() |
@@ -1214,8 +1293,9 @@ discard block |
||
1214 | 1293 | global $upcontext, $support_js, $db_type; |
1215 | 1294 | |
1216 | 1295 | // Have we just completed this? |
1217 | - if (!empty($_POST['database_done'])) |
|
1218 | - return true; |
|
1296 | + if (!empty($_POST['database_done'])) { |
|
1297 | + return true; |
|
1298 | + } |
|
1219 | 1299 | |
1220 | 1300 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'database_xml' : 'database_changes'; |
1221 | 1301 | $upcontext['page_title'] = 'Database Changes'; |
@@ -1230,15 +1310,16 @@ discard block |
||
1230 | 1310 | ); |
1231 | 1311 | |
1232 | 1312 | // How many files are there in total? |
1233 | - if (isset($_GET['filecount'])) |
|
1234 | - $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1235 | - else |
|
1313 | + if (isset($_GET['filecount'])) { |
|
1314 | + $upcontext['file_count'] = (int) $_GET['filecount']; |
|
1315 | + } else |
|
1236 | 1316 | { |
1237 | 1317 | $upcontext['file_count'] = 0; |
1238 | 1318 | foreach ($files as $file) |
1239 | 1319 | { |
1240 | - if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) |
|
1241 | - $upcontext['file_count']++; |
|
1320 | + if (!isset($modSettings['smfVersion']) || $modSettings['smfVersion'] < $file[1]) { |
|
1321 | + $upcontext['file_count']++; |
|
1322 | + } |
|
1242 | 1323 | } |
1243 | 1324 | } |
1244 | 1325 | |
@@ -1248,9 +1329,9 @@ discard block |
||
1248 | 1329 | $upcontext['cur_file_num'] = 0; |
1249 | 1330 | foreach ($files as $file) |
1250 | 1331 | { |
1251 | - if ($did_not_do) |
|
1252 | - $did_not_do--; |
|
1253 | - else |
|
1332 | + if ($did_not_do) { |
|
1333 | + $did_not_do--; |
|
1334 | + } else |
|
1254 | 1335 | { |
1255 | 1336 | $upcontext['cur_file_num']++; |
1256 | 1337 | $upcontext['cur_file_name'] = $file[0]; |
@@ -1277,12 +1358,13 @@ discard block |
||
1277 | 1358 | // Flag to move on to the next. |
1278 | 1359 | $upcontext['completed_step'] = true; |
1279 | 1360 | // Did we complete the whole file? |
1280 | - if ($nextFile) |
|
1281 | - $upcontext['current_debug_item_num'] = -1; |
|
1361 | + if ($nextFile) { |
|
1362 | + $upcontext['current_debug_item_num'] = -1; |
|
1363 | + } |
|
1282 | 1364 | return upgradeExit(); |
1365 | + } elseif ($support_js) { |
|
1366 | + break; |
|
1283 | 1367 | } |
1284 | - elseif ($support_js) |
|
1285 | - break; |
|
1286 | 1368 | } |
1287 | 1369 | // Set the progress bar to be right as if we had - even if we hadn't... |
1288 | 1370 | $upcontext['step_progress'] = ($upcontext['cur_file_num'] / $upcontext['file_count']) * 100; |
@@ -1307,8 +1389,9 @@ discard block |
||
1307 | 1389 | global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; |
1308 | 1390 | |
1309 | 1391 | // Now it's nice to have some of the basic SMF source files. |
1310 | - if (!isset($_GET['ssi']) && !$command_line) |
|
1311 | - redirectLocation('&ssi=1'); |
|
1392 | + if (!isset($_GET['ssi']) && !$command_line) { |
|
1393 | + redirectLocation('&ssi=1'); |
|
1394 | + } |
|
1312 | 1395 | |
1313 | 1396 | $upcontext['sub_template'] = 'upgrade_complete'; |
1314 | 1397 | $upcontext['page_title'] = 'Upgrade Complete'; |
@@ -1324,14 +1407,16 @@ discard block |
||
1324 | 1407 | // Are we in maintenance mode? |
1325 | 1408 | if (isset($upcontext['user']['main'])) |
1326 | 1409 | { |
1327 | - if ($command_line) |
|
1328 | - echo ' * '; |
|
1410 | + if ($command_line) { |
|
1411 | + echo ' * '; |
|
1412 | + } |
|
1329 | 1413 | $upcontext['removed_maintenance'] = true; |
1330 | 1414 | $changes['maintenance'] = $upcontext['user']['main']; |
1331 | 1415 | } |
1332 | 1416 | // Otherwise if somehow we are in 2 let's go to 1. |
1333 | - elseif (!empty($maintenance) && $maintenance == 2) |
|
1334 | - $changes['maintenance'] = 1; |
|
1417 | + elseif (!empty($maintenance) && $maintenance == 2) { |
|
1418 | + $changes['maintenance'] = 1; |
|
1419 | + } |
|
1335 | 1420 | |
1336 | 1421 | // Wipe this out... |
1337 | 1422 | $upcontext['user'] = array(); |
@@ -1346,9 +1431,9 @@ discard block |
||
1346 | 1431 | $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); |
1347 | 1432 | |
1348 | 1433 | // Now is the perfect time to fetch the SM files. |
1349 | - if ($command_line) |
|
1350 | - cli_scheduled_fetchSMfiles(); |
|
1351 | - else |
|
1434 | + if ($command_line) { |
|
1435 | + cli_scheduled_fetchSMfiles(); |
|
1436 | + } else |
|
1352 | 1437 | { |
1353 | 1438 | require_once($sourcedir . '/ScheduledTasks.php'); |
1354 | 1439 | $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. |
@@ -1356,8 +1441,9 @@ discard block |
||
1356 | 1441 | } |
1357 | 1442 | |
1358 | 1443 | // Log what we've done. |
1359 | - if (empty($user_info['id'])) |
|
1360 | - $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1444 | + if (empty($user_info['id'])) { |
|
1445 | + $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; |
|
1446 | + } |
|
1361 | 1447 | |
1362 | 1448 | // Log the action manually, so CLI still works. |
1363 | 1449 | $smcFunc['db_insert']('', |
@@ -1376,8 +1462,9 @@ discard block |
||
1376 | 1462 | |
1377 | 1463 | // Save the current database version. |
1378 | 1464 | $server_version = $smcFunc['db_server_info'](); |
1379 | - if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1380 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1465 | + if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1466 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1467 | + } |
|
1381 | 1468 | |
1382 | 1469 | if ($command_line) |
1383 | 1470 | { |
@@ -1389,8 +1476,9 @@ discard block |
||
1389 | 1476 | |
1390 | 1477 | // Make sure it says we're done. |
1391 | 1478 | $upcontext['overall_percent'] = 100; |
1392 | - if (isset($upcontext['step_progress'])) |
|
1393 | - unset($upcontext['step_progress']); |
|
1479 | + if (isset($upcontext['step_progress'])) { |
|
1480 | + unset($upcontext['step_progress']); |
|
1481 | + } |
|
1394 | 1482 | |
1395 | 1483 | $_GET['substep'] = 0; |
1396 | 1484 | return false; |
@@ -1401,8 +1489,9 @@ discard block |
||
1401 | 1489 | { |
1402 | 1490 | global $sourcedir, $language, $forum_version, $modSettings, $smcFunc; |
1403 | 1491 | |
1404 | - if (empty($modSettings['time_format'])) |
|
1405 | - $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1492 | + if (empty($modSettings['time_format'])) { |
|
1493 | + $modSettings['time_format'] = '%B %d, %Y, %I:%M:%S %p'; |
|
1494 | + } |
|
1406 | 1495 | |
1407 | 1496 | // What files do we want to get |
1408 | 1497 | $request = $smcFunc['db_query']('', ' |
@@ -1436,8 +1525,9 @@ discard block |
||
1436 | 1525 | $file_data = fetch_web_data($url); |
1437 | 1526 | |
1438 | 1527 | // If we got an error - give up - the site might be down. |
1439 | - if ($file_data === false) |
|
1440 | - return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1528 | + if ($file_data === false) { |
|
1529 | + return throw_error(sprintf('Could not retrieve the file %1$s.', $url)); |
|
1530 | + } |
|
1441 | 1531 | |
1442 | 1532 | // Save the file to the database. |
1443 | 1533 | $smcFunc['db_query']('substring', ' |
@@ -1479,8 +1569,9 @@ discard block |
||
1479 | 1569 | $themeData = array(); |
1480 | 1570 | foreach ($values as $variable => $value) |
1481 | 1571 | { |
1482 | - if (!isset($value) || $value === null) |
|
1483 | - $value = 0; |
|
1572 | + if (!isset($value) || $value === null) { |
|
1573 | + $value = 0; |
|
1574 | + } |
|
1484 | 1575 | |
1485 | 1576 | $themeData[] = array(0, 1, $variable, $value); |
1486 | 1577 | } |
@@ -1509,8 +1600,9 @@ discard block |
||
1509 | 1600 | |
1510 | 1601 | foreach ($values as $variable => $value) |
1511 | 1602 | { |
1512 | - if (empty($modSettings[$value[0]])) |
|
1513 | - continue; |
|
1603 | + if (empty($modSettings[$value[0]])) { |
|
1604 | + continue; |
|
1605 | + } |
|
1514 | 1606 | |
1515 | 1607 | $smcFunc['db_query']('', ' |
1516 | 1608 | INSERT IGNORE INTO {db_prefix}themes |
@@ -1596,10 +1688,11 @@ discard block |
||
1596 | 1688 | set_error_handler( |
1597 | 1689 | function ($errno, $errstr, $errfile, $errline) use ($support_js) |
1598 | 1690 | { |
1599 | - if ($support_js) |
|
1600 | - return true; |
|
1601 | - else |
|
1602 | - echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1691 | + if ($support_js) { |
|
1692 | + return true; |
|
1693 | + } else { |
|
1694 | + echo 'Error: ' . $errstr . ' File: ' . $errfile . ' Line: ' . $errline; |
|
1695 | + } |
|
1603 | 1696 | } |
1604 | 1697 | ); |
1605 | 1698 | |
@@ -1614,8 +1707,9 @@ discard block |
||
1614 | 1707 | 'db_error_skip' => true, |
1615 | 1708 | ) |
1616 | 1709 | ); |
1617 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1618 | - die('Unable to find members table!'); |
|
1710 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1711 | + die('Unable to find members table!'); |
|
1712 | + } |
|
1619 | 1713 | $table_status = $smcFunc['db_fetch_assoc']($request); |
1620 | 1714 | $smcFunc['db_free_result']($request); |
1621 | 1715 | |
@@ -1630,17 +1724,20 @@ discard block |
||
1630 | 1724 | ) |
1631 | 1725 | ); |
1632 | 1726 | // Got something? |
1633 | - if ($smcFunc['db_num_rows']($request) !== 0) |
|
1634 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
1727 | + if ($smcFunc['db_num_rows']($request) !== 0) { |
|
1728 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
1729 | + } |
|
1635 | 1730 | $smcFunc['db_free_result']($request); |
1636 | 1731 | |
1637 | 1732 | // Excellent! |
1638 | - if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) |
|
1639 | - $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
1733 | + if (!empty($collation_info['Collation']) && !empty($collation_info['Charset'])) { |
|
1734 | + $db_collation = ' CHARACTER SET ' . $collation_info['Charset'] . ' COLLATE ' . $collation_info['Collation']; |
|
1735 | + } |
|
1640 | 1736 | } |
1641 | 1737 | } |
1642 | - if (empty($db_collation)) |
|
1643 | - $db_collation = ''; |
|
1738 | + if (empty($db_collation)) { |
|
1739 | + $db_collation = ''; |
|
1740 | + } |
|
1644 | 1741 | |
1645 | 1742 | $endl = $command_line ? "\n" : '<br>' . "\n"; |
1646 | 1743 | |
@@ -1652,8 +1749,9 @@ discard block |
||
1652 | 1749 | $last_step = ''; |
1653 | 1750 | |
1654 | 1751 | // Make sure all newly created tables will have the proper characters set. |
1655 | - if (isset($db_character_set) && $db_character_set === 'utf8') |
|
1656 | - $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1752 | + if (isset($db_character_set) && $db_character_set === 'utf8') { |
|
1753 | + $lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines); |
|
1754 | + } |
|
1657 | 1755 | |
1658 | 1756 | // Count the total number of steps within this file - for progress. |
1659 | 1757 | $file_steps = substr_count(implode('', $lines), '---#'); |
@@ -1673,15 +1771,18 @@ discard block |
||
1673 | 1771 | $do_current = $substep >= $_GET['substep']; |
1674 | 1772 | |
1675 | 1773 | // Get rid of any comments in the beginning of the line... |
1676 | - if (substr(trim($line), 0, 2) === '/*') |
|
1677 | - $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1774 | + if (substr(trim($line), 0, 2) === '/*') { |
|
1775 | + $line = preg_replace('~/\*.+?\*/~', '', $line); |
|
1776 | + } |
|
1678 | 1777 | |
1679 | 1778 | // Always flush. Flush, flush, flush. Flush, flush, flush, flush! FLUSH! |
1680 | - if ($is_debug && !$support_js && $command_line) |
|
1681 | - flush(); |
|
1779 | + if ($is_debug && !$support_js && $command_line) { |
|
1780 | + flush(); |
|
1781 | + } |
|
1682 | 1782 | |
1683 | - if (trim($line) === '') |
|
1684 | - continue; |
|
1783 | + if (trim($line) === '') { |
|
1784 | + continue; |
|
1785 | + } |
|
1685 | 1786 | |
1686 | 1787 | if (trim(substr($line, 0, 3)) === '---') |
1687 | 1788 | { |
@@ -1691,8 +1792,9 @@ discard block |
||
1691 | 1792 | if (trim($current_data) != '' && $type !== '}') |
1692 | 1793 | { |
1693 | 1794 | $upcontext['error_message'] = 'Error in upgrade script - line ' . $line_number . '!' . $endl; |
1694 | - if ($command_line) |
|
1695 | - echo $upcontext['error_message']; |
|
1795 | + if ($command_line) { |
|
1796 | + echo $upcontext['error_message']; |
|
1797 | + } |
|
1696 | 1798 | } |
1697 | 1799 | |
1698 | 1800 | if ($type == ' ') |
@@ -1710,17 +1812,18 @@ discard block |
||
1710 | 1812 | if ($do_current) |
1711 | 1813 | { |
1712 | 1814 | $upcontext['actioned_items'][] = $last_step; |
1713 | - if ($command_line) |
|
1714 | - echo ' * '; |
|
1815 | + if ($command_line) { |
|
1816 | + echo ' * '; |
|
1817 | + } |
|
1715 | 1818 | } |
1716 | - } |
|
1717 | - elseif ($type == '#') |
|
1819 | + } elseif ($type == '#') |
|
1718 | 1820 | { |
1719 | 1821 | $upcontext['step_progress'] += (100 / $upcontext['file_count']) / $file_steps; |
1720 | 1822 | |
1721 | 1823 | $upcontext['current_debug_item_num']++; |
1722 | - if (trim($line) != '---#') |
|
1723 | - $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1824 | + if (trim($line) != '---#') { |
|
1825 | + $upcontext['current_debug_item_name'] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1826 | + } |
|
1724 | 1827 | |
1725 | 1828 | // Have we already done something? |
1726 | 1829 | if (isset($_GET['xml']) && $done_something) |
@@ -1731,34 +1834,36 @@ discard block |
||
1731 | 1834 | |
1732 | 1835 | if ($do_current) |
1733 | 1836 | { |
1734 | - if (trim($line) == '---#' && $command_line) |
|
1735 | - echo ' done.', $endl; |
|
1736 | - elseif ($command_line) |
|
1737 | - echo ' +++ ', rtrim(substr($line, 4)); |
|
1738 | - elseif (trim($line) != '---#') |
|
1837 | + if (trim($line) == '---#' && $command_line) { |
|
1838 | + echo ' done.', $endl; |
|
1839 | + } elseif ($command_line) { |
|
1840 | + echo ' +++ ', rtrim(substr($line, 4)); |
|
1841 | + } elseif (trim($line) != '---#') |
|
1739 | 1842 | { |
1740 | - if ($is_debug) |
|
1741 | - $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1843 | + if ($is_debug) { |
|
1844 | + $upcontext['actioned_items'][] = htmlspecialchars(rtrim(substr($line, 4))); |
|
1845 | + } |
|
1742 | 1846 | } |
1743 | 1847 | } |
1744 | 1848 | |
1745 | 1849 | if ($substep < $_GET['substep'] && $substep + 1 >= $_GET['substep']) |
1746 | 1850 | { |
1747 | - if ($command_line) |
|
1748 | - echo ' * '; |
|
1749 | - else |
|
1750 | - $upcontext['actioned_items'][] = $last_step; |
|
1851 | + if ($command_line) { |
|
1852 | + echo ' * '; |
|
1853 | + } else { |
|
1854 | + $upcontext['actioned_items'][] = $last_step; |
|
1855 | + } |
|
1751 | 1856 | } |
1752 | 1857 | |
1753 | 1858 | // Small step - only if we're actually doing stuff. |
1754 | - if ($do_current) |
|
1755 | - nextSubstep(++$substep); |
|
1756 | - else |
|
1757 | - $substep++; |
|
1758 | - } |
|
1759 | - elseif ($type == '{') |
|
1760 | - $current_type = 'code'; |
|
1761 | - elseif ($type == '}') |
|
1859 | + if ($do_current) { |
|
1860 | + nextSubstep(++$substep); |
|
1861 | + } else { |
|
1862 | + $substep++; |
|
1863 | + } |
|
1864 | + } elseif ($type == '{') { |
|
1865 | + $current_type = 'code'; |
|
1866 | + } elseif ($type == '}') |
|
1762 | 1867 | { |
1763 | 1868 | $current_type = 'sql'; |
1764 | 1869 | |
@@ -1771,8 +1876,9 @@ discard block |
||
1771 | 1876 | if (eval('global $db_prefix, $modSettings, $smcFunc; ' . $current_data) === false) |
1772 | 1877 | { |
1773 | 1878 | $upcontext['error_message'] = 'Error in upgrade script ' . basename($filename) . ' on line ' . $line_number . '!' . $endl; |
1774 | - if ($command_line) |
|
1775 | - echo $upcontext['error_message']; |
|
1879 | + if ($command_line) { |
|
1880 | + echo $upcontext['error_message']; |
|
1881 | + } |
|
1776 | 1882 | } |
1777 | 1883 | |
1778 | 1884 | // Done with code! |
@@ -1852,8 +1958,9 @@ discard block |
||
1852 | 1958 | $db_unbuffered = false; |
1853 | 1959 | |
1854 | 1960 | // Failure?! |
1855 | - if ($result !== false) |
|
1856 | - return $result; |
|
1961 | + if ($result !== false) { |
|
1962 | + return $result; |
|
1963 | + } |
|
1857 | 1964 | |
1858 | 1965 | $db_error_message = $smcFunc['db_error']($db_connection); |
1859 | 1966 | // If MySQL we do something more clever. |
@@ -1881,54 +1988,61 @@ discard block |
||
1881 | 1988 | { |
1882 | 1989 | mysqli_query($db_connection, 'REPAIR TABLE `' . $match[1] . '`'); |
1883 | 1990 | $result = mysqli_query($db_connection, $string); |
1884 | - if ($result !== false) |
|
1885 | - return $result; |
|
1991 | + if ($result !== false) { |
|
1992 | + return $result; |
|
1993 | + } |
|
1886 | 1994 | } |
1887 | - } |
|
1888 | - elseif ($mysqli_errno == 2013) |
|
1995 | + } elseif ($mysqli_errno == 2013) |
|
1889 | 1996 | { |
1890 | 1997 | $db_connection = mysqli_connect($db_server, $db_user, $db_passwd); |
1891 | 1998 | mysqli_select_db($db_connection, $db_name); |
1892 | 1999 | if ($db_connection) |
1893 | 2000 | { |
1894 | 2001 | $result = mysqli_query($db_connection, $string); |
1895 | - if ($result !== false) |
|
1896 | - return $result; |
|
2002 | + if ($result !== false) { |
|
2003 | + return $result; |
|
2004 | + } |
|
1897 | 2005 | } |
1898 | 2006 | } |
1899 | 2007 | // Duplicate column name... should be okay ;). |
1900 | - elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) |
|
1901 | - return false; |
|
2008 | + elseif (in_array($mysqli_errno, array(1060, 1061, 1068, 1091))) { |
|
2009 | + return false; |
|
2010 | + } |
|
1902 | 2011 | // Duplicate insert... make sure it's the proper type of query ;). |
1903 | - elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) |
|
1904 | - return false; |
|
2012 | + elseif (in_array($mysqli_errno, array(1054, 1062, 1146)) && $error_query) { |
|
2013 | + return false; |
|
2014 | + } |
|
1905 | 2015 | // Creating an index on a non-existent column. |
1906 | - elseif ($mysqli_errno == 1072) |
|
1907 | - return false; |
|
1908 | - elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') |
|
1909 | - return false; |
|
2016 | + elseif ($mysqli_errno == 1072) { |
|
2017 | + return false; |
|
2018 | + } elseif ($mysqli_errno == 1050 && substr(trim($string), 0, 12) == 'RENAME TABLE') { |
|
2019 | + return false; |
|
2020 | + } |
|
1910 | 2021 | } |
1911 | 2022 | // If a table already exists don't go potty. |
1912 | 2023 | else |
1913 | 2024 | { |
1914 | 2025 | if (in_array(substr(trim($string), 0, 8), array('CREATE T', 'CREATE S', 'DROP TABL', 'ALTER TA', 'CREATE I', 'CREATE U'))) |
1915 | 2026 | { |
1916 | - if (strpos($db_error_message, 'exist') !== false) |
|
1917 | - return true; |
|
1918 | - } |
|
1919 | - elseif (strpos(trim($string), 'INSERT ') !== false) |
|
2027 | + if (strpos($db_error_message, 'exist') !== false) { |
|
2028 | + return true; |
|
2029 | + } |
|
2030 | + } elseif (strpos(trim($string), 'INSERT ') !== false) |
|
1920 | 2031 | { |
1921 | - if (strpos($db_error_message, 'duplicate') !== false) |
|
1922 | - return true; |
|
2032 | + if (strpos($db_error_message, 'duplicate') !== false) { |
|
2033 | + return true; |
|
2034 | + } |
|
1923 | 2035 | } |
1924 | 2036 | } |
1925 | 2037 | |
1926 | 2038 | // Get the query string so we pass everything. |
1927 | 2039 | $query_string = ''; |
1928 | - foreach ($_GET as $k => $v) |
|
1929 | - $query_string .= ';' . $k . '=' . $v; |
|
1930 | - if (strlen($query_string) != 0) |
|
1931 | - $query_string = '?' . substr($query_string, 1); |
|
2040 | + foreach ($_GET as $k => $v) { |
|
2041 | + $query_string .= ';' . $k . '=' . $v; |
|
2042 | + } |
|
2043 | + if (strlen($query_string) != 0) { |
|
2044 | + $query_string = '?' . substr($query_string, 1); |
|
2045 | + } |
|
1932 | 2046 | |
1933 | 2047 | if ($command_line) |
1934 | 2048 | { |
@@ -1983,16 +2097,18 @@ discard block |
||
1983 | 2097 | { |
1984 | 2098 | $found |= 1; |
1985 | 2099 | // Do some checks on the data if we have it set. |
1986 | - if (isset($change['col_type'])) |
|
1987 | - $found &= $change['col_type'] === $column['type']; |
|
1988 | - if (isset($change['null_allowed'])) |
|
1989 | - $found &= $column['null'] == $change['null_allowed']; |
|
1990 | - if (isset($change['default'])) |
|
1991 | - $found &= $change['default'] === $column['default']; |
|
2100 | + if (isset($change['col_type'])) { |
|
2101 | + $found &= $change['col_type'] === $column['type']; |
|
2102 | + } |
|
2103 | + if (isset($change['null_allowed'])) { |
|
2104 | + $found &= $column['null'] == $change['null_allowed']; |
|
2105 | + } |
|
2106 | + if (isset($change['default'])) { |
|
2107 | + $found &= $change['default'] === $column['default']; |
|
2108 | + } |
|
1992 | 2109 | } |
1993 | 2110 | } |
1994 | - } |
|
1995 | - elseif ($change['type'] === 'index') |
|
2111 | + } elseif ($change['type'] === 'index') |
|
1996 | 2112 | { |
1997 | 2113 | $request = upgrade_query(' |
1998 | 2114 | SHOW INDEX |
@@ -2001,9 +2117,10 @@ discard block |
||
2001 | 2117 | { |
2002 | 2118 | $cur_index = array(); |
2003 | 2119 | |
2004 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2005 | - if ($row['Key_name'] === $change['name']) |
|
2120 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2121 | + if ($row['Key_name'] === $change['name']) |
|
2006 | 2122 | $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; |
2123 | + } |
|
2007 | 2124 | |
2008 | 2125 | ksort($cur_index, SORT_NUMERIC); |
2009 | 2126 | $found = array_values($cur_index) === $change['target_columns']; |
@@ -2013,14 +2130,17 @@ discard block |
||
2013 | 2130 | } |
2014 | 2131 | |
2015 | 2132 | // If we're trying to add and it's added, we're done. |
2016 | - if ($found && in_array($change['method'], array('add', 'change'))) |
|
2017 | - return true; |
|
2133 | + if ($found && in_array($change['method'], array('add', 'change'))) { |
|
2134 | + return true; |
|
2135 | + } |
|
2018 | 2136 | // Otherwise if we're removing and it wasn't found we're also done. |
2019 | - elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) |
|
2020 | - return true; |
|
2137 | + elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { |
|
2138 | + return true; |
|
2139 | + } |
|
2021 | 2140 | // Otherwise is it just a test? |
2022 | - elseif ($is_test) |
|
2023 | - return false; |
|
2141 | + elseif ($is_test) { |
|
2142 | + return false; |
|
2143 | + } |
|
2024 | 2144 | |
2025 | 2145 | // Not found it yet? Bummer! How about we see if we're currently doing it? |
2026 | 2146 | $running = false; |
@@ -2031,8 +2151,9 @@ discard block |
||
2031 | 2151 | SHOW FULL PROCESSLIST'); |
2032 | 2152 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2033 | 2153 | { |
2034 | - if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) |
|
2035 | - $found = true; |
|
2154 | + if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { |
|
2155 | + $found = true; |
|
2156 | + } |
|
2036 | 2157 | } |
2037 | 2158 | |
2038 | 2159 | // Can't find it? Then we need to run it fools! |
@@ -2044,8 +2165,9 @@ discard block |
||
2044 | 2165 | ALTER TABLE ' . $db_prefix . $change['table'] . ' |
2045 | 2166 | ' . $change['text'], true) !== false; |
2046 | 2167 | |
2047 | - if (!$success) |
|
2048 | - return false; |
|
2168 | + if (!$success) { |
|
2169 | + return false; |
|
2170 | + } |
|
2049 | 2171 | |
2050 | 2172 | // Return |
2051 | 2173 | $running = true; |
@@ -2087,8 +2209,9 @@ discard block |
||
2087 | 2209 | 'db_error_skip' => true, |
2088 | 2210 | ) |
2089 | 2211 | ); |
2090 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2091 | - die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2212 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2213 | + die('Unable to find column ' . $change['column'] . ' inside table ' . $db_prefix . $change['table']); |
|
2214 | + } |
|
2092 | 2215 | $table_row = $smcFunc['db_fetch_assoc']($request); |
2093 | 2216 | $smcFunc['db_free_result']($request); |
2094 | 2217 | |
@@ -2110,18 +2233,19 @@ discard block |
||
2110 | 2233 | ) |
2111 | 2234 | ); |
2112 | 2235 | // No results? Just forget it all together. |
2113 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
2114 | - unset($table_row['Collation']); |
|
2115 | - else |
|
2116 | - $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2236 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
2237 | + unset($table_row['Collation']); |
|
2238 | + } else { |
|
2239 | + $collation_info = $smcFunc['db_fetch_assoc']($request); |
|
2240 | + } |
|
2117 | 2241 | $smcFunc['db_free_result']($request); |
2118 | 2242 | } |
2119 | 2243 | |
2120 | 2244 | if ($column_fix) |
2121 | 2245 | { |
2122 | 2246 | // Make sure there are no NULL's left. |
2123 | - if ($null_fix) |
|
2124 | - $smcFunc['db_query']('', ' |
|
2247 | + if ($null_fix) { |
|
2248 | + $smcFunc['db_query']('', ' |
|
2125 | 2249 | UPDATE {db_prefix}' . $change['table'] . ' |
2126 | 2250 | SET ' . $change['column'] . ' = {string:default} |
2127 | 2251 | WHERE ' . $change['column'] . ' IS NULL', |
@@ -2130,6 +2254,7 @@ discard block |
||
2130 | 2254 | 'db_error_skip' => true, |
2131 | 2255 | ) |
2132 | 2256 | ); |
2257 | + } |
|
2133 | 2258 | |
2134 | 2259 | // Do the actual alteration. |
2135 | 2260 | $smcFunc['db_query']('', ' |
@@ -2158,8 +2283,9 @@ discard block |
||
2158 | 2283 | } |
2159 | 2284 | |
2160 | 2285 | // Not a column we need to check on? |
2161 | - if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) |
|
2162 | - return; |
|
2286 | + if (!in_array($change['name'], array('memberGroups', 'passwordSalt'))) { |
|
2287 | + return; |
|
2288 | + } |
|
2163 | 2289 | |
2164 | 2290 | // Break it up you (six|seven). |
2165 | 2291 | $temp = explode(' ', str_replace('NOT NULL', 'NOT_NULL', $change['text'])); |
@@ -2178,13 +2304,13 @@ discard block |
||
2178 | 2304 | 'new_name' => $temp[2], |
2179 | 2305 | )); |
2180 | 2306 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2181 | - if ($smcFunc['db_num_rows'] != 1) |
|
2182 | - return; |
|
2307 | + if ($smcFunc['db_num_rows'] != 1) { |
|
2308 | + return; |
|
2309 | + } |
|
2183 | 2310 | |
2184 | 2311 | list (, $current_type) = $smcFunc['db_fetch_assoc']($request); |
2185 | 2312 | $smcFunc['db_free_result']($request); |
2186 | - } |
|
2187 | - else |
|
2313 | + } else |
|
2188 | 2314 | { |
2189 | 2315 | // Do this the old fashion, sure method way. |
2190 | 2316 | $request = $smcFunc['db_query']('', ' |
@@ -2195,21 +2321,24 @@ discard block |
||
2195 | 2321 | )); |
2196 | 2322 | // Mayday! |
2197 | 2323 | // !!! This doesn't technically work because we don't pass request into it, but it hasn't broke anything yet. |
2198 | - if ($smcFunc['db_num_rows'] == 0) |
|
2199 | - return; |
|
2324 | + if ($smcFunc['db_num_rows'] == 0) { |
|
2325 | + return; |
|
2326 | + } |
|
2200 | 2327 | |
2201 | 2328 | // Oh where, oh where has my little field gone. Oh where can it be... |
2202 | - while ($row = $smcFunc['db_query']($request)) |
|
2203 | - if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2329 | + while ($row = $smcFunc['db_query']($request)) { |
|
2330 | + if ($row['Field'] == $temp[1] || $row['Field'] == $temp[2]) |
|
2204 | 2331 | { |
2205 | 2332 | $current_type = $row['Type']; |
2333 | + } |
|
2206 | 2334 | break; |
2207 | 2335 | } |
2208 | 2336 | } |
2209 | 2337 | |
2210 | 2338 | // If this doesn't match, the column may of been altered for a reason. |
2211 | - if (trim($current_type) != trim($temp[3])) |
|
2212 | - $temp[3] = $current_type; |
|
2339 | + if (trim($current_type) != trim($temp[3])) { |
|
2340 | + $temp[3] = $current_type; |
|
2341 | + } |
|
2213 | 2342 | |
2214 | 2343 | // Piece this back together. |
2215 | 2344 | $change['text'] = str_replace('NOT_NULL', 'NOT NULL', implode(' ', $temp)); |
@@ -2221,8 +2350,9 @@ discard block |
||
2221 | 2350 | global $start_time, $timeLimitThreshold, $command_line, $custom_warning; |
2222 | 2351 | global $step_progress, $is_debug, $upcontext; |
2223 | 2352 | |
2224 | - if ($_GET['substep'] < $substep) |
|
2225 | - $_GET['substep'] = $substep; |
|
2353 | + if ($_GET['substep'] < $substep) { |
|
2354 | + $_GET['substep'] = $substep; |
|
2355 | + } |
|
2226 | 2356 | |
2227 | 2357 | if ($command_line) |
2228 | 2358 | { |
@@ -2235,29 +2365,33 @@ discard block |
||
2235 | 2365 | } |
2236 | 2366 | |
2237 | 2367 | @set_time_limit(300); |
2238 | - if (function_exists('apache_reset_timeout')) |
|
2239 | - @apache_reset_timeout(); |
|
2368 | + if (function_exists('apache_reset_timeout')) { |
|
2369 | + @apache_reset_timeout(); |
|
2370 | + } |
|
2240 | 2371 | |
2241 | - if (time() - $start_time <= $timeLimitThreshold) |
|
2242 | - return; |
|
2372 | + if (time() - $start_time <= $timeLimitThreshold) { |
|
2373 | + return; |
|
2374 | + } |
|
2243 | 2375 | |
2244 | 2376 | // Do we have some custom step progress stuff? |
2245 | 2377 | if (!empty($step_progress)) |
2246 | 2378 | { |
2247 | 2379 | $upcontext['substep_progress'] = 0; |
2248 | 2380 | $upcontext['substep_progress_name'] = $step_progress['name']; |
2249 | - if ($step_progress['current'] > $step_progress['total']) |
|
2250 | - $upcontext['substep_progress'] = 99.9; |
|
2251 | - else |
|
2252 | - $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2381 | + if ($step_progress['current'] > $step_progress['total']) { |
|
2382 | + $upcontext['substep_progress'] = 99.9; |
|
2383 | + } else { |
|
2384 | + $upcontext['substep_progress'] = ($step_progress['current'] / $step_progress['total']) * 100; |
|
2385 | + } |
|
2253 | 2386 | |
2254 | 2387 | // Make it nicely rounded. |
2255 | 2388 | $upcontext['substep_progress'] = round($upcontext['substep_progress'], 1); |
2256 | 2389 | } |
2257 | 2390 | |
2258 | 2391 | // If this is XML we just exit right away! |
2259 | - if (isset($_GET['xml'])) |
|
2260 | - return upgradeExit(); |
|
2392 | + if (isset($_GET['xml'])) { |
|
2393 | + return upgradeExit(); |
|
2394 | + } |
|
2261 | 2395 | |
2262 | 2396 | // We're going to pause after this! |
2263 | 2397 | $upcontext['pause'] = true; |
@@ -2265,13 +2399,15 @@ discard block |
||
2265 | 2399 | $upcontext['query_string'] = ''; |
2266 | 2400 | foreach ($_GET as $k => $v) |
2267 | 2401 | { |
2268 | - if ($k != 'data' && $k != 'substep' && $k != 'step') |
|
2269 | - $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2402 | + if ($k != 'data' && $k != 'substep' && $k != 'step') { |
|
2403 | + $upcontext['query_string'] .= ';' . $k . '=' . $v; |
|
2404 | + } |
|
2270 | 2405 | } |
2271 | 2406 | |
2272 | 2407 | // Custom warning? |
2273 | - if (!empty($custom_warning)) |
|
2274 | - $upcontext['custom_warning'] = $custom_warning; |
|
2408 | + if (!empty($custom_warning)) { |
|
2409 | + $upcontext['custom_warning'] = $custom_warning; |
|
2410 | + } |
|
2275 | 2411 | |
2276 | 2412 | upgradeExit(); |
2277 | 2413 | } |
@@ -2286,25 +2422,26 @@ discard block |
||
2286 | 2422 | ob_implicit_flush(true); |
2287 | 2423 | @set_time_limit(600); |
2288 | 2424 | |
2289 | - if (!isset($_SERVER['argv'])) |
|
2290 | - $_SERVER['argv'] = array(); |
|
2425 | + if (!isset($_SERVER['argv'])) { |
|
2426 | + $_SERVER['argv'] = array(); |
|
2427 | + } |
|
2291 | 2428 | $_GET['maint'] = 1; |
2292 | 2429 | |
2293 | 2430 | foreach ($_SERVER['argv'] as $i => $arg) |
2294 | 2431 | { |
2295 | - if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) |
|
2296 | - $_GET['lang'] = $match[1]; |
|
2297 | - elseif (preg_match('~^--path=(.+)$~', $arg) != 0) |
|
2298 | - continue; |
|
2299 | - elseif ($arg == '--no-maintenance') |
|
2300 | - $_GET['maint'] = 0; |
|
2301 | - elseif ($arg == '--debug') |
|
2302 | - $is_debug = true; |
|
2303 | - elseif ($arg == '--backup') |
|
2304 | - $_POST['backup'] = 1; |
|
2305 | - elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) |
|
2306 | - $_GET['conv'] = 1; |
|
2307 | - elseif ($i != 0) |
|
2432 | + if (preg_match('~^--language=(.+)$~', $arg, $match) != 0) { |
|
2433 | + $_GET['lang'] = $match[1]; |
|
2434 | + } elseif (preg_match('~^--path=(.+)$~', $arg) != 0) { |
|
2435 | + continue; |
|
2436 | + } elseif ($arg == '--no-maintenance') { |
|
2437 | + $_GET['maint'] = 0; |
|
2438 | + } elseif ($arg == '--debug') { |
|
2439 | + $is_debug = true; |
|
2440 | + } elseif ($arg == '--backup') { |
|
2441 | + $_POST['backup'] = 1; |
|
2442 | + } elseif ($arg == '--template' && (file_exists($boarddir . '/template.php') || file_exists($boarddir . '/template.html') && !file_exists($modSettings['theme_dir'] . '/converted'))) { |
|
2443 | + $_GET['conv'] = 1; |
|
2444 | + } elseif ($i != 0) |
|
2308 | 2445 | { |
2309 | 2446 | echo 'SMF Command-line Upgrader |
2310 | 2447 | Usage: /path/to/php -f ' . basename(__FILE__) . ' -- [OPTION]... |
@@ -2318,10 +2455,12 @@ discard block |
||
2318 | 2455 | } |
2319 | 2456 | } |
2320 | 2457 | |
2321 | - if (!php_version_check()) |
|
2322 | - print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2323 | - if (!db_version_check()) |
|
2324 | - print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2458 | + if (!php_version_check()) { |
|
2459 | + print_error('Error: PHP ' . PHP_VERSION . ' does not match version requirements.', true); |
|
2460 | + } |
|
2461 | + if (!db_version_check()) { |
|
2462 | + print_error('Error: ' . $databases[$db_type]['name'] . ' ' . $databases[$db_type]['version'] . ' does not match minimum requirements.', true); |
|
2463 | + } |
|
2325 | 2464 | |
2326 | 2465 | // Do some checks to make sure they have proper privileges |
2327 | 2466 | db_extend('packages'); |
@@ -2336,34 +2475,39 @@ discard block |
||
2336 | 2475 | $drop = $smcFunc['db_drop_table']('{db_prefix}priv_check'); |
2337 | 2476 | |
2338 | 2477 | // Sorry... we need CREATE, ALTER and DROP |
2339 | - if (!$create || !$alter || !$drop) |
|
2340 | - 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); |
|
2478 | + if (!$create || !$alter || !$drop) { |
|
2479 | + 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); |
|
2480 | + } |
|
2341 | 2481 | |
2342 | 2482 | $check = @file_exists($modSettings['theme_dir'] . '/index.template.php') |
2343 | 2483 | && @file_exists($sourcedir . '/QueryString.php') |
2344 | 2484 | && @file_exists($sourcedir . '/ManageBoards.php'); |
2345 | - if (!$check && !isset($modSettings['smfVersion'])) |
|
2346 | - print_error('Error: Some files are missing or out-of-date.', true); |
|
2485 | + if (!$check && !isset($modSettings['smfVersion'])) { |
|
2486 | + print_error('Error: Some files are missing or out-of-date.', true); |
|
2487 | + } |
|
2347 | 2488 | |
2348 | 2489 | // Do a quick version spot check. |
2349 | 2490 | $temp = substr(@implode('', @file($boarddir . '/index.php')), 0, 4096); |
2350 | 2491 | preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $temp, $match); |
2351 | - if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) |
|
2352 | - print_error('Error: Some files have not yet been updated properly.'); |
|
2492 | + if (empty($match[1]) || (trim($match[1]) != SMF_VERSION)) { |
|
2493 | + print_error('Error: Some files have not yet been updated properly.'); |
|
2494 | + } |
|
2353 | 2495 | |
2354 | 2496 | // Make sure Settings.php is writable. |
2355 | 2497 | quickFileWritable($boarddir . '/Settings.php'); |
2356 | - if (!is_writable($boarddir . '/Settings.php')) |
|
2357 | - print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2498 | + if (!is_writable($boarddir . '/Settings.php')) { |
|
2499 | + print_error('Error: Unable to obtain write access to "Settings.php".', true); |
|
2500 | + } |
|
2358 | 2501 | |
2359 | 2502 | // Make sure Settings_bak.php is writable. |
2360 | 2503 | quickFileWritable($boarddir . '/Settings_bak.php'); |
2361 | - if (!is_writable($boarddir . '/Settings_bak.php')) |
|
2362 | - print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2504 | + if (!is_writable($boarddir . '/Settings_bak.php')) { |
|
2505 | + print_error('Error: Unable to obtain write access to "Settings_bak.php".'); |
|
2506 | + } |
|
2363 | 2507 | |
2364 | - if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) |
|
2365 | - print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2366 | - elseif (isset($modSettings['agreement'])) |
|
2508 | + if (isset($modSettings['agreement']) && (!is_writable($boarddir) || file_exists($boarddir . '/agreement.txt')) && !is_writable($boarddir . '/agreement.txt')) { |
|
2509 | + print_error('Error: Unable to obtain write access to "agreement.txt".'); |
|
2510 | + } elseif (isset($modSettings['agreement'])) |
|
2367 | 2511 | { |
2368 | 2512 | $fp = fopen($boarddir . '/agreement.txt', 'w'); |
2369 | 2513 | fwrite($fp, $modSettings['agreement']); |
@@ -2373,31 +2517,36 @@ discard block |
||
2373 | 2517 | // Make sure Themes is writable. |
2374 | 2518 | quickFileWritable($modSettings['theme_dir']); |
2375 | 2519 | |
2376 | - if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) |
|
2377 | - print_error('Error: Unable to obtain write access to "Themes".'); |
|
2520 | + if (!is_writable($modSettings['theme_dir']) && !isset($modSettings['smfVersion'])) { |
|
2521 | + print_error('Error: Unable to obtain write access to "Themes".'); |
|
2522 | + } |
|
2378 | 2523 | |
2379 | 2524 | // Make sure cache directory exists and is writable! |
2380 | 2525 | $cachedir_temp = empty($cachedir) ? $boarddir . '/cache' : $cachedir; |
2381 | - if (!file_exists($cachedir_temp)) |
|
2382 | - @mkdir($cachedir_temp); |
|
2526 | + if (!file_exists($cachedir_temp)) { |
|
2527 | + @mkdir($cachedir_temp); |
|
2528 | + } |
|
2383 | 2529 | |
2384 | 2530 | // Make sure the cache temp dir is writable. |
2385 | 2531 | quickFileWritable($cachedir_temp); |
2386 | 2532 | |
2387 | - if (!is_writable($cachedir_temp)) |
|
2388 | - print_error('Error: Unable to obtain write access to "cache".', true); |
|
2533 | + if (!is_writable($cachedir_temp)) { |
|
2534 | + print_error('Error: Unable to obtain write access to "cache".', true); |
|
2535 | + } |
|
2389 | 2536 | |
2390 | - if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) |
|
2391 | - print_error('Error: Unable to find language files!', true); |
|
2392 | - else |
|
2537 | + if (!file_exists($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php') && !isset($modSettings['smfVersion']) && !isset($_GET['lang'])) { |
|
2538 | + print_error('Error: Unable to find language files!', true); |
|
2539 | + } else |
|
2393 | 2540 | { |
2394 | 2541 | $temp = substr(@implode('', @file($modSettings['theme_dir'] . '/languages/index.' . $upcontext['language'] . '.php')), 0, 4096); |
2395 | 2542 | preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*index(?:[\s]{2}|\*/)~i', $temp, $match); |
2396 | 2543 | |
2397 | - if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) |
|
2398 | - print_error('Error: Language files out of date.', true); |
|
2399 | - if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) |
|
2400 | - print_error('Error: Install language is missing for selected language.', true); |
|
2544 | + if (empty($match[1]) || $match[1] != SMF_LANG_VERSION) { |
|
2545 | + print_error('Error: Language files out of date.', true); |
|
2546 | + } |
|
2547 | + if (!file_exists($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php')) { |
|
2548 | + print_error('Error: Install language is missing for selected language.', true); |
|
2549 | + } |
|
2401 | 2550 | |
2402 | 2551 | // Otherwise include it! |
2403 | 2552 | require_once($modSettings['theme_dir'] . '/languages/Install.' . $upcontext['language'] . '.php'); |
@@ -2426,8 +2575,7 @@ discard block |
||
2426 | 2575 | ); |
2427 | 2576 | |
2428 | 2577 | return true; |
2429 | - } |
|
2430 | - else |
|
2578 | + } else |
|
2431 | 2579 | { |
2432 | 2580 | $upcontext['page_title'] = 'Converting to UTF8'; |
2433 | 2581 | $upcontext['sub_template'] = isset($_GET['xml']) ? 'convert_xml' : 'convert_utf8'; |
@@ -2471,8 +2619,9 @@ discard block |
||
2471 | 2619 | ) |
2472 | 2620 | ); |
2473 | 2621 | $db_charsets = array(); |
2474 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2475 | - $db_charsets[] = $row['Charset']; |
|
2622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2623 | + $db_charsets[] = $row['Charset']; |
|
2624 | + } |
|
2476 | 2625 | |
2477 | 2626 | $smcFunc['db_free_result']($request); |
2478 | 2627 | |
@@ -2508,13 +2657,15 @@ discard block |
||
2508 | 2657 | // If there's a fulltext index, we need to drop it first... |
2509 | 2658 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
2510 | 2659 | { |
2511 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2512 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2660 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2661 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
2513 | 2662 | $upcontext['fulltext_index'][] = $row['Key_name']; |
2663 | + } |
|
2514 | 2664 | $smcFunc['db_free_result']($request); |
2515 | 2665 | |
2516 | - if (isset($upcontext['fulltext_index'])) |
|
2517 | - $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2666 | + if (isset($upcontext['fulltext_index'])) { |
|
2667 | + $upcontext['fulltext_index'] = array_unique($upcontext['fulltext_index']); |
|
2668 | + } |
|
2518 | 2669 | } |
2519 | 2670 | |
2520 | 2671 | // Drop it and make a note... |
@@ -2704,8 +2855,9 @@ discard block |
||
2704 | 2855 | $replace = '%field%'; |
2705 | 2856 | |
2706 | 2857 | // Build a huge REPLACE statement... |
2707 | - foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) |
|
2708 | - $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2858 | + foreach ($translation_tables[$upcontext['charset_detected']] as $from => $to) { |
|
2859 | + $replace = 'REPLACE(' . $replace . ', ' . $from . ', ' . $to . ')'; |
|
2860 | + } |
|
2709 | 2861 | } |
2710 | 2862 | |
2711 | 2863 | // Get a list of table names ahead of time... This makes it easier to set our substep and such |
@@ -2739,8 +2891,9 @@ discard block |
||
2739 | 2891 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
2740 | 2892 | |
2741 | 2893 | // Just to make sure it doesn't time out. |
2742 | - if (function_exists('apache_reset_timeout')) |
|
2743 | - @apache_reset_timeout(); |
|
2894 | + if (function_exists('apache_reset_timeout')) { |
|
2895 | + @apache_reset_timeout(); |
|
2896 | + } |
|
2744 | 2897 | |
2745 | 2898 | $table_charsets = array(); |
2746 | 2899 | |
@@ -2761,8 +2914,9 @@ discard block |
||
2761 | 2914 | { |
2762 | 2915 | list($charset) = explode('_', $collation); |
2763 | 2916 | |
2764 | - if (!isset($table_charsets[$charset])) |
|
2765 | - $table_charsets[$charset] = array(); |
|
2917 | + if (!isset($table_charsets[$charset])) { |
|
2918 | + $table_charsets[$charset] = array(); |
|
2919 | + } |
|
2766 | 2920 | |
2767 | 2921 | $table_charsets[$charset][] = $column_info; |
2768 | 2922 | } |
@@ -2802,10 +2956,11 @@ discard block |
||
2802 | 2956 | if (isset($translation_tables[$upcontext['charset_detected']])) |
2803 | 2957 | { |
2804 | 2958 | $update = ''; |
2805 | - foreach ($table_charsets as $charset => $columns) |
|
2806 | - foreach ($columns as $column) |
|
2959 | + foreach ($table_charsets as $charset => $columns) { |
|
2960 | + foreach ($columns as $column) |
|
2807 | 2961 | $update .= ' |
2808 | 2962 | ' . $column['Field'] . ' = ' . strtr($replace, array('%field%' => $column['Field'])) . ','; |
2963 | + } |
|
2809 | 2964 | |
2810 | 2965 | $smcFunc['db_query']('', ' |
2811 | 2966 | UPDATE {raw:table_name} |
@@ -2830,8 +2985,9 @@ discard block |
||
2830 | 2985 | // Now do the actual conversion (if still needed). |
2831 | 2986 | if ($charsets[$upcontext['charset_detected']] !== 'utf8') |
2832 | 2987 | { |
2833 | - if ($command_line) |
|
2834 | - echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
2988 | + if ($command_line) { |
|
2989 | + echo 'Converting table ' . $table_info['Name'] . ' to UTF-8...'; |
|
2990 | + } |
|
2835 | 2991 | |
2836 | 2992 | $smcFunc['db_query']('', ' |
2837 | 2993 | ALTER TABLE {raw:table_name} |
@@ -2841,8 +2997,9 @@ discard block |
||
2841 | 2997 | ) |
2842 | 2998 | ); |
2843 | 2999 | |
2844 | - if ($command_line) |
|
2845 | - echo " done.\n"; |
|
3000 | + if ($command_line) { |
|
3001 | + echo " done.\n"; |
|
3002 | + } |
|
2846 | 3003 | } |
2847 | 3004 | } |
2848 | 3005 | |
@@ -2872,8 +3029,8 @@ discard block |
||
2872 | 3029 | ); |
2873 | 3030 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2874 | 3031 | { |
2875 | - 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) |
|
2876 | - $smcFunc['db_query']('', ' |
|
3032 | + 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) { |
|
3033 | + $smcFunc['db_query']('', ' |
|
2877 | 3034 | UPDATE {db_prefix}log_actions |
2878 | 3035 | SET extra = {string:extra} |
2879 | 3036 | WHERE id_action = {int:current_action}', |
@@ -2882,6 +3039,7 @@ discard block |
||
2882 | 3039 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
2883 | 3040 | ) |
2884 | 3041 | ); |
3042 | + } |
|
2885 | 3043 | } |
2886 | 3044 | $smcFunc['db_free_result']($request); |
2887 | 3045 | |
@@ -2903,15 +3061,17 @@ discard block |
||
2903 | 3061 | // First thing's first - did we already do this? |
2904 | 3062 | if (!empty($modSettings['json_done'])) |
2905 | 3063 | { |
2906 | - if ($command_line) |
|
2907 | - return DeleteUpgrade(); |
|
2908 | - else |
|
2909 | - return true; |
|
3064 | + if ($command_line) { |
|
3065 | + return DeleteUpgrade(); |
|
3066 | + } else { |
|
3067 | + return true; |
|
3068 | + } |
|
2910 | 3069 | } |
2911 | 3070 | |
2912 | 3071 | // Done it already - js wise? |
2913 | - if (!empty($_POST['json_done'])) |
|
2914 | - return true; |
|
3072 | + if (!empty($_POST['json_done'])) { |
|
3073 | + return true; |
|
3074 | + } |
|
2915 | 3075 | |
2916 | 3076 | // List of tables affected by this function |
2917 | 3077 | // name => array('key', col1[,col2|true[,col3]]) |
@@ -2942,12 +3102,14 @@ discard block |
||
2942 | 3102 | $upcontext['cur_table_name'] = isset($keys[$_GET['substep']]) ? $keys[$_GET['substep']] : $keys[0]; |
2943 | 3103 | $upcontext['step_progress'] = (int) (($upcontext['cur_table_num'] / $upcontext['table_count']) * 100); |
2944 | 3104 | |
2945 | - foreach ($keys as $id => $table) |
|
2946 | - if ($id < $_GET['substep']) |
|
3105 | + foreach ($keys as $id => $table) { |
|
3106 | + if ($id < $_GET['substep']) |
|
2947 | 3107 | $upcontext['previous_tables'][] = $table; |
3108 | + } |
|
2948 | 3109 | |
2949 | - if ($command_line) |
|
2950 | - echo 'Converting data from serialize() to json_encode().'; |
|
3110 | + if ($command_line) { |
|
3111 | + echo 'Converting data from serialize() to json_encode().'; |
|
3112 | + } |
|
2951 | 3113 | |
2952 | 3114 | if (!$support_js || isset($_GET['xml'])) |
2953 | 3115 | { |
@@ -2987,8 +3149,9 @@ discard block |
||
2987 | 3149 | |
2988 | 3150 | // Loop through and fix these... |
2989 | 3151 | $new_settings = array(); |
2990 | - if ($command_line) |
|
2991 | - echo "\n" . 'Fixing some settings...'; |
|
3152 | + if ($command_line) { |
|
3153 | + echo "\n" . 'Fixing some settings...'; |
|
3154 | + } |
|
2992 | 3155 | |
2993 | 3156 | foreach ($serialized_settings as $var) |
2994 | 3157 | { |
@@ -2996,22 +3159,24 @@ discard block |
||
2996 | 3159 | { |
2997 | 3160 | // Attempt to unserialize the setting |
2998 | 3161 | $temp = @safe_unserialize($modSettings[$var]); |
2999 | - if (!$temp && $command_line) |
|
3000 | - echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3001 | - elseif ($temp !== false) |
|
3002 | - $new_settings[$var] = json_encode($temp); |
|
3162 | + if (!$temp && $command_line) { |
|
3163 | + echo "\n - Failed to unserialize the '" . $var . "' setting. Skipping."; |
|
3164 | + } elseif ($temp !== false) { |
|
3165 | + $new_settings[$var] = json_encode($temp); |
|
3166 | + } |
|
3003 | 3167 | } |
3004 | 3168 | } |
3005 | 3169 | |
3006 | 3170 | // Update everything at once |
3007 | - if (!function_exists('cache_put_data')) |
|
3008 | - require_once($sourcedir . '/Load.php'); |
|
3171 | + if (!function_exists('cache_put_data')) { |
|
3172 | + require_once($sourcedir . '/Load.php'); |
|
3173 | + } |
|
3009 | 3174 | updateSettings($new_settings, true); |
3010 | 3175 | |
3011 | - if ($command_line) |
|
3012 | - echo ' done.'; |
|
3013 | - } |
|
3014 | - elseif ($table == 'themes') |
|
3176 | + if ($command_line) { |
|
3177 | + echo ' done.'; |
|
3178 | + } |
|
3179 | + } elseif ($table == 'themes') |
|
3015 | 3180 | { |
3016 | 3181 | // Finally, fix the admin prefs. Unfortunately this is stored per theme, but hopefully they only have one theme installed at this point... |
3017 | 3182 | $query = $smcFunc['db_query']('', ' |
@@ -3030,10 +3195,11 @@ discard block |
||
3030 | 3195 | |
3031 | 3196 | if ($command_line) |
3032 | 3197 | { |
3033 | - if ($temp === false) |
|
3034 | - echo "\n" . 'Unserialize of admin_preferences for user ' . $row['id_member'] . ' failed. Skipping.'; |
|
3035 | - else |
|
3036 | - echo "\n" . 'Fixing admin preferences...'; |
|
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...'; |
|
3202 | + } |
|
3037 | 3203 | } |
3038 | 3204 | |
3039 | 3205 | if ($temp !== false) |
@@ -3053,15 +3219,15 @@ discard block |
||
3053 | 3219 | ) |
3054 | 3220 | ); |
3055 | 3221 | |
3056 | - if ($command_line) |
|
3057 | - echo ' done.'; |
|
3222 | + if ($command_line) { |
|
3223 | + echo ' done.'; |
|
3224 | + } |
|
3058 | 3225 | } |
3059 | 3226 | } |
3060 | 3227 | |
3061 | 3228 | $smcFunc['db_free_result']($query); |
3062 | 3229 | } |
3063 | - } |
|
3064 | - else |
|
3230 | + } else |
|
3065 | 3231 | { |
3066 | 3232 | // First item is always the key... |
3067 | 3233 | $key = $info[0]; |
@@ -3072,8 +3238,7 @@ discard block |
||
3072 | 3238 | { |
3073 | 3239 | $col_select = $info[1]; |
3074 | 3240 | $where = ' WHERE ' . $info[1] . ' != {empty}'; |
3075 | - } |
|
3076 | - else |
|
3241 | + } else |
|
3077 | 3242 | { |
3078 | 3243 | $col_select = implode(', ', $info); |
3079 | 3244 | } |
@@ -3106,8 +3271,7 @@ discard block |
||
3106 | 3271 | if ($temp === false && $command_line) |
3107 | 3272 | { |
3108 | 3273 | echo "\nFailed to unserialize " . $row[$col] . "... Skipping\n"; |
3109 | - } |
|
3110 | - else |
|
3274 | + } else |
|
3111 | 3275 | { |
3112 | 3276 | $row[$col] = json_encode($temp); |
3113 | 3277 | |
@@ -3132,16 +3296,18 @@ discard block |
||
3132 | 3296 | } |
3133 | 3297 | } |
3134 | 3298 | |
3135 | - if ($command_line) |
|
3136 | - echo ' done.'; |
|
3299 | + if ($command_line) { |
|
3300 | + echo ' done.'; |
|
3301 | + } |
|
3137 | 3302 | |
3138 | 3303 | // Free up some memory... |
3139 | 3304 | $smcFunc['db_free_result']($query); |
3140 | 3305 | } |
3141 | 3306 | } |
3142 | 3307 | // If this is XML to keep it nice for the user do one table at a time anyway! |
3143 | - if (isset($_GET['xml'])) |
|
3144 | - return upgradeExit(); |
|
3308 | + if (isset($_GET['xml'])) { |
|
3309 | + return upgradeExit(); |
|
3310 | + } |
|
3145 | 3311 | } |
3146 | 3312 | |
3147 | 3313 | if ($command_line) |
@@ -3156,8 +3322,9 @@ discard block |
||
3156 | 3322 | |
3157 | 3323 | $_GET['substep'] = 0; |
3158 | 3324 | // Make sure we move on! |
3159 | - if ($command_line) |
|
3160 | - return DeleteUpgrade(); |
|
3325 | + if ($command_line) { |
|
3326 | + return DeleteUpgrade(); |
|
3327 | + } |
|
3161 | 3328 | |
3162 | 3329 | return true; |
3163 | 3330 | } |
@@ -3177,14 +3344,16 @@ discard block |
||
3177 | 3344 | global $upcontext, $txt, $settings; |
3178 | 3345 | |
3179 | 3346 | // Don't call me twice! |
3180 | - if (!empty($upcontext['chmod_called'])) |
|
3181 | - return; |
|
3347 | + if (!empty($upcontext['chmod_called'])) { |
|
3348 | + return; |
|
3349 | + } |
|
3182 | 3350 | |
3183 | 3351 | $upcontext['chmod_called'] = true; |
3184 | 3352 | |
3185 | 3353 | // Nothing? |
3186 | - if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) |
|
3187 | - return; |
|
3354 | + if (empty($upcontext['chmod']['files']) && empty($upcontext['chmod']['ftp_error'])) { |
|
3355 | + return; |
|
3356 | + } |
|
3188 | 3357 | |
3189 | 3358 | // Was it a problem with Windows? |
3190 | 3359 | if (!empty($upcontext['chmod']['ftp_error']) && $upcontext['chmod']['ftp_error'] == 'total_mess') |
@@ -3216,11 +3385,12 @@ discard block |
||
3216 | 3385 | 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\'); |
3217 | 3386 | content.write(\'<p>', implode('<br>\n\t\t\t', $upcontext['chmod']['files']), '</p>\n\t\t\t\');'; |
3218 | 3387 | |
3219 | - if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') |
|
3220 | - echo ' |
|
3388 | + if (isset($upcontext['systemos']) && $upcontext['systemos'] == 'linux') { |
|
3389 | + echo ' |
|
3221 | 3390 | content.write(\'<hr>\n\t\t\t\'); |
3222 | 3391 | 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\'); |
3223 | 3392 | content.write(\'<tt># chmod a+w ', implode(' ', $upcontext['chmod']['files']), '</tt>\n\t\t\t\');'; |
3393 | + } |
|
3224 | 3394 | |
3225 | 3395 | echo ' |
3226 | 3396 | content.write(\'<a href="javascript:self.close();">close</a>\n\t\t</div>\n\t</body>\n</html>\'); |
@@ -3228,17 +3398,19 @@ discard block |
||
3228 | 3398 | } |
3229 | 3399 | </script>'; |
3230 | 3400 | |
3231 | - if (!empty($upcontext['chmod']['ftp_error'])) |
|
3232 | - echo ' |
|
3401 | + if (!empty($upcontext['chmod']['ftp_error'])) { |
|
3402 | + echo ' |
|
3233 | 3403 | <div class="error_message red"> |
3234 | 3404 | The following error was encountered when trying to connect:<br><br> |
3235 | 3405 | <code>', $upcontext['chmod']['ftp_error'], '</code> |
3236 | 3406 | </div> |
3237 | 3407 | <br>'; |
3408 | + } |
|
3238 | 3409 | |
3239 | - if (empty($upcontext['chmod_in_form'])) |
|
3240 | - echo ' |
|
3410 | + if (empty($upcontext['chmod_in_form'])) { |
|
3411 | + echo ' |
|
3241 | 3412 | <form action="', $upcontext['form_url'], '" method="post">'; |
3413 | + } |
|
3242 | 3414 | |
3243 | 3415 | echo ' |
3244 | 3416 | <table width="520" border="0" align="center" style="margin-bottom: 1ex;"> |
@@ -3273,10 +3445,11 @@ discard block |
||
3273 | 3445 | <div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['ftp_connect'], '" class="button_submit"></div> |
3274 | 3446 | </div>'; |
3275 | 3447 | |
3276 | - if (empty($upcontext['chmod_in_form'])) |
|
3277 | - echo ' |
|
3448 | + if (empty($upcontext['chmod_in_form'])) { |
|
3449 | + echo ' |
|
3278 | 3450 | </form>'; |
3279 | -} |
|
3451 | + } |
|
3452 | + } |
|
3280 | 3453 | |
3281 | 3454 | function template_upgrade_above() |
3282 | 3455 | { |
@@ -3336,9 +3509,10 @@ discard block |
||
3336 | 3509 | <h2>', $txt['upgrade_progress'], '</h2> |
3337 | 3510 | <ul>'; |
3338 | 3511 | |
3339 | - foreach ($upcontext['steps'] as $num => $step) |
|
3340 | - echo ' |
|
3512 | + foreach ($upcontext['steps'] as $num => $step) { |
|
3513 | + echo ' |
|
3341 | 3514 | <li class="', $num < $upcontext['current_step'] ? 'stepdone' : ($num == $upcontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
3515 | + } |
|
3342 | 3516 | |
3343 | 3517 | echo ' |
3344 | 3518 | </ul> |
@@ -3351,8 +3525,8 @@ discard block |
||
3351 | 3525 | </div> |
3352 | 3526 | </div>'; |
3353 | 3527 | |
3354 | - if (isset($upcontext['step_progress'])) |
|
3355 | - echo ' |
|
3528 | + if (isset($upcontext['step_progress'])) { |
|
3529 | + echo ' |
|
3356 | 3530 | <br> |
3357 | 3531 | <br> |
3358 | 3532 | <div id="progress_bar_step"> |
@@ -3361,6 +3535,7 @@ discard block |
||
3361 | 3535 | <span>', $txt['upgrade_step_progress'], '</span> |
3362 | 3536 | </div> |
3363 | 3537 | </div>'; |
3538 | + } |
|
3364 | 3539 | |
3365 | 3540 | echo ' |
3366 | 3541 | <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> |
@@ -3391,32 +3566,36 @@ discard block |
||
3391 | 3566 | { |
3392 | 3567 | global $upcontext, $txt; |
3393 | 3568 | |
3394 | - if (!empty($upcontext['pause'])) |
|
3395 | - echo ' |
|
3569 | + if (!empty($upcontext['pause'])) { |
|
3570 | + echo ' |
|
3396 | 3571 | <em>', $txt['upgrade_incomplete'], '.</em><br> |
3397 | 3572 | |
3398 | 3573 | <h2 style="margin-top: 2ex;">', $txt['upgrade_not_quite_done'], '</h2> |
3399 | 3574 | <h3> |
3400 | 3575 | ', $txt['upgrade_paused_overload'], ' |
3401 | 3576 | </h3>'; |
3577 | + } |
|
3402 | 3578 | |
3403 | - if (!empty($upcontext['custom_warning'])) |
|
3404 | - echo ' |
|
3579 | + if (!empty($upcontext['custom_warning'])) { |
|
3580 | + echo ' |
|
3405 | 3581 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3406 | 3582 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3407 | 3583 | <strong style="text-decoration: underline;">', $txt['upgrade_note'], '</strong><br> |
3408 | 3584 | <div style="padding-left: 6ex;">', $upcontext['custom_warning'], '</div> |
3409 | 3585 | </div>'; |
3586 | + } |
|
3410 | 3587 | |
3411 | 3588 | echo ' |
3412 | 3589 | <div class="righttext" style="margin: 1ex;">'; |
3413 | 3590 | |
3414 | - if (!empty($upcontext['continue'])) |
|
3415 | - echo ' |
|
3591 | + if (!empty($upcontext['continue'])) { |
|
3592 | + echo ' |
|
3416 | 3593 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '"', $upcontext['continue'] == 2 ? ' disabled' : '', ' class="button_submit">'; |
3417 | - if (!empty($upcontext['skip'])) |
|
3418 | - echo ' |
|
3594 | + } |
|
3595 | + if (!empty($upcontext['skip'])) { |
|
3596 | + echo ' |
|
3419 | 3597 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="dontSubmit = true; document.getElementById(\'contbutt\').disabled = \'disabled\'; return true;" class="button_submit">'; |
3598 | + } |
|
3420 | 3599 | |
3421 | 3600 | echo ' |
3422 | 3601 | </div> |
@@ -3466,11 +3645,12 @@ discard block |
||
3466 | 3645 | echo '<', '?xml version="1.0" encoding="UTF-8"?', '> |
3467 | 3646 | <smf>'; |
3468 | 3647 | |
3469 | - if (!empty($upcontext['get_data'])) |
|
3470 | - foreach ($upcontext['get_data'] as $k => $v) |
|
3648 | + if (!empty($upcontext['get_data'])) { |
|
3649 | + foreach ($upcontext['get_data'] as $k => $v) |
|
3471 | 3650 | echo ' |
3472 | 3651 | <get key="', $k, '">', $v, '</get>'; |
3473 | -} |
|
3652 | + } |
|
3653 | + } |
|
3474 | 3654 | |
3475 | 3655 | function template_xml_below() |
3476 | 3656 | { |
@@ -3511,8 +3691,8 @@ discard block |
||
3511 | 3691 | template_chmod(); |
3512 | 3692 | |
3513 | 3693 | // For large, pre 1.1 RC2 forums give them a warning about the possible impact of this upgrade! |
3514 | - if ($upcontext['is_large_forum']) |
|
3515 | - echo ' |
|
3694 | + if ($upcontext['is_large_forum']) { |
|
3695 | + echo ' |
|
3516 | 3696 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3517 | 3697 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3518 | 3698 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3520,10 +3700,11 @@ discard block |
||
3520 | 3700 | ', $txt['upgrade_warning_lots_data'], ' |
3521 | 3701 | </div> |
3522 | 3702 | </div>'; |
3703 | + } |
|
3523 | 3704 | |
3524 | 3705 | // A warning message? |
3525 | - if (!empty($upcontext['warning'])) |
|
3526 | - echo ' |
|
3706 | + if (!empty($upcontext['warning'])) { |
|
3707 | + echo ' |
|
3527 | 3708 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3528 | 3709 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3529 | 3710 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -3531,6 +3712,7 @@ discard block |
||
3531 | 3712 | ', $upcontext['warning'], ' |
3532 | 3713 | </div> |
3533 | 3714 | </div>'; |
3715 | + } |
|
3534 | 3716 | |
3535 | 3717 | // Paths are incorrect? |
3536 | 3718 | echo ' |
@@ -3546,20 +3728,22 @@ discard block |
||
3546 | 3728 | if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) |
3547 | 3729 | { |
3548 | 3730 | $ago = time() - $upcontext['started']; |
3549 | - if ($ago < 60) |
|
3550 | - $ago = $ago . ' seconds'; |
|
3551 | - elseif ($ago < 3600) |
|
3552 | - $ago = (int) ($ago / 60) . ' minutes'; |
|
3553 | - else |
|
3554 | - $ago = (int) ($ago / 3600) . ' hours'; |
|
3731 | + if ($ago < 60) { |
|
3732 | + $ago = $ago . ' seconds'; |
|
3733 | + } elseif ($ago < 3600) { |
|
3734 | + $ago = (int) ($ago / 60) . ' minutes'; |
|
3735 | + } else { |
|
3736 | + $ago = (int) ($ago / 3600) . ' hours'; |
|
3737 | + } |
|
3555 | 3738 | |
3556 | 3739 | $active = time() - $upcontext['updated']; |
3557 | - if ($active < 60) |
|
3558 | - $updated = $active . ' seconds'; |
|
3559 | - elseif ($active < 3600) |
|
3560 | - $updated = (int) ($active / 60) . ' minutes'; |
|
3561 | - else |
|
3562 | - $updated = (int) ($active / 3600) . ' hours'; |
|
3740 | + if ($active < 60) { |
|
3741 | + $updated = $active . ' seconds'; |
|
3742 | + } elseif ($active < 3600) { |
|
3743 | + $updated = (int) ($active / 60) . ' minutes'; |
|
3744 | + } else { |
|
3745 | + $updated = (int) ($active / 3600) . ' hours'; |
|
3746 | + } |
|
3563 | 3747 | |
3564 | 3748 | echo ' |
3565 | 3749 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
@@ -3568,16 +3752,18 @@ discard block |
||
3568 | 3752 | <div style="padding-left: 6ex;"> |
3569 | 3753 | "', $upcontext['user']['name'], '" has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.'; |
3570 | 3754 | |
3571 | - if ($active < 600) |
|
3572 | - echo ' |
|
3755 | + if ($active < 600) { |
|
3756 | + echo ' |
|
3573 | 3757 | We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.'; |
3758 | + } |
|
3574 | 3759 | |
3575 | - if ($active > $upcontext['inactive_timeout']) |
|
3576 | - echo ' |
|
3760 | + if ($active > $upcontext['inactive_timeout']) { |
|
3761 | + echo ' |
|
3577 | 3762 | <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.'; |
3578 | - else |
|
3579 | - echo ' |
|
3763 | + } else { |
|
3764 | + echo ' |
|
3580 | 3765 | <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!'); |
3766 | + } |
|
3581 | 3767 | |
3582 | 3768 | echo ' |
3583 | 3769 | </div> |
@@ -3593,9 +3779,10 @@ discard block |
||
3593 | 3779 | <td> |
3594 | 3780 | <input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '"', $disable_security ? ' disabled' : '', ' class="input_text">'; |
3595 | 3781 | |
3596 | - if (!empty($upcontext['username_incorrect'])) |
|
3597 | - echo ' |
|
3782 | + if (!empty($upcontext['username_incorrect'])) { |
|
3783 | + echo ' |
|
3598 | 3784 | <div class="smalltext" style="color: red;">Username Incorrect</div>'; |
3785 | + } |
|
3599 | 3786 | |
3600 | 3787 | echo ' |
3601 | 3788 | </td> |
@@ -3606,9 +3793,10 @@ discard block |
||
3606 | 3793 | <input type="password" name="passwrd" value=""', $disable_security ? ' disabled' : '', ' class="input_password"> |
3607 | 3794 | <input type="hidden" name="hash_passwrd" value="">'; |
3608 | 3795 | |
3609 | - if (!empty($upcontext['password_failed'])) |
|
3610 | - echo ' |
|
3796 | + if (!empty($upcontext['password_failed'])) { |
|
3797 | + echo ' |
|
3611 | 3798 | <div class="smalltext" style="color: red;">Password Incorrect</div>'; |
3799 | + } |
|
3612 | 3800 | |
3613 | 3801 | echo ' |
3614 | 3802 | </td> |
@@ -3679,8 +3867,8 @@ discard block |
||
3679 | 3867 | <form action="', $upcontext['form_url'], '" method="post" name="upform" id="upform">'; |
3680 | 3868 | |
3681 | 3869 | // Warning message? |
3682 | - if (!empty($upcontext['upgrade_options_warning'])) |
|
3683 | - echo ' |
|
3870 | + if (!empty($upcontext['upgrade_options_warning'])) { |
|
3871 | + echo ' |
|
3684 | 3872 | <div style="margin: 1ex; padding: 1ex; border: 1px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
3685 | 3873 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
3686 | 3874 | <strong style="text-decoration: underline;">Warning!</strong><br> |
@@ -3688,6 +3876,7 @@ discard block |
||
3688 | 3876 | ', $upcontext['upgrade_options_warning'], ' |
3689 | 3877 | </div> |
3690 | 3878 | </div>'; |
3879 | + } |
|
3691 | 3880 | |
3692 | 3881 | echo ' |
3693 | 3882 | <table> |
@@ -3730,8 +3919,8 @@ discard block |
||
3730 | 3919 | </td> |
3731 | 3920 | </tr>'; |
3732 | 3921 | |
3733 | - if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) |
|
3734 | - echo ' |
|
3922 | + if (!empty($upcontext['karma_installed']['good']) || !empty($upcontext['karma_installed']['bad'])) { |
|
3923 | + echo ' |
|
3735 | 3924 | <tr valign="top"> |
3736 | 3925 | <td width="2%"> |
3737 | 3926 | <input type="checkbox" name="delete_karma" id="delete_karma" value="1" class="input_check"> |
@@ -3740,6 +3929,7 @@ discard block |
||
3740 | 3929 | <label for="delete_karma">Delete all karma settings and info from the DB</label> |
3741 | 3930 | </td> |
3742 | 3931 | </tr>'; |
3932 | + } |
|
3743 | 3933 | |
3744 | 3934 | echo ' |
3745 | 3935 | <tr valign="top"> |
@@ -3775,10 +3965,11 @@ discard block |
||
3775 | 3965 | <span id="debuginfo"></span>'; |
3776 | 3966 | |
3777 | 3967 | // Dont any tables so far? |
3778 | - if (!empty($upcontext['previous_tables'])) |
|
3779 | - foreach ($upcontext['previous_tables'] as $table) |
|
3968 | + if (!empty($upcontext['previous_tables'])) { |
|
3969 | + foreach ($upcontext['previous_tables'] as $table) |
|
3780 | 3970 | echo ' |
3781 | 3971 | <br>Completed Table: "', $table, '".'; |
3972 | + } |
|
3782 | 3973 | |
3783 | 3974 | echo ' |
3784 | 3975 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
@@ -3815,12 +4006,13 @@ discard block |
||
3815 | 4006 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
3816 | 4007 | |
3817 | 4008 | // If debug flood the screen. |
3818 | - if ($is_debug) |
|
3819 | - echo ' |
|
4009 | + if ($is_debug) { |
|
4010 | + echo ' |
|
3820 | 4011 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\'); |
3821 | 4012 | |
3822 | 4013 | if (document.getElementById(\'debuginfo\').scrollHeight) |
3823 | 4014 | document.getElementById(\'debuginfo\').scrollTop = document.getElementById(\'debuginfo\').scrollHeight;'; |
4015 | + } |
|
3824 | 4016 | |
3825 | 4017 | echo ' |
3826 | 4018 | // Get the next update... |
@@ -3852,8 +4044,9 @@ discard block |
||
3852 | 4044 | { |
3853 | 4045 | global $upcontext, $support_js, $is_debug, $timeLimitThreshold; |
3854 | 4046 | |
3855 | - if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) |
|
3856 | - $is_debug = true; |
|
4047 | + if (empty($is_debug) && !empty($upcontext['upgrade_status']['debug'])) { |
|
4048 | + $is_debug = true; |
|
4049 | + } |
|
3857 | 4050 | |
3858 | 4051 | echo ' |
3859 | 4052 | <h3>Executing database changes</h3> |
@@ -3868,8 +4061,9 @@ discard block |
||
3868 | 4061 | { |
3869 | 4062 | foreach ($upcontext['actioned_items'] as $num => $item) |
3870 | 4063 | { |
3871 | - if ($num != 0) |
|
3872 | - echo ' Successful!'; |
|
4064 | + if ($num != 0) { |
|
4065 | + echo ' Successful!'; |
|
4066 | + } |
|
3873 | 4067 | echo '<br>' . $item; |
3874 | 4068 | } |
3875 | 4069 | if (!empty($upcontext['changes_complete'])) |
@@ -3882,28 +4076,32 @@ discard block |
||
3882 | 4076 | $seconds = intval($active % 60); |
3883 | 4077 | |
3884 | 4078 | $totalTime = ''; |
3885 | - if ($hours > 0) |
|
3886 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3887 | - if ($minutes > 0) |
|
3888 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3889 | - if ($seconds > 0) |
|
3890 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4079 | + if ($hours > 0) { |
|
4080 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4081 | + } |
|
4082 | + if ($minutes > 0) { |
|
4083 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4084 | + } |
|
4085 | + if ($seconds > 0) { |
|
4086 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4087 | + } |
|
3891 | 4088 | } |
3892 | 4089 | |
3893 | - if ($is_debug && !empty($totalTime)) |
|
3894 | - echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
3895 | - else |
|
3896 | - echo ' Successful!<br><br>'; |
|
4090 | + if ($is_debug && !empty($totalTime)) { |
|
4091 | + echo ' Successful! Completed in ', $totalTime, '<br><br>'; |
|
4092 | + } else { |
|
4093 | + echo ' Successful!<br><br>'; |
|
4094 | + } |
|
3897 | 4095 | |
3898 | 4096 | echo '<span id="commess" style="font-weight: bold;">1 Database Updates Complete! Click Continue to Proceed.</span><br>'; |
3899 | 4097 | } |
3900 | - } |
|
3901 | - else |
|
4098 | + } else |
|
3902 | 4099 | { |
3903 | 4100 | // Tell them how many files we have in total. |
3904 | - if ($upcontext['file_count'] > 1) |
|
3905 | - echo ' |
|
4101 | + if ($upcontext['file_count'] > 1) { |
|
4102 | + echo ' |
|
3906 | 4103 | <strong id="info1">Executing upgrade script <span id="file_done">', $upcontext['cur_file_num'], '</span> of ', $upcontext['file_count'], '.</strong>'; |
4104 | + } |
|
3907 | 4105 | |
3908 | 4106 | echo ' |
3909 | 4107 | <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> |
@@ -3919,19 +4117,23 @@ discard block |
||
3919 | 4117 | $seconds = intval($active % 60); |
3920 | 4118 | |
3921 | 4119 | $totalTime = ''; |
3922 | - if ($hours > 0) |
|
3923 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
3924 | - if ($minutes > 0) |
|
3925 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
3926 | - if ($seconds > 0) |
|
3927 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4120 | + if ($hours > 0) { |
|
4121 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4122 | + } |
|
4123 | + if ($minutes > 0) { |
|
4124 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4125 | + } |
|
4126 | + if ($seconds > 0) { |
|
4127 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4128 | + } |
|
3928 | 4129 | } |
3929 | 4130 | |
3930 | 4131 | echo ' |
3931 | 4132 | <br><span id="upgradeCompleted">'; |
3932 | 4133 | |
3933 | - if (!empty($totalTime)) |
|
3934 | - echo 'Completed in ', $totalTime, '<br>'; |
|
4134 | + if (!empty($totalTime)) { |
|
4135 | + echo 'Completed in ', $totalTime, '<br>'; |
|
4136 | + } |
|
3935 | 4137 | |
3936 | 4138 | echo '</span> |
3937 | 4139 | <div id="debug_section" style="height: 200px; overflow: auto;"> |
@@ -3968,9 +4170,10 @@ discard block |
||
3968 | 4170 | var getData = ""; |
3969 | 4171 | var debugItems = ', $upcontext['debug_items'], ';'; |
3970 | 4172 | |
3971 | - if ($is_debug) |
|
3972 | - echo ' |
|
4173 | + if ($is_debug) { |
|
4174 | + echo ' |
|
3973 | 4175 | var upgradeStartTime = ' . $upcontext['started'] . ';'; |
4176 | + } |
|
3974 | 4177 | |
3975 | 4178 | echo ' |
3976 | 4179 | function getNextItem() |
@@ -4010,9 +4213,10 @@ discard block |
||
4010 | 4213 | document.getElementById("error_block").style.display = ""; |
4011 | 4214 | setInnerHTML(document.getElementById("error_message"), "Error retrieving information on step: " + (sDebugName == "" ? sLastString : sDebugName));'; |
4012 | 4215 | |
4013 | - if ($is_debug) |
|
4014 | - echo ' |
|
4216 | + if ($is_debug) { |
|
4217 | + echo ' |
|
4015 | 4218 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4219 | + } |
|
4016 | 4220 | |
4017 | 4221 | echo ' |
4018 | 4222 | } |
@@ -4033,9 +4237,10 @@ discard block |
||
4033 | 4237 | document.getElementById("error_block").style.display = ""; |
4034 | 4238 | setInnerHTML(document.getElementById("error_message"), "Upgrade script appears to be going into a loop - step: " + sDebugName);'; |
4035 | 4239 | |
4036 | - if ($is_debug) |
|
4037 | - echo ' |
|
4240 | + if ($is_debug) { |
|
4241 | + echo ' |
|
4038 | 4242 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<span style="color: red;">failed<\' + \'/span><span id="debuginfo"><\' + \'/span>\');'; |
4243 | + } |
|
4039 | 4244 | |
4040 | 4245 | echo ' |
4041 | 4246 | } |
@@ -4094,8 +4299,8 @@ discard block |
||
4094 | 4299 | if (bIsComplete && iDebugNum == -1 && curFile >= ', $upcontext['file_count'], ') |
4095 | 4300 | {'; |
4096 | 4301 | |
4097 | - if ($is_debug) |
|
4098 | - echo ' |
|
4302 | + if ($is_debug) { |
|
4303 | + echo ' |
|
4099 | 4304 | document.getElementById(\'debug_section\').style.display = "none"; |
4100 | 4305 | |
4101 | 4306 | var upgradeFinishedTime = parseInt(oXMLDoc.getElementsByTagName("curtime")[0].childNodes[0].nodeValue); |
@@ -4113,6 +4318,7 @@ discard block |
||
4113 | 4318 | totalTime = totalTime + diffSeconds + " second" + (diffSeconds > 1 ? "s" : ""); |
4114 | 4319 | |
4115 | 4320 | setInnerHTML(document.getElementById("upgradeCompleted"), "Completed in " + totalTime);'; |
4321 | + } |
|
4116 | 4322 | |
4117 | 4323 | echo ' |
4118 | 4324 | |
@@ -4120,9 +4326,10 @@ discard block |
||
4120 | 4326 | document.getElementById(\'contbutt\').disabled = 0; |
4121 | 4327 | document.getElementById(\'database_done\').value = 1;'; |
4122 | 4328 | |
4123 | - if ($upcontext['file_count'] > 1) |
|
4124 | - echo ' |
|
4329 | + if ($upcontext['file_count'] > 1) { |
|
4330 | + echo ' |
|
4125 | 4331 | document.getElementById(\'info1\').style.display = "none";'; |
4332 | + } |
|
4126 | 4333 | |
4127 | 4334 | echo ' |
4128 | 4335 | document.getElementById(\'info2\').style.display = "none"; |
@@ -4135,9 +4342,10 @@ discard block |
||
4135 | 4342 | lastItem = 0; |
4136 | 4343 | prevFile = curFile;'; |
4137 | 4344 | |
4138 | - if ($is_debug) |
|
4139 | - echo ' |
|
4345 | + if ($is_debug) { |
|
4346 | + echo ' |
|
4140 | 4347 | setOuterHTML(document.getElementById(\'debuginfo\'), \'Moving to next script file...done<br><span id="debuginfo"><\' + \'/span>\');'; |
4348 | + } |
|
4141 | 4349 | |
4142 | 4350 | echo ' |
4143 | 4351 | getNextItem(); |
@@ -4145,8 +4353,8 @@ discard block |
||
4145 | 4353 | }'; |
4146 | 4354 | |
4147 | 4355 | // If debug scroll the screen. |
4148 | - if ($is_debug) |
|
4149 | - echo ' |
|
4356 | + if ($is_debug) { |
|
4357 | + echo ' |
|
4150 | 4358 | if (iLastSubStepProgress == -1) |
4151 | 4359 | { |
4152 | 4360 | // Give it consistent dots. |
@@ -4165,6 +4373,7 @@ discard block |
||
4165 | 4373 | |
4166 | 4374 | if (document.getElementById(\'debug_section\').scrollHeight) |
4167 | 4375 | document.getElementById(\'debug_section\').scrollTop = document.getElementById(\'debug_section\').scrollHeight'; |
4376 | + } |
|
4168 | 4377 | |
4169 | 4378 | echo ' |
4170 | 4379 | // Update the page. |
@@ -4225,9 +4434,10 @@ discard block |
||
4225 | 4434 | }'; |
4226 | 4435 | |
4227 | 4436 | // Start things off assuming we've not errored. |
4228 | - if (empty($upcontext['error_message'])) |
|
4229 | - echo ' |
|
4437 | + if (empty($upcontext['error_message'])) { |
|
4438 | + echo ' |
|
4230 | 4439 | getNextItem();'; |
4440 | + } |
|
4231 | 4441 | |
4232 | 4442 | echo ' |
4233 | 4443 | </script>'; |
@@ -4244,18 +4454,21 @@ discard block |
||
4244 | 4454 | <item num="', $upcontext['current_item_num'], '">', $upcontext['current_item_name'], '</item> |
4245 | 4455 | <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>'; |
4246 | 4456 | |
4247 | - if (!empty($upcontext['error_message'])) |
|
4248 | - echo ' |
|
4457 | + if (!empty($upcontext['error_message'])) { |
|
4458 | + echo ' |
|
4249 | 4459 | <error>', $upcontext['error_message'], '</error>'; |
4460 | + } |
|
4250 | 4461 | |
4251 | - if (!empty($upcontext['error_string'])) |
|
4252 | - echo ' |
|
4462 | + if (!empty($upcontext['error_string'])) { |
|
4463 | + echo ' |
|
4253 | 4464 | <sql>', $upcontext['error_string'], '</sql>'; |
4465 | + } |
|
4254 | 4466 | |
4255 | - if ($is_debug) |
|
4256 | - echo ' |
|
4467 | + if ($is_debug) { |
|
4468 | + echo ' |
|
4257 | 4469 | <curtime>', time(), '</curtime>'; |
4258 | -} |
|
4470 | + } |
|
4471 | + } |
|
4259 | 4472 | |
4260 | 4473 | // Template for the UTF-8 conversion step. Basically a copy of the backup stuff with slight modifications.... |
4261 | 4474 | function template_convert_utf8() |
@@ -4272,18 +4485,20 @@ discard block |
||
4272 | 4485 | <span id="debuginfo"></span>'; |
4273 | 4486 | |
4274 | 4487 | // Done any tables so far? |
4275 | - if (!empty($upcontext['previous_tables'])) |
|
4276 | - foreach ($upcontext['previous_tables'] as $table) |
|
4488 | + if (!empty($upcontext['previous_tables'])) { |
|
4489 | + foreach ($upcontext['previous_tables'] as $table) |
|
4277 | 4490 | echo ' |
4278 | 4491 | <br>Completed Table: "', $table, '".'; |
4492 | + } |
|
4279 | 4493 | |
4280 | 4494 | echo ' |
4281 | 4495 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3>'; |
4282 | 4496 | |
4283 | 4497 | // If we dropped their index, let's let them know |
4284 | - if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) |
|
4285 | - echo ' |
|
4498 | + if ($upcontext['cur_table_num'] == $upcontext['table_count'] && $upcontext['dropping_index']) { |
|
4499 | + echo ' |
|
4286 | 4500 | <br><span style="display:inline;">Please note that your fulltext index was dropped to facilitate the conversion and will need to be recreated.</span>'; |
4501 | + } |
|
4287 | 4502 | |
4288 | 4503 | echo ' |
4289 | 4504 | <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>'; |
@@ -4319,9 +4534,10 @@ discard block |
||
4319 | 4534 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4320 | 4535 | |
4321 | 4536 | // If debug flood the screen. |
4322 | - if ($is_debug) |
|
4323 | - echo ' |
|
4537 | + if ($is_debug) { |
|
4538 | + echo ' |
|
4324 | 4539 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
4540 | + } |
|
4325 | 4541 | |
4326 | 4542 | echo ' |
4327 | 4543 | // Get the next update... |
@@ -4363,19 +4579,21 @@ discard block |
||
4363 | 4579 | <span id="debuginfo"></span>'; |
4364 | 4580 | |
4365 | 4581 | // Dont any tables so far? |
4366 | - if (!empty($upcontext['previous_tables'])) |
|
4367 | - foreach ($upcontext['previous_tables'] as $table) |
|
4582 | + if (!empty($upcontext['previous_tables'])) { |
|
4583 | + foreach ($upcontext['previous_tables'] as $table) |
|
4368 | 4584 | echo ' |
4369 | 4585 | <br>Completed Table: "', $table, '".'; |
4586 | + } |
|
4370 | 4587 | |
4371 | 4588 | echo ' |
4372 | 4589 | <h3 id="current_tab_div">Current Table: "<span id="current_table">', $upcontext['cur_table_name'], '</span>"</h3> |
4373 | 4590 | <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>'; |
4374 | 4591 | |
4375 | 4592 | // Try to make sure substep was reset. |
4376 | - if ($upcontext['cur_table_num'] == $upcontext['table_count']) |
|
4377 | - echo ' |
|
4593 | + if ($upcontext['cur_table_num'] == $upcontext['table_count']) { |
|
4594 | + echo ' |
|
4378 | 4595 | <input type="hidden" name="substep" id="substep" value="0">'; |
4596 | + } |
|
4379 | 4597 | |
4380 | 4598 | // Continue please! |
4381 | 4599 | $upcontext['continue'] = $support_js ? 2 : 1; |
@@ -4408,9 +4626,10 @@ discard block |
||
4408 | 4626 | updateStepProgress(iTableNum, ', $upcontext['table_count'], ', ', $upcontext['step_weight'] * ((100 - $upcontext['step_progress']) / 100), ');'; |
4409 | 4627 | |
4410 | 4628 | // If debug flood the screen. |
4411 | - if ($is_debug) |
|
4412 | - echo ' |
|
4629 | + if ($is_debug) { |
|
4630 | + echo ' |
|
4413 | 4631 | setOuterHTML(document.getElementById(\'debuginfo\'), \'<br>Completed Table: "\' + sCompletedTableName + \'".<span id="debuginfo"><\' + \'/span>\');'; |
4632 | + } |
|
4414 | 4633 | |
4415 | 4634 | echo ' |
4416 | 4635 | // Get the next update... |
@@ -4445,8 +4664,8 @@ discard block |
||
4445 | 4664 | <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> |
4446 | 4665 | <form action="', $boardurl, '/index.php">'; |
4447 | 4666 | |
4448 | - if (!empty($upcontext['can_delete_script'])) |
|
4449 | - echo ' |
|
4667 | + if (!empty($upcontext['can_delete_script'])) { |
|
4668 | + echo ' |
|
4450 | 4669 | <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> |
4451 | 4670 | <script> |
4452 | 4671 | function doTheDelete(theCheck) |
@@ -4458,6 +4677,7 @@ discard block |
||
4458 | 4677 | } |
4459 | 4678 | </script> |
4460 | 4679 | <img src="', $settings['default_theme_url'], '/images/blank.png" alt="" id="delete_upgrader"><br>'; |
4680 | + } |
|
4461 | 4681 | |
4462 | 4682 | $active = time() - $upcontext['started']; |
4463 | 4683 | $hours = floor($active / 3600); |
@@ -4467,16 +4687,20 @@ discard block |
||
4467 | 4687 | if ($is_debug) |
4468 | 4688 | { |
4469 | 4689 | $totalTime = ''; |
4470 | - if ($hours > 0) |
|
4471 | - $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4472 | - if ($minutes > 0) |
|
4473 | - $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4474 | - if ($seconds > 0) |
|
4475 | - $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4690 | + if ($hours > 0) { |
|
4691 | + $totalTime .= $hours . ' hour' . ($hours > 1 ? 's' : '') . ' '; |
|
4692 | + } |
|
4693 | + if ($minutes > 0) { |
|
4694 | + $totalTime .= $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' '; |
|
4695 | + } |
|
4696 | + if ($seconds > 0) { |
|
4697 | + $totalTime .= $seconds . ' second' . ($seconds > 1 ? 's' : '') . ' '; |
|
4698 | + } |
|
4476 | 4699 | } |
4477 | 4700 | |
4478 | - if ($is_debug && !empty($totalTime)) |
|
4479 | - echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4701 | + if ($is_debug && !empty($totalTime)) { |
|
4702 | + echo '<br> Upgrade completed in ', $totalTime, '<br><br>'; |
|
4703 | + } |
|
4480 | 4704 | |
4481 | 4705 | echo '<br> |
4482 | 4706 | 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> |
@@ -4543,16 +4767,19 @@ discard block |
||
4543 | 4767 | 'empty' => '', |
4544 | 4768 | 'limit' => $limit, |
4545 | 4769 | )); |
4546 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4547 | - $arIp[] = $row[$oldCol]; |
|
4770 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
4771 | + $arIp[] = $row[$oldCol]; |
|
4772 | + } |
|
4548 | 4773 | $smcFunc['db_free_result']($request); |
4549 | 4774 | |
4550 | 4775 | // Special case, null ip could keep us in a loop. |
4551 | - if (is_null($arIp[0])) |
|
4552 | - unset($arIp[0]); |
|
4776 | + if (is_null($arIp[0])) { |
|
4777 | + unset($arIp[0]); |
|
4778 | + } |
|
4553 | 4779 | |
4554 | - if (empty($arIp)) |
|
4555 | - $is_done = true; |
|
4780 | + if (empty($arIp)) { |
|
4781 | + $is_done = true; |
|
4782 | + } |
|
4556 | 4783 | |
4557 | 4784 | $updates = array(); |
4558 | 4785 | $cases = array(); |
@@ -4561,16 +4788,18 @@ discard block |
||
4561 | 4788 | { |
4562 | 4789 | $arIp[$i] = trim($arIp[$i]); |
4563 | 4790 | |
4564 | - if (empty($arIp[$i])) |
|
4565 | - continue; |
|
4791 | + if (empty($arIp[$i])) { |
|
4792 | + continue; |
|
4793 | + } |
|
4566 | 4794 | |
4567 | 4795 | $updates['ip' . $i] = $arIp[$i]; |
4568 | 4796 | $cases[$arIp[$i]] = 'WHEN ' . $oldCol . ' = {string:ip' . $i . '} THEN {inet:ip' . $i . '}'; |
4569 | 4797 | |
4570 | 4798 | if ($setSize > 0 && $i % $setSize === 0) |
4571 | 4799 | { |
4572 | - if (count($updates) == 1) |
|
4573 | - continue; |
|
4800 | + if (count($updates) == 1) { |
|
4801 | + continue; |
|
4802 | + } |
|
4574 | 4803 | |
4575 | 4804 | $updates['whereSet'] = array_values($updates); |
4576 | 4805 | $smcFunc['db_query']('', ' |
@@ -4604,8 +4833,7 @@ discard block |
||
4604 | 4833 | 'ip' => $ip |
4605 | 4834 | )); |
4606 | 4835 | } |
4607 | - } |
|
4608 | - else |
|
4836 | + } else |
|
4609 | 4837 | { |
4610 | 4838 | $updates['whereSet'] = array_values($updates); |
4611 | 4839 | $smcFunc['db_query']('', ' |
@@ -4619,9 +4847,9 @@ discard block |
||
4619 | 4847 | $updates |
4620 | 4848 | ); |
4621 | 4849 | } |
4850 | + } else { |
|
4851 | + $is_done = true; |
|
4622 | 4852 | } |
4623 | - else |
|
4624 | - $is_done = true; |
|
4625 | 4853 | |
4626 | 4854 | $_GET['a'] += $limit; |
4627 | 4855 | $step_progress['current'] = $_GET['a']; |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
21 | 21 | |
22 | 22 | // Let's pull in useful classes |
23 | -if (!defined('SMF')) |
|
23 | +if (!defined('SMF')) { |
|
24 | 24 | define('SMF', 1); |
25 | +} |
|
25 | 26 | |
26 | 27 | require_once('Sources/Class-Package.php'); |
27 | 28 | |
@@ -63,12 +64,14 @@ discard block |
||
63 | 64 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
64 | 65 | |
65 | 66 | // Is it reserved? |
66 | - if ($value == 'pg_') |
|
67 | - return $txt['error_db_prefix_reserved']; |
|
67 | + if ($value == 'pg_') { |
|
68 | + return $txt['error_db_prefix_reserved']; |
|
69 | + } |
|
68 | 70 | |
69 | 71 | // Is the prefix numeric? |
70 | - if (preg_match('~^\d~', $value)) |
|
71 | - return $txt['error_db_prefix_numeric']; |
|
72 | + if (preg_match('~^\d~', $value)) { |
|
73 | + return $txt['error_db_prefix_numeric']; |
|
74 | + } |
|
72 | 75 | |
73 | 76 | return true; |
74 | 77 | }, |
@@ -115,10 +118,11 @@ discard block |
||
115 | 118 | $incontext['skip'] = false; |
116 | 119 | |
117 | 120 | // Call the step and if it returns false that means pause! |
118 | - if (function_exists($step[2]) && $step[2]() === false) |
|
119 | - break; |
|
120 | - elseif (function_exists($step[2])) |
|
121 | - $incontext['current_step']++; |
|
121 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
122 | + break; |
|
123 | + } elseif (function_exists($step[2])) { |
|
124 | + $incontext['current_step']++; |
|
125 | + } |
|
122 | 126 | |
123 | 127 | // No warnings pass on. |
124 | 128 | $incontext['warning'] = ''; |
@@ -134,12 +138,14 @@ discard block |
||
134 | 138 | global $databases, $incontext; |
135 | 139 | |
136 | 140 | // Just so people using older versions of PHP aren't left in the cold. |
137 | - if (!isset($_SERVER['PHP_SELF'])) |
|
138 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
141 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
142 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
143 | + } |
|
139 | 144 | |
140 | 145 | // Turn off magic quotes runtime and enable error reporting. |
141 | - if (function_exists('set_magic_quotes_runtime')) |
|
142 | - @set_magic_quotes_runtime(0); |
|
146 | + if (function_exists('set_magic_quotes_runtime')) { |
|
147 | + @set_magic_quotes_runtime(0); |
|
148 | + } |
|
143 | 149 | error_reporting(E_ALL); |
144 | 150 | |
145 | 151 | // Fun. Low PHP version... |
@@ -153,21 +159,23 @@ discard block |
||
153 | 159 | { |
154 | 160 | ob_start(); |
155 | 161 | |
156 | - if (ini_get('session.save_handler') == 'user') |
|
157 | - @ini_set('session.save_handler', 'files'); |
|
158 | - if (function_exists('session_start')) |
|
159 | - @session_start(); |
|
160 | - } |
|
161 | - else |
|
162 | + if (ini_get('session.save_handler') == 'user') { |
|
163 | + @ini_set('session.save_handler', 'files'); |
|
164 | + } |
|
165 | + if (function_exists('session_start')) { |
|
166 | + @session_start(); |
|
167 | + } |
|
168 | + } else |
|
162 | 169 | { |
163 | 170 | ob_start('ob_gzhandler'); |
164 | 171 | |
165 | - if (ini_get('session.save_handler') == 'user') |
|
166 | - @ini_set('session.save_handler', 'files'); |
|
172 | + if (ini_get('session.save_handler') == 'user') { |
|
173 | + @ini_set('session.save_handler', 'files'); |
|
174 | + } |
|
167 | 175 | session_start(); |
168 | 176 | |
169 | - if (!headers_sent()) |
|
170 | - echo '<!DOCTYPE html> |
|
177 | + if (!headers_sent()) { |
|
178 | + echo '<!DOCTYPE html> |
|
171 | 179 | <html> |
172 | 180 | <head> |
173 | 181 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -176,6 +184,7 @@ discard block |
||
176 | 184 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
177 | 185 | </body> |
178 | 186 | </html>'; |
187 | + } |
|
179 | 188 | exit; |
180 | 189 | } |
181 | 190 | |
@@ -184,16 +193,18 @@ discard block |
||
184 | 193 | { |
185 | 194 | $incontext['remote_files_available'] = false; |
186 | 195 | $test = @fsockopen('www.simplemachines.org', 80, $errno, $errstr, 1); |
187 | - if ($test) |
|
188 | - $incontext['remote_files_available'] = true; |
|
196 | + if ($test) { |
|
197 | + $incontext['remote_files_available'] = true; |
|
198 | + } |
|
189 | 199 | @fclose($test); |
190 | 200 | } |
191 | 201 | |
192 | 202 | // Add slashes, as long as they aren't already being added. |
193 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
194 | - foreach ($_POST as $k => $v) |
|
203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
204 | + foreach ($_POST as $k => $v) |
|
195 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
196 | 206 | $_POST[$k] = addslashes($v); |
207 | + } |
|
197 | 208 | |
198 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
199 | 210 | if (isset($_GET['delete'])) |
@@ -214,8 +225,7 @@ discard block |
||
214 | 225 | $ftp->close(); |
215 | 226 | |
216 | 227 | unset($_SESSION['installer_temp_ftp']); |
217 | - } |
|
218 | - else |
|
228 | + } else |
|
219 | 229 | { |
220 | 230 | @unlink(__FILE__); |
221 | 231 | |
@@ -236,10 +246,11 @@ discard block |
||
236 | 246 | { |
237 | 247 | // Get PHP's default timezone, if set |
238 | 248 | $ini_tz = ini_get('date.timezone'); |
239 | - if (!empty($ini_tz)) |
|
240 | - $timezone_id = $ini_tz; |
|
241 | - else |
|
242 | - $timezone_id = ''; |
|
249 | + if (!empty($ini_tz)) { |
|
250 | + $timezone_id = $ini_tz; |
|
251 | + } else { |
|
252 | + $timezone_id = ''; |
|
253 | + } |
|
243 | 254 | |
244 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
245 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -269,8 +280,9 @@ discard block |
||
269 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
270 | 281 | while ($entry = $dir->read()) |
271 | 282 | { |
272 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
273 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
283 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
284 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
285 | + } |
|
274 | 286 | } |
275 | 287 | $dir->close(); |
276 | 288 | } |
@@ -305,10 +317,11 @@ discard block |
||
305 | 317 | } |
306 | 318 | |
307 | 319 | // Override the language file? |
308 | - if (isset($_GET['lang_file'])) |
|
309 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
310 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
311 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
320 | + if (isset($_GET['lang_file'])) { |
|
321 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
322 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
323 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
324 | + } |
|
312 | 325 | |
313 | 326 | // Make sure it exists, if it doesn't reset it. |
314 | 327 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -317,8 +330,9 @@ discard block |
||
317 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
318 | 331 | |
319 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
320 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
321 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
333 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
334 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
335 | + } |
|
322 | 336 | } |
323 | 337 | |
324 | 338 | // And now include the actual language file itself. |
@@ -331,15 +345,18 @@ discard block |
||
331 | 345 | global $db_prefix, $db_connection, $sourcedir; |
332 | 346 | global $smcFunc, $modSettings, $db_type, $db_name, $db_user, $db_persist; |
333 | 347 | |
334 | - if (empty($sourcedir)) |
|
335 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
348 | + if (empty($sourcedir)) { |
|
349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
350 | + } |
|
336 | 351 | |
337 | 352 | // Need this to check whether we need the database password. |
338 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
339 | - if (!defined('SMF')) |
|
340 | - define('SMF', 1); |
|
341 | - if (empty($smcFunc)) |
|
342 | - $smcFunc = array(); |
|
354 | + if (!defined('SMF')) { |
|
355 | + define('SMF', 1); |
|
356 | + } |
|
357 | + if (empty($smcFunc)) { |
|
358 | + $smcFunc = array(); |
|
359 | + } |
|
343 | 360 | |
344 | 361 | $modSettings['disableQueryCheck'] = true; |
345 | 362 | |
@@ -347,8 +364,9 @@ discard block |
||
347 | 364 | if (!$db_connection) |
348 | 365 | { |
349 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
350 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
351 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
369 | + } |
|
352 | 370 | |
353 | 371 | $db_options = array('persist' => $db_persist); |
354 | 372 | $port = ''; |
@@ -359,19 +377,20 @@ discard block |
||
359 | 377 | if ($db_type == 'mysql') |
360 | 378 | { |
361 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
362 | - } |
|
363 | - elseif ($db_type == 'postgresql') |
|
380 | + } elseif ($db_type == 'postgresql') |
|
364 | 381 | { |
365 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
366 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
367 | 384 | } |
368 | 385 | } |
369 | 386 | |
370 | - if (!empty($port)) |
|
371 | - $db_options['port'] = $port; |
|
387 | + if (!empty($port)) { |
|
388 | + $db_options['port'] = $port; |
|
389 | + } |
|
372 | 390 | |
373 | - if (!$db_connection) |
|
374 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
391 | + if (!$db_connection) { |
|
392 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
393 | + } |
|
375 | 394 | } |
376 | 395 | } |
377 | 396 | |
@@ -399,8 +418,9 @@ discard block |
||
399 | 418 | // @todo REMOVE THIS!! |
400 | 419 | else |
401 | 420 | { |
402 | - if (function_exists('doStep' . $_GET['step'])) |
|
403 | - call_user_func('doStep' . $_GET['step']); |
|
421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
422 | + call_user_func('doStep' . $_GET['step']); |
|
423 | + } |
|
404 | 424 | } |
405 | 425 | // Show the footer. |
406 | 426 | template_install_below(); |
@@ -418,8 +438,9 @@ discard block |
||
418 | 438 | $incontext['sub_template'] = 'welcome_message'; |
419 | 439 | |
420 | 440 | // Done the submission? |
421 | - if (isset($_POST['contbutt'])) |
|
422 | - return true; |
|
441 | + if (isset($_POST['contbutt'])) { |
|
442 | + return true; |
|
443 | + } |
|
423 | 444 | |
424 | 445 | // See if we think they have already installed it? |
425 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -427,14 +448,17 @@ discard block |
||
427 | 448 | $probably_installed = 0; |
428 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
429 | 450 | { |
430 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
431 | - $probably_installed++; |
|
432 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
433 | - $probably_installed++; |
|
451 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
452 | + $probably_installed++; |
|
453 | + } |
|
454 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
455 | + $probably_installed++; |
|
456 | + } |
|
434 | 457 | } |
435 | 458 | |
436 | - if ($probably_installed == 2) |
|
437 | - $incontext['warning'] = $txt['error_already_installed']; |
|
459 | + if ($probably_installed == 2) { |
|
460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
461 | + } |
|
438 | 462 | } |
439 | 463 | |
440 | 464 | // Is some database support even compiled in? |
@@ -449,36 +473,43 @@ discard block |
||
449 | 473 | $databases[$key]['supported'] = false; |
450 | 474 | $notFoundSQLFile = true; |
451 | 475 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
476 | + } else { |
|
477 | + $incontext['supported_databases'][] = $db; |
|
452 | 478 | } |
453 | - else |
|
454 | - $incontext['supported_databases'][] = $db; |
|
455 | 479 | } |
456 | 480 | } |
457 | 481 | |
458 | 482 | // Check the PHP version. |
459 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) |
|
460 | - $error = 'error_php_too_low'; |
|
483 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>'))) { |
|
484 | + $error = 'error_php_too_low'; |
|
485 | + } |
|
461 | 486 | // Make sure we have a supported database |
462 | - elseif (empty($incontext['supported_databases'])) |
|
463 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
487 | + elseif (empty($incontext['supported_databases'])) { |
|
488 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
489 | + } |
|
464 | 490 | // How about session support? Some crazy sysadmin remove it? |
465 | - elseif (!function_exists('session_start')) |
|
466 | - $error = 'error_session_missing'; |
|
491 | + elseif (!function_exists('session_start')) { |
|
492 | + $error = 'error_session_missing'; |
|
493 | + } |
|
467 | 494 | // Make sure they uploaded all the files. |
468 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
469 | - $error = 'error_missing_files'; |
|
495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
496 | + $error = 'error_missing_files'; |
|
497 | + } |
|
470 | 498 | // Very simple check on the session.save_path for Windows. |
471 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
472 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
473 | - $error = 'error_session_save_path'; |
|
500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
501 | + $error = 'error_session_save_path'; |
|
502 | + } |
|
474 | 503 | |
475 | 504 | // Since each of the three messages would look the same, anyway... |
476 | - if (isset($error)) |
|
477 | - $incontext['error'] = $txt[$error]; |
|
505 | + if (isset($error)) { |
|
506 | + $incontext['error'] = $txt[$error]; |
|
507 | + } |
|
478 | 508 | |
479 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
480 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
481 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
510 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
511 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
512 | + } |
|
482 | 513 | |
483 | 514 | return false; |
484 | 515 | } |
@@ -503,12 +534,14 @@ discard block |
||
503 | 534 | 'Settings_bak.php', |
504 | 535 | ); |
505 | 536 | |
506 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
507 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
537 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
538 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
539 | + } |
|
508 | 540 | |
509 | 541 | // With mod_security installed, we could attempt to fix it with .htaccess. |
510 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
511 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
542 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
543 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
544 | + } |
|
512 | 545 | |
513 | 546 | $failed_files = array(); |
514 | 547 | |
@@ -524,12 +557,14 @@ discard block |
||
524 | 557 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
525 | 558 | |
526 | 559 | // Well, 755 hopefully worked... if not, try 777. |
527 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
528 | - $failed_files[] = $file; |
|
560 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
561 | + $failed_files[] = $file; |
|
562 | + } |
|
529 | 563 | } |
530 | 564 | } |
531 | - foreach ($extra_files as $file) |
|
532 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
565 | + foreach ($extra_files as $file) { |
|
566 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
567 | + } |
|
533 | 568 | } |
534 | 569 | // Windows is trickier. Let's try opening for r+... |
535 | 570 | else |
@@ -539,30 +574,35 @@ discard block |
||
539 | 574 | foreach ($writable_files as $file) |
540 | 575 | { |
541 | 576 | // Folders can't be opened for write... but the index.php in them can ;) |
542 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
543 | - $file .= '/index.php'; |
|
577 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
578 | + $file .= '/index.php'; |
|
579 | + } |
|
544 | 580 | |
545 | 581 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
546 | 582 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
547 | 583 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
548 | 584 | |
549 | 585 | // Hmm, okay, try just for write in that case... |
550 | - if (!is_resource($fp)) |
|
551 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
586 | + if (!is_resource($fp)) { |
|
587 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
588 | + } |
|
552 | 589 | |
553 | - if (!is_resource($fp)) |
|
554 | - $failed_files[] = $file; |
|
590 | + if (!is_resource($fp)) { |
|
591 | + $failed_files[] = $file; |
|
592 | + } |
|
555 | 593 | |
556 | 594 | @fclose($fp); |
557 | 595 | } |
558 | - foreach ($extra_files as $file) |
|
559 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
596 | + foreach ($extra_files as $file) { |
|
597 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
598 | + } |
|
560 | 599 | } |
561 | 600 | |
562 | 601 | $failure = count($failed_files) >= 1; |
563 | 602 | |
564 | - if (!isset($_SERVER)) |
|
565 | - return !$failure; |
|
603 | + if (!isset($_SERVER)) { |
|
604 | + return !$failure; |
|
605 | + } |
|
566 | 606 | |
567 | 607 | // Put the list into context. |
568 | 608 | $incontext['failed_files'] = $failed_files; |
@@ -610,19 +650,23 @@ discard block |
||
610 | 650 | |
611 | 651 | if (!isset($ftp) || $ftp->error !== false) |
612 | 652 | { |
613 | - if (!isset($ftp)) |
|
614 | - $ftp = new ftp_connection(null); |
|
653 | + if (!isset($ftp)) { |
|
654 | + $ftp = new ftp_connection(null); |
|
655 | + } |
|
615 | 656 | // Save the error so we can mess with listing... |
616 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
617 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
657 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
658 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
659 | + } |
|
618 | 660 | |
619 | 661 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
620 | 662 | |
621 | - if (empty($_POST['ftp_path']) && $found_path) |
|
622 | - $_POST['ftp_path'] = $detect_path; |
|
663 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
664 | + $_POST['ftp_path'] = $detect_path; |
|
665 | + } |
|
623 | 666 | |
624 | - if (!isset($_POST['ftp_username'])) |
|
625 | - $_POST['ftp_username'] = $username; |
|
667 | + if (!isset($_POST['ftp_username'])) { |
|
668 | + $_POST['ftp_username'] = $username; |
|
669 | + } |
|
626 | 670 | |
627 | 671 | // Set the username etc, into context. |
628 | 672 | $incontext['ftp'] = array( |
@@ -634,8 +678,7 @@ discard block |
||
634 | 678 | ); |
635 | 679 | |
636 | 680 | return false; |
637 | - } |
|
638 | - else |
|
681 | + } else |
|
639 | 682 | { |
640 | 683 | $_SESSION['installer_temp_ftp'] = array( |
641 | 684 | 'server' => $_POST['ftp_server'], |
@@ -649,10 +692,12 @@ discard block |
||
649 | 692 | |
650 | 693 | foreach ($failed_files as $file) |
651 | 694 | { |
652 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
653 | - $ftp->chmod($file, 0755); |
|
654 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
655 | - $ftp->chmod($file, 0777); |
|
695 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
696 | + $ftp->chmod($file, 0755); |
|
697 | + } |
|
698 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
699 | + $ftp->chmod($file, 0777); |
|
700 | + } |
|
656 | 701 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
657 | 702 | { |
658 | 703 | $failed_files_updated[] = $file; |
@@ -707,15 +752,17 @@ discard block |
||
707 | 752 | |
708 | 753 | if (!$foundOne) |
709 | 754 | { |
710 | - if (isset($db['default_host'])) |
|
711 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
755 | + if (isset($db['default_host'])) { |
|
756 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
757 | + } |
|
712 | 758 | if (isset($db['default_user'])) |
713 | 759 | { |
714 | 760 | $incontext['db']['user'] = ini_get($db['default_user']); |
715 | 761 | $incontext['db']['name'] = ini_get($db['default_user']); |
716 | 762 | } |
717 | - if (isset($db['default_password'])) |
|
718 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
763 | + if (isset($db['default_password'])) { |
|
764 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
765 | + } |
|
719 | 766 | |
720 | 767 | // For simplicity and less confusion, leave the port blank by default |
721 | 768 | $incontext['db']['port'] = ''; |
@@ -734,10 +781,10 @@ discard block |
||
734 | 781 | $incontext['db']['server'] = $_POST['db_server']; |
735 | 782 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
736 | 783 | |
737 | - if (!empty($_POST['db_port'])) |
|
738 | - $incontext['db']['port'] = $_POST['db_port']; |
|
739 | - } |
|
740 | - else |
|
784 | + if (!empty($_POST['db_port'])) { |
|
785 | + $incontext['db']['port'] = $_POST['db_port']; |
|
786 | + } |
|
787 | + } else |
|
741 | 788 | { |
742 | 789 | $incontext['db']['prefix'] = 'smf_'; |
743 | 790 | } |
@@ -773,10 +820,11 @@ discard block |
||
773 | 820 | if (!empty($_POST['db_port'])) |
774 | 821 | { |
775 | 822 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
776 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
777 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
778 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
779 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
823 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
824 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
825 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
826 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
827 | + } |
|
780 | 828 | } |
781 | 829 | |
782 | 830 | // God I hope it saved! |
@@ -789,8 +837,9 @@ discard block |
||
789 | 837 | // Make sure it works. |
790 | 838 | require(dirname(__FILE__) . '/Settings.php'); |
791 | 839 | |
792 | - if (empty($sourcedir)) |
|
793 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
840 | + if (empty($sourcedir)) { |
|
841 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
842 | + } |
|
794 | 843 | |
795 | 844 | // Better find the database file! |
796 | 845 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -800,18 +849,21 @@ discard block |
||
800 | 849 | } |
801 | 850 | |
802 | 851 | // Now include it for database functions! |
803 | - if (!defined('SMF')) |
|
804 | - define('SMF', 1); |
|
852 | + if (!defined('SMF')) { |
|
853 | + define('SMF', 1); |
|
854 | + } |
|
805 | 855 | |
806 | 856 | $modSettings['disableQueryCheck'] = true; |
807 | - if (empty($smcFunc)) |
|
808 | - $smcFunc = array(); |
|
857 | + if (empty($smcFunc)) { |
|
858 | + $smcFunc = array(); |
|
859 | + } |
|
809 | 860 | |
810 | 861 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
811 | 862 | |
812 | 863 | // What - running PHP4? The shame! |
813 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
814 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
864 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
865 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
866 | + } |
|
815 | 867 | |
816 | 868 | // Attempt a connection. |
817 | 869 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -899,12 +951,14 @@ discard block |
||
899 | 951 | $incontext['page_title'] = $txt['install_settings']; |
900 | 952 | |
901 | 953 | // Let's see if we got the database type correct. |
902 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
903 | - $db_type = $_POST['db_type']; |
|
954 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
955 | + $db_type = $_POST['db_type']; |
|
956 | + } |
|
904 | 957 | |
905 | 958 | // Else we'd better be able to get the connection. |
906 | - else |
|
907 | - load_database(); |
|
959 | + else { |
|
960 | + load_database(); |
|
961 | + } |
|
908 | 962 | |
909 | 963 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
910 | 964 | |
@@ -924,12 +978,14 @@ discard block |
||
924 | 978 | // Submitting? |
925 | 979 | if (isset($_POST['boardurl'])) |
926 | 980 | { |
927 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
928 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
929 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
930 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
931 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
932 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
981 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
982 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
983 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
984 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
985 | + } |
|
986 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
987 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
988 | + } |
|
933 | 989 | |
934 | 990 | // Save these variables. |
935 | 991 | $vars = array( |
@@ -960,10 +1016,10 @@ discard block |
||
960 | 1016 | { |
961 | 1017 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
962 | 1018 | return false; |
963 | - } |
|
964 | - else |
|
965 | - // Set the character set here. |
|
1019 | + } else { |
|
1020 | + // Set the character set here. |
|
966 | 1021 | updateSettingsFile(array('db_character_set' => 'utf8')); |
1022 | + } |
|
967 | 1023 | } |
968 | 1024 | |
969 | 1025 | // Good, skip on. |
@@ -983,8 +1039,9 @@ discard block |
||
983 | 1039 | $incontext['continue'] = 1; |
984 | 1040 | |
985 | 1041 | // Already done? |
986 | - if (isset($_POST['pop_done'])) |
|
987 | - return true; |
|
1042 | + if (isset($_POST['pop_done'])) { |
|
1043 | + return true; |
|
1044 | + } |
|
988 | 1045 | |
989 | 1046 | // Reload settings. |
990 | 1047 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1002,8 +1059,9 @@ discard block |
||
1002 | 1059 | $modSettings = array(); |
1003 | 1060 | if ($result !== false) |
1004 | 1061 | { |
1005 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1006 | - $modSettings[$row['variable']] = $row['value']; |
|
1062 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1063 | + $modSettings[$row['variable']] = $row['value']; |
|
1064 | + } |
|
1007 | 1065 | $smcFunc['db_free_result']($result); |
1008 | 1066 | |
1009 | 1067 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1016,20 +1074,22 @@ discard block |
||
1016 | 1074 | $modSettings['disableQueryCheck'] = true; |
1017 | 1075 | |
1018 | 1076 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
1019 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
1020 | - $smcFunc['db_query']('', ' |
|
1077 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
1078 | + $smcFunc['db_query']('', ' |
|
1021 | 1079 | SET NAMES {string:utf8}', |
1022 | 1080 | array( |
1023 | 1081 | 'db_error_skip' => true, |
1024 | 1082 | 'utf8' => 'utf8', |
1025 | 1083 | ) |
1026 | 1084 | ); |
1085 | + } |
|
1027 | 1086 | |
1028 | 1087 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
1029 | - if (substr(__DIR__, -1) == '\\') |
|
1030 | - $attachdir = __DIR__ . 'attachments'; |
|
1031 | - else |
|
1032 | - $attachdir = __DIR__ . '/attachments'; |
|
1088 | + if (substr(__DIR__, -1) == '\\') { |
|
1089 | + $attachdir = __DIR__ . 'attachments'; |
|
1090 | + } else { |
|
1091 | + $attachdir = __DIR__ . '/attachments'; |
|
1092 | + } |
|
1033 | 1093 | |
1034 | 1094 | $replaces = array( |
1035 | 1095 | '{$db_prefix}' => $db_prefix, |
@@ -1046,8 +1106,9 @@ discard block |
||
1046 | 1106 | |
1047 | 1107 | foreach ($txt as $key => $value) |
1048 | 1108 | { |
1049 | - if (substr($key, 0, 8) == 'default_') |
|
1050 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1109 | + if (substr($key, 0, 8) == 'default_') { |
|
1110 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
1111 | + } |
|
1051 | 1112 | } |
1052 | 1113 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
1053 | 1114 | |
@@ -1062,8 +1123,9 @@ discard block |
||
1062 | 1123 | |
1063 | 1124 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
1064 | 1125 | { |
1065 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
1066 | - $engines[] = $row['Engine']; |
|
1126 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
1127 | + $engines[] = $row['Engine']; |
|
1128 | + } |
|
1067 | 1129 | } |
1068 | 1130 | |
1069 | 1131 | // Done with this now |
@@ -1087,8 +1149,7 @@ discard block |
||
1087 | 1149 | $replaces['START TRANSACTION;'] = ''; |
1088 | 1150 | $replaces['COMMIT;'] = ''; |
1089 | 1151 | } |
1090 | - } |
|
1091 | - else |
|
1152 | + } else |
|
1092 | 1153 | { |
1093 | 1154 | $has_innodb = false; |
1094 | 1155 | } |
@@ -1110,21 +1171,24 @@ discard block |
||
1110 | 1171 | foreach ($sql_lines as $count => $line) |
1111 | 1172 | { |
1112 | 1173 | // No comments allowed! |
1113 | - if (substr(trim($line), 0, 1) != '#') |
|
1114 | - $current_statement .= "\n" . rtrim($line); |
|
1174 | + if (substr(trim($line), 0, 1) != '#') { |
|
1175 | + $current_statement .= "\n" . rtrim($line); |
|
1176 | + } |
|
1115 | 1177 | |
1116 | 1178 | // Is this the end of the query string? |
1117 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
1118 | - continue; |
|
1179 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
1180 | + continue; |
|
1181 | + } |
|
1119 | 1182 | |
1120 | 1183 | // Does this table already exist? If so, don't insert more data into it! |
1121 | 1184 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
1122 | 1185 | { |
1123 | 1186 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1124 | - if (!empty($matches[0])) |
|
1125 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1126 | - else |
|
1127 | - $incontext['sql_results']['insert_dups']++; |
|
1187 | + if (!empty($matches[0])) { |
|
1188 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
1189 | + } else { |
|
1190 | + $incontext['sql_results']['insert_dups']++; |
|
1191 | + } |
|
1128 | 1192 | |
1129 | 1193 | $current_statement = ''; |
1130 | 1194 | continue; |
@@ -1133,8 +1197,9 @@ discard block |
||
1133 | 1197 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
1134 | 1198 | { |
1135 | 1199 | // Use the appropriate function based on the DB type |
1136 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
1137 | - $db_errorno = $db_type . '_errno'; |
|
1200 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
1201 | + $db_errorno = $db_type . '_errno'; |
|
1202 | + } |
|
1138 | 1203 | |
1139 | 1204 | // Error 1050: Table already exists! |
1140 | 1205 | // @todo Needs to be made better! |
@@ -1149,18 +1214,18 @@ discard block |
||
1149 | 1214 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
1150 | 1215 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
1151 | 1216 | } |
1152 | - } |
|
1153 | - else |
|
1217 | + } else |
|
1154 | 1218 | { |
1155 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1156 | - $incontext['sql_results']['tables']++; |
|
1157 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1219 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
1220 | + $incontext['sql_results']['tables']++; |
|
1221 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
1158 | 1222 | { |
1159 | 1223 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
1160 | - if (!empty($matches[0])) |
|
1161 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1162 | - else |
|
1163 | - $incontext['sql_results']['inserts']++; |
|
1224 | + if (!empty($matches[0])) { |
|
1225 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
1226 | + } else { |
|
1227 | + $incontext['sql_results']['inserts']++; |
|
1228 | + } |
|
1164 | 1229 | } |
1165 | 1230 | } |
1166 | 1231 | |
@@ -1173,15 +1238,17 @@ discard block |
||
1173 | 1238 | // Sort out the context for the SQL. |
1174 | 1239 | foreach ($incontext['sql_results'] as $key => $number) |
1175 | 1240 | { |
1176 | - if ($number == 0) |
|
1177 | - unset($incontext['sql_results'][$key]); |
|
1178 | - else |
|
1179 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1241 | + if ($number == 0) { |
|
1242 | + unset($incontext['sql_results'][$key]); |
|
1243 | + } else { |
|
1244 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
1245 | + } |
|
1180 | 1246 | } |
1181 | 1247 | |
1182 | 1248 | // Make sure UTF will be used globally. |
1183 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
1184 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1249 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
1250 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
1251 | + } |
|
1185 | 1252 | |
1186 | 1253 | // Maybe we can auto-detect better cookie settings? |
1187 | 1254 | preg_match('~^http[s]?://([^\.]+?)([^/]*?)(/.*)?$~', $boardurl, $matches); |
@@ -1192,16 +1259,20 @@ discard block |
||
1192 | 1259 | $globalCookies = false; |
1193 | 1260 | |
1194 | 1261 | // Okay... let's see. Using a subdomain other than www.? (not a perfect check.) |
1195 | - if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) |
|
1196 | - $globalCookies = true; |
|
1262 | + if ($matches[2] != '' && (strpos(substr($matches[2], 1), '.') === false || in_array($matches[1], array('forum', 'board', 'community', 'forums', 'support', 'chat', 'help', 'talk', 'boards', 'www')))) { |
|
1263 | + $globalCookies = true; |
|
1264 | + } |
|
1197 | 1265 | // If there's a / in the middle of the path, or it starts with ~... we want local. |
1198 | - if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) |
|
1199 | - $localCookies = true; |
|
1266 | + if (isset($matches[3]) && strlen($matches[3]) > 3 && (substr($matches[3], 0, 2) == '/~' || strpos(substr($matches[3], 1), '/') !== false)) { |
|
1267 | + $localCookies = true; |
|
1268 | + } |
|
1200 | 1269 | |
1201 | - if ($globalCookies) |
|
1202 | - $newSettings[] = array('globalCookies', '1'); |
|
1203 | - if ($localCookies) |
|
1204 | - $newSettings[] = array('localCookies', '1'); |
|
1270 | + if ($globalCookies) { |
|
1271 | + $newSettings[] = array('globalCookies', '1'); |
|
1272 | + } |
|
1273 | + if ($localCookies) { |
|
1274 | + $newSettings[] = array('localCookies', '1'); |
|
1275 | + } |
|
1205 | 1276 | } |
1206 | 1277 | |
1207 | 1278 | // Are we allowing stat collection? |
@@ -1217,32 +1288,36 @@ discard block |
||
1217 | 1288 | fwrite($fp, $out); |
1218 | 1289 | |
1219 | 1290 | $return_data = ''; |
1220 | - while (!feof($fp)) |
|
1221 | - $return_data .= fgets($fp, 128); |
|
1291 | + while (!feof($fp)) { |
|
1292 | + $return_data .= fgets($fp, 128); |
|
1293 | + } |
|
1222 | 1294 | |
1223 | 1295 | fclose($fp); |
1224 | 1296 | |
1225 | 1297 | // Get the unique site ID. |
1226 | 1298 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
1227 | 1299 | |
1228 | - if (!empty($ID[1])) |
|
1229 | - $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
1300 | + if (!empty($ID[1])) { |
|
1301 | + $newSettings[] = array('allow_sm_stats', $ID[1]); |
|
1302 | + } |
|
1230 | 1303 | } |
1231 | 1304 | } |
1232 | 1305 | |
1233 | 1306 | // Are we enabling SSL? |
1234 | - if (!empty($_POST['force_ssl'])) |
|
1235 | - $newSettings[] = array('force_ssl', 2); |
|
1307 | + if (!empty($_POST['force_ssl'])) { |
|
1308 | + $newSettings[] = array('force_ssl', 2); |
|
1309 | + } |
|
1236 | 1310 | |
1237 | 1311 | // Setting a timezone is required. |
1238 | 1312 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
1239 | 1313 | { |
1240 | 1314 | // Get PHP's default timezone, if set |
1241 | 1315 | $ini_tz = ini_get('date.timezone'); |
1242 | - if (!empty($ini_tz)) |
|
1243 | - $timezone_id = $ini_tz; |
|
1244 | - else |
|
1245 | - $timezone_id = ''; |
|
1316 | + if (!empty($ini_tz)) { |
|
1317 | + $timezone_id = $ini_tz; |
|
1318 | + } else { |
|
1319 | + $timezone_id = ''; |
|
1320 | + } |
|
1246 | 1321 | |
1247 | 1322 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
1248 | 1323 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1251,8 +1326,9 @@ discard block |
||
1251 | 1326 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
1252 | 1327 | } |
1253 | 1328 | |
1254 | - if (date_default_timezone_set($timezone_id)) |
|
1255 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
1329 | + if (date_default_timezone_set($timezone_id)) { |
|
1330 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
1331 | + } |
|
1256 | 1332 | } |
1257 | 1333 | |
1258 | 1334 | if (!empty($newSettings)) |
@@ -1283,16 +1359,18 @@ discard block |
||
1283 | 1359 | } |
1284 | 1360 | |
1285 | 1361 | // MySQL specific stuff |
1286 | - if (substr($db_type, 0, 5) != 'mysql') |
|
1287 | - return false; |
|
1362 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
1363 | + return false; |
|
1364 | + } |
|
1288 | 1365 | |
1289 | 1366 | // Find database user privileges. |
1290 | 1367 | $privs = array(); |
1291 | 1368 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
1292 | 1369 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
1293 | 1370 | { |
1294 | - if ($row['Privilege'] == 'Alter') |
|
1295 | - $privs[] = $row['Privilege']; |
|
1371 | + if ($row['Privilege'] == 'Alter') { |
|
1372 | + $privs[] = $row['Privilege']; |
|
1373 | + } |
|
1296 | 1374 | } |
1297 | 1375 | $smcFunc['db_free_result']($get_privs); |
1298 | 1376 | |
@@ -1322,8 +1400,9 @@ discard block |
||
1322 | 1400 | $incontext['continue'] = 1; |
1323 | 1401 | |
1324 | 1402 | // Skipping? |
1325 | - if (!empty($_POST['skip'])) |
|
1326 | - return true; |
|
1403 | + if (!empty($_POST['skip'])) { |
|
1404 | + return true; |
|
1405 | + } |
|
1327 | 1406 | |
1328 | 1407 | // Need this to check whether we need the database password. |
1329 | 1408 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1336,18 +1415,22 @@ discard block |
||
1336 | 1415 | // We need this to properly hash the password for Admin |
1337 | 1416 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
1338 | 1417 | global $sourcedir; |
1339 | - if (function_exists('mb_strtolower')) |
|
1340 | - return mb_strtolower($string, 'UTF-8'); |
|
1418 | + if (function_exists('mb_strtolower')) { |
|
1419 | + return mb_strtolower($string, 'UTF-8'); |
|
1420 | + } |
|
1341 | 1421 | require_once($sourcedir . '/Subs-Charset.php'); |
1342 | 1422 | return utf8_strtolower($string); |
1343 | 1423 | }; |
1344 | 1424 | |
1345 | - if (!isset($_POST['username'])) |
|
1346 | - $_POST['username'] = ''; |
|
1347 | - if (!isset($_POST['email'])) |
|
1348 | - $_POST['email'] = ''; |
|
1349 | - if (!isset($_POST['server_email'])) |
|
1350 | - $_POST['server_email'] = ''; |
|
1425 | + if (!isset($_POST['username'])) { |
|
1426 | + $_POST['username'] = ''; |
|
1427 | + } |
|
1428 | + if (!isset($_POST['email'])) { |
|
1429 | + $_POST['email'] = ''; |
|
1430 | + } |
|
1431 | + if (!isset($_POST['server_email'])) { |
|
1432 | + $_POST['server_email'] = ''; |
|
1433 | + } |
|
1351 | 1434 | |
1352 | 1435 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
1353 | 1436 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1366,8 +1449,9 @@ discard block |
||
1366 | 1449 | 'admin_group' => 1, |
1367 | 1450 | ) |
1368 | 1451 | ); |
1369 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1370 | - $incontext['skip'] = 1; |
|
1452 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1453 | + $incontext['skip'] = 1; |
|
1454 | + } |
|
1371 | 1455 | $smcFunc['db_free_result']($request); |
1372 | 1456 | |
1373 | 1457 | // Trying to create an account? |
@@ -1398,8 +1482,9 @@ discard block |
||
1398 | 1482 | } |
1399 | 1483 | |
1400 | 1484 | // Update the webmaster's email? |
1401 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
1402 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1485 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
1486 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
1487 | + } |
|
1403 | 1488 | |
1404 | 1489 | // Work out whether we're going to have dodgy characters and remove them. |
1405 | 1490 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1422,32 +1507,27 @@ discard block |
||
1422 | 1507 | $smcFunc['db_free_result']($result); |
1423 | 1508 | |
1424 | 1509 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
1425 | - } |
|
1426 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1510 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
1427 | 1511 | { |
1428 | 1512 | // Try the previous step again. |
1429 | 1513 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
1430 | 1514 | return false; |
1431 | - } |
|
1432 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1515 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
1433 | 1516 | { |
1434 | 1517 | // Try the previous step again. |
1435 | 1518 | $incontext['error'] = $txt['error_invalid_characters_username']; |
1436 | 1519 | return false; |
1437 | - } |
|
1438 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1520 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
1439 | 1521 | { |
1440 | 1522 | // One step back, this time fill out a proper admin email address. |
1441 | 1523 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
1442 | 1524 | return false; |
1443 | - } |
|
1444 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1525 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
1445 | 1526 | { |
1446 | 1527 | // One step back, this time fill out a proper admin email address. |
1447 | 1528 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
1448 | 1529 | return false; |
1449 | - } |
|
1450 | - elseif ($_POST['username'] != '') |
|
1530 | + } elseif ($_POST['username'] != '') |
|
1451 | 1531 | { |
1452 | 1532 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
1453 | 1533 | |
@@ -1513,17 +1593,19 @@ discard block |
||
1513 | 1593 | require_once($sourcedir . '/Subs-Auth.php'); |
1514 | 1594 | |
1515 | 1595 | // Bring a warning over. |
1516 | - if (!empty($incontext['account_existed'])) |
|
1517 | - $incontext['warning'] = $incontext['account_existed']; |
|
1596 | + if (!empty($incontext['account_existed'])) { |
|
1597 | + $incontext['warning'] = $incontext['account_existed']; |
|
1598 | + } |
|
1518 | 1599 | |
1519 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
1520 | - $smcFunc['db_query']('', ' |
|
1600 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
1601 | + $smcFunc['db_query']('', ' |
|
1521 | 1602 | SET NAMES {string:db_character_set}', |
1522 | 1603 | array( |
1523 | 1604 | 'db_character_set' => $db_character_set, |
1524 | 1605 | 'db_error_skip' => true, |
1525 | 1606 | ) |
1526 | 1607 | ); |
1608 | + } |
|
1527 | 1609 | |
1528 | 1610 | // As track stats is by default enabled let's add some activity. |
1529 | 1611 | $smcFunc['db_insert']('ignore', |
@@ -1544,14 +1626,16 @@ discard block |
||
1544 | 1626 | // Only proceed if we can load the data. |
1545 | 1627 | if ($request) |
1546 | 1628 | { |
1547 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1548 | - $modSettings[$row[0]] = $row[1]; |
|
1629 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1630 | + $modSettings[$row[0]] = $row[1]; |
|
1631 | + } |
|
1549 | 1632 | $smcFunc['db_free_result']($request); |
1550 | 1633 | } |
1551 | 1634 | |
1552 | 1635 | // Automatically log them in ;) |
1553 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
1554 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1636 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
1637 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
1638 | + } |
|
1555 | 1639 | |
1556 | 1640 | $result = $smcFunc['db_query']('', ' |
1557 | 1641 | SELECT value |
@@ -1562,13 +1646,14 @@ discard block |
||
1562 | 1646 | 'db_error_skip' => true, |
1563 | 1647 | ) |
1564 | 1648 | ); |
1565 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1566 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1649 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1650 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
1651 | + } |
|
1567 | 1652 | $smcFunc['db_free_result']($result); |
1568 | 1653 | |
1569 | - if (empty($db_sessions)) |
|
1570 | - $_SESSION['admin_time'] = time(); |
|
1571 | - else |
|
1654 | + if (empty($db_sessions)) { |
|
1655 | + $_SESSION['admin_time'] = time(); |
|
1656 | + } else |
|
1572 | 1657 | { |
1573 | 1658 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
1574 | 1659 | |
@@ -1592,8 +1677,9 @@ discard block |
||
1592 | 1677 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
1593 | 1678 | function($string){ |
1594 | 1679 | global $sourcedir; |
1595 | - if (function_exists('mb_strtolower')) |
|
1596 | - return mb_strtolower($string, 'UTF-8'); |
|
1680 | + if (function_exists('mb_strtolower')) { |
|
1681 | + return mb_strtolower($string, 'UTF-8'); |
|
1682 | + } |
|
1597 | 1683 | require_once($sourcedir . '/Subs-Charset.php'); |
1598 | 1684 | return utf8_strtolower($string); |
1599 | 1685 | }; |
@@ -1609,8 +1695,9 @@ discard block |
||
1609 | 1695 | ) |
1610 | 1696 | ); |
1611 | 1697 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
1612 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1613 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1698 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1699 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
1700 | + } |
|
1614 | 1701 | $smcFunc['db_free_result']($request); |
1615 | 1702 | |
1616 | 1703 | // Now is the perfect time to fetch the SM files. |
@@ -1629,8 +1716,9 @@ discard block |
||
1629 | 1716 | |
1630 | 1717 | // Check if we need some stupid MySQL fix. |
1631 | 1718 | $server_version = $smcFunc['db_server_info'](); |
1632 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
1633 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1719 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
1720 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
1721 | + } |
|
1634 | 1722 | |
1635 | 1723 | // Some final context for the template. |
1636 | 1724 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1650,8 +1738,9 @@ discard block |
||
1650 | 1738 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
1651 | 1739 | |
1652 | 1740 | // @todo Do we just want to read the file in clean, and split it this way always? |
1653 | - if (count($settingsArray) == 1) |
|
1654 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1741 | + if (count($settingsArray) == 1) { |
|
1742 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
1743 | + } |
|
1655 | 1744 | |
1656 | 1745 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
1657 | 1746 | { |
@@ -1666,19 +1755,22 @@ discard block |
||
1666 | 1755 | continue; |
1667 | 1756 | } |
1668 | 1757 | |
1669 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
1670 | - $settingsArray[$i] = ''; |
|
1758 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
1759 | + $settingsArray[$i] = ''; |
|
1760 | + } |
|
1671 | 1761 | |
1672 | 1762 | // Don't trim or bother with it if it's not a variable. |
1673 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
1674 | - continue; |
|
1763 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
1764 | + continue; |
|
1765 | + } |
|
1675 | 1766 | |
1676 | 1767 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
1677 | 1768 | |
1678 | - foreach ($vars as $var => $val) |
|
1679 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1769 | + foreach ($vars as $var => $val) { |
|
1770 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
1680 | 1771 | { |
1681 | 1772 | $comment = strstr($settingsArray[$i], '#'); |
1773 | + } |
|
1682 | 1774 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
1683 | 1775 | unset($vars[$var]); |
1684 | 1776 | } |
@@ -1688,36 +1780,41 @@ discard block |
||
1688 | 1780 | if (!empty($vars)) |
1689 | 1781 | { |
1690 | 1782 | $settingsArray[$i++] = ''; |
1691 | - foreach ($vars as $var => $val) |
|
1692 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1783 | + foreach ($vars as $var => $val) { |
|
1784 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
1785 | + } |
|
1693 | 1786 | } |
1694 | 1787 | |
1695 | 1788 | // Blank out the file - done to fix a oddity with some servers. |
1696 | 1789 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
1697 | - if (!$fp) |
|
1698 | - return false; |
|
1790 | + if (!$fp) { |
|
1791 | + return false; |
|
1792 | + } |
|
1699 | 1793 | fclose($fp); |
1700 | 1794 | |
1701 | 1795 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
1702 | 1796 | |
1703 | 1797 | // Gotta have one of these ;) |
1704 | - if (trim($settingsArray[0]) != '<?php') |
|
1705 | - fwrite($fp, "<?php\n"); |
|
1798 | + if (trim($settingsArray[0]) != '<?php') { |
|
1799 | + fwrite($fp, "<?php\n"); |
|
1800 | + } |
|
1706 | 1801 | |
1707 | 1802 | $lines = count($settingsArray); |
1708 | 1803 | for ($i = 0; $i < $lines - 1; $i++) |
1709 | 1804 | { |
1710 | 1805 | // Don't just write a bunch of blank lines. |
1711 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
1712 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1806 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
1807 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
1808 | + } |
|
1713 | 1809 | } |
1714 | 1810 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
1715 | 1811 | fclose($fp); |
1716 | 1812 | |
1717 | 1813 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
1718 | 1814 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
1719 | - if (function_exists('opcache_invalidate')) |
|
1720 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1815 | + if (function_exists('opcache_invalidate')) { |
|
1816 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
1817 | + } |
|
1721 | 1818 | |
1722 | 1819 | return true; |
1723 | 1820 | } |
@@ -1742,9 +1839,9 @@ discard block |
||
1742 | 1839 | SecFilterScanPOST Off |
1743 | 1840 | </IfModule>'; |
1744 | 1841 | |
1745 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
1746 | - return true; |
|
1747 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1842 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
1843 | + return true; |
|
1844 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
1748 | 1845 | { |
1749 | 1846 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
1750 | 1847 | |
@@ -1756,29 +1853,28 @@ discard block |
||
1756 | 1853 | fwrite($ht_handle, $htaccess_addition); |
1757 | 1854 | fclose($ht_handle); |
1758 | 1855 | return true; |
1856 | + } else { |
|
1857 | + return false; |
|
1759 | 1858 | } |
1760 | - else |
|
1761 | - return false; |
|
1859 | + } else { |
|
1860 | + return true; |
|
1762 | 1861 | } |
1763 | - else |
|
1764 | - return true; |
|
1765 | - } |
|
1766 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
1767 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1768 | - elseif (is_writable(dirname(__FILE__))) |
|
1862 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
1863 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
1864 | + } elseif (is_writable(dirname(__FILE__))) |
|
1769 | 1865 | { |
1770 | 1866 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
1771 | 1867 | { |
1772 | 1868 | fwrite($ht_handle, $htaccess_addition); |
1773 | 1869 | fclose($ht_handle); |
1774 | 1870 | return true; |
1871 | + } else { |
|
1872 | + return false; |
|
1775 | 1873 | } |
1776 | - else |
|
1874 | + } else { |
|
1777 | 1875 | return false; |
1778 | 1876 | } |
1779 | - else |
|
1780 | - return false; |
|
1781 | -} |
|
1877 | + } |
|
1782 | 1878 | |
1783 | 1879 | function template_install_above() |
1784 | 1880 | { |
@@ -1816,9 +1912,10 @@ discard block |
||
1816 | 1912 | <label for="installer_language">', $txt['installer_language'], ':</label> |
1817 | 1913 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
1818 | 1914 | |
1819 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
1820 | - echo ' |
|
1915 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
1916 | + echo ' |
|
1821 | 1917 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
1918 | + } |
|
1822 | 1919 | |
1823 | 1920 | echo ' |
1824 | 1921 | </select> |
@@ -1838,9 +1935,10 @@ discard block |
||
1838 | 1935 | <h2>', $txt['upgrade_progress'], '</h2> |
1839 | 1936 | <ul>'; |
1840 | 1937 | |
1841 | - foreach ($incontext['steps'] as $num => $step) |
|
1842 | - echo ' |
|
1938 | + foreach ($incontext['steps'] as $num => $step) { |
|
1939 | + echo ' |
|
1843 | 1940 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
1941 | + } |
|
1844 | 1942 | |
1845 | 1943 | echo ' |
1846 | 1944 | </ul> |
@@ -1865,20 +1963,23 @@ discard block |
||
1865 | 1963 | echo ' |
1866 | 1964 | <div>'; |
1867 | 1965 | |
1868 | - if (!empty($incontext['continue'])) |
|
1869 | - echo ' |
|
1966 | + if (!empty($incontext['continue'])) { |
|
1967 | + echo ' |
|
1870 | 1968 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
1871 | - if (!empty($incontext['skip'])) |
|
1872 | - echo ' |
|
1969 | + } |
|
1970 | + if (!empty($incontext['skip'])) { |
|
1971 | + echo ' |
|
1873 | 1972 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button_submit" />'; |
1973 | + } |
|
1874 | 1974 | echo ' |
1875 | 1975 | </div>'; |
1876 | 1976 | } |
1877 | 1977 | |
1878 | 1978 | // Show the closing form tag and other data only if not in the last step |
1879 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
1880 | - echo ' |
|
1979 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
1980 | + echo ' |
|
1881 | 1981 | </form>'; |
1982 | + } |
|
1882 | 1983 | |
1883 | 1984 | echo ' |
1884 | 1985 | </div> |
@@ -1913,13 +2014,15 @@ discard block |
||
1913 | 2014 | </div>'; |
1914 | 2015 | |
1915 | 2016 | // Show the warnings, or not. |
1916 | - if (template_warning_divs()) |
|
1917 | - echo ' |
|
2017 | + if (template_warning_divs()) { |
|
2018 | + echo ' |
|
1918 | 2019 | <h3>', $txt['install_all_lovely'], '</h3>'; |
2020 | + } |
|
1919 | 2021 | |
1920 | 2022 | // Say we want the continue button! |
1921 | - if (empty($incontext['error'])) |
|
1922 | - $incontext['continue'] = 1; |
|
2023 | + if (empty($incontext['error'])) { |
|
2024 | + $incontext['continue'] = 1; |
|
2025 | + } |
|
1923 | 2026 | |
1924 | 2027 | // For the latest version stuff. |
1925 | 2028 | echo ' |
@@ -1953,8 +2056,8 @@ discard block |
||
1953 | 2056 | global $txt, $incontext; |
1954 | 2057 | |
1955 | 2058 | // Errors are very serious.. |
1956 | - if (!empty($incontext['error'])) |
|
1957 | - echo ' |
|
2059 | + if (!empty($incontext['error'])) { |
|
2060 | + echo ' |
|
1958 | 2061 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
1959 | 2062 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
1960 | 2063 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -1962,9 +2065,10 @@ discard block |
||
1962 | 2065 | ', $incontext['error'], ' |
1963 | 2066 | </div> |
1964 | 2067 | </div>'; |
2068 | + } |
|
1965 | 2069 | // A warning message? |
1966 | - elseif (!empty($incontext['warning'])) |
|
1967 | - echo ' |
|
2070 | + elseif (!empty($incontext['warning'])) { |
|
2071 | + echo ' |
|
1968 | 2072 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
1969 | 2073 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
1970 | 2074 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -1972,6 +2076,7 @@ discard block |
||
1972 | 2076 | ', $incontext['warning'], ' |
1973 | 2077 | </div> |
1974 | 2078 | </div>'; |
2079 | + } |
|
1975 | 2080 | |
1976 | 2081 | return empty($incontext['error']) && empty($incontext['warning']); |
1977 | 2082 | } |
@@ -1987,27 +2092,30 @@ discard block |
||
1987 | 2092 | <li>', $incontext['failed_files']), '</li> |
1988 | 2093 | </ul>'; |
1989 | 2094 | |
1990 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
1991 | - echo ' |
|
2095 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
2096 | + echo ' |
|
1992 | 2097 | <hr> |
1993 | 2098 | <p>', $txt['chmod_linux_info'], '</p> |
1994 | 2099 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
2100 | + } |
|
1995 | 2101 | |
1996 | 2102 | // This is serious! |
1997 | - if (!template_warning_divs()) |
|
1998 | - return; |
|
2103 | + if (!template_warning_divs()) { |
|
2104 | + return; |
|
2105 | + } |
|
1999 | 2106 | |
2000 | 2107 | echo ' |
2001 | 2108 | <hr> |
2002 | 2109 | <p>', $txt['ftp_setup_info'], '</p>'; |
2003 | 2110 | |
2004 | - if (!empty($incontext['ftp_errors'])) |
|
2005 | - echo ' |
|
2111 | + if (!empty($incontext['ftp_errors'])) { |
|
2112 | + echo ' |
|
2006 | 2113 | <div class="error_message"> |
2007 | 2114 | ', $txt['error_ftp_no_connect'], '<br><br> |
2008 | 2115 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
2009 | 2116 | </div> |
2010 | 2117 | <br>'; |
2118 | + } |
|
2011 | 2119 | |
2012 | 2120 | echo ' |
2013 | 2121 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2067,17 +2175,17 @@ discard block |
||
2067 | 2175 | <td> |
2068 | 2176 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
2069 | 2177 | |
2070 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
2071 | - echo ' |
|
2178 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
2179 | + echo ' |
|
2072 | 2180 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
2181 | + } |
|
2073 | 2182 | |
2074 | 2183 | echo ' |
2075 | 2184 | </select> |
2076 | 2185 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
2077 | 2186 | </td> |
2078 | 2187 | </tr>'; |
2079 | - } |
|
2080 | - else |
|
2188 | + } else |
|
2081 | 2189 | { |
2082 | 2190 | echo ' |
2083 | 2191 | <tr style="display: none;"> |
@@ -2269,9 +2377,10 @@ discard block |
||
2269 | 2377 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
2270 | 2378 | <ul>'; |
2271 | 2379 | |
2272 | - foreach ($incontext['failures'] as $line => $fail) |
|
2273 | - echo ' |
|
2380 | + foreach ($incontext['failures'] as $line => $fail) { |
|
2381 | + echo ' |
|
2274 | 2382 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
2383 | + } |
|
2275 | 2384 | |
2276 | 2385 | echo ' |
2277 | 2386 | </ul>'; |
@@ -2332,15 +2441,16 @@ discard block |
||
2332 | 2441 | </tr> |
2333 | 2442 | </table>'; |
2334 | 2443 | |
2335 | - if ($incontext['require_db_confirm']) |
|
2336 | - echo ' |
|
2444 | + if ($incontext['require_db_confirm']) { |
|
2445 | + echo ' |
|
2337 | 2446 | <h2>', $txt['user_settings_database'], '</h2> |
2338 | 2447 | <p>', $txt['user_settings_database_info'], '</p> |
2339 | 2448 | |
2340 | 2449 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
2341 | 2450 | <input type="password" name="password3" size="30" class="input_password" /> |
2342 | 2451 | </div>'; |
2343 | -} |
|
2452 | + } |
|
2453 | + } |
|
2344 | 2454 | |
2345 | 2455 | // Tell them it's done, and to delete. |
2346 | 2456 | function template_delete_install() |
@@ -2353,14 +2463,15 @@ discard block |
||
2353 | 2463 | template_warning_divs(); |
2354 | 2464 | |
2355 | 2465 | // Install directory still writable? |
2356 | - if ($incontext['dir_still_writable']) |
|
2357 | - echo ' |
|
2466 | + if ($incontext['dir_still_writable']) { |
|
2467 | + echo ' |
|
2358 | 2468 | <em>', $txt['still_writable'], '</em><br> |
2359 | 2469 | <br>'; |
2470 | + } |
|
2360 | 2471 | |
2361 | 2472 | // Don't show the box if it's like 99% sure it won't work :P. |
2362 | - if ($incontext['probably_delete_install']) |
|
2363 | - echo ' |
|
2473 | + if ($incontext['probably_delete_install']) { |
|
2474 | + echo ' |
|
2364 | 2475 | <div style="margin: 1ex; font-weight: bold;"> |
2365 | 2476 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" class="input_check" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
2366 | 2477 | </div> |
@@ -2376,6 +2487,7 @@ discard block |
||
2376 | 2487 | } |
2377 | 2488 | </script> |
2378 | 2489 | <br>'; |
2490 | + } |
|
2379 | 2491 | |
2380 | 2492 | echo ' |
2381 | 2493 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |
@@ -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 | /** |
20 | 21 | * Clean the cache using the SMF 2.1 CacheAPI. |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | global $smcFunc; |
46 | 47 | static $member_groups = array(); |
47 | 48 | |
48 | - if (!empty($member_groups)) |
|
49 | - return $member_groups; |
|
49 | + if (!empty($member_groups)) { |
|
50 | + return $member_groups; |
|
51 | + } |
|
50 | 52 | |
51 | 53 | $request = $smcFunc['db_query']('', ' |
52 | 54 | SELECT group_name, id_group |
@@ -71,8 +73,9 @@ discard block |
||
71 | 73 | ) |
72 | 74 | ); |
73 | 75 | } |
74 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
75 | - $member_groups[trim($row[0])] = $row[1]; |
|
76 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
77 | + $member_groups[trim($row[0])] = $row[1]; |
|
78 | + } |
|
76 | 79 | $smcFunc['db_free_result']($request); |
77 | 80 | |
78 | 81 | return $member_groups; |
@@ -88,8 +91,9 @@ discard block |
||
88 | 91 | { |
89 | 92 | global $upcontext, $boarddir, $sourcedir; |
90 | 93 | |
91 | - if (empty($files)) |
|
92 | - return true; |
|
94 | + if (empty($files)) { |
|
95 | + return true; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | $failure = false; |
95 | 99 | // On linux, it's easy - just use is_writable! |
@@ -104,14 +108,16 @@ discard block |
||
104 | 108 | @chmod($file, 0755); |
105 | 109 | |
106 | 110 | // Well, 755 hopefully worked... if not, try 777. |
107 | - if (!is_writable($file) && !@chmod($file, 0777)) |
|
108 | - $failure = true; |
|
111 | + if (!is_writable($file) && !@chmod($file, 0777)) { |
|
112 | + $failure = true; |
|
113 | + } |
|
109 | 114 | // Otherwise remove it as it's good! |
110 | - else |
|
111 | - unset($files[$k]); |
|
115 | + else { |
|
116 | + unset($files[$k]); |
|
117 | + } |
|
118 | + } else { |
|
119 | + unset($files[$k]); |
|
112 | 120 | } |
113 | - else |
|
114 | - unset($files[$k]); |
|
115 | 121 | } |
116 | 122 | } |
117 | 123 | // Windows is trickier. Let's try opening for r+... |
@@ -122,30 +128,35 @@ discard block |
||
122 | 128 | foreach ($files as $k => $file) |
123 | 129 | { |
124 | 130 | // Folders can't be opened for write... but the index.php in them can ;). |
125 | - if (is_dir($file)) |
|
126 | - $file .= '/index.php'; |
|
131 | + if (is_dir($file)) { |
|
132 | + $file .= '/index.php'; |
|
133 | + } |
|
127 | 134 | |
128 | 135 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
129 | 136 | @chmod($file, 0777); |
130 | 137 | $fp = @fopen($file, 'r+'); |
131 | 138 | |
132 | 139 | // Hmm, okay, try just for write in that case... |
133 | - if (!$fp) |
|
134 | - $fp = @fopen($file, 'w'); |
|
140 | + if (!$fp) { |
|
141 | + $fp = @fopen($file, 'w'); |
|
142 | + } |
|
135 | 143 | |
136 | - if (!$fp) |
|
137 | - $failure = true; |
|
138 | - else |
|
139 | - unset($files[$k]); |
|
144 | + if (!$fp) { |
|
145 | + $failure = true; |
|
146 | + } else { |
|
147 | + unset($files[$k]); |
|
148 | + } |
|
140 | 149 | @fclose($fp); |
141 | 150 | } |
142 | 151 | } |
143 | 152 | |
144 | - if (empty($files)) |
|
145 | - return true; |
|
153 | + if (empty($files)) { |
|
154 | + return true; |
|
155 | + } |
|
146 | 156 | |
147 | - if (!isset($_SERVER)) |
|
148 | - return !$failure; |
|
157 | + if (!isset($_SERVER)) { |
|
158 | + return !$failure; |
|
159 | + } |
|
149 | 160 | |
150 | 161 | // What still needs to be done? |
151 | 162 | $upcontext['chmod']['files'] = $files; |
@@ -197,36 +208,40 @@ discard block |
||
197 | 208 | |
198 | 209 | if (!isset($ftp) || $ftp->error !== false) |
199 | 210 | { |
200 | - if (!isset($ftp)) |
|
201 | - $ftp = new ftp_connection(null); |
|
211 | + if (!isset($ftp)) { |
|
212 | + $ftp = new ftp_connection(null); |
|
213 | + } |
|
202 | 214 | // Save the error so we can mess with listing... |
203 | - elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) |
|
204 | - $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
215 | + elseif ($ftp->error !== false && !isset($upcontext['chmod']['ftp_error'])) { |
|
216 | + $upcontext['chmod']['ftp_error'] = $ftp->last_message === null ? '' : $ftp->last_message; |
|
217 | + } |
|
205 | 218 | |
206 | 219 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
207 | 220 | |
208 | - if ($found_path || !isset($upcontext['chmod']['path'])) |
|
209 | - $upcontext['chmod']['path'] = $detect_path; |
|
221 | + if ($found_path || !isset($upcontext['chmod']['path'])) { |
|
222 | + $upcontext['chmod']['path'] = $detect_path; |
|
223 | + } |
|
210 | 224 | |
211 | - if (!isset($upcontext['chmod']['username'])) |
|
212 | - $upcontext['chmod']['username'] = $username; |
|
225 | + if (!isset($upcontext['chmod']['username'])) { |
|
226 | + $upcontext['chmod']['username'] = $username; |
|
227 | + } |
|
213 | 228 | |
214 | 229 | // Don't forget the login token. |
215 | 230 | $upcontext += createToken('login'); |
216 | 231 | |
217 | 232 | return false; |
218 | - } |
|
219 | - else |
|
233 | + } else |
|
220 | 234 | { |
221 | 235 | // We want to do a relative path for FTP. |
222 | 236 | if (!in_array($upcontext['chmod']['path'], array('', '/'))) |
223 | 237 | { |
224 | 238 | $ftp_root = strtr($boarddir, array($upcontext['chmod']['path'] => '')); |
225 | - if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) |
|
226 | - $ftp_root = substr($ftp_root, 0, -1); |
|
239 | + if (substr($ftp_root, -1) == '/' && ($upcontext['chmod']['path'] == '' || $upcontext['chmod']['path'][0] === '/')) { |
|
240 | + $ftp_root = substr($ftp_root, 0, -1); |
|
241 | + } |
|
242 | + } else { |
|
243 | + $ftp_root = $boarddir; |
|
227 | 244 | } |
228 | - else |
|
229 | - $ftp_root = $boarddir; |
|
230 | 245 | |
231 | 246 | // Save the info for next time! |
232 | 247 | $_SESSION['installer_temp_ftp'] = array( |
@@ -240,10 +255,12 @@ discard block |
||
240 | 255 | |
241 | 256 | foreach ($files as $k => $file) |
242 | 257 | { |
243 | - if (!is_writable($file)) |
|
244 | - $ftp->chmod($file, 0755); |
|
245 | - if (!is_writable($file)) |
|
246 | - $ftp->chmod($file, 0777); |
|
258 | + if (!is_writable($file)) { |
|
259 | + $ftp->chmod($file, 0755); |
|
260 | + } |
|
261 | + if (!is_writable($file)) { |
|
262 | + $ftp->chmod($file, 0777); |
|
263 | + } |
|
247 | 264 | |
248 | 265 | // Assuming that didn't work calculate the path without the boarddir. |
249 | 266 | if (!is_writable($file)) |
@@ -252,19 +269,23 @@ discard block |
||
252 | 269 | { |
253 | 270 | $ftp_file = strtr($file, array($_SESSION['installer_temp_ftp']['root'] => '')); |
254 | 271 | $ftp->chmod($ftp_file, 0755); |
255 | - if (!is_writable($file)) |
|
256 | - $ftp->chmod($ftp_file, 0777); |
|
272 | + if (!is_writable($file)) { |
|
273 | + $ftp->chmod($ftp_file, 0777); |
|
274 | + } |
|
257 | 275 | // Sometimes an extra slash can help... |
258 | 276 | $ftp_file = '/' . $ftp_file; |
259 | - if (!is_writable($file)) |
|
260 | - $ftp->chmod($ftp_file, 0755); |
|
261 | - if (!is_writable($file)) |
|
262 | - $ftp->chmod($ftp_file, 0777); |
|
277 | + if (!is_writable($file)) { |
|
278 | + $ftp->chmod($ftp_file, 0755); |
|
279 | + } |
|
280 | + if (!is_writable($file)) { |
|
281 | + $ftp->chmod($ftp_file, 0777); |
|
282 | + } |
|
263 | 283 | } |
264 | 284 | } |
265 | 285 | |
266 | - if (is_writable($file)) |
|
267 | - unset($files[$k]); |
|
286 | + if (is_writable($file)) { |
|
287 | + unset($files[$k]); |
|
288 | + } |
|
268 | 289 | } |
269 | 290 | |
270 | 291 | $ftp->close(); |
@@ -274,8 +295,9 @@ discard block |
||
274 | 295 | // What remains? |
275 | 296 | $upcontext['chmod']['files'] = $files; |
276 | 297 | |
277 | - if (empty($files)) |
|
278 | - return true; |
|
298 | + if (empty($files)) { |
|
299 | + return true; |
|
300 | + } |
|
279 | 301 | |
280 | 302 | return false; |
281 | 303 | } |
@@ -288,8 +310,9 @@ discard block |
||
288 | 310 | */ |
289 | 311 | function quickFileWritable($file) |
290 | 312 | { |
291 | - if (is_writable($file)) |
|
292 | - return true; |
|
313 | + if (is_writable($file)) { |
|
314 | + return true; |
|
315 | + } |
|
293 | 316 | |
294 | 317 | @chmod($file, 0755); |
295 | 318 | |
@@ -299,10 +322,11 @@ discard block |
||
299 | 322 | foreach ($chmod_values as $val) |
300 | 323 | { |
301 | 324 | // If it's writable, break out of the loop |
302 | - if (is_writable($file)) |
|
303 | - break; |
|
304 | - else |
|
305 | - @chmod($file, $val); |
|
325 | + if (is_writable($file)) { |
|
326 | + break; |
|
327 | + } else { |
|
328 | + @chmod($file, $val); |
|
329 | + } |
|
306 | 330 | } |
307 | 331 | |
308 | 332 | return is_writable($file); |
@@ -329,14 +353,16 @@ discard block |
||
329 | 353 | { |
330 | 354 | static $fp = null; |
331 | 355 | |
332 | - if ($fp === null) |
|
333 | - $fp = fopen('php://stderr', 'wb'); |
|
356 | + if ($fp === null) { |
|
357 | + $fp = fopen('php://stderr', 'wb'); |
|
358 | + } |
|
334 | 359 | |
335 | 360 | fwrite($fp, $message . "\n"); |
336 | 361 | |
337 | - if ($fatal) |
|
338 | - exit; |
|
339 | -} |
|
362 | + if ($fatal) { |
|
363 | + exit; |
|
364 | + } |
|
365 | + } |
|
340 | 366 | |
341 | 367 | /** |
342 | 368 | * Throws a graphical error message. |