@@ -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 |