@@ -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 dispatcher; doesn't do anything, just delegates. |
@@ -92,18 +93,19 @@ discard block |
||
92 | 93 | checkSession('get'); |
93 | 94 | validateToken('admin-bm-' . (int) $_REQUEST['src_board'], 'request'); |
94 | 95 | |
95 | - if ($_REQUEST['move_to'] === 'top') |
|
96 | - $boardOptions = array( |
|
96 | + if ($_REQUEST['move_to'] === 'top') { |
|
97 | + $boardOptions = array( |
|
97 | 98 | 'move_to' => $_REQUEST['move_to'], |
98 | 99 | 'target_category' => (int) $_REQUEST['target_cat'], |
99 | 100 | 'move_first_child' => true, |
100 | 101 | ); |
101 | - else |
|
102 | - $boardOptions = array( |
|
102 | + } else { |
|
103 | + $boardOptions = array( |
|
103 | 104 | 'move_to' => $_REQUEST['move_to'], |
104 | 105 | 'target_board' => (int) $_REQUEST['target_board'], |
105 | 106 | 'move_first_child' => true, |
106 | 107 | ); |
108 | + } |
|
107 | 109 | modifyBoard((int) $_REQUEST['src_board'], $boardOptions); |
108 | 110 | } |
109 | 111 | |
@@ -148,15 +150,16 @@ discard block |
||
148 | 150 | $security = $context['session_var'] . '=' . $context['session_id'] . ';' . $context['admin-bm-' . $context['move_board'] . '_token_var'] . '=' . $context['admin-bm-' . $context['move_board'] . '_token']; |
149 | 151 | foreach ($boardList[$catid] as $boardid) |
150 | 152 | { |
151 | - if (!isset($context['categories'][$catid]['move_link'])) |
|
152 | - $context['categories'][$catid]['move_link'] = array( |
|
153 | + if (!isset($context['categories'][$catid]['move_link'])) { |
|
154 | + $context['categories'][$catid]['move_link'] = array( |
|
153 | 155 | 'child_level' => 0, |
154 | 156 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
155 | 157 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security, |
156 | 158 | ); |
159 | + } |
|
157 | 160 | |
158 | - if (!$context['categories'][$catid]['boards'][$boardid]['move']) |
|
159 | - $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
161 | + if (!$context['categories'][$catid]['boards'][$boardid]['move']) { |
|
162 | + $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
160 | 163 | array( |
161 | 164 | 'child_level' => $boards[$boardid]['level'], |
162 | 165 | 'label' => $txt['mboards_order_after'] . '\'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
@@ -170,33 +173,38 @@ discard block |
||
170 | 173 | 'class' => 'here', |
171 | 174 | ), |
172 | 175 | ); |
176 | + } |
|
173 | 177 | |
174 | 178 | $difference = $boards[$boardid]['level'] - $prev_child_level; |
175 | - if ($difference == 1) |
|
176 | - array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
177 | - elseif ($difference < 0) |
|
179 | + if ($difference == 1) { |
|
180 | + array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
181 | + } elseif ($difference < 0) |
|
178 | 182 | { |
179 | - if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
180 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
181 | - for ($i = 0; $i < -$difference; $i++) |
|
182 | - if (($temp = array_pop($stack)) != null) |
|
183 | + if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
184 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
185 | + } |
|
186 | + for ($i = 0; $i < -$difference; $i++) { |
|
187 | + if (($temp = array_pop($stack)) != null) |
|
183 | 188 | array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp); |
189 | + } |
|
184 | 190 | } |
185 | 191 | |
186 | 192 | $prev_board = $boardid; |
187 | 193 | $prev_child_level = $boards[$boardid]['level']; |
188 | 194 | } |
189 | - if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
190 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
191 | - elseif (!empty($stack)) |
|
192 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
195 | + if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
196 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
197 | + } elseif (!empty($stack)) { |
|
198 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
199 | + } |
|
193 | 200 | |
194 | - if (empty($boardList[$catid])) |
|
195 | - $context['categories'][$catid]['move_link'] = array( |
|
201 | + if (empty($boardList[$catid])) { |
|
202 | + $context['categories'][$catid]['move_link'] = array( |
|
196 | 203 | 'child_level' => 0, |
197 | 204 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'', |
198 | 205 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
199 | 206 | ); |
207 | + } |
|
200 | 208 | } |
201 | 209 | } |
202 | 210 | |
@@ -252,9 +260,9 @@ discard block |
||
252 | 260 | ); |
253 | 261 | } |
254 | 262 | // Category doesn't exist, man... sorry. |
255 | - elseif (!isset($cat_tree[$_REQUEST['cat']])) |
|
256 | - redirectexit('action=admin;area=manageboards'); |
|
257 | - else |
|
263 | + elseif (!isset($cat_tree[$_REQUEST['cat']])) { |
|
264 | + redirectexit('action=admin;area=manageboards'); |
|
265 | + } else |
|
258 | 266 | { |
259 | 267 | $context['category'] = array( |
260 | 268 | 'id' => $_REQUEST['cat'], |
@@ -266,30 +274,31 @@ discard block |
||
266 | 274 | 'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children']) |
267 | 275 | ); |
268 | 276 | |
269 | - foreach ($boardList[$_REQUEST['cat']] as $child_board) |
|
270 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
277 | + foreach ($boardList[$_REQUEST['cat']] as $child_board) { |
|
278 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
279 | + } |
|
271 | 280 | } |
272 | 281 | |
273 | 282 | $prevCat = 0; |
274 | 283 | foreach ($cat_tree as $catid => $tree) |
275 | 284 | { |
276 | - if ($catid == $_REQUEST['cat'] && $prevCat > 0) |
|
277 | - $context['category_order'][$prevCat]['selected'] = true; |
|
278 | - elseif ($catid != $_REQUEST['cat']) |
|
279 | - $context['category_order'][$catid] = array( |
|
285 | + if ($catid == $_REQUEST['cat'] && $prevCat > 0) { |
|
286 | + $context['category_order'][$prevCat]['selected'] = true; |
|
287 | + } elseif ($catid != $_REQUEST['cat']) { |
|
288 | + $context['category_order'][$catid] = array( |
|
280 | 289 | 'id' => $catid, |
281 | 290 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
282 | 291 | 'selected' => false, |
283 | 292 | 'true_name' => $tree['node']['name'] |
284 | 293 | ); |
294 | + } |
|
285 | 295 | $prevCat = $catid; |
286 | 296 | } |
287 | 297 | if (!isset($_REQUEST['delete'])) |
288 | 298 | { |
289 | 299 | $context['sub_template'] = 'modify_category'; |
290 | 300 | $context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit']; |
291 | - } |
|
292 | - else |
|
301 | + } else |
|
293 | 302 | { |
294 | 303 | $context['sub_template'] = 'confirm_category_delete'; |
295 | 304 | $context['page_title'] = $txt['mboards_delete_cat']; |
@@ -326,8 +335,9 @@ discard block |
||
326 | 335 | { |
327 | 336 | $catOptions = array(); |
328 | 337 | |
329 | - if (isset($_POST['cat_order'])) |
|
330 | - $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
338 | + if (isset($_POST['cat_order'])) { |
|
339 | + $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
340 | + } |
|
331 | 341 | |
332 | 342 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
333 | 343 | $catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']); |
@@ -335,10 +345,11 @@ discard block |
||
335 | 345 | |
336 | 346 | $catOptions['is_collapsible'] = isset($_POST['collapse']); |
337 | 347 | |
338 | - if (isset($_POST['add'])) |
|
339 | - createCategory($catOptions); |
|
340 | - else |
|
341 | - modifyCategory($_POST['cat'], $catOptions); |
|
348 | + if (isset($_POST['add'])) { |
|
349 | + createCategory($catOptions); |
|
350 | + } else { |
|
351 | + modifyCategory($_POST['cat'], $catOptions); |
|
352 | + } |
|
342 | 353 | } |
343 | 354 | // If they want to delete - first give them confirmation. |
344 | 355 | elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) |
@@ -352,13 +363,14 @@ discard block |
||
352 | 363 | // First off - check if we are moving all the current boards first - before we start deleting! |
353 | 364 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
354 | 365 | { |
355 | - if (empty($_POST['cat_to'])) |
|
356 | - fatal_lang_error('mboards_delete_error'); |
|
366 | + if (empty($_POST['cat_to'])) { |
|
367 | + fatal_lang_error('mboards_delete_error'); |
|
368 | + } |
|
357 | 369 | |
358 | 370 | deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); |
371 | + } else { |
|
372 | + deleteCategories(array($_POST['cat'])); |
|
359 | 373 | } |
360 | - else |
|
361 | - deleteCategories(array($_POST['cat'])); |
|
362 | 374 | } |
363 | 375 | |
364 | 376 | redirectexit('action=admin;area=manageboards'); |
@@ -403,8 +415,9 @@ discard block |
||
403 | 415 | if ($_REQUEST['sa'] == 'newboard') |
404 | 416 | { |
405 | 417 | // Category doesn't exist, man... sorry. |
406 | - if (empty($_REQUEST['cat'])) |
|
407 | - redirectexit('action=admin;area=manageboards'); |
|
418 | + if (empty($_REQUEST['cat'])) { |
|
419 | + redirectexit('action=admin;area=manageboards'); |
|
420 | + } |
|
408 | 421 | |
409 | 422 | // Some things that need to be setup for a new board. |
410 | 423 | $curBoard = array( |
@@ -428,8 +441,7 @@ discard block |
||
428 | 441 | 'category' => (int) $_REQUEST['cat'], |
429 | 442 | 'no_children' => true, |
430 | 443 | ); |
431 | - } |
|
432 | - else |
|
444 | + } else |
|
433 | 445 | { |
434 | 446 | // Just some easy shortcuts. |
435 | 447 | $curBoard = &$boards[$_REQUEST['boardid']]; |
@@ -477,8 +489,9 @@ discard block |
||
477 | 489 | ); |
478 | 490 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
479 | 491 | { |
480 | - if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) |
|
481 | - $curBoard['member_groups'][] = $row['id_group']; |
|
492 | + if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) { |
|
493 | + $curBoard['member_groups'][] = $row['id_group']; |
|
494 | + } |
|
482 | 495 | |
483 | 496 | $context['groups'][(int) $row['id_group']] = array( |
484 | 497 | 'id' => $row['id_group'], |
@@ -491,8 +504,9 @@ discard block |
||
491 | 504 | $smcFunc['db_free_result']($request); |
492 | 505 | |
493 | 506 | // Category doesn't exist, man... sorry. |
494 | - if (!isset($boardList[$curBoard['category']])) |
|
495 | - redirectexit('action=admin;area=manageboards'); |
|
507 | + if (!isset($boardList[$curBoard['category']])) { |
|
508 | + redirectexit('action=admin;area=manageboards'); |
|
509 | + } |
|
496 | 510 | |
497 | 511 | foreach ($boardList[$curBoard['category']] as $boardid) |
498 | 512 | { |
@@ -506,8 +520,7 @@ discard block |
||
506 | 520 | 'is_child' => false, |
507 | 521 | 'selected' => true |
508 | 522 | ); |
509 | - } |
|
510 | - else |
|
523 | + } else |
|
511 | 524 | { |
512 | 525 | $context['board_order'][] = array( |
513 | 526 | 'id' => $boardid, |
@@ -524,19 +537,21 @@ discard block |
||
524 | 537 | $context['can_move_children'] = false; |
525 | 538 | $context['children'] = $boards[$_REQUEST['boardid']]['tree']['children']; |
526 | 539 | |
527 | - foreach ($context['board_order'] as $lBoard) |
|
528 | - if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
540 | + foreach ($context['board_order'] as $lBoard) { |
|
541 | + if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
529 | 542 | $context['can_move_children'] = true; |
543 | + } |
|
530 | 544 | } |
531 | 545 | |
532 | 546 | // Get other available categories. |
533 | 547 | $context['categories'] = array(); |
534 | - foreach ($cat_tree as $catID => $tree) |
|
535 | - $context['categories'][] = array( |
|
548 | + foreach ($cat_tree as $catID => $tree) { |
|
549 | + $context['categories'][] = array( |
|
536 | 550 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
537 | 551 | 'name' => $tree['node']['name'], |
538 | 552 | 'selected' => $catID == $curBoard['category'] |
539 | 553 | ); |
554 | + } |
|
540 | 555 | |
541 | 556 | $request = $smcFunc['db_query']('', ' |
542 | 557 | SELECT mem.id_member, mem.real_name |
@@ -548,14 +563,16 @@ discard block |
||
548 | 563 | ) |
549 | 564 | ); |
550 | 565 | $context['board']['moderators'] = array(); |
551 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
552 | - $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
566 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
567 | + $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
568 | + } |
|
553 | 569 | $smcFunc['db_free_result']($request); |
554 | 570 | |
555 | 571 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
556 | 572 | |
557 | - if (!empty($context['board']['moderators'])) |
|
558 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
573 | + if (!empty($context['board']['moderators'])) { |
|
574 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
575 | + } |
|
559 | 576 | |
560 | 577 | // Get all the groups assigned as moderators |
561 | 578 | $request = $smcFunc['db_query']('', ' |
@@ -567,14 +584,16 @@ discard block |
||
567 | 584 | ) |
568 | 585 | ); |
569 | 586 | $context['board']['moderator_groups'] = array(); |
570 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
571 | - $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
587 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
588 | + $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
589 | + } |
|
572 | 590 | $smcFunc['db_free_result']($request); |
573 | 591 | |
574 | 592 | $context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '"' . implode('", &qout;', $context['board']['moderator_groups']) . '"'; |
575 | 593 | |
576 | - if (!empty($context['board']['moderator_groups'])) |
|
577 | - list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
594 | + if (!empty($context['board']['moderator_groups'])) { |
|
595 | + list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
596 | + } |
|
578 | 597 | |
579 | 598 | // Get all the themes... |
580 | 599 | $request = $smcFunc['db_query']('', ' |
@@ -586,8 +605,9 @@ discard block |
||
586 | 605 | ) |
587 | 606 | ); |
588 | 607 | $context['themes'] = array(); |
589 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
590 | - $context['themes'][] = $row; |
|
608 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
609 | + $context['themes'][] = $row; |
|
610 | + } |
|
591 | 611 | $smcFunc['db_free_result']($request); |
592 | 612 | |
593 | 613 | if (!isset($_REQUEST['delete'])) |
@@ -595,8 +615,7 @@ discard block |
||
595 | 615 | $context['sub_template'] = 'modify_board'; |
596 | 616 | $context['page_title'] = $txt['boardsEdit']; |
597 | 617 | loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest'); |
598 | - } |
|
599 | - else |
|
618 | + } else |
|
600 | 619 | { |
601 | 620 | $context['sub_template'] = 'confirm_board_delete'; |
602 | 621 | $context['page_title'] = $txt['mboards_delete_board']; |
@@ -640,8 +659,9 @@ discard block |
||
640 | 659 | // Change the boardorder of this board? |
641 | 660 | elseif (!empty($_POST['placement']) && !empty($_POST['board_order'])) |
642 | 661 | { |
643 | - if (!in_array($_POST['placement'], array('before', 'after', 'child'))) |
|
644 | - fatal_lang_error('mangled_post', false); |
|
662 | + if (!in_array($_POST['placement'], array('before', 'after', 'child'))) { |
|
663 | + fatal_lang_error('mangled_post', false); |
|
664 | + } |
|
645 | 665 | |
646 | 666 | $boardOptions['move_to'] = $_POST['placement']; |
647 | 667 | $boardOptions['target_board'] = (int) $_POST['board_order']; |
@@ -654,13 +674,14 @@ discard block |
||
654 | 674 | $boardOptions['access_groups'] = array(); |
655 | 675 | $boardOptions['deny_groups'] = array(); |
656 | 676 | |
657 | - if (!empty($_POST['groups'])) |
|
658 | - foreach ($_POST['groups'] as $group => $action) |
|
677 | + if (!empty($_POST['groups'])) { |
|
678 | + foreach ($_POST['groups'] as $group => $action) |
|
659 | 679 | { |
660 | 680 | if ($action == 'allow') |
661 | 681 | $boardOptions['access_groups'][] = (int) $group; |
662 | - elseif ($action == 'deny') |
|
663 | - $boardOptions['deny_groups'][] = (int) $group; |
|
682 | + } elseif ($action == 'deny') { |
|
683 | + $boardOptions['deny_groups'][] = (int) $group; |
|
684 | + } |
|
664 | 685 | } |
665 | 686 | |
666 | 687 | // People with manage-boards are special. |
@@ -672,8 +693,9 @@ discard block |
||
672 | 693 | // Secondly, make sure those with super cow powers (like apt-get, or in this case manage boards) are upgraded. |
673 | 694 | $boardOptions['access_groups'] = array_unique(array_merge($boardOptions['access_groups'], $board_managers)); |
674 | 695 | |
675 | - if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
|
676 | - fatal_lang_error('too_many_groups', false); |
|
696 | + if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) { |
|
697 | + fatal_lang_error('too_many_groups', false); |
|
698 | + } |
|
677 | 699 | |
678 | 700 | // Do not allow HTML tags. Parse the string. |
679 | 701 | $boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']); |
@@ -684,8 +706,9 @@ discard block |
||
684 | 706 | if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list'])) |
685 | 707 | { |
686 | 708 | $moderators = array(); |
687 | - foreach ($_POST['moderator_list'] as $moderator) |
|
688 | - $moderators[(int) $moderator] = (int) $moderator; |
|
709 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
710 | + $moderators[(int) $moderator] = (int) $moderator; |
|
711 | + } |
|
689 | 712 | $boardOptions['moderators'] = $moderators; |
690 | 713 | } |
691 | 714 | |
@@ -694,8 +717,9 @@ discard block |
||
694 | 717 | if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list'])) |
695 | 718 | { |
696 | 719 | $moderator_groups = array(); |
697 | - foreach ($_POST['moderator_group_list'] as $moderator_group) |
|
698 | - $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
720 | + foreach ($_POST['moderator_group_list'] as $moderator_group) { |
|
721 | + $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
722 | + } |
|
699 | 723 | $boardOptions['moderator_groups'] = $moderator_groups; |
700 | 724 | } |
701 | 725 | |
@@ -721,56 +745,62 @@ discard block |
||
721 | 745 | $smcFunc['db_free_result']($request); |
722 | 746 | |
723 | 747 | // If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board. |
724 | - if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) |
|
725 | - unset($boardOptions['redirect']); |
|
748 | + if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) { |
|
749 | + unset($boardOptions['redirect']); |
|
750 | + } |
|
726 | 751 | // Reset the redirection count when switching on/off. |
727 | - elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) |
|
728 | - $boardOptions['num_posts'] = 0; |
|
752 | + elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) { |
|
753 | + $boardOptions['num_posts'] = 0; |
|
754 | + } |
|
729 | 755 | // Resetting the count? |
730 | - elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) |
|
731 | - $boardOptions['num_posts'] = 0; |
|
756 | + elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) { |
|
757 | + $boardOptions['num_posts'] = 0; |
|
758 | + } |
|
732 | 759 | } |
733 | 760 | |
734 | 761 | // Create a new board... |
735 | 762 | if (isset($_POST['add'])) |
736 | 763 | { |
737 | 764 | // New boards by default go to the bottom of the category. |
738 | - if (empty($_POST['new_cat'])) |
|
739 | - $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
740 | - if (!isset($boardOptions['move_to'])) |
|
741 | - $boardOptions['move_to'] = 'bottom'; |
|
765 | + if (empty($_POST['new_cat'])) { |
|
766 | + $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
767 | + } |
|
768 | + if (!isset($boardOptions['move_to'])) { |
|
769 | + $boardOptions['move_to'] = 'bottom'; |
|
770 | + } |
|
742 | 771 | |
743 | 772 | createBoard($boardOptions); |
744 | 773 | } |
745 | 774 | |
746 | 775 | // ...or update an existing board. |
747 | - else |
|
748 | - modifyBoard($_POST['boardid'], $boardOptions); |
|
749 | - } |
|
750 | - elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
776 | + else { |
|
777 | + modifyBoard($_POST['boardid'], $boardOptions); |
|
778 | + } |
|
779 | + } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
751 | 780 | { |
752 | 781 | EditBoard(); |
753 | 782 | return; |
754 | - } |
|
755 | - elseif (isset($_POST['delete'])) |
|
783 | + } elseif (isset($_POST['delete'])) |
|
756 | 784 | { |
757 | 785 | // First off - check if we are moving all the current child boards first - before we start deleting! |
758 | 786 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
759 | 787 | { |
760 | - if (empty($_POST['board_to'])) |
|
761 | - fatal_lang_error('mboards_delete_board_error'); |
|
788 | + if (empty($_POST['board_to'])) { |
|
789 | + fatal_lang_error('mboards_delete_board_error'); |
|
790 | + } |
|
762 | 791 | |
763 | 792 | deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']); |
793 | + } else { |
|
794 | + deleteBoards(array($_POST['boardid']), 0); |
|
764 | 795 | } |
765 | - else |
|
766 | - deleteBoards(array($_POST['boardid']), 0); |
|
767 | 796 | } |
768 | 797 | |
769 | - if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') |
|
770 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
771 | - else |
|
772 | - redirectexit('action=admin;area=manageboards'); |
|
773 | -} |
|
798 | + if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') { |
|
799 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
800 | + } else { |
|
801 | + redirectexit('action=admin;area=manageboards'); |
|
802 | + } |
|
803 | + } |
|
774 | 804 | |
775 | 805 | /** |
776 | 806 | * Used to retrieve data for modifying a board category |
@@ -807,8 +837,9 @@ discard block |
||
807 | 837 | $smcFunc['db_free_result']($request); |
808 | 838 | |
809 | 839 | // This would probably never happen, but just to be sure. |
810 | - if ($cat .= $allowed_sa[1]) |
|
811 | - die(str_replace(',', ' to', $cat)); |
|
840 | + if ($cat .= $allowed_sa[1]) { |
|
841 | + die(str_replace(',', ' to', $cat)); |
|
842 | + } |
|
812 | 843 | |
813 | 844 | redirectexit(); |
814 | 845 | } |
@@ -834,8 +865,9 @@ discard block |
||
834 | 865 | 'empty_string' => '', |
835 | 866 | ) |
836 | 867 | ); |
837 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
838 | - $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
868 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
869 | + $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
870 | + } |
|
839 | 871 | $smcFunc['db_free_result']($request); |
840 | 872 | |
841 | 873 | if (!empty($recycle_boards)) |
@@ -843,13 +875,14 @@ discard block |
||
843 | 875 | require_once($sourcedir . '/Subs-Boards.php'); |
844 | 876 | sortBoards($recycle_boards); |
845 | 877 | $recycle_boards = array('') + $recycle_boards; |
878 | + } else { |
|
879 | + $recycle_boards = array(''); |
|
846 | 880 | } |
847 | - else |
|
848 | - $recycle_boards = array(''); |
|
849 | 881 | |
850 | 882 | // If this setting is missing, set it to 1 |
851 | - if (empty($modSettings['boardindex_max_depth'])) |
|
852 | - $modSettings['boardindex_max_depth'] = 1; |
|
883 | + if (empty($modSettings['boardindex_max_depth'])) { |
|
884 | + $modSettings['boardindex_max_depth'] = 1; |
|
885 | + } |
|
853 | 886 | |
854 | 887 | // Here and the board settings... |
855 | 888 | $config_vars = array( |
@@ -868,8 +901,9 @@ discard block |
||
868 | 901 | |
869 | 902 | call_integration_hook('integrate_modify_board_settings', array(&$config_vars)); |
870 | 903 | |
871 | - if ($return_config) |
|
872 | - return $config_vars; |
|
904 | + if ($return_config) { |
|
905 | + return $config_vars; |
|
906 | + } |
|
873 | 907 | |
874 | 908 | // Needed for the settings template. |
875 | 909 | require_once($sourcedir . '/ManageServer.php'); |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | * @version 2.1 Beta 4 |
18 | 18 | */ |
19 | 19 | |
20 | -if (!defined('SMF')) |
|
20 | +if (!defined('SMF')) { |
|
21 | 21 | die('No direct access...'); |
22 | +} |
|
22 | 23 | |
23 | 24 | /** |
24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
38 | 39 | { |
39 | 40 | $parsed_url = parse_url($boardurl); |
40 | 41 | |
41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | // @todo Set the session cookie path? |
45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
48 | 50 | { |
49 | 51 | // Attempt to end the already-started session. |
50 | - if (ini_get('session.auto_start') == 1) |
|
51 | - session_write_close(); |
|
52 | + if (ini_get('session.auto_start') == 1) { |
|
53 | + session_write_close(); |
|
54 | + } |
|
52 | 55 | |
53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -63,23 +66,26 @@ discard block |
||
63 | 66 | if (!empty($modSettings['databaseSession_enable'])) |
64 | 67 | { |
65 | 68 | @ini_set('session.serialize_handler', 'php_serialize'); |
66 | - if (ini_get('session.serialize_handler') != 'php_serialize') |
|
67 | - @ini_set('session.serialize_handler', 'php'); |
|
69 | + if (ini_get('session.serialize_handler') != 'php_serialize') { |
|
70 | + @ini_set('session.serialize_handler', 'php'); |
|
71 | + } |
|
68 | 72 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
69 | 73 | @ini_set('session.gc_probability', '1'); |
74 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
75 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
70 | 76 | } |
71 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
72 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
73 | 77 | |
74 | 78 | // Use cache setting sessions? |
75 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
76 | - call_integration_hook('integrate_session_handlers'); |
|
79 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
80 | + call_integration_hook('integrate_session_handlers'); |
|
81 | + } |
|
77 | 82 | |
78 | 83 | session_start(); |
79 | 84 | |
80 | 85 | // Change it so the cache settings are a little looser than default. |
81 | - if (!empty($modSettings['databaseSession_loose'])) |
|
82 | - header('cache-control: private'); |
|
86 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
87 | + header('cache-control: private'); |
|
88 | + } |
|
83 | 89 | } |
84 | 90 | |
85 | 91 | // Set the randomly generated code. |
@@ -125,8 +131,9 @@ discard block |
||
125 | 131 | { |
126 | 132 | global $smcFunc; |
127 | 133 | |
128 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
129 | - return ''; |
|
134 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
135 | + return ''; |
|
136 | + } |
|
130 | 137 | |
131 | 138 | // Look for it in the database. |
132 | 139 | $result = $smcFunc['db_query']('', ' |
@@ -156,8 +163,9 @@ discard block |
||
156 | 163 | global $smcFunc, $db_connection, $db_server, $db_name, $db_user, $db_passwd; |
157 | 164 | global $db_prefix, $db_persist, $db_port, $db_mb4; |
158 | 165 | |
159 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
160 | - return false; |
|
166 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
167 | + return false; |
|
168 | + } |
|
161 | 169 | |
162 | 170 | // php < 7.0 need this |
163 | 171 | if (empty($db_connection)) |
@@ -165,11 +173,13 @@ discard block |
||
165 | 173 | $db_options = array(); |
166 | 174 | |
167 | 175 | // Add in the port if needed |
168 | - if (!empty($db_port)) |
|
169 | - $db_options['port'] = $db_port; |
|
176 | + if (!empty($db_port)) { |
|
177 | + $db_options['port'] = $db_port; |
|
178 | + } |
|
170 | 179 | |
171 | - if (!empty($db_mb4)) |
|
172 | - $db_options['db_mb4'] = $db_mb4; |
|
180 | + if (!empty($db_mb4)) { |
|
181 | + $db_options['db_mb4'] = $db_mb4; |
|
182 | + } |
|
173 | 183 | |
174 | 184 | $options = array_merge($db_options, array('persist' => $db_persist, 'dont_select_db' => SMF == 'SSI')); |
175 | 185 | |
@@ -189,13 +199,14 @@ discard block |
||
189 | 199 | ); |
190 | 200 | |
191 | 201 | // If that didn't work, try inserting a new one. |
192 | - if ($smcFunc['db_affected_rows']() == 0) |
|
193 | - $smcFunc['db_insert']('ignore', |
|
202 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
203 | + $smcFunc['db_insert']('ignore', |
|
194 | 204 | '{db_prefix}sessions', |
195 | 205 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
196 | 206 | array($session_id, $data, time()), |
197 | 207 | array('session_id') |
198 | 208 | ); |
209 | + } |
|
199 | 210 | |
200 | 211 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
201 | 212 | } |
@@ -210,8 +221,9 @@ discard block |
||
210 | 221 | { |
211 | 222 | global $smcFunc; |
212 | 223 | |
213 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
214 | - return false; |
|
224 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
225 | + return false; |
|
226 | + } |
|
215 | 227 | |
216 | 228 | // Just delete the row... |
217 | 229 | $smcFunc['db_query']('', ' |
@@ -237,8 +249,9 @@ discard block |
||
237 | 249 | global $modSettings, $smcFunc; |
238 | 250 | |
239 | 251 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
240 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
241 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
252 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
253 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
254 | + } |
|
242 | 255 | |
243 | 256 | // Clean up after yerself ;). |
244 | 257 | $smcFunc['db_query']('', ' |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | |
660 | 660 | // Remove the phrase parts and extract the words. |
661 | 661 | $wordArray = preg_replace('~(?:^|\s)(?:[-]?)"(?:[^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), ' ', $search_params['search']); |
662 | - $wordArray = explode(' ', $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES)); |
|
662 | + $wordArray = explode(' ', $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES)); |
|
663 | 663 | |
664 | 664 | // A minus sign in front of a word excludes the word.... so... |
665 | 665 | $excludedWords = array(); |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | // Are the result fresh? |
998 | 998 | if (!$update_cache && !empty($_SESSION['search_cache']['id_search'])) |
999 | 999 | { |
1000 | - $request = $smcFunc['db_query']('',' |
|
1000 | + $request = $smcFunc['db_query']('', ' |
|
1001 | 1001 | SELECT id_search |
1002 | 1002 | FROM {db_prefix}log_search_results |
1003 | 1003 | WHERE id_search = {int:search_id} |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | SELECT |
1120 | 1120 | {int:id_search}, |
1121 | 1121 | t.id_topic, |
1122 | - ' . $relevance. ', |
|
1122 | + ' . $relevance . ', |
|
1123 | 1123 | ' . (empty($userQuery) ? 't.id_first_msg' : 'm.id_msg') . ', |
1124 | 1124 | 1 |
1125 | 1125 | FROM ' . $subject_query['from'] . (empty($subject_query['inner_join']) ? '' : ' |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | if (empty($subject_query['where'])) |
1353 | 1353 | continue; |
1354 | 1354 | |
1355 | - $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( ' |
|
1355 | + $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? (' |
|
1356 | 1356 | INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics |
1357 | 1357 | (' . ($createTemporary ? '' : 'id_search, ') . 'id_topic)') : '') . ' |
1358 | 1358 | SELECT ' . ($createTemporary ? '' : $_SESSION['search_cache']['id_search'] . ', ') . 't.id_topic |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | } |
1580 | 1580 | $main_query['select']['relevance'] = substr($relevance, 0, -3) . ') / ' . $new_weight_total . ' AS relevance'; |
1581 | 1581 | |
1582 | - $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? ( ' |
|
1582 | + $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? (' |
|
1583 | 1583 | INSERT IGNORE INTO ' . '{db_prefix}log_search_results |
1584 | 1584 | (' . implode(', ', array_keys($main_query['select'])) . ')') : '') . ' |
1585 | 1585 | SELECT |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
1648 | 1648 | |
1649 | 1649 | $usedIDs = array_flip(empty($inserts) ? array() : array_keys($inserts)); |
1650 | - $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? ( ' |
|
1650 | + $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? (' |
|
1651 | 1651 | INSERT IGNORE INTO {db_prefix}log_search_results |
1652 | 1652 | (id_search, id_topic, relevance, id_msg, num_matches)') : '') . ' |
1653 | 1653 | SELECT |
@@ -2116,7 +2116,7 @@ discard block |
||
2116 | 2116 | if (strlen($query) == 0) |
2117 | 2117 | continue; |
2118 | 2118 | |
2119 | - $body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function ($m) |
|
2119 | + $body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function($m) |
|
2120 | 2120 | { |
2121 | 2121 | return isset($m[2]) && "$m[2]" == "$m[1]" ? stripslashes("$m[1]") : "<strong class=\"highlight\">$m[1]</strong>"; |
2122 | 2122 | }, $body_highlighted); |
@@ -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 | // This defines two version types for checking the API's are compatible with this version of SMF. |
20 | 21 | $GLOBALS['search_versions'] = array( |
@@ -39,8 +40,9 @@ discard block |
||
39 | 40 | global $txt, $scripturl, $modSettings, $user_info, $context, $smcFunc, $sourcedir; |
40 | 41 | |
41 | 42 | // Is the load average too high to allow searching just now? |
42 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
43 | - fatal_lang_error('loadavg_search_disabled', false); |
|
43 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
44 | + fatal_lang_error('loadavg_search_disabled', false); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | loadLanguage('Search'); |
46 | 48 | // Don't load this in XML mode. |
@@ -88,23 +90,30 @@ discard block |
||
88 | 90 | @list ($k, $v) = explode('|\'|', $data); |
89 | 91 | $context['search_params'][$k] = $v; |
90 | 92 | } |
91 | - if (isset($context['search_params']['brd'])) |
|
92 | - $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']); |
|
93 | + if (isset($context['search_params']['brd'])) { |
|
94 | + $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']); |
|
95 | + } |
|
93 | 96 | } |
94 | 97 | |
95 | - if (isset($_REQUEST['search'])) |
|
96 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
98 | + if (isset($_REQUEST['search'])) { |
|
99 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
100 | + } |
|
97 | 101 | |
98 | - if (isset($context['search_params']['search'])) |
|
99 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
100 | - if (isset($context['search_params']['userspec'])) |
|
101 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
102 | - if (!empty($context['search_params']['searchtype'])) |
|
103 | - $context['search_params']['searchtype'] = 2; |
|
104 | - if (!empty($context['search_params']['minage'])) |
|
105 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
106 | - if (!empty($context['search_params']['maxage'])) |
|
107 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
102 | + if (isset($context['search_params']['search'])) { |
|
103 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
104 | + } |
|
105 | + if (isset($context['search_params']['userspec'])) { |
|
106 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
107 | + } |
|
108 | + if (!empty($context['search_params']['searchtype'])) { |
|
109 | + $context['search_params']['searchtype'] = 2; |
|
110 | + } |
|
111 | + if (!empty($context['search_params']['minage'])) { |
|
112 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
113 | + } |
|
114 | + if (!empty($context['search_params']['maxage'])) { |
|
115 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
116 | + } |
|
108 | 117 | |
109 | 118 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
110 | 119 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
@@ -116,11 +125,13 @@ discard block |
||
116 | 125 | $context['search_errors']['messages'] = array(); |
117 | 126 | foreach ($context['search_errors'] as $search_error => $dummy) |
118 | 127 | { |
119 | - if ($search_error === 'messages') |
|
120 | - continue; |
|
128 | + if ($search_error === 'messages') { |
|
129 | + continue; |
|
130 | + } |
|
121 | 131 | |
122 | - if ($search_error == 'string_too_long') |
|
123 | - $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
132 | + if ($search_error == 'string_too_long') { |
|
133 | + $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
134 | + } |
|
124 | 135 | |
125 | 136 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
126 | 137 | } |
@@ -143,12 +154,13 @@ discard block |
||
143 | 154 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
144 | 155 | { |
145 | 156 | // This category hasn't been set up yet.. |
146 | - if (!isset($context['categories'][$row['id_cat']])) |
|
147 | - $context['categories'][$row['id_cat']] = array( |
|
157 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
158 | + $context['categories'][$row['id_cat']] = array( |
|
148 | 159 | 'id' => $row['id_cat'], |
149 | 160 | 'name' => $row['cat_name'], |
150 | 161 | 'boards' => array() |
151 | 162 | ); |
163 | + } |
|
152 | 164 | |
153 | 165 | // Set this board up, and let the template know when it's a child. (indent them..) |
154 | 166 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -159,8 +171,9 @@ discard block |
||
159 | 171 | ); |
160 | 172 | |
161 | 173 | // If a board wasn't checked that probably should have been ensure the board selection is selected, yo! |
162 | - if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) |
|
163 | - $context['boards_check_all'] = false; |
|
174 | + if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) { |
|
175 | + $context['boards_check_all'] = false; |
|
176 | + } |
|
164 | 177 | } |
165 | 178 | $smcFunc['db_free_result']($request); |
166 | 179 | |
@@ -182,18 +195,20 @@ discard block |
||
182 | 195 | } |
183 | 196 | |
184 | 197 | $max_boards = ceil(count($temp_boards) / 2); |
185 | - if ($max_boards == 1) |
|
186 | - $max_boards = 2; |
|
198 | + if ($max_boards == 1) { |
|
199 | + $max_boards = 2; |
|
200 | + } |
|
187 | 201 | |
188 | 202 | // Now, alternate them so they can be shown left and right ;). |
189 | 203 | $context['board_columns'] = array(); |
190 | 204 | for ($i = 0; $i < $max_boards; $i++) |
191 | 205 | { |
192 | 206 | $context['board_columns'][] = $temp_boards[$i]; |
193 | - if (isset($temp_boards[$i + $max_boards])) |
|
194 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
195 | - else |
|
196 | - $context['board_columns'][] = array(); |
|
207 | + if (isset($temp_boards[$i + $max_boards])) { |
|
208 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
209 | + } else { |
|
210 | + $context['board_columns'][] = array(); |
|
211 | + } |
|
197 | 212 | } |
198 | 213 | |
199 | 214 | if (!empty($_REQUEST['topic'])) |
@@ -225,8 +240,9 @@ discard block |
||
225 | 240 | ) |
226 | 241 | ); |
227 | 242 | |
228 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
229 | - fatal_lang_error('topic_gone', false); |
|
243 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
244 | + fatal_lang_error('topic_gone', false); |
|
245 | + } |
|
230 | 246 | |
231 | 247 | list ($context['search_topic']['subject']) = $smcFunc['db_fetch_row']($request); |
232 | 248 | $smcFunc['db_free_result']($request); |
@@ -256,11 +272,13 @@ discard block |
||
256 | 272 | global $excludedWords, $participants, $smcFunc; |
257 | 273 | |
258 | 274 | // if comming from the quick search box, and we want to search on members, well we need to do that ;) |
259 | - if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') |
|
260 | - redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search'])); |
|
275 | + if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') { |
|
276 | + redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search'])); |
|
277 | + } |
|
261 | 278 | |
262 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
263 | - fatal_lang_error('loadavg_search_disabled', false); |
|
279 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
280 | + fatal_lang_error('loadavg_search_disabled', false); |
|
281 | + } |
|
264 | 282 | |
265 | 283 | // No, no, no... this is a bit hard on the server, so don't you go prefetching it! |
266 | 284 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -307,8 +325,9 @@ discard block |
||
307 | 325 | } |
308 | 326 | |
309 | 327 | // Zero weight. Weightless :P. |
310 | - if (empty($weight_total)) |
|
311 | - fatal_lang_error('search_invalid_weights'); |
|
328 | + if (empty($weight_total)) { |
|
329 | + fatal_lang_error('search_invalid_weights'); |
|
330 | + } |
|
312 | 331 | |
313 | 332 | // These vars don't require an interface, they're just here for tweaking. |
314 | 333 | $recentPercentage = 0.30; |
@@ -326,11 +345,13 @@ discard block |
||
326 | 345 | $context['search_string_limit'] = 100; |
327 | 346 | |
328 | 347 | loadLanguage('Search'); |
329 | - if (!isset($_REQUEST['xml'])) |
|
330 | - loadTemplate('Search'); |
|
348 | + if (!isset($_REQUEST['xml'])) { |
|
349 | + loadTemplate('Search'); |
|
350 | + } |
|
331 | 351 | //If we're doing XML we need to use the results template regardless really. |
332 | - else |
|
333 | - $context['sub_template'] = 'results'; |
|
352 | + else { |
|
353 | + $context['sub_template'] = 'results'; |
|
354 | + } |
|
334 | 355 | |
335 | 356 | // Are you allowed? |
336 | 357 | isAllowedTo('search_posts'); |
@@ -363,34 +384,39 @@ discard block |
||
363 | 384 | $search_params[$k] = $v; |
364 | 385 | } |
365 | 386 | |
366 | - if (isset($search_params['brd'])) |
|
367 | - $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']); |
|
387 | + if (isset($search_params['brd'])) { |
|
388 | + $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']); |
|
389 | + } |
|
368 | 390 | } |
369 | 391 | |
370 | 392 | // Store whether simple search was used (needed if the user wants to do another query). |
371 | - if (!isset($search_params['advanced'])) |
|
372 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
393 | + if (!isset($search_params['advanced'])) { |
|
394 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
395 | + } |
|
373 | 396 | |
374 | 397 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
375 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
376 | - $search_params['searchtype'] = 2; |
|
398 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
399 | + $search_params['searchtype'] = 2; |
|
400 | + } |
|
377 | 401 | |
378 | 402 | // Minimum age of messages. Default to zero (don't set param in that case). |
379 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
380 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
403 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
404 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
405 | + } |
|
381 | 406 | |
382 | 407 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
383 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) |
|
384 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
408 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) { |
|
409 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
410 | + } |
|
385 | 411 | |
386 | 412 | // Searching a specific topic? |
387 | 413 | if (!empty($_REQUEST['topic']) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'topic')) |
388 | 414 | { |
389 | 415 | $search_params['topic'] = empty($_REQUEST['search_selection']) ? (int) $_REQUEST['topic'] : (isset($_REQUEST['sd_topic']) ? (int) $_REQUEST['sd_topic'] : ''); |
390 | 416 | $search_params['show_complete'] = true; |
417 | + } elseif (!empty($search_params['topic'])) { |
|
418 | + $search_params['topic'] = (int) $search_params['topic']; |
|
391 | 419 | } |
392 | - elseif (!empty($search_params['topic'])) |
|
393 | - $search_params['topic'] = (int) $search_params['topic']; |
|
394 | 420 | |
395 | 421 | if (!empty($search_params['minage']) || !empty($search_params['maxage'])) |
396 | 422 | { |
@@ -408,19 +434,21 @@ discard block |
||
408 | 434 | ) |
409 | 435 | ); |
410 | 436 | list ($minMsgID, $maxMsgID) = $smcFunc['db_fetch_row']($request); |
411 | - if ($minMsgID < 0 || $maxMsgID < 0) |
|
412 | - $context['search_errors']['no_messages_in_time_frame'] = true; |
|
437 | + if ($minMsgID < 0 || $maxMsgID < 0) { |
|
438 | + $context['search_errors']['no_messages_in_time_frame'] = true; |
|
439 | + } |
|
413 | 440 | $smcFunc['db_free_result']($request); |
414 | 441 | } |
415 | 442 | |
416 | 443 | // Default the user name to a wildcard matching every user (*). |
417 | - if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
418 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
444 | + if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
445 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
446 | + } |
|
419 | 447 | |
420 | 448 | // If there's no specific user, then don't mention it in the main query. |
421 | - if (empty($search_params['userspec'])) |
|
422 | - $userQuery = ''; |
|
423 | - else |
|
449 | + if (empty($search_params['userspec'])) { |
|
450 | + $userQuery = ''; |
|
451 | + } else |
|
424 | 452 | { |
425 | 453 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
426 | 454 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -432,19 +460,21 @@ discard block |
||
432 | 460 | { |
433 | 461 | $possible_users[$k] = trim($possible_users[$k]); |
434 | 462 | |
435 | - if (strlen($possible_users[$k]) == 0) |
|
436 | - unset($possible_users[$k]); |
|
463 | + if (strlen($possible_users[$k]) == 0) { |
|
464 | + unset($possible_users[$k]); |
|
465 | + } |
|
437 | 466 | } |
438 | 467 | |
439 | 468 | // Create a list of database-escaped search names. |
440 | 469 | $realNameMatches = array(); |
441 | - foreach ($possible_users as $possible_user) |
|
442 | - $realNameMatches[] = $smcFunc['db_quote']( |
|
470 | + foreach ($possible_users as $possible_user) { |
|
471 | + $realNameMatches[] = $smcFunc['db_quote']( |
|
443 | 472 | '{string:possible_user}', |
444 | 473 | array( |
445 | 474 | 'possible_user' => $possible_user |
446 | 475 | ) |
447 | 476 | ); |
477 | + } |
|
448 | 478 | |
449 | 479 | // Retrieve a list of possible members. |
450 | 480 | $request = $smcFunc['db_query']('', ' |
@@ -456,9 +486,9 @@ discard block |
||
456 | 486 | ) |
457 | 487 | ); |
458 | 488 | // Simply do nothing if there're too many members matching the criteria. |
459 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
460 | - $userQuery = ''; |
|
461 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
489 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
490 | + $userQuery = ''; |
|
491 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
462 | 492 | { |
463 | 493 | $userQuery = $smcFunc['db_quote']( |
464 | 494 | 'm.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})', |
@@ -467,12 +497,12 @@ discard block |
||
467 | 497 | 'match_possible_guest_names' => 'm.poster_name LIKE ' . implode(' OR m.poster_name LIKE ', $realNameMatches), |
468 | 498 | ) |
469 | 499 | ); |
470 | - } |
|
471 | - else |
|
500 | + } else |
|
472 | 501 | { |
473 | 502 | $memberlist = array(); |
474 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
475 | - $memberlist[] = $row['id_member']; |
|
503 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
504 | + $memberlist[] = $row['id_member']; |
|
505 | + } |
|
476 | 506 | $userQuery = $smcFunc['db_quote']( |
477 | 507 | '(m.id_member IN ({array_int:matched_members}) OR (m.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})))', |
478 | 508 | array( |
@@ -486,22 +516,25 @@ discard block |
||
486 | 516 | } |
487 | 517 | |
488 | 518 | // If the boards were passed by URL (params=), temporarily put them back in $_REQUEST. |
489 | - if (!empty($search_params['brd']) && is_array($search_params['brd'])) |
|
490 | - $_REQUEST['brd'] = $search_params['brd']; |
|
519 | + if (!empty($search_params['brd']) && is_array($search_params['brd'])) { |
|
520 | + $_REQUEST['brd'] = $search_params['brd']; |
|
521 | + } |
|
491 | 522 | |
492 | 523 | // Ensure that brd is an array. |
493 | 524 | if ((!empty($_REQUEST['brd']) && !is_array($_REQUEST['brd'])) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'board')) |
494 | 525 | { |
495 | - if (!empty($_REQUEST['brd'])) |
|
496 | - $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']); |
|
497 | - else |
|
498 | - $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array(); |
|
526 | + if (!empty($_REQUEST['brd'])) { |
|
527 | + $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']); |
|
528 | + } else { |
|
529 | + $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array(); |
|
530 | + } |
|
499 | 531 | } |
500 | 532 | |
501 | 533 | // Make sure all boards are integers. |
502 | - if (!empty($_REQUEST['brd'])) |
|
503 | - foreach ($_REQUEST['brd'] as $id => $brd) |
|
534 | + if (!empty($_REQUEST['brd'])) { |
|
535 | + foreach ($_REQUEST['brd'] as $id => $brd) |
|
504 | 536 | $_REQUEST['brd'][$id] = (int) $brd; |
537 | + } |
|
505 | 538 | |
506 | 539 | // Special case for boards: searching just one topic? |
507 | 540 | if (!empty($search_params['topic'])) |
@@ -520,17 +553,18 @@ discard block |
||
520 | 553 | ) |
521 | 554 | ); |
522 | 555 | |
523 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
524 | - fatal_lang_error('topic_gone', false); |
|
556 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
557 | + fatal_lang_error('topic_gone', false); |
|
558 | + } |
|
525 | 559 | |
526 | 560 | $search_params['brd'] = array(); |
527 | 561 | list ($search_params['brd'][0]) = $smcFunc['db_fetch_row']($request); |
528 | 562 | $smcFunc['db_free_result']($request); |
529 | 563 | } |
530 | 564 | // Select all boards you've selected AND are allowed to see. |
531 | - elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) |
|
532 | - $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd']; |
|
533 | - else |
|
565 | + elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) { |
|
566 | + $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd']; |
|
567 | + } else |
|
534 | 568 | { |
535 | 569 | $see_board = empty($search_params['advanced']) ? 'query_wanna_see_board' : 'query_see_board'; |
536 | 570 | $request = $smcFunc['db_query']('', ' |
@@ -548,19 +582,22 @@ discard block |
||
548 | 582 | ) |
549 | 583 | ); |
550 | 584 | $search_params['brd'] = array(); |
551 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
552 | - $search_params['brd'][] = $row['id_board']; |
|
585 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
586 | + $search_params['brd'][] = $row['id_board']; |
|
587 | + } |
|
553 | 588 | $smcFunc['db_free_result']($request); |
554 | 589 | |
555 | 590 | // This error should pro'bly only happen for hackers. |
556 | - if (empty($search_params['brd'])) |
|
557 | - $context['search_errors']['no_boards_selected'] = true; |
|
591 | + if (empty($search_params['brd'])) { |
|
592 | + $context['search_errors']['no_boards_selected'] = true; |
|
593 | + } |
|
558 | 594 | } |
559 | 595 | |
560 | 596 | if (count($search_params['brd']) != 0) |
561 | 597 | { |
562 | - foreach ($search_params['brd'] as $k => $v) |
|
563 | - $search_params['brd'][$k] = (int) $v; |
|
598 | + foreach ($search_params['brd'] as $k => $v) { |
|
599 | + $search_params['brd'][$k] = (int) $v; |
|
600 | + } |
|
564 | 601 | |
565 | 602 | // If we've selected all boards, this parameter can be left empty. |
566 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -574,15 +611,16 @@ discard block |
||
574 | 611 | list ($num_boards) = $smcFunc['db_fetch_row']($request); |
575 | 612 | $smcFunc['db_free_result']($request); |
576 | 613 | |
577 | - if (count($search_params['brd']) == $num_boards) |
|
614 | + if (count($search_params['brd']) == $num_boards) { |
|
615 | + $boardQuery = ''; |
|
616 | + } elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) { |
|
617 | + $boardQuery = '!= ' . $modSettings['recycle_board']; |
|
618 | + } else { |
|
619 | + $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')'; |
|
620 | + } |
|
621 | + } else { |
|
578 | 622 | $boardQuery = ''; |
579 | - elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) |
|
580 | - $boardQuery = '!= ' . $modSettings['recycle_board']; |
|
581 | - else |
|
582 | - $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')'; |
|
583 | 623 | } |
584 | - else |
|
585 | - $boardQuery = ''; |
|
586 | 624 | |
587 | 625 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
588 | 626 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
@@ -596,11 +634,13 @@ discard block |
||
596 | 634 | 'id_msg', |
597 | 635 | ); |
598 | 636 | call_integration_hook('integrate_search_sort_columns', array(&$sort_columns)); |
599 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
600 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
637 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
638 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
639 | + } |
|
601 | 640 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'relevance'; |
602 | - if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') |
|
603 | - $search_params['sort'] = 'id_msg'; |
|
641 | + if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') { |
|
642 | + $search_params['sort'] = 'id_msg'; |
|
643 | + } |
|
604 | 644 | |
605 | 645 | // Sorting direction: descending unless stated otherwise. |
606 | 646 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
@@ -624,17 +664,19 @@ discard block |
||
624 | 664 | // What are we searching for? |
625 | 665 | if (empty($search_params['search'])) |
626 | 666 | { |
627 | - if (isset($_GET['search'])) |
|
628 | - $search_params['search'] = un_htmlspecialchars($_GET['search']); |
|
629 | - elseif (isset($_POST['search'])) |
|
630 | - $search_params['search'] = $_POST['search']; |
|
631 | - else |
|
632 | - $search_params['search'] = ''; |
|
667 | + if (isset($_GET['search'])) { |
|
668 | + $search_params['search'] = un_htmlspecialchars($_GET['search']); |
|
669 | + } elseif (isset($_POST['search'])) { |
|
670 | + $search_params['search'] = $_POST['search']; |
|
671 | + } else { |
|
672 | + $search_params['search'] = ''; |
|
673 | + } |
|
633 | 674 | } |
634 | 675 | |
635 | 676 | // Nothing?? |
636 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
637 | - $context['search_errors']['invalid_search_string'] = true; |
|
677 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
678 | + $context['search_errors']['invalid_search_string'] = true; |
|
679 | + } |
|
638 | 680 | // Too long? |
639 | 681 | elseif ($smcFunc['strlen']($search_params['search']) > $context['search_string_limit']) |
640 | 682 | { |
@@ -648,8 +690,9 @@ discard block |
||
648 | 690 | $stripped_query = un_htmlspecialchars($smcFunc['strtolower']($stripped_query)); |
649 | 691 | |
650 | 692 | // This (hidden) setting will do fulltext searching in the most basic way. |
651 | - if (!empty($modSettings['search_simple_fulltext'])) |
|
652 | - $stripped_query = strtr($stripped_query, array('"' => '')); |
|
693 | + if (!empty($modSettings['search_simple_fulltext'])) { |
|
694 | + $stripped_query = strtr($stripped_query, array('"' => '')); |
|
695 | + } |
|
653 | 696 | |
654 | 697 | $no_regexp = preg_match('~&#(?:\d{1,7}|x[0-9a-fA-F]{1,6});~', $stripped_query) === 1; |
655 | 698 | |
@@ -672,8 +715,9 @@ discard block |
||
672 | 715 | { |
673 | 716 | if ($word === '-') |
674 | 717 | { |
675 | - if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) |
|
676 | - $excludedWords[] = $word; |
|
718 | + if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) { |
|
719 | + $excludedWords[] = $word; |
|
720 | + } |
|
677 | 721 | unset($phraseArray[$index]); |
678 | 722 | } |
679 | 723 | } |
@@ -683,8 +727,9 @@ discard block |
||
683 | 727 | { |
684 | 728 | if (strpos(trim($word), '-') === 0) |
685 | 729 | { |
686 | - if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) |
|
687 | - $excludedWords[] = $word; |
|
730 | + if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) { |
|
731 | + $excludedWords[] = $word; |
|
732 | + } |
|
688 | 733 | unset($wordArray[$index]); |
689 | 734 | } |
690 | 735 | } |
@@ -697,8 +742,9 @@ discard block |
||
697 | 742 | foreach ($searchArray as $index => $value) |
698 | 743 | { |
699 | 744 | // Skip anything practically empty. |
700 | - if (($searchArray[$index] = trim($value, '-_\' ')) === '') |
|
701 | - unset($searchArray[$index]); |
|
745 | + if (($searchArray[$index] = trim($value, '-_\' ')) === '') { |
|
746 | + unset($searchArray[$index]); |
|
747 | + } |
|
702 | 748 | // Skip blacklisted words. Make sure to note we skipped them in case we end up with nothing. |
703 | 749 | elseif (in_array($searchArray[$index], $blacklisted_words)) |
704 | 750 | { |
@@ -716,31 +762,37 @@ discard block |
||
716 | 762 | |
717 | 763 | // Create an array of replacements for highlighting. |
718 | 764 | $context['mark'] = array(); |
719 | - foreach ($searchArray as $word) |
|
720 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
765 | + foreach ($searchArray as $word) { |
|
766 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
767 | + } |
|
721 | 768 | |
722 | 769 | // Initialize two arrays storing the words that have to be searched for. |
723 | 770 | $orParts = array(); |
724 | 771 | $searchWords = array(); |
725 | 772 | |
726 | 773 | // Make sure at least one word is being searched for. |
727 | - if (empty($searchArray)) |
|
728 | - $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
774 | + if (empty($searchArray)) { |
|
775 | + $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
776 | + } |
|
729 | 777 | // All words/sentences must match. |
730 | - elseif (empty($search_params['searchtype'])) |
|
731 | - $orParts[0] = $searchArray; |
|
778 | + elseif (empty($search_params['searchtype'])) { |
|
779 | + $orParts[0] = $searchArray; |
|
780 | + } |
|
732 | 781 | // Any word/sentence must match. |
733 | - else |
|
734 | - foreach ($searchArray as $index => $value) |
|
782 | + else { |
|
783 | + foreach ($searchArray as $index => $value) |
|
735 | 784 | $orParts[$index] = array($value); |
785 | + } |
|
736 | 786 | |
737 | 787 | // Don't allow duplicate error messages if one string is too short. |
738 | - if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) |
|
739 | - unset($context['search_errors']['invalid_search_string']); |
|
788 | + if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) { |
|
789 | + unset($context['search_errors']['invalid_search_string']); |
|
790 | + } |
|
740 | 791 | // Make sure the excluded words are in all or-branches. |
741 | - foreach ($orParts as $orIndex => $andParts) |
|
742 | - foreach ($excludedWords as $word) |
|
792 | + foreach ($orParts as $orIndex => $andParts) { |
|
793 | + foreach ($excludedWords as $word) |
|
743 | 794 | $orParts[$orIndex][] = $word; |
795 | + } |
|
744 | 796 | |
745 | 797 | // Determine the or-branches and the fulltext search words. |
746 | 798 | foreach ($orParts as $orIndex => $andParts) |
@@ -754,8 +806,9 @@ discard block |
||
754 | 806 | ); |
755 | 807 | |
756 | 808 | // Sort the indexed words (large words -> small words -> excluded words). |
757 | - if ($searchAPI->supportsMethod('searchSort')) |
|
758 | - usort($orParts[$orIndex], 'searchSort'); |
|
809 | + if ($searchAPI->supportsMethod('searchSort')) { |
|
810 | + usort($orParts[$orIndex], 'searchSort'); |
|
811 | + } |
|
759 | 812 | |
760 | 813 | foreach ($orParts[$orIndex] as $word) |
761 | 814 | { |
@@ -767,15 +820,17 @@ discard block |
||
767 | 820 | if (!$is_excluded || count($subjectWords) === 1) |
768 | 821 | { |
769 | 822 | $searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords); |
770 | - if ($is_excluded) |
|
771 | - $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
823 | + if ($is_excluded) { |
|
824 | + $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
825 | + } |
|
826 | + } else { |
|
827 | + $excludedPhrases[] = $word; |
|
772 | 828 | } |
773 | - else |
|
774 | - $excludedPhrases[] = $word; |
|
775 | 829 | |
776 | 830 | // Have we got indexes to prepare? |
777 | - if ($searchAPI->supportsMethod('prepareIndexes')) |
|
778 | - $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
831 | + if ($searchAPI->supportsMethod('prepareIndexes')) { |
|
832 | + $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
833 | + } |
|
779 | 834 | } |
780 | 835 | |
781 | 836 | // Search_force_index requires all AND parts to have at least one fulltext word. |
@@ -783,8 +838,7 @@ discard block |
||
783 | 838 | { |
784 | 839 | $context['search_errors']['query_not_specific_enough'] = true; |
785 | 840 | break; |
786 | - } |
|
787 | - elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
841 | + } elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
788 | 842 | { |
789 | 843 | $context['search_errors']['query_not_specific_enough'] = true; |
790 | 844 | break; |
@@ -812,8 +866,9 @@ discard block |
||
812 | 866 | $found_misspelling = false; |
813 | 867 | foreach ($searchArray as $word) |
814 | 868 | { |
815 | - if (empty($link)) |
|
816 | - continue; |
|
869 | + if (empty($link)) { |
|
870 | + continue; |
|
871 | + } |
|
817 | 872 | |
818 | 873 | // Don't check phrases. |
819 | 874 | if (preg_match('~^\w+$~', $word) === 0) |
@@ -828,8 +883,7 @@ discard block |
||
828 | 883 | $did_you_mean['search'][] = $word; |
829 | 884 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
830 | 885 | continue; |
831 | - } |
|
832 | - elseif (spell_check($link, $word)) |
|
886 | + } elseif (spell_check($link, $word)) |
|
833 | 887 | { |
834 | 888 | $did_you_mean['search'][] = $word; |
835 | 889 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -840,11 +894,13 @@ discard block |
||
840 | 894 | foreach ($suggestions as $i => $s) |
841 | 895 | { |
842 | 896 | // Search is case insensitive. |
843 | - if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) |
|
844 | - unset($suggestions[$i]); |
|
897 | + if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) { |
|
898 | + unset($suggestions[$i]); |
|
899 | + } |
|
845 | 900 | // Plus, don't suggest something the user thinks is rude! |
846 | - elseif ($suggestions[$i] != censorText($s)) |
|
847 | - unset($suggestions[$i]); |
|
901 | + elseif ($suggestions[$i] != censorText($s)) { |
|
902 | + unset($suggestions[$i]); |
|
903 | + } |
|
848 | 904 | } |
849 | 905 | |
850 | 906 | // Anything found? If so, correct it! |
@@ -854,8 +910,7 @@ discard block |
||
854 | 910 | $did_you_mean['search'][] = $suggestions[0]; |
855 | 911 | $did_you_mean['display'][] = '<em><strong>' . $smcFunc['htmlspecialchars']($suggestions[0]) . '</strong></em>'; |
856 | 912 | $found_misspelling = true; |
857 | - } |
|
858 | - else |
|
913 | + } else |
|
859 | 914 | { |
860 | 915 | $did_you_mean['search'][] = $word; |
861 | 916 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -872,8 +927,7 @@ discard block |
||
872 | 927 | { |
873 | 928 | $temp_excluded['search'][] = '-"' . $word . '"'; |
874 | 929 | $temp_excluded['display'][] = '-"' . $smcFunc['htmlspecialchars']($word) . '"'; |
875 | - } |
|
876 | - else |
|
930 | + } else |
|
877 | 931 | { |
878 | 932 | $temp_excluded['search'][] = '-' . $word; |
879 | 933 | $temp_excluded['display'][] = '-' . $smcFunc['htmlspecialchars']($word); |
@@ -885,11 +939,13 @@ discard block |
||
885 | 939 | |
886 | 940 | $temp_params = $search_params; |
887 | 941 | $temp_params['search'] = implode(' ', $did_you_mean['search']); |
888 | - if (isset($temp_params['brd'])) |
|
889 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
942 | + if (isset($temp_params['brd'])) { |
|
943 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
944 | + } |
|
890 | 945 | $context['params'] = array(); |
891 | - foreach ($temp_params as $k => $v) |
|
892 | - $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
946 | + foreach ($temp_params as $k => $v) { |
|
947 | + $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
948 | + } |
|
893 | 949 | $context['did_you_mean_params'] = base64_encode(implode('|"|', $context['did_you_mean_params'])); |
894 | 950 | $context['did_you_mean'] = implode(' ', $did_you_mean['display']); |
895 | 951 | } |
@@ -897,18 +953,20 @@ discard block |
||
897 | 953 | |
898 | 954 | // Let the user adjust the search query, should they wish? |
899 | 955 | $context['search_params'] = $search_params; |
900 | - if (isset($context['search_params']['search'])) |
|
901 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
902 | - if (isset($context['search_params']['userspec'])) |
|
903 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
956 | + if (isset($context['search_params']['search'])) { |
|
957 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
958 | + } |
|
959 | + if (isset($context['search_params']['userspec'])) { |
|
960 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
961 | + } |
|
904 | 962 | |
905 | 963 | // Do we have captcha enabled? |
906 | 964 | if ($user_info['is_guest'] && !empty($modSettings['search_enable_captcha']) && empty($_SESSION['ss_vv_passed']) && (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search'])) |
907 | 965 | { |
908 | 966 | // If we come from another search box tone down the error... |
909 | - if (!isset($_REQUEST['search_vv'])) |
|
910 | - $context['search_errors']['need_verification_code'] = true; |
|
911 | - else |
|
967 | + if (!isset($_REQUEST['search_vv'])) { |
|
968 | + $context['search_errors']['need_verification_code'] = true; |
|
969 | + } else |
|
912 | 970 | { |
913 | 971 | require_once($sourcedir . '/Subs-Editor.php'); |
914 | 972 | $verificationOptions = array( |
@@ -918,12 +976,14 @@ discard block |
||
918 | 976 | |
919 | 977 | if (is_array($context['require_verification'])) |
920 | 978 | { |
921 | - foreach ($context['require_verification'] as $error) |
|
922 | - $context['search_errors'][$error] = true; |
|
979 | + foreach ($context['require_verification'] as $error) { |
|
980 | + $context['search_errors'][$error] = true; |
|
981 | + } |
|
923 | 982 | } |
924 | 983 | // Don't keep asking for it - they've proven themselves worthy. |
925 | - else |
|
926 | - $_SESSION['ss_vv_passed'] = true; |
|
984 | + else { |
|
985 | + $_SESSION['ss_vv_passed'] = true; |
|
986 | + } |
|
927 | 987 | } |
928 | 988 | } |
929 | 989 | |
@@ -931,19 +991,22 @@ discard block |
||
931 | 991 | |
932 | 992 | // All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below. |
933 | 993 | $temp_params = $search_params; |
934 | - if (isset($temp_params['brd'])) |
|
935 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
994 | + if (isset($temp_params['brd'])) { |
|
995 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
996 | + } |
|
936 | 997 | $context['params'] = array(); |
937 | - foreach ($temp_params as $k => $v) |
|
938 | - $context['params'][] = $k . '|\'|' . $v; |
|
998 | + foreach ($temp_params as $k => $v) { |
|
999 | + $context['params'][] = $k . '|\'|' . $v; |
|
1000 | + } |
|
939 | 1001 | |
940 | 1002 | if (!empty($context['params'])) |
941 | 1003 | { |
942 | 1004 | // Due to old IE's 2083 character limit, we have to compress long search strings |
943 | 1005 | $params = @gzcompress(implode('|"|', $context['params'])); |
944 | 1006 | // Gzcompress failed, use try non-gz |
945 | - if (empty($params)) |
|
946 | - $params = implode('|"|', $context['params']); |
|
1007 | + if (empty($params)) { |
|
1008 | + $params = implode('|"|', $context['params']); |
|
1009 | + } |
|
947 | 1010 | // Base64 encode, then replace +/= with uri safe ones that can be reverted |
948 | 1011 | $context['params'] = str_replace(array('+', '/', '='), array('-', '_', '.'), base64_encode($params)); |
949 | 1012 | } |
@@ -969,8 +1032,9 @@ discard block |
||
969 | 1032 | } |
970 | 1033 | |
971 | 1034 | // Spam me not, Spam-a-lot? |
972 | - if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) |
|
973 | - spamProtection('search'); |
|
1035 | + if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) { |
|
1036 | + spamProtection('search'); |
|
1037 | + } |
|
974 | 1038 | // Store the last search string to allow pages of results to be browsed. |
975 | 1039 | $_SESSION['last_ss'] = $search_params['search']; |
976 | 1040 | |
@@ -1007,8 +1071,9 @@ discard block |
||
1007 | 1071 | ) |
1008 | 1072 | ); |
1009 | 1073 | |
1010 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1011 | - $update_cache = true; |
|
1074 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1075 | + $update_cache = true; |
|
1076 | + } |
|
1012 | 1077 | } |
1013 | 1078 | |
1014 | 1079 | if ($update_cache) |
@@ -1047,8 +1112,9 @@ discard block |
||
1047 | 1112 | 'where' => array(), |
1048 | 1113 | ); |
1049 | 1114 | |
1050 | - if ($modSettings['postmod_active']) |
|
1051 | - $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
1115 | + if ($modSettings['postmod_active']) { |
|
1116 | + $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
1117 | + } |
|
1052 | 1118 | |
1053 | 1119 | $numTables = 0; |
1054 | 1120 | $prev_join = 0; |
@@ -1060,8 +1126,7 @@ discard block |
||
1060 | 1126 | { |
1061 | 1127 | $subject_query['left_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}') . ' AND subj' . $numTables . '.id_topic = t.id_topic)'; |
1062 | 1128 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
1063 | - } |
|
1064 | - else |
|
1129 | + } else |
|
1065 | 1130 | { |
1066 | 1131 | $subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)'; |
1067 | 1132 | $subject_query['where'][] = 'subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}'); |
@@ -1079,14 +1144,18 @@ discard block |
||
1079 | 1144 | } |
1080 | 1145 | $subject_query['where'][] = $userQuery; |
1081 | 1146 | } |
1082 | - if (!empty($search_params['topic'])) |
|
1083 | - $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
1084 | - if (!empty($minMsgID)) |
|
1085 | - $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
1086 | - if (!empty($maxMsgID)) |
|
1087 | - $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
1088 | - if (!empty($boardQuery)) |
|
1089 | - $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
1147 | + if (!empty($search_params['topic'])) { |
|
1148 | + $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
1149 | + } |
|
1150 | + if (!empty($minMsgID)) { |
|
1151 | + $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
1152 | + } |
|
1153 | + if (!empty($maxMsgID)) { |
|
1154 | + $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
1155 | + } |
|
1156 | + if (!empty($boardQuery)) { |
|
1157 | + $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
1158 | + } |
|
1090 | 1159 | if (!empty($excludedPhrases)) |
1091 | 1160 | { |
1092 | 1161 | if ($subject_query['from'] != '{db_prefix}messages AS m') |
@@ -1106,8 +1175,9 @@ discard block |
||
1106 | 1175 | foreach ($weight_factors as $type => $value) |
1107 | 1176 | { |
1108 | 1177 | $relevance .= $weight[$type]; |
1109 | - if (!empty($value['results'])) |
|
1110 | - $relevance .= ' * ' . $value['results']; |
|
1178 | + if (!empty($value['results'])) { |
|
1179 | + $relevance .= ' * ' . $value['results']; |
|
1180 | + } |
|
1111 | 1181 | $relevance .= ' + '; |
1112 | 1182 | } |
1113 | 1183 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1145,20 +1215,23 @@ discard block |
||
1145 | 1215 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1146 | 1216 | { |
1147 | 1217 | // No duplicates! |
1148 | - if (isset($inserts[$row[1]])) |
|
1149 | - continue; |
|
1218 | + if (isset($inserts[$row[1]])) { |
|
1219 | + continue; |
|
1220 | + } |
|
1150 | 1221 | |
1151 | - foreach ($row as $key => $value) |
|
1152 | - $inserts[$row[1]][] = (int) $row[$key]; |
|
1222 | + foreach ($row as $key => $value) { |
|
1223 | + $inserts[$row[1]][] = (int) $row[$key]; |
|
1224 | + } |
|
1153 | 1225 | } |
1154 | 1226 | $smcFunc['db_free_result']($ignoreRequest); |
1155 | 1227 | $numSubjectResults = count($inserts); |
1228 | + } else { |
|
1229 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1156 | 1230 | } |
1157 | - else |
|
1158 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1159 | 1231 | |
1160 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
1161 | - break; |
|
1232 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
1233 | + break; |
|
1234 | + } |
|
1162 | 1235 | } |
1163 | 1236 | |
1164 | 1237 | // If there's data to be inserted for non-IGNORE databases do it here! |
@@ -1173,8 +1246,7 @@ discard block |
||
1173 | 1246 | } |
1174 | 1247 | |
1175 | 1248 | $_SESSION['search_cache']['num_results'] = $numSubjectResults; |
1176 | - } |
|
1177 | - else |
|
1249 | + } else |
|
1178 | 1250 | { |
1179 | 1251 | $main_query = array( |
1180 | 1252 | 'select' => array( |
@@ -1206,8 +1278,7 @@ discard block |
||
1206 | 1278 | $main_query['weights'] = $weight_factors; |
1207 | 1279 | |
1208 | 1280 | $main_query['group_by'][] = 't.id_topic'; |
1209 | - } |
|
1210 | - else |
|
1281 | + } else |
|
1211 | 1282 | { |
1212 | 1283 | // This is outrageous! |
1213 | 1284 | $main_query['select']['id_topic'] = 'm.id_msg AS id_topic'; |
@@ -1228,8 +1299,9 @@ discard block |
||
1228 | 1299 | $main_query['where'][] = 't.id_topic = {int:topic}'; |
1229 | 1300 | $main_query['parameters']['topic'] = $search_params['topic']; |
1230 | 1301 | } |
1231 | - if (!empty($search_params['show_complete'])) |
|
1232 | - $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
1302 | + if (!empty($search_params['show_complete'])) { |
|
1303 | + $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
1304 | + } |
|
1233 | 1305 | } |
1234 | 1306 | |
1235 | 1307 | // *** Get the subject results. |
@@ -1254,14 +1326,15 @@ discard block |
||
1254 | 1326 | ) !== false; |
1255 | 1327 | |
1256 | 1328 | // Clean up some previous cache. |
1257 | - if (!$createTemporary) |
|
1258 | - $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
1329 | + if (!$createTemporary) { |
|
1330 | + $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
1259 | 1331 | DELETE FROM {db_prefix}log_search_topics |
1260 | 1332 | WHERE id_search = {int:search_id}', |
1261 | 1333 | array( |
1262 | 1334 | 'search_id' => $_SESSION['search_cache']['id_search'], |
1263 | 1335 | ) |
1264 | 1336 | ); |
1337 | + } |
|
1265 | 1338 | |
1266 | 1339 | foreach ($searchWords as $orIndex => $words) |
1267 | 1340 | { |
@@ -1293,8 +1366,7 @@ discard block |
||
1293 | 1366 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
1294 | 1367 | $subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:body_not_' . $count . '}'; |
1295 | 1368 | $subject_query['params']['body_not_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($subjectWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $subjectWord), '\\\'') . '[[:>:]]'; |
1296 | - } |
|
1297 | - else |
|
1369 | + } else |
|
1298 | 1370 | { |
1299 | 1371 | $subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)'; |
1300 | 1372 | $subject_query['where'][] = 'subj' . $numTables . '.word LIKE {string:subject_like_' . $count . '}'; |
@@ -1349,8 +1421,9 @@ discard block |
||
1349 | 1421 | call_integration_hook('integrate_subject_search_query', array(&$subject_query)); |
1350 | 1422 | |
1351 | 1423 | // Nothing to search for? |
1352 | - if (empty($subject_query['where'])) |
|
1353 | - continue; |
|
1424 | + if (empty($subject_query['where'])) { |
|
1425 | + continue; |
|
1426 | + } |
|
1354 | 1427 | |
1355 | 1428 | $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( ' |
1356 | 1429 | INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics |
@@ -1373,19 +1446,21 @@ discard block |
||
1373 | 1446 | { |
1374 | 1447 | $ind = $createTemporary ? 0 : 1; |
1375 | 1448 | // No duplicates! |
1376 | - if (isset($inserts[$row[$ind]])) |
|
1377 | - continue; |
|
1449 | + if (isset($inserts[$row[$ind]])) { |
|
1450 | + continue; |
|
1451 | + } |
|
1378 | 1452 | |
1379 | 1453 | $inserts[$row[$ind]] = $row; |
1380 | 1454 | } |
1381 | 1455 | $smcFunc['db_free_result']($ignoreRequest); |
1382 | 1456 | $numSubjectResults = count($inserts); |
1457 | + } else { |
|
1458 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1383 | 1459 | } |
1384 | - else |
|
1385 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1386 | 1460 | |
1387 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
1388 | - break; |
|
1461 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
1462 | + break; |
|
1463 | + } |
|
1389 | 1464 | } |
1390 | 1465 | |
1391 | 1466 | // Got some non-MySQL data to plonk in? |
@@ -1403,8 +1478,9 @@ discard block |
||
1403 | 1478 | { |
1404 | 1479 | $main_query['weights']['subject']['search'] = 'CASE WHEN MAX(lst.id_topic) IS NULL THEN 0 ELSE 1 END'; |
1405 | 1480 | $main_query['left_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics AS lst ON (' . ($createTemporary ? '' : 'lst.id_search = {int:id_search} AND ') . 'lst.id_topic = t.id_topic)'; |
1406 | - if (!$createTemporary) |
|
1407 | - $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
1481 | + if (!$createTemporary) { |
|
1482 | + $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
1483 | + } |
|
1408 | 1484 | } |
1409 | 1485 | } |
1410 | 1486 | |
@@ -1430,14 +1506,15 @@ discard block |
||
1430 | 1506 | ) !== false; |
1431 | 1507 | |
1432 | 1508 | // Clear, all clear! |
1433 | - if (!$createTemporary) |
|
1434 | - $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
1509 | + if (!$createTemporary) { |
|
1510 | + $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
1435 | 1511 | DELETE FROM {db_prefix}log_search_messages |
1436 | 1512 | WHERE id_search = {int:id_search}', |
1437 | 1513 | array( |
1438 | 1514 | 'id_search' => $_SESSION['search_cache']['id_search'], |
1439 | 1515 | ) |
1440 | 1516 | ); |
1517 | + } |
|
1441 | 1518 | |
1442 | 1519 | foreach ($searchWords as $orIndex => $words) |
1443 | 1520 | { |
@@ -1471,19 +1548,21 @@ discard block |
||
1471 | 1548 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1472 | 1549 | { |
1473 | 1550 | // No duplicates! |
1474 | - if (isset($inserts[$row[0]])) |
|
1475 | - continue; |
|
1551 | + if (isset($inserts[$row[0]])) { |
|
1552 | + continue; |
|
1553 | + } |
|
1476 | 1554 | |
1477 | 1555 | $inserts[$row[0]] = $row; |
1478 | 1556 | } |
1479 | 1557 | $smcFunc['db_free_result']($ignoreRequest); |
1480 | 1558 | $indexedResults = count($inserts); |
1559 | + } else { |
|
1560 | + $indexedResults += $smcFunc['db_affected_rows'](); |
|
1481 | 1561 | } |
1482 | - else |
|
1483 | - $indexedResults += $smcFunc['db_affected_rows'](); |
|
1484 | 1562 | |
1485 | - if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) |
|
1486 | - break; |
|
1563 | + if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) { |
|
1564 | + break; |
|
1565 | + } |
|
1487 | 1566 | } |
1488 | 1567 | } |
1489 | 1568 | |
@@ -1503,8 +1582,7 @@ discard block |
||
1503 | 1582 | $context['search_errors']['query_not_specific_enough'] = true; |
1504 | 1583 | $_REQUEST['params'] = $context['params']; |
1505 | 1584 | return PlushSearch1(); |
1506 | - } |
|
1507 | - elseif (!empty($indexedResults)) |
|
1585 | + } elseif (!empty($indexedResults)) |
|
1508 | 1586 | { |
1509 | 1587 | $main_query['inner_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages AS lsm ON (lsm.id_msg = m.id_msg)'; |
1510 | 1588 | if (!$createTemporary) |
@@ -1526,15 +1604,18 @@ discard block |
||
1526 | 1604 | foreach ($words['all_words'] as $regularWord) |
1527 | 1605 | { |
1528 | 1606 | $where[] = 'm.body' . (in_array($regularWord, $excludedWords) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
1529 | - if (in_array($regularWord, $excludedWords)) |
|
1530 | - $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
1607 | + if (in_array($regularWord, $excludedWords)) { |
|
1608 | + $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
1609 | + } |
|
1531 | 1610 | $main_query['parameters']['all_word_body_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
1532 | 1611 | } |
1533 | - if (!empty($where)) |
|
1534 | - $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
1612 | + if (!empty($where)) { |
|
1613 | + $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
1614 | + } |
|
1615 | + } |
|
1616 | + if (!empty($orWhere)) { |
|
1617 | + $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
1535 | 1618 | } |
1536 | - if (!empty($orWhere)) |
|
1537 | - $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
1538 | 1619 | |
1539 | 1620 | if (!empty($userQuery)) |
1540 | 1621 | { |
@@ -1572,8 +1653,9 @@ discard block |
||
1572 | 1653 | foreach ($main_query['weights'] as $type => $value) |
1573 | 1654 | { |
1574 | 1655 | $relevance .= $weight[$type]; |
1575 | - if (!empty($value['search'])) |
|
1576 | - $relevance .= ' * ' . $value['search']; |
|
1656 | + if (!empty($value['search'])) { |
|
1657 | + $relevance .= ' * ' . $value['search']; |
|
1658 | + } |
|
1577 | 1659 | $relevance .= ' + '; |
1578 | 1660 | $new_weight_total += $weight[$type]; |
1579 | 1661 | } |
@@ -1604,11 +1686,13 @@ discard block |
||
1604 | 1686 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1605 | 1687 | { |
1606 | 1688 | // No duplicates! |
1607 | - if (isset($inserts[$row[2]])) |
|
1608 | - continue; |
|
1689 | + if (isset($inserts[$row[2]])) { |
|
1690 | + continue; |
|
1691 | + } |
|
1609 | 1692 | |
1610 | - foreach ($row as $key => $value) |
|
1611 | - $inserts[$row[2]][] = (int) $row[$key]; |
|
1693 | + foreach ($row as $key => $value) { |
|
1694 | + $inserts[$row[2]][] = (int) $row[$key]; |
|
1695 | + } |
|
1612 | 1696 | } |
1613 | 1697 | $smcFunc['db_free_result']($ignoreRequest); |
1614 | 1698 | |
@@ -1616,8 +1700,9 @@ discard block |
||
1616 | 1700 | if (!empty($inserts)) |
1617 | 1701 | { |
1618 | 1702 | $query_columns = array(); |
1619 | - foreach ($main_query['select'] as $k => $v) |
|
1620 | - $query_columns[$k] = 'int'; |
|
1703 | + foreach ($main_query['select'] as $k => $v) { |
|
1704 | + $query_columns[$k] = 'int'; |
|
1705 | + } |
|
1621 | 1706 | |
1622 | 1707 | $smcFunc['db_insert']('', |
1623 | 1708 | '{db_prefix}log_search_results', |
@@ -1627,21 +1712,23 @@ discard block |
||
1627 | 1712 | ); |
1628 | 1713 | } |
1629 | 1714 | $_SESSION['search_cache']['num_results'] += count($inserts); |
1715 | + } else { |
|
1716 | + $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
1630 | 1717 | } |
1631 | - else |
|
1632 | - $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
1633 | 1718 | } |
1634 | 1719 | |
1635 | 1720 | // Insert subject-only matches. |
1636 | 1721 | if ($_SESSION['search_cache']['num_results'] < $modSettings['search_max_results'] && $numSubjectResults !== 0) |
1637 | 1722 | { |
1638 | 1723 | $relevance = '1000 * ('; |
1639 | - foreach ($weight_factors as $type => $value) |
|
1640 | - if (isset($value['results'])) |
|
1724 | + foreach ($weight_factors as $type => $value) { |
|
1725 | + if (isset($value['results'])) |
|
1641 | 1726 | { |
1642 | 1727 | $relevance .= $weight[$type]; |
1643 | - if (!empty($value['results'])) |
|
1644 | - $relevance .= ' * ' . $value['results']; |
|
1728 | + } |
|
1729 | + if (!empty($value['results'])) { |
|
1730 | + $relevance .= ' * ' . $value['results']; |
|
1731 | + } |
|
1645 | 1732 | $relevance .= ' + '; |
1646 | 1733 | } |
1647 | 1734 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1675,8 +1762,9 @@ discard block |
||
1675 | 1762 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1676 | 1763 | { |
1677 | 1764 | // No duplicates! |
1678 | - if (isset($usedIDs[$row[1]])) |
|
1679 | - continue; |
|
1765 | + if (isset($usedIDs[$row[1]])) { |
|
1766 | + continue; |
|
1767 | + } |
|
1680 | 1768 | |
1681 | 1769 | $usedIDs[$row[1]] = true; |
1682 | 1770 | $inserts[] = $row; |
@@ -1694,12 +1782,12 @@ discard block |
||
1694 | 1782 | ); |
1695 | 1783 | } |
1696 | 1784 | $_SESSION['search_cache']['num_results'] += count($inserts); |
1785 | + } else { |
|
1786 | + $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
1697 | 1787 | } |
1698 | - else |
|
1699 | - $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
1788 | + } elseif ($_SESSION['search_cache']['num_results'] == -1) { |
|
1789 | + $_SESSION['search_cache']['num_results'] = 0; |
|
1700 | 1790 | } |
1701 | - elseif ($_SESSION['search_cache']['num_results'] == -1) |
|
1702 | - $_SESSION['search_cache']['num_results'] = 0; |
|
1703 | 1791 | } |
1704 | 1792 | } |
1705 | 1793 | |
@@ -1769,14 +1857,16 @@ discard block |
||
1769 | 1857 | ) |
1770 | 1858 | ); |
1771 | 1859 | $posters = array(); |
1772 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1773 | - $posters[] = $row['id_member']; |
|
1860 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1861 | + $posters[] = $row['id_member']; |
|
1862 | + } |
|
1774 | 1863 | $smcFunc['db_free_result']($request); |
1775 | 1864 | |
1776 | 1865 | call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters)); |
1777 | 1866 | |
1778 | - if (!empty($posters)) |
|
1779 | - loadMemberData(array_unique($posters)); |
|
1867 | + if (!empty($posters)) { |
|
1868 | + loadMemberData(array_unique($posters)); |
|
1869 | + } |
|
1780 | 1870 | |
1781 | 1871 | // Get the messages out for the callback - select enough that it can be made to look just like Display. |
1782 | 1872 | $messages_request = $smcFunc['db_query']('', ' |
@@ -1809,8 +1899,9 @@ discard block |
||
1809 | 1899 | ); |
1810 | 1900 | |
1811 | 1901 | // If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore. |
1812 | - if ($smcFunc['db_num_rows']($messages_request) == 0) |
|
1813 | - $context['topics'] = array(); |
|
1902 | + if ($smcFunc['db_num_rows']($messages_request) == 0) { |
|
1903 | + $context['topics'] = array(); |
|
1904 | + } |
|
1814 | 1905 | |
1815 | 1906 | // If we want to know who participated in what then load this now. |
1816 | 1907 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
@@ -1828,8 +1919,9 @@ discard block |
||
1828 | 1919 | 'limit' => count($participants), |
1829 | 1920 | ) |
1830 | 1921 | ); |
1831 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1832 | - $participants[$row['id_topic']] = true; |
|
1922 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1923 | + $participants[$row['id_topic']] = true; |
|
1924 | + } |
|
1833 | 1925 | $smcFunc['db_free_result']($result); |
1834 | 1926 | } |
1835 | 1927 | } |
@@ -1838,15 +1930,17 @@ discard block |
||
1838 | 1930 | $context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $num_results, $modSettings['search_results_per_page'], false); |
1839 | 1931 | |
1840 | 1932 | // Consider the search complete! |
1841 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1842 | - cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
1933 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1934 | + cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
1935 | + } |
|
1843 | 1936 | |
1844 | 1937 | $context['key_words'] = &$searchArray; |
1845 | 1938 | |
1846 | 1939 | // Setup the default topic icons... for checking they exist and the like! |
1847 | 1940 | $context['icon_sources'] = array(); |
1848 | - foreach ($context['stable_icons'] as $icon) |
|
1849 | - $context['icon_sources'][$icon] = 'images_url'; |
|
1941 | + foreach ($context['stable_icons'] as $icon) { |
|
1942 | + $context['icon_sources'][$icon] = 'images_url'; |
|
1943 | + } |
|
1850 | 1944 | |
1851 | 1945 | $context['sub_template'] = 'results'; |
1852 | 1946 | $context['page_title'] = $txt['search_results']; |
@@ -1877,26 +1971,31 @@ discard block |
||
1877 | 1971 | global $boards_can, $participants, $smcFunc; |
1878 | 1972 | static $recycle_board = null; |
1879 | 1973 | |
1880 | - if ($recycle_board === null) |
|
1881 | - $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
1974 | + if ($recycle_board === null) { |
|
1975 | + $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
1976 | + } |
|
1882 | 1977 | |
1883 | 1978 | // Remember which message this is. (ie. reply #83) |
1884 | 1979 | static $counter = null; |
1885 | - if ($counter == null || $reset) |
|
1886 | - $counter = $_REQUEST['start'] + 1; |
|
1980 | + if ($counter == null || $reset) { |
|
1981 | + $counter = $_REQUEST['start'] + 1; |
|
1982 | + } |
|
1887 | 1983 | |
1888 | 1984 | // If the query returned false, bail. |
1889 | - if ($messages_request == false) |
|
1890 | - return false; |
|
1985 | + if ($messages_request == false) { |
|
1986 | + return false; |
|
1987 | + } |
|
1891 | 1988 | |
1892 | 1989 | // Start from the beginning... |
1893 | - if ($reset) |
|
1894 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1990 | + if ($reset) { |
|
1991 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1992 | + } |
|
1895 | 1993 | |
1896 | 1994 | // Attempt to get the next message. |
1897 | 1995 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
1898 | - if (!$message) |
|
1899 | - return false; |
|
1996 | + if (!$message) { |
|
1997 | + return false; |
|
1998 | + } |
|
1900 | 1999 | |
1901 | 2000 | // Can't have an empty subject can we? |
1902 | 2001 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1935,9 +2034,9 @@ discard block |
||
1935 | 2034 | |
1936 | 2035 | if ($smcFunc['strlen']($message['body']) > $charLimit) |
1937 | 2036 | { |
1938 | - if (empty($context['key_words'])) |
|
1939 | - $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
1940 | - else |
|
2037 | + if (empty($context['key_words'])) { |
|
2038 | + $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
2039 | + } else |
|
1941 | 2040 | { |
1942 | 2041 | $matchString = ''; |
1943 | 2042 | $force_partial_word = false; |
@@ -1946,18 +2045,20 @@ discard block |
||
1946 | 2045 | $keyword = un_htmlspecialchars($keyword); |
1947 | 2046 | $keyword = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&'))); |
1948 | 2047 | |
1949 | - if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) |
|
1950 | - $force_partial_word = true; |
|
2048 | + if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) { |
|
2049 | + $force_partial_word = true; |
|
2050 | + } |
|
1951 | 2051 | $matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|'; |
1952 | 2052 | } |
1953 | 2053 | $matchString = un_htmlspecialchars(substr($matchString, 0, -1)); |
1954 | 2054 | |
1955 | 2055 | $message['body'] = un_htmlspecialchars(strtr($message['body'], array(' ' => ' ', '<br>' => "\n", '[' => '[', ']' => ']', ':' => ':', '@' => '@'))); |
1956 | 2056 | |
1957 | - if (empty($modSettings['search_method']) || $force_partial_word) |
|
1958 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
1959 | - else |
|
1960 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
2057 | + if (empty($modSettings['search_method']) || $force_partial_word) { |
|
2058 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
2059 | + } else { |
|
2060 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
2061 | + } |
|
1961 | 2062 | |
1962 | 2063 | $message['body'] = ''; |
1963 | 2064 | foreach ($matches[0] as $index => $match) |
@@ -1970,8 +2071,7 @@ discard block |
||
1970 | 2071 | // Re-fix the international characters. |
1971 | 2072 | $message['body'] = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']); |
1972 | 2073 | } |
1973 | - } |
|
1974 | - else |
|
2074 | + } else |
|
1975 | 2075 | { |
1976 | 2076 | // Run BBC interpreter on the message. |
1977 | 2077 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
@@ -1990,21 +2090,26 @@ discard block |
||
1990 | 2090 | // Sadly, we need to check the icon ain't broke. |
1991 | 2091 | if (!empty($modSettings['messageIconChecks_enable'])) |
1992 | 2092 | { |
1993 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
1994 | - $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1995 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
1996 | - $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1997 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1998 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1999 | - } |
|
2000 | - else |
|
2093 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
2094 | + $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2095 | + } |
|
2096 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
2097 | + $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2098 | + } |
|
2099 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
2100 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2101 | + } |
|
2102 | + } else |
|
2001 | 2103 | { |
2002 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
2003 | - $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
2004 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
2005 | - $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
2006 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
2007 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
2104 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
2105 | + $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
2106 | + } |
|
2107 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
2108 | + $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
2109 | + } |
|
2110 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
2111 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
2112 | + } |
|
2008 | 2113 | } |
2009 | 2114 | |
2010 | 2115 | // Do we have quote tag enabled? |
@@ -2014,12 +2119,14 @@ discard block |
||
2014 | 2119 | $colorClass = 'windowbg'; |
2015 | 2120 | |
2016 | 2121 | // Sticky topics should get a different color, too. |
2017 | - if ($message['is_sticky']) |
|
2018 | - $colorClass .= ' sticky'; |
|
2122 | + if ($message['is_sticky']) { |
|
2123 | + $colorClass .= ' sticky'; |
|
2124 | + } |
|
2019 | 2125 | |
2020 | 2126 | // Locked topics get special treatment as well. |
2021 | - if ($message['locked']) |
|
2022 | - $colorClass .= ' locked'; |
|
2127 | + if ($message['locked']) { |
|
2128 | + $colorClass .= ' locked'; |
|
2129 | + } |
|
2023 | 2130 | |
2024 | 2131 | $output = array_merge($context['topics'][$message['id_msg']], array( |
2025 | 2132 | 'id' => $message['id_topic'], |
@@ -2113,8 +2220,9 @@ discard block |
||
2113 | 2220 | $query = strtr($smcFunc['htmlspecialchars']($query), array('\\\'' => '\'')); |
2114 | 2221 | |
2115 | 2222 | // Highlighting empty strings would make a terrible mess... |
2116 | - if (strlen($query) == 0) |
|
2117 | - continue; |
|
2223 | + if (strlen($query) == 0) { |
|
2224 | + continue; |
|
2225 | + } |
|
2118 | 2226 | |
2119 | 2227 | $body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function ($m) |
2120 | 2228 | { |
@@ -2167,8 +2275,9 @@ discard block |
||
2167 | 2275 | |
2168 | 2276 | // Load up the search API we are going to use. |
2169 | 2277 | $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index']; |
2170 | - if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) |
|
2171 | - fatal_lang_error('search_api_missing'); |
|
2278 | + if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) { |
|
2279 | + fatal_lang_error('search_api_missing'); |
|
2280 | + } |
|
2172 | 2281 | require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'); |
2173 | 2282 | |
2174 | 2283 | // Create an instance of the search API and check it is valid for this version of SMF. |
@@ -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 | // I love my own image... |
@@ -682,8 +697,9 @@ discard block |
||
682 | 697 | { |
683 | 698 | // Find the position of the image. |
684 | 699 | $start_pos = strpos($text, $matches[0]); |
685 | - if ($start_pos === false) |
|
686 | - break; |
|
700 | + if ($start_pos === false) { |
|
701 | + break; |
|
702 | + } |
|
687 | 703 | $end_pos = $start_pos + strlen($matches[0]); |
688 | 704 | |
689 | 705 | $params = ''; |
@@ -692,12 +708,13 @@ discard block |
||
692 | 708 | $attrs = fetchTagAttributes($matches[1]); |
693 | 709 | foreach ($attrs as $attrib => $value) |
694 | 710 | { |
695 | - if (in_array($attrib, array('width', 'height'))) |
|
696 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
697 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
698 | - $params .= ' alt=' . trim($value); |
|
699 | - elseif ($attrib == 'src') |
|
700 | - $src = trim($value); |
|
711 | + if (in_array($attrib, array('width', 'height'))) { |
|
712 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
713 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
714 | + $params .= ' alt=' . trim($value); |
|
715 | + } elseif ($attrib == 'src') { |
|
716 | + $src = trim($value); |
|
717 | + } |
|
701 | 718 | } |
702 | 719 | |
703 | 720 | $tag = ''; |
@@ -708,10 +725,11 @@ discard block |
||
708 | 725 | { |
709 | 726 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
710 | 727 | |
711 | - if (substr($src, 0, 1) === '/') |
|
712 | - $src = $baseURL . $src; |
|
713 | - else |
|
714 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
728 | + if (substr($src, 0, 1) === '/') { |
|
729 | + $src = $baseURL . $src; |
|
730 | + } else { |
|
731 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
732 | + } |
|
715 | 733 | } |
716 | 734 | |
717 | 735 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -889,20 +907,23 @@ discard block |
||
889 | 907 | }, |
890 | 908 | ); |
891 | 909 | |
892 | - foreach ($tags as $tag => $replace) |
|
893 | - $text = preg_replace_callback($tag, $replace, $text); |
|
910 | + foreach ($tags as $tag => $replace) { |
|
911 | + $text = preg_replace_callback($tag, $replace, $text); |
|
912 | + } |
|
894 | 913 | |
895 | 914 | // Please give us just a little more time. |
896 | - if (connection_aborted() && $context['server']['is_apache']) |
|
897 | - @apache_reset_timeout(); |
|
915 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
916 | + @apache_reset_timeout(); |
|
917 | + } |
|
898 | 918 | |
899 | 919 | // What about URL's - the pain in the ass of the tag world. |
900 | 920 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
901 | 921 | { |
902 | 922 | // Find the position of the URL. |
903 | 923 | $start_pos = strpos($text, $matches[0]); |
904 | - if ($start_pos === false) |
|
905 | - break; |
|
924 | + if ($start_pos === false) { |
|
925 | + break; |
|
926 | + } |
|
906 | 927 | $end_pos = $start_pos + strlen($matches[0]); |
907 | 928 | |
908 | 929 | $tag_type = 'url'; |
@@ -916,8 +937,9 @@ discard block |
||
916 | 937 | $href = trim($value); |
917 | 938 | |
918 | 939 | // Are we dealing with an FTP link? |
919 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
920 | - $tag_type = 'ftp'; |
|
940 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
941 | + $tag_type = 'ftp'; |
|
942 | + } |
|
921 | 943 | |
922 | 944 | // Or is this a link to an email address? |
923 | 945 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -931,28 +953,31 @@ discard block |
||
931 | 953 | { |
932 | 954 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
933 | 955 | |
934 | - if (substr($href, 0, 1) === '/') |
|
935 | - $href = $baseURL . $href; |
|
936 | - else |
|
937 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
956 | + if (substr($href, 0, 1) === '/') { |
|
957 | + $href = $baseURL . $href; |
|
958 | + } else { |
|
959 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
960 | + } |
|
938 | 961 | } |
939 | 962 | } |
940 | 963 | |
941 | 964 | // External URL? |
942 | 965 | if ($attrib == 'target' && $tag_type == 'url') |
943 | 966 | { |
944 | - if (trim($value) == '_blank') |
|
945 | - $tag_type == 'iurl'; |
|
967 | + if (trim($value) == '_blank') { |
|
968 | + $tag_type == 'iurl'; |
|
969 | + } |
|
946 | 970 | } |
947 | 971 | } |
948 | 972 | |
949 | 973 | $tag = ''; |
950 | 974 | if ($href != '') |
951 | 975 | { |
952 | - if ($matches[2] == $href) |
|
953 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
954 | - else |
|
955 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
976 | + if ($matches[2] == $href) { |
|
977 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
978 | + } else { |
|
979 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
980 | + } |
|
956 | 981 | } |
957 | 982 | |
958 | 983 | // Replace the tag |
@@ -991,17 +1016,18 @@ discard block |
||
991 | 1016 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
992 | 1017 | if ($text[$i] == '=') |
993 | 1018 | { |
994 | - if ($tag_state == 0) |
|
995 | - $tag_state = 1; |
|
996 | - elseif ($tag_state == 2) |
|
997 | - $value .= '='; |
|
1019 | + if ($tag_state == 0) { |
|
1020 | + $tag_state = 1; |
|
1021 | + } elseif ($tag_state == 2) { |
|
1022 | + $value .= '='; |
|
1023 | + } |
|
998 | 1024 | } |
999 | 1025 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
1000 | 1026 | elseif ($text[$i] == ' ') |
1001 | 1027 | { |
1002 | - if ($tag_state == 2) |
|
1003 | - $value .= ' '; |
|
1004 | - elseif ($tag_state == 1) |
|
1028 | + if ($tag_state == 2) { |
|
1029 | + $value .= ' '; |
|
1030 | + } elseif ($tag_state == 1) |
|
1005 | 1031 | { |
1006 | 1032 | $attribs[$key] = $value; |
1007 | 1033 | $key = $value = ''; |
@@ -1012,24 +1038,27 @@ discard block |
||
1012 | 1038 | elseif ($text[$i] == '"') |
1013 | 1039 | { |
1014 | 1040 | // Must be either going into or out of a string. |
1015 | - if ($tag_state == 1) |
|
1016 | - $tag_state = 2; |
|
1017 | - else |
|
1018 | - $tag_state = 1; |
|
1041 | + if ($tag_state == 1) { |
|
1042 | + $tag_state = 2; |
|
1043 | + } else { |
|
1044 | + $tag_state = 1; |
|
1045 | + } |
|
1019 | 1046 | } |
1020 | 1047 | // Otherwise it's fine. |
1021 | 1048 | else |
1022 | 1049 | { |
1023 | - if ($tag_state == 0) |
|
1024 | - $key .= $text[$i]; |
|
1025 | - else |
|
1026 | - $value .= $text[$i]; |
|
1050 | + if ($tag_state == 0) { |
|
1051 | + $key .= $text[$i]; |
|
1052 | + } else { |
|
1053 | + $value .= $text[$i]; |
|
1054 | + } |
|
1027 | 1055 | } |
1028 | 1056 | } |
1029 | 1057 | |
1030 | 1058 | // Anything left? |
1031 | - if ($key != '' && $value != '') |
|
1032 | - $attribs[$key] = $value; |
|
1059 | + if ($key != '' && $value != '') { |
|
1060 | + $attribs[$key] = $value; |
|
1061 | + } |
|
1033 | 1062 | |
1034 | 1063 | return $attribs; |
1035 | 1064 | } |
@@ -1045,15 +1074,17 @@ discard block |
||
1045 | 1074 | global $modSettings; |
1046 | 1075 | |
1047 | 1076 | // Don't care about the texts that are too short. |
1048 | - if (strlen($text) < 3) |
|
1049 | - return $text; |
|
1077 | + if (strlen($text) < 3) { |
|
1078 | + return $text; |
|
1079 | + } |
|
1050 | 1080 | |
1051 | 1081 | // A list of tags that's disabled by the admin. |
1052 | 1082 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
1053 | 1083 | |
1054 | 1084 | // Add flash if it's disabled as embedded tag. |
1055 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1056 | - $disabled['flash'] = true; |
|
1085 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1086 | + $disabled['flash'] = true; |
|
1087 | + } |
|
1057 | 1088 | |
1058 | 1089 | // Get a list of all the tags that are not disabled. |
1059 | 1090 | $all_tags = parse_bbc(false); |
@@ -1061,10 +1092,12 @@ discard block |
||
1061 | 1092 | $self_closing_tags = array(); |
1062 | 1093 | foreach ($all_tags as $tag) |
1063 | 1094 | { |
1064 | - if (!isset($disabled[$tag['tag']])) |
|
1065 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1066 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
1067 | - $self_closing_tags[] = $tag['tag']; |
|
1095 | + if (!isset($disabled[$tag['tag']])) { |
|
1096 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1097 | + } |
|
1098 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
1099 | + $self_closing_tags[] = $tag['tag']; |
|
1100 | + } |
|
1068 | 1101 | } |
1069 | 1102 | |
1070 | 1103 | // 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! |
@@ -1091,16 +1124,19 @@ discard block |
||
1091 | 1124 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
1092 | 1125 | |
1093 | 1126 | // We're closing the exact same tag that we opened. |
1094 | - if ($isClosingTag && $insideTag === $tagName) |
|
1095 | - $insideTag = null; |
|
1127 | + if ($isClosingTag && $insideTag === $tagName) { |
|
1128 | + $insideTag = null; |
|
1129 | + } |
|
1096 | 1130 | |
1097 | 1131 | // We're opening a tag and we're not yet inside one either |
1098 | - elseif (!$isClosingTag && $insideTag === null) |
|
1099 | - $insideTag = $tagName; |
|
1132 | + elseif (!$isClosingTag && $insideTag === null) { |
|
1133 | + $insideTag = $tagName; |
|
1134 | + } |
|
1100 | 1135 | |
1101 | 1136 | // In all other cases, this tag must be invalid |
1102 | - else |
|
1103 | - unset($matches[$i]); |
|
1137 | + else { |
|
1138 | + unset($matches[$i]); |
|
1139 | + } |
|
1104 | 1140 | } |
1105 | 1141 | |
1106 | 1142 | // The next one is gonna be the other one. |
@@ -1108,8 +1144,9 @@ discard block |
||
1108 | 1144 | } |
1109 | 1145 | |
1110 | 1146 | // We're still inside a tag and had no chance for closure? |
1111 | - if ($insideTag !== null) |
|
1112 | - $matches[] = '[/' . $insideTag . ']'; |
|
1147 | + if ($insideTag !== null) { |
|
1148 | + $matches[] = '[/' . $insideTag . ']'; |
|
1149 | + } |
|
1113 | 1150 | |
1114 | 1151 | // And a complete text string again. |
1115 | 1152 | $text = implode('', $matches); |
@@ -1118,8 +1155,9 @@ discard block |
||
1118 | 1155 | // Quickly remove any tags which are back to back. |
1119 | 1156 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
1120 | 1157 | $lastlen = 0; |
1121 | - while (strlen($text) !== $lastlen) |
|
1122 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1158 | + while (strlen($text) !== $lastlen) { |
|
1159 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1160 | + } |
|
1123 | 1161 | |
1124 | 1162 | // Need to sort the tags my name length. |
1125 | 1163 | uksort($valid_tags, 'sort_array_length'); |
@@ -1156,8 +1194,9 @@ discard block |
||
1156 | 1194 | $isCompetingTag = in_array($tag, $competing_tags); |
1157 | 1195 | |
1158 | 1196 | // Check if this might be one of those cleaned out tags. |
1159 | - if ($tag === '') |
|
1160 | - continue; |
|
1197 | + if ($tag === '') { |
|
1198 | + continue; |
|
1199 | + } |
|
1161 | 1200 | |
1162 | 1201 | // Special case: inside [code] blocks any code is left untouched. |
1163 | 1202 | elseif ($tag === 'code') |
@@ -1168,8 +1207,9 @@ discard block |
||
1168 | 1207 | $inCode = false; |
1169 | 1208 | |
1170 | 1209 | // Reopen tags that were closed before the code block. |
1171 | - if (!empty($inlineElements)) |
|
1172 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1210 | + if (!empty($inlineElements)) { |
|
1211 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1212 | + } |
|
1173 | 1213 | } |
1174 | 1214 | |
1175 | 1215 | // We're outside a coding and nobbc block and opening it. |
@@ -1198,8 +1238,9 @@ discard block |
||
1198 | 1238 | $inNoBbc = false; |
1199 | 1239 | |
1200 | 1240 | // Some inline elements might've been closed that need reopening. |
1201 | - if (!empty($inlineElements)) |
|
1202 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1241 | + if (!empty($inlineElements)) { |
|
1242 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1243 | + } |
|
1203 | 1244 | } |
1204 | 1245 | |
1205 | 1246 | // We're outside a nobbc and coding block and opening it. |
@@ -1219,8 +1260,9 @@ discard block |
||
1219 | 1260 | } |
1220 | 1261 | |
1221 | 1262 | // So, we're inside one of the special blocks: ignore any tag. |
1222 | - elseif ($inCode || $inNoBbc) |
|
1223 | - continue; |
|
1263 | + elseif ($inCode || $inNoBbc) { |
|
1264 | + continue; |
|
1265 | + } |
|
1224 | 1266 | |
1225 | 1267 | // We're dealing with an opening tag. |
1226 | 1268 | if ($isOpeningTag) |
@@ -1261,8 +1303,9 @@ discard block |
||
1261 | 1303 | if ($parts[$j + 3] === $tag) |
1262 | 1304 | { |
1263 | 1305 | // If it's an opening tag, increase the level. |
1264 | - if ($parts[$j + 2] === '') |
|
1265 | - $curLevel++; |
|
1306 | + if ($parts[$j + 2] === '') { |
|
1307 | + $curLevel++; |
|
1308 | + } |
|
1266 | 1309 | |
1267 | 1310 | // A closing tag, decrease the level. |
1268 | 1311 | else |
@@ -1285,13 +1328,15 @@ discard block |
||
1285 | 1328 | { |
1286 | 1329 | if ($isCompetingTag) |
1287 | 1330 | { |
1288 | - if (!isset($competingElements[$tag])) |
|
1289 | - $competingElements[$tag] = array(); |
|
1331 | + if (!isset($competingElements[$tag])) { |
|
1332 | + $competingElements[$tag] = array(); |
|
1333 | + } |
|
1290 | 1334 | |
1291 | 1335 | $competingElements[$tag][] = $parts[$i + 4]; |
1292 | 1336 | |
1293 | - if (count($competingElements[$tag]) > 1) |
|
1294 | - $parts[$i] .= '[/' . $tag . ']'; |
|
1337 | + if (count($competingElements[$tag]) > 1) { |
|
1338 | + $parts[$i] .= '[/' . $tag . ']'; |
|
1339 | + } |
|
1295 | 1340 | } |
1296 | 1341 | |
1297 | 1342 | $inlineElements[$elementContent] = $tag; |
@@ -1311,15 +1356,17 @@ discard block |
||
1311 | 1356 | $addClosingTags = array(); |
1312 | 1357 | while ($element = array_pop($blockElements)) |
1313 | 1358 | { |
1314 | - if ($element === $tag) |
|
1315 | - break; |
|
1359 | + if ($element === $tag) { |
|
1360 | + break; |
|
1361 | + } |
|
1316 | 1362 | |
1317 | 1363 | // Still a block tag was open not equal to this tag. |
1318 | 1364 | $addClosingTags[] = $element['type']; |
1319 | 1365 | } |
1320 | 1366 | |
1321 | - if (!empty($addClosingTags)) |
|
1322 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1367 | + if (!empty($addClosingTags)) { |
|
1368 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1369 | + } |
|
1323 | 1370 | |
1324 | 1371 | // Apparently the closing tag was not found on the stack. |
1325 | 1372 | if (!is_string($element) || $element !== $tag) |
@@ -1329,8 +1376,7 @@ discard block |
||
1329 | 1376 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
1330 | 1377 | continue; |
1331 | 1378 | } |
1332 | - } |
|
1333 | - else |
|
1379 | + } else |
|
1334 | 1380 | { |
1335 | 1381 | // Get rid of this closing tag! |
1336 | 1382 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1359,53 +1405,62 @@ discard block |
||
1359 | 1405 | unset($inlineElements[$tagContentToBeClosed]); |
1360 | 1406 | |
1361 | 1407 | // Was this the tag we were looking for? |
1362 | - if ($tagToBeClosed === $tag) |
|
1363 | - break; |
|
1408 | + if ($tagToBeClosed === $tag) { |
|
1409 | + break; |
|
1410 | + } |
|
1364 | 1411 | |
1365 | 1412 | // Nope, close it and look further! |
1366 | - else |
|
1367 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1413 | + else { |
|
1414 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1415 | + } |
|
1368 | 1416 | } |
1369 | 1417 | |
1370 | 1418 | if ($isCompetingTag && !empty($competingElements[$tag])) |
1371 | 1419 | { |
1372 | 1420 | array_pop($competingElements[$tag]); |
1373 | 1421 | |
1374 | - if (count($competingElements[$tag]) > 0) |
|
1375 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1422 | + if (count($competingElements[$tag]) > 0) { |
|
1423 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1424 | + } |
|
1376 | 1425 | } |
1377 | 1426 | } |
1378 | 1427 | |
1379 | 1428 | // Unexpected closing tag, ex-ter-mi-nate. |
1380 | - else |
|
1381 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1429 | + else { |
|
1430 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1431 | + } |
|
1382 | 1432 | } |
1383 | 1433 | } |
1384 | 1434 | } |
1385 | 1435 | |
1386 | 1436 | // Close the code tags. |
1387 | - if ($inCode) |
|
1388 | - $parts[$i] .= '[/code]'; |
|
1437 | + if ($inCode) { |
|
1438 | + $parts[$i] .= '[/code]'; |
|
1439 | + } |
|
1389 | 1440 | |
1390 | 1441 | // The same for nobbc tags. |
1391 | - elseif ($inNoBbc) |
|
1392 | - $parts[$i] .= '[/nobbc]'; |
|
1442 | + elseif ($inNoBbc) { |
|
1443 | + $parts[$i] .= '[/nobbc]'; |
|
1444 | + } |
|
1393 | 1445 | |
1394 | 1446 | // Still inline tags left unclosed? Close them now, better late than never. |
1395 | - elseif (!empty($inlineElements)) |
|
1396 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1447 | + elseif (!empty($inlineElements)) { |
|
1448 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1449 | + } |
|
1397 | 1450 | |
1398 | 1451 | // Now close the block elements. |
1399 | - if (!empty($blockElements)) |
|
1400 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1452 | + if (!empty($blockElements)) { |
|
1453 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1454 | + } |
|
1401 | 1455 | |
1402 | 1456 | $text = implode('', $parts); |
1403 | 1457 | } |
1404 | 1458 | |
1405 | 1459 | // Final clean up of back to back tags. |
1406 | 1460 | $lastlen = 0; |
1407 | - while (strlen($text) !== $lastlen) |
|
1408 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1461 | + while (strlen($text) !== $lastlen) { |
|
1462 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1463 | + } |
|
1409 | 1464 | |
1410 | 1465 | return $text; |
1411 | 1466 | } |
@@ -1434,22 +1489,25 @@ discard block |
||
1434 | 1489 | $context['template_layers'] = array(); |
1435 | 1490 | // Lets make sure we aren't going to output anything nasty. |
1436 | 1491 | @ob_end_clean(); |
1437 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
1438 | - @ob_start('ob_gzhandler'); |
|
1439 | - else |
|
1440 | - @ob_start(); |
|
1492 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
1493 | + @ob_start('ob_gzhandler'); |
|
1494 | + } else { |
|
1495 | + @ob_start(); |
|
1496 | + } |
|
1441 | 1497 | |
1442 | 1498 | // If we don't have any locale better avoid broken js |
1443 | - if (empty($txt['lang_locale'])) |
|
1444 | - die(); |
|
1499 | + if (empty($txt['lang_locale'])) { |
|
1500 | + die(); |
|
1501 | + } |
|
1445 | 1502 | |
1446 | 1503 | $file_data = '(function ($) { |
1447 | 1504 | \'use strict\'; |
1448 | 1505 | |
1449 | 1506 | $.sceditor.locale[' . JavaScriptEscape($txt['lang_locale']) . '] = {'; |
1450 | - foreach ($editortxt as $key => $val) |
|
1451 | - $file_data .= ' |
|
1507 | + foreach ($editortxt as $key => $val) { |
|
1508 | + $file_data .= ' |
|
1452 | 1509 | ' . JavaScriptEscape($key) . ': ' . JavaScriptEscape($val) . ','; |
1510 | + } |
|
1453 | 1511 | |
1454 | 1512 | $file_data .= ' |
1455 | 1513 | dateFormat: "day.month.year" |
@@ -1517,8 +1575,9 @@ discard block |
||
1517 | 1575 | ) |
1518 | 1576 | ); |
1519 | 1577 | $icon_data = array(); |
1520 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1521 | - $icon_data[] = $row; |
|
1578 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1579 | + $icon_data[] = $row; |
|
1580 | + } |
|
1522 | 1581 | $smcFunc['db_free_result']($request); |
1523 | 1582 | |
1524 | 1583 | $icons = array(); |
@@ -1533,9 +1592,9 @@ discard block |
||
1533 | 1592 | } |
1534 | 1593 | |
1535 | 1594 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
1595 | + } else { |
|
1596 | + $icons = $temp; |
|
1536 | 1597 | } |
1537 | - else |
|
1538 | - $icons = $temp; |
|
1539 | 1598 | } |
1540 | 1599 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
1541 | 1600 | |
@@ -1577,8 +1636,9 @@ discard block |
||
1577 | 1636 | { |
1578 | 1637 | // Some general stuff. |
1579 | 1638 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
1580 | - if (!empty($context['drafts_autosave'])) |
|
1581 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1639 | + if (!empty($context['drafts_autosave'])) { |
|
1640 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1641 | + } |
|
1582 | 1642 | |
1583 | 1643 | // This really has some WYSIWYG stuff. |
1584 | 1644 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1596,8 +1656,9 @@ discard block |
||
1596 | 1656 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
1597 | 1657 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
1598 | 1658 | // editor language file |
1599 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
1600 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1659 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
1660 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1661 | + } |
|
1601 | 1662 | |
1602 | 1663 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))]; |
1603 | 1664 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1606,11 +1667,12 @@ discard block |
||
1606 | 1667 | loadJavaScriptFile('spellcheck.js', array('minimize' => true), 'smf_spellcheck'); |
1607 | 1668 | |
1608 | 1669 | // Some hidden information is needed in order to make the spell checking work. |
1609 | - if (!isset($_REQUEST['xml'])) |
|
1610 | - $context['insert_after_template'] .= ' |
|
1670 | + if (!isset($_REQUEST['xml'])) { |
|
1671 | + $context['insert_after_template'] .= ' |
|
1611 | 1672 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
1612 | 1673 | <input type="hidden" name="spellstring" value=""> |
1613 | 1674 | </form>'; |
1675 | + } |
|
1614 | 1676 | } |
1615 | 1677 | } |
1616 | 1678 | |
@@ -1802,10 +1864,12 @@ discard block |
||
1802 | 1864 | |
1803 | 1865 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
1804 | 1866 | $disabled_tags = array(); |
1805 | - if (!empty($modSettings['disabledBBC'])) |
|
1806 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1807 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1808 | - $disabled_tags[] = 'flash'; |
|
1867 | + if (!empty($modSettings['disabledBBC'])) { |
|
1868 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1869 | + } |
|
1870 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1871 | + $disabled_tags[] = 'flash'; |
|
1872 | + } |
|
1809 | 1873 | |
1810 | 1874 | foreach ($disabled_tags as $tag) |
1811 | 1875 | { |
@@ -1817,9 +1881,10 @@ discard block |
||
1817 | 1881 | $context['disabled_tags']['orderedlist'] = true; |
1818 | 1882 | } |
1819 | 1883 | |
1820 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
1821 | - if ($tag === $thisTag) |
|
1884 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
1885 | + if ($tag === $thisTag) |
|
1822 | 1886 | $context['disabled_tags'][$tagNameBBC] = true; |
1887 | + } |
|
1823 | 1888 | |
1824 | 1889 | $context['disabled_tags'][$tag] = true; |
1825 | 1890 | } |
@@ -1830,8 +1895,9 @@ discard block |
||
1830 | 1895 | |
1831 | 1896 | foreach ($context['bbc_tags'] as $row => $tagRow) |
1832 | 1897 | { |
1833 | - if (!isset($context['bbc_toolbar'][$row])) |
|
1834 | - $context['bbc_toolbar'][$row] = array(); |
|
1898 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
1899 | + $context['bbc_toolbar'][$row] = array(); |
|
1900 | + } |
|
1835 | 1901 | |
1836 | 1902 | $tagsRow = array(); |
1837 | 1903 | |
@@ -1867,20 +1933,21 @@ discard block |
||
1867 | 1933 | |
1868 | 1934 | $context['bbcodes_handlers'] .= ' |
1869 | 1935 | });'; |
1870 | - } |
|
1871 | - else |
|
1936 | + } else |
|
1872 | 1937 | { |
1873 | 1938 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
1874 | 1939 | $tagsRow = array(); |
1875 | 1940 | } |
1876 | 1941 | } |
1877 | 1942 | |
1878 | - if (!empty($tagsRow)) |
|
1879 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1943 | + if (!empty($tagsRow)) { |
|
1944 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1945 | + } |
|
1880 | 1946 | } |
1881 | 1947 | |
1882 | - if (!empty($bbcodes_styles)) |
|
1883 | - addInlineCss($bbcodes_styles); |
|
1948 | + if (!empty($bbcodes_styles)) { |
|
1949 | + addInlineCss($bbcodes_styles); |
|
1950 | + } |
|
1884 | 1951 | } |
1885 | 1952 | |
1886 | 1953 | // Initialize smiley array... if not loaded before. |
@@ -1892,8 +1959,8 @@ discard block |
||
1892 | 1959 | ); |
1893 | 1960 | |
1894 | 1961 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
1895 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
1896 | - $context['smileys']['postform'][] = array( |
|
1962 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
1963 | + $context['smileys']['postform'][] = array( |
|
1897 | 1964 | 'smileys' => array( |
1898 | 1965 | array( |
1899 | 1966 | 'code' => ':)', |
@@ -1979,7 +2046,7 @@ discard block |
||
1979 | 2046 | ), |
1980 | 2047 | 'isLast' => true, |
1981 | 2048 | ); |
1982 | - elseif ($user_info['smiley_set'] != 'none') |
|
2049 | + } elseif ($user_info['smiley_set'] != 'none') |
|
1983 | 2050 | { |
1984 | 2051 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
1985 | 2052 | { |
@@ -2002,17 +2069,19 @@ discard block |
||
2002 | 2069 | |
2003 | 2070 | foreach ($context['smileys'] as $section => $smileyRows) |
2004 | 2071 | { |
2005 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
2006 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2072 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
2073 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2074 | + } |
|
2007 | 2075 | |
2008 | - if (!empty($smileyRows)) |
|
2009 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2076 | + if (!empty($smileyRows)) { |
|
2077 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2078 | + } |
|
2010 | 2079 | } |
2011 | 2080 | |
2012 | 2081 | cache_put_data('posting_smileys', $context['smileys'], 480); |
2082 | + } else { |
|
2083 | + $context['smileys'] = $temp; |
|
2013 | 2084 | } |
2014 | - else |
|
2015 | - $context['smileys'] = $temp; |
|
2016 | 2085 | } |
2017 | 2086 | } |
2018 | 2087 | |
@@ -2028,12 +2097,15 @@ discard block |
||
2028 | 2097 | 'plugins' => 'undo', |
2029 | 2098 | 'bbcodeTrim' => true, |
2030 | 2099 | ); |
2031 | - if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) |
|
2032 | - $sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale']; |
|
2033 | - if (!empty($context['right_to_left'])) |
|
2034 | - $sce_options['rtl'] = true; |
|
2035 | - if ($editorOptions['id'] != 'quickReply') |
|
2036 | - $sce_options['autofocus'] = true; |
|
2100 | + if (!empty($context['controls']['richedit'][$editorOptions['id']]['locale'])) { |
|
2101 | + $sce_options['locale'] = $context['controls']['richedit'][$editorOptions['id']]['locale']; |
|
2102 | + } |
|
2103 | + if (!empty($context['right_to_left'])) { |
|
2104 | + $sce_options['rtl'] = true; |
|
2105 | + } |
|
2106 | + if ($editorOptions['id'] != 'quickReply') { |
|
2107 | + $sce_options['autofocus'] = true; |
|
2108 | + } |
|
2037 | 2109 | |
2038 | 2110 | $sce_options['emoticons'] = array(); |
2039 | 2111 | $sce_options['emoticonsDescriptions'] = array(); |
@@ -2050,10 +2122,11 @@ discard block |
||
2050 | 2122 | $countLocations--; |
2051 | 2123 | |
2052 | 2124 | unset($smiley_location); |
2053 | - if ($location == 'postform') |
|
2054 | - $smiley_location = &$sce_options['emoticons']['dropdown']; |
|
2055 | - elseif ($location == 'popup') |
|
2056 | - $smiley_location = &$sce_options['emoticons']['popup']; |
|
2125 | + if ($location == 'postform') { |
|
2126 | + $smiley_location = &$sce_options['emoticons']['dropdown']; |
|
2127 | + } elseif ($location == 'popup') { |
|
2128 | + $smiley_location = &$sce_options['emoticons']['popup']; |
|
2129 | + } |
|
2057 | 2130 | |
2058 | 2131 | $numRows = count($smileyRows); |
2059 | 2132 | |
@@ -2067,8 +2140,9 @@ discard block |
||
2067 | 2140 | $sce_options['emoticonsDescriptions'][$smiley['code']] = $smiley['description']; |
2068 | 2141 | } |
2069 | 2142 | |
2070 | - if (empty($smileyRow['isLast']) && $numRows != 1) |
|
2071 | - $smiley_location['-' . $emptyPlaceholder++] = ''; |
|
2143 | + if (empty($smileyRow['isLast']) && $numRows != 1) { |
|
2144 | + $smiley_location['-' . $emptyPlaceholder++] = ''; |
|
2145 | + } |
|
2072 | 2146 | } |
2073 | 2147 | } |
2074 | 2148 | } |
@@ -2083,8 +2157,9 @@ discard block |
||
2083 | 2157 | |
2084 | 2158 | $count_tags--; |
2085 | 2159 | |
2086 | - if (!empty($count_tags)) |
|
2087 | - $sce_options['toolbar'] .= '||'; |
|
2160 | + if (!empty($count_tags)) { |
|
2161 | + $sce_options['toolbar'] .= '||'; |
|
2162 | + } |
|
2088 | 2163 | } |
2089 | 2164 | } |
2090 | 2165 | |
@@ -2112,8 +2187,9 @@ discard block |
||
2112 | 2187 | loadTemplate('GenericControls'); |
2113 | 2188 | |
2114 | 2189 | // Some javascript ma'am? |
2115 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
2116 | - loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha'); |
|
2190 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
2191 | + loadJavaScriptFile('captcha.js', array('minimize' => true), 'smf_captcha'); |
|
2192 | + } |
|
2117 | 2193 | |
2118 | 2194 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
2119 | 2195 | |
@@ -2126,8 +2202,8 @@ discard block |
||
2126 | 2202 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
2127 | 2203 | |
2128 | 2204 | // Log this into our collection. |
2129 | - if ($isNew) |
|
2130 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2205 | + if ($isNew) { |
|
2206 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2131 | 2207 | 'id' => $verificationOptions['id'], |
2132 | 2208 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
2133 | 2209 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2138,13 +2214,15 @@ discard block |
||
2138 | 2214 | 'questions' => array(), |
2139 | 2215 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
2140 | 2216 | ); |
2217 | + } |
|
2141 | 2218 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
2142 | 2219 | |
2143 | 2220 | // Is there actually going to be anything? |
2144 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
2145 | - return false; |
|
2146 | - elseif (!$isNew && !$do_test) |
|
2147 | - return true; |
|
2221 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
2222 | + return false; |
|
2223 | + } elseif (!$isNew && !$do_test) { |
|
2224 | + return true; |
|
2225 | + } |
|
2148 | 2226 | |
2149 | 2227 | // Sanitize reCAPTCHA fields? |
2150 | 2228 | if ($thisVerification['can_recaptcha']) |
@@ -2157,11 +2235,12 @@ discard block |
||
2157 | 2235 | } |
2158 | 2236 | |
2159 | 2237 | // Add javascript for the object. |
2160 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
2161 | - $context['insert_after_template'] .= ' |
|
2238 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
2239 | + $context['insert_after_template'] .= ' |
|
2162 | 2240 | <script> |
2163 | 2241 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
2164 | 2242 | </script>'; |
2243 | + } |
|
2165 | 2244 | |
2166 | 2245 | // If we want questions do we have a cache of all the IDs? |
2167 | 2246 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2184,8 +2263,9 @@ discard block |
||
2184 | 2263 | unset ($row['id_question']); |
2185 | 2264 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
2186 | 2265 | $row['answers'] = $smcFunc['json_decode']($row['answers'], true); |
2187 | - foreach ($row['answers'] as $k => $v) |
|
2188 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2266 | + foreach ($row['answers'] as $k => $v) { |
|
2267 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2268 | + } |
|
2189 | 2269 | |
2190 | 2270 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
2191 | 2271 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2196,35 +2276,42 @@ discard block |
||
2196 | 2276 | } |
2197 | 2277 | } |
2198 | 2278 | |
2199 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
2200 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2279 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
2280 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2281 | + } |
|
2201 | 2282 | |
2202 | 2283 | // Do we need to refresh the verification? |
2203 | - 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'])) |
|
2204 | - $force_refresh = true; |
|
2205 | - else |
|
2206 | - $force_refresh = false; |
|
2284 | + 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'])) { |
|
2285 | + $force_refresh = true; |
|
2286 | + } else { |
|
2287 | + $force_refresh = false; |
|
2288 | + } |
|
2207 | 2289 | |
2208 | 2290 | // This can also force a fresh, although unlikely. |
2209 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
2210 | - $force_refresh = true; |
|
2291 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
2292 | + $force_refresh = true; |
|
2293 | + } |
|
2211 | 2294 | |
2212 | 2295 | $verification_errors = array(); |
2213 | 2296 | // Start with any testing. |
2214 | 2297 | if ($do_test) |
2215 | 2298 | { |
2216 | 2299 | // This cannot happen! |
2217 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
2218 | - fatal_lang_error('no_access', false); |
|
2300 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
2301 | + fatal_lang_error('no_access', false); |
|
2302 | + } |
|
2219 | 2303 | // ... nor this! |
2220 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
2221 | - fatal_lang_error('no_access', false); |
|
2304 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
2305 | + fatal_lang_error('no_access', false); |
|
2306 | + } |
|
2222 | 2307 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
2223 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
2224 | - fatal_lang_error('no_access', false); |
|
2308 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
2309 | + fatal_lang_error('no_access', false); |
|
2310 | + } |
|
2225 | 2311 | // While we're here, did the user do something bad? |
2226 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
2227 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2312 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
2313 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2314 | + } |
|
2228 | 2315 | |
2229 | 2316 | if ($thisVerification['can_recaptcha']) |
2230 | 2317 | { |
@@ -2235,22 +2322,25 @@ discard block |
||
2235 | 2322 | { |
2236 | 2323 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
2237 | 2324 | |
2238 | - if (!$resp->isSuccess()) |
|
2239 | - $verification_errors[] = 'wrong_verification_code'; |
|
2325 | + if (!$resp->isSuccess()) { |
|
2326 | + $verification_errors[] = 'wrong_verification_code'; |
|
2327 | + } |
|
2328 | + } else { |
|
2329 | + $verification_errors[] = 'wrong_verification_code'; |
|
2240 | 2330 | } |
2241 | - else |
|
2242 | - $verification_errors[] = 'wrong_verification_code'; |
|
2243 | 2331 | } |
2244 | - 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'])) |
|
2245 | - $verification_errors[] = 'wrong_verification_code'; |
|
2332 | + 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'])) { |
|
2333 | + $verification_errors[] = 'wrong_verification_code'; |
|
2334 | + } |
|
2246 | 2335 | if ($thisVerification['number_questions']) |
2247 | 2336 | { |
2248 | 2337 | $incorrectQuestions = array(); |
2249 | 2338 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
2250 | 2339 | { |
2251 | 2340 | // We don't have this question any more, thus no answers. |
2252 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
2253 | - continue; |
|
2341 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
2342 | + continue; |
|
2343 | + } |
|
2254 | 2344 | // This is quite complex. We have our question but it might have multiple answers. |
2255 | 2345 | // First, did they actually answer this question? |
2256 | 2346 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2262,24 +2352,28 @@ discard block |
||
2262 | 2352 | else |
2263 | 2353 | { |
2264 | 2354 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
2265 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
2266 | - $incorrectQuestions[] = $q; |
|
2355 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
2356 | + $incorrectQuestions[] = $q; |
|
2357 | + } |
|
2267 | 2358 | } |
2268 | 2359 | } |
2269 | 2360 | |
2270 | - if (!empty($incorrectQuestions)) |
|
2271 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2361 | + if (!empty($incorrectQuestions)) { |
|
2362 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2363 | + } |
|
2272 | 2364 | } |
2273 | 2365 | } |
2274 | 2366 | |
2275 | 2367 | // Any errors means we refresh potentially. |
2276 | 2368 | if (!empty($verification_errors)) |
2277 | 2369 | { |
2278 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
2279 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2370 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
2371 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2372 | + } |
|
2280 | 2373 | // Too many errors? |
2281 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
2282 | - $force_refresh = true; |
|
2374 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
2375 | + $force_refresh = true; |
|
2376 | + } |
|
2283 | 2377 | |
2284 | 2378 | // Keep a track of these. |
2285 | 2379 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2312,8 +2406,9 @@ discard block |
||
2312 | 2406 | // Are we overriding the range? |
2313 | 2407 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
2314 | 2408 | |
2315 | - for ($i = 0; $i < 6; $i++) |
|
2316 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2409 | + for ($i = 0; $i < 6; $i++) { |
|
2410 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2411 | + } |
|
2317 | 2412 | } |
2318 | 2413 | |
2319 | 2414 | // Getting some new questions? |
@@ -2321,8 +2416,9 @@ discard block |
||
2321 | 2416 | { |
2322 | 2417 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
2323 | 2418 | $possible_langs = array(); |
2324 | - if (isset($_SESSION['language'])) |
|
2325 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2419 | + if (isset($_SESSION['language'])) { |
|
2420 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2421 | + } |
|
2326 | 2422 | if (!empty($user_info['language'])); |
2327 | 2423 | $possible_langs[] = $user_info['language']; |
2328 | 2424 | $possible_langs[] = $language; |
@@ -2341,8 +2437,7 @@ discard block |
||
2341 | 2437 | } |
2342 | 2438 | } |
2343 | 2439 | } |
2344 | - } |
|
2345 | - else |
|
2440 | + } else |
|
2346 | 2441 | { |
2347 | 2442 | // Same questions as before. |
2348 | 2443 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2352,8 +2447,9 @@ discard block |
||
2352 | 2447 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
2353 | 2448 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
2354 | 2449 | { |
2355 | - if (!isset($context['html_headers'])) |
|
2356 | - $context['html_headers'] = ''; |
|
2450 | + if (!isset($context['html_headers'])) { |
|
2451 | + $context['html_headers'] = ''; |
|
2452 | + } |
|
2357 | 2453 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
2358 | 2454 | } |
2359 | 2455 | |
@@ -2379,11 +2475,13 @@ discard block |
||
2379 | 2475 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
2380 | 2476 | |
2381 | 2477 | // Return errors if we have them. |
2382 | - if (!empty($verification_errors)) |
|
2383 | - return $verification_errors; |
|
2478 | + if (!empty($verification_errors)) { |
|
2479 | + return $verification_errors; |
|
2480 | + } |
|
2384 | 2481 | // If we had a test that one, make a note. |
2385 | - elseif ($do_test) |
|
2386 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2482 | + elseif ($do_test) { |
|
2483 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2484 | + } |
|
2387 | 2485 | |
2388 | 2486 | // Say that everything went well chaps. |
2389 | 2487 | return true; |
@@ -2408,8 +2506,9 @@ discard block |
||
2408 | 2506 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
2409 | 2507 | |
2410 | 2508 | // If we're just checking the callback function is registered return true or false. |
2411 | - if ($checkRegistered != null) |
|
2412 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2509 | + if ($checkRegistered != null) { |
|
2510 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2511 | + } |
|
2413 | 2512 | |
2414 | 2513 | checkSession('get'); |
2415 | 2514 | loadTemplate('Xml'); |
@@ -2560,24 +2659,27 @@ discard block |
||
2560 | 2659 | foreach ($possible_versions as $ver) |
2561 | 2660 | { |
2562 | 2661 | $ver = trim($ver); |
2563 | - if (strpos($ver, 'SMF') === 0) |
|
2564 | - $versions[] = $ver; |
|
2662 | + if (strpos($ver, 'SMF') === 0) { |
|
2663 | + $versions[] = $ver; |
|
2664 | + } |
|
2565 | 2665 | } |
2566 | 2666 | } |
2567 | 2667 | $smcFunc['db_free_result']($request); |
2568 | 2668 | |
2569 | 2669 | // Just in case we don't have ANYthing. |
2570 | - if (empty($versions)) |
|
2571 | - $versions = array('SMF 2.0'); |
|
2670 | + if (empty($versions)) { |
|
2671 | + $versions = array('SMF 2.0'); |
|
2672 | + } |
|
2572 | 2673 | |
2573 | - foreach ($versions as $id => $version) |
|
2574 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2674 | + foreach ($versions as $id => $version) { |
|
2675 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2575 | 2676 | $xml_data['items']['children'][] = array( |
2576 | 2677 | 'attributes' => array( |
2577 | 2678 | 'id' => $id, |
2578 | 2679 | ), |
2579 | 2680 | 'value' => $version, |
2580 | 2681 | ); |
2682 | + } |
|
2581 | 2683 | |
2582 | 2684 | return $xml_data; |
2583 | 2685 | } |
@@ -18,11 +18,12 @@ discard block |
||
18 | 18 | global $context, $txt, $scripturl; |
19 | 19 | |
20 | 20 | // Let them know the action was a success. |
21 | - if (!empty($context['report_post_action'])) |
|
22 | - echo ' |
|
21 | + if (!empty($context['report_post_action'])) { |
|
22 | + echo ' |
|
23 | 23 | <div class="infobox"> |
24 | 24 | ', $txt['report_action_' . $context['report_post_action']], ' |
25 | 25 | </div>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | echo ' |
28 | 29 | <form id="reported_posts" action="', $scripturl, '?action=moderate;area=reportedposts;sa=show', $context['view_closed'] ? ';closed' : '', ';start=', $context['start'], '" method="post" accept-charset="', $context['character_set'], '"> |
@@ -52,8 +53,9 @@ discard block |
||
52 | 53 | |
53 | 54 | // Prepare the comments... |
54 | 55 | $comments = array(); |
55 | - foreach ($report['comments'] as $comment) |
|
56 | - $comments[$comment['member']['id']] = $comment['member']['link']; |
|
56 | + foreach ($report['comments'] as $comment) { |
|
57 | + $comments[$comment['member']['id']] = $comment['member']['link']; |
|
58 | + } |
|
57 | 59 | |
58 | 60 | echo ' |
59 | 61 | ', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), ' |
@@ -69,18 +71,21 @@ discard block |
||
69 | 71 | <li><a href="', $scripturl, '?action=moderate;area=reportedposts;sa=handle;closed=', (int) !$report['closed'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-closed_token_var'], '=', $context['mod-report-closed_token'], '">', $close_button, '</a></li>'; |
70 | 72 | |
71 | 73 | // Delete message button. |
72 | - if (!$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards']))) |
|
73 | - echo ' |
|
74 | + if (!$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards']))) { |
|
75 | + echo ' |
|
74 | 76 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $report['topic']['id'], '.0;msg=', $report['topic']['id_msg'], ';modcenter;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['mc_reportedp_delete_confirm'], '" class="you_sure">', $delete_button, '</a></li>'; |
77 | + } |
|
75 | 78 | |
76 | 79 | // Ban this user button. |
77 | - if (!$report['closed'] && !empty($context['report_manage_bans'])) |
|
78 | - echo ' |
|
80 | + if (!$report['closed'] && !empty($context['report_manage_bans'])) { |
|
81 | + echo ' |
|
79 | 82 | <li><a href="', $scripturl, '?action=admin;area=ban;sa=add', (!empty($report['author']['id']) ? ';u=' . $report['author']['id'] : ';msg=' . $report['topic']['id_msg']), ';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>'; |
83 | + } |
|
80 | 84 | |
81 | - if (!$context['view_closed']) |
|
82 | - echo ' |
|
85 | + if (!$context['view_closed']) { |
|
86 | + echo ' |
|
83 | 87 | <li><input type="checkbox" name="close[]" value="' . $report['id'] . '"></li>'; |
88 | + } |
|
84 | 89 | |
85 | 90 | echo ' |
86 | 91 | </ul> |
@@ -88,18 +93,20 @@ discard block |
||
88 | 93 | } |
89 | 94 | |
90 | 95 | // Were none found? |
91 | - if (empty($context['reports'])) |
|
92 | - echo ' |
|
96 | + if (empty($context['reports'])) { |
|
97 | + echo ' |
|
93 | 98 | <div class="windowbg"> |
94 | 99 | <p class="centertext">', $txt['mc_reportedp_none_found'], '</p> |
95 | 100 | </div>'; |
101 | + } |
|
96 | 102 | |
97 | 103 | echo ' |
98 | 104 | <div class="pagesection">'; |
99 | 105 | |
100 | - if (!empty($context['total_reports']) && $context['total_reports'] >= $context['reports_how_many']) |
|
101 | - echo ' |
|
106 | + if (!empty($context['total_reports']) && $context['total_reports'] >= $context['reports_how_many']) { |
|
107 | + echo ' |
|
102 | 108 | <div class="pagelinks floatleft">' . $context['page_index'] . '</div>'; |
109 | + } |
|
103 | 110 | |
104 | 111 | echo ' |
105 | 112 | <div class="floatright">', !$context['view_closed'] ? ' |
@@ -130,18 +137,20 @@ discard block |
||
130 | 137 | <div class="modbox"> |
131 | 138 | <ul>'; |
132 | 139 | |
133 | - foreach ($context['reported_posts'] as $report) |
|
134 | - echo ' |
|
140 | + foreach ($context['reported_posts'] as $report) { |
|
141 | + echo ' |
|
135 | 142 | <li class="smalltext"> |
136 | 143 | <a href="', $report['report_href'], '">', $report['subject'], '</a> ', $txt['mc_reportedp_by'], ' ', $report['author']['link'], ' |
137 | 144 | </li>'; |
145 | + } |
|
138 | 146 | |
139 | 147 | // Don't have any watched users right now? |
140 | - if (empty($context['reported_posts'])) |
|
141 | - echo ' |
|
148 | + if (empty($context['reported_posts'])) { |
|
149 | + echo ' |
|
142 | 150 | <li> |
143 | 151 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
144 | 152 | </li>'; |
153 | + } |
|
145 | 154 | |
146 | 155 | echo ' |
147 | 156 | </ul> |
@@ -189,11 +198,12 @@ discard block |
||
189 | 198 | global $context, $scripturl, $txt; |
190 | 199 | |
191 | 200 | // Let them know the action was a success. |
192 | - if (!empty($context['report_post_action'])) |
|
193 | - echo ' |
|
201 | + if (!empty($context['report_post_action'])) { |
|
202 | + echo ' |
|
194 | 203 | <div class="infobox"> |
195 | 204 | ', $txt['report_action_' . $context['report_post_action']], ' |
196 | 205 | </div>'; |
206 | + } |
|
197 | 207 | |
198 | 208 | echo ' |
199 | 209 | <div id="modcenter"> |
@@ -229,14 +239,15 @@ discard block |
||
229 | 239 | <h3 class="catbg">', $txt['mc_modreport_whoreported_title'], '</h3> |
230 | 240 | </div>'; |
231 | 241 | |
232 | - foreach ($context['report']['comments'] as $comment) |
|
233 | - echo ' |
|
242 | + foreach ($context['report']['comments'] as $comment) { |
|
243 | + echo ' |
|
234 | 244 | <div class="windowbg"> |
235 | 245 | <p class="smalltext"> |
236 | 246 | ', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), ' |
237 | 247 | </p> |
238 | 248 | <p>', $comment['message'], '</p> |
239 | 249 | </div>'; |
250 | + } |
|
240 | 251 | |
241 | 252 | echo ' |
242 | 253 | <br> |
@@ -245,11 +256,12 @@ discard block |
||
245 | 256 | </div> |
246 | 257 | <div>'; |
247 | 258 | |
248 | - if (empty($context['report']['mod_comments'])) |
|
249 | - echo ' |
|
259 | + if (empty($context['report']['mod_comments'])) { |
|
260 | + echo ' |
|
250 | 261 | <div class="information"> |
251 | 262 | <p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p> |
252 | 263 | </div>'; |
264 | + } |
|
253 | 265 | |
254 | 266 | foreach ($context['report']['mod_comments'] as $comment) |
255 | 267 | { |
@@ -335,18 +347,20 @@ discard block |
||
335 | 347 | <div class="modbox"> |
336 | 348 | <ul>'; |
337 | 349 | |
338 | - foreach ($context['reported_members'] as $report) |
|
339 | - echo ' |
|
350 | + foreach ($context['reported_members'] as $report) { |
|
351 | + echo ' |
|
340 | 352 | <li class="smalltext"> |
341 | 353 | <a href="', $report['report_href'], '">', $report['user_name'], '</a> |
342 | 354 | </li>'; |
355 | + } |
|
343 | 356 | |
344 | 357 | // Don't have any reported members right now? |
345 | - if (empty($context['reported_members'])) |
|
346 | - echo ' |
|
358 | + if (empty($context['reported_members'])) { |
|
359 | + echo ' |
|
347 | 360 | <li> |
348 | 361 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
349 | 362 | </li>'; |
363 | + } |
|
350 | 364 | |
351 | 365 | echo ' |
352 | 366 | </ul> |
@@ -394,11 +408,12 @@ discard block |
||
394 | 408 | global $context, $txt, $scripturl; |
395 | 409 | |
396 | 410 | // Let them know the action was a success. |
397 | - if (!empty($context['report_post_action']) && !empty($txt['report_action_' . $context['report_post_action']])) |
|
398 | - echo ' |
|
411 | + if (!empty($context['report_post_action']) && !empty($txt['report_action_' . $context['report_post_action']])) { |
|
412 | + echo ' |
|
399 | 413 | <div class="infobox"> |
400 | 414 | ', $txt['report_action_' . $context['report_post_action']], ' |
401 | 415 | </div>'; |
416 | + } |
|
402 | 417 | |
403 | 418 | echo ' |
404 | 419 | <form id="reported_members" action="', $scripturl, '?action=moderate;area=reportedmembers;sa=show', $context['view_closed'] ? ';closed' : '', ';start=', $context['start'], '" method="post" accept-charset="', $context['character_set'], '"> |
@@ -430,8 +445,9 @@ discard block |
||
430 | 445 | |
431 | 446 | // Prepare the comments... |
432 | 447 | $comments = array(); |
433 | - foreach ($report['comments'] as $comment) |
|
434 | - $comments[$comment['member']['id']] = $comment['member']['link']; |
|
448 | + foreach ($report['comments'] as $comment) { |
|
449 | + $comments[$comment['member']['id']] = $comment['member']['link']; |
|
450 | + } |
|
435 | 451 | |
436 | 452 | echo ' |
437 | 453 | ', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), ' |
@@ -443,13 +459,15 @@ discard block |
||
443 | 459 | <li><a href="', $scripturl, '?action=moderate;area=reportedmembers;sa=handle;closed=', (int) !$report['closed'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-closed_token_var'], '=', $context['mod-report-closed_token'], '">', $close_button, '</a></li>'; |
444 | 460 | |
445 | 461 | // Ban this user button. |
446 | - if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id'])) |
|
447 | - echo ' |
|
462 | + if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id'])) { |
|
463 | + echo ' |
|
448 | 464 | <li><a href="', $scripturl, '?action=admin;area=ban;sa=add;u=', $report['user']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>'; |
465 | + } |
|
449 | 466 | |
450 | - if (!$context['view_closed']) |
|
451 | - echo ' |
|
467 | + if (!$context['view_closed']) { |
|
468 | + echo ' |
|
452 | 469 | <li><input type="checkbox" name="close[]" value="' . $report['id'] . '"></li>'; |
470 | + } |
|
453 | 471 | |
454 | 472 | echo ' |
455 | 473 | </ul> |
@@ -457,11 +475,12 @@ discard block |
||
457 | 475 | } |
458 | 476 | |
459 | 477 | // Were none found? |
460 | - if (empty($context['reports'])) |
|
461 | - echo ' |
|
478 | + if (empty($context['reports'])) { |
|
479 | + echo ' |
|
462 | 480 | <div class="windowbg"> |
463 | 481 | <p class="centertext">', $txt['mc_reportedp_none_found'], '</p> |
464 | 482 | </div>'; |
483 | + } |
|
465 | 484 | |
466 | 485 | echo ' |
467 | 486 | <div class="pagesection"> |
@@ -482,11 +501,12 @@ discard block |
||
482 | 501 | global $context, $scripturl, $txt; |
483 | 502 | |
484 | 503 | // Let them know the action was a success. |
485 | - if (!empty($context['report_post_action'])) |
|
486 | - echo ' |
|
504 | + if (!empty($context['report_post_action'])) { |
|
505 | + echo ' |
|
487 | 506 | <div class="infobox"> |
488 | 507 | ', $txt['report_action_' . $context['report_post_action']], ' |
489 | 508 | </div>'; |
509 | + } |
|
490 | 510 | |
491 | 511 | echo ' |
492 | 512 | <div id="modcenter"> |
@@ -519,14 +539,15 @@ discard block |
||
519 | 539 | <h3 class="catbg">', $txt['mc_memberreport_whoreported_title'], '</h3> |
520 | 540 | </div>'; |
521 | 541 | |
522 | - foreach ($context['report']['comments'] as $comment) |
|
523 | - echo ' |
|
542 | + foreach ($context['report']['comments'] as $comment) { |
|
543 | + echo ' |
|
524 | 544 | <div class="windowbg"> |
525 | 545 | <p class="smalltext"> |
526 | 546 | ', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), ' |
527 | 547 | </p> |
528 | 548 | <p>', $comment['message'], '</p> |
529 | 549 | </div>'; |
550 | + } |
|
530 | 551 | |
531 | 552 | echo ' |
532 | 553 | <br> |
@@ -535,11 +556,12 @@ discard block |
||
535 | 556 | </div> |
536 | 557 | <div>'; |
537 | 558 | |
538 | - if (empty($context['report']['mod_comments'])) |
|
539 | - echo ' |
|
559 | + if (empty($context['report']['mod_comments'])) { |
|
560 | + echo ' |
|
540 | 561 | <div class="information"> |
541 | 562 | <p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p> |
542 | 563 | </div>'; |
564 | + } |
|
543 | 565 | |
544 | 566 | foreach ($context['report']['mod_comments'] as $comment) |
545 | 567 | { |
@@ -40,9 +40,10 @@ discard block |
||
40 | 40 | <option value="0000"', $context['holiday']['year'] == '0000' ? ' selected' : '', '>', $txt['every_year'], '</option>'; |
41 | 41 | |
42 | 42 | // Show a list of all the years we allow... |
43 | - for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) |
|
44 | - echo ' |
|
43 | + for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) { |
|
44 | + echo ' |
|
45 | 45 | <option value="', $year, '"', $year == $context['holiday']['year'] ? ' selected' : '', '>', $year, '</option>'; |
46 | + } |
|
46 | 47 | |
47 | 48 | echo ' |
48 | 49 | </select> |
@@ -50,9 +51,10 @@ discard block |
||
50 | 51 | <select name="month" id="month" onchange="generateDays();">'; |
51 | 52 | |
52 | 53 | // There are 12 months per year - ensure that they all get listed. |
53 | - for ($month = 1; $month <= 12; $month++) |
|
54 | - echo ' |
|
54 | + for ($month = 1; $month <= 12; $month++) { |
|
55 | + echo ' |
|
55 | 56 | <option value="', $month, '"', $month == $context['holiday']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
57 | + } |
|
56 | 58 | |
57 | 59 | echo ' |
58 | 60 | </select> |
@@ -60,23 +62,25 @@ discard block |
||
60 | 62 | <select name="day" id="day" onchange="generateDays();">'; |
61 | 63 | |
62 | 64 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
63 | - for ($day = 1; $day <= $context['holiday']['last_day']; $day++) |
|
64 | - echo ' |
|
65 | + for ($day = 1; $day <= $context['holiday']['last_day']; $day++) { |
|
66 | + echo ' |
|
65 | 67 | <option value="', $day, '"', $day == $context['holiday']['day'] ? ' selected' : '', '>', $day, '</option>'; |
68 | + } |
|
66 | 69 | |
67 | 70 | echo ' |
68 | 71 | </select> |
69 | 72 | </dd> |
70 | 73 | </dl>'; |
71 | 74 | |
72 | - if ($context['is_new']) |
|
73 | - echo ' |
|
75 | + if ($context['is_new']) { |
|
76 | + echo ' |
|
74 | 77 | <input type="submit" value="', $txt['holidays_button_add'], '" class="button">'; |
75 | - else |
|
76 | - echo ' |
|
78 | + } else { |
|
79 | + echo ' |
|
77 | 80 | <input type="submit" name="edit" value="', $txt['holidays_button_edit'], '" class="button"> |
78 | 81 | <input type="submit" name="delete" value="', $txt['holidays_button_remove'], '" class="button"> |
79 | 82 | <input type="hidden" name="holiday" value="', $context['holiday']['id'], '">'; |
83 | + } |
|
80 | 84 | echo ' |
81 | 85 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
82 | 86 | </div><!-- .windowbg --> |
@@ -55,9 +55,10 @@ discard block |
||
55 | 55 | <legend>', $txt['membergroups_edit_select_group_type'], '</legend> |
56 | 56 | <label for="group_type_private"><input type="radio" name="group_type" id="group_type_private" value="0" checked onclick="swapPostGroup(0);">', $txt['membergroups_group_type_private'], '</label><br>'; |
57 | 57 | |
58 | - if ($context['allow_protected']) |
|
59 | - echo ' |
|
58 | + if ($context['allow_protected']) { |
|
59 | + echo ' |
|
60 | 60 | <label for="group_type_protected"><input type="radio" name="group_type" id="group_type_protected" value="1" onclick="swapPostGroup(0);">', $txt['membergroups_group_type_protected'], '</label><br>'; |
61 | + } |
|
61 | 62 | |
62 | 63 | echo ' |
63 | 64 | <label for="group_type_request"><input type="radio" name="group_type" id="group_type_request" value="2" onclick="swapPostGroup(0);">', $txt['membergroups_group_type_request'], '</label><br> |
@@ -67,14 +68,15 @@ discard block |
||
67 | 68 | </dd>'; |
68 | 69 | } |
69 | 70 | |
70 | - if ($context['post_group'] || $context['undefined_group']) |
|
71 | - echo ' |
|
71 | + if ($context['post_group'] || $context['undefined_group']) { |
|
72 | + echo ' |
|
72 | 73 | <dt id="min_posts_text"> |
73 | 74 | <strong>', $txt['membergroups_min_posts'], ':</strong> |
74 | 75 | </dt> |
75 | 76 | <dd> |
76 | 77 | <input type="number" name="min_posts" id="min_posts_input" size="5"> |
77 | 78 | </dd>'; |
79 | + } |
|
78 | 80 | |
79 | 81 | if (!$context['post_group'] || !empty($modSettings['permission_enable_postgroups'])) |
80 | 82 | { |
@@ -92,9 +94,10 @@ discard block |
||
92 | 94 | <option value="-1">', $txt['membergroups_guests'], '</option> |
93 | 95 | <option value="0" selected>', $txt['membergroups_members'], '</option>'; |
94 | 96 | |
95 | - foreach ($context['groups'] as $group) |
|
96 | - echo ' |
|
97 | + foreach ($context['groups'] as $group) { |
|
98 | + echo ' |
|
97 | 99 | <option value="', $group['id'], '">', $group['name'], '</option>'; |
100 | + } |
|
98 | 101 | |
99 | 102 | echo ' |
100 | 103 | </select> |
@@ -105,9 +108,10 @@ discard block |
||
105 | 108 | <option value="-1">', $txt['membergroups_guests'], '</option> |
106 | 109 | <option value="0" selected>', $txt['membergroups_members'], '</option>'; |
107 | 110 | |
108 | - foreach ($context['groups'] as $group) |
|
109 | - echo ' |
|
111 | + foreach ($context['groups'] as $group) { |
|
112 | + echo ' |
|
110 | 113 | <option value="', $group['id'], '">', $group['name'], '</option>'; |
114 | + } |
|
111 | 115 | |
112 | 116 | echo ' |
113 | 117 | </select> |
@@ -139,8 +143,8 @@ discard block |
||
139 | 143 | <input type="submit" value="', $txt['membergroups_add_group'], '" class="button"> |
140 | 144 | </div><!-- .windowbg -->'; |
141 | 145 | |
142 | - if ($context['undefined_group']) |
|
143 | - echo ' |
|
146 | + if ($context['undefined_group']) { |
|
147 | + echo ' |
|
144 | 148 | <script> |
145 | 149 | function swapPostGroup(isChecked) |
146 | 150 | { |
@@ -150,6 +154,7 @@ discard block |
||
150 | 154 | } |
151 | 155 | swapPostGroup(', $context['post_group'] ? 'true' : 'false', '); |
152 | 156 | </script>'; |
157 | + } |
|
153 | 158 | |
154 | 159 | echo ' |
155 | 160 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -181,14 +186,15 @@ discard block |
||
181 | 186 | <input type="text" name="group_name" id="group_name_input" value="', $context['group']['editable_name'], '" size="30"> |
182 | 187 | </dd>'; |
183 | 188 | |
184 | - if ($context['group']['id'] != 3 && $context['group']['id'] != 4) |
|
185 | - echo ' |
|
189 | + if ($context['group']['id'] != 3 && $context['group']['id'] != 4) { |
|
190 | + echo ' |
|
186 | 191 | <dt id="group_desc_text"> |
187 | 192 | <label for="group_desc_input"><strong>', $txt['membergroups_edit_desc'], ':</strong></label> |
188 | 193 | </dt> |
189 | 194 | <dd> |
190 | 195 | <textarea name="group_desc" id="group_desc_input" rows="4" cols="40">', $context['group']['description'], '</textarea> |
191 | 196 | </dd>'; |
197 | + } |
|
192 | 198 | |
193 | 199 | // Group type... |
194 | 200 | if ($context['group']['allow_post_group']) |
@@ -202,9 +208,10 @@ discard block |
||
202 | 208 | <legend>', $txt['membergroups_edit_select_group_type'], '</legend> |
203 | 209 | <label for="group_type_private"><input type="radio" name="group_type" id="group_type_private" value="0"', !$context['group']['is_post_group'] && $context['group']['type'] == 0 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_private'], '</label><br>'; |
204 | 210 | |
205 | - if ($context['group']['allow_protected']) |
|
206 | - echo ' |
|
211 | + if ($context['group']['allow_protected']) { |
|
212 | + echo ' |
|
207 | 213 | <label for="group_type_protected"><input type="radio" name="group_type" id="group_type_protected" value="1"', $context['group']['type'] == 1 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_protected'], '</label><br>'; |
214 | + } |
|
208 | 215 | |
209 | 216 | echo ' |
210 | 217 | <label for="group_type_request"><input type="radio" name="group_type" id="group_type_request" value="2"', $context['group']['type'] == 2 ? ' checked' : '', ' onclick="swapPostGroup(0);">', $txt['membergroups_group_type_request'], '</label><br> |
@@ -214,8 +221,8 @@ discard block |
||
214 | 221 | </dd>'; |
215 | 222 | } |
216 | 223 | |
217 | - if ($context['group']['id'] != 3 && $context['group']['id'] != 4) |
|
218 | - echo ' |
|
224 | + if ($context['group']['id'] != 3 && $context['group']['id'] != 4) { |
|
225 | + echo ' |
|
219 | 226 | <dt id="group_moderators_text"> |
220 | 227 | <label for="group_moderators"><strong>', $txt['moderators'], ':</strong></label> |
221 | 228 | </dt> |
@@ -233,6 +240,7 @@ discard block |
||
233 | 240 | <option value="2"', $context['group']['hidden'] == 2 ? ' selected' : '', '>', $txt['membergroups_edit_hidden_all'], '</option> |
234 | 241 | </select> |
235 | 242 | </dd>'; |
243 | + } |
|
236 | 244 | |
237 | 245 | // Can they inherit permissions? |
238 | 246 | if ($context['group']['id'] > 1 && $context['group']['id'] != 3) |
@@ -249,9 +257,10 @@ discard block |
||
249 | 257 | <option value="0"', $context['group']['inherited_from'] == 0 ? ' selected' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $txt['membergroups_members'], '</option>'; |
250 | 258 | |
251 | 259 | // For all the inheritable groups show an option. |
252 | - foreach ($context['inheritable_groups'] as $id => $group) |
|
253 | - echo ' |
|
260 | + foreach ($context['inheritable_groups'] as $id => $group) { |
|
261 | + echo ' |
|
254 | 262 | <option value="', $id, '"', $context['group']['inherited_from'] == $id ? ' selected' : '', '>', $txt['membergroups_edit_inherit_permissions_from'], ': ', $group, '</option>'; |
263 | + } |
|
255 | 264 | |
256 | 265 | echo ' |
257 | 266 | </select> |
@@ -259,8 +268,8 @@ discard block |
||
259 | 268 | </dd>'; |
260 | 269 | } |
261 | 270 | |
262 | - if ($context['group']['allow_post_group']) |
|
263 | - echo ' |
|
271 | + if ($context['group']['allow_post_group']) { |
|
272 | + echo ' |
|
264 | 273 | |
265 | 274 | <dt id="min_posts_text"> |
266 | 275 | <label for="min_posts_input"><strong>', $txt['membergroups_min_posts'], ':</strong></label> |
@@ -268,6 +277,7 @@ discard block |
||
268 | 277 | <dd> |
269 | 278 | <input type="number" name="min_posts" id="min_posts_input"', $context['group']['is_post_group'] ? ' value="' . $context['group']['min_posts'] . '"' : '', ' size="6"> |
270 | 279 | </dd>'; |
280 | + } |
|
271 | 281 | |
272 | 282 | echo ' |
273 | 283 | <dt> |
@@ -297,9 +307,10 @@ discard block |
||
297 | 307 | <select name="icon_image" id="icon_image_input">'; |
298 | 308 | |
299 | 309 | // For every possible icon, create an option. |
300 | - foreach ($context['possible_icons'] as $icon) |
|
301 | - echo ' |
|
310 | + foreach ($context['possible_icons'] as $icon) { |
|
311 | + echo ' |
|
302 | 312 | <option value="', $icon, '"', $context['group']['icon_image'] == $icon ? ' selected' : '', '>', $icon, '</option>'; |
313 | + } |
|
303 | 314 | |
304 | 315 | echo ' |
305 | 316 | </select> |
@@ -308,9 +319,10 @@ discard block |
||
308 | 319 | } |
309 | 320 | |
310 | 321 | // No? Hide the entire control. |
311 | - else |
|
312 | - echo ' |
|
322 | + else { |
|
323 | + echo ' |
|
313 | 324 | <input type="hidden" name="icon_image" value="">'; |
325 | + } |
|
314 | 326 | |
315 | 327 | echo ' |
316 | 328 | <dt> |
@@ -322,8 +334,8 @@ discard block |
||
322 | 334 | </dd>'; |
323 | 335 | |
324 | 336 | // Force 2FA for this membergroup? |
325 | - if (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] == 2) |
|
326 | - echo ' |
|
337 | + if (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] == 2) { |
|
338 | + echo ' |
|
327 | 339 | <dt> |
328 | 340 | <label for="group_tfa_force_input"><strong>', $txt['membergroups_tfa_force'], ':</strong></label><br> |
329 | 341 | <span class="smalltext">', $txt['membergroups_tfa_force_note'], '</span> |
@@ -331,6 +343,7 @@ discard block |
||
331 | 343 | <dd> |
332 | 344 | <input type="checkbox" name="group_tfa_force"', $context['group']['tfa_required'] ? ' checked' : '', '> |
333 | 345 | </dd>'; |
346 | + } |
|
334 | 347 | |
335 | 348 | if (!empty($context['categories'])) |
336 | 349 | { |
@@ -341,11 +354,11 @@ discard block |
||
341 | 354 | </dt> |
342 | 355 | <dd>'; |
343 | 356 | |
344 | - if (!empty($context['can_manage_boards'])) |
|
345 | - echo $txt['membergroups_can_manage_access']; |
|
346 | - |
|
347 | - else |
|
348 | - template_add_edit_group_boards_list(); |
|
357 | + if (!empty($context['can_manage_boards'])) { |
|
358 | + echo $txt['membergroups_can_manage_access']; |
|
359 | + } else { |
|
360 | + template_add_edit_group_boards_list(); |
|
361 | + } |
|
349 | 362 | |
350 | 363 | echo ' |
351 | 364 | </dd>'; |
@@ -375,20 +388,21 @@ discard block |
||
375 | 388 | sItemListContainerId: \'moderator_container\', |
376 | 389 | aListItems: ['; |
377 | 390 | |
378 | - foreach ($context['group']['moderators'] as $id_member => $member_name) |
|
379 | - echo ' |
|
391 | + foreach ($context['group']['moderators'] as $id_member => $member_name) { |
|
392 | + echo ' |
|
380 | 393 | { |
381 | 394 | sItemId: ', JavaScriptEscape($id_member), ', |
382 | 395 | sItemName: ', JavaScriptEscape($member_name), ' |
383 | 396 | }', $id_member == $context['group']['last_moderator_id'] ? '' : ','; |
397 | + } |
|
384 | 398 | |
385 | 399 | echo ' |
386 | 400 | ] |
387 | 401 | }); |
388 | 402 | </script>'; |
389 | 403 | |
390 | - if ($context['group']['allow_post_group']) |
|
391 | - echo ' |
|
404 | + if ($context['group']['allow_post_group']) { |
|
405 | + echo ' |
|
392 | 406 | <script> |
393 | 407 | function swapPostGroup(isChecked) |
394 | 408 | { |
@@ -436,7 +450,8 @@ discard block |
||
436 | 450 | |
437 | 451 | swapPostGroup(', $context['group']['is_post_group'] ? 'true' : 'false', '); |
438 | 452 | </script>'; |
439 | -} |
|
453 | + } |
|
454 | + } |
|
440 | 455 | |
441 | 456 | /** |
442 | 457 | * The template for determining which boards a group has access to. |
@@ -454,13 +469,13 @@ discard block |
||
454 | 469 | |
455 | 470 | foreach ($context['categories'] as $category) |
456 | 471 | { |
457 | - if (empty($modSettings['deny_boards_access'])) |
|
458 | - echo ' |
|
472 | + if (empty($modSettings['deny_boards_access'])) { |
|
473 | + echo ' |
|
459 | 474 | <li class="category"> |
460 | 475 | <a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'new_group\'); return false;"><strong>', $category['name'], '</strong></a> |
461 | 476 | <ul>'; |
462 | - else |
|
463 | - echo ' |
|
477 | + } else { |
|
478 | + echo ' |
|
464 | 479 | <li class="category"> |
465 | 480 | <strong>', $category['name'], '</strong> |
466 | 481 | <span class="select_all_box"> |
@@ -473,16 +488,17 @@ discard block |
||
473 | 488 | </select> |
474 | 489 | </span> |
475 | 490 | <ul id="boards_list_', $category['id'], '">'; |
491 | + } |
|
476 | 492 | |
477 | 493 | foreach ($category['boards'] as $board) |
478 | 494 | { |
479 | - if (empty($modSettings['deny_boards_access'])) |
|
480 | - echo ' |
|
495 | + if (empty($modSettings['deny_boards_access'])) { |
|
496 | + echo ' |
|
481 | 497 | <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> |
482 | 498 | <input type="checkbox" name="boardaccess[', $board['id'], ']" id="brd', $board['id'], '" value="allow"', $board['allow'] ? ' checked' : '', '> <label for="brd', $board['id'], '">', $board['name'], '</label> |
483 | 499 | </li>'; |
484 | - else |
|
485 | - echo ' |
|
500 | + } else { |
|
501 | + echo ' |
|
486 | 502 | <li class="board" style="width:100%"> |
487 | 503 | <span style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">', $board['name'], ': </span> |
488 | 504 | <span style="width:50%;float:right"> |
@@ -491,6 +507,7 @@ discard block |
||
491 | 507 | <input type="radio" name="boardaccess[', $board['id'], ']" id="deny_brd', $board['id'], '" value="deny"', $board['deny'] ? ' checked' : '', '> <label for="deny_brd', $board['id'], '">', $txt['permissions_option_deny'], '</label> |
492 | 508 | </span> |
493 | 509 | </li>'; |
510 | + } |
|
494 | 511 | } |
495 | 512 | |
496 | 513 | echo ' |
@@ -501,14 +518,14 @@ discard block |
||
501 | 518 | echo ' |
502 | 519 | </ul>'; |
503 | 520 | |
504 | - if (empty($modSettings['deny_boards_access'])) |
|
505 | - echo ' |
|
521 | + if (empty($modSettings['deny_boards_access'])) { |
|
522 | + echo ' |
|
506 | 523 | <br class="clear"><br> |
507 | 524 | <input type="checkbox" id="checkall_check" onclick="invertAll(this, this.form, \'boardaccess\');"> |
508 | 525 | <label for="checkall_check"><em>', $txt['check_all'], '</em></label> |
509 | 526 | </fieldset>'; |
510 | - else |
|
511 | - echo ' |
|
527 | + } else { |
|
528 | + echo ' |
|
512 | 529 | <br class="clear"> |
513 | 530 | <span class="select_all_box"> |
514 | 531 | <em>', $txt['all'], ': </em> |
@@ -524,15 +541,17 @@ discard block |
||
524 | 541 | }); |
525 | 542 | }); |
526 | 543 | </script>'; |
544 | + } |
|
527 | 545 | |
528 | - if ($collapse) |
|
529 | - echo ' |
|
546 | + if ($collapse) { |
|
547 | + echo ' |
|
530 | 548 | <a href="javascript:void(0);" onclick="document.getElementById(\'visible_boards\').style.display = \'block\'; document.getElementById(\'visible_boards_link\').style.display = \'none\'; return false;" id="visible_boards_link" style="display: none;">[ ', $txt['membergroups_select_visible_boards'], ' ]</a> |
531 | 549 | <script> |
532 | 550 | document.getElementById("visible_boards_link").style.display = ""; |
533 | 551 | document.getElementById("visible_boards").style.display = "none"; |
534 | 552 | </script>'; |
535 | -} |
|
553 | + } |
|
554 | + } |
|
536 | 555 | |
537 | 556 | /** |
538 | 557 | * Templatine for viewing the members of a group. |
@@ -557,14 +576,15 @@ discard block |
||
557 | 576 | </dd>'; |
558 | 577 | |
559 | 578 | // Any description to show? |
560 | - if (!empty($context['group']['description'])) |
|
561 | - echo ' |
|
579 | + if (!empty($context['group']['description'])) { |
|
580 | + echo ' |
|
562 | 581 | <dt> |
563 | 582 | <strong>' . $txt['membergroups_members_description'] . ':</strong> |
564 | 583 | </dt> |
565 | 584 | <dd> |
566 | 585 | ', $context['group']['description'], ' |
567 | 586 | </dd>'; |
587 | + } |
|
568 | 588 | |
569 | 589 | echo ' |
570 | 590 | <dt> |
@@ -578,8 +598,9 @@ discard block |
||
578 | 598 | if (!empty($context['group']['moderators'])) |
579 | 599 | { |
580 | 600 | $moderators = array(); |
581 | - foreach ($context['group']['moderators'] as $moderator) |
|
582 | - $moderators[] = '<a href="' . $scripturl . '?action=profile;u=' . $moderator['id'] . '">' . $moderator['name'] . '</a>'; |
|
601 | + foreach ($context['group']['moderators'] as $moderator) { |
|
602 | + $moderators[] = '<a href="' . $scripturl . '?action=profile;u=' . $moderator['id'] . '">' . $moderator['name'] . '</a>'; |
|
603 | + } |
|
583 | 604 | |
584 | 605 | echo ' |
585 | 606 | <dt> |
@@ -604,9 +625,10 @@ discard block |
||
604 | 625 | <tr class="title_bar"> |
605 | 626 | <th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=name', $context['sort_by'] == 'name' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['name'], $context['sort_by'] == 'name' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th>'; |
606 | 627 | |
607 | - if ($context['can_send_email']) |
|
608 | - echo ' |
|
628 | + if ($context['can_send_email']) { |
|
629 | + echo ' |
|
609 | 630 | <th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=email', $context['sort_by'] == 'email' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['email'], $context['sort_by'] == 'email' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th>'; |
631 | + } |
|
610 | 632 | |
611 | 633 | echo ' |
612 | 634 | <th><a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=active', $context['sort_by'] == 'active' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['membergroups_members_last_active'], $context['sort_by'] == 'active' ? '<span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a></th> |
@@ -615,20 +637,22 @@ discard block |
||
615 | 637 | <a href="', $scripturl, '?action=', $context['current_action'], (isset($context['admin_area']) ? ';area=' . $context['admin_area'] : ''), ';sa=members;start=', $context['start'], ';sort=posts', $context['sort_by'] == 'posts' && $context['sort_direction'] == 'up' ? ';desc' : '', ';group=', $context['group']['id'], '">', $txt['posts'], $context['sort_by'] == 'posts' ? ' <span class="generic_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a> |
616 | 638 | </th>'; |
617 | 639 | |
618 | - if (!empty($context['group']['assignable'])) |
|
619 | - echo ' |
|
640 | + if (!empty($context['group']['assignable'])) { |
|
641 | + echo ' |
|
620 | 642 | <th style="width: 4%"><input type="checkbox" onclick="invertAll(this, this.form);"></th>'; |
643 | + } |
|
621 | 644 | |
622 | 645 | echo ' |
623 | 646 | </tr> |
624 | 647 | </thead> |
625 | 648 | <tbody>'; |
626 | 649 | |
627 | - if (empty($context['members'])) |
|
628 | - echo ' |
|
650 | + if (empty($context['members'])) { |
|
651 | + echo ' |
|
629 | 652 | <tr class="windowbg"> |
630 | 653 | <td colspan="6">', $txt['membergroups_members_no_members'], '</td> |
631 | 654 | </tr>'; |
655 | + } |
|
632 | 656 | |
633 | 657 | foreach ($context['members'] as $member) |
634 | 658 | { |
@@ -636,20 +660,22 @@ discard block |
||
636 | 660 | <tr class="windowbg"> |
637 | 661 | <td>', $member['name'], '</td>'; |
638 | 662 | |
639 | - if ($context['can_send_email']) |
|
640 | - echo ' |
|
663 | + if ($context['can_send_email']) { |
|
664 | + echo ' |
|
641 | 665 | <td> |
642 | 666 | <a href="mailto:', $member['email'], '">', $member['email'], '</a> |
643 | 667 | </td>'; |
668 | + } |
|
644 | 669 | |
645 | 670 | echo ' |
646 | 671 | <td>', $member['last_online'], '</td> |
647 | 672 | <td>', $member['registered'], '</td> |
648 | 673 | <td', empty($context['group']['assignable']) ? ' colspan="2"' : '', '>', $member['posts'], '</td>'; |
649 | 674 | |
650 | - if (!empty($context['group']['assignable'])) |
|
651 | - echo ' |
|
675 | + if (!empty($context['group']['assignable'])) { |
|
676 | + echo ' |
|
652 | 677 | <td style="width: 4%"><input type="checkbox" name="rem[]" value="', $member['id'], '" ', ($context['user']['id'] == $member['id'] && $context['group']['id'] == 1 ? 'onclick="if (this.checked) return confirm(\'' . $txt['membergroups_members_deadmin_confirm'] . '\')" ' : ''), '/></td>'; |
678 | + } |
|
653 | 679 | |
654 | 680 | echo ' |
655 | 681 | </tr>'; |
@@ -659,11 +685,12 @@ discard block |
||
659 | 685 | </tbody> |
660 | 686 | </table>'; |
661 | 687 | |
662 | - if (!empty($context['group']['assignable'])) |
|
663 | - echo ' |
|
688 | + if (!empty($context['group']['assignable'])) { |
|
689 | + echo ' |
|
664 | 690 | <div class="floatright"> |
665 | 691 | <input type="submit" name="remove" value="', $txt['membergroups_members_remove'], '" class="button "> |
666 | 692 | </div>'; |
693 | + } |
|
667 | 694 | |
668 | 695 | echo ' |
669 | 696 | <div class="pagesection flow_hidden"> |
@@ -671,8 +698,8 @@ discard block |
||
671 | 698 | </div> |
672 | 699 | <br>'; |
673 | 700 | |
674 | - if (!empty($context['group']['assignable'])) |
|
675 | - echo ' |
|
701 | + if (!empty($context['group']['assignable'])) { |
|
702 | + echo ' |
|
676 | 703 | <div class="cat_bar"> |
677 | 704 | <h3 class="catbg">', $txt['membergroups_members_add_title'], '</h3> |
678 | 705 | </div> |
@@ -688,6 +715,7 @@ discard block |
||
688 | 715 | </dl> |
689 | 716 | <input type="submit" name="add" value="', $txt['membergroups_members_add'], '" class="button"> |
690 | 717 | </div>'; |
718 | + } |
|
691 | 719 | |
692 | 720 | echo ' |
693 | 721 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -695,8 +723,8 @@ discard block |
||
695 | 723 | </form> |
696 | 724 | </div><!-- #admincenter -->'; |
697 | 725 | |
698 | - if (!empty($context['group']['assignable'])) |
|
699 | - echo ' |
|
726 | + if (!empty($context['group']['assignable'])) { |
|
727 | + echo ' |
|
700 | 728 | <script> |
701 | 729 | var oAddMemberSuggest = new smc_AutoSuggest({ |
702 | 730 | sSelf: \'oAddMemberSuggest\', |
@@ -712,7 +740,8 @@ discard block |
||
712 | 740 | sItemListContainerId: \'toAddItemContainer\' |
713 | 741 | }); |
714 | 742 | </script>'; |
715 | -} |
|
743 | + } |
|
744 | + } |
|
716 | 745 | |
717 | 746 | /** |
718 | 747 | * Allow the moderator to enter a reason to each user being rejected. |
@@ -732,8 +761,8 @@ discard block |
||
732 | 761 | <dl class="settings">'; |
733 | 762 | |
734 | 763 | // Loop through and print out a reason box for each... |
735 | - foreach ($context['group_requests'] as $request) |
|
736 | - echo ' |
|
764 | + foreach ($context['group_requests'] as $request) { |
|
765 | + echo ' |
|
737 | 766 | <dt> |
738 | 767 | <strong>', sprintf($txt['mc_groupr_reason_desc'], $request['member_link'], $request['group_link']), ':</strong> |
739 | 768 | </dt> |
@@ -741,6 +770,7 @@ discard block |
||
741 | 770 | <input type="hidden" name="groupr[]" value="', $request['id'], '"> |
742 | 771 | <textarea name="groupreason[', $request['id'], ']" rows="3" cols="40"></textarea> |
743 | 772 | </dd>'; |
773 | + } |
|
744 | 774 | |
745 | 775 | echo ' |
746 | 776 | </dl> |
@@ -106,7 +106,7 @@ |
||
106 | 106 | if (!empty($context['custom_profile_fields']['columns'])) |
107 | 107 | foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
108 | 108 | echo ' |
109 | - <td class="' , $key , ' centertext">', $member['options'][$key], '</td>'; |
|
109 | + <td class="' , $key, ' centertext">', $member['options'][$key], '</td>'; |
|
110 | 110 | |
111 | 111 | echo ' |
112 | 112 | </tr>'; |
@@ -27,9 +27,10 @@ discard block |
||
27 | 27 | <h3 class="catbg"> |
28 | 28 | <span class="floatleft">', $txt['members_list'], '</span>'; |
29 | 29 | |
30 | - if (!isset($context['old_search'])) |
|
31 | - echo ' |
|
30 | + if (!isset($context['old_search'])) { |
|
31 | + echo ' |
|
32 | 32 | <span class="floatright">', $context['letter_links'], '</span>'; |
33 | + } |
|
33 | 34 | echo ' |
34 | 35 | </h3> |
35 | 36 | </div>'; |
@@ -44,20 +45,23 @@ discard block |
||
44 | 45 | foreach ($context['columns'] as $key => $column) |
45 | 46 | { |
46 | 47 | // @TODO maybe find something nicer? |
47 | - if ($key == 'email_address' && !$context['can_send_email']) |
|
48 | - continue; |
|
48 | + if ($key == 'email_address' && !$context['can_send_email']) { |
|
49 | + continue; |
|
50 | + } |
|
49 | 51 | |
50 | 52 | // This is a selected column, so underline it or some such. |
51 | - if ($column['selected']) |
|
52 | - echo ' |
|
53 | + if ($column['selected']) { |
|
54 | + echo ' |
|
53 | 55 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '> |
54 | 56 | <a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>'; |
57 | + } |
|
55 | 58 | |
56 | 59 | // This is just some column... show the link and be done with it. |
57 | - else |
|
58 | - echo ' |
|
60 | + else { |
|
61 | + echo ' |
|
59 | 62 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '> |
60 | 63 | ', $column['link'], '</th>'; |
64 | + } |
|
61 | 65 | } |
62 | 66 | |
63 | 67 | echo ' |
@@ -77,9 +81,10 @@ discard block |
||
77 | 81 | </td> |
78 | 82 | <td class="real_name lefttext">', $member['link'], '</td>'; |
79 | 83 | |
80 | - if (!isset($context['disabled_fields']['website'])) |
|
81 | - echo ' |
|
84 | + if (!isset($context['disabled_fields']['website'])) { |
|
85 | + echo ' |
|
82 | 86 | <td class="website_url centertext">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" rel="noopener"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>'; |
87 | + } |
|
83 | 88 | |
84 | 89 | // Group and date. |
85 | 90 | echo ' |
@@ -92,32 +97,35 @@ discard block |
||
92 | 97 | <td class="post_count centertext">', $member['posts'], '</td> |
93 | 98 | <td class="statsbar">'; |
94 | 99 | |
95 | - if (!empty($member['post_percent'])) |
|
96 | - echo ' |
|
100 | + if (!empty($member['post_percent'])) { |
|
101 | + echo ' |
|
97 | 102 | <div class="generic_bar"> |
98 | 103 | <div class="bar" style="width: ', $member['post_percent'], '%;"></div> |
99 | 104 | </div>'; |
105 | + } |
|
100 | 106 | |
101 | 107 | echo ' |
102 | 108 | </td>'; |
103 | 109 | } |
104 | 110 | |
105 | 111 | // Show custom fields marked to be shown here |
106 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
107 | - foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
112 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
113 | + foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
108 | 114 | echo ' |
109 | 115 | <td class="' , $key , ' centertext">', $member['options'][$key], '</td>'; |
116 | + } |
|
110 | 117 | |
111 | 118 | echo ' |
112 | 119 | </tr>'; |
113 | 120 | } |
114 | 121 | } |
115 | 122 | // No members? |
116 | - else |
|
117 | - echo ' |
|
123 | + else { |
|
124 | + echo ' |
|
118 | 125 | <tr> |
119 | 126 | <td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td> |
120 | 127 | </tr>'; |
128 | + } |
|
121 | 129 | |
122 | 130 | echo ' |
123 | 131 | </tbody> |
@@ -130,11 +138,12 @@ discard block |
||
130 | 138 | <div class="pagelinks floatleft">', $context['page_index'], '</div>'; |
131 | 139 | |
132 | 140 | // If it is displaying the result of a search show a "search again" link to edit their criteria. |
133 | - if (isset($context['old_search'])) |
|
134 | - echo ' |
|
141 | + if (isset($context['old_search'])) { |
|
142 | + echo ' |
|
135 | 143 | <div class="buttonlist floatright"> |
136 | 144 | <a class="button" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a> |
137 | 145 | </div>'; |
146 | + } |
|
138 | 147 | echo ' |
139 | 148 | </div> |
140 | 149 | </div><!-- #memberlist -->'; |
@@ -174,12 +183,13 @@ discard block |
||
174 | 183 | <dd> |
175 | 184 | <ul>'; |
176 | 185 | |
177 | - foreach ($context['search_fields'] as $id => $title) |
|
178 | - echo ' |
|
186 | + foreach ($context['search_fields'] as $id => $title) { |
|
187 | + echo ' |
|
179 | 188 | <li> |
180 | 189 | <input type="checkbox" name="fields[]" id="fields-', $id, '" value="', $id, '"', in_array($id, $context['search_defaults']) ? ' checked' : '', '> |
181 | 190 | <label for="fields-', $id, '">', $title, '</label> |
182 | 191 | </li>'; |
192 | + } |
|
183 | 193 | |
184 | 194 | echo ' |
185 | 195 | </ul> |
@@ -18,11 +18,12 @@ discard block |
||
18 | 18 | global $context, $txt, $scripturl, $modSettings; |
19 | 19 | |
20 | 20 | // If maintenance has finished tell the user. |
21 | - if (!empty($context['maintenance_finished'])) |
|
22 | - echo ' |
|
21 | + if (!empty($context['maintenance_finished'])) { |
|
22 | + echo ' |
|
23 | 23 | <div class="infobox"> |
24 | 24 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
25 | 25 | </div>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | echo ' |
28 | 29 | <div id="manage_maintenance"> |
@@ -39,8 +40,8 @@ discard block |
||
39 | 40 | </div>'; |
40 | 41 | |
41 | 42 | // Show an option to convert the body column of the post table to MEDIUMTEXT or TEXT |
42 | - if (isset($context['convert_to'])) |
|
43 | - echo ' |
|
43 | + if (isset($context['convert_to'])) { |
|
44 | + echo ' |
|
44 | 45 | <div class="cat_bar"> |
45 | 46 | <h3 class="catbg">', $txt[$context['convert_to'] . '_title'], '</h3> |
46 | 47 | </div> |
@@ -53,10 +54,11 @@ discard block |
||
53 | 54 | <input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '"> |
54 | 55 | </form> |
55 | 56 | </div>'; |
57 | + } |
|
56 | 58 | |
57 | 59 | // We might want to convert entities if we're on UTF-8. |
58 | - if ($context['convert_entities']) |
|
59 | - echo ' |
|
60 | + if ($context['convert_entities']) { |
|
61 | + echo ' |
|
60 | 62 | <div class="cat_bar"> |
61 | 63 | <h3 class="catbg">', $txt['entity_convert_title'], '</h3> |
62 | 64 | </div> |
@@ -68,6 +70,7 @@ discard block |
||
68 | 70 | <input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '"> |
69 | 71 | </form> |
70 | 72 | </div>'; |
73 | + } |
|
71 | 74 | |
72 | 75 | echo ' |
73 | 76 | </div><!-- #manage_maintenance -->'; |
@@ -85,11 +88,12 @@ discard block |
||
85 | 88 | <div id="manage_maintenance">'; |
86 | 89 | |
87 | 90 | // If maintenance has finished tell the user. |
88 | - if (!empty($context['maintenance_finished'])) |
|
89 | - echo ' |
|
91 | + if (!empty($context['maintenance_finished'])) { |
|
92 | + echo ' |
|
90 | 93 | <div class="infobox"> |
91 | 94 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
92 | 95 | </div>'; |
96 | + } |
|
93 | 97 | |
94 | 98 | echo ' |
95 | 99 | <div class="cat_bar"> |
@@ -221,11 +225,12 @@ discard block |
||
221 | 225 | <div id="manage_maintenance">'; |
222 | 226 | |
223 | 227 | // If maintenance has finished, tell the user. |
224 | - if (!empty($context['maintenance_finished'])) |
|
225 | - echo ' |
|
228 | + if (!empty($context['maintenance_finished'])) { |
|
229 | + echo ' |
|
226 | 230 | <div class="infobox"> |
227 | 231 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
228 | 232 | </div>'; |
233 | + } |
|
229 | 234 | |
230 | 235 | echo ' |
231 | 236 | <div class="cat_bar"> |
@@ -287,9 +292,10 @@ discard block |
||
287 | 292 | </p> |
288 | 293 | <div style="display: none;" id="membersPanel">'; |
289 | 294 | |
290 | - foreach ($context['membergroups'] as $group) |
|
291 | - echo ' |
|
295 | + foreach ($context['membergroups'] as $group) { |
|
296 | + echo ' |
|
292 | 297 | <label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked> ', $group['name'], '</label><br>'; |
298 | + } |
|
293 | 299 | |
294 | 300 | echo ' |
295 | 301 | </div> |
@@ -333,11 +339,12 @@ discard block |
||
333 | 339 | global $scripturl, $txt, $context, $settings, $modSettings; |
334 | 340 | |
335 | 341 | // If maintenance has finished tell the user. |
336 | - if (!empty($context['maintenance_finished'])) |
|
337 | - echo ' |
|
342 | + if (!empty($context['maintenance_finished'])) { |
|
343 | + echo ' |
|
338 | 344 | <div class="infobox"> |
339 | 345 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
340 | 346 | </div>'; |
347 | + } |
|
341 | 348 | |
342 | 349 | // Bit of javascript for showing which boards to prune in an otherwise hidden list. |
343 | 350 | echo ' |
@@ -405,21 +412,23 @@ discard block |
||
405 | 412 | <ul>'; |
406 | 413 | |
407 | 414 | // Display a checkbox with every board. |
408 | - foreach ($category['boards'] as $board) |
|
409 | - echo ' |
|
415 | + foreach ($category['boards'] as $board) { |
|
416 | + echo ' |
|
410 | 417 | <li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;"> |
411 | 418 | <label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked>', $board['name'], '</label> |
412 | 419 | </li>'; |
420 | + } |
|
413 | 421 | |
414 | 422 | echo ' |
415 | 423 | </ul> |
416 | 424 | </fieldset>'; |
417 | 425 | |
418 | 426 | // Increase $i, and check if we're at the middle yet. |
419 | - if (++$i == $middle) |
|
420 | - echo ' |
|
427 | + if (++$i == $middle) { |
|
428 | + echo ' |
|
421 | 429 | </div><!-- .floatleft --> |
422 | 430 | <div class="floatright" style="width: 49%;">'; |
431 | + } |
|
423 | 432 | } |
424 | 433 | |
425 | 434 | echo ' |
@@ -461,9 +470,10 @@ discard block |
||
461 | 470 | echo ' |
462 | 471 | <optgroup label="', $category['name'], '">'; |
463 | 472 | |
464 | - foreach ($category['boards'] as $board) |
|
465 | - echo ' |
|
473 | + foreach ($category['boards'] as $board) { |
|
474 | + echo ' |
|
466 | 475 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
476 | + } |
|
467 | 477 | |
468 | 478 | echo ' |
469 | 479 | </optgroup>'; |
@@ -481,9 +491,10 @@ discard block |
||
481 | 491 | echo ' |
482 | 492 | <optgroup label="', $category['name'], '">'; |
483 | 493 | |
484 | - foreach ($category['boards'] as $board) |
|
485 | - echo ' |
|
494 | + foreach ($category['boards'] as $board) { |
|
495 | + echo ' |
|
486 | 496 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
497 | + } |
|
487 | 498 | |
488 | 499 | echo ' |
489 | 500 | </optgroup>'; |
@@ -526,9 +537,10 @@ discard block |
||
526 | 537 | ', $txt['database_optimize_attempt'], '<br>'; |
527 | 538 | |
528 | 539 | // List each table being optimized... |
529 | - foreach ($context['optimized_tables'] as $table) |
|
530 | - echo ' |
|
540 | + foreach ($context['optimized_tables'] as $table) { |
|
541 | + echo ' |
|
531 | 542 | ', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>'; |
543 | + } |
|
532 | 544 | |
533 | 545 | // How did we go? |
534 | 546 | echo ' |
@@ -588,13 +600,14 @@ discard block |
||
588 | 600 | </li> |
589 | 601 | </ul>'; |
590 | 602 | |
591 | - if (!empty($context['exceeding_messages_morethan'])) |
|
592 | - echo ' |
|
603 | + if (!empty($context['exceeding_messages_morethan'])) { |
|
604 | + echo ' |
|
593 | 605 | <p>', $context['exceeding_messages_morethan'], '</p>'; |
594 | - } |
|
595 | - else |
|
596 | - echo ' |
|
606 | + } |
|
607 | + } else { |
|
608 | + echo ' |
|
597 | 609 | <p class="infobox">', $txt['convert_to_text'], '</p>'; |
610 | + } |
|
598 | 611 | |
599 | 612 | echo ' |
600 | 613 | <form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '"> |