@@ -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 | * Updates a report with the given parameters. Logs each action via logAction() |
@@ -28,19 +29,20 @@ discard block |
||
| 28 | 29 | global $smcFunc, $user_info, $context; |
| 29 | 30 | |
| 30 | 31 | // Don't bother. |
| 31 | - if (empty($action) || empty($report_id)) |
|
| 32 | - return false; |
|
| 32 | + if (empty($action) || empty($report_id)) { |
|
| 33 | + return false; |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | // Add the "_all" thingy. |
| 35 | - if ($action == 'ignore') |
|
| 36 | - $action = 'ignore_all'; |
|
| 37 | + if ($action == 'ignore') { |
|
| 38 | + $action = 'ignore_all'; |
|
| 39 | + } |
|
| 37 | 40 | |
| 38 | 41 | // We don't need the board query for reported members |
| 39 | 42 | if ($context['report_type'] == 'members') |
| 40 | 43 | { |
| 41 | 44 | $board_query = ''; |
| 42 | - } |
|
| 43 | - else |
|
| 45 | + } else |
|
| 44 | 46 | { |
| 45 | 47 | $board_query = ' AND ' . $user_info['mod_cache']['bq']; |
| 46 | 48 | } |
@@ -76,17 +78,17 @@ discard block |
||
| 76 | 78 | ) |
| 77 | 79 | ); |
| 78 | 80 | |
| 79 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 80 | - $extra[$row['id_report']] = array( |
|
| 81 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 82 | + $extra[$row['id_report']] = array( |
|
| 81 | 83 | 'report' => $row['id_report'], |
| 82 | 84 | 'board' => $row['id_board'], |
| 83 | 85 | 'message' => $row['id_msg'], |
| 84 | 86 | 'topic' => $row['id_topic'], |
| 85 | 87 | ); |
| 88 | + } |
|
| 86 | 89 | |
| 87 | 90 | $smcFunc['db_free_result']($request); |
| 88 | - } |
|
| 89 | - else |
|
| 91 | + } else |
|
| 90 | 92 | { |
| 91 | 93 | $request = $smcFunc['db_query']('', ' |
| 92 | 94 | SELECT id_report, id_member, membername |
@@ -97,28 +99,32 @@ discard block |
||
| 97 | 99 | ) |
| 98 | 100 | ); |
| 99 | 101 | |
| 100 | - while($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 101 | - $extra[$row['id_report']] = array( |
|
| 102 | + while($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 103 | + $extra[$row['id_report']] = array( |
|
| 102 | 104 | 'report' => $row['id_report'], |
| 103 | 105 | 'member' => $row['id_member'], |
| 104 | 106 | ); |
| 107 | + } |
|
| 105 | 108 | |
| 106 | 109 | $smcFunc['db_free_result']($request); |
| 107 | 110 | } |
| 108 | 111 | |
| 109 | 112 | // Back to "ignore". |
| 110 | - if ($action == 'ignore_all') |
|
| 111 | - $action = 'ignore'; |
|
| 113 | + if ($action == 'ignore_all') { |
|
| 114 | + $action = 'ignore'; |
|
| 115 | + } |
|
| 112 | 116 | |
| 113 | 117 | $log_report = $action == 'ignore' ? (!empty($value) ? 'ignore' : 'unignore') : (!empty($value) ? 'close' : 'open'); |
| 114 | 118 | |
| 115 | - if ($context['report_type'] == 'members') |
|
| 116 | - $log_report .= '_user'; |
|
| 119 | + if ($context['report_type'] == 'members') { |
|
| 120 | + $log_report .= '_user'; |
|
| 121 | + } |
|
| 117 | 122 | |
| 118 | 123 | // Log this action. |
| 119 | - if (!empty($extra)) |
|
| 120 | - foreach ($extra as $report) |
|
| 124 | + if (!empty($extra)) { |
|
| 125 | + foreach ($extra as $report) |
|
| 121 | 126 | logAction($log_report . '_report', $report); |
| 127 | + } |
|
| 122 | 128 | |
| 123 | 129 | // Time to update. |
| 124 | 130 | updateSettings(array('last_mod_report_action' => time())); |
@@ -140,14 +146,12 @@ discard block |
||
| 140 | 146 | if ($context['report_type'] == 'members') |
| 141 | 147 | { |
| 142 | 148 | $and = 'lr.id_board = 0'; |
| 143 | - } |
|
| 144 | - else |
|
| 149 | + } else |
|
| 145 | 150 | { |
| 146 | 151 | if ($user_info['mod_cache']['bq'] == '1=1' || $user_info['mod_cache']['bq'] == '0=1') |
| 147 | 152 | { |
| 148 | 153 | $bq = $user_info['mod_cache']['bq']; |
| 149 | - } |
|
| 150 | - else |
|
| 154 | + } else |
|
| 151 | 155 | { |
| 152 | 156 | $bq = 'lr.' . $user_info['mod_cache']['bq']; |
| 153 | 157 | } |
@@ -203,8 +207,7 @@ discard block |
||
| 203 | 207 | 'max' => 10, |
| 204 | 208 | ) |
| 205 | 209 | ); |
| 206 | - } |
|
| 207 | - else |
|
| 210 | + } else |
|
| 208 | 211 | { |
| 209 | 212 | $request = $smcFunc['db_query']('', ' |
| 210 | 213 | SELECT lr.id_report, lr.id_msg, lr.id_topic, lr.id_board, lr.id_member, lr.subject, lr.body, |
@@ -252,8 +255,7 @@ discard block |
||
| 252 | 255 | 'href' => $scripturl . '?action=profile;u=' . $row['id_user'], |
| 253 | 256 | ), |
| 254 | 257 | ); |
| 255 | - } |
|
| 256 | - else |
|
| 258 | + } else |
|
| 257 | 259 | { |
| 258 | 260 | $report_boards_ids[] = $row['id_board']; |
| 259 | 261 | $extraDetails = array( |
@@ -293,14 +295,16 @@ discard block |
||
| 293 | 295 | ) |
| 294 | 296 | ); |
| 295 | 297 | |
| 296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 297 | - $board_names[$row['id_board']] = $row['name']; |
|
| 298 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 299 | + $board_names[$row['id_board']] = $row['name']; |
|
| 300 | + } |
|
| 298 | 301 | |
| 299 | 302 | $smcFunc['db_free_result']($request); |
| 300 | 303 | |
| 301 | - foreach ($reports as $id_report => $report) |
|
| 302 | - if (!empty($board_names[$report['topic']['id_board']])) |
|
| 304 | + foreach ($reports as $id_report => $report) { |
|
| 305 | + if (!empty($board_names[$report['topic']['id_board']])) |
|
| 303 | 306 | $reports[$id_report]['topic']['board_name'] = $board_names[$report['topic']['id_board']]; |
| 307 | + } |
|
| 304 | 308 | } |
| 305 | 309 | |
| 306 | 310 | // Now get all the people who reported it. |
@@ -350,10 +354,11 @@ discard block |
||
| 350 | 354 | { |
| 351 | 355 | global $user_info, $smcFunc; |
| 352 | 356 | |
| 353 | - if ($type == 'members') |
|
| 354 | - $bq = ''; |
|
| 355 | - else |
|
| 356 | - $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
| 357 | + if ($type == 'members') { |
|
| 358 | + $bq = ''; |
|
| 359 | + } else { |
|
| 360 | + $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
| 361 | + } |
|
| 357 | 362 | |
| 358 | 363 | $request = $smcFunc['db_query']('', ' |
| 359 | 364 | SELECT COUNT(*) |
@@ -392,8 +397,9 @@ discard block |
||
| 392 | 397 | { |
| 393 | 398 | global $smcFunc, $user_info, $context; |
| 394 | 399 | |
| 395 | - if (empty($report_id)) |
|
| 396 | - return false; |
|
| 400 | + if (empty($report_id)) { |
|
| 401 | + return false; |
|
| 402 | + } |
|
| 397 | 403 | |
| 398 | 404 | // We don't need all this info if we're only getting user info |
| 399 | 405 | if ($context['report_type'] == 'members') |
@@ -411,8 +417,7 @@ discard block |
||
| 411 | 417 | 'id_report' => $report_id, |
| 412 | 418 | ) |
| 413 | 419 | ); |
| 414 | - } |
|
| 415 | - else |
|
| 420 | + } else |
|
| 416 | 421 | { |
| 417 | 422 | // Get the report details, need this so we can limit access to a particular board. |
| 418 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -431,8 +436,9 @@ discard block |
||
| 431 | 436 | } |
| 432 | 437 | |
| 433 | 438 | // So did we find anything? |
| 434 | - if (!$smcFunc['db_num_rows']($request)) |
|
| 435 | - return false; |
|
| 439 | + if (!$smcFunc['db_num_rows']($request)) { |
|
| 440 | + return false; |
|
| 441 | + } |
|
| 436 | 442 | |
| 437 | 443 | // Woohoo we found a report and they can see it! |
| 438 | 444 | $row = $smcFunc['db_fetch_assoc']($request); |
@@ -451,8 +457,9 @@ discard block |
||
| 451 | 457 | { |
| 452 | 458 | global $smcFunc, $scripturl, $user_info, $txt; |
| 453 | 459 | |
| 454 | - if (empty($report_id)) |
|
| 455 | - return false; |
|
| 460 | + if (empty($report_id)) { |
|
| 461 | + return false; |
|
| 462 | + } |
|
| 456 | 463 | |
| 457 | 464 | $report = array( |
| 458 | 465 | 'comments' => array(), |
@@ -533,8 +540,9 @@ discard block |
||
| 533 | 540 | { |
| 534 | 541 | global $smcFunc, $user_info; |
| 535 | 542 | |
| 536 | - if (empty($comment_id)) |
|
| 537 | - return false; |
|
| 543 | + if (empty($comment_id)) { |
|
| 544 | + return false; |
|
| 545 | + } |
|
| 538 | 546 | |
| 539 | 547 | $request = $smcFunc['db_query']('', ' |
| 540 | 548 | SELECT id_comment, id_notice, log_time, body, id_member |
@@ -551,8 +559,9 @@ discard block |
||
| 551 | 559 | $smcFunc['db_free_result']($request); |
| 552 | 560 | |
| 553 | 561 | // Add the permission |
| 554 | - if (!empty($comment)) |
|
| 555 | - $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
| 562 | + if (!empty($comment)) { |
|
| 563 | + $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
| 564 | + } |
|
| 556 | 565 | |
| 557 | 566 | return $comment; |
| 558 | 567 | } |
@@ -568,8 +577,9 @@ discard block |
||
| 568 | 577 | { |
| 569 | 578 | global $smcFunc, $user_info, $context; |
| 570 | 579 | |
| 571 | - if (empty($data)) |
|
| 572 | - return false; |
|
| 580 | + if (empty($data)) { |
|
| 581 | + return false; |
|
| 582 | + } |
|
| 573 | 583 | |
| 574 | 584 | $data = array_merge(array($user_info['id'], $user_info['name'], 'reportc', ''), $data); |
| 575 | 585 | |
@@ -598,8 +608,7 @@ discard block |
||
| 598 | 608 | 'comment_id' => $last_comment, |
| 599 | 609 | 'time' => time(), |
| 600 | 610 | ); |
| 601 | - } |
|
| 602 | - else |
|
| 611 | + } else |
|
| 603 | 612 | { |
| 604 | 613 | $prefix = 'Msg'; |
| 605 | 614 | $data = array( |
@@ -615,14 +624,15 @@ discard block |
||
| 615 | 624 | } |
| 616 | 625 | |
| 617 | 626 | // And get ready to notify people. |
| 618 | - if (!empty($report)) |
|
| 619 | - $smcFunc['db_insert']('insert', |
|
| 627 | + if (!empty($report)) { |
|
| 628 | + $smcFunc['db_insert']('insert', |
|
| 620 | 629 | '{db_prefix}background_tasks', |
| 621 | 630 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 622 | 631 | array('$sourcedir/tasks/' . $prefix . 'ReportReply-Notify.php', $prefix . 'ReportReply_Notify_Background', json_encode($data), 0), |
| 623 | 632 | array('id_task') |
| 624 | 633 | ); |
| 625 | -} |
|
| 634 | + } |
|
| 635 | + } |
|
| 626 | 636 | |
| 627 | 637 | /** |
| 628 | 638 | * Saves the new information whenever a moderator comment is edited. |
@@ -635,8 +645,9 @@ discard block |
||
| 635 | 645 | { |
| 636 | 646 | global $smcFunc; |
| 637 | 647 | |
| 638 | - if (empty($comment_id) || empty($edited_comment)) |
|
| 639 | - return false; |
|
| 648 | + if (empty($comment_id) || empty($edited_comment)) { |
|
| 649 | + return false; |
|
| 650 | + } |
|
| 640 | 651 | |
| 641 | 652 | $smcFunc['db_query']('', ' |
| 642 | 653 | UPDATE {db_prefix}log_comments |
@@ -659,8 +670,9 @@ discard block |
||
| 659 | 670 | { |
| 660 | 671 | global $smcFunc; |
| 661 | 672 | |
| 662 | - if (empty($comment_id)) |
|
| 663 | - return false; |
|
| 673 | + if (empty($comment_id)) { |
|
| 674 | + return false; |
|
| 675 | + } |
|
| 664 | 676 | |
| 665 | 677 | $smcFunc['db_query']('', ' |
| 666 | 678 | DELETE FROM {db_prefix}log_comments |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
| 32 | 33 | |
| 33 | 34 | // Are we looking at the moderation log or the administration log. |
| 34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
| 35 | - if ($context['log_type'] == 3) |
|
| 36 | - isAllowedTo('admin_forum'); |
|
| 36 | + if ($context['log_type'] == 3) { |
|
| 37 | + isAllowedTo('admin_forum'); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
| 39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
| 40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 41 | - else |
|
| 42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
| 42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 43 | + } else { |
|
| 44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 45 | + } |
|
| 43 | 46 | |
| 44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
| 45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
| 67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
| 68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
| 69 | 72 | |
| 70 | - } |
|
| 71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 72 | 74 | { |
| 73 | 75 | checkSession(); |
| 74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
| 114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
| 115 | 117 | ); |
| 116 | 118 | |
| 117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
| 118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 119 | - else |
|
| 120 | - $search_params_string = $search_params['string']; |
|
| 119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
| 120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 121 | + } else { |
|
| 122 | + $search_params_string = $search_params['string']; |
|
| 123 | + } |
|
| 121 | 124 | |
| 122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
| 123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 124 | - else |
|
| 125 | - $search_params_type = $search_params['type']; |
|
| 125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
| 126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 127 | + } else { |
|
| 128 | + $search_params_type = $search_params['type']; |
|
| 129 | + } |
|
| 126 | 130 | |
| 127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
| 128 | 132 | $search_params = array( |
@@ -297,13 +301,14 @@ discard block |
||
| 297 | 301 | $context['sub_template'] = 'show_list'; |
| 298 | 302 | $context['default_list'] = 'moderation_log_list'; |
| 299 | 303 | |
| 300 | - if (isset($context['moderation_menu_name'])) |
|
| 301 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 304 | + if (isset($context['moderation_menu_name'])) { |
|
| 305 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 302 | 306 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
| 303 | 307 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
| 304 | 308 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
| 305 | 309 | ); |
| 306 | -} |
|
| 310 | + } |
|
| 311 | + } |
|
| 307 | 312 | |
| 308 | 313 | /** |
| 309 | 314 | * Get the number of mod log entries. |
@@ -407,30 +412,35 @@ discard block |
||
| 407 | 412 | // Add on some of the column stuff info |
| 408 | 413 | if (!empty($row['id_board'])) |
| 409 | 414 | { |
| 410 | - if ($row['action'] == 'move') |
|
| 411 | - $row['extra']['board_to'] = $row['id_board']; |
|
| 412 | - else |
|
| 413 | - $row['extra']['board'] = $row['id_board']; |
|
| 415 | + if ($row['action'] == 'move') { |
|
| 416 | + $row['extra']['board_to'] = $row['id_board']; |
|
| 417 | + } else { |
|
| 418 | + $row['extra']['board'] = $row['id_board']; |
|
| 419 | + } |
|
| 414 | 420 | } |
| 415 | 421 | |
| 416 | - if (!empty($row['id_topic'])) |
|
| 417 | - $row['extra']['topic'] = $row['id_topic']; |
|
| 418 | - if (!empty($row['id_msg'])) |
|
| 419 | - $row['extra']['message'] = $row['id_msg']; |
|
| 422 | + if (!empty($row['id_topic'])) { |
|
| 423 | + $row['extra']['topic'] = $row['id_topic']; |
|
| 424 | + } |
|
| 425 | + if (!empty($row['id_msg'])) { |
|
| 426 | + $row['extra']['message'] = $row['id_msg']; |
|
| 427 | + } |
|
| 420 | 428 | |
| 421 | 429 | // Is this associated with a topic? |
| 422 | - if (isset($row['extra']['topic'])) |
|
| 423 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 424 | - if (isset($row['extra']['new_topic'])) |
|
| 425 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 430 | + if (isset($row['extra']['topic'])) { |
|
| 431 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 432 | + } |
|
| 433 | + if (isset($row['extra']['new_topic'])) { |
|
| 434 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 435 | + } |
|
| 426 | 436 | |
| 427 | 437 | // How about a member? |
| 428 | 438 | if (isset($row['extra']['member'])) |
| 429 | 439 | { |
| 430 | 440 | // Guests don't have names! |
| 431 | - if (empty($row['extra']['member'])) |
|
| 432 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 433 | - else |
|
| 441 | + if (empty($row['extra']['member'])) { |
|
| 442 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 443 | + } else |
|
| 434 | 444 | { |
| 435 | 445 | // Try to find it... |
| 436 | 446 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -438,35 +448,42 @@ discard block |
||
| 438 | 448 | } |
| 439 | 449 | |
| 440 | 450 | // Associated with a board? |
| 441 | - if (isset($row['extra']['board_to'])) |
|
| 442 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 443 | - if (isset($row['extra']['board_from'])) |
|
| 444 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 445 | - if (isset($row['extra']['board'])) |
|
| 446 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 451 | + if (isset($row['extra']['board_to'])) { |
|
| 452 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 453 | + } |
|
| 454 | + if (isset($row['extra']['board_from'])) { |
|
| 455 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 456 | + } |
|
| 457 | + if (isset($row['extra']['board'])) { |
|
| 458 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 459 | + } |
|
| 447 | 460 | |
| 448 | 461 | // A message? |
| 449 | - if (isset($row['extra']['message'])) |
|
| 450 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 462 | + if (isset($row['extra']['message'])) { |
|
| 463 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 464 | + } |
|
| 451 | 465 | |
| 452 | 466 | // IP Info? |
| 453 | - if (isset($row['extra']['ip_range'])) |
|
| 454 | - if ($seeIP) |
|
| 467 | + if (isset($row['extra']['ip_range'])) { |
|
| 468 | + if ($seeIP) |
|
| 455 | 469 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
| 456 | - else |
|
| 457 | - $row['extra']['ip_range'] = $txt['logged']; |
|
| 470 | + } else { |
|
| 471 | + $row['extra']['ip_range'] = $txt['logged']; |
|
| 472 | + } |
|
| 458 | 473 | |
| 459 | 474 | // Email? |
| 460 | - if (isset($row['extra']['email'])) |
|
| 461 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 475 | + if (isset($row['extra']['email'])) { |
|
| 476 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 477 | + } |
|
| 462 | 478 | |
| 463 | 479 | // Bans are complex. |
| 464 | 480 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
| 465 | 481 | { |
| 466 | 482 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
| 467 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
| 468 | - if (isset($row['extra'][$type])) |
|
| 483 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
| 484 | + if (isset($row['extra'][$type])) |
|
| 469 | 485 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
| 486 | + } |
|
| 470 | 487 | } |
| 471 | 488 | |
| 472 | 489 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -502,12 +519,13 @@ discard block |
||
| 502 | 519 | foreach ($boards[$row['id_board']] as $action) |
| 503 | 520 | { |
| 504 | 521 | // Make the board number into a link - dealing with moving too. |
| 505 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
| 506 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 507 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
| 508 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 509 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
| 510 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 522 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
| 523 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 524 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
| 525 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 526 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
| 527 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 528 | + } |
|
| 511 | 529 | } |
| 512 | 530 | } |
| 513 | 531 | $smcFunc['db_free_result']($request); |
@@ -541,10 +559,11 @@ discard block |
||
| 541 | 559 | ); |
| 542 | 560 | |
| 543 | 561 | // Make the topic number into a link - dealing with splitting too. |
| 544 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
| 545 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 546 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
| 547 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 562 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
| 563 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 564 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
| 565 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 566 | + } |
|
| 548 | 567 | } |
| 549 | 568 | } |
| 550 | 569 | $smcFunc['db_free_result']($request); |
@@ -577,8 +596,9 @@ discard block |
||
| 577 | 596 | ); |
| 578 | 597 | |
| 579 | 598 | // Make the message number into a link. |
| 580 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
| 581 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 599 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
| 600 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 601 | + } |
|
| 582 | 602 | } |
| 583 | 603 | } |
| 584 | 604 | $smcFunc['db_free_result']($request); |
@@ -618,25 +638,29 @@ discard block |
||
| 618 | 638 | foreach ($entries as $k => $entry) |
| 619 | 639 | { |
| 620 | 640 | // Make any message info links so its easier to go find that message. |
| 621 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
| 622 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 641 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
| 642 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 643 | + } |
|
| 623 | 644 | |
| 624 | 645 | // Mark up any deleted members, topics and boards. |
| 625 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
| 626 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 646 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
| 647 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 627 | 648 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
| 649 | + } |
|
| 628 | 650 | |
| 629 | 651 | if (isset($entry['extra']['report'])) |
| 630 | 652 | { |
| 631 | 653 | // Member profile reports go in a different area |
| 632 | - if (stristr($entry['action'], 'user_report')) |
|
| 633 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 634 | - else |
|
| 635 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 654 | + if (stristr($entry['action'], 'user_report')) { |
|
| 655 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 656 | + } else { |
|
| 657 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 658 | + } |
|
| 636 | 659 | } |
| 637 | 660 | |
| 638 | - if (empty($entries[$k]['action_text'])) |
|
| 639 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 661 | + if (empty($entries[$k]['action_text'])) { |
|
| 662 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 663 | + } |
|
| 640 | 664 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
| 641 | 665 | function ($matches) use ($entries, $k) |
| 642 | 666 | { |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | loadLanguage('Drafts'); |
| 21 | 22 | |
@@ -33,8 +34,9 @@ discard block |
||
| 33 | 34 | global $context, $user_info, $smcFunc, $modSettings, $board; |
| 34 | 35 | |
| 35 | 36 | // can you be, should you be ... here? |
| 36 | - if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) |
|
| 37 | - return false; |
|
| 37 | + if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | // read in what they sent us, if anything |
| 40 | 42 | $id_draft = (int) $_POST['id_draft']; |
@@ -46,14 +48,16 @@ discard block |
||
| 46 | 48 | $context['draft_saved_on'] = $draft_info['poster_time']; |
| 47 | 49 | |
| 48 | 50 | // since we were called from the autosave function, send something back |
| 49 | - if (!empty($id_draft)) |
|
| 50 | - XmlDraft($id_draft); |
|
| 51 | + if (!empty($id_draft)) { |
|
| 52 | + XmlDraft($id_draft); |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | return true; |
| 53 | 56 | } |
| 54 | 57 | |
| 55 | - if (!isset($_POST['message'])) |
|
| 56 | - $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
| 58 | + if (!isset($_POST['message'])) { |
|
| 59 | + $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
| 60 | + } |
|
| 57 | 61 | |
| 58 | 62 | // prepare any data from the form |
| 59 | 63 | $topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic']; |
@@ -66,8 +70,9 @@ discard block |
||
| 66 | 70 | |
| 67 | 71 | // message and subject still need a bit more work |
| 68 | 72 | preparsecode($draft['body']); |
| 69 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
| 70 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 73 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
| 74 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 75 | + } |
|
| 71 | 76 | |
| 72 | 77 | // Modifying an existing draft, like hitting the save draft button or autosave enabled? |
| 73 | 78 | if (!empty($id_draft) && !empty($draft_info)) |
@@ -148,9 +153,9 @@ discard block |
||
| 148 | 153 | { |
| 149 | 154 | $context['draft_saved'] = true; |
| 150 | 155 | $context['id_draft'] = $id_draft; |
| 156 | + } else { |
|
| 157 | + $post_errors[] = 'draft_not_saved'; |
|
| 151 | 158 | } |
| 152 | - else |
|
| 153 | - $post_errors[] = 'draft_not_saved'; |
|
| 154 | 159 | |
| 155 | 160 | // cleanup |
| 156 | 161 | unset($_POST['save_draft']); |
@@ -180,8 +185,9 @@ discard block |
||
| 180 | 185 | global $context, $user_info, $smcFunc, $modSettings; |
| 181 | 186 | |
| 182 | 187 | // PM survey says ... can you stay or must you go |
| 183 | - if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) |
|
| 184 | - return false; |
|
| 188 | + if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) { |
|
| 189 | + return false; |
|
| 190 | + } |
|
| 185 | 191 | |
| 186 | 192 | // read in what you sent us |
| 187 | 193 | $id_pm_draft = (int) $_POST['id_pm_draft']; |
@@ -193,8 +199,9 @@ discard block |
||
| 193 | 199 | $context['draft_saved_on'] = $draft_info['poster_time']; |
| 194 | 200 | |
| 195 | 201 | // Send something back to the javascript caller |
| 196 | - if (!empty($id_draft)) |
|
| 197 | - XmlDraft($id_draft); |
|
| 202 | + if (!empty($id_draft)) { |
|
| 203 | + XmlDraft($id_draft); |
|
| 204 | + } |
|
| 198 | 205 | |
| 199 | 206 | return true; |
| 200 | 207 | } |
@@ -204,9 +211,9 @@ discard block |
||
| 204 | 211 | { |
| 205 | 212 | $recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array(); |
| 206 | 213 | $recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array(); |
| 214 | + } elseif (!empty($draft_info['to_list']) && empty($recipientList)) { |
|
| 215 | + $recipientList = smf_json_decode($draft_info['to_list'], true); |
|
| 207 | 216 | } |
| 208 | - elseif (!empty($draft_info['to_list']) && empty($recipientList)) |
|
| 209 | - $recipientList = smf_json_decode($draft_info['to_list'], true); |
|
| 210 | 217 | |
| 211 | 218 | // prepare the data we got from the form |
| 212 | 219 | $reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to']; |
@@ -215,8 +222,9 @@ discard block |
||
| 215 | 222 | |
| 216 | 223 | // message and subject always need a bit more work |
| 217 | 224 | preparsecode($draft['body']); |
| 218 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
| 219 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 225 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
| 226 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
| 227 | + } |
|
| 220 | 228 | |
| 221 | 229 | // Modifying an existing PM draft? |
| 222 | 230 | if (!empty($id_pm_draft) && !empty($draft_info)) |
@@ -280,9 +288,9 @@ discard block |
||
| 280 | 288 | { |
| 281 | 289 | $context['draft_saved'] = true; |
| 282 | 290 | $context['id_pm_draft'] = $id_pm_draft; |
| 291 | + } else { |
|
| 292 | + $post_errors[] = 'draft_not_saved'; |
|
| 283 | 293 | } |
| 284 | - else |
|
| 285 | - $post_errors[] = 'draft_not_saved'; |
|
| 286 | 294 | } |
| 287 | 295 | |
| 288 | 296 | // if we were called from the autosave function, send something back |
@@ -315,8 +323,9 @@ discard block |
||
| 315 | 323 | $type = (int) $type; |
| 316 | 324 | |
| 317 | 325 | // nothing to read, nothing to do |
| 318 | - if (empty($id_draft)) |
|
| 319 | - return false; |
|
| 326 | + if (empty($id_draft)) { |
|
| 327 | + return false; |
|
| 328 | + } |
|
| 320 | 329 | |
| 321 | 330 | // load in this draft from the DB |
| 322 | 331 | $request = $smcFunc['db_query']('', ' |
@@ -337,8 +346,9 @@ discard block |
||
| 337 | 346 | ); |
| 338 | 347 | |
| 339 | 348 | // no results? |
| 340 | - if (!$smcFunc['db_num_rows']($request)) |
|
| 341 | - return false; |
|
| 349 | + if (!$smcFunc['db_num_rows']($request)) { |
|
| 350 | + return false; |
|
| 351 | + } |
|
| 342 | 352 | |
| 343 | 353 | // load up the data |
| 344 | 354 | $draft_info = $smcFunc['db_fetch_assoc']($request); |
@@ -358,8 +368,7 @@ discard block |
||
| 358 | 368 | $context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
| 359 | 369 | $context['board'] = !empty($draft_info['id_board']) ? $draft_info['id_board'] : ''; |
| 360 | 370 | $context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0; |
| 361 | - } |
|
| 362 | - elseif ($type === 1) |
|
| 371 | + } elseif ($type === 1) |
|
| 363 | 372 | { |
| 364 | 373 | // one of those pm drafts? then set it up like we have an error |
| 365 | 374 | $_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
@@ -395,12 +404,14 @@ discard block |
||
| 395 | 404 | global $user_info, $smcFunc; |
| 396 | 405 | |
| 397 | 406 | // Only a single draft. |
| 398 | - if (is_numeric($id_draft)) |
|
| 399 | - $id_draft = array($id_draft); |
|
| 407 | + if (is_numeric($id_draft)) { |
|
| 408 | + $id_draft = array($id_draft); |
|
| 409 | + } |
|
| 400 | 410 | |
| 401 | 411 | // can't delete nothing |
| 402 | - if (empty($id_draft) || ($check && empty($user_info['id']))) |
|
| 403 | - return false; |
|
| 412 | + if (empty($id_draft) || ($check && empty($user_info['id']))) { |
|
| 413 | + return false; |
|
| 414 | + } |
|
| 404 | 415 | |
| 405 | 416 | $smcFunc['db_query']('', ' |
| 406 | 417 | DELETE FROM {db_prefix}user_drafts |
@@ -429,14 +440,16 @@ discard block |
||
| 429 | 440 | global $smcFunc, $scripturl, $context, $txt, $modSettings; |
| 430 | 441 | |
| 431 | 442 | // Permissions |
| 432 | - if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) |
|
| 433 | - return false; |
|
| 443 | + if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) { |
|
| 444 | + return false; |
|
| 445 | + } |
|
| 434 | 446 | |
| 435 | 447 | $context['drafts'] = array(); |
| 436 | 448 | |
| 437 | 449 | // has a specific draft has been selected? Load it up if there is not a message already in the editor |
| 438 | - if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) |
|
| 439 | - ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
| 450 | + if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) { |
|
| 451 | + ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
| 452 | + } |
|
| 440 | 453 | |
| 441 | 454 | // load the drafts this user has available |
| 442 | 455 | $request = $smcFunc['db_query']('', ' |
@@ -459,8 +472,9 @@ discard block |
||
| 459 | 472 | // add them to the draft array for display |
| 460 | 473 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 461 | 474 | { |
| 462 | - if (empty($row['subject'])) |
|
| 463 | - $row['subject'] = $txt['no_subject']; |
|
| 475 | + if (empty($row['subject'])) { |
|
| 476 | + $row['subject'] = $txt['no_subject']; |
|
| 477 | + } |
|
| 464 | 478 | |
| 465 | 479 | // Post drafts |
| 466 | 480 | if ($draft_type === 0) |
@@ -545,8 +559,9 @@ discard block |
||
| 545 | 559 | } |
| 546 | 560 | |
| 547 | 561 | // Default to 10. |
| 548 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 549 | - $_REQUEST['viewscount'] = 10; |
|
| 562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 563 | + $_REQUEST['viewscount'] = 10; |
|
| 564 | + } |
|
| 550 | 565 | |
| 551 | 566 | // Get the count of applicable drafts on the boards they can (still) see ... |
| 552 | 567 | // @todo .. should we just let them see their drafts even if they have lost board access ? |
@@ -611,12 +626,14 @@ discard block |
||
| 611 | 626 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 612 | 627 | { |
| 613 | 628 | // Censor.... |
| 614 | - if (empty($row['body'])) |
|
| 615 | - $row['body'] = ''; |
|
| 629 | + if (empty($row['body'])) { |
|
| 630 | + $row['body'] = ''; |
|
| 631 | + } |
|
| 616 | 632 | |
| 617 | 633 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
| 618 | - if (empty($row['subject'])) |
|
| 619 | - $row['subject'] = $txt['no_subject']; |
|
| 634 | + if (empty($row['subject'])) { |
|
| 635 | + $row['subject'] = $txt['no_subject']; |
|
| 636 | + } |
|
| 620 | 637 | |
| 621 | 638 | censorText($row['body']); |
| 622 | 639 | censorText($row['subject']); |
@@ -648,8 +665,9 @@ discard block |
||
| 648 | 665 | $smcFunc['db_free_result']($request); |
| 649 | 666 | |
| 650 | 667 | // If the drafts were retrieved in reverse order, get them right again. |
| 651 | - if ($reverse) |
|
| 652 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 668 | + if ($reverse) { |
|
| 669 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 670 | + } |
|
| 653 | 671 | |
| 654 | 672 | // Menu tab |
| 655 | 673 | $context[$context['profile_menu_name']]['tab_data'] = array( |
@@ -707,8 +725,9 @@ discard block |
||
| 707 | 725 | } |
| 708 | 726 | |
| 709 | 727 | // Default to 10. |
| 710 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 711 | - $_REQUEST['viewscount'] = 10; |
|
| 728 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 729 | + $_REQUEST['viewscount'] = 10; |
|
| 730 | + } |
|
| 712 | 731 | |
| 713 | 732 | // Get the count of applicable drafts |
| 714 | 733 | $request = $smcFunc['db_query']('', ' |
@@ -767,12 +786,14 @@ discard block |
||
| 767 | 786 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 768 | 787 | { |
| 769 | 788 | // Censor.... |
| 770 | - if (empty($row['body'])) |
|
| 771 | - $row['body'] = ''; |
|
| 789 | + if (empty($row['body'])) { |
|
| 790 | + $row['body'] = ''; |
|
| 791 | + } |
|
| 772 | 792 | |
| 773 | 793 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
| 774 | - if (empty($row['subject'])) |
|
| 775 | - $row['subject'] = $txt['no_subject']; |
|
| 794 | + if (empty($row['subject'])) { |
|
| 795 | + $row['subject'] = $txt['no_subject']; |
|
| 796 | + } |
|
| 776 | 797 | |
| 777 | 798 | censorText($row['body']); |
| 778 | 799 | censorText($row['subject']); |
@@ -827,8 +848,9 @@ discard block |
||
| 827 | 848 | $smcFunc['db_free_result']($request); |
| 828 | 849 | |
| 829 | 850 | // if the drafts were retrieved in reverse order, then put them in the right order again. |
| 830 | - if ($reverse) |
|
| 831 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 851 | + if ($reverse) { |
|
| 852 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
| 853 | + } |
|
| 832 | 854 | |
| 833 | 855 | // off to the template we go |
| 834 | 856 | $context['page_title'] = $txt['drafts']; |
@@ -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 | * Finds or repairs errors in the database to fix possible problems. |
@@ -50,8 +51,9 @@ discard block |
||
| 50 | 51 | ); |
| 51 | 52 | |
| 52 | 53 | // Start displaying errors without fixing them. |
| 53 | - if (isset($_GET['fixErrors'])) |
|
| 54 | - checkSession('get'); |
|
| 54 | + if (isset($_GET['fixErrors'])) { |
|
| 55 | + checkSession('get'); |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | 58 | // Will want this. |
| 57 | 59 | loadForumTests(); |
@@ -69,11 +71,11 @@ discard block |
||
| 69 | 71 | $_SESSION['repairboards_to_fix'] = $context['to_fix']; |
| 70 | 72 | $_SESSION['repairboards_to_fix2'] = null; |
| 71 | 73 | |
| 72 | - if (empty($context['repair_errors'])) |
|
| 73 | - $context['repair_errors'][] = '???'; |
|
| 74 | + if (empty($context['repair_errors'])) { |
|
| 75 | + $context['repair_errors'][] = '???'; |
|
| 76 | + } |
|
| 74 | 77 | } |
| 75 | - } |
|
| 76 | - else |
|
| 78 | + } else |
|
| 77 | 79 | { |
| 78 | 80 | $context['error_search'] = false; |
| 79 | 81 | $context['to_fix'] = isset($_SESSION['repairboards_to_fix']) ? $_SESSION['repairboards_to_fix'] : array(); |
@@ -120,16 +122,19 @@ discard block |
||
| 120 | 122 | |
| 121 | 123 | // More time, I need more time! |
| 122 | 124 | @set_time_limit(600); |
| 123 | - if (function_exists('apache_reset_timeout')) |
|
| 124 | - @apache_reset_timeout(); |
|
| 125 | + if (function_exists('apache_reset_timeout')) { |
|
| 126 | + @apache_reset_timeout(); |
|
| 127 | + } |
|
| 125 | 128 | |
| 126 | 129 | // Errr, wait. How much time has this taken already? |
| 127 | - if (!$force && time() - array_sum(explode(' ', $time_start)) < 3) |
|
| 128 | - return; |
|
| 130 | + if (!$force && time() - array_sum(explode(' ', $time_start)) < 3) { |
|
| 131 | + return; |
|
| 132 | + } |
|
| 129 | 133 | |
| 130 | 134 | // Restore the query cache if interested. |
| 131 | - if (!empty($db_temp_cache)) |
|
| 132 | - $db_cache = $db_temp_cache; |
|
| 135 | + if (!empty($db_temp_cache)) { |
|
| 136 | + $db_cache = $db_temp_cache; |
|
| 137 | + } |
|
| 133 | 138 | |
| 134 | 139 | $context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 135 | 140 | $context['page_title'] = $txt['not_done_title']; |
@@ -138,10 +143,11 @@ discard block |
||
| 138 | 143 | $context['sub_template'] = 'not_done'; |
| 139 | 144 | |
| 140 | 145 | // Change these two if more steps are added! |
| 141 | - if (empty($max_substep)) |
|
| 142 | - $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 143 | - else |
|
| 144 | - $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 146 | + if (empty($max_substep)) { |
|
| 147 | + $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
| 148 | + } else { |
|
| 149 | + $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
| 150 | + } |
|
| 145 | 151 | |
| 146 | 152 | // Never more than 100%! |
| 147 | 153 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -612,8 +618,9 @@ discard block |
||
| 612 | 618 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
| 613 | 619 | |
| 614 | 620 | // Not really a problem? |
| 615 | - if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 616 | - return false; |
|
| 621 | + if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 622 | + return false; |
|
| 623 | + } |
|
| 617 | 624 | |
| 618 | 625 | $memberStartedID = (int) getMsgMemberID($row['myid_first_msg']); |
| 619 | 626 | $memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']); |
@@ -637,15 +644,19 @@ discard block |
||
| 637 | 644 | 'message_function' => function ($row) use ($txt, &$context) |
| 638 | 645 | { |
| 639 | 646 | // A pretend error? |
| 640 | - if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
| 641 | - return false; |
|
| 647 | + if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
| 648 | + return false; |
|
| 649 | + } |
|
| 642 | 650 | |
| 643 | - if ($row['id_first_msg'] != $row['myid_first_msg']) |
|
| 644 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 645 | - if ($row['id_last_msg'] != $row['myid_last_msg']) |
|
| 646 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 647 | - if ($row['approved'] != $row['firstmsg_approved']) |
|
| 648 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 651 | + if ($row['id_first_msg'] != $row['myid_first_msg']) { |
|
| 652 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
| 653 | + } |
|
| 654 | + if ($row['id_last_msg'] != $row['myid_last_msg']) { |
|
| 655 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
| 656 | + } |
|
| 657 | + if ($row['approved'] != $row['firstmsg_approved']) { |
|
| 658 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
| 659 | + } |
|
| 649 | 660 | |
| 650 | 661 | return true; |
| 651 | 662 | }, |
@@ -675,8 +686,9 @@ discard block |
||
| 675 | 686 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
| 676 | 687 | |
| 677 | 688 | // Not really a problem? |
| 678 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 679 | - return false; |
|
| 689 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 690 | + return false; |
|
| 691 | + } |
|
| 680 | 692 | |
| 681 | 693 | $smcFunc['db_query']('', ' |
| 682 | 694 | UPDATE {db_prefix}topics |
@@ -695,11 +707,13 @@ discard block |
||
| 695 | 707 | global $txt, $context; |
| 696 | 708 | |
| 697 | 709 | // Just joking? |
| 698 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
| 699 | - return false; |
|
| 710 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
| 711 | + return false; |
|
| 712 | + } |
|
| 700 | 713 | |
| 701 | - if ($row['num_replies'] != $row['my_num_replies']) |
|
| 702 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 714 | + if ($row['num_replies'] != $row['my_num_replies']) { |
|
| 715 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
| 716 | + } |
|
| 703 | 717 | |
| 704 | 718 | return true; |
| 705 | 719 | |
@@ -1290,8 +1304,9 @@ discard block |
||
| 1290 | 1304 | $inserts = array(); |
| 1291 | 1305 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1292 | 1306 | { |
| 1293 | - foreach (text2words($row['subject']) as $word) |
|
| 1294 | - $inserts[] = array($word, $row['id_topic']); |
|
| 1307 | + foreach (text2words($row['subject']) as $word) { |
|
| 1308 | + $inserts[] = array($word, $row['id_topic']); |
|
| 1309 | + } |
|
| 1295 | 1310 | if (count($inserts) > 500) |
| 1296 | 1311 | { |
| 1297 | 1312 | $smcFunc['db_insert']('ignore', |
@@ -1305,13 +1320,14 @@ discard block |
||
| 1305 | 1320 | |
| 1306 | 1321 | } |
| 1307 | 1322 | |
| 1308 | - if (!empty($inserts)) |
|
| 1309 | - $smcFunc['db_insert']('ignore', |
|
| 1323 | + if (!empty($inserts)) { |
|
| 1324 | + $smcFunc['db_insert']('ignore', |
|
| 1310 | 1325 | '{db_prefix}log_search_subjects', |
| 1311 | 1326 | array('word' => 'string', 'id_topic' => 'int'), |
| 1312 | 1327 | $inserts, |
| 1313 | 1328 | array('word', 'id_topic') |
| 1314 | 1329 | ); |
| 1330 | + } |
|
| 1315 | 1331 | |
| 1316 | 1332 | }, |
| 1317 | 1333 | 'message_function' => function ($row) |
@@ -1581,8 +1597,9 @@ discard block |
||
| 1581 | 1597 | $current_step++; |
| 1582 | 1598 | |
| 1583 | 1599 | // Already done this? |
| 1584 | - if ($_GET['step'] > $current_step) |
|
| 1585 | - continue; |
|
| 1600 | + if ($_GET['step'] > $current_step) { |
|
| 1601 | + continue; |
|
| 1602 | + } |
|
| 1586 | 1603 | |
| 1587 | 1604 | // If we're fixing it but it ain't broke why try? |
| 1588 | 1605 | if ($do_fix && !in_array($error_type, $to_fix)) |
@@ -1611,14 +1628,16 @@ discard block |
||
| 1611 | 1628 | while (!$done) |
| 1612 | 1629 | { |
| 1613 | 1630 | // Make sure there's at least one ID to test. |
| 1614 | - if (isset($test['substeps']) && empty($step_max)) |
|
| 1615 | - break; |
|
| 1631 | + if (isset($test['substeps']) && empty($step_max)) { |
|
| 1632 | + break; |
|
| 1633 | + } |
|
| 1616 | 1634 | |
| 1617 | 1635 | // What is the testing query (Changes if we are testing or fixing) |
| 1618 | - if (!$do_fix) |
|
| 1619 | - $test_query = 'check_query'; |
|
| 1620 | - else |
|
| 1621 | - $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1636 | + if (!$do_fix) { |
|
| 1637 | + $test_query = 'check_query'; |
|
| 1638 | + } else { |
|
| 1639 | + $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
| 1640 | + } |
|
| 1622 | 1641 | |
| 1623 | 1642 | // Do the test... |
| 1624 | 1643 | $request = $smcFunc['db_query']('', |
@@ -1628,10 +1647,11 @@ discard block |
||
| 1628 | 1647 | ); |
| 1629 | 1648 | |
| 1630 | 1649 | // Does it need a fix? |
| 1631 | - if (!empty($test['check_type']) && $test['check_type'] == 'count') |
|
| 1632 | - list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1633 | - else |
|
| 1634 | - $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1650 | + if (!empty($test['check_type']) && $test['check_type'] == 'count') { |
|
| 1651 | + list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
| 1652 | + } else { |
|
| 1653 | + $needs_fix = $smcFunc['db_num_rows']($request); |
|
| 1654 | + } |
|
| 1635 | 1655 | |
| 1636 | 1656 | $total_queries++; |
| 1637 | 1657 | |
@@ -1643,8 +1663,9 @@ discard block |
||
| 1643 | 1663 | // Assume need to fix. |
| 1644 | 1664 | $found_errors = true; |
| 1645 | 1665 | |
| 1646 | - if (isset($test['message'])) |
|
| 1647 | - $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1666 | + if (isset($test['message'])) { |
|
| 1667 | + $context['repair_errors'][] = $txt[$test['message']]; |
|
| 1668 | + } |
|
| 1648 | 1669 | |
| 1649 | 1670 | // One per row! |
| 1650 | 1671 | elseif (isset($test['messages'])) |
@@ -1654,10 +1675,11 @@ discard block |
||
| 1654 | 1675 | $variables = $test['messages']; |
| 1655 | 1676 | foreach ($variables as $k => $v) |
| 1656 | 1677 | { |
| 1657 | - if ($k == 0 && isset($txt[$v])) |
|
| 1658 | - $variables[$k] = $txt[$v]; |
|
| 1659 | - elseif ($k > 0 && isset($row[$v])) |
|
| 1660 | - $variables[$k] = $row[$v]; |
|
| 1678 | + if ($k == 0 && isset($txt[$v])) { |
|
| 1679 | + $variables[$k] = $txt[$v]; |
|
| 1680 | + } elseif ($k > 0 && isset($row[$v])) { |
|
| 1681 | + $variables[$k] = $row[$v]; |
|
| 1682 | + } |
|
| 1661 | 1683 | } |
| 1662 | 1684 | $context['repair_errors'][] = call_user_func_array('sprintf', $variables); |
| 1663 | 1685 | } |
@@ -1668,13 +1690,15 @@ discard block |
||
| 1668 | 1690 | { |
| 1669 | 1691 | // Find out if there are actually errors. |
| 1670 | 1692 | $found_errors = false; |
| 1671 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1672 | - $found_errors |= $test['message_function']($row); |
|
| 1693 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1694 | + $found_errors |= $test['message_function']($row); |
|
| 1695 | + } |
|
| 1673 | 1696 | } |
| 1674 | 1697 | |
| 1675 | 1698 | // Actually have something to fix? |
| 1676 | - if ($found_errors) |
|
| 1677 | - $to_fix[] = $error_type; |
|
| 1699 | + if ($found_errors) { |
|
| 1700 | + $to_fix[] = $error_type; |
|
| 1701 | + } |
|
| 1678 | 1702 | } |
| 1679 | 1703 | |
| 1680 | 1704 | // We want to fix, we need to fix - so work out what exactly to do! |
@@ -1684,8 +1708,9 @@ discard block |
||
| 1684 | 1708 | if (isset($test['fix_collect'])) |
| 1685 | 1709 | { |
| 1686 | 1710 | $ids = array(); |
| 1687 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1688 | - $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1711 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1712 | + $ids[] = $row[$test['fix_collect']['index']]; |
|
| 1713 | + } |
|
| 1689 | 1714 | if (!empty($ids)) |
| 1690 | 1715 | { |
| 1691 | 1716 | // Fix it! |
@@ -1694,30 +1719,34 @@ discard block |
||
| 1694 | 1719 | } |
| 1695 | 1720 | |
| 1696 | 1721 | // Simply executing a fix it query? |
| 1697 | - elseif (isset($test['fix_it_query'])) |
|
| 1698 | - $smcFunc['db_query']('', |
|
| 1722 | + elseif (isset($test['fix_it_query'])) { |
|
| 1723 | + $smcFunc['db_query']('', |
|
| 1699 | 1724 | $test['fix_it_query'], |
| 1700 | 1725 | array( |
| 1701 | 1726 | ) |
| 1702 | 1727 | ); |
| 1728 | + } |
|
| 1703 | 1729 | |
| 1704 | 1730 | // Do we have some processing to do? |
| 1705 | 1731 | elseif (isset($test['fix_processing'])) |
| 1706 | 1732 | { |
| 1707 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1708 | - $test['fix_processing']($row); |
|
| 1733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1734 | + $test['fix_processing']($row); |
|
| 1735 | + } |
|
| 1709 | 1736 | } |
| 1710 | 1737 | |
| 1711 | 1738 | // What about the full set of processing? |
| 1712 | - elseif (isset($test['fix_full_processing'])) |
|
| 1713 | - $test['fix_full_processing']($request); |
|
| 1739 | + elseif (isset($test['fix_full_processing'])) { |
|
| 1740 | + $test['fix_full_processing']($request); |
|
| 1741 | + } |
|
| 1714 | 1742 | |
| 1715 | 1743 | // Do we have other things we need to fix as a result? |
| 1716 | 1744 | if (!empty($test['force_fix'])) |
| 1717 | 1745 | { |
| 1718 | - foreach ($test['force_fix'] as $item) |
|
| 1719 | - if (!in_array($item, $to_fix)) |
|
| 1746 | + foreach ($test['force_fix'] as $item) { |
|
| 1747 | + if (!in_array($item, $to_fix)) |
|
| 1720 | 1748 | $to_fix[] = $item; |
| 1749 | + } |
|
| 1721 | 1750 | } |
| 1722 | 1751 | } |
| 1723 | 1752 | } |
@@ -1735,16 +1764,17 @@ discard block |
||
| 1735 | 1764 | if ($_GET['substep'] <= $step_max) |
| 1736 | 1765 | { |
| 1737 | 1766 | pauseRepairProcess($to_fix, $error_type, $step_max); |
| 1767 | + } else { |
|
| 1768 | + $done = true; |
|
| 1738 | 1769 | } |
| 1739 | - else |
|
| 1740 | - $done = true; |
|
| 1770 | + } else { |
|
| 1771 | + $done = true; |
|
| 1741 | 1772 | } |
| 1742 | - else |
|
| 1743 | - $done = true; |
|
| 1744 | 1773 | |
| 1745 | 1774 | // Don't allow more than 1000 queries at a time. |
| 1746 | - if ($total_queries >= 1000) |
|
| 1747 | - pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1775 | + if ($total_queries >= 1000) { |
|
| 1776 | + pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
| 1777 | + } |
|
| 1748 | 1778 | } |
| 1749 | 1779 | |
| 1750 | 1780 | // Keep going. |
@@ -1757,8 +1787,9 @@ discard block |
||
| 1757 | 1787 | if ($do_fix) |
| 1758 | 1788 | { |
| 1759 | 1789 | $key = array_search($error_type, $to_fix); |
| 1760 | - if ($key !== false && isset($to_fix[$key])) |
|
| 1761 | - unset($to_fix[$key]); |
|
| 1790 | + if ($key !== false && isset($to_fix[$key])) { |
|
| 1791 | + unset($to_fix[$key]); |
|
| 1792 | + } |
|
| 1762 | 1793 | } |
| 1763 | 1794 | |
| 1764 | 1795 | // Are we done? |
@@ -1781,10 +1812,11 @@ discard block |
||
| 1781 | 1812 | static $createOnce = false; |
| 1782 | 1813 | |
| 1783 | 1814 | // Have we already created it? |
| 1784 | - if ($createOnce) |
|
| 1785 | - return; |
|
| 1786 | - else |
|
| 1787 | - $createOnce = true; |
|
| 1815 | + if ($createOnce) { |
|
| 1816 | + return; |
|
| 1817 | + } else { |
|
| 1818 | + $createOnce = true; |
|
| 1819 | + } |
|
| 1788 | 1820 | |
| 1789 | 1821 | // Back to the forum's default language. |
| 1790 | 1822 | loadLanguage('Admin', $language); |
@@ -1799,8 +1831,9 @@ discard block |
||
| 1799 | 1831 | 'cat_name' => $txt['salvaged_category_name'], |
| 1800 | 1832 | ) |
| 1801 | 1833 | ); |
| 1802 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1803 | - list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1834 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1835 | + list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
| 1836 | + } |
|
| 1804 | 1837 | $smcFunc['db_free_result']($result); |
| 1805 | 1838 | |
| 1806 | 1839 | if (empty($salvageCatID)) |
@@ -1832,8 +1865,9 @@ discard block |
||
| 1832 | 1865 | 'board_name' => $txt['salvaged_board_name'], |
| 1833 | 1866 | ) |
| 1834 | 1867 | ); |
| 1835 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1836 | - list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1868 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1869 | + list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
| 1870 | + } |
|
| 1837 | 1871 | $smcFunc['db_free_result']($result); |
| 1838 | 1872 | |
| 1839 | 1873 | if (empty($salvageBoardID)) |
@@ -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 | * Entry point for the moderation center. |
@@ -26,8 +27,9 @@ discard block |
||
| 26 | 27 | global $txt, $context, $scripturl, $modSettings, $user_info, $sourcedir, $options; |
| 27 | 28 | |
| 28 | 29 | // Don't run this twice... and don't conflict with the admin bar. |
| 29 | - if (isset($context['admin_area'])) |
|
| 30 | - return; |
|
| 30 | + if (isset($context['admin_area'])) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 31 | 33 | |
| 32 | 34 | $context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1'; |
| 33 | 35 | $context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1'; |
@@ -35,8 +37,9 @@ discard block |
||
| 35 | 37 | $context['can_moderate_users'] = allowedTo('moderate_forum'); |
| 36 | 38 | |
| 37 | 39 | // Everyone using this area must be allowed here! |
| 38 | - if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) |
|
| 39 | - isAllowedTo('access_mod_center'); |
|
| 40 | + if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) { |
|
| 41 | + isAllowedTo('access_mod_center'); |
|
| 42 | + } |
|
| 40 | 43 | |
| 41 | 44 | // We're gonna want a menu of some kind. |
| 42 | 45 | require_once($sourcedir . '/Subs-Menu.php'); |
@@ -195,8 +198,9 @@ discard block |
||
| 195 | 198 | unset($moderation_areas); |
| 196 | 199 | |
| 197 | 200 | // We got something - didn't we? DIDN'T WE! |
| 198 | - if ($mod_include_data == false) |
|
| 199 | - fatal_lang_error('no_access', false); |
|
| 201 | + if ($mod_include_data == false) { |
|
| 202 | + fatal_lang_error('no_access', false); |
|
| 203 | + } |
|
| 200 | 204 | |
| 201 | 205 | // Retain the ID information in case required by a subaction. |
| 202 | 206 | $context['moderation_menu_id'] = $context['max_menu_id']; |
@@ -219,22 +223,25 @@ discard block |
||
| 219 | 223 | 'url' => $scripturl . '?action=moderate', |
| 220 | 224 | 'name' => $txt['moderation_center'], |
| 221 | 225 | ); |
| 222 | - if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') |
|
| 223 | - $context['linktree'][] = array( |
|
| 226 | + if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') { |
|
| 227 | + $context['linktree'][] = array( |
|
| 224 | 228 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'], |
| 225 | 229 | 'name' => $mod_include_data['label'], |
| 226 | 230 | ); |
| 227 | - if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) |
|
| 228 | - $context['linktree'][] = array( |
|
| 231 | + } |
|
| 232 | + if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) { |
|
| 233 | + $context['linktree'][] = array( |
|
| 229 | 234 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'], |
| 230 | 235 | 'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0], |
| 231 | 236 | ); |
| 237 | + } |
|
| 232 | 238 | |
| 233 | 239 | // Now - finally - the bit before the encore - the main performance of course! |
| 234 | 240 | if (!$dont_call) |
| 235 | 241 | { |
| 236 | - if (isset($mod_include_data['file'])) |
|
| 237 | - require_once($sourcedir . '/' . $mod_include_data['file']); |
|
| 242 | + if (isset($mod_include_data['file'])) { |
|
| 243 | + require_once($sourcedir . '/' . $mod_include_data['file']); |
|
| 244 | + } |
|
| 238 | 245 | |
| 239 | 246 | call_helper($mod_include_data['function']); |
| 240 | 247 | } |
@@ -259,8 +266,9 @@ discard block |
||
| 259 | 266 | // Load what blocks the user actually can see... |
| 260 | 267 | $valid_blocks = array(); |
| 261 | 268 | |
| 262 | - if ($context['can_moderate_groups']) |
|
| 263 | - $valid_blocks['g'] = 'GroupRequests'; |
|
| 269 | + if ($context['can_moderate_groups']) { |
|
| 270 | + $valid_blocks['g'] = 'GroupRequests'; |
|
| 271 | + } |
|
| 264 | 272 | if ($context['can_moderate_boards']) |
| 265 | 273 | { |
| 266 | 274 | $valid_blocks['r'] = 'ReportedPosts'; |
@@ -269,8 +277,9 @@ discard block |
||
| 269 | 277 | if ($context['can_moderate_users']) |
| 270 | 278 | { |
| 271 | 279 | // This falls under the category of moderating users as well... |
| 272 | - if (!$context['can_moderate_boards']) |
|
| 273 | - $valid_blocks['w'] = 'WatchedUsers'; |
|
| 280 | + if (!$context['can_moderate_boards']) { |
|
| 281 | + $valid_blocks['w'] = 'WatchedUsers'; |
|
| 282 | + } |
|
| 274 | 283 | |
| 275 | 284 | $valid_blocks['rm'] = 'ReportedMembers'; |
| 276 | 285 | } |
@@ -281,8 +290,9 @@ discard block |
||
| 281 | 290 | foreach ($valid_blocks as $k => $block) |
| 282 | 291 | { |
| 283 | 292 | $block = 'ModBlock' . $block; |
| 284 | - if (function_exists($block)) |
|
| 285 | - $context['mod_blocks'][] = $block(); |
|
| 293 | + if (function_exists($block)) { |
|
| 294 | + $context['mod_blocks'][] = $block(); |
|
| 295 | + } |
|
| 286 | 296 | } |
| 287 | 297 | |
| 288 | 298 | $context['admin_prefs'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
@@ -309,8 +319,9 @@ discard block |
||
| 309 | 319 | ) |
| 310 | 320 | ); |
| 311 | 321 | $watched_users = array(); |
| 312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 313 | - $watched_users[] = $row; |
|
| 322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 323 | + $watched_users[] = $row; |
|
| 324 | + } |
|
| 314 | 325 | $smcFunc['db_free_result']($request); |
| 315 | 326 | |
| 316 | 327 | cache_put_data('recent_user_watches', $watched_users, 240); |
@@ -402,8 +413,9 @@ discard block |
||
| 402 | 413 | $note_owner = $smcFunc['db_num_rows']($get_owner); |
| 403 | 414 | $smcFunc['db_free_result']($get_owner); |
| 404 | 415 | |
| 405 | - if (empty($note_owner)) |
|
| 406 | - fatal_lang_error('mc_notes_delete_own', false); |
|
| 416 | + if (empty($note_owner)) { |
|
| 417 | + fatal_lang_error('mc_notes_delete_own', false); |
|
| 418 | + } |
|
| 407 | 419 | } |
| 408 | 420 | |
| 409 | 421 | // Lets delete it. |
@@ -460,12 +472,14 @@ discard block |
||
| 460 | 472 | ) |
| 461 | 473 | ); |
| 462 | 474 | $moderator_notes = array(); |
| 463 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 464 | - $moderator_notes[] = $row; |
|
| 475 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 476 | + $moderator_notes[] = $row; |
|
| 477 | + } |
|
| 465 | 478 | $smcFunc['db_free_result']($request); |
| 466 | 479 | |
| 467 | - if ($offset == 0) |
|
| 468 | - cache_put_data('moderator_notes', $moderator_notes, 240); |
|
| 480 | + if ($offset == 0) { |
|
| 481 | + cache_put_data('moderator_notes', $moderator_notes, 240); |
|
| 482 | + } |
|
| 469 | 483 | } |
| 470 | 484 | |
| 471 | 485 | // Lets construct a page index. |
@@ -504,8 +518,9 @@ discard block |
||
| 504 | 518 | // Got the info already? |
| 505 | 519 | $cachekey = md5(json_encode($user_info['mod_cache']['bq'])); |
| 506 | 520 | $context['reported_posts'] = array(); |
| 507 | - if ($user_info['mod_cache']['bq'] == '0=1') |
|
| 508 | - return 'reported_posts_block'; |
|
| 521 | + if ($user_info['mod_cache']['bq'] == '0=1') { |
|
| 522 | + return 'reported_posts_block'; |
|
| 523 | + } |
|
| 509 | 524 | |
| 510 | 525 | if (($reported_posts = cache_get_data('reported_posts_' . $cachekey, 90)) === null) |
| 511 | 526 | { |
@@ -529,8 +544,9 @@ discard block |
||
| 529 | 544 | ) |
| 530 | 545 | ); |
| 531 | 546 | $reported_posts = array(); |
| 532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 533 | - $reported_posts[] = $row; |
|
| 547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 548 | + $reported_posts[] = $row; |
|
| 549 | + } |
|
| 534 | 550 | $smcFunc['db_free_result']($request); |
| 535 | 551 | |
| 536 | 552 | // Cache it. |
@@ -568,8 +584,9 @@ discard block |
||
| 568 | 584 | |
| 569 | 585 | $context['group_requests'] = array(); |
| 570 | 586 | // Make sure they can even moderate someone! |
| 571 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
| 572 | - return 'group_requests_block'; |
|
| 587 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
| 588 | + return 'group_requests_block'; |
|
| 589 | + } |
|
| 573 | 590 | |
| 574 | 591 | // What requests are outstanding? |
| 575 | 592 | $request = $smcFunc['db_query']('', ' |
@@ -618,8 +635,9 @@ discard block |
||
| 618 | 635 | // Got the info already? |
| 619 | 636 | $cachekey = md5(json_encode((int) allowedTo('moderate_forum'))); |
| 620 | 637 | $context['reported_users'] = array(); |
| 621 | - if (!allowedTo('moderate_forum')) |
|
| 622 | - return 'reported_users_block'; |
|
| 638 | + if (!allowedTo('moderate_forum')) { |
|
| 639 | + return 'reported_users_block'; |
|
| 640 | + } |
|
| 623 | 641 | |
| 624 | 642 | if (($reported_users = cache_get_data('reported_users_' . $cachekey, 90)) === null) |
| 625 | 643 | { |
@@ -642,8 +660,9 @@ discard block |
||
| 642 | 660 | ) |
| 643 | 661 | ); |
| 644 | 662 | $reported_users = array(); |
| 645 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 646 | - $reported_users[] = $row; |
|
| 663 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 664 | + $reported_users[] = $row; |
|
| 665 | + } |
|
| 647 | 666 | $smcFunc['db_free_result']($request); |
| 648 | 667 | |
| 649 | 668 | // Cache it. |
@@ -691,8 +710,9 @@ discard block |
||
| 691 | 710 | isAllowedTo('moderate_forum'); |
| 692 | 711 | |
| 693 | 712 | // Are they wanting to view a particular report? |
| 694 | - if (!empty($_REQUEST['report'])) |
|
| 695 | - return MemberReport(); |
|
| 713 | + if (!empty($_REQUEST['report'])) { |
|
| 714 | + return MemberReport(); |
|
| 715 | + } |
|
| 696 | 716 | |
| 697 | 717 | // Set up the comforting bits... |
| 698 | 718 | $context['page_title'] = $txt['mc_reported_members']; |
@@ -746,15 +766,15 @@ discard block |
||
| 746 | 766 | // Time to update. |
| 747 | 767 | updateSettings(array('last_mod_report_action' => time())); |
| 748 | 768 | recountOpenReports('members'); |
| 749 | - } |
|
| 750 | - elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
| 769 | + } elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
| 751 | 770 | { |
| 752 | 771 | checkSession(); |
| 753 | 772 | |
| 754 | 773 | // All the ones to update... |
| 755 | 774 | $toClose = array(); |
| 756 | - foreach ($_POST['close'] as $rid) |
|
| 757 | - $toClose[] = (int) $rid; |
|
| 775 | + foreach ($_POST['close'] as $rid) { |
|
| 776 | + $toClose[] = (int) $rid; |
|
| 777 | + } |
|
| 758 | 778 | |
| 759 | 779 | if (!empty($toClose)) |
| 760 | 780 | { |
@@ -907,8 +927,9 @@ discard block |
||
| 907 | 927 | global $context, $user_info; |
| 908 | 928 | |
| 909 | 929 | // You need to be allowed to moderate groups... |
| 910 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
| 911 | - isAllowedTo('manage_membergroups'); |
|
| 930 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
| 931 | + isAllowedTo('manage_membergroups'); |
|
| 932 | + } |
|
| 912 | 933 | |
| 913 | 934 | // Load the group templates. |
| 914 | 935 | loadTemplate('ModerationCenter'); |
@@ -919,8 +940,9 @@ discard block |
||
| 919 | 940 | 'view' => 'ViewGroups', |
| 920 | 941 | ); |
| 921 | 942 | |
| 922 | - if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
| 923 | - $_GET['sa'] = 'view'; |
|
| 943 | + if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
| 944 | + $_GET['sa'] = 'view'; |
|
| 945 | + } |
|
| 924 | 946 | $context['sub_action'] = $_GET['sa']; |
| 925 | 947 | |
| 926 | 948 | // Call the relevant function. |
@@ -950,8 +972,9 @@ discard block |
||
| 950 | 972 | 'id_notice' => $id_notice, |
| 951 | 973 | ) |
| 952 | 974 | ); |
| 953 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 954 | - fatal_lang_error('no_access', false); |
|
| 975 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 976 | + fatal_lang_error('no_access', false); |
|
| 977 | + } |
|
| 955 | 978 | list ($context['notice_body'], $context['notice_subject']) = $smcFunc['db_fetch_row']($request); |
| 956 | 979 | $smcFunc['db_free_result']($request); |
| 957 | 980 | |
@@ -988,18 +1011,20 @@ discard block |
||
| 988 | 1011 | checkSession(!is_array($_REQUEST['delete']) ? 'get' : 'post'); |
| 989 | 1012 | |
| 990 | 1013 | $toDelete = array(); |
| 991 | - if (!is_array($_REQUEST['delete'])) |
|
| 992 | - $toDelete[] = (int) $_REQUEST['delete']; |
|
| 993 | - else |
|
| 994 | - foreach ($_REQUEST['delete'] as $did) |
|
| 1014 | + if (!is_array($_REQUEST['delete'])) { |
|
| 1015 | + $toDelete[] = (int) $_REQUEST['delete']; |
|
| 1016 | + } else { |
|
| 1017 | + foreach ($_REQUEST['delete'] as $did) |
|
| 995 | 1018 | $toDelete[] = (int) $did; |
| 1019 | + } |
|
| 996 | 1020 | |
| 997 | 1021 | if (!empty($toDelete)) |
| 998 | 1022 | { |
| 999 | 1023 | require_once($sourcedir . '/RemoveTopic.php'); |
| 1000 | 1024 | // If they don't have permission we'll let it error - either way no chance of a security slip here! |
| 1001 | - foreach ($toDelete as $did) |
|
| 1002 | - removeMessage($did); |
|
| 1025 | + foreach ($toDelete as $did) { |
|
| 1026 | + removeMessage($did); |
|
| 1027 | + } |
|
| 1003 | 1028 | } |
| 1004 | 1029 | } |
| 1005 | 1030 | |
@@ -1008,20 +1033,21 @@ discard block |
||
| 1008 | 1033 | { |
| 1009 | 1034 | $approve_query = ''; |
| 1010 | 1035 | $delete_boards = array(); |
| 1011 | - } |
|
| 1012 | - else |
|
| 1036 | + } else |
|
| 1013 | 1037 | { |
| 1014 | 1038 | // Still obey permissions! |
| 1015 | 1039 | $approve_boards = boardsAllowedTo('approve_posts'); |
| 1016 | 1040 | $delete_boards = boardsAllowedTo('delete_any'); |
| 1017 | 1041 | |
| 1018 | - if ($approve_boards == array(0)) |
|
| 1019 | - $approve_query = ''; |
|
| 1020 | - elseif (!empty($approve_boards)) |
|
| 1021 | - $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
| 1042 | + if ($approve_boards == array(0)) { |
|
| 1043 | + $approve_query = ''; |
|
| 1044 | + } elseif (!empty($approve_boards)) { |
|
| 1045 | + $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
| 1046 | + } |
|
| 1022 | 1047 | // Nada, zip, etc... |
| 1023 | - else |
|
| 1024 | - $approve_query = ' AND 1=0'; |
|
| 1048 | + else { |
|
| 1049 | + $approve_query = ' AND 1=0'; |
|
| 1050 | + } |
|
| 1025 | 1051 | } |
| 1026 | 1052 | |
| 1027 | 1053 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1120,10 +1146,11 @@ discard block |
||
| 1120 | 1146 | 'data' => array( |
| 1121 | 1147 | 'function' => function($member) use ($scripturl) |
| 1122 | 1148 | { |
| 1123 | - if ($member['last_post_id']) |
|
| 1124 | - return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
| 1125 | - else |
|
| 1126 | - return $member['last_post']; |
|
| 1149 | + if ($member['last_post_id']) { |
|
| 1150 | + return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
| 1151 | + } else { |
|
| 1152 | + return $member['last_post']; |
|
| 1153 | + } |
|
| 1127 | 1154 | }, |
| 1128 | 1155 | ), |
| 1129 | 1156 | ), |
@@ -1251,8 +1278,9 @@ discard block |
||
| 1251 | 1278 | ) |
| 1252 | 1279 | ); |
| 1253 | 1280 | $latest_posts = array(); |
| 1254 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1255 | - $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
| 1281 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1282 | + $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
| 1283 | + } |
|
| 1256 | 1284 | |
| 1257 | 1285 | if (!empty($latest_posts)) |
| 1258 | 1286 | { |
@@ -1443,15 +1471,17 @@ discard block |
||
| 1443 | 1471 | // Setup the direction stuff... |
| 1444 | 1472 | $context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'member'; |
| 1445 | 1473 | |
| 1446 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
| 1447 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 1448 | - else |
|
| 1449 | - $search_params_string = $search_params['string']; |
|
| 1474 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
| 1475 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 1476 | + } else { |
|
| 1477 | + $search_params_string = $search_params['string']; |
|
| 1478 | + } |
|
| 1450 | 1479 | |
| 1451 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
| 1452 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 1453 | - else |
|
| 1454 | - $search_params_type = $search_params['type']; |
|
| 1480 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
| 1481 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 1482 | + } else { |
|
| 1483 | + $search_params_type = $search_params['type']; |
|
| 1484 | + } |
|
| 1455 | 1485 | |
| 1456 | 1486 | $search_params = array( |
| 1457 | 1487 | 'string' => $search_params_string, |
@@ -1534,9 +1564,10 @@ discard block |
||
| 1534 | 1564 | ' . $rowData['reason'] . ' |
| 1535 | 1565 | </div>'; |
| 1536 | 1566 | |
| 1537 | - if (!empty($rowData['id_notice'])) |
|
| 1538 | - $output .= ' |
|
| 1567 | + if (!empty($rowData['id_notice'])) { |
|
| 1568 | + $output .= ' |
|
| 1539 | 1569 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $rowData['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>'; |
| 1570 | + } |
|
| 1540 | 1571 | return $output; |
| 1541 | 1572 | }, |
| 1542 | 1573 | ), |
@@ -1654,9 +1685,9 @@ discard block |
||
| 1654 | 1685 | global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info; |
| 1655 | 1686 | |
| 1656 | 1687 | // Submitting a new one? |
| 1657 | - if (isset($_POST['add'])) |
|
| 1658 | - return ModifyWarningTemplate(); |
|
| 1659 | - elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
| 1688 | + if (isset($_POST['add'])) { |
|
| 1689 | + return ModifyWarningTemplate(); |
|
| 1690 | + } elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
| 1660 | 1691 | { |
| 1661 | 1692 | checkSession(); |
| 1662 | 1693 | validateToken('mod-wt'); |
@@ -1675,8 +1706,9 @@ discard block |
||
| 1675 | 1706 | 'current_member' => $user_info['id'], |
| 1676 | 1707 | ) |
| 1677 | 1708 | ); |
| 1678 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1679 | - logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
| 1709 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1710 | + logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
| 1711 | + } |
|
| 1680 | 1712 | $smcFunc['db_free_result']($request); |
| 1681 | 1713 | |
| 1682 | 1714 | // Do the deletes. |
@@ -1967,16 +1999,18 @@ discard block |
||
| 1967 | 1999 | ); |
| 1968 | 2000 | |
| 1969 | 2001 | // If it wasn't visible and now is they've effectively added it. |
| 1970 | - if ($context['template_data']['personal'] && !$recipient_id) |
|
| 1971 | - logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
| 2002 | + if ($context['template_data']['personal'] && !$recipient_id) { |
|
| 2003 | + logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
| 2004 | + } |
|
| 1972 | 2005 | // Conversely if they made it personal it's a delete. |
| 1973 | - elseif (!$context['template_data']['personal'] && $recipient_id) |
|
| 1974 | - logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
| 2006 | + elseif (!$context['template_data']['personal'] && $recipient_id) { |
|
| 2007 | + logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
| 2008 | + } |
|
| 1975 | 2009 | // Otherwise just an edit. |
| 1976 | - else |
|
| 1977 | - logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
| 1978 | - } |
|
| 1979 | - else |
|
| 2010 | + else { |
|
| 2011 | + logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
| 2012 | + } |
|
| 2013 | + } else |
|
| 1980 | 2014 | { |
| 1981 | 2015 | $smcFunc['db_insert']('', |
| 1982 | 2016 | '{db_prefix}log_comments', |
@@ -1996,17 +2030,18 @@ discard block |
||
| 1996 | 2030 | |
| 1997 | 2031 | // Get out of town... |
| 1998 | 2032 | redirectexit('action=moderate;area=warnings;sa=templates'); |
| 1999 | - } |
|
| 2000 | - else |
|
| 2033 | + } else |
|
| 2001 | 2034 | { |
| 2002 | 2035 | $context['warning_errors'] = array(); |
| 2003 | 2036 | $context['template_data']['title'] = !empty($_POST['template_title']) ? $_POST['template_title'] : ''; |
| 2004 | 2037 | $context['template_data']['body'] = !empty($_POST['template_body']) ? $_POST['template_body'] : $txt['mc_warning_template_body_default']; |
| 2005 | 2038 | $context['template_data']['personal'] = !empty($_POST['make_personal']); |
| 2006 | - if (empty($_POST['template_title'])) |
|
| 2007 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
| 2008 | - if (empty($_POST['template_body'])) |
|
| 2009 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
| 2039 | + if (empty($_POST['template_title'])) { |
|
| 2040 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
| 2041 | + } |
|
| 2042 | + if (empty($_POST['template_body'])) { |
|
| 2043 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
| 2044 | + } |
|
| 2010 | 2045 | } |
| 2011 | 2046 | } |
| 2012 | 2047 | |
@@ -2051,8 +2086,9 @@ discard block |
||
| 2051 | 2086 | // Now check other options! |
| 2052 | 2087 | $pref_binary = 0; |
| 2053 | 2088 | |
| 2054 | - if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) |
|
| 2055 | - $pref_binary |= 4; |
|
| 2089 | + if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) { |
|
| 2090 | + $pref_binary |= 4; |
|
| 2091 | + } |
|
| 2056 | 2092 | |
| 2057 | 2093 | // Put it all together. |
| 2058 | 2094 | $mod_prefs = '0||' . $pref_binary; |
@@ -2076,9 +2112,10 @@ discard block |
||
| 2076 | 2112 | unset($_SESSION['moderate_time']); |
| 2077 | 2113 | |
| 2078 | 2114 | // Clean any moderator tokens as well. |
| 2079 | - foreach ($_SESSION['token'] as $key => $token) |
|
| 2080 | - if (strpos($key, '-mod') !== false) |
|
| 2115 | + foreach ($_SESSION['token'] as $key => $token) { |
|
| 2116 | + if (strpos($key, '-mod') !== false) |
|
| 2081 | 2117 | unset($_SESSION['token'][$key]); |
| 2118 | + } |
|
| 2082 | 2119 | |
| 2083 | 2120 | redirectexit(); |
| 2084 | 2121 | } |
@@ -16,8 +16,9 @@ discard block |
||
| 16 | 16 | * @version 2.1 Beta 4 |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | -if (!defined('SMF')) |
|
| 19 | +if (!defined('SMF')) { |
|
| 20 | 20 | die('No direct access...'); |
| 21 | +} |
|
| 21 | 22 | |
| 22 | 23 | |
| 23 | 24 | /** |
@@ -28,14 +29,16 @@ discard block |
||
| 28 | 29 | function sha1_smf($str) |
| 29 | 30 | { |
| 30 | 31 | // If we have mhash loaded in, use it instead! |
| 31 | - if (function_exists('mhash') && defined('MHASH_SHA1')) |
|
| 32 | - return bin2hex(mhash(MHASH_SHA1, $str)); |
|
| 32 | + if (function_exists('mhash') && defined('MHASH_SHA1')) { |
|
| 33 | + return bin2hex(mhash(MHASH_SHA1, $str)); |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | $nblk = (strlen($str) + 8 >> 6) + 1; |
| 35 | 37 | $blks = array_pad(array(), $nblk * 16, 0); |
| 36 | 38 | |
| 37 | - for ($i = 0; $i < strlen($str); $i++) |
|
| 38 | - $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
| 39 | + for ($i = 0; $i < strlen($str); $i++) { |
|
| 40 | + $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
| 41 | + } |
|
| 39 | 42 | |
| 40 | 43 | $blks[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8); |
| 41 | 44 | |
@@ -70,10 +73,11 @@ discard block |
||
| 70 | 73 | |
| 71 | 74 | for ($j = 0; $j < 80; $j++) |
| 72 | 75 | { |
| 73 | - if ($j < 16) |
|
| 74 | - $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
| 75 | - else |
|
| 76 | - $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
| 76 | + if ($j < 16) { |
|
| 77 | + $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
| 78 | + } else { |
|
| 79 | + $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
| 80 | + } |
|
| 77 | 81 | |
| 78 | 82 | $t = sha1_rol($a, 5) + sha1_ft($j, $b, $c, $d) + $e + $w[$j] + sha1_kt($j); |
| 79 | 83 | $e = $d; |
@@ -103,12 +107,15 @@ discard block |
||
| 103 | 107 | */ |
| 104 | 108 | function sha1_ft($t, $b, $c, $d) |
| 105 | 109 | { |
| 106 | - if ($t < 20) |
|
| 107 | - return ($b & $c) | ((~$b) & $d); |
|
| 108 | - if ($t < 40) |
|
| 109 | - return $b ^ $c ^ $d; |
|
| 110 | - if ($t < 60) |
|
| 111 | - return ($b & $c) | ($b & $d) | ($c & $d); |
|
| 110 | + if ($t < 20) { |
|
| 111 | + return ($b & $c) | ((~$b) & $d); |
|
| 112 | + } |
|
| 113 | + if ($t < 40) { |
|
| 114 | + return $b ^ $c ^ $d; |
|
| 115 | + } |
|
| 116 | + if ($t < 60) { |
|
| 117 | + return ($b & $c) | ($b & $d) | ($c & $d); |
|
| 118 | + } |
|
| 112 | 119 | |
| 113 | 120 | return $b ^ $c ^ $d; |
| 114 | 121 | } |
@@ -132,10 +139,11 @@ discard block |
||
| 132 | 139 | function sha1_rol($num, $cnt) |
| 133 | 140 | { |
| 134 | 141 | // Unfortunately, PHP uses unsigned 32-bit longs only. So we have to kludge it a bit. |
| 135 | - if ($num & 0x80000000) |
|
| 136 | - $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
| 137 | - else |
|
| 138 | - $a = $num >> (32 - $cnt); |
|
| 142 | + if ($num & 0x80000000) { |
|
| 143 | + $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
| 144 | + } else { |
|
| 145 | + $a = $num >> (32 - $cnt); |
|
| 146 | + } |
|
| 139 | 147 | |
| 140 | 148 | return ($num << $cnt) | $a; |
| 141 | 149 | } |
@@ -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 | * The main entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
| 98 | 99 | { |
| 99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
| 100 | 101 | |
| 101 | - foreach ($_POST['censortext'] as $c) |
|
| 102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 103 | - } |
|
| 104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 102 | + foreach ($_POST['censortext'] as $c) { |
|
| 103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
| 104 | + } |
|
| 105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
| 105 | 106 | { |
| 106 | 107 | if (is_array($_POST['censor_vulgar'])) |
| 107 | 108 | { |
| 108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
| 109 | 110 | { |
| 110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
| 111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
| 112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
| 113 | + } |
|
| 112 | 114 | } |
| 113 | 115 | |
| 114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
| 115 | 117 | $censored_proper = $_POST['censor_proper']; |
| 116 | - } |
|
| 117 | - else |
|
| 118 | + } else |
|
| 118 | 119 | { |
| 119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
| 120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
| 151 | 152 | $context['censored_words'] = array(); |
| 152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
| 153 | 154 | { |
| 154 | - if (empty($censor_vulgar[$i])) |
|
| 155 | - continue; |
|
| 155 | + if (empty($censor_vulgar[$i])) { |
|
| 156 | + continue; |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | // Skip it, it's either spaces or stars only. |
| 158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
| 159 | - continue; |
|
| 160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 160 | 163 | |
| 161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
| 162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
| 187 | 190 | |
| 188 | 191 | // Make an inline conditional a little shorter... |
| 189 | 192 | $can_spell_check = false; |
| 190 | - if (function_exists('pspell_new')) |
|
| 191 | - $can_spell_check = true; |
|
| 192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
| 193 | - $can_spell_check = true; |
|
| 193 | + if (function_exists('pspell_new')) { |
|
| 194 | + $can_spell_check = true; |
|
| 195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
| 196 | + $can_spell_check = true; |
|
| 197 | + } |
|
| 194 | 198 | |
| 195 | 199 | // All the settings... |
| 196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
| 221 | 225 | |
| 222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
| 223 | 227 | |
| 224 | - if ($return_config) |
|
| 225 | - return $config_vars; |
|
| 228 | + if ($return_config) { |
|
| 229 | + return $config_vars; |
|
| 230 | + } |
|
| 226 | 231 | |
| 227 | 232 | // We'll want this for our easy save. |
| 228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
| 242 | 247 | db_extend('packages'); |
| 243 | 248 | |
| 244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 245 | - foreach ($colData as $column) |
|
| 246 | - if ($column['name'] == 'body') |
|
| 250 | + foreach ($colData as $column) { |
|
| 251 | + if ($column['name'] == 'body') |
|
| 247 | 252 | $body_type = $column['type']; |
| 253 | + } |
|
| 248 | 254 | |
| 249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
| 250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
| 256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
| 257 | + } |
|
| 251 | 258 | } |
| 252 | 259 | |
| 253 | 260 | // If we're changing the post preview length let's check its valid |
| 254 | - if (!empty($_POST['preview_characters'])) |
|
| 255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 261 | + if (!empty($_POST['preview_characters'])) { |
|
| 262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
| 263 | + } |
|
| 256 | 264 | |
| 257 | 265 | call_integration_hook('integrate_save_post_settings'); |
| 258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
| 313 | 321 | |
| 314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
| 315 | 323 | |
| 316 | - if ($return_config) |
|
| 317 | - return $config_vars; |
|
| 324 | + if ($return_config) { |
|
| 325 | + return $config_vars; |
|
| 326 | + } |
|
| 318 | 327 | |
| 319 | 328 | // Get the settings template ready. |
| 320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
| 367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
| 368 | 377 | ); |
| 369 | 378 | |
| 370 | - if ($return_config) |
|
| 371 | - return $config_vars; |
|
| 379 | + if ($return_config) { |
|
| 380 | + return $config_vars; |
|
| 381 | + } |
|
| 372 | 382 | |
| 373 | 383 | // Get the settings template ready. |
| 374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * View the forum's error log. |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc; |
| 31 | 32 | |
| 32 | 33 | // Viewing contents of a file? |
| 33 | - if (isset($_GET['file'])) |
|
| 34 | - return ViewFile(); |
|
| 34 | + if (isset($_GET['file'])) { |
|
| 35 | + return ViewFile(); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Check for the administrative permission to do this. |
| 37 | 39 | isAllowedTo('admin_forum'); |
@@ -85,8 +87,8 @@ discard block |
||
| 85 | 87 | ); |
| 86 | 88 | |
| 87 | 89 | // Set up the filtering... |
| 88 | - if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) |
|
| 89 | - $filter = array( |
|
| 90 | + if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { |
|
| 91 | + $filter = array( |
|
| 90 | 92 | 'variable' => $_GET['filter'], |
| 91 | 93 | 'value' => array( |
| 92 | 94 | 'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']), |
@@ -94,10 +96,12 @@ discard block |
||
| 94 | 96 | 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], |
| 95 | 97 | 'entity' => $filters[$_GET['filter']]['txt'] |
| 96 | 98 | ); |
| 99 | + } |
|
| 97 | 100 | |
| 98 | 101 | // Deleting, are we? |
| 99 | - if (isset($_POST['delall']) || isset($_POST['delete'])) |
|
| 100 | - deleteErrors(); |
|
| 102 | + if (isset($_POST['delall']) || isset($_POST['delete'])) { |
|
| 103 | + deleteErrors(); |
|
| 104 | + } |
|
| 101 | 105 | |
| 102 | 106 | // Just how many errors are there? |
| 103 | 107 | $result = $smcFunc['db_query']('', ' |
@@ -112,12 +116,14 @@ discard block |
||
| 112 | 116 | $smcFunc['db_free_result']($result); |
| 113 | 117 | |
| 114 | 118 | // If this filter is empty... |
| 115 | - if ($num_errors == 0 && isset($filter)) |
|
| 116 | - redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
| 119 | + if ($num_errors == 0 && isset($filter)) { |
|
| 120 | + redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
| 121 | + } |
|
| 117 | 122 | |
| 118 | 123 | // Clean up start. |
| 119 | - if (!isset($_GET['start']) || $_GET['start'] < 0) |
|
| 120 | - $_GET['start'] = 0; |
|
| 124 | + if (!isset($_GET['start']) || $_GET['start'] < 0) { |
|
| 125 | + $_GET['start'] = 0; |
|
| 126 | + } |
|
| 121 | 127 | |
| 122 | 128 | // Do we want to reverse error listing? |
| 123 | 129 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
@@ -127,9 +133,9 @@ discard block |
||
| 127 | 133 | $context['start'] = $_GET['start']; |
| 128 | 134 | |
| 129 | 135 | // Update the error count |
| 130 | - if (!isset($filter)) |
|
| 131 | - $context['num_errors'] = $num_errors; |
|
| 132 | - else |
|
| 136 | + if (!isset($filter)) { |
|
| 137 | + $context['num_errors'] = $num_errors; |
|
| 138 | + } else |
|
| 133 | 139 | { |
| 134 | 140 | // We want all errors, not just the number of filtered messages... |
| 135 | 141 | $query = $smcFunc['db_query']('', ' |
@@ -161,8 +167,9 @@ discard block |
||
| 161 | 167 | for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++) |
| 162 | 168 | { |
| 163 | 169 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
| 164 | - if ($search_message == $filter['value']['sql']) |
|
| 165 | - $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
| 170 | + if ($search_message == $filter['value']['sql']) { |
|
| 171 | + $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
| 172 | + } |
|
| 166 | 173 | $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br>')); |
| 167 | 174 | |
| 168 | 175 | $context['errors'][$row['id_error']] = array( |
@@ -221,8 +228,9 @@ discard block |
||
| 221 | 228 | 'members' => count($members), |
| 222 | 229 | ) |
| 223 | 230 | ); |
| 224 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 225 | - $members[$row['id_member']] = $row; |
|
| 231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 232 | + $members[$row['id_member']] = $row; |
|
| 233 | + } |
|
| 226 | 234 | $smcFunc['db_free_result']($request); |
| 227 | 235 | |
| 228 | 236 | // This is a guest... |
@@ -254,20 +262,18 @@ discard block |
||
| 254 | 262 | $id = $filter['value']['sql']; |
| 255 | 263 | loadMemberData($id, false, 'minimal'); |
| 256 | 264 | $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; |
| 257 | - } |
|
| 258 | - elseif ($filter['variable'] == 'url') |
|
| 259 | - $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
| 260 | - elseif ($filter['variable'] == 'message') |
|
| 265 | + } elseif ($filter['variable'] == 'url') { |
|
| 266 | + $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
| 267 | + } elseif ($filter['variable'] == 'message') |
|
| 261 | 268 | { |
| 262 | 269 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
| 263 | 270 | $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); |
| 264 | - } |
|
| 265 | - elseif ($filter['variable'] == 'error_type') |
|
| 271 | + } elseif ($filter['variable'] == 'error_type') |
|
| 266 | 272 | { |
| 267 | 273 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
| 274 | + } else { |
|
| 275 | + $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
| 268 | 276 | } |
| 269 | - else |
|
| 270 | - $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
| 271 | 277 | } |
| 272 | 278 | |
| 273 | 279 | $context['error_types'] = array(); |
@@ -308,10 +314,11 @@ discard block |
||
| 308 | 314 | $context['error_types']['all']['label'] .= ' (' . $sum . ')'; |
| 309 | 315 | |
| 310 | 316 | // Finally, work out what is the last tab! |
| 311 | - if (isset($context['error_types'][$sum])) |
|
| 312 | - $context['error_types'][$sum]['is_last'] = true; |
|
| 313 | - else |
|
| 314 | - $context['error_types']['all']['is_last'] = true; |
|
| 317 | + if (isset($context['error_types'][$sum])) { |
|
| 318 | + $context['error_types'][$sum]['is_last'] = true; |
|
| 319 | + } else { |
|
| 320 | + $context['error_types']['all']['is_last'] = true; |
|
| 321 | + } |
|
| 315 | 322 | |
| 316 | 323 | // And this is pretty basic ;). |
| 317 | 324 | $context['page_title'] = $txt['errlog']; |
@@ -337,21 +344,23 @@ discard block |
||
| 337 | 344 | validateToken('admin-el'); |
| 338 | 345 | |
| 339 | 346 | // Delete all or just some? |
| 340 | - if (isset($_POST['delall']) && !isset($filter)) |
|
| 341 | - $smcFunc['db_query']('truncate_table', ' |
|
| 347 | + if (isset($_POST['delall']) && !isset($filter)) { |
|
| 348 | + $smcFunc['db_query']('truncate_table', ' |
|
| 342 | 349 | TRUNCATE {db_prefix}log_errors', |
| 343 | 350 | array( |
| 344 | 351 | ) |
| 345 | 352 | ); |
| 353 | + } |
|
| 346 | 354 | // Deleting all with a filter? |
| 347 | - elseif (isset($_POST['delall']) && isset($filter)) |
|
| 348 | - $smcFunc['db_query']('', ' |
|
| 355 | + elseif (isset($_POST['delall']) && isset($filter)) { |
|
| 356 | + $smcFunc['db_query']('', ' |
|
| 349 | 357 | DELETE FROM {db_prefix}log_errors |
| 350 | 358 | WHERE ' . $filter['variable'] . ' LIKE {string:filter}', |
| 351 | 359 | array( |
| 352 | 360 | 'filter' => $filter['value']['sql'], |
| 353 | 361 | ) |
| 354 | 362 | ); |
| 363 | + } |
|
| 355 | 364 | // Just specific errors? |
| 356 | 365 | elseif (!empty($_POST['delete'])) |
| 357 | 366 | { |
@@ -397,15 +406,17 @@ discard block |
||
| 397 | 406 | $line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0; |
| 398 | 407 | |
| 399 | 408 | // Make sure the file we are looking for is one they are allowed to look at |
| 400 | - if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) |
|
| 401 | - fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
| 409 | + if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) { |
|
| 410 | + fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
| 411 | + } |
|
| 402 | 412 | |
| 403 | 413 | // get the min and max lines |
| 404 | 414 | $min = $line - 20 <= 0 ? 1 : $line - 20; |
| 405 | 415 | $max = $line + 21; // One additional line to make everything work out correctly |
| 406 | 416 | |
| 407 | - if ($max <= 0 || $min >= $max) |
|
| 408 | - fatal_lang_error('error_bad_line'); |
|
| 417 | + if ($max <= 0 || $min >= $max) { |
|
| 418 | + fatal_lang_error('error_bad_line'); |
|
| 419 | + } |
|
| 409 | 420 | |
| 410 | 421 | $file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file))))); |
| 411 | 422 | |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * !!!Compatibility!!! |
@@ -30,8 +31,9 @@ discard block |
||
| 30 | 31 | { |
| 31 | 32 | global $modSettings; |
| 32 | 33 | |
| 33 | - if (!$compat_mode) |
|
| 34 | - return $text; |
|
| 34 | + if (!$compat_mode) { |
|
| 35 | + return $text; |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | // Turn line breaks back into br's. |
| 37 | 39 | $text = strtr($text, array("\r" => '', "\n" => '<br>')); |
@@ -48,8 +50,9 @@ discard block |
||
| 48 | 50 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 49 | 51 | { |
| 50 | 52 | // Value of 2 means we're inside the tag. |
| 51 | - if ($i % 4 == 2) |
|
| 52 | - $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
| 53 | + if ($i % 4 == 2) { |
|
| 54 | + $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
| 55 | + } |
|
| 53 | 56 | } |
| 54 | 57 | // Put our humpty dumpty message back together again. |
| 55 | 58 | $text = implode('', $parts); |
@@ -107,8 +110,9 @@ discard block |
||
| 107 | 110 | $text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text); |
| 108 | 111 | |
| 109 | 112 | // Safari/webkit wraps lines in Wysiwyg in <div>'s. |
| 110 | - if (isBrowser('webkit')) |
|
| 111 | - $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
| 113 | + if (isBrowser('webkit')) { |
|
| 114 | + $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
| 115 | + } |
|
| 112 | 116 | |
| 113 | 117 | // If there's a trailing break get rid of it - Firefox tends to add one. |
| 114 | 118 | $text = preg_replace('~<br\s?/?' . '>$~i', '', $text); |
@@ -123,8 +127,9 @@ discard block |
||
| 123 | 127 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 124 | 128 | { |
| 125 | 129 | // Value of 2 means we're inside the tag. |
| 126 | - if ($i % 4 == 2) |
|
| 127 | - $parts[$i] = strip_tags($parts[$i]); |
|
| 130 | + if ($i % 4 == 2) { |
|
| 131 | + $parts[$i] = strip_tags($parts[$i]); |
|
| 132 | + } |
|
| 128 | 133 | } |
| 129 | 134 | |
| 130 | 135 | $text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>')); |
@@ -150,18 +155,19 @@ discard block |
||
| 150 | 155 | { |
| 151 | 156 | $found = array_search($file, $smileysto); |
| 152 | 157 | // Note the weirdness here is to stop double spaces between smileys. |
| 153 | - if ($found) |
|
| 154 | - $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
| 155 | - else |
|
| 156 | - $matches[1][$k] = ''; |
|
| 158 | + if ($found) { |
|
| 159 | + $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
| 160 | + } else { |
|
| 161 | + $matches[1][$k] = ''; |
|
| 162 | + } |
|
| 157 | 163 | } |
| 158 | - } |
|
| 159 | - else |
|
| 164 | + } else |
|
| 160 | 165 | { |
| 161 | 166 | // Load all the smileys. |
| 162 | 167 | $names = array(); |
| 163 | - foreach ($matches[1] as $file) |
|
| 164 | - $names[] = $file; |
|
| 168 | + foreach ($matches[1] as $file) { |
|
| 169 | + $names[] = $file; |
|
| 170 | + } |
|
| 165 | 171 | $names = array_unique($names); |
| 166 | 172 | |
| 167 | 173 | if (!empty($names)) |
@@ -175,13 +181,15 @@ discard block |
||
| 175 | 181 | ) |
| 176 | 182 | ); |
| 177 | 183 | $mappings = array(); |
| 178 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 179 | - $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
| 184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 185 | + $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
| 186 | + } |
|
| 180 | 187 | $smcFunc['db_free_result']($request); |
| 181 | 188 | |
| 182 | - foreach ($matches[1] as $k => $file) |
|
| 183 | - if (isset($mappings[$file])) |
|
| 189 | + foreach ($matches[1] as $k => $file) { |
|
| 190 | + if (isset($mappings[$file])) |
|
| 184 | 191 | $matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#'; |
| 192 | + } |
|
| 185 | 193 | } |
| 186 | 194 | } |
| 187 | 195 | |
@@ -193,8 +201,9 @@ discard block |
||
| 193 | 201 | } |
| 194 | 202 | |
| 195 | 203 | // Only try to buy more time if the client didn't quit. |
| 196 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 197 | - @apache_reset_timeout(); |
|
| 204 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 205 | + @apache_reset_timeout(); |
|
| 206 | + } |
|
| 198 | 207 | |
| 199 | 208 | $parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 200 | 209 | $replacement = ''; |
@@ -205,9 +214,9 @@ discard block |
||
| 205 | 214 | if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1) |
| 206 | 215 | { |
| 207 | 216 | // If it's being closed instantly, we can't deal with it...yet. |
| 208 | - if ($matches[5] === '/') |
|
| 209 | - continue; |
|
| 210 | - else |
|
| 217 | + if ($matches[5] === '/') { |
|
| 218 | + continue; |
|
| 219 | + } else |
|
| 211 | 220 | { |
| 212 | 221 | // Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.) |
| 213 | 222 | $styles = explode(';', strtr($matches[3], array('"' => ''))); |
@@ -223,8 +232,9 @@ discard block |
||
| 223 | 232 | $clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':')); |
| 224 | 233 | |
| 225 | 234 | // Something like 'font-weight: bold' is expected here. |
| 226 | - if (strpos($clean_type_value_pair, ':') === false) |
|
| 227 | - continue; |
|
| 235 | + if (strpos($clean_type_value_pair, ':') === false) { |
|
| 236 | + continue; |
|
| 237 | + } |
|
| 228 | 238 | |
| 229 | 239 | // Capture the elements of a single style item (e.g. 'font-weight' and 'bold'). |
| 230 | 240 | list ($style_type, $style_value) = explode(':', $type_value_pair); |
@@ -246,8 +256,7 @@ discard block |
||
| 246 | 256 | { |
| 247 | 257 | $curCloseTags .= '[/u]'; |
| 248 | 258 | $replacement .= '[u]'; |
| 249 | - } |
|
| 250 | - elseif ($style_value == 'line-through') |
|
| 259 | + } elseif ($style_value == 'line-through') |
|
| 251 | 260 | { |
| 252 | 261 | $curCloseTags .= '[/s]'; |
| 253 | 262 | $replacement .= '[s]'; |
@@ -259,13 +268,11 @@ discard block |
||
| 259 | 268 | { |
| 260 | 269 | $curCloseTags .= '[/left]'; |
| 261 | 270 | $replacement .= '[left]'; |
| 262 | - } |
|
| 263 | - elseif ($style_value == 'center') |
|
| 271 | + } elseif ($style_value == 'center') |
|
| 264 | 272 | { |
| 265 | 273 | $curCloseTags .= '[/center]'; |
| 266 | 274 | $replacement .= '[center]'; |
| 267 | - } |
|
| 268 | - elseif ($style_value == 'right') |
|
| 275 | + } elseif ($style_value == 'right') |
|
| 269 | 276 | { |
| 270 | 277 | $curCloseTags .= '[/right]'; |
| 271 | 278 | $replacement .= '[right]'; |
@@ -287,8 +294,9 @@ discard block |
||
| 287 | 294 | |
| 288 | 295 | case 'font-size': |
| 289 | 296 | // Sometimes people put decimals where decimals should not be. |
| 290 | - if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) |
|
| 291 | - $style_value = $dec_matches[1] . $dec_matches[2]; |
|
| 297 | + if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) { |
|
| 298 | + $style_value = $dec_matches[1] . $dec_matches[2]; |
|
| 299 | + } |
|
| 292 | 300 | |
| 293 | 301 | $curCloseTags .= '[/size]'; |
| 294 | 302 | $replacement .= '[size=' . $style_value . ']'; |
@@ -296,8 +304,9 @@ discard block |
||
| 296 | 304 | |
| 297 | 305 | case 'font-family': |
| 298 | 306 | // Only get the first freaking font if there's a list! |
| 299 | - if (strpos($style_value, ',') !== false) |
|
| 300 | - $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
| 307 | + if (strpos($style_value, ',') !== false) { |
|
| 308 | + $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
| 309 | + } |
|
| 301 | 310 | |
| 302 | 311 | $curCloseTags .= '[/font]'; |
| 303 | 312 | $replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']'; |
@@ -306,13 +315,15 @@ discard block |
||
| 306 | 315 | // This is a hack for images with dimensions embedded. |
| 307 | 316 | case 'width': |
| 308 | 317 | case 'height': |
| 309 | - if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) |
|
| 310 | - $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
| 318 | + if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) { |
|
| 319 | + $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
| 320 | + } |
|
| 311 | 321 | break; |
| 312 | 322 | |
| 313 | 323 | case 'list-style-type': |
| 314 | - if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) |
|
| 315 | - $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
| 324 | + if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) { |
|
| 325 | + $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
| 326 | + } |
|
| 316 | 327 | break; |
| 317 | 328 | } |
| 318 | 329 | } |
@@ -325,18 +336,17 @@ discard block |
||
| 325 | 336 | } |
| 326 | 337 | |
| 327 | 338 | // If there's something that still needs closing, push it to the stack. |
| 328 | - if (!empty($curCloseTags)) |
|
| 329 | - array_push($stack, array( |
|
| 339 | + if (!empty($curCloseTags)) { |
|
| 340 | + array_push($stack, array( |
|
| 330 | 341 | 'element' => strtolower($curElement), |
| 331 | 342 | 'closeTags' => $curCloseTags |
| 332 | 343 | ) |
| 333 | 344 | ); |
| 334 | - elseif (!empty($extra_attr)) |
|
| 335 | - $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
| 345 | + } elseif (!empty($extra_attr)) { |
|
| 346 | + $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
| 347 | + } |
|
| 336 | 348 | } |
| 337 | - } |
|
| 338 | - |
|
| 339 | - elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
| 349 | + } elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
| 340 | 350 | { |
| 341 | 351 | // Is this the element that we've been waiting for to be closed? |
| 342 | 352 | if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element']) |
@@ -346,28 +356,32 @@ discard block |
||
| 346 | 356 | } |
| 347 | 357 | |
| 348 | 358 | // Must've been something else. |
| 349 | - else |
|
| 350 | - $replacement .= $part; |
|
| 359 | + else { |
|
| 360 | + $replacement .= $part; |
|
| 361 | + } |
|
| 351 | 362 | } |
| 352 | 363 | // In all other cases, just add the part to the replacement. |
| 353 | - else |
|
| 354 | - $replacement .= $part; |
|
| 364 | + else { |
|
| 365 | + $replacement .= $part; |
|
| 366 | + } |
|
| 355 | 367 | } |
| 356 | 368 | |
| 357 | 369 | // Now put back the replacement in the text. |
| 358 | 370 | $text = $replacement; |
| 359 | 371 | |
| 360 | 372 | // We are not finished yet, request more time. |
| 361 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 362 | - @apache_reset_timeout(); |
|
| 373 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 374 | + @apache_reset_timeout(); |
|
| 375 | + } |
|
| 363 | 376 | |
| 364 | 377 | // Let's pull out any legacy alignments. |
| 365 | 378 | while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1) |
| 366 | 379 | { |
| 367 | 380 | // Find the position in the text of this tag over again. |
| 368 | 381 | $start_pos = strpos($text, $matches[0]); |
| 369 | - if ($start_pos === false) |
|
| 370 | - break; |
|
| 382 | + if ($start_pos === false) { |
|
| 383 | + break; |
|
| 384 | + } |
|
| 371 | 385 | |
| 372 | 386 | // End tag? |
| 373 | 387 | if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false) |
@@ -381,8 +395,7 @@ discard block |
||
| 381 | 395 | |
| 382 | 396 | // Put the tags back into the body. |
| 383 | 397 | $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos); |
| 384 | - } |
|
| 385 | - else |
|
| 398 | + } else |
|
| 386 | 399 | { |
| 387 | 400 | // Just get rid of this evil tag. |
| 388 | 401 | $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0])); |
@@ -395,8 +408,9 @@ discard block |
||
| 395 | 408 | // Find the position of this again. |
| 396 | 409 | $start_pos = strpos($text, $matches[0]); |
| 397 | 410 | $end_pos = false; |
| 398 | - if ($start_pos === false) |
|
| 399 | - break; |
|
| 411 | + if ($start_pos === false) { |
|
| 412 | + break; |
|
| 413 | + } |
|
| 400 | 414 | |
| 401 | 415 | // This must have an end tag - and we must find the right one. |
| 402 | 416 | $lower_text = strtolower($text); |
@@ -429,8 +443,9 @@ discard block |
||
| 429 | 443 | break; |
| 430 | 444 | } |
| 431 | 445 | } |
| 432 | - if ($end_pos === false) |
|
| 433 | - break; |
|
| 446 | + if ($end_pos === false) { |
|
| 447 | + break; |
|
| 448 | + } |
|
| 434 | 449 | |
| 435 | 450 | // Now work out what the attributes are. |
| 436 | 451 | $attribs = fetchTagAttributes($matches[1]); |
@@ -444,11 +459,11 @@ discard block |
||
| 444 | 459 | $v = (int) trim($v); |
| 445 | 460 | $v = empty($v) ? 1 : $v; |
| 446 | 461 | $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]'); |
| 462 | + } elseif ($s == 'face') { |
|
| 463 | + $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
| 464 | + } elseif ($s == 'color') { |
|
| 465 | + $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
| 447 | 466 | } |
| 448 | - elseif ($s == 'face') |
|
| 449 | - $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
| 450 | - elseif ($s == 'color') |
|
| 451 | - $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
| 452 | 467 | } |
| 453 | 468 | |
| 454 | 469 | // As before add in our tags. |
@@ -456,8 +471,9 @@ discard block |
||
| 456 | 471 | foreach ($tags as $tag) |
| 457 | 472 | { |
| 458 | 473 | $before .= $tag[0]; |
| 459 | - if (isset($tag[1])) |
|
| 460 | - $after = $tag[1] . $after; |
|
| 474 | + if (isset($tag[1])) { |
|
| 475 | + $after = $tag[1] . $after; |
|
| 476 | + } |
|
| 461 | 477 | } |
| 462 | 478 | |
| 463 | 479 | // Remove the tag so it's never checked again. |
@@ -468,8 +484,9 @@ discard block |
||
| 468 | 484 | } |
| 469 | 485 | |
| 470 | 486 | // Almost there, just a little more time. |
| 471 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 472 | - @apache_reset_timeout(); |
|
| 487 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 488 | + @apache_reset_timeout(); |
|
| 489 | + } |
|
| 473 | 490 | |
| 474 | 491 | if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) |
| 475 | 492 | { |
@@ -525,12 +542,13 @@ discard block |
||
| 525 | 542 | { |
| 526 | 543 | $inList = true; |
| 527 | 544 | |
| 528 | - if ($tag === 'ol') |
|
| 529 | - $listType = 'decimal'; |
|
| 530 | - elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) |
|
| 531 | - $listType = $listTypeMapping[$match[1]]; |
|
| 532 | - else |
|
| 533 | - $listType = null; |
|
| 545 | + if ($tag === 'ol') { |
|
| 546 | + $listType = 'decimal'; |
|
| 547 | + } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) { |
|
| 548 | + $listType = $listTypeMapping[$match[1]]; |
|
| 549 | + } else { |
|
| 550 | + $listType = null; |
|
| 551 | + } |
|
| 534 | 552 | |
| 535 | 553 | $listDepth++; |
| 536 | 554 | |
@@ -594,9 +612,7 @@ discard block |
||
| 594 | 612 | $parts[$i + 1] = ''; |
| 595 | 613 | $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]'; |
| 596 | 614 | $parts[$i + 3] = ''; |
| 597 | - } |
|
| 598 | - |
|
| 599 | - else |
|
| 615 | + } else |
|
| 600 | 616 | { |
| 601 | 617 | // We're in a list item. |
| 602 | 618 | if ($listDepth > 0) |
@@ -633,9 +649,7 @@ discard block |
||
| 633 | 649 | $parts[$i + 1] = ''; |
| 634 | 650 | $parts[$i + 2] = ''; |
| 635 | 651 | $parts[$i + 3] = ''; |
| 636 | - } |
|
| 637 | - |
|
| 638 | - else |
|
| 652 | + } else |
|
| 639 | 653 | { |
| 640 | 654 | // Remove the trailing breaks from the list item. |
| 641 | 655 | $parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]); |
@@ -673,8 +687,9 @@ discard block |
||
| 673 | 687 | $text .= str_repeat("\t", $listDepth) . '[/list]'; |
| 674 | 688 | } |
| 675 | 689 | |
| 676 | - for ($i = $listDepth; $i > 0; $i--) |
|
| 677 | - $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
| 690 | + for ($i = $listDepth; $i > 0; $i--) { |
|
| 691 | + $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
| 692 | + } |
|
| 678 | 693 | |
| 679 | 694 | } |
| 680 | 695 | |
@@ -683,8 +698,9 @@ discard block |
||
| 683 | 698 | { |
| 684 | 699 | // Find the position of the image. |
| 685 | 700 | $start_pos = strpos($text, $matches[0]); |
| 686 | - if ($start_pos === false) |
|
| 687 | - break; |
|
| 701 | + if ($start_pos === false) { |
|
| 702 | + break; |
|
| 703 | + } |
|
| 688 | 704 | $end_pos = $start_pos + strlen($matches[0]); |
| 689 | 705 | |
| 690 | 706 | $params = ''; |
@@ -693,12 +709,13 @@ discard block |
||
| 693 | 709 | $attrs = fetchTagAttributes($matches[1]); |
| 694 | 710 | foreach ($attrs as $attrib => $value) |
| 695 | 711 | { |
| 696 | - if (in_array($attrib, array('width', 'height'))) |
|
| 697 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 698 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
| 699 | - $params .= ' alt=' . trim($value); |
|
| 700 | - elseif ($attrib == 'src') |
|
| 701 | - $src = trim($value); |
|
| 712 | + if (in_array($attrib, array('width', 'height'))) { |
|
| 713 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
| 714 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
| 715 | + $params .= ' alt=' . trim($value); |
|
| 716 | + } elseif ($attrib == 'src') { |
|
| 717 | + $src = trim($value); |
|
| 718 | + } |
|
| 702 | 719 | } |
| 703 | 720 | |
| 704 | 721 | $tag = ''; |
@@ -709,10 +726,11 @@ discard block |
||
| 709 | 726 | { |
| 710 | 727 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 711 | 728 | |
| 712 | - if (substr($src, 0, 1) === '/') |
|
| 713 | - $src = $baseURL . $src; |
|
| 714 | - else |
|
| 715 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 729 | + if (substr($src, 0, 1) === '/') { |
|
| 730 | + $src = $baseURL . $src; |
|
| 731 | + } else { |
|
| 732 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
| 733 | + } |
|
| 716 | 734 | } |
| 717 | 735 | |
| 718 | 736 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -890,20 +908,23 @@ discard block |
||
| 890 | 908 | }, |
| 891 | 909 | ); |
| 892 | 910 | |
| 893 | - foreach ($tags as $tag => $replace) |
|
| 894 | - $text = preg_replace_callback($tag, $replace, $text); |
|
| 911 | + foreach ($tags as $tag => $replace) { |
|
| 912 | + $text = preg_replace_callback($tag, $replace, $text); |
|
| 913 | + } |
|
| 895 | 914 | |
| 896 | 915 | // Please give us just a little more time. |
| 897 | - if (connection_aborted() && $context['server']['is_apache']) |
|
| 898 | - @apache_reset_timeout(); |
|
| 916 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
| 917 | + @apache_reset_timeout(); |
|
| 918 | + } |
|
| 899 | 919 | |
| 900 | 920 | // What about URL's - the pain in the ass of the tag world. |
| 901 | 921 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
| 902 | 922 | { |
| 903 | 923 | // Find the position of the URL. |
| 904 | 924 | $start_pos = strpos($text, $matches[0]); |
| 905 | - if ($start_pos === false) |
|
| 906 | - break; |
|
| 925 | + if ($start_pos === false) { |
|
| 926 | + break; |
|
| 927 | + } |
|
| 907 | 928 | $end_pos = $start_pos + strlen($matches[0]); |
| 908 | 929 | |
| 909 | 930 | $tag_type = 'url'; |
@@ -917,8 +938,9 @@ discard block |
||
| 917 | 938 | $href = trim($value); |
| 918 | 939 | |
| 919 | 940 | // Are we dealing with an FTP link? |
| 920 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
| 921 | - $tag_type = 'ftp'; |
|
| 941 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
| 942 | + $tag_type = 'ftp'; |
|
| 943 | + } |
|
| 922 | 944 | |
| 923 | 945 | // Or is this a link to an email address? |
| 924 | 946 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -932,28 +954,31 @@ discard block |
||
| 932 | 954 | { |
| 933 | 955 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
| 934 | 956 | |
| 935 | - if (substr($href, 0, 1) === '/') |
|
| 936 | - $href = $baseURL . $href; |
|
| 937 | - else |
|
| 938 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 957 | + if (substr($href, 0, 1) === '/') { |
|
| 958 | + $href = $baseURL . $href; |
|
| 959 | + } else { |
|
| 960 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
| 961 | + } |
|
| 939 | 962 | } |
| 940 | 963 | } |
| 941 | 964 | |
| 942 | 965 | // External URL? |
| 943 | 966 | if ($attrib == 'target' && $tag_type == 'url') |
| 944 | 967 | { |
| 945 | - if (trim($value) == '_blank') |
|
| 946 | - $tag_type == 'iurl'; |
|
| 968 | + if (trim($value) == '_blank') { |
|
| 969 | + $tag_type == 'iurl'; |
|
| 970 | + } |
|
| 947 | 971 | } |
| 948 | 972 | } |
| 949 | 973 | |
| 950 | 974 | $tag = ''; |
| 951 | 975 | if ($href != '') |
| 952 | 976 | { |
| 953 | - if ($matches[2] == $href) |
|
| 954 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 955 | - else |
|
| 956 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 977 | + if ($matches[2] == $href) { |
|
| 978 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
| 979 | + } else { |
|
| 980 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
| 981 | + } |
|
| 957 | 982 | } |
| 958 | 983 | |
| 959 | 984 | // Replace the tag |
@@ -992,17 +1017,18 @@ discard block |
||
| 992 | 1017 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
| 993 | 1018 | if ($text[$i] == '=') |
| 994 | 1019 | { |
| 995 | - if ($tag_state == 0) |
|
| 996 | - $tag_state = 1; |
|
| 997 | - elseif ($tag_state == 2) |
|
| 998 | - $value .= '='; |
|
| 1020 | + if ($tag_state == 0) { |
|
| 1021 | + $tag_state = 1; |
|
| 1022 | + } elseif ($tag_state == 2) { |
|
| 1023 | + $value .= '='; |
|
| 1024 | + } |
|
| 999 | 1025 | } |
| 1000 | 1026 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
| 1001 | 1027 | elseif ($text[$i] == ' ') |
| 1002 | 1028 | { |
| 1003 | - if ($tag_state == 2) |
|
| 1004 | - $value .= ' '; |
|
| 1005 | - elseif ($tag_state == 1) |
|
| 1029 | + if ($tag_state == 2) { |
|
| 1030 | + $value .= ' '; |
|
| 1031 | + } elseif ($tag_state == 1) |
|
| 1006 | 1032 | { |
| 1007 | 1033 | $attribs[$key] = $value; |
| 1008 | 1034 | $key = $value = ''; |
@@ -1013,24 +1039,27 @@ discard block |
||
| 1013 | 1039 | elseif ($text[$i] == '"') |
| 1014 | 1040 | { |
| 1015 | 1041 | // Must be either going into or out of a string. |
| 1016 | - if ($tag_state == 1) |
|
| 1017 | - $tag_state = 2; |
|
| 1018 | - else |
|
| 1019 | - $tag_state = 1; |
|
| 1042 | + if ($tag_state == 1) { |
|
| 1043 | + $tag_state = 2; |
|
| 1044 | + } else { |
|
| 1045 | + $tag_state = 1; |
|
| 1046 | + } |
|
| 1020 | 1047 | } |
| 1021 | 1048 | // Otherwise it's fine. |
| 1022 | 1049 | else |
| 1023 | 1050 | { |
| 1024 | - if ($tag_state == 0) |
|
| 1025 | - $key .= $text[$i]; |
|
| 1026 | - else |
|
| 1027 | - $value .= $text[$i]; |
|
| 1051 | + if ($tag_state == 0) { |
|
| 1052 | + $key .= $text[$i]; |
|
| 1053 | + } else { |
|
| 1054 | + $value .= $text[$i]; |
|
| 1055 | + } |
|
| 1028 | 1056 | } |
| 1029 | 1057 | } |
| 1030 | 1058 | |
| 1031 | 1059 | // Anything left? |
| 1032 | - if ($key != '' && $value != '') |
|
| 1033 | - $attribs[$key] = $value; |
|
| 1060 | + if ($key != '' && $value != '') { |
|
| 1061 | + $attribs[$key] = $value; |
|
| 1062 | + } |
|
| 1034 | 1063 | |
| 1035 | 1064 | return $attribs; |
| 1036 | 1065 | } |
@@ -1046,15 +1075,17 @@ discard block |
||
| 1046 | 1075 | global $modSettings; |
| 1047 | 1076 | |
| 1048 | 1077 | // Don't care about the texts that are too short. |
| 1049 | - if (strlen($text) < 3) |
|
| 1050 | - return $text; |
|
| 1078 | + if (strlen($text) < 3) { |
|
| 1079 | + return $text; |
|
| 1080 | + } |
|
| 1051 | 1081 | |
| 1052 | 1082 | // A list of tags that's disabled by the admin. |
| 1053 | 1083 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
| 1054 | 1084 | |
| 1055 | 1085 | // Add flash if it's disabled as embedded tag. |
| 1056 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1057 | - $disabled['flash'] = true; |
|
| 1086 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1087 | + $disabled['flash'] = true; |
|
| 1088 | + } |
|
| 1058 | 1089 | |
| 1059 | 1090 | // Get a list of all the tags that are not disabled. |
| 1060 | 1091 | $all_tags = parse_bbc(false); |
@@ -1062,10 +1093,12 @@ discard block |
||
| 1062 | 1093 | $self_closing_tags = array(); |
| 1063 | 1094 | foreach ($all_tags as $tag) |
| 1064 | 1095 | { |
| 1065 | - if (!isset($disabled[$tag['tag']])) |
|
| 1066 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1067 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
| 1068 | - $self_closing_tags[] = $tag['tag']; |
|
| 1096 | + if (!isset($disabled[$tag['tag']])) { |
|
| 1097 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
| 1098 | + } |
|
| 1099 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
| 1100 | + $self_closing_tags[] = $tag['tag']; |
|
| 1101 | + } |
|
| 1069 | 1102 | } |
| 1070 | 1103 | |
| 1071 | 1104 | // Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid! |
@@ -1092,16 +1125,19 @@ discard block |
||
| 1092 | 1125 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
| 1093 | 1126 | |
| 1094 | 1127 | // We're closing the exact same tag that we opened. |
| 1095 | - if ($isClosingTag && $insideTag === $tagName) |
|
| 1096 | - $insideTag = null; |
|
| 1128 | + if ($isClosingTag && $insideTag === $tagName) { |
|
| 1129 | + $insideTag = null; |
|
| 1130 | + } |
|
| 1097 | 1131 | |
| 1098 | 1132 | // We're opening a tag and we're not yet inside one either |
| 1099 | - elseif (!$isClosingTag && $insideTag === null) |
|
| 1100 | - $insideTag = $tagName; |
|
| 1133 | + elseif (!$isClosingTag && $insideTag === null) { |
|
| 1134 | + $insideTag = $tagName; |
|
| 1135 | + } |
|
| 1101 | 1136 | |
| 1102 | 1137 | // In all other cases, this tag must be invalid |
| 1103 | - else |
|
| 1104 | - unset($matches[$i]); |
|
| 1138 | + else { |
|
| 1139 | + unset($matches[$i]); |
|
| 1140 | + } |
|
| 1105 | 1141 | } |
| 1106 | 1142 | |
| 1107 | 1143 | // The next one is gonna be the other one. |
@@ -1109,8 +1145,9 @@ discard block |
||
| 1109 | 1145 | } |
| 1110 | 1146 | |
| 1111 | 1147 | // We're still inside a tag and had no chance for closure? |
| 1112 | - if ($insideTag !== null) |
|
| 1113 | - $matches[] = '[/' . $insideTag . ']'; |
|
| 1148 | + if ($insideTag !== null) { |
|
| 1149 | + $matches[] = '[/' . $insideTag . ']'; |
|
| 1150 | + } |
|
| 1114 | 1151 | |
| 1115 | 1152 | // And a complete text string again. |
| 1116 | 1153 | $text = implode('', $matches); |
@@ -1119,8 +1156,9 @@ discard block |
||
| 1119 | 1156 | // Quickly remove any tags which are back to back. |
| 1120 | 1157 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
| 1121 | 1158 | $lastlen = 0; |
| 1122 | - while (strlen($text) !== $lastlen) |
|
| 1123 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1159 | + while (strlen($text) !== $lastlen) { |
|
| 1160 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1161 | + } |
|
| 1124 | 1162 | |
| 1125 | 1163 | // Need to sort the tags my name length. |
| 1126 | 1164 | uksort($valid_tags, 'sort_array_length'); |
@@ -1157,8 +1195,9 @@ discard block |
||
| 1157 | 1195 | $isCompetingTag = in_array($tag, $competing_tags); |
| 1158 | 1196 | |
| 1159 | 1197 | // Check if this might be one of those cleaned out tags. |
| 1160 | - if ($tag === '') |
|
| 1161 | - continue; |
|
| 1198 | + if ($tag === '') { |
|
| 1199 | + continue; |
|
| 1200 | + } |
|
| 1162 | 1201 | |
| 1163 | 1202 | // Special case: inside [code] blocks any code is left untouched. |
| 1164 | 1203 | elseif ($tag === 'code') |
@@ -1169,8 +1208,9 @@ discard block |
||
| 1169 | 1208 | $inCode = false; |
| 1170 | 1209 | |
| 1171 | 1210 | // Reopen tags that were closed before the code block. |
| 1172 | - if (!empty($inlineElements)) |
|
| 1173 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1211 | + if (!empty($inlineElements)) { |
|
| 1212 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1213 | + } |
|
| 1174 | 1214 | } |
| 1175 | 1215 | |
| 1176 | 1216 | // We're outside a coding and nobbc block and opening it. |
@@ -1199,8 +1239,9 @@ discard block |
||
| 1199 | 1239 | $inNoBbc = false; |
| 1200 | 1240 | |
| 1201 | 1241 | // Some inline elements might've been closed that need reopening. |
| 1202 | - if (!empty($inlineElements)) |
|
| 1203 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1242 | + if (!empty($inlineElements)) { |
|
| 1243 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
| 1244 | + } |
|
| 1204 | 1245 | } |
| 1205 | 1246 | |
| 1206 | 1247 | // We're outside a nobbc and coding block and opening it. |
@@ -1220,8 +1261,9 @@ discard block |
||
| 1220 | 1261 | } |
| 1221 | 1262 | |
| 1222 | 1263 | // So, we're inside one of the special blocks: ignore any tag. |
| 1223 | - elseif ($inCode || $inNoBbc) |
|
| 1224 | - continue; |
|
| 1264 | + elseif ($inCode || $inNoBbc) { |
|
| 1265 | + continue; |
|
| 1266 | + } |
|
| 1225 | 1267 | |
| 1226 | 1268 | // We're dealing with an opening tag. |
| 1227 | 1269 | if ($isOpeningTag) |
@@ -1262,8 +1304,9 @@ discard block |
||
| 1262 | 1304 | if ($parts[$j + 3] === $tag) |
| 1263 | 1305 | { |
| 1264 | 1306 | // If it's an opening tag, increase the level. |
| 1265 | - if ($parts[$j + 2] === '') |
|
| 1266 | - $curLevel++; |
|
| 1307 | + if ($parts[$j + 2] === '') { |
|
| 1308 | + $curLevel++; |
|
| 1309 | + } |
|
| 1267 | 1310 | |
| 1268 | 1311 | // A closing tag, decrease the level. |
| 1269 | 1312 | else |
@@ -1286,13 +1329,15 @@ discard block |
||
| 1286 | 1329 | { |
| 1287 | 1330 | if ($isCompetingTag) |
| 1288 | 1331 | { |
| 1289 | - if (!isset($competingElements[$tag])) |
|
| 1290 | - $competingElements[$tag] = array(); |
|
| 1332 | + if (!isset($competingElements[$tag])) { |
|
| 1333 | + $competingElements[$tag] = array(); |
|
| 1334 | + } |
|
| 1291 | 1335 | |
| 1292 | 1336 | $competingElements[$tag][] = $parts[$i + 4]; |
| 1293 | 1337 | |
| 1294 | - if (count($competingElements[$tag]) > 1) |
|
| 1295 | - $parts[$i] .= '[/' . $tag . ']'; |
|
| 1338 | + if (count($competingElements[$tag]) > 1) { |
|
| 1339 | + $parts[$i] .= '[/' . $tag . ']'; |
|
| 1340 | + } |
|
| 1296 | 1341 | } |
| 1297 | 1342 | |
| 1298 | 1343 | $inlineElements[$elementContent] = $tag; |
@@ -1313,15 +1358,17 @@ discard block |
||
| 1313 | 1358 | $addClosingTags = array(); |
| 1314 | 1359 | while ($element = array_pop($blockElements)) |
| 1315 | 1360 | { |
| 1316 | - if ($element === $tag) |
|
| 1317 | - break; |
|
| 1361 | + if ($element === $tag) { |
|
| 1362 | + break; |
|
| 1363 | + } |
|
| 1318 | 1364 | |
| 1319 | 1365 | // Still a block tag was open not equal to this tag. |
| 1320 | 1366 | $addClosingTags[] = $element['type']; |
| 1321 | 1367 | } |
| 1322 | 1368 | |
| 1323 | - if (!empty($addClosingTags)) |
|
| 1324 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1369 | + if (!empty($addClosingTags)) { |
|
| 1370 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
| 1371 | + } |
|
| 1325 | 1372 | |
| 1326 | 1373 | // Apparently the closing tag was not found on the stack. |
| 1327 | 1374 | if (!is_string($element) || $element !== $tag) |
@@ -1331,8 +1378,7 @@ discard block |
||
| 1331 | 1378 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
| 1332 | 1379 | continue; |
| 1333 | 1380 | } |
| 1334 | - } |
|
| 1335 | - else |
|
| 1381 | + } else |
|
| 1336 | 1382 | { |
| 1337 | 1383 | // Get rid of this closing tag! |
| 1338 | 1384 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1361,53 +1407,62 @@ discard block |
||
| 1361 | 1407 | unset($inlineElements[$tagContentToBeClosed]); |
| 1362 | 1408 | |
| 1363 | 1409 | // Was this the tag we were looking for? |
| 1364 | - if ($tagToBeClosed === $tag) |
|
| 1365 | - break; |
|
| 1410 | + if ($tagToBeClosed === $tag) { |
|
| 1411 | + break; |
|
| 1412 | + } |
|
| 1366 | 1413 | |
| 1367 | 1414 | // Nope, close it and look further! |
| 1368 | - else |
|
| 1369 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1415 | + else { |
|
| 1416 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
| 1417 | + } |
|
| 1370 | 1418 | } |
| 1371 | 1419 | |
| 1372 | 1420 | if ($isCompetingTag && !empty($competingElements[$tag])) |
| 1373 | 1421 | { |
| 1374 | 1422 | array_pop($competingElements[$tag]); |
| 1375 | 1423 | |
| 1376 | - if (count($competingElements[$tag]) > 0) |
|
| 1377 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1424 | + if (count($competingElements[$tag]) > 0) { |
|
| 1425 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
| 1426 | + } |
|
| 1378 | 1427 | } |
| 1379 | 1428 | } |
| 1380 | 1429 | |
| 1381 | 1430 | // Unexpected closing tag, ex-ter-mi-nate. |
| 1382 | - else |
|
| 1383 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1431 | + else { |
|
| 1432 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
| 1433 | + } |
|
| 1384 | 1434 | } |
| 1385 | 1435 | } |
| 1386 | 1436 | } |
| 1387 | 1437 | |
| 1388 | 1438 | // Close the code tags. |
| 1389 | - if ($inCode) |
|
| 1390 | - $parts[$i] .= '[/code]'; |
|
| 1439 | + if ($inCode) { |
|
| 1440 | + $parts[$i] .= '[/code]'; |
|
| 1441 | + } |
|
| 1391 | 1442 | |
| 1392 | 1443 | // The same for nobbc tags. |
| 1393 | - elseif ($inNoBbc) |
|
| 1394 | - $parts[$i] .= '[/nobbc]'; |
|
| 1444 | + elseif ($inNoBbc) { |
|
| 1445 | + $parts[$i] .= '[/nobbc]'; |
|
| 1446 | + } |
|
| 1395 | 1447 | |
| 1396 | 1448 | // Still inline tags left unclosed? Close them now, better late than never. |
| 1397 | - elseif (!empty($inlineElements)) |
|
| 1398 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1449 | + elseif (!empty($inlineElements)) { |
|
| 1450 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
| 1451 | + } |
|
| 1399 | 1452 | |
| 1400 | 1453 | // Now close the block elements. |
| 1401 | - if (!empty($blockElements)) |
|
| 1402 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1454 | + if (!empty($blockElements)) { |
|
| 1455 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
| 1456 | + } |
|
| 1403 | 1457 | |
| 1404 | 1458 | $text = implode('', $parts); |
| 1405 | 1459 | } |
| 1406 | 1460 | |
| 1407 | 1461 | // Final clean up of back to back tags. |
| 1408 | 1462 | $lastlen = 0; |
| 1409 | - while (strlen($text) !== $lastlen) |
|
| 1410 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1463 | + while (strlen($text) !== $lastlen) { |
|
| 1464 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
| 1465 | + } |
|
| 1411 | 1466 | |
| 1412 | 1467 | return $text; |
| 1413 | 1468 | } |
@@ -1436,22 +1491,25 @@ discard block |
||
| 1436 | 1491 | $context['template_layers'] = array(); |
| 1437 | 1492 | // Lets make sure we aren't going to output anything nasty. |
| 1438 | 1493 | @ob_end_clean(); |
| 1439 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
| 1440 | - @ob_start('ob_gzhandler'); |
|
| 1441 | - else |
|
| 1442 | - @ob_start(); |
|
| 1494 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
| 1495 | + @ob_start('ob_gzhandler'); |
|
| 1496 | + } else { |
|
| 1497 | + @ob_start(); |
|
| 1498 | + } |
|
| 1443 | 1499 | |
| 1444 | 1500 | // If we don't have any locale better avoid broken js |
| 1445 | - if (empty($txt['lang_locale'])) |
|
| 1446 | - die(); |
|
| 1501 | + if (empty($txt['lang_locale'])) { |
|
| 1502 | + die(); |
|
| 1503 | + } |
|
| 1447 | 1504 | |
| 1448 | 1505 | $file_data = '(function ($) { |
| 1449 | 1506 | \'use strict\'; |
| 1450 | 1507 | |
| 1451 | 1508 | $.sceditor.locale[' . javaScriptEscape($txt['lang_locale']) . '] = {'; |
| 1452 | - foreach ($editortxt as $key => $val) |
|
| 1453 | - $file_data .= ' |
|
| 1509 | + foreach ($editortxt as $key => $val) { |
|
| 1510 | + $file_data .= ' |
|
| 1454 | 1511 | ' . javaScriptEscape($key) . ': ' . javaScriptEscape($val) . ','; |
| 1512 | + } |
|
| 1455 | 1513 | |
| 1456 | 1514 | $file_data .= ' |
| 1457 | 1515 | dateFormat: "day.month.year" |
@@ -1519,8 +1577,9 @@ discard block |
||
| 1519 | 1577 | ) |
| 1520 | 1578 | ); |
| 1521 | 1579 | $icon_data = array(); |
| 1522 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1523 | - $icon_data[] = $row; |
|
| 1580 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1581 | + $icon_data[] = $row; |
|
| 1582 | + } |
|
| 1524 | 1583 | $smcFunc['db_free_result']($request); |
| 1525 | 1584 | |
| 1526 | 1585 | $icons = array(); |
@@ -1535,9 +1594,9 @@ discard block |
||
| 1535 | 1594 | } |
| 1536 | 1595 | |
| 1537 | 1596 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
| 1597 | + } else { |
|
| 1598 | + $icons = $temp; |
|
| 1538 | 1599 | } |
| 1539 | - else |
|
| 1540 | - $icons = $temp; |
|
| 1541 | 1600 | } |
| 1542 | 1601 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
| 1543 | 1602 | |
@@ -1578,8 +1637,9 @@ discard block |
||
| 1578 | 1637 | { |
| 1579 | 1638 | // Some general stuff. |
| 1580 | 1639 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
| 1581 | - if (!empty($context['drafts_autosave'])) |
|
| 1582 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1640 | + if (!empty($context['drafts_autosave'])) { |
|
| 1641 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
| 1642 | + } |
|
| 1583 | 1643 | |
| 1584 | 1644 | // This really has some WYSIWYG stuff. |
| 1585 | 1645 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1595,8 +1655,9 @@ discard block |
||
| 1595 | 1655 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
| 1596 | 1656 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
| 1597 | 1657 | // editor language file |
| 1598 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
| 1599 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
| 1658 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
| 1659 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
| 1660 | + } |
|
| 1600 | 1661 | |
| 1601 | 1662 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))]; |
| 1602 | 1663 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1605,11 +1666,12 @@ discard block |
||
| 1605 | 1666 | loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck'); |
| 1606 | 1667 | |
| 1607 | 1668 | // Some hidden information is needed in order to make the spell checking work. |
| 1608 | - if (!isset($_REQUEST['xml'])) |
|
| 1609 | - $context['insert_after_template'] .= ' |
|
| 1669 | + if (!isset($_REQUEST['xml'])) { |
|
| 1670 | + $context['insert_after_template'] .= ' |
|
| 1610 | 1671 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
| 1611 | 1672 | <input type="hidden" name="spellstring" value=""> |
| 1612 | 1673 | </form>'; |
| 1674 | + } |
|
| 1613 | 1675 | } |
| 1614 | 1676 | } |
| 1615 | 1677 | |
@@ -1775,10 +1837,12 @@ discard block |
||
| 1775 | 1837 | |
| 1776 | 1838 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
| 1777 | 1839 | $disabled_tags = array(); |
| 1778 | - if (!empty($modSettings['disabledBBC'])) |
|
| 1779 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1780 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
| 1781 | - $disabled_tags[] = 'flash'; |
|
| 1840 | + if (!empty($modSettings['disabledBBC'])) { |
|
| 1841 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
| 1842 | + } |
|
| 1843 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
| 1844 | + $disabled_tags[] = 'flash'; |
|
| 1845 | + } |
|
| 1782 | 1846 | |
| 1783 | 1847 | foreach ($disabled_tags as $tag) |
| 1784 | 1848 | { |
@@ -1788,9 +1852,10 @@ discard block |
||
| 1788 | 1852 | $context['disabled_tags']['orderedlist'] = true; |
| 1789 | 1853 | } |
| 1790 | 1854 | |
| 1791 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
| 1792 | - if ($tag === $thisTag) |
|
| 1855 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
| 1856 | + if ($tag === $thisTag) |
|
| 1793 | 1857 | $context['disabled_tags'][$tagNameBBC] = true; |
| 1858 | + } |
|
| 1794 | 1859 | |
| 1795 | 1860 | $context['disabled_tags'][trim($tag)] = true; |
| 1796 | 1861 | } |
@@ -1800,19 +1865,21 @@ discard block |
||
| 1800 | 1865 | $context['bbc_toolbar'] = array(); |
| 1801 | 1866 | foreach ($context['bbc_tags'] as $row => $tagRow) |
| 1802 | 1867 | { |
| 1803 | - if (!isset($context['bbc_toolbar'][$row])) |
|
| 1804 | - $context['bbc_toolbar'][$row] = array(); |
|
| 1868 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
| 1869 | + $context['bbc_toolbar'][$row] = array(); |
|
| 1870 | + } |
|
| 1805 | 1871 | $tagsRow = array(); |
| 1806 | 1872 | foreach ($tagRow as $tag) |
| 1807 | 1873 | { |
| 1808 | 1874 | if ((!empty($tag['code'])) && empty($context['disabled_tags'][$tag['code']])) |
| 1809 | 1875 | { |
| 1810 | 1876 | $tagsRow[] = $tag['code']; |
| 1811 | - if (isset($tag['image'])) |
|
| 1812 | - $bbcodes_styles .= ' |
|
| 1877 | + if (isset($tag['image'])) { |
|
| 1878 | + $bbcodes_styles .= ' |
|
| 1813 | 1879 | .sceditor-button-' . $tag['code'] . ' div { |
| 1814 | 1880 | background: url(\'' . $settings['default_theme_url'] . '/images/bbc/' . $tag['image'] . '.png\'); |
| 1815 | 1881 | }'; |
| 1882 | + } |
|
| 1816 | 1883 | if (isset($tag['before'])) |
| 1817 | 1884 | { |
| 1818 | 1885 | $context['bbcodes_handlers'] .= ' |
@@ -1826,8 +1893,7 @@ discard block |
||
| 1826 | 1893 | });'; |
| 1827 | 1894 | } |
| 1828 | 1895 | |
| 1829 | - } |
|
| 1830 | - else |
|
| 1896 | + } else |
|
| 1831 | 1897 | { |
| 1832 | 1898 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1833 | 1899 | $tagsRow = array(); |
@@ -1838,14 +1904,16 @@ discard block |
||
| 1838 | 1904 | { |
| 1839 | 1905 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
| 1840 | 1906 | $tagsRow = array(); |
| 1841 | - if (!isset($context['disabled_tags']['font'])) |
|
| 1842 | - $tagsRow[] = 'font'; |
|
| 1843 | - if (!isset($context['disabled_tags']['size'])) |
|
| 1844 | - $tagsRow[] = 'size'; |
|
| 1845 | - if (!isset($context['disabled_tags']['color'])) |
|
| 1846 | - $tagsRow[] = 'color'; |
|
| 1847 | - } |
|
| 1848 | - elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
| 1907 | + if (!isset($context['disabled_tags']['font'])) { |
|
| 1908 | + $tagsRow[] = 'font'; |
|
| 1909 | + } |
|
| 1910 | + if (!isset($context['disabled_tags']['size'])) { |
|
| 1911 | + $tagsRow[] = 'size'; |
|
| 1912 | + } |
|
| 1913 | + if (!isset($context['disabled_tags']['color'])) { |
|
| 1914 | + $tagsRow[] = 'color'; |
|
| 1915 | + } |
|
| 1916 | + } elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
| 1849 | 1917 | { |
| 1850 | 1918 | $tmp = array(); |
| 1851 | 1919 | $tagsRow[] = 'removeformat'; |
@@ -1856,13 +1924,15 @@ discard block |
||
| 1856 | 1924 | } |
| 1857 | 1925 | } |
| 1858 | 1926 | |
| 1859 | - if (!empty($tagsRow)) |
|
| 1860 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1927 | + if (!empty($tagsRow)) { |
|
| 1928 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
| 1929 | + } |
|
| 1861 | 1930 | } |
| 1862 | - if (!empty($bbcodes_styles)) |
|
| 1863 | - $context['html_headers'] .= ' |
|
| 1931 | + if (!empty($bbcodes_styles)) { |
|
| 1932 | + $context['html_headers'] .= ' |
|
| 1864 | 1933 | <style>' . $bbcodes_styles . ' |
| 1865 | 1934 | </style>'; |
| 1935 | + } |
|
| 1866 | 1936 | } |
| 1867 | 1937 | |
| 1868 | 1938 | // Initialize smiley array... if not loaded before. |
@@ -1874,8 +1944,8 @@ discard block |
||
| 1874 | 1944 | ); |
| 1875 | 1945 | |
| 1876 | 1946 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
| 1877 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
| 1878 | - $context['smileys']['postform'][] = array( |
|
| 1947 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
| 1948 | + $context['smileys']['postform'][] = array( |
|
| 1879 | 1949 | 'smileys' => array( |
| 1880 | 1950 | array( |
| 1881 | 1951 | 'code' => ':)', |
@@ -1961,7 +2031,7 @@ discard block |
||
| 1961 | 2031 | ), |
| 1962 | 2032 | 'isLast' => true, |
| 1963 | 2033 | ); |
| 1964 | - elseif ($user_info['smiley_set'] != 'none') |
|
| 2034 | + } elseif ($user_info['smiley_set'] != 'none') |
|
| 1965 | 2035 | { |
| 1966 | 2036 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
| 1967 | 2037 | { |
@@ -1984,17 +2054,19 @@ discard block |
||
| 1984 | 2054 | |
| 1985 | 2055 | foreach ($context['smileys'] as $section => $smileyRows) |
| 1986 | 2056 | { |
| 1987 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
| 1988 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2057 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
| 2058 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
| 2059 | + } |
|
| 1989 | 2060 | |
| 1990 | - if (!empty($smileyRows)) |
|
| 1991 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2061 | + if (!empty($smileyRows)) { |
|
| 2062 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
| 2063 | + } |
|
| 1992 | 2064 | } |
| 1993 | 2065 | |
| 1994 | 2066 | cache_put_data('posting_smileys', $context['smileys'], 480); |
| 2067 | + } else { |
|
| 2068 | + $context['smileys'] = $temp; |
|
| 1995 | 2069 | } |
| 1996 | - else |
|
| 1997 | - $context['smileys'] = $temp; |
|
| 1998 | 2070 | } |
| 1999 | 2071 | } |
| 2000 | 2072 | |
@@ -2020,8 +2092,9 @@ discard block |
||
| 2020 | 2092 | loadTemplate('GenericControls'); |
| 2021 | 2093 | |
| 2022 | 2094 | // Some javascript ma'am? |
| 2023 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
| 2024 | - loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
| 2095 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
| 2096 | + loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
| 2097 | + } |
|
| 2025 | 2098 | |
| 2026 | 2099 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
| 2027 | 2100 | |
@@ -2034,8 +2107,8 @@ discard block |
||
| 2034 | 2107 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
| 2035 | 2108 | |
| 2036 | 2109 | // Log this into our collection. |
| 2037 | - if ($isNew) |
|
| 2038 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2110 | + if ($isNew) { |
|
| 2111 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
| 2039 | 2112 | 'id' => $verificationOptions['id'], |
| 2040 | 2113 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
| 2041 | 2114 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2046,13 +2119,15 @@ discard block |
||
| 2046 | 2119 | 'questions' => array(), |
| 2047 | 2120 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
| 2048 | 2121 | ); |
| 2122 | + } |
|
| 2049 | 2123 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
| 2050 | 2124 | |
| 2051 | 2125 | // Is there actually going to be anything? |
| 2052 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
| 2053 | - return false; |
|
| 2054 | - elseif (!$isNew && !$do_test) |
|
| 2055 | - return true; |
|
| 2126 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
| 2127 | + return false; |
|
| 2128 | + } elseif (!$isNew && !$do_test) { |
|
| 2129 | + return true; |
|
| 2130 | + } |
|
| 2056 | 2131 | |
| 2057 | 2132 | // Sanitize reCAPTCHA fields? |
| 2058 | 2133 | if ($thisVerification['can_recaptcha']) |
@@ -2065,11 +2140,12 @@ discard block |
||
| 2065 | 2140 | } |
| 2066 | 2141 | |
| 2067 | 2142 | // Add javascript for the object. |
| 2068 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
| 2069 | - $context['insert_after_template'] .= ' |
|
| 2143 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
| 2144 | + $context['insert_after_template'] .= ' |
|
| 2070 | 2145 | <script> |
| 2071 | 2146 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
| 2072 | 2147 | </script>'; |
| 2148 | + } |
|
| 2073 | 2149 | |
| 2074 | 2150 | // If we want questions do we have a cache of all the IDs? |
| 2075 | 2151 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2092,8 +2168,9 @@ discard block |
||
| 2092 | 2168 | unset ($row['id_question']); |
| 2093 | 2169 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
| 2094 | 2170 | $row['answers'] = smf_json_decode($row['answers'], true); |
| 2095 | - foreach ($row['answers'] as $k => $v) |
|
| 2096 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2171 | + foreach ($row['answers'] as $k => $v) { |
|
| 2172 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
| 2173 | + } |
|
| 2097 | 2174 | |
| 2098 | 2175 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
| 2099 | 2176 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2104,35 +2181,42 @@ discard block |
||
| 2104 | 2181 | } |
| 2105 | 2182 | } |
| 2106 | 2183 | |
| 2107 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
| 2108 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2184 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
| 2185 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
| 2186 | + } |
|
| 2109 | 2187 | |
| 2110 | 2188 | // Do we need to refresh the verification? |
| 2111 | - if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) |
|
| 2112 | - $force_refresh = true; |
|
| 2113 | - else |
|
| 2114 | - $force_refresh = false; |
|
| 2189 | + if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) { |
|
| 2190 | + $force_refresh = true; |
|
| 2191 | + } else { |
|
| 2192 | + $force_refresh = false; |
|
| 2193 | + } |
|
| 2115 | 2194 | |
| 2116 | 2195 | // This can also force a fresh, although unlikely. |
| 2117 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2118 | - $force_refresh = true; |
|
| 2196 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2197 | + $force_refresh = true; |
|
| 2198 | + } |
|
| 2119 | 2199 | |
| 2120 | 2200 | $verification_errors = array(); |
| 2121 | 2201 | // Start with any testing. |
| 2122 | 2202 | if ($do_test) |
| 2123 | 2203 | { |
| 2124 | 2204 | // This cannot happen! |
| 2125 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
| 2126 | - fatal_lang_error('no_access', false); |
|
| 2205 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
| 2206 | + fatal_lang_error('no_access', false); |
|
| 2207 | + } |
|
| 2127 | 2208 | // ... nor this! |
| 2128 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
| 2129 | - fatal_lang_error('no_access', false); |
|
| 2209 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
| 2210 | + fatal_lang_error('no_access', false); |
|
| 2211 | + } |
|
| 2130 | 2212 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
| 2131 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
| 2132 | - fatal_lang_error('no_access', false); |
|
| 2213 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
| 2214 | + fatal_lang_error('no_access', false); |
|
| 2215 | + } |
|
| 2133 | 2216 | // While we're here, did the user do something bad? |
| 2134 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
| 2135 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2217 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
| 2218 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2219 | + } |
|
| 2136 | 2220 | |
| 2137 | 2221 | if ($thisVerification['can_recaptcha']) |
| 2138 | 2222 | { |
@@ -2143,22 +2227,25 @@ discard block |
||
| 2143 | 2227 | { |
| 2144 | 2228 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
| 2145 | 2229 | |
| 2146 | - if (!$resp->isSuccess()) |
|
| 2147 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2230 | + if (!$resp->isSuccess()) { |
|
| 2231 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2232 | + } |
|
| 2233 | + } else { |
|
| 2234 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2148 | 2235 | } |
| 2149 | - else |
|
| 2150 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2151 | 2236 | } |
| 2152 | - if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) |
|
| 2153 | - $verification_errors[] = 'wrong_verification_code'; |
|
| 2237 | + if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) { |
|
| 2238 | + $verification_errors[] = 'wrong_verification_code'; |
|
| 2239 | + } |
|
| 2154 | 2240 | if ($thisVerification['number_questions']) |
| 2155 | 2241 | { |
| 2156 | 2242 | $incorrectQuestions = array(); |
| 2157 | 2243 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
| 2158 | 2244 | { |
| 2159 | 2245 | // We don't have this question any more, thus no answers. |
| 2160 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
| 2161 | - continue; |
|
| 2246 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
| 2247 | + continue; |
|
| 2248 | + } |
|
| 2162 | 2249 | // This is quite complex. We have our question but it might have multiple answers. |
| 2163 | 2250 | // First, did they actually answer this question? |
| 2164 | 2251 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2170,24 +2257,28 @@ discard block |
||
| 2170 | 2257 | else |
| 2171 | 2258 | { |
| 2172 | 2259 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
| 2173 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
| 2174 | - $incorrectQuestions[] = $q; |
|
| 2260 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
| 2261 | + $incorrectQuestions[] = $q; |
|
| 2262 | + } |
|
| 2175 | 2263 | } |
| 2176 | 2264 | } |
| 2177 | 2265 | |
| 2178 | - if (!empty($incorrectQuestions)) |
|
| 2179 | - $verification_errors[] = 'wrong_verification_answer'; |
|
| 2266 | + if (!empty($incorrectQuestions)) { |
|
| 2267 | + $verification_errors[] = 'wrong_verification_answer'; |
|
| 2268 | + } |
|
| 2180 | 2269 | } |
| 2181 | 2270 | } |
| 2182 | 2271 | |
| 2183 | 2272 | // Any errors means we refresh potentially. |
| 2184 | 2273 | if (!empty($verification_errors)) |
| 2185 | 2274 | { |
| 2186 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
| 2187 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2275 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
| 2276 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
| 2277 | + } |
|
| 2188 | 2278 | // Too many errors? |
| 2189 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
| 2190 | - $force_refresh = true; |
|
| 2279 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
| 2280 | + $force_refresh = true; |
|
| 2281 | + } |
|
| 2191 | 2282 | |
| 2192 | 2283 | // Keep a track of these. |
| 2193 | 2284 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2220,8 +2311,9 @@ discard block |
||
| 2220 | 2311 | // Are we overriding the range? |
| 2221 | 2312 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
| 2222 | 2313 | |
| 2223 | - for ($i = 0; $i < 6; $i++) |
|
| 2224 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2314 | + for ($i = 0; $i < 6; $i++) { |
|
| 2315 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
| 2316 | + } |
|
| 2225 | 2317 | } |
| 2226 | 2318 | |
| 2227 | 2319 | // Getting some new questions? |
@@ -2229,8 +2321,9 @@ discard block |
||
| 2229 | 2321 | { |
| 2230 | 2322 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
| 2231 | 2323 | $possible_langs = array(); |
| 2232 | - if (isset($_SESSION['language'])) |
|
| 2233 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2324 | + if (isset($_SESSION['language'])) { |
|
| 2325 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
| 2326 | + } |
|
| 2234 | 2327 | if (!empty($user_info['language'])); |
| 2235 | 2328 | $possible_langs[] = $user_info['language']; |
| 2236 | 2329 | $possible_langs[] = $language; |
@@ -2249,8 +2342,7 @@ discard block |
||
| 2249 | 2342 | } |
| 2250 | 2343 | } |
| 2251 | 2344 | } |
| 2252 | - } |
|
| 2253 | - else |
|
| 2345 | + } else |
|
| 2254 | 2346 | { |
| 2255 | 2347 | // Same questions as before. |
| 2256 | 2348 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2260,8 +2352,9 @@ discard block |
||
| 2260 | 2352 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
| 2261 | 2353 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
| 2262 | 2354 | { |
| 2263 | - if (!isset($context['html_headers'])) |
|
| 2264 | - $context['html_headers'] = ''; |
|
| 2355 | + if (!isset($context['html_headers'])) { |
|
| 2356 | + $context['html_headers'] = ''; |
|
| 2357 | + } |
|
| 2265 | 2358 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
| 2266 | 2359 | } |
| 2267 | 2360 | |
@@ -2287,11 +2380,13 @@ discard block |
||
| 2287 | 2380 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
| 2288 | 2381 | |
| 2289 | 2382 | // Return errors if we have them. |
| 2290 | - if (!empty($verification_errors)) |
|
| 2291 | - return $verification_errors; |
|
| 2383 | + if (!empty($verification_errors)) { |
|
| 2384 | + return $verification_errors; |
|
| 2385 | + } |
|
| 2292 | 2386 | // If we had a test that one, make a note. |
| 2293 | - elseif ($do_test) |
|
| 2294 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2387 | + elseif ($do_test) { |
|
| 2388 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
| 2389 | + } |
|
| 2295 | 2390 | |
| 2296 | 2391 | // Say that everything went well chaps. |
| 2297 | 2392 | return true; |
@@ -2316,8 +2411,9 @@ discard block |
||
| 2316 | 2411 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
| 2317 | 2412 | |
| 2318 | 2413 | // If we're just checking the callback function is registered return true or false. |
| 2319 | - if ($checkRegistered != null) |
|
| 2320 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2414 | + if ($checkRegistered != null) { |
|
| 2415 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
| 2416 | + } |
|
| 2321 | 2417 | |
| 2322 | 2418 | checkSession('get'); |
| 2323 | 2419 | loadTemplate('Xml'); |
@@ -2468,24 +2564,27 @@ discard block |
||
| 2468 | 2564 | foreach ($possible_versions as $ver) |
| 2469 | 2565 | { |
| 2470 | 2566 | $ver = trim($ver); |
| 2471 | - if (strpos($ver, 'SMF') === 0) |
|
| 2472 | - $versions[] = $ver; |
|
| 2567 | + if (strpos($ver, 'SMF') === 0) { |
|
| 2568 | + $versions[] = $ver; |
|
| 2569 | + } |
|
| 2473 | 2570 | } |
| 2474 | 2571 | } |
| 2475 | 2572 | $smcFunc['db_free_result']($request); |
| 2476 | 2573 | |
| 2477 | 2574 | // Just in case we don't have ANYthing. |
| 2478 | - if (empty($versions)) |
|
| 2479 | - $versions = array('SMF 2.0'); |
|
| 2575 | + if (empty($versions)) { |
|
| 2576 | + $versions = array('SMF 2.0'); |
|
| 2577 | + } |
|
| 2480 | 2578 | |
| 2481 | - foreach ($versions as $id => $version) |
|
| 2482 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2579 | + foreach ($versions as $id => $version) { |
|
| 2580 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
| 2483 | 2581 | $xml_data['items']['children'][] = array( |
| 2484 | 2582 | 'attributes' => array( |
| 2485 | 2583 | 'id' => $id, |
| 2486 | 2584 | ), |
| 2487 | 2585 | 'value' => $version, |
| 2488 | 2586 | ); |
| 2587 | + } |
|
| 2489 | 2588 | |
| 2490 | 2589 | return $xml_data; |
| 2491 | 2590 | } |