@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | WHERE table_name = {string:cur_table} |
| 571 | 571 | AND (data_type = \'character varying\' or data_type = \'text\')', |
| 572 | 572 | array( |
| 573 | - 'cur_table' => $db_prefix.$cur_table, |
|
| 573 | + 'cur_table' => $db_prefix . $cur_table, |
|
| 574 | 574 | ) |
| 575 | 575 | ); |
| 576 | 576 | else |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | WHERE i.indrelid = {string:cur_table}::regclass |
| 596 | 596 | AND i.indisprimary', |
| 597 | 597 | array( |
| 598 | - 'cur_table' => $db_prefix.$cur_table, |
|
| 598 | + 'cur_table' => $db_prefix . $cur_table, |
|
| 599 | 599 | ) |
| 600 | 600 | ); |
| 601 | 601 | else |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * 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, 'minimize' => true), '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,13 +578,14 @@ 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(); |
| 566 | - if ($db_type == 'postgresql') |
|
| 567 | - $request = $smcFunc['db_query']('', ' |
|
| 587 | + if ($db_type == 'postgresql') { |
|
| 588 | + $request = $smcFunc['db_query']('', ' |
|
| 568 | 589 | SELECT column_name "Field", data_type "Type" |
| 569 | 590 | FROM information_schema.columns |
| 570 | 591 | WHERE table_name = {string:cur_table} |
@@ -573,21 +594,23 @@ discard block |
||
| 573 | 594 | 'cur_table' => $db_prefix.$cur_table, |
| 574 | 595 | ) |
| 575 | 596 | ); |
| 576 | - else |
|
| 577 | - $request = $smcFunc['db_query']('', ' |
|
| 597 | + } else { |
|
| 598 | + $request = $smcFunc['db_query']('', ' |
|
| 578 | 599 | SHOW FULL COLUMNS |
| 579 | 600 | FROM {db_prefix}{raw:cur_table}', |
| 580 | 601 | array( |
| 581 | 602 | 'cur_table' => $cur_table, |
| 582 | 603 | ) |
| 583 | 604 | ); |
| 584 | - while ($column_info = $smcFunc['db_fetch_assoc']($request)) |
|
| 585 | - if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
| 605 | + } |
|
| 606 | + while ($column_info = $smcFunc['db_fetch_assoc']($request)) { |
|
| 607 | + if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
| 586 | 608 | $columns[] = strtolower($column_info['Field']); |
| 609 | + } |
|
| 587 | 610 | |
| 588 | 611 | // Get the column with the (first) primary key. |
| 589 | - if ($db_type == 'postgresql') |
|
| 590 | - $request = $smcFunc['db_query']('', ' |
|
| 612 | + if ($db_type == 'postgresql') { |
|
| 613 | + $request = $smcFunc['db_query']('', ' |
|
| 591 | 614 | SELECT a.attname "Column_name", \'PRIMARY\' "Key_name", attnum "Seq_in_index" |
| 592 | 615 | FROM pg_index i |
| 593 | 616 | JOIN pg_attribute a ON a.attrelid = i.indrelid |
@@ -598,20 +621,22 @@ discard block |
||
| 598 | 621 | 'cur_table' => $db_prefix.$cur_table, |
| 599 | 622 | ) |
| 600 | 623 | ); |
| 601 | - else |
|
| 602 | - $request = $smcFunc['db_query']('', ' |
|
| 624 | + } else { |
|
| 625 | + $request = $smcFunc['db_query']('', ' |
|
| 603 | 626 | SHOW KEYS |
| 604 | 627 | FROM {db_prefix}{raw:cur_table}', |
| 605 | 628 | array( |
| 606 | 629 | 'cur_table' => $cur_table, |
| 607 | 630 | ) |
| 608 | 631 | ); |
| 632 | + } |
|
| 609 | 633 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 610 | 634 | { |
| 611 | 635 | if ($row['Key_name'] === 'PRIMARY') |
| 612 | 636 | { |
| 613 | - if ((empty($primary_key) || $row['Seq_in_index'] == 1) && !in_array(strtolower($row['Column_name']), $columns)) |
|
| 614 | - $primary_key = $row['Column_name']; |
|
| 637 | + if ((empty($primary_key) || $row['Seq_in_index'] == 1) && !in_array(strtolower($row['Column_name']), $columns)) { |
|
| 638 | + $primary_key = $row['Column_name']; |
|
| 639 | + } |
|
| 615 | 640 | |
| 616 | 641 | $primary_keys[] = $row['Column_name']; |
| 617 | 642 | } |
@@ -620,8 +645,9 @@ discard block |
||
| 620 | 645 | |
| 621 | 646 | // No primary key, no glory. |
| 622 | 647 | // Same for columns. Just to be sure we've work to do! |
| 623 | - if (empty($primary_key) || empty($columns)) |
|
| 624 | - continue; |
|
| 648 | + if (empty($primary_key) || empty($columns)) { |
|
| 649 | + continue; |
|
| 650 | + } |
|
| 625 | 651 | |
| 626 | 652 | // Get the maximum value for the primary key. |
| 627 | 653 | $request = $smcFunc['db_query']('', ' |
@@ -635,8 +661,9 @@ discard block |
||
| 635 | 661 | list($max_value) = $smcFunc['db_fetch_row']($request); |
| 636 | 662 | $smcFunc['db_free_result']($request); |
| 637 | 663 | |
| 638 | - if (empty($max_value)) |
|
| 639 | - continue; |
|
| 664 | + if (empty($max_value)) { |
|
| 665 | + continue; |
|
| 666 | + } |
|
| 640 | 667 | |
| 641 | 668 | while ($context['start'] <= $max_value) |
| 642 | 669 | { |
@@ -660,10 +687,11 @@ discard block |
||
| 660 | 687 | { |
| 661 | 688 | $insertion_variables = array(); |
| 662 | 689 | $changes = array(); |
| 663 | - foreach ($row as $column_name => $column_value) |
|
| 664 | - if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
| 690 | + foreach ($row as $column_name => $column_value) { |
|
| 691 | + if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
| 665 | 692 | { |
| 666 | 693 | $changes[] = $column_name . ' = {string:changes_' . $column_name . '}'; |
| 694 | + } |
|
| 667 | 695 | $insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,5}|x[0-9a-fA-F]{1,4});~', 'fixchardb__callback', $column_value); |
| 668 | 696 | } |
| 669 | 697 | |
@@ -675,8 +703,8 @@ discard block |
||
| 675 | 703 | } |
| 676 | 704 | |
| 677 | 705 | // Update the row. |
| 678 | - if (!empty($changes)) |
|
| 679 | - $smcFunc['db_query']('', ' |
|
| 706 | + if (!empty($changes)) { |
|
| 707 | + $smcFunc['db_query']('', ' |
|
| 680 | 708 | UPDATE {db_prefix}' . $cur_table . ' |
| 681 | 709 | SET |
| 682 | 710 | ' . implode(', |
@@ -684,6 +712,7 @@ discard block |
||
| 684 | 712 | WHERE ' . implode(' AND ', $where), |
| 685 | 713 | $insertion_variables |
| 686 | 714 | ); |
| 715 | + } |
|
| 687 | 716 | } |
| 688 | 717 | $smcFunc['db_free_result']($request); |
| 689 | 718 | $context['start'] += 500; |
@@ -724,10 +753,11 @@ discard block |
||
| 724 | 753 | |
| 725 | 754 | checkSession('request'); |
| 726 | 755 | |
| 727 | - if (!isset($_SESSION['optimized_tables'])) |
|
| 728 | - validateToken('admin-maint'); |
|
| 729 | - else |
|
| 730 | - validateToken('admin-optimize', 'post', false); |
|
| 756 | + if (!isset($_SESSION['optimized_tables'])) { |
|
| 757 | + validateToken('admin-maint'); |
|
| 758 | + } else { |
|
| 759 | + validateToken('admin-optimize', 'post', false); |
|
| 760 | + } |
|
| 731 | 761 | |
| 732 | 762 | ignore_user_abort(true); |
| 733 | 763 | db_extend(); |
@@ -743,13 +773,15 @@ discard block |
||
| 743 | 773 | // Get a list of tables, as well as how many there are. |
| 744 | 774 | $temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%'); |
| 745 | 775 | $tables = array(); |
| 746 | - foreach ($temp_tables as $table) |
|
| 747 | - $tables[] = array('table_name' => $table); |
|
| 776 | + foreach ($temp_tables as $table) { |
|
| 777 | + $tables[] = array('table_name' => $table); |
|
| 778 | + } |
|
| 748 | 779 | |
| 749 | 780 | // If there aren't any tables then I believe that would mean the world has exploded... |
| 750 | 781 | $context['num_tables'] = count($tables); |
| 751 | - if ($context['num_tables'] == 0) |
|
| 752 | - fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
| 782 | + if ($context['num_tables'] == 0) { |
|
| 783 | + fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
| 784 | + } |
|
| 753 | 785 | |
| 754 | 786 | $_REQUEST['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 755 | 787 | |
@@ -760,8 +792,9 @@ discard block |
||
| 760 | 792 | $_SESSION['optimized_tables'] = !empty($_SESSION['optimized_tables']) ? $_SESSION['optimized_tables'] : array(); |
| 761 | 793 | for ($key = $_REQUEST['start']; $context['num_tables'] - 1; $key++) |
| 762 | 794 | { |
| 763 | - if (empty($tables[$key])) |
|
| 764 | - break; |
|
| 795 | + if (empty($tables[$key])) { |
|
| 796 | + break; |
|
| 797 | + } |
|
| 765 | 798 | |
| 766 | 799 | // Continue? |
| 767 | 800 | if (microtime(true) - $time_start > 10) |
@@ -775,8 +808,9 @@ discard block |
||
| 775 | 808 | createToken('admin-optimize'); |
| 776 | 809 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-optimize_token_var'] . '" value="' . $context['admin-optimize_token'] . '">'; |
| 777 | 810 | |
| 778 | - if (function_exists('apache_reset_timeout')) |
|
| 779 | - apache_reset_timeout(); |
|
| 811 | + if (function_exists('apache_reset_timeout')) { |
|
| 812 | + apache_reset_timeout(); |
|
| 813 | + } |
|
| 780 | 814 | |
| 781 | 815 | return; |
| 782 | 816 | } |
@@ -784,11 +818,12 @@ discard block |
||
| 784 | 818 | // Optimize the table! We use backticks here because it might be a custom table. |
| 785 | 819 | $data_freed = $smcFunc['db_optimize_table']($tables[$key]['table_name']); |
| 786 | 820 | |
| 787 | - if ($data_freed > 0) |
|
| 788 | - $_SESSION['optimized_tables'][] = array( |
|
| 821 | + if ($data_freed > 0) { |
|
| 822 | + $_SESSION['optimized_tables'][] = array( |
|
| 789 | 823 | 'name' => $tables[$key]['table_name'], |
| 790 | 824 | 'data_freed' => $data_freed, |
| 791 | 825 | ); |
| 826 | + } |
|
| 792 | 827 | } |
| 793 | 828 | |
| 794 | 829 | // Number of tables, etc... |
@@ -823,10 +858,11 @@ discard block |
||
| 823 | 858 | checkSession('request'); |
| 824 | 859 | |
| 825 | 860 | // validate the request or the loop |
| 826 | - if (!isset($_REQUEST['step'])) |
|
| 827 | - validateToken('admin-maint'); |
|
| 828 | - else |
|
| 829 | - validateToken('admin-boardrecount'); |
|
| 861 | + if (!isset($_REQUEST['step'])) { |
|
| 862 | + validateToken('admin-maint'); |
|
| 863 | + } else { |
|
| 864 | + validateToken('admin-boardrecount'); |
|
| 865 | + } |
|
| 830 | 866 | |
| 831 | 867 | $context['page_title'] = $txt['not_done_title']; |
| 832 | 868 | $context['continue_post_data'] = ''; |
@@ -847,8 +883,9 @@ discard block |
||
| 847 | 883 | $smcFunc['db_free_result']($request); |
| 848 | 884 | |
| 849 | 885 | $increment = min(max(50, ceil($max_topics / 4)), 2000); |
| 850 | - if (empty($_REQUEST['start'])) |
|
| 851 | - $_REQUEST['start'] = 0; |
|
| 886 | + if (empty($_REQUEST['start'])) { |
|
| 887 | + $_REQUEST['start'] = 0; |
|
| 888 | + } |
|
| 852 | 889 | |
| 853 | 890 | $total_steps = 8; |
| 854 | 891 | |
@@ -875,8 +912,8 @@ discard block |
||
| 875 | 912 | 'max_id' => $_REQUEST['start'] + $increment, |
| 876 | 913 | ) |
| 877 | 914 | ); |
| 878 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 879 | - $smcFunc['db_query']('', ' |
|
| 915 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 916 | + $smcFunc['db_query']('', ' |
|
| 880 | 917 | UPDATE {db_prefix}topics |
| 881 | 918 | SET num_replies = {int:num_replies} |
| 882 | 919 | WHERE id_topic = {int:id_topic}', |
@@ -885,6 +922,7 @@ discard block |
||
| 885 | 922 | 'id_topic' => $row['id_topic'], |
| 886 | 923 | ) |
| 887 | 924 | ); |
| 925 | + } |
|
| 888 | 926 | $smcFunc['db_free_result']($request); |
| 889 | 927 | |
| 890 | 928 | // Recount unapproved messages |
@@ -903,8 +941,8 @@ discard block |
||
| 903 | 941 | 'max_id' => $_REQUEST['start'] + $increment, |
| 904 | 942 | ) |
| 905 | 943 | ); |
| 906 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 907 | - $smcFunc['db_query']('', ' |
|
| 944 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 945 | + $smcFunc['db_query']('', ' |
|
| 908 | 946 | UPDATE {db_prefix}topics |
| 909 | 947 | SET unapproved_posts = {int:unapproved_posts} |
| 910 | 948 | WHERE id_topic = {int:id_topic}', |
@@ -913,6 +951,7 @@ discard block |
||
| 913 | 951 | 'id_topic' => $row['id_topic'], |
| 914 | 952 | ) |
| 915 | 953 | ); |
| 954 | + } |
|
| 916 | 955 | $smcFunc['db_free_result']($request); |
| 917 | 956 | |
| 918 | 957 | $_REQUEST['start'] += $increment; |
@@ -935,8 +974,8 @@ discard block |
||
| 935 | 974 | // Update the post count of each board. |
| 936 | 975 | if ($_REQUEST['step'] <= 1) |
| 937 | 976 | { |
| 938 | - if (empty($_REQUEST['start'])) |
|
| 939 | - $smcFunc['db_query']('', ' |
|
| 977 | + if (empty($_REQUEST['start'])) { |
|
| 978 | + $smcFunc['db_query']('', ' |
|
| 940 | 979 | UPDATE {db_prefix}boards |
| 941 | 980 | SET num_posts = {int:num_posts} |
| 942 | 981 | WHERE redirect = {string:redirect}', |
@@ -945,6 +984,7 @@ discard block |
||
| 945 | 984 | 'redirect' => '', |
| 946 | 985 | ) |
| 947 | 986 | ); |
| 987 | + } |
|
| 948 | 988 | |
| 949 | 989 | while ($_REQUEST['start'] < $max_topics) |
| 950 | 990 | { |
@@ -961,8 +1001,8 @@ discard block |
||
| 961 | 1001 | 'is_approved' => 1, |
| 962 | 1002 | ) |
| 963 | 1003 | ); |
| 964 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 965 | - $smcFunc['db_query']('', ' |
|
| 1004 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1005 | + $smcFunc['db_query']('', ' |
|
| 966 | 1006 | UPDATE {db_prefix}boards |
| 967 | 1007 | SET num_posts = num_posts + {int:real_num_posts} |
| 968 | 1008 | WHERE id_board = {int:id_board}', |
@@ -971,6 +1011,7 @@ discard block |
||
| 971 | 1011 | 'real_num_posts' => $row['real_num_posts'], |
| 972 | 1012 | ) |
| 973 | 1013 | ); |
| 1014 | + } |
|
| 974 | 1015 | $smcFunc['db_free_result']($request); |
| 975 | 1016 | |
| 976 | 1017 | $_REQUEST['start'] += $increment; |
@@ -993,14 +1034,15 @@ discard block |
||
| 993 | 1034 | // Update the topic count of each board. |
| 994 | 1035 | if ($_REQUEST['step'] <= 2) |
| 995 | 1036 | { |
| 996 | - if (empty($_REQUEST['start'])) |
|
| 997 | - $smcFunc['db_query']('', ' |
|
| 1037 | + if (empty($_REQUEST['start'])) { |
|
| 1038 | + $smcFunc['db_query']('', ' |
|
| 998 | 1039 | UPDATE {db_prefix}boards |
| 999 | 1040 | SET num_topics = {int:num_topics}', |
| 1000 | 1041 | array( |
| 1001 | 1042 | 'num_topics' => 0, |
| 1002 | 1043 | ) |
| 1003 | 1044 | ); |
| 1045 | + } |
|
| 1004 | 1046 | |
| 1005 | 1047 | while ($_REQUEST['start'] < $max_topics) |
| 1006 | 1048 | { |
@@ -1017,8 +1059,8 @@ discard block |
||
| 1017 | 1059 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
| 1018 | 1060 | ) |
| 1019 | 1061 | ); |
| 1020 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1021 | - $smcFunc['db_query']('', ' |
|
| 1062 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1063 | + $smcFunc['db_query']('', ' |
|
| 1022 | 1064 | UPDATE {db_prefix}boards |
| 1023 | 1065 | SET num_topics = num_topics + {int:real_num_topics} |
| 1024 | 1066 | WHERE id_board = {int:id_board}', |
@@ -1027,6 +1069,7 @@ discard block |
||
| 1027 | 1069 | 'real_num_topics' => $row['real_num_topics'], |
| 1028 | 1070 | ) |
| 1029 | 1071 | ); |
| 1072 | + } |
|
| 1030 | 1073 | $smcFunc['db_free_result']($request); |
| 1031 | 1074 | |
| 1032 | 1075 | $_REQUEST['start'] += $increment; |
@@ -1049,14 +1092,15 @@ discard block |
||
| 1049 | 1092 | // Update the unapproved post count of each board. |
| 1050 | 1093 | if ($_REQUEST['step'] <= 3) |
| 1051 | 1094 | { |
| 1052 | - if (empty($_REQUEST['start'])) |
|
| 1053 | - $smcFunc['db_query']('', ' |
|
| 1095 | + if (empty($_REQUEST['start'])) { |
|
| 1096 | + $smcFunc['db_query']('', ' |
|
| 1054 | 1097 | UPDATE {db_prefix}boards |
| 1055 | 1098 | SET unapproved_posts = {int:unapproved_posts}', |
| 1056 | 1099 | array( |
| 1057 | 1100 | 'unapproved_posts' => 0, |
| 1058 | 1101 | ) |
| 1059 | 1102 | ); |
| 1103 | + } |
|
| 1060 | 1104 | |
| 1061 | 1105 | while ($_REQUEST['start'] < $max_topics) |
| 1062 | 1106 | { |
@@ -1073,8 +1117,8 @@ discard block |
||
| 1073 | 1117 | 'is_approved' => 0, |
| 1074 | 1118 | ) |
| 1075 | 1119 | ); |
| 1076 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1077 | - $smcFunc['db_query']('', ' |
|
| 1120 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1121 | + $smcFunc['db_query']('', ' |
|
| 1078 | 1122 | UPDATE {db_prefix}boards |
| 1079 | 1123 | SET unapproved_posts = unapproved_posts + {int:unapproved_posts} |
| 1080 | 1124 | WHERE id_board = {int:id_board}', |
@@ -1083,6 +1127,7 @@ discard block |
||
| 1083 | 1127 | 'unapproved_posts' => $row['real_unapproved_posts'], |
| 1084 | 1128 | ) |
| 1085 | 1129 | ); |
| 1130 | + } |
|
| 1086 | 1131 | $smcFunc['db_free_result']($request); |
| 1087 | 1132 | |
| 1088 | 1133 | $_REQUEST['start'] += $increment; |
@@ -1105,14 +1150,15 @@ discard block |
||
| 1105 | 1150 | // Update the unapproved topic count of each board. |
| 1106 | 1151 | if ($_REQUEST['step'] <= 4) |
| 1107 | 1152 | { |
| 1108 | - if (empty($_REQUEST['start'])) |
|
| 1109 | - $smcFunc['db_query']('', ' |
|
| 1153 | + if (empty($_REQUEST['start'])) { |
|
| 1154 | + $smcFunc['db_query']('', ' |
|
| 1110 | 1155 | UPDATE {db_prefix}boards |
| 1111 | 1156 | SET unapproved_topics = {int:unapproved_topics}', |
| 1112 | 1157 | array( |
| 1113 | 1158 | 'unapproved_topics' => 0, |
| 1114 | 1159 | ) |
| 1115 | 1160 | ); |
| 1161 | + } |
|
| 1116 | 1162 | |
| 1117 | 1163 | while ($_REQUEST['start'] < $max_topics) |
| 1118 | 1164 | { |
@@ -1129,8 +1175,8 @@ discard block |
||
| 1129 | 1175 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
| 1130 | 1176 | ) |
| 1131 | 1177 | ); |
| 1132 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1133 | - $smcFunc['db_query']('', ' |
|
| 1178 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1179 | + $smcFunc['db_query']('', ' |
|
| 1134 | 1180 | UPDATE {db_prefix}boards |
| 1135 | 1181 | SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics} |
| 1136 | 1182 | WHERE id_board = {int:id_board}', |
@@ -1139,6 +1185,7 @@ discard block |
||
| 1139 | 1185 | 'real_unapproved_topics' => $row['real_unapproved_topics'], |
| 1140 | 1186 | ) |
| 1141 | 1187 | ); |
| 1188 | + } |
|
| 1142 | 1189 | $smcFunc['db_free_result']($request); |
| 1143 | 1190 | |
| 1144 | 1191 | $_REQUEST['start'] += $increment; |
@@ -1172,8 +1219,9 @@ discard block |
||
| 1172 | 1219 | 'is_not_deleted' => 0, |
| 1173 | 1220 | ) |
| 1174 | 1221 | ); |
| 1175 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1176 | - updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
| 1222 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1223 | + updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
| 1224 | + } |
|
| 1177 | 1225 | $smcFunc['db_free_result']($request); |
| 1178 | 1226 | |
| 1179 | 1227 | $request = $smcFunc['db_query']('', ' |
@@ -1188,8 +1236,9 @@ discard block |
||
| 1188 | 1236 | 'is_not_read' => 0, |
| 1189 | 1237 | ) |
| 1190 | 1238 | ); |
| 1191 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1192 | - updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
| 1239 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1240 | + updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
| 1241 | + } |
|
| 1193 | 1242 | $smcFunc['db_free_result']($request); |
| 1194 | 1243 | |
| 1195 | 1244 | if (microtime(true) - $time_start > 3) |
@@ -1221,12 +1270,13 @@ discard block |
||
| 1221 | 1270 | ) |
| 1222 | 1271 | ); |
| 1223 | 1272 | $boards = array(); |
| 1224 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1225 | - $boards[$row['id_board']][] = $row['id_msg']; |
|
| 1273 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1274 | + $boards[$row['id_board']][] = $row['id_msg']; |
|
| 1275 | + } |
|
| 1226 | 1276 | $smcFunc['db_free_result']($request); |
| 1227 | 1277 | |
| 1228 | - foreach ($boards as $board_id => $messages) |
|
| 1229 | - $smcFunc['db_query']('', ' |
|
| 1278 | + foreach ($boards as $board_id => $messages) { |
|
| 1279 | + $smcFunc['db_query']('', ' |
|
| 1230 | 1280 | UPDATE {db_prefix}messages |
| 1231 | 1281 | SET id_board = {int:id_board} |
| 1232 | 1282 | WHERE id_msg IN ({array_int:id_msg_array})', |
@@ -1235,6 +1285,7 @@ discard block |
||
| 1235 | 1285 | 'id_board' => $board_id, |
| 1236 | 1286 | ) |
| 1237 | 1287 | ); |
| 1288 | + } |
|
| 1238 | 1289 | |
| 1239 | 1290 | $_REQUEST['start'] += $increment; |
| 1240 | 1291 | |
@@ -1264,8 +1315,9 @@ discard block |
||
| 1264 | 1315 | ) |
| 1265 | 1316 | ); |
| 1266 | 1317 | $realBoardCounts = array(); |
| 1267 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1268 | - $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
| 1318 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1319 | + $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
| 1320 | + } |
|
| 1269 | 1321 | $smcFunc['db_free_result']($request); |
| 1270 | 1322 | |
| 1271 | 1323 | $request = $smcFunc['db_query']('', ' |
@@ -1285,18 +1337,20 @@ discard block |
||
| 1285 | 1337 | krsort($resort_me); |
| 1286 | 1338 | |
| 1287 | 1339 | $lastModifiedMsg = array(); |
| 1288 | - foreach ($resort_me as $rows) |
|
| 1289 | - foreach ($rows as $row) |
|
| 1340 | + foreach ($resort_me as $rows) { |
|
| 1341 | + foreach ($rows as $row) |
|
| 1290 | 1342 | { |
| 1291 | 1343 | // The latest message is the latest of the current board and its children. |
| 1292 | 1344 | if (isset($lastModifiedMsg[$row['id_board']])) |
| 1293 | 1345 | $curLastModifiedMsg = max($row['local_last_msg'], $lastModifiedMsg[$row['id_board']]); |
| 1294 | - else |
|
| 1295 | - $curLastModifiedMsg = $row['local_last_msg']; |
|
| 1346 | + } |
|
| 1347 | + else { |
|
| 1348 | + $curLastModifiedMsg = $row['local_last_msg']; |
|
| 1349 | + } |
|
| 1296 | 1350 | |
| 1297 | 1351 | // If what is and what should be the latest message differ, an update is necessary. |
| 1298 | - if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) |
|
| 1299 | - $smcFunc['db_query']('', ' |
|
| 1352 | + if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) { |
|
| 1353 | + $smcFunc['db_query']('', ' |
|
| 1300 | 1354 | UPDATE {db_prefix}boards |
| 1301 | 1355 | SET id_last_msg = {int:id_last_msg}, id_msg_updated = {int:id_msg_updated} |
| 1302 | 1356 | WHERE id_board = {int:id_board}', |
@@ -1306,12 +1360,14 @@ discard block |
||
| 1306 | 1360 | 'id_board' => $row['id_board'], |
| 1307 | 1361 | ) |
| 1308 | 1362 | ); |
| 1363 | + } |
|
| 1309 | 1364 | |
| 1310 | 1365 | // Parent boards inherit the latest modified message of their children. |
| 1311 | - if (isset($lastModifiedMsg[$row['id_parent']])) |
|
| 1312 | - $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
| 1313 | - else |
|
| 1314 | - $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
| 1366 | + if (isset($lastModifiedMsg[$row['id_parent']])) { |
|
| 1367 | + $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
| 1368 | + } else { |
|
| 1369 | + $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
| 1370 | + } |
|
| 1315 | 1371 | } |
| 1316 | 1372 | |
| 1317 | 1373 | // Update all the basic statistics. |
@@ -1383,8 +1439,9 @@ discard block |
||
| 1383 | 1439 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1384 | 1440 | $members = findMembers($_POST['to']); |
| 1385 | 1441 | |
| 1386 | - if (empty($members)) |
|
| 1387 | - fatal_lang_error('reattribute_cannot_find_member'); |
|
| 1442 | + if (empty($members)) { |
|
| 1443 | + fatal_lang_error('reattribute_cannot_find_member'); |
|
| 1444 | + } |
|
| 1388 | 1445 | |
| 1389 | 1446 | $memID = array_shift($members); |
| 1390 | 1447 | $memID = $memID['id']; |
@@ -1414,8 +1471,9 @@ discard block |
||
| 1414 | 1471 | validateToken('admin-maint'); |
| 1415 | 1472 | |
| 1416 | 1473 | $groups = array(); |
| 1417 | - foreach ($_POST['groups'] as $id => $dummy) |
|
| 1418 | - $groups[] = (int) $id; |
|
| 1474 | + foreach ($_POST['groups'] as $id => $dummy) { |
|
| 1475 | + $groups[] = (int) $id; |
|
| 1476 | + } |
|
| 1419 | 1477 | $time_limit = (time() - ($_POST['maxdays'] * 24 * 3600)); |
| 1420 | 1478 | $where_vars = array( |
| 1421 | 1479 | 'time_limit' => $time_limit, |
@@ -1424,9 +1482,9 @@ discard block |
||
| 1424 | 1482 | { |
| 1425 | 1483 | $where = 'mem.date_registered < {int:time_limit} AND mem.is_activated = {int:is_activated}'; |
| 1426 | 1484 | $where_vars['is_activated'] = 0; |
| 1485 | + } else { |
|
| 1486 | + $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
| 1427 | 1487 | } |
| 1428 | - else |
|
| 1429 | - $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
| 1430 | 1488 | |
| 1431 | 1489 | // Need to get *all* groups then work out which (if any) we avoid. |
| 1432 | 1490 | $request = $smcFunc['db_query']('', ' |
@@ -1445,8 +1503,7 @@ discard block |
||
| 1445 | 1503 | { |
| 1446 | 1504 | $where .= ' AND mem.id_post_group != {int:id_post_group_' . $row['id_group'] . '}'; |
| 1447 | 1505 | $where_vars['id_post_group_' . $row['id_group']] = $row['id_group']; |
| 1448 | - } |
|
| 1449 | - else |
|
| 1506 | + } else |
|
| 1450 | 1507 | { |
| 1451 | 1508 | $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'; |
| 1452 | 1509 | $where_vars['id_group_' . $row['id_group']] = $row['id_group']; |
@@ -1473,8 +1530,9 @@ discard block |
||
| 1473 | 1530 | $members = array(); |
| 1474 | 1531 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1475 | 1532 | { |
| 1476 | - if (!$row['is_mod'] || !in_array(3, $groups)) |
|
| 1477 | - $members[] = $row['id_member']; |
|
| 1533 | + if (!$row['is_mod'] || !in_array(3, $groups)) { |
|
| 1534 | + $members[] = $row['id_member']; |
|
| 1535 | + } |
|
| 1478 | 1536 | } |
| 1479 | 1537 | $smcFunc['db_free_result']($request); |
| 1480 | 1538 | |
@@ -1521,8 +1579,9 @@ discard block |
||
| 1521 | 1579 | ) |
| 1522 | 1580 | ); |
| 1523 | 1581 | |
| 1524 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1525 | - $drafts[] = (int) $row[0]; |
|
| 1582 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1583 | + $drafts[] = (int) $row[0]; |
|
| 1584 | + } |
|
| 1526 | 1585 | $smcFunc['db_free_result']($request); |
| 1527 | 1586 | |
| 1528 | 1587 | // If we have old drafts, remove them |
@@ -1565,8 +1624,9 @@ discard block |
||
| 1565 | 1624 | $sticky = isset($_POST['move_type_sticky']) || isset($_GET['sticky']); |
| 1566 | 1625 | |
| 1567 | 1626 | // No boards then this is your stop. |
| 1568 | - if (empty($id_board_from) || empty($id_board_to)) |
|
| 1569 | - return; |
|
| 1627 | + if (empty($id_board_from) || empty($id_board_to)) { |
|
| 1628 | + return; |
|
| 1629 | + } |
|
| 1570 | 1630 | |
| 1571 | 1631 | // The big WHERE clause |
| 1572 | 1632 | $conditions = 'WHERE t.id_board = {int:id_board_from} |
@@ -1614,18 +1674,20 @@ discard block |
||
| 1614 | 1674 | ); |
| 1615 | 1675 | list ($total_topics) = $smcFunc['db_fetch_row']($request); |
| 1616 | 1676 | $smcFunc['db_free_result']($request); |
| 1677 | + } else { |
|
| 1678 | + $total_topics = (int) $_REQUEST['totaltopics']; |
|
| 1617 | 1679 | } |
| 1618 | - else |
|
| 1619 | - $total_topics = (int) $_REQUEST['totaltopics']; |
|
| 1620 | 1680 | |
| 1621 | 1681 | // Seems like we need this here. |
| 1622 | 1682 | $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; |
| 1623 | 1683 | |
| 1624 | - if ($locked) |
|
| 1625 | - $context['continue_get_data'] .= ';locked'; |
|
| 1684 | + if ($locked) { |
|
| 1685 | + $context['continue_get_data'] .= ';locked'; |
|
| 1686 | + } |
|
| 1626 | 1687 | |
| 1627 | - if ($sticky) |
|
| 1628 | - $context['continue_get_data'] .= ';sticky'; |
|
| 1688 | + if ($sticky) { |
|
| 1689 | + $context['continue_get_data'] .= ';sticky'; |
|
| 1690 | + } |
|
| 1629 | 1691 | |
| 1630 | 1692 | $context['continue_get_data'] .= ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1631 | 1693 | |
@@ -1646,8 +1708,9 @@ discard block |
||
| 1646 | 1708 | |
| 1647 | 1709 | // Get the ids. |
| 1648 | 1710 | $topics = array(); |
| 1649 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1650 | - $topics[] = $row['id_topic']; |
|
| 1711 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1712 | + $topics[] = $row['id_topic']; |
|
| 1713 | + } |
|
| 1651 | 1714 | |
| 1652 | 1715 | // Just return if we don't have any topics left to move. |
| 1653 | 1716 | if (empty($topics)) |
@@ -1738,9 +1801,9 @@ discard block |
||
| 1738 | 1801 | // save it so we don't do this again for this task |
| 1739 | 1802 | list ($_SESSION['total_members']) = $smcFunc['db_fetch_row']($request); |
| 1740 | 1803 | $smcFunc['db_free_result']($request); |
| 1804 | + } else { |
|
| 1805 | + validateToken('admin-recountposts'); |
|
| 1741 | 1806 | } |
| 1742 | - else |
|
| 1743 | - validateToken('admin-recountposts'); |
|
| 1744 | 1807 | |
| 1745 | 1808 | // Lets get a group of members and determine their post count (from the boards that have post count enabled of course). |
| 1746 | 1809 | $request = $smcFunc['db_query']('', ' |
@@ -1786,8 +1849,9 @@ discard block |
||
| 1786 | 1849 | createToken('admin-recountposts'); |
| 1787 | 1850 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-recountposts_token_var'] . '" value="' . $context['admin-recountposts_token'] . '">'; |
| 1788 | 1851 | |
| 1789 | - if (function_exists('apache_reset_timeout')) |
|
| 1790 | - apache_reset_timeout(); |
|
| 1852 | + if (function_exists('apache_reset_timeout')) { |
|
| 1853 | + apache_reset_timeout(); |
|
| 1854 | + } |
|
| 1791 | 1855 | return; |
| 1792 | 1856 | } |
| 1793 | 1857 | |
@@ -1873,10 +1937,9 @@ discard block |
||
| 1873 | 1937 | checkSession('request'); |
| 1874 | 1938 | validateToken('admin-hook', 'request'); |
| 1875 | 1939 | |
| 1876 | - if ($_REQUEST['do'] == 'remove') |
|
| 1877 | - remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
| 1878 | - |
|
| 1879 | - else |
|
| 1940 | + if ($_REQUEST['do'] == 'remove') { |
|
| 1941 | + remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
| 1942 | + } else |
|
| 1880 | 1943 | { |
| 1881 | 1944 | $function_remove = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '' : '!'); |
| 1882 | 1945 | $function_add = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '!' : ''); |
@@ -1926,11 +1989,11 @@ discard block |
||
| 1926 | 1989 | // Show a nice icon to indicate this is an instance. |
| 1927 | 1990 | $instance = (!empty($data['instance']) ? '<span class="generic_icons news" title="' . $txt['hooks_field_function_method'] . '"></span> ' : ''); |
| 1928 | 1991 | |
| 1929 | - if (!empty($data['included_file'])) |
|
| 1930 | - return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
| 1931 | - |
|
| 1932 | - else |
|
| 1933 | - return $instance . $data['real_function']; |
|
| 1992 | + if (!empty($data['included_file'])) { |
|
| 1993 | + return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
| 1994 | + } else { |
|
| 1995 | + return $instance . $data['real_function']; |
|
| 1996 | + } |
|
| 1934 | 1997 | }, |
| 1935 | 1998 | ), |
| 1936 | 1999 | 'sort' => array( |
@@ -1995,11 +2058,12 @@ discard block |
||
| 1995 | 2058 | 'data' => array( |
| 1996 | 2059 | 'function' => function($data) use ($txt, $scripturl, $context) |
| 1997 | 2060 | { |
| 1998 | - if (!$data['hook_exists']) |
|
| 1999 | - return ' |
|
| 2061 | + if (!$data['hook_exists']) { |
|
| 2062 | + return ' |
|
| 2000 | 2063 | <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"> |
| 2001 | 2064 | <span class="generic_icons delete" title="' . $txt['hooks_button_remove'] . '"></span> |
| 2002 | 2065 | </a>'; |
| 2066 | + } |
|
| 2003 | 2067 | }, |
| 2004 | 2068 | 'class' => 'centertext', |
| 2005 | 2069 | ), |
@@ -2034,10 +2098,11 @@ discard block |
||
| 2034 | 2098 | { |
| 2035 | 2099 | if ($file != '.' && $file != '..') |
| 2036 | 2100 | { |
| 2037 | - if (is_dir($dir_path . '/' . $file)) |
|
| 2038 | - $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
| 2039 | - else |
|
| 2040 | - $files[] = array('dir' => $dir_path, 'name' => $file); |
|
| 2101 | + if (is_dir($dir_path . '/' . $file)) { |
|
| 2102 | + $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
| 2103 | + } else { |
|
| 2104 | + $files[] = array('dir' => $dir_path, 'name' => $file); |
|
| 2105 | + } |
|
| 2041 | 2106 | } |
| 2042 | 2107 | } |
| 2043 | 2108 | } |
@@ -2086,16 +2151,16 @@ discard block |
||
| 2086 | 2151 | // I need to know if there is at least one function called in this file. |
| 2087 | 2152 | $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
| 2088 | 2153 | unset($temp_hooks[$hook][$rawFunc]); |
| 2089 | - } |
|
| 2090 | - elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
| 2154 | + } elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
| 2091 | 2155 | { |
| 2092 | 2156 | $hook_status[$hook][$hookParsedData['pureFunc']] = $hookParsedData; |
| 2093 | 2157 | $hook_status[$hook][$hookParsedData['pureFunc']]['exists'] = true; |
| 2094 | 2158 | $hook_status[$hook][$hookParsedData['pureFunc']]['in_file'] = (!empty($file['name']) ? $file['name'] : (!empty($hookParsedData['hookFile']) ? $hookParsedData['hookFile'] : '')); |
| 2095 | 2159 | |
| 2096 | 2160 | // Does the hook has its own file? |
| 2097 | - if (!empty($hookParsedData['hookFile'])) |
|
| 2098 | - $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
| 2161 | + if (!empty($hookParsedData['hookFile'])) { |
|
| 2162 | + $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
| 2163 | + } |
|
| 2099 | 2164 | |
| 2100 | 2165 | // 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) |
| 2101 | 2166 | $temp_data['function'][$file['name']][$hookParsedData['pureFunc']] = $hookParsedData['enabled']; |
@@ -2122,15 +2187,17 @@ discard block |
||
| 2122 | 2187 | $sort = array(); |
| 2123 | 2188 | $hooks_filters = array(); |
| 2124 | 2189 | |
| 2125 | - foreach ($hooks as $hook => $functions) |
|
| 2126 | - $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
| 2190 | + foreach ($hooks as $hook => $functions) { |
|
| 2191 | + $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
| 2192 | + } |
|
| 2127 | 2193 | |
| 2128 | - if (!empty($hooks_filters)) |
|
| 2129 | - $context['insert_after_template'] .= ' |
|
| 2194 | + if (!empty($hooks_filters)) { |
|
| 2195 | + $context['insert_after_template'] .= ' |
|
| 2130 | 2196 | <script> |
| 2131 | 2197 | var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\'); |
| 2132 | 2198 | 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>') . '; |
| 2133 | 2199 | </script>'; |
| 2200 | + } |
|
| 2134 | 2201 | |
| 2135 | 2202 | $temp_data = array(); |
| 2136 | 2203 | $id = 0; |
@@ -2172,10 +2239,11 @@ discard block |
||
| 2172 | 2239 | |
| 2173 | 2240 | foreach ($temp_data as $data) |
| 2174 | 2241 | { |
| 2175 | - if (++$counter < $start) |
|
| 2176 | - continue; |
|
| 2177 | - elseif ($counter == $start + $per_page) |
|
| 2178 | - break; |
|
| 2242 | + if (++$counter < $start) { |
|
| 2243 | + continue; |
|
| 2244 | + } elseif ($counter == $start + $per_page) { |
|
| 2245 | + break; |
|
| 2246 | + } |
|
| 2179 | 2247 | |
| 2180 | 2248 | $hooks_data[] = $data; |
| 2181 | 2249 | } |
@@ -2197,13 +2265,15 @@ discard block |
||
| 2197 | 2265 | $hooks_count = 0; |
| 2198 | 2266 | |
| 2199 | 2267 | $context['filter'] = false; |
| 2200 | - if (isset($_GET['filter'])) |
|
| 2201 | - $context['filter'] = $_GET['filter']; |
|
| 2268 | + if (isset($_GET['filter'])) { |
|
| 2269 | + $context['filter'] = $_GET['filter']; |
|
| 2270 | + } |
|
| 2202 | 2271 | |
| 2203 | 2272 | foreach ($hooks as $hook => $functions) |
| 2204 | 2273 | { |
| 2205 | - if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) |
|
| 2206 | - $hooks_count += count($functions); |
|
| 2274 | + if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) { |
|
| 2275 | + $hooks_count += count($functions); |
|
| 2276 | + } |
|
| 2207 | 2277 | } |
| 2208 | 2278 | |
| 2209 | 2279 | return $hooks_count; |
@@ -2224,8 +2294,9 @@ discard block |
||
| 2224 | 2294 | $integration_hooks = array(); |
| 2225 | 2295 | foreach ($modSettings as $key => $value) |
| 2226 | 2296 | { |
| 2227 | - if (!empty($value) && substr($key, 0, 10) === 'integrate_') |
|
| 2228 | - $integration_hooks[$key] = explode(',', $value); |
|
| 2297 | + if (!empty($value) && substr($key, 0, 10) === 'integrate_') { |
|
| 2298 | + $integration_hooks[$key] = explode(',', $value); |
|
| 2299 | + } |
|
| 2229 | 2300 | } |
| 2230 | 2301 | } |
| 2231 | 2302 | |
@@ -2256,8 +2327,9 @@ discard block |
||
| 2256 | 2327 | ); |
| 2257 | 2328 | |
| 2258 | 2329 | // Meh... |
| 2259 | - if (empty($rawData)) |
|
| 2260 | - return $hookData; |
|
| 2330 | + if (empty($rawData)) { |
|
| 2331 | + return $hookData; |
|
| 2332 | + } |
|
| 2261 | 2333 | |
| 2262 | 2334 | // For convenience purposes only! |
| 2263 | 2335 | $modFunc = $rawData; |
@@ -2268,11 +2340,11 @@ discard block |
||
| 2268 | 2340 | list ($hookData['hookFile'], $modFunc) = explode('|', $modFunc); |
| 2269 | 2341 | |
| 2270 | 2342 | // Does the file exists? who knows! |
| 2271 | - if (empty($settings['theme_dir'])) |
|
| 2272 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 2273 | - |
|
| 2274 | - else |
|
| 2275 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 2343 | + if (empty($settings['theme_dir'])) { |
|
| 2344 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 2345 | + } else { |
|
| 2346 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 2347 | + } |
|
| 2276 | 2348 | |
| 2277 | 2349 | $hookData['fileExists'] = file_exists($hookData['absPath']); |
| 2278 | 2350 | $hookData['hookFile'] = basename($hookData['hookFile']); |
@@ -2297,11 +2369,10 @@ discard block |
||
| 2297 | 2369 | { |
| 2298 | 2370 | list ($hookData['class'], $hookData['method']) = explode('::', $modFunc); |
| 2299 | 2371 | $hookData['pureFunc'] = $hookData['method']; |
| 2372 | + } else { |
|
| 2373 | + $hookData['pureFunc'] = $modFunc; |
|
| 2300 | 2374 | } |
| 2301 | 2375 | |
| 2302 | - else |
|
| 2303 | - $hookData['pureFunc'] = $modFunc; |
|
| 2304 | - |
|
| 2305 | 2376 | return $hookData; |
| 2306 | 2377 | } |
| 2307 | 2378 | |
@@ -2319,16 +2390,18 @@ discard block |
||
| 2319 | 2390 | function fixchardb__callback($matches) |
| 2320 | 2391 | { |
| 2321 | 2392 | global $smcFunc; |
| 2322 | - if (!isset($matches[1])) |
|
| 2323 | - return ''; |
|
| 2393 | + if (!isset($matches[1])) { |
|
| 2394 | + return ''; |
|
| 2395 | + } |
|
| 2324 | 2396 | |
| 2325 | 2397 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
| 2326 | 2398 | |
| 2327 | 2399 | // it's to big for mb3? |
| 2328 | - if ($num > 0xFFFF && !$smcFunc['db_mb4']) |
|
| 2329 | - return $matches[0]; |
|
| 2330 | - else |
|
| 2331 | - return fixchar__callback($matches); |
|
| 2332 | -} |
|
| 2400 | + if ($num > 0xFFFF && !$smcFunc['db_mb4']) { |
|
| 2401 | + return $matches[0]; |
|
| 2402 | + } else { |
|
| 2403 | + return fixchar__callback($matches); |
|
| 2404 | + } |
|
| 2405 | + } |
|
| 2333 | 2406 | |
| 2334 | 2407 | ?> |
| 2335 | 2408 | \ No newline at end of file |