@@ -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']('', ' |
@@ -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 | * This function works out what to do! |
@@ -24,9 +25,9 @@ discard block |
||
24 | 25 | global $time_start, $smcFunc; |
25 | 26 | |
26 | 27 | // Special case for doing the mail queue. |
27 | - if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') |
|
28 | - ReduceMailQueue(); |
|
29 | - else |
|
28 | + if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') { |
|
29 | + ReduceMailQueue(); |
|
30 | + } else |
|
30 | 31 | { |
31 | 32 | $task_string = ''; |
32 | 33 | |
@@ -53,18 +54,20 @@ discard block |
||
53 | 54 | |
54 | 55 | // How long in seconds it the gap? |
55 | 56 | $duration = $row['time_regularity']; |
56 | - if ($row['time_unit'] == 'm') |
|
57 | - $duration *= 60; |
|
58 | - elseif ($row['time_unit'] == 'h') |
|
59 | - $duration *= 3600; |
|
60 | - elseif ($row['time_unit'] == 'd') |
|
61 | - $duration *= 86400; |
|
62 | - elseif ($row['time_unit'] == 'w') |
|
63 | - $duration *= 604800; |
|
57 | + if ($row['time_unit'] == 'm') { |
|
58 | + $duration *= 60; |
|
59 | + } elseif ($row['time_unit'] == 'h') { |
|
60 | + $duration *= 3600; |
|
61 | + } elseif ($row['time_unit'] == 'd') { |
|
62 | + $duration *= 86400; |
|
63 | + } elseif ($row['time_unit'] == 'w') { |
|
64 | + $duration *= 604800; |
|
65 | + } |
|
64 | 66 | |
65 | 67 | // If we were really late running this task actually skip the next one. |
66 | - if (time() + ($duration / 2) > $next_time) |
|
67 | - $next_time += $duration; |
|
68 | + if (time() + ($duration / 2) > $next_time) { |
|
69 | + $next_time += $duration; |
|
70 | + } |
|
68 | 71 | |
69 | 72 | // Update it now, so no others run this! |
70 | 73 | $smcFunc['db_query']('', ' |
@@ -81,16 +84,19 @@ discard block |
||
81 | 84 | $affected_rows = $smcFunc['db_affected_rows'](); |
82 | 85 | |
83 | 86 | // What kind of task are we handling? |
84 | - if (!empty($row['callable'])) |
|
85 | - $task_string = $row['callable']; |
|
87 | + if (!empty($row['callable'])) { |
|
88 | + $task_string = $row['callable']; |
|
89 | + } |
|
86 | 90 | |
87 | 91 | // Default SMF task or old mods? |
88 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
89 | - $task_string = 'scheduled_' . $row['task']; |
|
92 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
93 | + $task_string = 'scheduled_' . $row['task']; |
|
94 | + } |
|
90 | 95 | |
91 | 96 | // One last resource, the task name. |
92 | - elseif (!empty($row['task'])) |
|
93 | - $task_string = $row['task']; |
|
97 | + elseif (!empty($row['task'])) { |
|
98 | + $task_string = $row['task']; |
|
99 | + } |
|
94 | 100 | |
95 | 101 | // The function must exist or we are wasting our time, plus do some timestamp checking, and database check! |
96 | 102 | if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) |
@@ -101,11 +107,11 @@ discard block |
||
101 | 107 | $callable_task = call_helper($task_string, true); |
102 | 108 | |
103 | 109 | // Perform the task. |
104 | - if (!empty($callable_task)) |
|
105 | - $completed = call_user_func($callable_task); |
|
106 | - |
|
107 | - else |
|
108 | - $completed = false; |
|
110 | + if (!empty($callable_task)) { |
|
111 | + $completed = call_user_func($callable_task); |
|
112 | + } else { |
|
113 | + $completed = false; |
|
114 | + } |
|
109 | 115 | |
110 | 116 | // Log that we did it ;) |
111 | 117 | if ($completed) |
@@ -138,18 +144,20 @@ discard block |
||
138 | 144 | ) |
139 | 145 | ); |
140 | 146 | // No new task scheduled yet? |
141 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
142 | - $nextEvent = time() + 86400; |
|
143 | - else |
|
144 | - list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
147 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
148 | + $nextEvent = time() + 86400; |
|
149 | + } else { |
|
150 | + list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
151 | + } |
|
145 | 152 | $smcFunc['db_free_result']($request); |
146 | 153 | |
147 | 154 | updateSettings(array('next_task_time' => $nextEvent)); |
148 | 155 | } |
149 | 156 | |
150 | 157 | // Shall we return? |
151 | - if (!isset($_GET['scheduled'])) |
|
152 | - return true; |
|
158 | + if (!isset($_GET['scheduled'])) { |
|
159 | + return true; |
|
160 | + } |
|
153 | 161 | |
154 | 162 | // Finally, send some stuff... |
155 | 163 | header('expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -181,16 +189,18 @@ discard block |
||
181 | 189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
182 | 190 | { |
183 | 191 | // If this is no longer around we'll ignore it. |
184 | - if (empty($row['id_topic'])) |
|
185 | - continue; |
|
192 | + if (empty($row['id_topic'])) { |
|
193 | + continue; |
|
194 | + } |
|
186 | 195 | |
187 | 196 | // What type is it? |
188 | - if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) |
|
189 | - $type = 'topic'; |
|
190 | - elseif ($row['id_attach']) |
|
191 | - $type = 'attach'; |
|
192 | - else |
|
193 | - $type = 'msg'; |
|
197 | + if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) { |
|
198 | + $type = 'topic'; |
|
199 | + } elseif ($row['id_attach']) { |
|
200 | + $type = 'attach'; |
|
201 | + } else { |
|
202 | + $type = 'msg'; |
|
203 | + } |
|
194 | 204 | |
195 | 205 | // Add it to the array otherwise. |
196 | 206 | $notices[$row['id_board']][$type][] = array( |
@@ -211,8 +221,9 @@ discard block |
||
211 | 221 | ); |
212 | 222 | |
213 | 223 | // If nothing quit now. |
214 | - if (empty($notices)) |
|
215 | - return true; |
|
224 | + if (empty($notices)) { |
|
225 | + return true; |
|
226 | + } |
|
216 | 227 | |
217 | 228 | // Now we need to think about finding out *who* can approve - this is hard! |
218 | 229 | |
@@ -231,14 +242,16 @@ discard block |
||
231 | 242 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
232 | 243 | { |
233 | 244 | // Sorry guys, but we have to ignore guests AND members - it would be too many otherwise. |
234 | - if ($row['id_group'] < 2) |
|
235 | - continue; |
|
245 | + if ($row['id_group'] < 2) { |
|
246 | + continue; |
|
247 | + } |
|
236 | 248 | |
237 | 249 | $perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group']; |
238 | 250 | |
239 | 251 | // Anyone who can access has to be considered. |
240 | - if ($row['add_deny']) |
|
241 | - $addGroups[] = $row['id_group']; |
|
252 | + if ($row['add_deny']) { |
|
253 | + $addGroups[] = $row['id_group']; |
|
254 | + } |
|
242 | 255 | } |
243 | 256 | $smcFunc['db_free_result']($request); |
244 | 257 | |
@@ -283,8 +296,9 @@ discard block |
||
283 | 296 | if (!empty($row['mod_prefs'])) |
284 | 297 | { |
285 | 298 | list(,, $pref_binary) = explode('|', $row['mod_prefs']); |
286 | - if (!($pref_binary & 4)) |
|
287 | - continue; |
|
299 | + if (!($pref_binary & 4)) { |
|
300 | + continue; |
|
301 | + } |
|
288 | 302 | } |
289 | 303 | |
290 | 304 | $members[$row['id_member']] = array( |
@@ -309,8 +323,9 @@ discard block |
||
309 | 323 | $emailbody = ''; |
310 | 324 | |
311 | 325 | // Load the language file as required. |
312 | - if (empty($current_language) || $current_language != $member['language']) |
|
313 | - $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
326 | + if (empty($current_language) || $current_language != $member['language']) { |
|
327 | + $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
328 | + } |
|
314 | 329 | |
315 | 330 | // Loop through each notice... |
316 | 331 | foreach ($notices as $board => $notice) |
@@ -318,29 +333,34 @@ discard block |
||
318 | 333 | $access = false; |
319 | 334 | |
320 | 335 | // Can they mod in this board? |
321 | - if (isset($mods[$id][$board])) |
|
322 | - $access = true; |
|
336 | + if (isset($mods[$id][$board])) { |
|
337 | + $access = true; |
|
338 | + } |
|
323 | 339 | |
324 | 340 | // Do the group check... |
325 | 341 | if (!$access && isset($perms[$profiles[$board]]['add'])) |
326 | 342 | { |
327 | 343 | // They can access?! |
328 | - if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) |
|
329 | - $access = true; |
|
344 | + if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) { |
|
345 | + $access = true; |
|
346 | + } |
|
330 | 347 | |
331 | 348 | // If they have deny rights don't consider them! |
332 | - if (isset($perms[$profiles[$board]]['deny'])) |
|
333 | - if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
349 | + if (isset($perms[$profiles[$board]]['deny'])) { |
|
350 | + if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
334 | 351 | $access = false; |
352 | + } |
|
335 | 353 | } |
336 | 354 | |
337 | 355 | // Finally, fix it for admins! |
338 | - if (in_array(1, $member['groups'])) |
|
339 | - $access = true; |
|
356 | + if (in_array(1, $member['groups'])) { |
|
357 | + $access = true; |
|
358 | + } |
|
340 | 359 | |
341 | 360 | // If they can't access it then give it a break! |
342 | - if (!$access) |
|
343 | - continue; |
|
361 | + if (!$access) { |
|
362 | + continue; |
|
363 | + } |
|
344 | 364 | |
345 | 365 | foreach ($notice as $type => $items) |
346 | 366 | { |
@@ -348,15 +368,17 @@ discard block |
||
348 | 368 | $emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" . |
349 | 369 | '------------------------------------------------------' . "\n"; |
350 | 370 | |
351 | - foreach ($items as $item) |
|
352 | - $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
371 | + foreach ($items as $item) { |
|
372 | + $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
373 | + } |
|
353 | 374 | |
354 | 375 | $emailbody .= "\n"; |
355 | 376 | } |
356 | 377 | } |
357 | 378 | |
358 | - if ($emailbody == '') |
|
359 | - continue; |
|
379 | + if ($emailbody == '') { |
|
380 | + continue; |
|
381 | + } |
|
360 | 382 | |
361 | 383 | $replacements = array( |
362 | 384 | 'REALNAME' => $member['name'], |
@@ -397,8 +419,9 @@ discard block |
||
397 | 419 | ) |
398 | 420 | ); |
399 | 421 | $members = array(); |
400 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
401 | - $members[$row['id_member']] = $row['warning']; |
|
422 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
423 | + $members[$row['id_member']] = $row['warning']; |
|
424 | + } |
|
402 | 425 | $smcFunc['db_free_result']($request); |
403 | 426 | |
404 | 427 | // Have some members to check? |
@@ -420,17 +443,18 @@ discard block |
||
420 | 443 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
421 | 444 | { |
422 | 445 | // More than 24 hours ago? |
423 | - if ($row['last_warning'] <= time() - 86400) |
|
424 | - $member_changes[] = array( |
|
446 | + if ($row['last_warning'] <= time() - 86400) { |
|
447 | + $member_changes[] = array( |
|
425 | 448 | 'id' => $row['id_recipient'], |
426 | 449 | 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0, |
427 | 450 | ); |
451 | + } |
|
428 | 452 | } |
429 | 453 | $smcFunc['db_free_result']($request); |
430 | 454 | |
431 | 455 | // Have some members to change? |
432 | - if (!empty($member_changes)) |
|
433 | - foreach ($member_changes as $change) |
|
456 | + if (!empty($member_changes)) { |
|
457 | + foreach ($member_changes as $change) |
|
434 | 458 | $smcFunc['db_query']('', ' |
435 | 459 | UPDATE {db_prefix}members |
436 | 460 | SET warning = {int:warning} |
@@ -440,6 +464,7 @@ discard block |
||
440 | 464 | 'id_member' => $change['id'], |
441 | 465 | ) |
442 | 466 | ); |
467 | + } |
|
443 | 468 | } |
444 | 469 | } |
445 | 470 | |
@@ -519,15 +544,17 @@ discard block |
||
519 | 544 | |
520 | 545 | // Store this useful data! |
521 | 546 | $boards[$row['id_board']] = $row['id_board']; |
522 | - if ($row['id_topic']) |
|
523 | - $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
524 | - else |
|
525 | - $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
547 | + if ($row['id_topic']) { |
|
548 | + $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
549 | + } else { |
|
550 | + $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
551 | + } |
|
526 | 552 | } |
527 | 553 | $smcFunc['db_free_result']($request); |
528 | 554 | |
529 | - if (empty($boards)) |
|
530 | - return true; |
|
555 | + if (empty($boards)) { |
|
556 | + return true; |
|
557 | + } |
|
531 | 558 | |
532 | 559 | // Just get the board names. |
533 | 560 | $request = $smcFunc['db_query']('', ' |
@@ -539,12 +566,14 @@ discard block |
||
539 | 566 | ) |
540 | 567 | ); |
541 | 568 | $boards = array(); |
542 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
543 | - $boards[$row['id_board']] = $row['name']; |
|
569 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
570 | + $boards[$row['id_board']] = $row['name']; |
|
571 | + } |
|
544 | 572 | $smcFunc['db_free_result']($request); |
545 | 573 | |
546 | - if (empty($boards)) |
|
547 | - return true; |
|
574 | + if (empty($boards)) { |
|
575 | + return true; |
|
576 | + } |
|
548 | 577 | |
549 | 578 | // Get the actual topics... |
550 | 579 | $request = $smcFunc['db_query']('', ' |
@@ -564,52 +593,57 @@ discard block |
||
564 | 593 | $types = array(); |
565 | 594 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
566 | 595 | { |
567 | - if (!isset($types[$row['note_type']][$row['id_board']])) |
|
568 | - $types[$row['note_type']][$row['id_board']] = array( |
|
596 | + if (!isset($types[$row['note_type']][$row['id_board']])) { |
|
597 | + $types[$row['note_type']][$row['id_board']] = array( |
|
569 | 598 | 'lines' => array(), |
570 | 599 | 'name' => $row['board_name'], |
571 | 600 | 'id' => $row['id_board'], |
572 | 601 | ); |
602 | + } |
|
573 | 603 | |
574 | 604 | if ($row['note_type'] == 'reply') |
575 | 605 | { |
576 | - if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
577 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
578 | - else |
|
579 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
606 | + if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
607 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
608 | + } else { |
|
609 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
580 | 610 | 'id' => $row['id_topic'], |
581 | 611 | 'subject' => un_htmlspecialchars($row['subject']), |
582 | 612 | 'count' => 1, |
583 | 613 | ); |
584 | - } |
|
585 | - elseif ($row['note_type'] == 'topic') |
|
614 | + } |
|
615 | + } elseif ($row['note_type'] == 'topic') |
|
586 | 616 | { |
587 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
588 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
617 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
618 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
589 | 619 | 'id' => $row['id_topic'], |
590 | 620 | 'subject' => un_htmlspecialchars($row['subject']), |
591 | 621 | ); |
592 | - } |
|
593 | - else |
|
622 | + } |
|
623 | + } else |
|
594 | 624 | { |
595 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
596 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
625 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
626 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
597 | 627 | 'id' => $row['id_topic'], |
598 | 628 | 'subject' => un_htmlspecialchars($row['subject']), |
599 | 629 | 'starter' => $row['id_member_started'], |
600 | 630 | ); |
631 | + } |
|
601 | 632 | } |
602 | 633 | |
603 | 634 | $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array(); |
604 | - if (!empty($notify['topics'][$row['id_topic']])) |
|
605 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
606 | - if (!empty($notify['boards'][$row['id_board']])) |
|
607 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
635 | + if (!empty($notify['topics'][$row['id_topic']])) { |
|
636 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
637 | + } |
|
638 | + if (!empty($notify['boards'][$row['id_board']])) { |
|
639 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
640 | + } |
|
608 | 641 | } |
609 | 642 | $smcFunc['db_free_result']($request); |
610 | 643 | |
611 | - if (empty($types)) |
|
612 | - return true; |
|
644 | + if (empty($types)) { |
|
645 | + return true; |
|
646 | + } |
|
613 | 647 | |
614 | 648 | // Let's load all the languages into a cache thingy. |
615 | 649 | $langtxt = array(); |
@@ -651,8 +685,9 @@ discard block |
||
651 | 685 | $notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1; |
652 | 686 | |
653 | 687 | // Did they not elect to choose this? |
654 | - if ($frequency < 3 || $frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) |
|
655 | - continue; |
|
688 | + if ($frequency < 3 || $frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) { |
|
689 | + continue; |
|
690 | + } |
|
656 | 691 | |
657 | 692 | // Right character set! |
658 | 693 | $context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set']; |
@@ -668,39 +703,43 @@ discard block |
||
668 | 703 | if (isset($types['topic'])) |
669 | 704 | { |
670 | 705 | $titled = false; |
671 | - foreach ($types['topic'] as $id => $board) |
|
672 | - foreach ($board['lines'] as $topic) |
|
706 | + foreach ($types['topic'] as $id => $board) { |
|
707 | + foreach ($board['lines'] as $topic) |
|
673 | 708 | if (in_array($mid, $topic['members'])) |
674 | 709 | { |
675 | 710 | if (!$titled) |
676 | 711 | { |
677 | 712 | $email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------'; |
713 | + } |
|
678 | 714 | $titled = true; |
679 | 715 | } |
680 | 716 | $email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']); |
681 | 717 | } |
682 | - if ($titled) |
|
683 | - $email['body'] .= "\n"; |
|
718 | + if ($titled) { |
|
719 | + $email['body'] .= "\n"; |
|
720 | + } |
|
684 | 721 | } |
685 | 722 | |
686 | 723 | // What about replies? |
687 | 724 | if (isset($types['reply'])) |
688 | 725 | { |
689 | 726 | $titled = false; |
690 | - foreach ($types['reply'] as $id => $board) |
|
691 | - foreach ($board['lines'] as $topic) |
|
727 | + foreach ($types['reply'] as $id => $board) { |
|
728 | + foreach ($board['lines'] as $topic) |
|
692 | 729 | if (in_array($mid, $topic['members'])) |
693 | 730 | { |
694 | 731 | if (!$titled) |
695 | 732 | { |
696 | 733 | $email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------'; |
734 | + } |
|
697 | 735 | $titled = true; |
698 | 736 | } |
699 | 737 | $email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject'])); |
700 | 738 | } |
701 | 739 | |
702 | - if ($titled) |
|
703 | - $email['body'] .= "\n"; |
|
740 | + if ($titled) { |
|
741 | + $email['body'] .= "\n"; |
|
742 | + } |
|
704 | 743 | } |
705 | 744 | |
706 | 745 | // Finally, moderation actions! |
@@ -709,24 +748,27 @@ discard block |
||
709 | 748 | $titled = false; |
710 | 749 | foreach ($types as $note_type => $type) |
711 | 750 | { |
712 | - if ($note_type == 'topic' || $note_type == 'reply') |
|
713 | - continue; |
|
751 | + if ($note_type == 'topic' || $note_type == 'reply') { |
|
752 | + continue; |
|
753 | + } |
|
714 | 754 | |
715 | - foreach ($type as $id => $board) |
|
716 | - foreach ($board['lines'] as $topic) |
|
755 | + foreach ($type as $id => $board) { |
|
756 | + foreach ($board['lines'] as $topic) |
|
717 | 757 | if (in_array($mid, $topic['members'])) |
718 | 758 | { |
719 | 759 | if (!$titled) |
720 | 760 | { |
721 | 761 | $email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------'; |
762 | + } |
|
722 | 763 | $titled = true; |
723 | 764 | } |
724 | 765 | $email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']); |
725 | 766 | } |
726 | 767 | } |
727 | 768 | } |
728 | - if ($titled) |
|
729 | - $email['body'] .= "\n"; |
|
769 | + if ($titled) { |
|
770 | + $email['body'] .= "\n"; |
|
771 | + } |
|
730 | 772 | |
731 | 773 | // Then just say our goodbyes! |
732 | 774 | $email['body'] .= "\n\n" . $txt['regards_team']; |
@@ -756,8 +798,7 @@ discard block |
||
756 | 798 | 'not_daily' => 0, |
757 | 799 | ) |
758 | 800 | ); |
759 | - } |
|
760 | - else |
|
801 | + } else |
|
761 | 802 | { |
762 | 803 | // Clear any only weekly ones, and stop us from sending daily again. |
763 | 804 | $smcFunc['db_query']('', ' |
@@ -821,16 +862,19 @@ discard block |
||
821 | 862 | global $modSettings, $smcFunc, $sourcedir; |
822 | 863 | |
823 | 864 | // Are we intending another script to be sending out the queue? |
824 | - if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) |
|
825 | - return false; |
|
865 | + if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) { |
|
866 | + return false; |
|
867 | + } |
|
826 | 868 | |
827 | 869 | // By default send 5 at once. |
828 | - if (!$number) |
|
829 | - $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
870 | + if (!$number) { |
|
871 | + $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
872 | + } |
|
830 | 873 | |
831 | 874 | // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us. |
832 | - if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) |
|
833 | - return false; |
|
875 | + if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) { |
|
876 | + return false; |
|
877 | + } |
|
834 | 878 | |
835 | 879 | // By default move the next sending on by 10 seconds, and require an affected row. |
836 | 880 | if (!$override_limit) |
@@ -847,8 +891,9 @@ discard block |
||
847 | 891 | 'last_send' => $modSettings['mail_next_send'], |
848 | 892 | ) |
849 | 893 | ); |
850 | - if ($smcFunc['db_affected_rows']() == 0) |
|
851 | - return false; |
|
894 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
895 | + return false; |
|
896 | + } |
|
852 | 897 | $modSettings['mail_next_send'] = time() + $delay; |
853 | 898 | } |
854 | 899 | |
@@ -869,8 +914,9 @@ discard block |
||
869 | 914 | $mn += $number; |
870 | 915 | } |
871 | 916 | // No more I'm afraid, return! |
872 | - else |
|
873 | - return false; |
|
917 | + else { |
|
918 | + return false; |
|
919 | + } |
|
874 | 920 | |
875 | 921 | // Reflect that we're about to send some, do it now to be safe. |
876 | 922 | updateSettings(array('mail_recent' => $mt . '|' . $mn)); |
@@ -905,14 +951,15 @@ discard block |
||
905 | 951 | $smcFunc['db_free_result']($request); |
906 | 952 | |
907 | 953 | // Delete, delete, delete!!! |
908 | - if (!empty($ids)) |
|
909 | - $smcFunc['db_query']('', ' |
|
954 | + if (!empty($ids)) { |
|
955 | + $smcFunc['db_query']('', ' |
|
910 | 956 | DELETE FROM {db_prefix}mail_queue |
911 | 957 | WHERE id_mail IN ({array_int:mail_list})', |
912 | 958 | array( |
913 | 959 | 'mail_list' => $ids, |
914 | 960 | ) |
915 | 961 | ); |
962 | + } |
|
916 | 963 | |
917 | 964 | // Don't believe we have any left? |
918 | 965 | if (count($ids) < $number) |
@@ -930,11 +977,13 @@ discard block |
||
930 | 977 | ); |
931 | 978 | } |
932 | 979 | |
933 | - if (empty($ids)) |
|
934 | - return false; |
|
980 | + if (empty($ids)) { |
|
981 | + return false; |
|
982 | + } |
|
935 | 983 | |
936 | - if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') |
|
937 | - require_once($sourcedir . '/Subs-Post.php'); |
|
984 | + if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') { |
|
985 | + require_once($sourcedir . '/Subs-Post.php'); |
|
986 | + } |
|
938 | 987 | |
939 | 988 | // Send each email, yea! |
940 | 989 | $failed_emails = array(); |
@@ -954,15 +1003,17 @@ discard block |
||
954 | 1003 | |
955 | 1004 | // Try to stop a timeout, this would be bad... |
956 | 1005 | @set_time_limit(300); |
957 | - if (function_exists('apache_reset_timeout')) |
|
958 | - @apache_reset_timeout(); |
|
1006 | + if (function_exists('apache_reset_timeout')) { |
|
1007 | + @apache_reset_timeout(); |
|
1008 | + } |
|
1009 | + } else { |
|
1010 | + $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
959 | 1011 | } |
960 | - else |
|
961 | - $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
962 | 1012 | |
963 | 1013 | // Hopefully it sent? |
964 | - if (!$result) |
|
965 | - $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
1014 | + if (!$result) { |
|
1015 | + $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
1016 | + } |
|
966 | 1017 | } |
967 | 1018 | |
968 | 1019 | // Any emails that didn't send? |
@@ -977,8 +1028,8 @@ discard block |
||
977 | 1028 | ); |
978 | 1029 | |
979 | 1030 | // If we have failed to many times, tell mail to wait a bit and try again. |
980 | - if ($modSettings['mail_failed_attempts'] > 5) |
|
981 | - $smcFunc['db_query']('', ' |
|
1031 | + if ($modSettings['mail_failed_attempts'] > 5) { |
|
1032 | + $smcFunc['db_query']('', ' |
|
982 | 1033 | UPDATE {db_prefix}settings |
983 | 1034 | SET value = {string:next_mail_send} |
984 | 1035 | WHERE variable = {literal:mail_next_send} |
@@ -987,6 +1038,7 @@ discard block |
||
987 | 1038 | 'next_mail_send' => time() + 60, |
988 | 1039 | 'last_send' => $modSettings['mail_next_send'], |
989 | 1040 | )); |
1041 | + } |
|
990 | 1042 | |
991 | 1043 | // Add our email back to the queue, manually. |
992 | 1044 | $smcFunc['db_insert']('insert', |
@@ -999,8 +1051,8 @@ discard block |
||
999 | 1051 | return false; |
1000 | 1052 | } |
1001 | 1053 | // We where unable to send the email, clear our failed attempts. |
1002 | - elseif (!empty($modSettings['mail_failed_attempts'])) |
|
1003 | - $smcFunc['db_query']('', ' |
|
1054 | + elseif (!empty($modSettings['mail_failed_attempts'])) { |
|
1055 | + $smcFunc['db_query']('', ' |
|
1004 | 1056 | UPDATE {db_prefix}settings |
1005 | 1057 | SET value = {string:zero} |
1006 | 1058 | WHERE variable = {string:mail_failed_attempts}', |
@@ -1008,6 +1060,7 @@ discard block |
||
1008 | 1060 | 'zero' => '0', |
1009 | 1061 | 'mail_failed_attempts' => 'mail_failed_attempts', |
1010 | 1062 | )); |
1063 | + } |
|
1011 | 1064 | |
1012 | 1065 | // Had something to send... |
1013 | 1066 | return true; |
@@ -1024,16 +1077,18 @@ discard block |
||
1024 | 1077 | global $modSettings, $smcFunc; |
1025 | 1078 | |
1026 | 1079 | $task_query = ''; |
1027 | - if (!is_array($tasks)) |
|
1028 | - $tasks = array($tasks); |
|
1080 | + if (!is_array($tasks)) { |
|
1081 | + $tasks = array($tasks); |
|
1082 | + } |
|
1029 | 1083 | |
1030 | 1084 | // Actually have something passed? |
1031 | 1085 | if (!empty($tasks)) |
1032 | 1086 | { |
1033 | - if (!isset($tasks[0]) || is_numeric($tasks[0])) |
|
1034 | - $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
1035 | - else |
|
1036 | - $task_query = ' AND task IN ({array_string:tasks})'; |
|
1087 | + if (!isset($tasks[0]) || is_numeric($tasks[0])) { |
|
1088 | + $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
1089 | + } else { |
|
1090 | + $task_query = ' AND task IN ({array_string:tasks})'; |
|
1091 | + } |
|
1037 | 1092 | } |
1038 | 1093 | $nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time']; |
1039 | 1094 | |
@@ -1054,20 +1109,22 @@ discard block |
||
1054 | 1109 | $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']); |
1055 | 1110 | |
1056 | 1111 | // Only bother moving the task if it's out of place or we're forcing it! |
1057 | - if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) |
|
1058 | - $tasks[$row['id_task']] = $next_time; |
|
1059 | - else |
|
1060 | - $next_time = $row['next_time']; |
|
1112 | + if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) { |
|
1113 | + $tasks[$row['id_task']] = $next_time; |
|
1114 | + } else { |
|
1115 | + $next_time = $row['next_time']; |
|
1116 | + } |
|
1061 | 1117 | |
1062 | 1118 | // If this is sooner than the current next task, make this the next task. |
1063 | - if ($next_time < $nextTaskTime) |
|
1064 | - $nextTaskTime = $next_time; |
|
1119 | + if ($next_time < $nextTaskTime) { |
|
1120 | + $nextTaskTime = $next_time; |
|
1121 | + } |
|
1065 | 1122 | } |
1066 | 1123 | $smcFunc['db_free_result']($request); |
1067 | 1124 | |
1068 | 1125 | // Now make the changes! |
1069 | - foreach ($tasks as $id => $time) |
|
1070 | - $smcFunc['db_query']('', ' |
|
1126 | + foreach ($tasks as $id => $time) { |
|
1127 | + $smcFunc['db_query']('', ' |
|
1071 | 1128 | UPDATE {db_prefix}scheduled_tasks |
1072 | 1129 | SET next_time = {int:next_time} |
1073 | 1130 | WHERE id_task = {int:id_task}', |
@@ -1076,11 +1133,13 @@ discard block |
||
1076 | 1133 | 'id_task' => $id, |
1077 | 1134 | ) |
1078 | 1135 | ); |
1136 | + } |
|
1079 | 1137 | |
1080 | 1138 | // If the next task is now different update. |
1081 | - if ($modSettings['next_task_time'] != $nextTaskTime) |
|
1082 | - updateSettings(array('next_task_time' => $nextTaskTime)); |
|
1083 | -} |
|
1139 | + if ($modSettings['next_task_time'] != $nextTaskTime) { |
|
1140 | + updateSettings(array('next_task_time' => $nextTaskTime)); |
|
1141 | + } |
|
1142 | + } |
|
1084 | 1143 | |
1085 | 1144 | /** |
1086 | 1145 | * Simply returns a time stamp of the next instance of these time parameters. |
@@ -1093,8 +1152,9 @@ discard block |
||
1093 | 1152 | function next_time($regularity, $unit, $offset) |
1094 | 1153 | { |
1095 | 1154 | // Just in case! |
1096 | - if ($regularity == 0) |
|
1097 | - $regularity = 2; |
|
1155 | + if ($regularity == 0) { |
|
1156 | + $regularity = 2; |
|
1157 | + } |
|
1098 | 1158 | |
1099 | 1159 | $curMin = date('i', time()); |
1100 | 1160 | |
@@ -1104,15 +1164,16 @@ discard block |
||
1104 | 1164 | $off = date('i', $offset); |
1105 | 1165 | |
1106 | 1166 | // If it's now just pretend it ain't, |
1107 | - if ($off == $curMin) |
|
1108 | - $next_time = time() + $regularity; |
|
1109 | - else |
|
1167 | + if ($off == $curMin) { |
|
1168 | + $next_time = time() + $regularity; |
|
1169 | + } else |
|
1110 | 1170 | { |
1111 | 1171 | // Make sure that the offset is always in the past. |
1112 | 1172 | $off = $off > $curMin ? $off - 60 : $off; |
1113 | 1173 | |
1114 | - while ($off <= $curMin) |
|
1115 | - $off += $regularity; |
|
1174 | + while ($off <= $curMin) { |
|
1175 | + $off += $regularity; |
|
1176 | + } |
|
1116 | 1177 | |
1117 | 1178 | // Now we know when the time should be! |
1118 | 1179 | $next_time = time() + 60 * ($off - $curMin); |
@@ -1132,11 +1193,13 @@ discard block |
||
1132 | 1193 | // Default we'll jump in hours. |
1133 | 1194 | $applyOffset = 3600; |
1134 | 1195 | // 24 hours = 1 day. |
1135 | - if ($unit == 'd') |
|
1136 | - $applyOffset = 86400; |
|
1196 | + if ($unit == 'd') { |
|
1197 | + $applyOffset = 86400; |
|
1198 | + } |
|
1137 | 1199 | // Otherwise a week. |
1138 | - if ($unit == 'w') |
|
1139 | - $applyOffset = 604800; |
|
1200 | + if ($unit == 'w') { |
|
1201 | + $applyOffset = 604800; |
|
1202 | + } |
|
1140 | 1203 | |
1141 | 1204 | $applyOffset *= $regularity; |
1142 | 1205 | |
@@ -1173,8 +1236,9 @@ discard block |
||
1173 | 1236 | $settings[$row['variable']] = $row['value']; |
1174 | 1237 | |
1175 | 1238 | // Is this the default theme? |
1176 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') |
|
1177 | - $settings['default_' . $row['variable']] = $row['value']; |
|
1239 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') { |
|
1240 | + $settings['default_' . $row['variable']] = $row['value']; |
|
1241 | + } |
|
1178 | 1242 | } |
1179 | 1243 | $smcFunc['db_free_result']($result); |
1180 | 1244 | |
@@ -1184,12 +1248,14 @@ discard block |
||
1184 | 1248 | $settings['template_dirs'] = array($settings['theme_dir']); |
1185 | 1249 | |
1186 | 1250 | // Based on theme (if there is one). |
1187 | - if (!empty($settings['base_theme_dir'])) |
|
1188 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1251 | + if (!empty($settings['base_theme_dir'])) { |
|
1252 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1253 | + } |
|
1189 | 1254 | |
1190 | 1255 | // Lastly the default theme. |
1191 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1192 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1256 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1257 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1258 | + } |
|
1193 | 1259 | } |
1194 | 1260 | |
1195 | 1261 | // Assume we want this. |
@@ -1333,8 +1399,9 @@ discard block |
||
1333 | 1399 | // Ok should we prune the logs? |
1334 | 1400 | if (!empty($modSettings['pruningOptions'])) |
1335 | 1401 | { |
1336 | - if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) |
|
1337 | - list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
1402 | + if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) { |
|
1403 | + list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
1404 | + } |
|
1338 | 1405 | |
1339 | 1406 | if (!empty($modSettings['pruneErrorLog'])) |
1340 | 1407 | { |
@@ -1400,8 +1467,9 @@ discard block |
||
1400 | 1467 | ) |
1401 | 1468 | ); |
1402 | 1469 | |
1403 | - while ($row = $smcFunc['db_fetch_row']($result)) |
|
1404 | - $reports[] = $row[0]; |
|
1470 | + while ($row = $smcFunc['db_fetch_row']($result)) { |
|
1471 | + $reports[] = $row[0]; |
|
1472 | + } |
|
1405 | 1473 | |
1406 | 1474 | $smcFunc['db_free_result']($result); |
1407 | 1475 | |
@@ -1486,8 +1554,9 @@ discard block |
||
1486 | 1554 | ); |
1487 | 1555 | |
1488 | 1556 | // Run Cache housekeeping |
1489 | - if (!empty($cache_enable) && !empty($cacheAPI)) |
|
1490 | - $cacheAPI->housekeeping(); |
|
1557 | + if (!empty($cache_enable) && !empty($cacheAPI)) { |
|
1558 | + $cacheAPI->housekeeping(); |
|
1559 | + } |
|
1491 | 1560 | |
1492 | 1561 | // Prevent stale minimized CSS and JavaScript from cluttering up the theme directories |
1493 | 1562 | deleteAllMinified(); |
@@ -1570,8 +1639,9 @@ discard block |
||
1570 | 1639 | $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); |
1571 | 1640 | |
1572 | 1641 | // Send the actual email. |
1573 | - if ($notifyPrefs[$row['id_member']] & 0x02) |
|
1574 | - sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
1642 | + if ($notifyPrefs[$row['id_member']] & 0x02) { |
|
1643 | + sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
1644 | + } |
|
1575 | 1645 | |
1576 | 1646 | if ($notifyPrefs[$row['id_member']] & 0x01) |
1577 | 1647 | { |
@@ -1594,18 +1664,19 @@ discard block |
||
1594 | 1664 | } |
1595 | 1665 | |
1596 | 1666 | // Insert the alerts if any |
1597 | - if (!empty($alert_rows)) |
|
1598 | - $smcFunc['db_insert']('', |
|
1667 | + if (!empty($alert_rows)) { |
|
1668 | + $smcFunc['db_insert']('', |
|
1599 | 1669 | '{db_prefix}user_alerts', |
1600 | 1670 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
1601 | 1671 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
1602 | 1672 | $alert_rows, |
1603 | 1673 | array() |
1604 | 1674 | ); |
1675 | + } |
|
1605 | 1676 | |
1606 | 1677 | // Mark the reminder as sent. |
1607 | - if (!empty($subs_reminded)) |
|
1608 | - $smcFunc['db_query']('', ' |
|
1678 | + if (!empty($subs_reminded)) { |
|
1679 | + $smcFunc['db_query']('', ' |
|
1609 | 1680 | UPDATE {db_prefix}log_subscribed |
1610 | 1681 | SET reminder_sent = {int:reminder_sent} |
1611 | 1682 | WHERE id_sublog IN ({array_int:subscription_list})', |
@@ -1614,6 +1685,7 @@ discard block |
||
1614 | 1685 | 'reminder_sent' => 1, |
1615 | 1686 | ) |
1616 | 1687 | ); |
1688 | + } |
|
1617 | 1689 | |
1618 | 1690 | return true; |
1619 | 1691 | } |
@@ -1629,13 +1701,13 @@ discard block |
||
1629 | 1701 | // We need to know where this thing is going. |
1630 | 1702 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
1631 | 1703 | { |
1632 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
1633 | - $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1704 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
1705 | + $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
|
1706 | + } |
|
1634 | 1707 | |
1635 | 1708 | // Just use the current path for temp files. |
1636 | 1709 | $attach_dirs = $modSettings['attachmentUploadDir']; |
1637 | - } |
|
1638 | - else |
|
1710 | + } else |
|
1639 | 1711 | { |
1640 | 1712 | $attach_dirs = array($modSettings['attachmentUploadDir']); |
1641 | 1713 | } |
@@ -1654,14 +1726,16 @@ discard block |
||
1654 | 1726 | |
1655 | 1727 | while ($file = readdir($dir)) |
1656 | 1728 | { |
1657 | - if ($file == '.' || $file == '..') |
|
1658 | - continue; |
|
1729 | + if ($file == '.' || $file == '..') { |
|
1730 | + continue; |
|
1731 | + } |
|
1659 | 1732 | |
1660 | 1733 | if (strpos($file, 'post_tmp_') !== false) |
1661 | 1734 | { |
1662 | 1735 | // Temp file is more than 5 hours old! |
1663 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
1664 | - @unlink($attach_dir . '/' . $file); |
|
1736 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
1737 | + @unlink($attach_dir . '/' . $file); |
|
1738 | + } |
|
1665 | 1739 | } |
1666 | 1740 | } |
1667 | 1741 | closedir($dir); |
@@ -1694,8 +1768,9 @@ discard block |
||
1694 | 1768 | ) |
1695 | 1769 | ); |
1696 | 1770 | |
1697 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1698 | - $topics[] = $row[0]; |
|
1771 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1772 | + $topics[] = $row[0]; |
|
1773 | + } |
|
1699 | 1774 | $smcFunc['db_free_result']($request); |
1700 | 1775 | |
1701 | 1776 | // Zap, your gone |
@@ -1715,8 +1790,9 @@ discard block |
||
1715 | 1790 | { |
1716 | 1791 | global $smcFunc, $sourcedir, $modSettings; |
1717 | 1792 | |
1718 | - if (empty($modSettings['drafts_keep_days'])) |
|
1719 | - return true; |
|
1793 | + if (empty($modSettings['drafts_keep_days'])) { |
|
1794 | + return true; |
|
1795 | + } |
|
1720 | 1796 | |
1721 | 1797 | // init |
1722 | 1798 | $drafts = array(); |
@@ -1734,8 +1810,9 @@ discard block |
||
1734 | 1810 | ) |
1735 | 1811 | ); |
1736 | 1812 | |
1737 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1738 | - $drafts[] = (int) $row[0]; |
|
1813 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1814 | + $drafts[] = (int) $row[0]; |
|
1815 | + } |
|
1739 | 1816 | $smcFunc['db_free_result']($request); |
1740 | 1817 | |
1741 | 1818 | // If we have old one, remove them |
@@ -18,18 +18,20 @@ discard block |
||
18 | 18 | global $context, $settings, $options, $txt, $scripturl, $modSettings; |
19 | 19 | |
20 | 20 | // Let them know, if their report was a success! |
21 | - if ($context['report_sent']) |
|
22 | - echo ' |
|
21 | + if ($context['report_sent']) { |
|
22 | + echo ' |
|
23 | 23 | <div class="infobox"> |
24 | 24 | ', $txt['report_sent'], ' |
25 | 25 | </div>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | // Let them know why their message became unapproved. |
28 | - if ($context['becomesUnapproved']) |
|
29 | - echo ' |
|
29 | + if ($context['becomesUnapproved']) { |
|
30 | + echo ' |
|
30 | 31 | <div class="noticebox"> |
31 | 32 | ', $txt['post_becomesUnapproved'], ' |
32 | 33 | </div>'; |
34 | + } |
|
33 | 35 | |
34 | 36 | // Show new topic info here? |
35 | 37 | echo ' |
@@ -49,11 +51,13 @@ discard block |
||
49 | 51 | <p>'; |
50 | 52 | |
51 | 53 | // Show just numbers...? |
52 | - if ($settings['display_who_viewing'] == 1) |
|
53 | - echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
54 | + if ($settings['display_who_viewing'] == 1) { |
|
55 | + echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
56 | + } |
|
54 | 57 | // Or show the actual people viewing the topic? |
55 | - else |
|
56 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
58 | + else { |
|
59 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
60 | + } |
|
57 | 61 | |
58 | 62 | // Now show how many guests are here too. |
59 | 63 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], ' |
@@ -91,10 +95,11 @@ discard block |
||
91 | 95 | <dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt> |
92 | 96 | <dd class="statsbar generic_bar', $option['voted_this'] ? ' voted' : '', '">'; |
93 | 97 | |
94 | - if ($context['allow_results_view']) |
|
95 | - echo ' |
|
98 | + if ($context['allow_results_view']) { |
|
99 | + echo ' |
|
96 | 100 | ', $option['bar_ndt'], ' |
97 | 101 | <span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>'; |
102 | + } |
|
98 | 103 | |
99 | 104 | echo ' |
100 | 105 | </dd>'; |
@@ -103,9 +108,10 @@ discard block |
||
103 | 108 | echo ' |
104 | 109 | </dl>'; |
105 | 110 | |
106 | - if ($context['allow_results_view']) |
|
107 | - echo ' |
|
111 | + if ($context['allow_results_view']) { |
|
112 | + echo ' |
|
108 | 113 | <p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>'; |
114 | + } |
|
109 | 115 | } |
110 | 116 | // They are allowed to vote! Go to it! |
111 | 117 | else |
@@ -114,17 +120,19 @@ discard block |
||
114 | 120 | <form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">'; |
115 | 121 | |
116 | 122 | // Show a warning if they are allowed more than one option. |
117 | - if ($context['poll']['allowed_warning']) |
|
118 | - echo ' |
|
123 | + if ($context['poll']['allowed_warning']) { |
|
124 | + echo ' |
|
119 | 125 | <p class="smallpadding">', $context['poll']['allowed_warning'], '</p>'; |
126 | + } |
|
120 | 127 | |
121 | 128 | echo ' |
122 | 129 | <ul class="options">'; |
123 | 130 | |
124 | 131 | // Show each option with its button - a radio likely. |
125 | - foreach ($context['poll']['options'] as $option) |
|
126 | - echo ' |
|
132 | + foreach ($context['poll']['options'] as $option) { |
|
133 | + echo ' |
|
127 | 134 | <li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>'; |
135 | + } |
|
128 | 136 | |
129 | 137 | echo ' |
130 | 138 | </ul> |
@@ -136,9 +144,10 @@ discard block |
||
136 | 144 | } |
137 | 145 | |
138 | 146 | // Is the clock ticking? |
139 | - if (!empty($context['poll']['expire_time'])) |
|
140 | - echo ' |
|
147 | + if (!empty($context['poll']['expire_time'])) { |
|
148 | + echo ' |
|
141 | 149 | <p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>'; |
150 | + } |
|
142 | 151 | |
143 | 152 | echo ' |
144 | 153 | </div><!-- #poll_options --> |
@@ -168,11 +177,13 @@ discard block |
||
168 | 177 | <li> |
169 | 178 | <strong class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></strong>'; |
170 | 179 | |
171 | - if ($event['can_edit']) |
|
172 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
180 | + if ($event['can_edit']) { |
|
181 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
182 | + } |
|
173 | 183 | |
174 | - if ($event['can_export']) |
|
175 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
184 | + if ($event['can_export']) { |
|
185 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
186 | + } |
|
176 | 187 | |
177 | 188 | echo ' |
178 | 189 | <br>'; |
@@ -180,14 +191,14 @@ discard block |
||
180 | 191 | if (!empty($event['allday'])) |
181 | 192 | { |
182 | 193 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
183 | - } |
|
184 | - else |
|
194 | + } else |
|
185 | 195 | { |
186 | 196 | // Display event info relative to user's local timezone |
187 | 197 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
188 | 198 | |
189 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
190 | - echo trim($event['end_date_local']) . ', '; |
|
199 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
200 | + echo trim($event['end_date_local']) . ', '; |
|
201 | + } |
|
191 | 202 | |
192 | 203 | echo trim($event['end_time_local']); |
193 | 204 | |
@@ -196,24 +207,28 @@ discard block |
||
196 | 207 | { |
197 | 208 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
198 | 209 | |
199 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
200 | - echo trim($event['start_date_orig']), ', '; |
|
210 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
211 | + echo trim($event['start_date_orig']), ', '; |
|
212 | + } |
|
201 | 213 | |
202 | 214 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
203 | 215 | |
204 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
205 | - echo trim($event['end_date_orig']) . ', '; |
|
216 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
217 | + echo trim($event['end_date_orig']) . ', '; |
|
218 | + } |
|
206 | 219 | |
207 | 220 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
208 | 221 | } |
209 | 222 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
210 | - else |
|
211 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
223 | + else { |
|
224 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
225 | + } |
|
212 | 226 | } |
213 | 227 | |
214 | - if (!empty($event['location'])) |
|
215 | - echo ' |
|
228 | + if (!empty($event['location'])) { |
|
229 | + echo ' |
|
216 | 230 | <br>', $event['location']; |
231 | + } |
|
217 | 232 | |
218 | 233 | echo ' |
219 | 234 | </li>'; |
@@ -235,12 +250,13 @@ discard block |
||
235 | 250 | </div>'; |
236 | 251 | |
237 | 252 | // Mobile action - moderation buttons (top) |
238 | - if (!empty($context['normal_buttons'])) |
|
239 | - echo ' |
|
253 | + if (!empty($context['normal_buttons'])) { |
|
254 | + echo ' |
|
240 | 255 | <div class="mobile_buttons floatright"> |
241 | 256 | <a class="button mobile_act">', $txt['mobile_action'], '</a> |
242 | 257 | ', !empty($context['mod_buttons']) ? '<a class="button mobile_mod">' . $txt['mobile_moderation'] . '</a>' : '', ' |
243 | 258 | </div>'; |
259 | + } |
|
244 | 260 | |
245 | 261 | // Show the topic information - icon, subject, etc. |
246 | 262 | echo ' |
@@ -251,20 +267,22 @@ discard block |
||
251 | 267 | $context['removableMessageIDs'] = array(); |
252 | 268 | |
253 | 269 | // Get all the messages... |
254 | - while ($message = $context['get_message']()) |
|
255 | - template_single_post($message); |
|
270 | + while ($message = $context['get_message']()) { |
|
271 | + template_single_post($message); |
|
272 | + } |
|
256 | 273 | |
257 | 274 | echo ' |
258 | 275 | </form> |
259 | 276 | </div><!-- #forumposts -->'; |
260 | 277 | |
261 | 278 | // Mobile action - moderation buttons (bottom) |
262 | - if (!empty($context['normal_buttons'])) |
|
263 | - echo ' |
|
279 | + if (!empty($context['normal_buttons'])) { |
|
280 | + echo ' |
|
264 | 281 | <div class="mobile_buttons floatright"> |
265 | 282 | <a class="button mobile_act">', $txt['mobile_action'], '</a> |
266 | 283 | ', !empty($context['mod_buttons']) ? '<a class="button mobile_mod">' . $txt['mobile_moderation'] . '</a>' : '', ' |
267 | 284 | </div>'; |
285 | + } |
|
268 | 286 | |
269 | 287 | // Show the page index... "Pages: [1]". |
270 | 288 | echo ' |
@@ -291,8 +309,9 @@ discard block |
||
291 | 309 | <div id="display_jump_to"></div>'; |
292 | 310 | |
293 | 311 | // Show quickreply |
294 | - if ($context['can_reply']) |
|
295 | - template_quickreply(); |
|
312 | + if ($context['can_reply']) { |
|
313 | + template_quickreply(); |
|
314 | + } |
|
296 | 315 | |
297 | 316 | // User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device. |
298 | 317 | echo ' |
@@ -307,8 +326,8 @@ discard block |
||
307 | 326 | </div>'; |
308 | 327 | |
309 | 328 | // Show the moderation button & pop (if there is anything to show) |
310 | - if (!empty($context['mod_buttons'])) |
|
311 | - echo ' |
|
329 | + if (!empty($context['mod_buttons'])) { |
|
330 | + echo ' |
|
312 | 331 | <div id="mobile_moderation" class="popup_container"> |
313 | 332 | <div class="popup_window description"> |
314 | 333 | <div class="popup_heading"> |
@@ -320,6 +339,7 @@ discard block |
||
320 | 339 | </div> |
321 | 340 | </div> |
322 | 341 | </div>'; |
342 | + } |
|
323 | 343 | |
324 | 344 | echo ' |
325 | 345 | <script>'; |
@@ -443,9 +463,10 @@ discard block |
||
443 | 463 | }); |
444 | 464 | }'; |
445 | 465 | |
446 | - if (!empty($context['ignoredMsgs'])) |
|
447 | - echo ' |
|
466 | + if (!empty($context['ignoredMsgs'])) { |
|
467 | + echo ' |
|
448 | 468 | ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');'; |
469 | + } |
|
449 | 470 | |
450 | 471 | echo ' |
451 | 472 | </script>'; |
@@ -462,8 +483,9 @@ discard block |
||
462 | 483 | |
463 | 484 | $ignoring = false; |
464 | 485 | |
465 | - if ($message['can_remove']) |
|
466 | - $context['removableMessageIDs'][] = $message['id']; |
|
486 | + if ($message['can_remove']) { |
|
487 | + $context['removableMessageIDs'][] = $message['id']; |
|
488 | + } |
|
467 | 489 | |
468 | 490 | // Are we ignoring this message? |
469 | 491 | if (!empty($message['is_ignored'])) |
@@ -490,9 +512,10 @@ discard block |
||
490 | 512 | <div class="custom_fields_above_member"> |
491 | 513 | <ul class="nolist">'; |
492 | 514 | |
493 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
494 | - echo ' |
|
515 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
516 | + echo ' |
|
495 | 517 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
518 | + } |
|
496 | 519 | |
497 | 520 | echo ' |
498 | 521 | </ul> |
@@ -503,25 +526,28 @@ discard block |
||
503 | 526 | <h4>'; |
504 | 527 | |
505 | 528 | // Show online and offline buttons? |
506 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
507 | - echo ' |
|
529 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
530 | + echo ' |
|
508 | 531 | ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : ''; |
532 | + } |
|
509 | 533 | |
510 | 534 | // Custom fields BEFORE the username? |
511 | - if (!empty($message['custom_fields']['before_member'])) |
|
512 | - foreach ($message['custom_fields']['before_member'] as $custom) |
|
535 | + if (!empty($message['custom_fields']['before_member'])) { |
|
536 | + foreach ($message['custom_fields']['before_member'] as $custom) |
|
513 | 537 | echo ' |
514 | 538 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
539 | + } |
|
515 | 540 | |
516 | 541 | // Show a link to the member's profile. |
517 | 542 | echo ' |
518 | 543 | ', $message['member']['link']; |
519 | 544 | |
520 | 545 | // Custom fields AFTER the username? |
521 | - if (!empty($message['custom_fields']['after_member'])) |
|
522 | - foreach ($message['custom_fields']['after_member'] as $custom) |
|
546 | + if (!empty($message['custom_fields']['after_member'])) { |
|
547 | + foreach ($message['custom_fields']['after_member'] as $custom) |
|
523 | 548 | echo ' |
524 | 549 | <span class="custom ', $custom['col_name'], '">', $custom['value'], '</span>'; |
550 | + } |
|
525 | 551 | |
526 | 552 | // Begin display of user info |
527 | 553 | echo ' |
@@ -529,50 +555,58 @@ discard block |
||
529 | 555 | <ul class="user_info">'; |
530 | 556 | |
531 | 557 | // Show the user's avatar. |
532 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
533 | - echo ' |
|
558 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
559 | + echo ' |
|
534 | 560 | <li class="avatar"> |
535 | 561 | <a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a> |
536 | 562 | </li>'; |
563 | + } |
|
537 | 564 | |
538 | 565 | // Are there any custom fields below the avatar? |
539 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
540 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
566 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
567 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
541 | 568 | echo ' |
542 | 569 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
570 | + } |
|
543 | 571 | |
544 | 572 | // Show the post group icons, but not for guests. |
545 | - if (!$message['member']['is_guest']) |
|
546 | - echo ' |
|
573 | + if (!$message['member']['is_guest']) { |
|
574 | + echo ' |
|
547 | 575 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
576 | + } |
|
548 | 577 | |
549 | 578 | // Show the member's primary group (like 'Administrator') if they have one. |
550 | - if (!empty($message['member']['group'])) |
|
551 | - echo ' |
|
579 | + if (!empty($message['member']['group'])) { |
|
580 | + echo ' |
|
552 | 581 | <li class="membergroup">', $message['member']['group'], '</li>'; |
582 | + } |
|
553 | 583 | |
554 | 584 | // Show the member's custom title, if they have one. |
555 | - if (!empty($message['member']['title'])) |
|
556 | - echo ' |
|
585 | + if (!empty($message['member']['title'])) { |
|
586 | + echo ' |
|
557 | 587 | <li class="title">', $message['member']['title'], '</li>'; |
588 | + } |
|
558 | 589 | |
559 | 590 | // Don't show these things for guests. |
560 | 591 | if (!$message['member']['is_guest']) |
561 | 592 | { |
562 | 593 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
563 | - if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) |
|
564 | - echo ' |
|
594 | + if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) { |
|
595 | + echo ' |
|
565 | 596 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
597 | + } |
|
566 | 598 | |
567 | 599 | // Show how many posts they have made. |
568 | - if (!isset($context['disabled_fields']['posts'])) |
|
569 | - echo ' |
|
600 | + if (!isset($context['disabled_fields']['posts'])) { |
|
601 | + echo ' |
|
570 | 602 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
603 | + } |
|
571 | 604 | |
572 | 605 | // Show their personal text? |
573 | - if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) |
|
574 | - echo ' |
|
606 | + if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) { |
|
607 | + echo ' |
|
575 | 608 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
609 | + } |
|
576 | 610 | |
577 | 611 | // Any custom fields to show as icons? |
578 | 612 | if (!empty($message['custom_fields']['icons'])) |
@@ -581,9 +615,10 @@ discard block |
||
581 | 615 | <li class="im_icons"> |
582 | 616 | <ol>'; |
583 | 617 | |
584 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
585 | - echo ' |
|
618 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
619 | + echo ' |
|
586 | 620 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
621 | + } |
|
587 | 622 | |
588 | 623 | echo ' |
589 | 624 | </ol> |
@@ -598,19 +633,22 @@ discard block |
||
598 | 633 | <ol class="profile_icons">'; |
599 | 634 | |
600 | 635 | // Don't show an icon if they haven't specified a website. |
601 | - if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) |
|
602 | - echo ' |
|
636 | + if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) { |
|
637 | + echo ' |
|
603 | 638 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
639 | + } |
|
604 | 640 | |
605 | 641 | // Since we know this person isn't a guest, you *can* message them. |
606 | - if ($context['can_send_pm']) |
|
607 | - echo ' |
|
642 | + if ($context['can_send_pm']) { |
|
643 | + echo ' |
|
608 | 644 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
645 | + } |
|
609 | 646 | |
610 | 647 | // Show the email if necessary |
611 | - if (!empty($message['member']['email']) && $message['member']['show_email']) |
|
612 | - echo ' |
|
648 | + if (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
649 | + echo ' |
|
613 | 650 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
651 | + } |
|
614 | 652 | |
615 | 653 | echo ' |
616 | 654 | </ol> |
@@ -618,57 +656,65 @@ discard block |
||
618 | 656 | } |
619 | 657 | |
620 | 658 | // Any custom fields for standard placement? |
621 | - if (!empty($message['custom_fields']['standard'])) |
|
622 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
659 | + if (!empty($message['custom_fields']['standard'])) { |
|
660 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
623 | 661 | echo ' |
624 | 662 | <li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>'; |
663 | + } |
|
625 | 664 | } |
626 | 665 | // Otherwise, show the guest's email. |
627 | - elseif (!empty($message['member']['email']) && $message['member']['show_email']) |
|
628 | - echo ' |
|
666 | + elseif (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
667 | + echo ' |
|
629 | 668 | <li class="email"> |
630 | 669 | <a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a> |
631 | 670 | </li>'; |
671 | + } |
|
632 | 672 | |
633 | 673 | // Show the IP to this user for this post - because you can moderate? |
634 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
635 | - echo ' |
|
674 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
675 | + echo ' |
|
636 | 676 | <li class="poster_ip"> |
637 | 677 | <a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a> |
638 | 678 | </li>'; |
679 | + } |
|
639 | 680 | |
640 | 681 | // Or, should we show it because this is you? |
641 | - elseif ($message['can_see_ip']) |
|
642 | - echo ' |
|
682 | + elseif ($message['can_see_ip']) { |
|
683 | + echo ' |
|
643 | 684 | <li class="poster_ip"> |
644 | 685 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a> |
645 | 686 | </li>'; |
687 | + } |
|
646 | 688 | |
647 | 689 | // Okay, are you at least logged in? Then we can show something about why IPs are logged... |
648 | - elseif (!$context['user']['is_guest']) |
|
649 | - echo ' |
|
690 | + elseif (!$context['user']['is_guest']) { |
|
691 | + echo ' |
|
650 | 692 | <li class="poster_ip"> |
651 | 693 | <a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a> |
652 | 694 | </li>'; |
695 | + } |
|
653 | 696 | |
654 | 697 | // Otherwise, you see NOTHING! |
655 | - else |
|
656 | - echo ' |
|
698 | + else { |
|
699 | + echo ' |
|
657 | 700 | <li class="poster_ip">', $txt['logged'], '</li>'; |
701 | + } |
|
658 | 702 | |
659 | 703 | // Are we showing the warning status? |
660 | 704 | // Don't show these things for guests. |
661 | - if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) |
|
662 | - echo ' |
|
705 | + if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) { |
|
706 | + echo ' |
|
663 | 707 | <li class="warning"> |
664 | 708 | ', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span> |
665 | 709 | </li>'; |
710 | + } |
|
666 | 711 | |
667 | 712 | // Are there any custom fields to show at the bottom of the poster info? |
668 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
669 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
713 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
714 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
670 | 715 | echo ' |
671 | 716 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
717 | + } |
|
672 | 718 | |
673 | 719 | // Poster info ends. |
674 | 720 | echo ' |
@@ -698,9 +744,10 @@ discard block |
||
698 | 744 | echo ' |
699 | 745 | <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">'; |
700 | 746 | |
701 | - if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
|
702 | - echo |
|
747 | + if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) { |
|
748 | + echo |
|
703 | 749 | $message['modified']['last_edit_text']; |
750 | + } |
|
704 | 751 | |
705 | 752 | echo ' |
706 | 753 | </span> |
@@ -709,22 +756,24 @@ discard block |
||
709 | 756 | </div><!-- .keyinfo -->'; |
710 | 757 | |
711 | 758 | // Ignoring this user? Hide the post. |
712 | - if ($ignoring) |
|
713 | - echo ' |
|
759 | + if ($ignoring) { |
|
760 | + echo ' |
|
714 | 761 | <div id="msg_', $message['id'], '_ignored_prompt"> |
715 | 762 | ', $txt['ignoring_user'], ' |
716 | 763 | <a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
717 | 764 | </div>'; |
765 | + } |
|
718 | 766 | |
719 | 767 | // Show the post itself, finally! |
720 | 768 | echo ' |
721 | 769 | <div class="post">'; |
722 | 770 | |
723 | - if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) |
|
724 | - echo ' |
|
771 | + if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) { |
|
772 | + echo ' |
|
725 | 773 | <div class="approve_post"> |
726 | 774 | ', $txt['post_awaiting_approval'], ' |
727 | 775 | </div>'; |
776 | + } |
|
728 | 777 | echo ' |
729 | 778 | <div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '> |
730 | 779 | ', $message['body'], ' |
@@ -743,9 +792,9 @@ discard block |
||
743 | 792 | foreach ($message['attachment'] as $attachment) |
744 | 793 | { |
745 | 794 | // Do we want this attachment to not be showed here? |
746 | - if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) |
|
747 | - continue; |
|
748 | - elseif (!$div_output) |
|
795 | + if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) { |
|
796 | + continue; |
|
797 | + } elseif (!$div_output) |
|
749 | 798 | { |
750 | 799 | $div_output = true; |
751 | 800 | |
@@ -762,9 +811,10 @@ discard block |
||
762 | 811 | <legend> |
763 | 812 | ', $txt['attach_awaiting_approve']; |
764 | 813 | |
765 | - if ($context['can_approve']) |
|
766 | - echo ' |
|
814 | + if ($context['can_approve']) { |
|
815 | + echo ' |
|
767 | 816 | [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]'; |
817 | + } |
|
768 | 818 | |
769 | 819 | echo ' |
770 | 820 | </legend>'; |
@@ -778,12 +828,13 @@ discard block |
||
778 | 828 | echo ' |
779 | 829 | <div class="attachments_top">'; |
780 | 830 | |
781 | - if ($attachment['thumbnail']['has_thumb']) |
|
782 | - echo ' |
|
831 | + if ($attachment['thumbnail']['has_thumb']) { |
|
832 | + echo ' |
|
783 | 833 | <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>'; |
784 | - else |
|
785 | - echo ' |
|
834 | + } else { |
|
835 | + echo ' |
|
786 | 836 | <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">'; |
837 | + } |
|
787 | 838 | |
788 | 839 | echo ' |
789 | 840 | </div><!-- .attachments_top -->'; |
@@ -793,9 +844,10 @@ discard block |
||
793 | 844 | <div class="attachments_bot"> |
794 | 845 | <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*"> ' . $attachment['name'] . '</a> '; |
795 | 846 | |
796 | - if (!$attachment['is_approved'] && $context['can_approve']) |
|
797 | - echo ' |
|
847 | + if (!$attachment['is_approved'] && $context['can_approve']) { |
|
848 | + echo ' |
|
798 | 849 | [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] '; |
850 | + } |
|
799 | 851 | echo ' |
800 | 852 | <br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), ' |
801 | 853 | </div><!-- .attachments_bot -->'; |
@@ -804,35 +856,40 @@ discard block |
||
804 | 856 | </div><!-- .attached -->'; |
805 | 857 | |
806 | 858 | // Next attachment line ? |
807 | - if (++$i % $attachments_per_line === 0) |
|
808 | - echo ' |
|
859 | + if (++$i % $attachments_per_line === 0) { |
|
860 | + echo ' |
|
809 | 861 | <br>'; |
862 | + } |
|
810 | 863 | } |
811 | 864 | |
812 | 865 | // If we had unapproved attachments clean up. |
813 | - if ($last_approved_state == 0) |
|
814 | - echo ' |
|
866 | + if ($last_approved_state == 0) { |
|
867 | + echo ' |
|
815 | 868 | </fieldset>'; |
869 | + } |
|
816 | 870 | |
817 | 871 | // Only do this if we output a div above - otherwise it'll break things |
818 | - if ($div_output) |
|
819 | - echo ' |
|
872 | + if ($div_output) { |
|
873 | + echo ' |
|
820 | 874 | </div><!-- #msg_[id]_footer -->'; |
875 | + } |
|
821 | 876 | } |
822 | 877 | |
823 | 878 | // And stuff below the attachments. |
824 | - if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
825 | - echo ' |
|
879 | + if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
880 | + echo ' |
|
826 | 881 | <div class="under_message">'; |
882 | + } |
|
827 | 883 | |
828 | 884 | // Maybe they want to report this post to the moderator(s)? |
829 | - if ($context['can_report_moderator']) |
|
830 | - echo ' |
|
885 | + if ($context['can_report_moderator']) { |
|
886 | + echo ' |
|
831 | 887 | <ul class="floatright smalltext"> |
832 | 888 | <li class="report_link"> |
833 | 889 | <a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a> |
834 | 890 | </li> |
835 | 891 | </ul>'; |
892 | + } |
|
836 | 893 | |
837 | 894 | // What about likes? |
838 | 895 | if (!empty($modSettings['enable_likes'])) |
@@ -879,83 +936,95 @@ discard block |
||
879 | 936 | <ul class="quickbuttons">'; |
880 | 937 | |
881 | 938 | // Can they quote? if so they can select and quote as well! |
882 | - if ($context['can_quote']) |
|
883 | - echo ' |
|
939 | + if ($context['can_quote']) { |
|
940 | + echo ' |
|
884 | 941 | <li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li> |
885 | 942 | <li style="display:none;" id="quoteSelected_', $message['id'], '"> |
886 | 943 | <a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a> |
887 | 944 | </li>'; |
945 | + } |
|
888 | 946 | |
889 | 947 | // Can the user modify the contents of this post? Show the modify inline image. |
890 | - if ($message['can_modify']) |
|
891 | - echo ' |
|
948 | + if ($message['can_modify']) { |
|
949 | + echo ' |
|
892 | 950 | <li class="quick_edit"> |
893 | 951 | <a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a> |
894 | 952 | </li>'; |
953 | + } |
|
895 | 954 | |
896 | - if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
897 | - echo ' |
|
955 | + if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
956 | + echo ' |
|
898 | 957 | <li class="post_options">', $txt['post_options']; |
958 | + } |
|
899 | 959 | |
900 | 960 | echo ' |
901 | 961 | <ul>'; |
902 | 962 | |
903 | 963 | // Can the user modify the contents of this post? |
904 | - if ($message['can_modify']) |
|
905 | - echo ' |
|
964 | + if ($message['can_modify']) { |
|
965 | + echo ' |
|
906 | 966 | <li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>'; |
967 | + } |
|
907 | 968 | |
908 | 969 | // How about... even... remove it entirely?! |
909 | - if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) |
|
910 | - echo ' |
|
970 | + if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) { |
|
971 | + echo ' |
|
911 | 972 | <li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>'; |
912 | - |
|
913 | - elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) |
|
914 | - echo ' |
|
973 | + } elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) { |
|
974 | + echo ' |
|
915 | 975 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
976 | + } |
|
916 | 977 | |
917 | 978 | // What about splitting it off the rest of the topic? |
918 | - if ($context['can_split'] && !empty($context['real_num_replies'])) |
|
919 | - echo ' |
|
979 | + if ($context['can_split'] && !empty($context['real_num_replies'])) { |
|
980 | + echo ' |
|
920 | 981 | <li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>'; |
982 | + } |
|
921 | 983 | |
922 | 984 | // Can we issue a warning because of this post? Remember, we can't give guests warnings. |
923 | - if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) |
|
924 | - echo ' |
|
985 | + if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) { |
|
986 | + echo ' |
|
925 | 987 | <li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>'; |
988 | + } |
|
926 | 989 | |
927 | 990 | // Can we restore topics? |
928 | - if ($context['can_restore_msg']) |
|
929 | - echo ' |
|
991 | + if ($context['can_restore_msg']) { |
|
992 | + echo ' |
|
930 | 993 | <li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>'; |
994 | + } |
|
931 | 995 | |
932 | 996 | // Maybe we can approve it, maybe we should? |
933 | - if ($message['can_approve']) |
|
934 | - echo ' |
|
997 | + if ($message['can_approve']) { |
|
998 | + echo ' |
|
935 | 999 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>'; |
1000 | + } |
|
936 | 1001 | |
937 | 1002 | // Maybe we can unapprove it? |
938 | - if ($message['can_unapprove']) |
|
939 | - echo ' |
|
1003 | + if ($message['can_unapprove']) { |
|
1004 | + echo ' |
|
940 | 1005 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>'; |
1006 | + } |
|
941 | 1007 | |
942 | 1008 | echo ' |
943 | 1009 | </ul> |
944 | 1010 | </li>'; |
945 | 1011 | |
946 | 1012 | // Show a checkbox for quick moderation? |
947 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) |
|
948 | - echo ' |
|
1013 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) { |
|
1014 | + echo ' |
|
949 | 1015 | <li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>'; |
1016 | + } |
|
950 | 1017 | |
951 | - if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
952 | - echo ' |
|
1018 | + if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
1019 | + echo ' |
|
953 | 1020 | </ul><!-- .quickbuttons -->'; |
1021 | + } |
|
954 | 1022 | } |
955 | 1023 | |
956 | - if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
957 | - echo ' |
|
1024 | + if ($context['can_report_moderator'] || !empty($modSettings['enable_likes']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
1025 | + echo ' |
|
958 | 1026 | </div><!-- .under_message -->'; |
1027 | + } |
|
959 | 1028 | |
960 | 1029 | echo ' |
961 | 1030 | </div><!-- .postarea --> |
@@ -968,9 +1037,10 @@ discard block |
||
968 | 1037 | <div class="custom_fields_above_signature"> |
969 | 1038 | <ul class="nolist">'; |
970 | 1039 | |
971 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
972 | - echo ' |
|
1040 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
1041 | + echo ' |
|
973 | 1042 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
1043 | + } |
|
974 | 1044 | |
975 | 1045 | echo ' |
976 | 1046 | </ul> |
@@ -978,11 +1048,12 @@ discard block |
||
978 | 1048 | } |
979 | 1049 | |
980 | 1050 | // Show the member's signature? |
981 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
982 | - echo ' |
|
1051 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
1052 | + echo ' |
|
983 | 1053 | <div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '> |
984 | 1054 | ', $message['member']['signature'], ' |
985 | 1055 | </div>'; |
1056 | + } |
|
986 | 1057 | |
987 | 1058 | |
988 | 1059 | // Are there any custom profile fields for below the signature? |
@@ -992,9 +1063,10 @@ discard block |
||
992 | 1063 | <div class="custom_fields_below_signature"> |
993 | 1064 | <ul class="nolist">'; |
994 | 1065 | |
995 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
996 | - echo ' |
|
1066 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
1067 | + echo ' |
|
997 | 1068 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
1069 | + } |
|
998 | 1070 | |
999 | 1071 | echo ' |
1000 | 1072 | </ul> |
@@ -1027,24 +1099,28 @@ discard block |
||
1027 | 1099 | <div class="roundframe">'; |
1028 | 1100 | |
1029 | 1101 | // Are we hiding the full editor? |
1030 | - if (empty($options['use_editor_quick_reply'])) |
|
1031 | - echo ' |
|
1102 | + if (empty($options['use_editor_quick_reply'])) { |
|
1103 | + echo ' |
|
1032 | 1104 | <p class="smalltext lefttext">', $txt['quick_reply_desc'], '</p>'; |
1105 | + } |
|
1033 | 1106 | |
1034 | 1107 | // Is the topic locked? |
1035 | - if ($context['is_locked']) |
|
1036 | - echo ' |
|
1108 | + if ($context['is_locked']) { |
|
1109 | + echo ' |
|
1037 | 1110 | <p class="alert smalltext">', $txt['quick_reply_warning'], '</p>'; |
1111 | + } |
|
1038 | 1112 | |
1039 | 1113 | // Show a warning if the topic is old |
1040 | - if (!empty($context['oldTopicError'])) |
|
1041 | - echo ' |
|
1114 | + if (!empty($context['oldTopicError'])) { |
|
1115 | + echo ' |
|
1042 | 1116 | <p class="alert smalltext">', sprintf($txt['error_old_topic'], $modSettings['oldTopicDays']), '</p>'; |
1117 | + } |
|
1043 | 1118 | |
1044 | 1119 | // Does the post need approval? |
1045 | - if (!$context['can_reply_approved']) |
|
1046 | - echo ' |
|
1120 | + if (!$context['can_reply_approved']) { |
|
1121 | + echo ' |
|
1047 | 1122 | <p><em>', $txt['wait_for_approval'], '</em></p>'; |
1123 | + } |
|
1048 | 1124 | |
1049 | 1125 | echo ' |
1050 | 1126 | <form action="', $scripturl, '?board=', $context['current_board'], ';action=post2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" onsubmit="submitonce(this);"> |
@@ -1060,8 +1136,8 @@ discard block |
||
1060 | 1136 | <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">'; |
1061 | 1137 | |
1062 | 1138 | // Guests just need more. |
1063 | - if ($context['user']['is_guest']) |
|
1064 | - echo ' |
|
1139 | + if ($context['user']['is_guest']) { |
|
1140 | + echo ' |
|
1065 | 1141 | <dl id="post_header"> |
1066 | 1142 | <dt> |
1067 | 1143 | ', $txt['name'], ': |
@@ -1076,6 +1152,7 @@ discard block |
||
1076 | 1152 | <input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" required> |
1077 | 1153 | </dd> |
1078 | 1154 | </dl>'; |
1155 | + } |
|
1079 | 1156 | |
1080 | 1157 | echo ' |
1081 | 1158 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), ' |
@@ -1100,12 +1177,13 @@ discard block |
||
1100 | 1177 | </script>'; |
1101 | 1178 | |
1102 | 1179 | // Is visual verification enabled? |
1103 | - if ($context['require_verification']) |
|
1104 | - echo ' |
|
1180 | + if ($context['require_verification']) { |
|
1181 | + echo ' |
|
1105 | 1182 | <div class="post_verification"> |
1106 | 1183 | <strong>', $txt['verification'], ':</strong> |
1107 | 1184 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
1108 | 1185 | </div>'; |
1186 | + } |
|
1109 | 1187 | |
1110 | 1188 | // Finally, the submit buttons. |
1111 | 1189 | echo ' |
@@ -1121,8 +1199,8 @@ discard block |
||
1121 | 1199 | <br class="clear">'; |
1122 | 1200 | |
1123 | 1201 | // Draft autosave available and the user has it enabled? |
1124 | - if (!empty($context['drafts_autosave'])) |
|
1125 | - echo ' |
|
1202 | + if (!empty($context['drafts_autosave'])) { |
|
1203 | + echo ' |
|
1126 | 1204 | <script> |
1127 | 1205 | var oDraftAutoSave = new smf_DraftAutoSave({ |
1128 | 1206 | sSelf: \'oDraftAutoSave\', |
@@ -1134,12 +1212,14 @@ discard block |
||
1134 | 1212 | iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), ' |
1135 | 1213 | }); |
1136 | 1214 | </script>'; |
1215 | + } |
|
1137 | 1216 | |
1138 | - if ($context['show_spellchecking']) |
|
1139 | - echo ' |
|
1217 | + if ($context['show_spellchecking']) { |
|
1218 | + echo ' |
|
1140 | 1219 | <form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"> |
1141 | 1220 | <input type="hidden" name="spellstring" value=""> |
1142 | 1221 | </form>'; |
1222 | + } |
|
1143 | 1223 | |
1144 | 1224 | echo ' |
1145 | 1225 | <script> |
@@ -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 | * Display some useful/interesting board statistics. |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | |
31 | 32 | isAllowedTo('view_stats'); |
32 | 33 | // Page disabled - redirect them out |
33 | - if (empty($modSettings['trackStats'])) |
|
34 | - fatal_lang_error('feature_disabled', true); |
|
34 | + if (empty($modSettings['trackStats'])) { |
|
35 | + fatal_lang_error('feature_disabled', true); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | if (!empty($_REQUEST['expand'])) |
37 | 39 | { |
@@ -39,31 +41,34 @@ discard block |
||
39 | 41 | |
40 | 42 | $month = (int) substr($_REQUEST['expand'], 4); |
41 | 43 | $year = (int) substr($_REQUEST['expand'], 0, 4); |
42 | - if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) |
|
43 | - $_SESSION['expanded_stats'][$year][] = $month; |
|
44 | - } |
|
45 | - elseif (!empty($_REQUEST['collapse'])) |
|
44 | + if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) { |
|
45 | + $_SESSION['expanded_stats'][$year][] = $month; |
|
46 | + } |
|
47 | + } elseif (!empty($_REQUEST['collapse'])) |
|
46 | 48 | { |
47 | 49 | $context['robot_no_index'] = true; |
48 | 50 | |
49 | 51 | $month = (int) substr($_REQUEST['collapse'], 4); |
50 | 52 | $year = (int) substr($_REQUEST['collapse'], 0, 4); |
51 | - if (!empty($_SESSION['expanded_stats'][$year])) |
|
52 | - $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
53 | + if (!empty($_SESSION['expanded_stats'][$year])) { |
|
54 | + $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
55 | + } |
|
53 | 56 | } |
54 | 57 | |
55 | 58 | // Handle the XMLHttpRequest. |
56 | 59 | if (isset($_REQUEST['xml'])) |
57 | 60 | { |
58 | 61 | // Collapsing stats only needs adjustments of the session variables. |
59 | - if (!empty($_REQUEST['collapse'])) |
|
60 | - obExit(false); |
|
62 | + if (!empty($_REQUEST['collapse'])) { |
|
63 | + obExit(false); |
|
64 | + } |
|
61 | 65 | |
62 | 66 | $context['sub_template'] = 'stats'; |
63 | 67 | $context['yearly'] = array(); |
64 | 68 | |
65 | - if (empty($month) || empty($year)) |
|
66 | - return; |
|
69 | + if (empty($month) || empty($year)) { |
|
70 | + return; |
|
71 | + } |
|
67 | 72 | |
68 | 73 | getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month)); |
69 | 74 | $context['yearly'][$year]['months'][$month]['date'] = array( |
@@ -221,8 +226,9 @@ discard block |
||
221 | 226 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
222 | 227 | ); |
223 | 228 | |
224 | - if ($max_num_posts < $row_members['posts']) |
|
225 | - $max_num_posts = $row_members['posts']; |
|
229 | + if ($max_num_posts < $row_members['posts']) { |
|
230 | + $max_num_posts = $row_members['posts']; |
|
231 | + } |
|
226 | 232 | } |
227 | 233 | $smcFunc['db_free_result']($members_result); |
228 | 234 | |
@@ -258,8 +264,9 @@ discard block |
||
258 | 264 | 'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['name'] . '</a>' |
259 | 265 | ); |
260 | 266 | |
261 | - if ($max_num_posts < $row_board['num_posts']) |
|
262 | - $max_num_posts = $row_board['num_posts']; |
|
267 | + if ($max_num_posts < $row_board['num_posts']) { |
|
268 | + $max_num_posts = $row_board['num_posts']; |
|
269 | + } |
|
263 | 270 | } |
264 | 271 | $smcFunc['db_free_result']($boards_result); |
265 | 272 | |
@@ -285,12 +292,13 @@ discard block |
||
285 | 292 | ) |
286 | 293 | ); |
287 | 294 | $topic_ids = array(); |
288 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
289 | - $topic_ids[] = $row['id_topic']; |
|
295 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
296 | + $topic_ids[] = $row['id_topic']; |
|
297 | + } |
|
290 | 298 | $smcFunc['db_free_result']($request); |
299 | + } else { |
|
300 | + $topic_ids = array(); |
|
291 | 301 | } |
292 | - else |
|
293 | - $topic_ids = array(); |
|
294 | 302 | |
295 | 303 | // Topic replies top 10. |
296 | 304 | $topic_reply_result = $smcFunc['db_query']('', ' |
@@ -330,8 +338,9 @@ discard block |
||
330 | 338 | 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_reply['id_topic'] . '.0">' . $row_topic_reply['subject'] . '</a>' |
331 | 339 | ); |
332 | 340 | |
333 | - if ($max_num_replies < $row_topic_reply['num_replies']) |
|
334 | - $max_num_replies = $row_topic_reply['num_replies']; |
|
341 | + if ($max_num_replies < $row_topic_reply['num_replies']) { |
|
342 | + $max_num_replies = $row_topic_reply['num_replies']; |
|
343 | + } |
|
335 | 344 | } |
336 | 345 | $smcFunc['db_free_result']($topic_reply_result); |
337 | 346 | |
@@ -355,12 +364,13 @@ discard block |
||
355 | 364 | ) |
356 | 365 | ); |
357 | 366 | $topic_ids = array(); |
358 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
359 | - $topic_ids[] = $row['id_topic']; |
|
367 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
368 | + $topic_ids[] = $row['id_topic']; |
|
369 | + } |
|
360 | 370 | $smcFunc['db_free_result']($request); |
371 | + } else { |
|
372 | + $topic_ids = array(); |
|
361 | 373 | } |
362 | - else |
|
363 | - $topic_ids = array(); |
|
364 | 374 | |
365 | 375 | // Topic views top 10. |
366 | 376 | $topic_view_result = $smcFunc['db_query']('', ' |
@@ -400,8 +410,9 @@ discard block |
||
400 | 410 | 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . $row_topic_views['subject'] . '</a>' |
401 | 411 | ); |
402 | 412 | |
403 | - if ($max_num < $row_topic_views['num_views']) |
|
404 | - $max_num = $row_topic_views['num_views']; |
|
413 | + if ($max_num < $row_topic_views['num_views']) { |
|
414 | + $max_num = $row_topic_views['num_views']; |
|
415 | + } |
|
405 | 416 | } |
406 | 417 | $smcFunc['db_free_result']($topic_view_result); |
407 | 418 | |
@@ -426,15 +437,17 @@ discard block |
||
426 | 437 | ) |
427 | 438 | ); |
428 | 439 | $members = array(); |
429 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
430 | - $members[$row['id_member_started']] = $row['hits']; |
|
440 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
441 | + $members[$row['id_member_started']] = $row['hits']; |
|
442 | + } |
|
431 | 443 | $smcFunc['db_free_result']($request); |
432 | 444 | |
433 | 445 | cache_put_data('stats_top_starters', $members, 360); |
434 | 446 | } |
435 | 447 | |
436 | - if (empty($members)) |
|
437 | - $members = array(0 => 0); |
|
448 | + if (empty($members)) { |
|
449 | + $members = array(0 => 0); |
|
450 | + } |
|
438 | 451 | |
439 | 452 | // Topic poster top 10. |
440 | 453 | $members_result = $smcFunc['db_query']('', ' |
@@ -459,8 +472,9 @@ discard block |
||
459 | 472 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
460 | 473 | ); |
461 | 474 | |
462 | - if ($max_num < $members[$row_members['id_member']]) |
|
463 | - $max_num = $members[$row_members['id_member']]; |
|
475 | + if ($max_num < $members[$row_members['id_member']]) { |
|
476 | + $max_num = $members[$row_members['id_member']]; |
|
477 | + } |
|
464 | 478 | } |
465 | 479 | ksort($context['stats_blocks']['starters']); |
466 | 480 | $smcFunc['db_free_result']($members_result); |
@@ -489,8 +503,9 @@ discard block |
||
489 | 503 | while ($row_members = $smcFunc['db_fetch_assoc']($members_result)) |
490 | 504 | { |
491 | 505 | $temp2[] = (int) $row_members['id_member']; |
492 | - if (count($context['stats_blocks']['time_online']) >= 10) |
|
493 | - continue; |
|
506 | + if (count($context['stats_blocks']['time_online']) >= 10) { |
|
507 | + continue; |
|
508 | + } |
|
494 | 509 | |
495 | 510 | // Figure out the days, hours and minutes. |
496 | 511 | $timeDays = floor($row_members['total_time_logged_in'] / 86400); |
@@ -498,10 +513,12 @@ discard block |
||
498 | 513 | |
499 | 514 | // Figure out which things to show... (days, hours, minutes, etc.) |
500 | 515 | $timelogged = ''; |
501 | - if ($timeDays > 0) |
|
502 | - $timelogged .= $timeDays . $txt['totalTimeLogged5']; |
|
503 | - if ($timeHours > 0) |
|
504 | - $timelogged .= $timeHours . $txt['totalTimeLogged6']; |
|
516 | + if ($timeDays > 0) { |
|
517 | + $timelogged .= $timeDays . $txt['totalTimeLogged5']; |
|
518 | + } |
|
519 | + if ($timeHours > 0) { |
|
520 | + $timelogged .= $timeHours . $txt['totalTimeLogged6']; |
|
521 | + } |
|
505 | 522 | $timelogged .= floor(($row_members['total_time_logged_in'] % 3600) / 60) . $txt['totalTimeLogged7']; |
506 | 523 | |
507 | 524 | $context['stats_blocks']['time_online'][] = array( |
@@ -513,17 +530,20 @@ discard block |
||
513 | 530 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
514 | 531 | ); |
515 | 532 | |
516 | - if ($max_time_online < $row_members['total_time_logged_in']) |
|
517 | - $max_time_online = $row_members['total_time_logged_in']; |
|
533 | + if ($max_time_online < $row_members['total_time_logged_in']) { |
|
534 | + $max_time_online = $row_members['total_time_logged_in']; |
|
535 | + } |
|
518 | 536 | } |
519 | 537 | $smcFunc['db_free_result']($members_result); |
520 | 538 | |
521 | - foreach ($context['stats_blocks']['time_online'] as $i => $member) |
|
522 | - $context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online); |
|
539 | + foreach ($context['stats_blocks']['time_online'] as $i => $member) { |
|
540 | + $context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online); |
|
541 | + } |
|
523 | 542 | |
524 | 543 | // Cache the ones we found for a bit, just so we don't have to look again. |
525 | - if ($temp !== $temp2) |
|
526 | - cache_put_data('stats_total_time_members', $temp2, 480); |
|
544 | + if ($temp !== $temp2) { |
|
545 | + cache_put_data('stats_total_time_members', $temp2, 480); |
|
546 | + } |
|
527 | 547 | |
528 | 548 | // Likes. |
529 | 549 | if (!empty($modSettings['enable_likes'])) |
@@ -559,13 +579,15 @@ discard block |
||
559 | 579 | 'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>' |
560 | 580 | ); |
561 | 581 | |
562 | - if ($max_liked_message < $row_liked_message['likes']) |
|
563 | - $max_liked_message = $row_liked_message['likes']; |
|
582 | + if ($max_liked_message < $row_liked_message['likes']) { |
|
583 | + $max_liked_message = $row_liked_message['likes']; |
|
584 | + } |
|
564 | 585 | } |
565 | 586 | $smcFunc['db_free_result']($liked_messages); |
566 | 587 | |
567 | - foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) |
|
568 | - $context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message); |
|
588 | + foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) { |
|
589 | + $context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message); |
|
590 | + } |
|
569 | 591 | |
570 | 592 | // Liked users top 10. |
571 | 593 | $context['stats_blocks']['liked_users'] = array(); |
@@ -596,14 +618,16 @@ discard block |
||
596 | 618 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_liked_users['liked_user'] . '">' . $row_liked_users['real_name'] . '</a>', |
597 | 619 | ); |
598 | 620 | |
599 | - if ($max_liked_users < $row_liked_users['count']) |
|
600 | - $max_liked_users = $row_liked_users['count']; |
|
621 | + if ($max_liked_users < $row_liked_users['count']) { |
|
622 | + $max_liked_users = $row_liked_users['count']; |
|
623 | + } |
|
601 | 624 | } |
602 | 625 | |
603 | 626 | $smcFunc['db_free_result']($liked_users); |
604 | 627 | |
605 | - foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) |
|
606 | - $context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users); |
|
628 | + foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) { |
|
629 | + $context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users); |
|
630 | + } |
|
607 | 631 | } |
608 | 632 | |
609 | 633 | // Activity by month. |
@@ -621,8 +645,8 @@ discard block |
||
621 | 645 | $ID_MONTH = $row_months['stats_year'] . sprintf('%02d', $row_months['stats_month']); |
622 | 646 | $expanded = !empty($_SESSION['expanded_stats'][$row_months['stats_year']]) && in_array($row_months['stats_month'], $_SESSION['expanded_stats'][$row_months['stats_year']]); |
623 | 647 | |
624 | - if (!isset($context['yearly'][$row_months['stats_year']])) |
|
625 | - $context['yearly'][$row_months['stats_year']] = array( |
|
648 | + if (!isset($context['yearly'][$row_months['stats_year']])) { |
|
649 | + $context['yearly'][$row_months['stats_year']] = array( |
|
626 | 650 | 'year' => $row_months['stats_year'], |
627 | 651 | 'new_topics' => 0, |
628 | 652 | 'new_posts' => 0, |
@@ -634,6 +658,7 @@ discard block |
||
634 | 658 | 'expanded' => false, |
635 | 659 | 'current_year' => $row_months['stats_year'] == date('Y'), |
636 | 660 | ); |
661 | + } |
|
637 | 662 | |
638 | 663 | $context['yearly'][$row_months['stats_year']]['months'][(int) $row_months['stats_month']] = array( |
639 | 664 | 'id' => $ID_MONTH, |
@@ -679,29 +704,33 @@ discard block |
||
679 | 704 | $context['yearly'][$year]['hits'] = comma_format($data['hits']); |
680 | 705 | |
681 | 706 | // Keep a list of collapsed years. |
682 | - if (!$data['expanded'] && !$data['current_year']) |
|
683 | - $context['collapsed_years'][] = $year; |
|
707 | + if (!$data['expanded'] && !$data['current_year']) { |
|
708 | + $context['collapsed_years'][] = $year; |
|
709 | + } |
|
684 | 710 | } |
685 | 711 | |
686 | 712 | // Custom stats (just add a template_layer to add it to the template!) |
687 | 713 | call_integration_hook('integrate_forum_stats'); |
688 | 714 | |
689 | - if (empty($_SESSION['expanded_stats'])) |
|
690 | - return; |
|
715 | + if (empty($_SESSION['expanded_stats'])) { |
|
716 | + return; |
|
717 | + } |
|
691 | 718 | |
692 | 719 | $condition_text = array(); |
693 | 720 | $condition_params = array(); |
694 | - foreach ($_SESSION['expanded_stats'] as $year => $months) |
|
695 | - if (!empty($months)) |
|
721 | + foreach ($_SESSION['expanded_stats'] as $year => $months) { |
|
722 | + if (!empty($months)) |
|
696 | 723 | { |
697 | 724 | $condition_text[] = 'YEAR(date) = {int:year_' . $year . '} AND MONTH(date) IN ({array_int:months_' . $year . '})'; |
725 | + } |
|
698 | 726 | $condition_params['year_' . $year] = $year; |
699 | 727 | $condition_params['months_' . $year] = $months; |
700 | 728 | } |
701 | 729 | |
702 | 730 | // No daily stats to even look at? |
703 | - if (empty($condition_text)) |
|
704 | - return; |
|
731 | + if (empty($condition_text)) { |
|
732 | + return; |
|
733 | + } |
|
705 | 734 | |
706 | 735 | getDailyStats(implode(' OR ', $condition_text), $condition_params); |
707 | 736 | } |
@@ -724,8 +753,8 @@ discard block |
||
724 | 753 | ORDER BY stats_day ASC', |
725 | 754 | $condition_parameters |
726 | 755 | ); |
727 | - while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) |
|
728 | - $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array( |
|
756 | + while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) { |
|
757 | + $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array( |
|
729 | 758 | 'day' => sprintf('%02d', $row_days['stats_day']), |
730 | 759 | 'month' => sprintf('%02d', $row_days['stats_month']), |
731 | 760 | 'year' => $row_days['stats_year'], |
@@ -735,6 +764,7 @@ discard block |
||
735 | 764 | 'most_members_online' => comma_format($row_days['most_on']), |
736 | 765 | 'hits' => comma_format($row_days['hits']) |
737 | 766 | ); |
767 | + } |
|
738 | 768 | $smcFunc['db_free_result']($days_result); |
739 | 769 | } |
740 | 770 | |
@@ -752,16 +782,19 @@ discard block |
||
752 | 782 | global $modSettings, $user_info, $forum_version, $sourcedir; |
753 | 783 | |
754 | 784 | // First, is it disabled? |
755 | - if (empty($modSettings['enable_sm_stats']) || empty($modSettings['sm_stats_key'])) |
|
756 | - die(); |
|
785 | + if (empty($modSettings['enable_sm_stats']) || empty($modSettings['sm_stats_key'])) { |
|
786 | + die(); |
|
787 | + } |
|
757 | 788 | |
758 | 789 | // Are we saying who we are, and are we right? (OR an admin) |
759 | - if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['sm_stats_key'])) |
|
760 | - die(); |
|
790 | + if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['sm_stats_key'])) { |
|
791 | + die(); |
|
792 | + } |
|
761 | 793 | |
762 | 794 | // Verify the referer... |
763 | - if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) |
|
764 | - die(); |
|
795 | + if (!$user_info['is_admin'] && (!isset($_SERVER['HTTP_REFERER']) || md5($_SERVER['HTTP_REFERER']) != '746cb59a1a0d5cf4bd240e5a67c73085')) { |
|
796 | + die(); |
|
797 | + } |
|
765 | 798 | |
766 | 799 | // Get some server versions. |
767 | 800 | require_once($sourcedir . '/Subs-Admin.php'); |
@@ -787,16 +820,17 @@ discard block |
||
787 | 820 | ); |
788 | 821 | |
789 | 822 | // Encode all the data, for security. |
790 | - foreach ($stats_to_send as $k => $v) |
|
791 | - $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v); |
|
823 | + foreach ($stats_to_send as $k => $v) { |
|
824 | + $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v); |
|
825 | + } |
|
792 | 826 | |
793 | 827 | // Turn this into the query string! |
794 | 828 | $stats_to_send = implode('&', $stats_to_send); |
795 | 829 | |
796 | 830 | // If we're an admin, just plonk them out. |
797 | - if ($user_info['is_admin']) |
|
798 | - echo $stats_to_send; |
|
799 | - else |
|
831 | + if ($user_info['is_admin']) { |
|
832 | + echo $stats_to_send; |
|
833 | + } else |
|
800 | 834 | { |
801 | 835 | // Connect to the collection script. |
802 | 836 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
@@ -59,8 +59,9 @@ discard block |
||
59 | 59 | * @version 2.1 Beta 4 |
60 | 60 | */ |
61 | 61 | |
62 | -if (!defined('SMF')) |
|
62 | +if (!defined('SMF')) { |
|
63 | 63 | die('No direct access...'); |
64 | +} |
|
64 | 65 | |
65 | 66 | /** |
66 | 67 | * This is the main dispatcher. Sets up all the available sub-actions, all the tabs and selects |
@@ -111,10 +112,11 @@ discard block |
||
111 | 112 | $settings_not_writable = !is_writable($boarddir . '/Settings.php'); |
112 | 113 | $settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); |
113 | 114 | |
114 | - if ($settings_not_writable) |
|
115 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
116 | - elseif ($settings_backup_fail) |
|
117 | - $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
115 | + if ($settings_not_writable) { |
|
116 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br>'; |
|
117 | + } elseif ($settings_backup_fail) { |
|
118 | + $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br>'; |
|
119 | + } |
|
118 | 120 | |
119 | 121 | $context['settings_not_writable'] = $settings_not_writable; |
120 | 122 | |
@@ -142,10 +144,11 @@ discard block |
||
142 | 144 | |
143 | 145 | // If no cert, force_ssl must remain 0 |
144 | 146 | require_once($sourcedir . '/Subs.php'); |
145 | - if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl'])) |
|
146 | - $disable_force_ssl = true; |
|
147 | - else |
|
148 | - $disable_force_ssl = false; |
|
147 | + if (!ssl_cert_found($boardurl) && empty($modSettings['force_ssl'])) { |
|
148 | + $disable_force_ssl = true; |
|
149 | + } else { |
|
150 | + $disable_force_ssl = false; |
|
151 | + } |
|
149 | 152 | |
150 | 153 | /* If you're writing a mod, it's a bad idea to add things here.... |
151 | 154 | For each option: |
@@ -174,8 +177,9 @@ discard block |
||
174 | 177 | |
175 | 178 | call_integration_hook('integrate_general_settings', array(&$config_vars)); |
176 | 179 | |
177 | - if ($return_config) |
|
178 | - return $config_vars; |
|
180 | + if ($return_config) { |
|
181 | + return $config_vars; |
|
182 | + } |
|
179 | 183 | |
180 | 184 | // Setup the template stuff. |
181 | 185 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=general;save'; |
@@ -192,16 +196,18 @@ discard block |
||
192 | 196 | $registerSMStats = registerSMStats(); |
193 | 197 | |
194 | 198 | // Failed to register, disable it again. |
195 | - if (empty($registerSMStats)) |
|
196 | - $_POST['enable_sm_stats'] = 0; |
|
199 | + if (empty($registerSMStats)) { |
|
200 | + $_POST['enable_sm_stats'] = 0; |
|
201 | + } |
|
197 | 202 | } |
198 | 203 | |
199 | 204 | // Ensure all URLs are aligned with the new force_ssl setting |
200 | 205 | // Treat unset like 0 |
201 | - if (isset($_POST['force_ssl'])) |
|
202 | - AlignURLsWithSSLSetting($_POST['force_ssl']); |
|
203 | - else |
|
204 | - AlignURLsWithSSLSetting(0); |
|
206 | + if (isset($_POST['force_ssl'])) { |
|
207 | + AlignURLsWithSSLSetting($_POST['force_ssl']); |
|
208 | + } else { |
|
209 | + AlignURLsWithSSLSetting(0); |
|
210 | + } |
|
205 | 211 | |
206 | 212 | saveSettings($config_vars); |
207 | 213 | $_SESSION['adm-save'] = true; |
@@ -254,10 +260,11 @@ discard block |
||
254 | 260 | require_once($sourcedir . '/Subs-Admin.php'); |
255 | 261 | |
256 | 262 | // Check $boardurl |
257 | - if (!empty($new_force_ssl)) |
|
258 | - $newval = strtr($boardurl, array('http://' => 'https://')); |
|
259 | - else |
|
260 | - $newval = strtr($boardurl, array('https://' => 'http://')); |
|
263 | + if (!empty($new_force_ssl)) { |
|
264 | + $newval = strtr($boardurl, array('http://' => 'https://')); |
|
265 | + } else { |
|
266 | + $newval = strtr($boardurl, array('https://' => 'http://')); |
|
267 | + } |
|
261 | 268 | updateSettingsFile(array('boardurl' => '\'' . addslashes($newval) . '\'')); |
262 | 269 | |
263 | 270 | $new_settings = array(); |
@@ -265,20 +272,22 @@ discard block |
||
265 | 272 | // Check $smileys_url, but only if it points to a subfolder of $boardurl |
266 | 273 | if (BoardurlMatch($modSettings['smileys_url'])) |
267 | 274 | { |
268 | - if (!empty($new_force_ssl)) |
|
269 | - $newval = strtr($modSettings['smileys_url'], array('http://' => 'https://')); |
|
270 | - else |
|
271 | - $newval = strtr($modSettings['smileys_url'], array('https://' => 'http://')); |
|
275 | + if (!empty($new_force_ssl)) { |
|
276 | + $newval = strtr($modSettings['smileys_url'], array('http://' => 'https://')); |
|
277 | + } else { |
|
278 | + $newval = strtr($modSettings['smileys_url'], array('https://' => 'http://')); |
|
279 | + } |
|
272 | 280 | $new_settings['smileys_url'] = $newval; |
273 | 281 | } |
274 | 282 | |
275 | 283 | // Check $avatar_url, but only if it points to a subfolder of $boardurl |
276 | 284 | if (BoardurlMatch($modSettings['avatar_url'])) |
277 | 285 | { |
278 | - if (!empty($new_force_ssl)) |
|
279 | - $newval = strtr($modSettings['avatar_url'], array('http://' => 'https://')); |
|
280 | - else |
|
281 | - $newval = strtr($modSettings['avatar_url'], array('https://' => 'http://')); |
|
286 | + if (!empty($new_force_ssl)) { |
|
287 | + $newval = strtr($modSettings['avatar_url'], array('http://' => 'https://')); |
|
288 | + } else { |
|
289 | + $newval = strtr($modSettings['avatar_url'], array('https://' => 'http://')); |
|
290 | + } |
|
282 | 291 | $new_settings['avatar_url'] = $newval; |
283 | 292 | } |
284 | 293 | |
@@ -286,16 +295,18 @@ discard block |
||
286 | 295 | // This one had been optional in the past, make sure it is set first |
287 | 296 | if (isset($modSettings['custom_avatar_url']) && BoardurlMatch($modSettings['custom_avatar_url'])) |
288 | 297 | { |
289 | - if (!empty($new_force_ssl)) |
|
290 | - $newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://')); |
|
291 | - else |
|
292 | - $newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://')); |
|
298 | + if (!empty($new_force_ssl)) { |
|
299 | + $newval = strtr($modSettings['custom_avatar_url'], array('http://' => 'https://')); |
|
300 | + } else { |
|
301 | + $newval = strtr($modSettings['custom_avatar_url'], array('https://' => 'http://')); |
|
302 | + } |
|
293 | 303 | $new_settings['custom_avatar_url'] = $newval; |
294 | 304 | } |
295 | 305 | |
296 | 306 | // Save updates to the settings table |
297 | - if (!empty($new_settings)) |
|
298 | - updateSettings($new_settings, true); |
|
307 | + if (!empty($new_settings)) { |
|
308 | + updateSettings($new_settings, true); |
|
309 | + } |
|
299 | 310 | |
300 | 311 | // Now we move onto the themes. |
301 | 312 | // First, get a list of theme URLs... |
@@ -316,10 +327,11 @@ discard block |
||
316 | 327 | // First check to see if it points to a subfolder of $boardurl |
317 | 328 | if (BoardurlMatch($row['value'])) |
318 | 329 | { |
319 | - if (!empty($new_force_ssl)) |
|
320 | - $newval = strtr($row['value'], array('http://' => 'https://')); |
|
321 | - else |
|
322 | - $newval = strtr($row['value'], array('https://' => 'http://')); |
|
330 | + if (!empty($new_force_ssl)) { |
|
331 | + $newval = strtr($row['value'], array('http://' => 'https://')); |
|
332 | + } else { |
|
333 | + $newval = strtr($row['value'], array('https://' => 'http://')); |
|
334 | + } |
|
323 | 335 | $smcFunc['db_query']('', ' |
324 | 336 | UPDATE {db_prefix}themes |
325 | 337 | SET value = {string:theme_val} |
@@ -359,11 +371,12 @@ discard block |
||
359 | 371 | |
360 | 372 | // If leftmost portion of path matches boardurl, return true |
361 | 373 | $result = strpos($urlpath, $boardurlpath); |
362 | - if ($result === false || $result != 0) |
|
363 | - return false; |
|
364 | - else |
|
365 | - return true; |
|
366 | -} |
|
374 | + if ($result === false || $result != 0) { |
|
375 | + return false; |
|
376 | + } else { |
|
377 | + return true; |
|
378 | + } |
|
379 | + } |
|
367 | 380 | |
368 | 381 | /** |
369 | 382 | * Basic database and paths settings - database name, host, etc. |
@@ -402,8 +415,9 @@ discard block |
||
402 | 415 | $request = $smcFunc['db_query']('', 'SELECT cfgname FROM pg_ts_config', array()); |
403 | 416 | $fts_language = array(); |
404 | 417 | |
405 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
406 | - $fts_language[$row['cfgname']] = $row['cfgname']; |
|
418 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
419 | + $fts_language[$row['cfgname']] = $row['cfgname']; |
|
420 | + } |
|
407 | 421 | |
408 | 422 | $config_vars = array_merge ($config_vars, array( |
409 | 423 | '', |
@@ -415,20 +429,22 @@ discard block |
||
415 | 429 | |
416 | 430 | call_integration_hook('integrate_database_settings', array(&$config_vars)); |
417 | 431 | |
418 | - if ($return_config) |
|
419 | - return $config_vars; |
|
432 | + if ($return_config) { |
|
433 | + return $config_vars; |
|
434 | + } |
|
420 | 435 | |
421 | 436 | // Setup the template stuff. |
422 | 437 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=database;save'; |
423 | 438 | $context['settings_title'] = $txt['database_settings']; |
424 | 439 | $context['save_disabled'] = $context['settings_not_writable']; |
425 | 440 | |
426 | - if (!$smcFunc['db_allow_persistent']()) |
|
427 | - addInlineJavaScript(' |
|
441 | + if (!$smcFunc['db_allow_persistent']()) { |
|
442 | + addInlineJavaScript(' |
|
428 | 443 | $(function() |
429 | 444 | { |
430 | 445 | $("#db_persist").prop("disabled", true); |
431 | 446 | });', true); |
447 | + } |
|
432 | 448 | |
433 | 449 | // Saving settings? |
434 | 450 | if (isset($_REQUEST['save'])) |
@@ -498,13 +514,15 @@ discard block |
||
498 | 514 | hideGlobalCookies(); |
499 | 515 | });', true); |
500 | 516 | |
501 | - if (empty($user_settings['tfa_secret'])) |
|
502 | - addInlineJavaScript(''); |
|
517 | + if (empty($user_settings['tfa_secret'])) { |
|
518 | + addInlineJavaScript(''); |
|
519 | + } |
|
503 | 520 | |
504 | 521 | call_integration_hook('integrate_cookie_settings', array(&$config_vars)); |
505 | 522 | |
506 | - if ($return_config) |
|
507 | - return $config_vars; |
|
523 | + if ($return_config) { |
|
524 | + return $config_vars; |
|
525 | + } |
|
508 | 526 | |
509 | 527 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save'; |
510 | 528 | $context['settings_title'] = $txt['cookies_sessions_settings']; |
@@ -515,14 +533,17 @@ discard block |
||
515 | 533 | call_integration_hook('integrate_save_cookie_settings'); |
516 | 534 | |
517 | 535 | // Local and global do not play nicely together. |
518 | - if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) |
|
519 | - unset ($_POST['globalCookies']); |
|
536 | + if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) { |
|
537 | + unset ($_POST['globalCookies']); |
|
538 | + } |
|
520 | 539 | |
521 | - if (empty($modSettings['localCookies']) != empty($_POST['localCookies']) || empty($modSettings['globalCookies']) != empty($_POST['globalCookies'])) |
|
522 | - $scope_changed = true; |
|
540 | + if (empty($modSettings['localCookies']) != empty($_POST['localCookies']) || empty($modSettings['globalCookies']) != empty($_POST['globalCookies'])) { |
|
541 | + $scope_changed = true; |
|
542 | + } |
|
523 | 543 | |
524 | - if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) |
|
525 | - fatal_lang_error('invalid_cookie_domain', false); |
|
544 | + if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) { |
|
545 | + fatal_lang_error('invalid_cookie_domain', false); |
|
546 | + } |
|
526 | 547 | |
527 | 548 | saveSettings($config_vars); |
528 | 549 | |
@@ -605,8 +626,9 @@ discard block |
||
605 | 626 | |
606 | 627 | call_integration_hook('integrate_general_security_settings', array(&$config_vars)); |
607 | 628 | |
608 | - if ($return_config) |
|
609 | - return $config_vars; |
|
629 | + if ($return_config) { |
|
630 | + return $config_vars; |
|
631 | + } |
|
610 | 632 | |
611 | 633 | // Saving? |
612 | 634 | if (isset($_GET['save'])) |
@@ -645,8 +667,7 @@ discard block |
||
645 | 667 | $txt['cache_settings_message'] = $txt['detected_no_caching']; |
646 | 668 | $cache_level = array($txt['cache_off']); |
647 | 669 | $detected['none'] = $txt['cache_off']; |
648 | - } |
|
649 | - else |
|
670 | + } else |
|
650 | 671 | { |
651 | 672 | $txt['cache_settings_message'] = sprintf($txt['detected_accelerators'], implode(', ', $detected)); |
652 | 673 | $cache_level = array($txt['cache_off'], $txt['cache_level1'], $txt['cache_level2'], $txt['cache_level3']); |
@@ -683,8 +704,9 @@ discard block |
||
683 | 704 | } |
684 | 705 | } |
685 | 706 | } |
686 | - if ($return_config) |
|
687 | - return $config_vars; |
|
707 | + if ($return_config) { |
|
708 | + return $config_vars; |
|
709 | + } |
|
688 | 710 | |
689 | 711 | // Saving again? |
690 | 712 | if (isset($_GET['save'])) |
@@ -712,8 +734,9 @@ discard block |
||
712 | 734 | $context['save_disabled'] = $context['settings_not_writable']; |
713 | 735 | |
714 | 736 | // Decide what message to show. |
715 | - if (!$context['save_disabled']) |
|
716 | - $context['settings_message'] = $txt['caching_information']; |
|
737 | + if (!$context['save_disabled']) { |
|
738 | + $context['settings_message'] = $txt['caching_information']; |
|
739 | + } |
|
717 | 740 | |
718 | 741 | // Prepare the template. |
719 | 742 | prepareServerSettingsContext($config_vars); |
@@ -736,24 +759,25 @@ discard block |
||
736 | 759 | if (stripos(PHP_OS, 'win') === 0) |
737 | 760 | { |
738 | 761 | $context['settings_message'] = $txt['loadavg_disabled_windows']; |
739 | - if (isset($_GET['save'])) |
|
740 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
741 | - } |
|
742 | - elseif (stripos(PHP_OS, 'darwin') === 0) |
|
762 | + if (isset($_GET['save'])) { |
|
763 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_windows']; |
|
764 | + } |
|
765 | + } elseif (stripos(PHP_OS, 'darwin') === 0) |
|
743 | 766 | { |
744 | 767 | $context['settings_message'] = $txt['loadavg_disabled_osx']; |
745 | - if (isset($_GET['save'])) |
|
746 | - $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
747 | - } |
|
748 | - else |
|
768 | + if (isset($_GET['save'])) { |
|
769 | + $_SESSION['adm-save'] = $txt['loadavg_disabled_osx']; |
|
770 | + } |
|
771 | + } else |
|
749 | 772 | { |
750 | 773 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
751 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) |
|
752 | - $modSettings['load_average'] = (float) $matches[1]; |
|
753 | - elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) |
|
754 | - $modSettings['load_average'] = (float) $matches[1]; |
|
755 | - else |
|
756 | - unset($modSettings['load_average']); |
|
774 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) !== 0) { |
|
775 | + $modSettings['load_average'] = (float) $matches[1]; |
|
776 | + } elseif (($modSettings['load_average'] = @`uptime`) !== null && preg_match('~load averages?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) !== 0) { |
|
777 | + $modSettings['load_average'] = (float) $matches[1]; |
|
778 | + } else { |
|
779 | + unset($modSettings['load_average']); |
|
780 | + } |
|
757 | 781 | |
758 | 782 | if (!empty($modSettings['load_average']) || (isset($modSettings['load_average']) && $modSettings['load_average'] === 0.0)) |
759 | 783 | { |
@@ -789,8 +813,9 @@ discard block |
||
789 | 813 | |
790 | 814 | call_integration_hook('integrate_loadavg_settings', array(&$config_vars)); |
791 | 815 | |
792 | - if ($return_config) |
|
793 | - return $config_vars; |
|
816 | + if ($return_config) { |
|
817 | + return $config_vars; |
|
818 | + } |
|
794 | 819 | |
795 | 820 | $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=loads;save'; |
796 | 821 | $context['settings_title'] = $txt['load_balancing_settings']; |
@@ -801,24 +826,27 @@ discard block |
||
801 | 826 | // Stupidity is not allowed. |
802 | 827 | foreach ($_POST as $key => $value) |
803 | 828 | { |
804 | - if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) |
|
805 | - continue; |
|
806 | - else |
|
807 | - $_POST[$key] = (float) $value; |
|
808 | - |
|
809 | - if ($key == 'loadavg_auto_opt' && $value <= 1) |
|
810 | - $_POST['loadavg_auto_opt'] = 1.0; |
|
811 | - elseif ($key == 'loadavg_forum' && $value < 10) |
|
812 | - $_POST['loadavg_forum'] = 10.0; |
|
813 | - elseif ($value < 2) |
|
814 | - $_POST[$key] = 2.0; |
|
829 | + if (strpos($key, 'loadavg') === 0 || $key === 'loadavg_enable' || !in_array($key, array_keys($default_values))) { |
|
830 | + continue; |
|
831 | + } else { |
|
832 | + $_POST[$key] = (float) $value; |
|
833 | + } |
|
834 | + |
|
835 | + if ($key == 'loadavg_auto_opt' && $value <= 1) { |
|
836 | + $_POST['loadavg_auto_opt'] = 1.0; |
|
837 | + } elseif ($key == 'loadavg_forum' && $value < 10) { |
|
838 | + $_POST['loadavg_forum'] = 10.0; |
|
839 | + } elseif ($value < 2) { |
|
840 | + $_POST[$key] = 2.0; |
|
841 | + } |
|
815 | 842 | } |
816 | 843 | |
817 | 844 | call_integration_hook('integrate_save_loadavg_settings'); |
818 | 845 | |
819 | 846 | saveDBSettings($config_vars); |
820 | - if (!isset($_SESSION['adm-save'])) |
|
821 | - $_SESSION['adm-save'] = true; |
|
847 | + if (!isset($_SESSION['adm-save'])) { |
|
848 | + $_SESSION['adm-save'] = true; |
|
849 | + } |
|
822 | 850 | redirectexit('action=admin;area=serversettings;sa=loads;' . $context['session_var'] . '=' . $context['session_id']); |
823 | 851 | } |
824 | 852 | |
@@ -854,10 +882,11 @@ discard block |
||
854 | 882 | |
855 | 883 | if (isset($_SESSION['adm-save'])) |
856 | 884 | { |
857 | - if ($_SESSION['adm-save'] === true) |
|
858 | - $context['saved_successful'] = true; |
|
859 | - else |
|
860 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
885 | + if ($_SESSION['adm-save'] === true) { |
|
886 | + $context['saved_successful'] = true; |
|
887 | + } else { |
|
888 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
889 | + } |
|
861 | 890 | |
862 | 891 | unset($_SESSION['adm-save']); |
863 | 892 | } |
@@ -865,9 +894,9 @@ discard block |
||
865 | 894 | $context['config_vars'] = array(); |
866 | 895 | foreach ($config_vars as $identifier => $config_var) |
867 | 896 | { |
868 | - if (!is_array($config_var) || !isset($config_var[1])) |
|
869 | - $context['config_vars'][] = $config_var; |
|
870 | - else |
|
897 | + if (!is_array($config_var) || !isset($config_var[1])) { |
|
898 | + $context['config_vars'][] = $config_var; |
|
899 | + } else |
|
871 | 900 | { |
872 | 901 | $varname = $config_var[0]; |
873 | 902 | global $$varname; |
@@ -902,16 +931,19 @@ discard block |
||
902 | 931 | if ($config_var[3] == 'int' || $config_var[3] == 'float') |
903 | 932 | { |
904 | 933 | // Default to a min of 0 if one isn't set |
905 | - if (isset($config_var['min'])) |
|
906 | - $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
907 | - else |
|
908 | - $context['config_vars'][$config_var[0]]['min'] = 0; |
|
934 | + if (isset($config_var['min'])) { |
|
935 | + $context['config_vars'][$config_var[0]]['min'] = $config_var['min']; |
|
936 | + } else { |
|
937 | + $context['config_vars'][$config_var[0]]['min'] = 0; |
|
938 | + } |
|
909 | 939 | |
910 | - if (isset($config_var['max'])) |
|
911 | - $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
940 | + if (isset($config_var['max'])) { |
|
941 | + $context['config_vars'][$config_var[0]]['max'] = $config_var['max']; |
|
942 | + } |
|
912 | 943 | |
913 | - if (isset($config_var['step'])) |
|
914 | - $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
944 | + if (isset($config_var['step'])) { |
|
945 | + $context['config_vars'][$config_var[0]]['step'] = $config_var['step']; |
|
946 | + } |
|
915 | 947 | } |
916 | 948 | |
917 | 949 | // If this is a select box handle any data. |
@@ -919,12 +951,13 @@ discard block |
||
919 | 951 | { |
920 | 952 | // If it's associative |
921 | 953 | $config_values = array_values($config_var[4]); |
922 | - if (isset($config_values[0]) && is_array($config_values[0])) |
|
923 | - $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
924 | - else |
|
954 | + if (isset($config_values[0]) && is_array($config_values[0])) { |
|
955 | + $context['config_vars'][$config_var[0]]['data'] = $config_var[4]; |
|
956 | + } else |
|
925 | 957 | { |
926 | - foreach ($config_var[4] as $key => $item) |
|
927 | - $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
958 | + foreach ($config_var[4] as $key => $item) { |
|
959 | + $context['config_vars'][$config_var[0]]['data'][] = array($key, $item); |
|
960 | + } |
|
928 | 961 | } |
929 | 962 | } |
930 | 963 | } |
@@ -949,10 +982,11 @@ discard block |
||
949 | 982 | |
950 | 983 | if (isset($_SESSION['adm-save'])) |
951 | 984 | { |
952 | - if ($_SESSION['adm-save'] === true) |
|
953 | - $context['saved_successful'] = true; |
|
954 | - else |
|
955 | - $context['saved_failed'] = $_SESSION['adm-save']; |
|
985 | + if ($_SESSION['adm-save'] === true) { |
|
986 | + $context['saved_successful'] = true; |
|
987 | + } else { |
|
988 | + $context['saved_failed'] = $_SESSION['adm-save']; |
|
989 | + } |
|
956 | 990 | |
957 | 991 | unset($_SESSION['adm-save']); |
958 | 992 | } |
@@ -964,26 +998,30 @@ discard block |
||
964 | 998 | foreach ($config_vars as $config_var) |
965 | 999 | { |
966 | 1000 | // HR? |
967 | - if (!is_array($config_var)) |
|
968 | - $context['config_vars'][] = $config_var; |
|
969 | - else |
|
1001 | + if (!is_array($config_var)) { |
|
1002 | + $context['config_vars'][] = $config_var; |
|
1003 | + } else |
|
970 | 1004 | { |
971 | 1005 | // If it has no name it doesn't have any purpose! |
972 | - if (empty($config_var[1])) |
|
973 | - continue; |
|
1006 | + if (empty($config_var[1])) { |
|
1007 | + continue; |
|
1008 | + } |
|
974 | 1009 | |
975 | 1010 | // Special case for inline permissions |
976 | - if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) |
|
977 | - $inlinePermissions[] = $config_var[1]; |
|
978 | - elseif ($config_var[0] == 'permissions') |
|
979 | - continue; |
|
1011 | + if ($config_var[0] == 'permissions' && allowedTo('manage_permissions')) { |
|
1012 | + $inlinePermissions[] = $config_var[1]; |
|
1013 | + } elseif ($config_var[0] == 'permissions') { |
|
1014 | + continue; |
|
1015 | + } |
|
980 | 1016 | |
981 | - if ($config_var[0] == 'boards') |
|
982 | - $board_list = true; |
|
1017 | + if ($config_var[0] == 'boards') { |
|
1018 | + $board_list = true; |
|
1019 | + } |
|
983 | 1020 | |
984 | 1021 | // Are we showing the BBC selection box? |
985 | - if ($config_var[0] == 'bbc') |
|
986 | - $bbcChoice[] = $config_var[1]; |
|
1022 | + if ($config_var[0] == 'bbc') { |
|
1023 | + $bbcChoice[] = $config_var[1]; |
|
1024 | + } |
|
987 | 1025 | |
988 | 1026 | // We need to do some parsing of the value before we pass it in. |
989 | 1027 | if (isset($modSettings[$config_var[1]])) |
@@ -1002,8 +1040,7 @@ discard block |
||
1002 | 1040 | default: |
1003 | 1041 | $value = $smcFunc['htmlspecialchars']($modSettings[$config_var[1]]); |
1004 | 1042 | } |
1005 | - } |
|
1006 | - else |
|
1043 | + } else |
|
1007 | 1044 | { |
1008 | 1045 | // Darn, it's empty. What type is expected? |
1009 | 1046 | switch ($config_var[0]) |
@@ -1043,16 +1080,19 @@ discard block |
||
1043 | 1080 | if ($config_var[0] == 'int' || $config_var[0] == 'float') |
1044 | 1081 | { |
1045 | 1082 | // Default to a min of 0 if one isn't set |
1046 | - if (isset($config_var['min'])) |
|
1047 | - $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
1048 | - else |
|
1049 | - $context['config_vars'][$config_var[1]]['min'] = 0; |
|
1083 | + if (isset($config_var['min'])) { |
|
1084 | + $context['config_vars'][$config_var[1]]['min'] = $config_var['min']; |
|
1085 | + } else { |
|
1086 | + $context['config_vars'][$config_var[1]]['min'] = 0; |
|
1087 | + } |
|
1050 | 1088 | |
1051 | - if (isset($config_var['max'])) |
|
1052 | - $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
1089 | + if (isset($config_var['max'])) { |
|
1090 | + $context['config_vars'][$config_var[1]]['max'] = $config_var['max']; |
|
1091 | + } |
|
1053 | 1092 | |
1054 | - if (isset($config_var['step'])) |
|
1055 | - $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
1093 | + if (isset($config_var['step'])) { |
|
1094 | + $context['config_vars'][$config_var[1]]['step'] = $config_var['step']; |
|
1095 | + } |
|
1056 | 1096 | } |
1057 | 1097 | |
1058 | 1098 | // If this is a select box handle any data. |
@@ -1066,12 +1106,13 @@ discard block |
||
1066 | 1106 | } |
1067 | 1107 | |
1068 | 1108 | // If it's associative |
1069 | - if (isset($config_var[2][0]) && is_array($config_var[2][0])) |
|
1070 | - $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
1071 | - else |
|
1109 | + if (isset($config_var[2][0]) && is_array($config_var[2][0])) { |
|
1110 | + $context['config_vars'][$config_var[1]]['data'] = $config_var[2]; |
|
1111 | + } else |
|
1072 | 1112 | { |
1073 | - foreach ($config_var[2] as $key => $item) |
|
1074 | - $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
1113 | + foreach ($config_var[2] as $key => $item) { |
|
1114 | + $context['config_vars'][$config_var[1]]['data'][] = array($key, $item); |
|
1115 | + } |
|
1075 | 1116 | } |
1076 | 1117 | } |
1077 | 1118 | |
@@ -1080,17 +1121,19 @@ discard block |
||
1080 | 1121 | { |
1081 | 1122 | if (!is_numeric($k)) |
1082 | 1123 | { |
1083 | - if (substr($k, 0, 2) == 'on') |
|
1084 | - $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
1085 | - else |
|
1086 | - $context['config_vars'][$config_var[1]][$k] = $v; |
|
1124 | + if (substr($k, 0, 2) == 'on') { |
|
1125 | + $context['config_vars'][$config_var[1]]['javascript'] .= ' ' . $k . '="' . $v . '"'; |
|
1126 | + } else { |
|
1127 | + $context['config_vars'][$config_var[1]][$k] = $v; |
|
1128 | + } |
|
1087 | 1129 | } |
1088 | 1130 | |
1089 | 1131 | // See if there are any other labels that might fit? |
1090 | - if (isset($txt['setting_' . $config_var[1]])) |
|
1091 | - $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
1092 | - elseif (isset($txt['groups_' . $config_var[1]])) |
|
1093 | - $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
1132 | + if (isset($txt['setting_' . $config_var[1]])) { |
|
1133 | + $context['config_vars'][$config_var[1]]['label'] = $txt['setting_' . $config_var[1]]; |
|
1134 | + } elseif (isset($txt['groups_' . $config_var[1]])) { |
|
1135 | + $context['config_vars'][$config_var[1]]['label'] = $txt['groups_' . $config_var[1]]; |
|
1136 | + } |
|
1094 | 1137 | } |
1095 | 1138 | |
1096 | 1139 | // Set the subtext in case it's part of the label. |
@@ -1123,8 +1166,9 @@ discard block |
||
1123 | 1166 | // What are the options, eh? |
1124 | 1167 | $temp = parse_bbc(false); |
1125 | 1168 | $bbcTags = array(); |
1126 | - foreach ($temp as $tag) |
|
1127 | - $bbcTags[] = $tag['tag']; |
|
1169 | + foreach ($temp as $tag) { |
|
1170 | + $bbcTags[] = $tag['tag']; |
|
1171 | + } |
|
1128 | 1172 | |
1129 | 1173 | $bbcTags = array_unique($bbcTags); |
1130 | 1174 | $totalTags = count($bbcTags); |
@@ -1139,8 +1183,9 @@ discard block |
||
1139 | 1183 | $col = 0; $i = 0; |
1140 | 1184 | foreach ($bbcTags as $tag) |
1141 | 1185 | { |
1142 | - if ($i % $tagsPerColumn == 0 && $i != 0) |
|
1143 | - $col++; |
|
1186 | + if ($i % $tagsPerColumn == 0 && $i != 0) { |
|
1187 | + $col++; |
|
1188 | + } |
|
1144 | 1189 | |
1145 | 1190 | $context['bbc_columns'][$col][] = array( |
1146 | 1191 | 'tag' => $tag, |
@@ -1183,18 +1228,21 @@ discard block |
||
1183 | 1228 | validateToken('admin-ssc'); |
1184 | 1229 | |
1185 | 1230 | // Fix the darn stupid cookiename! (more may not be allowed, but these for sure!) |
1186 | - if (isset($_POST['cookiename'])) |
|
1187 | - $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
1231 | + if (isset($_POST['cookiename'])) { |
|
1232 | + $_POST['cookiename'] = preg_replace('~[,;\s\.$]+~' . ($context['utf8'] ? 'u' : ''), '', $_POST['cookiename']); |
|
1233 | + } |
|
1188 | 1234 | |
1189 | 1235 | // Fix the forum's URL if necessary. |
1190 | 1236 | if (isset($_POST['boardurl'])) |
1191 | 1237 | { |
1192 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
1193 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1194 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
1195 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1196 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
1197 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1238 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
1239 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
1240 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
1241 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
1242 | + } |
|
1243 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
1244 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
1245 | + } |
|
1198 | 1246 | } |
1199 | 1247 | |
1200 | 1248 | // Any passwords? |
@@ -1229,21 +1277,21 @@ discard block |
||
1229 | 1277 | // Figure out which config vars we're saving here... |
1230 | 1278 | foreach ($config_vars as $var) |
1231 | 1279 | { |
1232 | - if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) |
|
1233 | - continue; |
|
1280 | + if (!is_array($var) || $var[2] != 'file' || (!in_array($var[0], $config_bools) && !isset($_POST[$var[0]]))) { |
|
1281 | + continue; |
|
1282 | + } |
|
1234 | 1283 | |
1235 | 1284 | $config_var = $var[0]; |
1236 | 1285 | |
1237 | 1286 | if (in_array($config_var, $config_passwords)) |
1238 | 1287 | { |
1239 | - if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) |
|
1240 | - $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
1241 | - } |
|
1242 | - elseif (in_array($config_var, $config_strs)) |
|
1288 | + if (isset($_POST[$config_var][1]) && $_POST[$config_var][0] == $_POST[$config_var][1]) { |
|
1289 | + $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var][0], '\'\\') . '\''; |
|
1290 | + } |
|
1291 | + } elseif (in_array($config_var, $config_strs)) |
|
1243 | 1292 | { |
1244 | 1293 | $new_settings[$config_var] = '\'' . addcslashes($_POST[$config_var], '\'\\') . '\''; |
1245 | - } |
|
1246 | - elseif (in_array($config_var, $config_ints)) |
|
1294 | + } elseif (in_array($config_var, $config_ints)) |
|
1247 | 1295 | { |
1248 | 1296 | $new_settings[$config_var] = (int) $_POST[$config_var]; |
1249 | 1297 | |
@@ -1252,17 +1300,17 @@ discard block |
||
1252 | 1300 | $new_settings[$config_var] = max($min, $new_settings[$config_var]); |
1253 | 1301 | |
1254 | 1302 | // Is there a max value for this as well? |
1255 | - if (isset($var['max'])) |
|
1256 | - $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
1257 | - } |
|
1258 | - elseif (in_array($config_var, $config_bools)) |
|
1303 | + if (isset($var['max'])) { |
|
1304 | + $new_settings[$config_var] = min($var['max'], $new_settings[$config_var]); |
|
1305 | + } |
|
1306 | + } elseif (in_array($config_var, $config_bools)) |
|
1259 | 1307 | { |
1260 | - if (!empty($_POST[$config_var])) |
|
1261 | - $new_settings[$config_var] = '1'; |
|
1262 | - else |
|
1263 | - $new_settings[$config_var] = '0'; |
|
1264 | - } |
|
1265 | - else |
|
1308 | + if (!empty($_POST[$config_var])) { |
|
1309 | + $new_settings[$config_var] = '1'; |
|
1310 | + } else { |
|
1311 | + $new_settings[$config_var] = '0'; |
|
1312 | + } |
|
1313 | + } else |
|
1266 | 1314 | { |
1267 | 1315 | // This shouldn't happen, but it might... |
1268 | 1316 | fatal_error('Unknown config_var \'' . $config_var . '\''); |
@@ -1278,30 +1326,35 @@ discard block |
||
1278 | 1326 | foreach ($config_vars as $config_var) |
1279 | 1327 | { |
1280 | 1328 | // We just saved the file-based settings, so skip their definitions. |
1281 | - if (!is_array($config_var) || $config_var[2] == 'file') |
|
1282 | - continue; |
|
1329 | + if (!is_array($config_var) || $config_var[2] == 'file') { |
|
1330 | + continue; |
|
1331 | + } |
|
1283 | 1332 | |
1284 | 1333 | $new_setting = array($config_var[3], $config_var[0]); |
1285 | 1334 | |
1286 | 1335 | // Select options need carried over, too. |
1287 | - if (isset($config_var[4])) |
|
1288 | - $new_setting[] = $config_var[4]; |
|
1336 | + if (isset($config_var[4])) { |
|
1337 | + $new_setting[] = $config_var[4]; |
|
1338 | + } |
|
1289 | 1339 | |
1290 | 1340 | // Include min and max if necessary |
1291 | - if (isset($config_var['min'])) |
|
1292 | - $new_setting['min'] = $config_var['min']; |
|
1341 | + if (isset($config_var['min'])) { |
|
1342 | + $new_setting['min'] = $config_var['min']; |
|
1343 | + } |
|
1293 | 1344 | |
1294 | - if (isset($config_var['max'])) |
|
1295 | - $new_setting['max'] = $config_var['max']; |
|
1345 | + if (isset($config_var['max'])) { |
|
1346 | + $new_setting['max'] = $config_var['max']; |
|
1347 | + } |
|
1296 | 1348 | |
1297 | 1349 | // Rewrite the definition a bit. |
1298 | 1350 | $new_settings[] = $new_setting; |
1299 | 1351 | } |
1300 | 1352 | |
1301 | 1353 | // Save the new database-based settings, if any. |
1302 | - if (!empty($new_settings)) |
|
1303 | - saveDBSettings($new_settings); |
|
1304 | -} |
|
1354 | + if (!empty($new_settings)) { |
|
1355 | + saveDBSettings($new_settings); |
|
1356 | + } |
|
1357 | + } |
|
1305 | 1358 | |
1306 | 1359 | /** |
1307 | 1360 | * Helper function for saving database settings. |
@@ -1319,22 +1372,25 @@ discard block |
||
1319 | 1372 | $inlinePermissions = array(); |
1320 | 1373 | foreach ($config_vars as $var) |
1321 | 1374 | { |
1322 | - if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) |
|
1323 | - continue; |
|
1375 | + if (!isset($var[1]) || (!isset($_POST[$var[1]]) && $var[0] != 'check' && $var[0] != 'permissions' && $var[0] != 'boards' && ($var[0] != 'bbc' || !isset($_POST[$var[1] . '_enabledTags'])))) { |
|
1376 | + continue; |
|
1377 | + } |
|
1324 | 1378 | |
1325 | 1379 | // Checkboxes! |
1326 | - elseif ($var[0] == 'check') |
|
1327 | - $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
1380 | + elseif ($var[0] == 'check') { |
|
1381 | + $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; |
|
1382 | + } |
|
1328 | 1383 | // Select boxes! |
1329 | - elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) |
|
1330 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
1331 | - elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
1384 | + elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) { |
|
1385 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
1386 | + } elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != array()) |
|
1332 | 1387 | { |
1333 | 1388 | // For security purposes we validate this line by line. |
1334 | 1389 | $lOptions = array(); |
1335 | - foreach ($_POST[$var[1]] as $invar) |
|
1336 | - if (in_array($invar, array_keys($var[2]))) |
|
1390 | + foreach ($_POST[$var[1]] as $invar) { |
|
1391 | + if (in_array($invar, array_keys($var[2]))) |
|
1337 | 1392 | $lOptions[] = $invar; |
1393 | + } |
|
1338 | 1394 | |
1339 | 1395 | $setArray[$var[1]] = $smcFunc['json_encode']($lOptions); |
1340 | 1396 | } |
@@ -1348,18 +1404,20 @@ discard block |
||
1348 | 1404 | $request = $smcFunc['db_query']('', ' |
1349 | 1405 | SELECT id_board |
1350 | 1406 | FROM {db_prefix}boards'); |
1351 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1352 | - $board_list[$row[0]] = true; |
|
1407 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1408 | + $board_list[$row[0]] = true; |
|
1409 | + } |
|
1353 | 1410 | |
1354 | 1411 | $smcFunc['db_free_result']($request); |
1355 | 1412 | } |
1356 | 1413 | |
1357 | 1414 | $lOptions = array(); |
1358 | 1415 | |
1359 | - if (!empty($_POST[$var[1]])) |
|
1360 | - foreach ($_POST[$var[1]] as $invar => $dummy) |
|
1416 | + if (!empty($_POST[$var[1]])) { |
|
1417 | + foreach ($_POST[$var[1]] as $invar => $dummy) |
|
1361 | 1418 | if (isset($board_list[$invar])) |
1362 | 1419 | $lOptions[] = $invar; |
1420 | + } |
|
1363 | 1421 | |
1364 | 1422 | $setArray[$var[1]] = !empty($lOptions) ? implode(',', $lOptions) : ''; |
1365 | 1423 | } |
@@ -1373,8 +1431,9 @@ discard block |
||
1373 | 1431 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
1374 | 1432 | |
1375 | 1433 | // Do we have a max value for this as well? |
1376 | - if (isset($var['max'])) |
|
1377 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1434 | + if (isset($var['max'])) { |
|
1435 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1436 | + } |
|
1378 | 1437 | } |
1379 | 1438 | // Floating point! |
1380 | 1439 | elseif ($var[0] == 'float') |
@@ -1386,39 +1445,46 @@ discard block |
||
1386 | 1445 | $setArray[$var[1]] = max($min, $setArray[$var[1]]); |
1387 | 1446 | |
1388 | 1447 | // Do we have a max value for this as well? |
1389 | - if (isset($var['max'])) |
|
1390 | - $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1448 | + if (isset($var['max'])) { |
|
1449 | + $setArray[$var[1]] = min($var['max'], $setArray[$var[1]]); |
|
1450 | + } |
|
1391 | 1451 | } |
1392 | 1452 | // Text! |
1393 | - elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) |
|
1394 | - $setArray[$var[1]] = $_POST[$var[1]]; |
|
1453 | + elseif (in_array($var[0], array('text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'))) { |
|
1454 | + $setArray[$var[1]] = $_POST[$var[1]]; |
|
1455 | + } |
|
1395 | 1456 | // Passwords! |
1396 | 1457 | elseif ($var[0] == 'password') |
1397 | 1458 | { |
1398 | - if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) |
|
1399 | - $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
1459 | + if (isset($_POST[$var[1]][1]) && $_POST[$var[1]][0] == $_POST[$var[1]][1]) { |
|
1460 | + $setArray[$var[1]] = $_POST[$var[1]][0]; |
|
1461 | + } |
|
1400 | 1462 | } |
1401 | 1463 | // BBC. |
1402 | 1464 | elseif ($var[0] == 'bbc') |
1403 | 1465 | { |
1404 | 1466 | $bbcTags = array(); |
1405 | - foreach (parse_bbc(false) as $tag) |
|
1406 | - $bbcTags[] = $tag['tag']; |
|
1467 | + foreach (parse_bbc(false) as $tag) { |
|
1468 | + $bbcTags[] = $tag['tag']; |
|
1469 | + } |
|
1407 | 1470 | |
1408 | - if (!isset($_POST[$var[1] . '_enabledTags'])) |
|
1409 | - $_POST[$var[1] . '_enabledTags'] = array(); |
|
1410 | - elseif (!is_array($_POST[$var[1] . '_enabledTags'])) |
|
1411 | - $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
1471 | + if (!isset($_POST[$var[1] . '_enabledTags'])) { |
|
1472 | + $_POST[$var[1] . '_enabledTags'] = array(); |
|
1473 | + } elseif (!is_array($_POST[$var[1] . '_enabledTags'])) { |
|
1474 | + $_POST[$var[1] . '_enabledTags'] = array($_POST[$var[1] . '_enabledTags']); |
|
1475 | + } |
|
1412 | 1476 | |
1413 | 1477 | $setArray[$var[1]] = implode(',', array_diff($bbcTags, $_POST[$var[1] . '_enabledTags'])); |
1414 | 1478 | } |
1415 | 1479 | // Permissions? |
1416 | - elseif ($var[0] == 'permissions') |
|
1417 | - $inlinePermissions[] = $var[1]; |
|
1480 | + elseif ($var[0] == 'permissions') { |
|
1481 | + $inlinePermissions[] = $var[1]; |
|
1482 | + } |
|
1418 | 1483 | } |
1419 | 1484 | |
1420 | - if (!empty($setArray)) |
|
1421 | - updateSettings($setArray); |
|
1485 | + if (!empty($setArray)) { |
|
1486 | + updateSettings($setArray); |
|
1487 | + } |
|
1422 | 1488 | |
1423 | 1489 | // If we have inline permissions we need to save them. |
1424 | 1490 | if (!empty($inlinePermissions) && allowedTo('manage_permissions')) |
@@ -1455,18 +1521,21 @@ discard block |
||
1455 | 1521 | // put all of it into an array |
1456 | 1522 | foreach ($info_lines as $line) |
1457 | 1523 | { |
1458 | - if (preg_match('~(' . $remove . ')~', $line)) |
|
1459 | - continue; |
|
1524 | + if (preg_match('~(' . $remove . ')~', $line)) { |
|
1525 | + continue; |
|
1526 | + } |
|
1460 | 1527 | |
1461 | 1528 | // new category? |
1462 | - if (strpos($line, '<h2>') !== false) |
|
1463 | - $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
1529 | + if (strpos($line, '<h2>') !== false) { |
|
1530 | + $category = preg_match('~<h2>(.*)</h2>~', $line, $title) ? $category = $title[1] : $category; |
|
1531 | + } |
|
1464 | 1532 | |
1465 | 1533 | // load it as setting => value or the old setting local master |
1466 | - if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
1467 | - $pinfo[$category][$val[1]] = $val[2]; |
|
1468 | - elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) |
|
1469 | - $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
1534 | + if (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
1535 | + $pinfo[$category][$val[1]] = $val[2]; |
|
1536 | + } elseif (preg_match('~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~', $line, $val)) { |
|
1537 | + $pinfo[$category][$val[1]] = array($txt['phpinfo_localsettings'] => $val[2], $txt['phpinfo_defaultsettings'] => $val[3]); |
|
1538 | + } |
|
1470 | 1539 | } |
1471 | 1540 | |
1472 | 1541 | // load it in to context and display it |
@@ -1501,8 +1570,9 @@ discard block |
||
1501 | 1570 | $testAPI = new $cache_class_name(); |
1502 | 1571 | |
1503 | 1572 | // No Support? NEXT! |
1504 | - if (!$testAPI->isSupported(true)) |
|
1505 | - continue; |
|
1573 | + if (!$testAPI->isSupported(true)) { |
|
1574 | + continue; |
|
1575 | + } |
|
1506 | 1576 | |
1507 | 1577 | $apis[$tryCache] = isset($txt[$tryCache . '_cache']) ? $txt[$tryCache . '_cache'] : $tryCache; |
1508 | 1578 | } |
@@ -1527,8 +1597,9 @@ discard block |
||
1527 | 1597 | global $modSettings, $boardurl, $smcFunc; |
1528 | 1598 | |
1529 | 1599 | // Already have a key? Can't register again. |
1530 | - if (!empty($modSettings['sm_stats_key'])) |
|
1531 | - return true; |
|
1600 | + if (!empty($modSettings['sm_stats_key'])) { |
|
1601 | + return true; |
|
1602 | + } |
|
1532 | 1603 | |
1533 | 1604 | $fp = @fsockopen('www.simplemachines.org', 80, $errno, $errstr); |
1534 | 1605 | if ($fp) |
@@ -1539,8 +1610,9 @@ discard block |
||
1539 | 1610 | fwrite($fp, $out); |
1540 | 1611 | |
1541 | 1612 | $return_data = ''; |
1542 | - while (!feof($fp)) |
|
1543 | - $return_data .= fgets($fp, 128); |
|
1613 | + while (!feof($fp)) { |
|
1614 | + $return_data .= fgets($fp, 128); |
|
1615 | + } |
|
1544 | 1616 | |
1545 | 1617 | fclose($fp); |
1546 | 1618 |
@@ -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 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
56 | 57 | |
57 | 58 | $context['name'] = $board_info['name']; |
58 | 59 | $context['description'] = $board_info['description']; |
59 | - if (!empty($board_info['description'])) |
|
60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
60 | + if (!empty($board_info['description'])) { |
|
61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
62 | + } |
|
61 | 63 | |
62 | 64 | // How many topics do we have in total? |
63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
73 | 75 | $session_name = session_name(); |
74 | 76 | foreach ($_GET as $k => $v) |
75 | 77 | { |
76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
77 | - $context['robot_no_index'] = true; |
|
78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
79 | + $context['robot_no_index'] = true; |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | } |
80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
81 | - $context['robot_no_index'] = true; |
|
83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
84 | + $context['robot_no_index'] = true; |
|
85 | + } |
|
82 | 86 | |
83 | 87 | // If we can view unapproved messages and there are some build up a list. |
84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
89 | 93 | } |
90 | 94 | |
91 | 95 | // We only know these. |
92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
93 | - $_REQUEST['sort'] = 'last_post'; |
|
96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
97 | + $_REQUEST['sort'] = 'last_post'; |
|
98 | + } |
|
94 | 99 | |
95 | 100 | // Make sure the starting place makes sense and construct the page index. |
96 | - if (isset($_REQUEST['sort'])) |
|
97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
98 | - else |
|
99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
101 | + if (isset($_REQUEST['sort'])) { |
|
102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
103 | + } else { |
|
104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
105 | + } |
|
100 | 106 | $context['start'] = &$_REQUEST['start']; |
101 | 107 | |
102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
132 | 138 | $context['link_moderators'] = array(); |
133 | 139 | if (!empty($board_info['moderators'])) |
134 | 140 | { |
135 | - foreach ($board_info['moderators'] as $mod) |
|
136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
141 | + foreach ($board_info['moderators'] as $mod) { |
|
142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
143 | + } |
|
137 | 144 | } |
138 | 145 | if (!empty($board_info['moderator_groups'])) |
139 | 146 | { |
140 | 147 | // By default just tack the moderator groups onto the end of the members |
141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
150 | + } |
|
143 | 151 | } |
144 | 152 | |
145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
191 | 199 | ); |
192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
193 | 201 | { |
194 | - if (empty($row['id_member'])) |
|
195 | - continue; |
|
202 | + if (empty($row['id_member'])) { |
|
203 | + continue; |
|
204 | + } |
|
196 | 205 | |
197 | - if (!empty($row['online_color'])) |
|
198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
199 | - else |
|
200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
206 | + if (!empty($row['online_color'])) { |
|
207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
208 | + } else { |
|
209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
210 | + } |
|
201 | 211 | |
202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
203 | - if ($is_buddy) |
|
204 | - $link = '<strong>' . $link . '</strong>'; |
|
213 | + if ($is_buddy) { |
|
214 | + $link = '<strong>' . $link . '</strong>'; |
|
215 | + } |
|
205 | 216 | |
206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
219 | + } |
|
208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
217 | 229 | 'hidden' => empty($row['show_online']), |
218 | 230 | ); |
219 | 231 | |
220 | - if (empty($row['show_online'])) |
|
221 | - $context['view_num_hidden']++; |
|
232 | + if (empty($row['show_online'])) { |
|
233 | + $context['view_num_hidden']++; |
|
234 | + } |
|
222 | 235 | } |
223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
224 | 237 | $smcFunc['db_free_result']($request); |
@@ -273,8 +286,9 @@ discard block |
||
273 | 286 | // Bring in any changes we want to make before the query. |
274 | 287 | call_integration_hook('integrate_pre_messageindex', array(&$sort_methods)); |
275 | 288 | |
276 | - foreach ($sort_methods as $key => $val) |
|
277 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
289 | + foreach ($sort_methods as $key => $val) { |
|
290 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
291 | + } |
|
278 | 292 | |
279 | 293 | // Calculate the fastest way to get the topics. |
280 | 294 | $start = (int) $_REQUEST['start']; |
@@ -284,14 +298,15 @@ discard block |
||
284 | 298 | $fake_ascending = true; |
285 | 299 | $context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex']; |
286 | 300 | $start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex']; |
301 | + } else { |
|
302 | + $fake_ascending = false; |
|
287 | 303 | } |
288 | - else |
|
289 | - $fake_ascending = false; |
|
290 | 304 | |
291 | 305 | // Setup the default topic icons... |
292 | 306 | $context['icon_sources'] = array(); |
293 | - foreach ($context['stable_icons'] as $icon) |
|
294 | - $context['icon_sources'][$icon] = 'images_url'; |
|
307 | + foreach ($context['stable_icons'] as $icon) { |
|
308 | + $context['icon_sources'][$icon] = 'images_url'; |
|
309 | + } |
|
295 | 310 | |
296 | 311 | $topic_ids = array(); |
297 | 312 | $context['topics'] = array(); |
@@ -314,10 +329,11 @@ discard block |
||
314 | 329 | $message_index_wheres = array(); |
315 | 330 | call_integration_hook('integrate_message_index', array(&$message_index_selects, &$message_index_tables, &$message_index_parameters, &$message_index_wheres, &$topic_ids)); |
316 | 331 | |
317 | - if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
|
318 | - $enableParticipation = true; |
|
319 | - else |
|
320 | - $enableParticipation = false; |
|
332 | + if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) { |
|
333 | + $enableParticipation = true; |
|
334 | + } else { |
|
335 | + $enableParticipation = false; |
|
336 | + } |
|
321 | 337 | |
322 | 338 | $sort_table = 'SELECT t.id_topic, t.id_first_msg, t.id_last_msg |
323 | 339 | FROM {db_prefix}topics t |
@@ -364,8 +380,9 @@ discard block |
||
364 | 380 | // Begin 'printing' the message index for current board. |
365 | 381 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
366 | 382 | { |
367 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
368 | - continue; |
|
383 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
384 | + continue; |
|
385 | + } |
|
369 | 386 | |
370 | 387 | $topic_ids[] = $row['id_topic']; |
371 | 388 | |
@@ -377,8 +394,9 @@ discard block |
||
377 | 394 | { |
378 | 395 | // Limit them to $modSettings['preview_characters'] characters |
379 | 396 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
380 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
381 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
397 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
398 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
399 | + } |
|
382 | 400 | |
383 | 401 | // Censor the subject and message preview. |
384 | 402 | censorText($row['first_subject']); |
@@ -389,27 +407,27 @@ discard block |
||
389 | 407 | { |
390 | 408 | $row['last_subject'] = $row['first_subject']; |
391 | 409 | $row['last_body'] = $row['first_body']; |
392 | - } |
|
393 | - else |
|
410 | + } else |
|
394 | 411 | { |
395 | 412 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
396 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
397 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
413 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
414 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
415 | + } |
|
398 | 416 | |
399 | 417 | censorText($row['last_subject']); |
400 | 418 | censorText($row['last_body']); |
401 | 419 | } |
402 | - } |
|
403 | - else |
|
420 | + } else |
|
404 | 421 | { |
405 | 422 | $row['first_body'] = ''; |
406 | 423 | $row['last_body'] = ''; |
407 | 424 | censorText($row['first_subject']); |
408 | 425 | |
409 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
410 | - $row['last_subject'] = $row['first_subject']; |
|
411 | - else |
|
412 | - censorText($row['last_subject']); |
|
426 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
427 | + $row['last_subject'] = $row['first_subject']; |
|
428 | + } else { |
|
429 | + censorText($row['last_subject']); |
|
430 | + } |
|
413 | 431 | } |
414 | 432 | |
415 | 433 | // Decide how many pages the topic should have. |
@@ -420,42 +438,50 @@ discard block |
||
420 | 438 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
421 | 439 | |
422 | 440 | // If we can use all, show all. |
423 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
424 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
441 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
442 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
443 | + } |
|
444 | + } else { |
|
445 | + $pages = ''; |
|
425 | 446 | } |
426 | - else |
|
427 | - $pages = ''; |
|
428 | 447 | |
429 | 448 | // We need to check the topic icons exist... |
430 | 449 | if (!empty($modSettings['messageIconChecks_enable'])) |
431 | 450 | { |
432 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
433 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
434 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
435 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
436 | - } |
|
437 | - else |
|
451 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
452 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
453 | + } |
|
454 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
455 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
456 | + } |
|
457 | + } else |
|
438 | 458 | { |
439 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
440 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
441 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
442 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
459 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
460 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
461 | + } |
|
462 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
463 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
464 | + } |
|
443 | 465 | } |
444 | 466 | |
445 | - if (!empty($board_info['recycle'])) |
|
446 | - $row['first_icon'] = 'recycled'; |
|
467 | + if (!empty($board_info['recycle'])) { |
|
468 | + $row['first_icon'] = 'recycled'; |
|
469 | + } |
|
447 | 470 | |
448 | 471 | // Is this topic pending approval, or does it have any posts pending approval? |
449 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
450 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
472 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
473 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
474 | + } |
|
451 | 475 | |
452 | 476 | // Sticky topics should get a different color, too. |
453 | - if ($row['is_sticky']) |
|
454 | - $colorClass .= ' sticky'; |
|
477 | + if ($row['is_sticky']) { |
|
478 | + $colorClass .= ' sticky'; |
|
479 | + } |
|
455 | 480 | |
456 | 481 | // Locked topics get special treatment as well. |
457 | - if ($row['locked']) |
|
458 | - $colorClass .= ' locked'; |
|
482 | + if ($row['locked']) { |
|
483 | + $colorClass .= ' locked'; |
|
484 | + } |
|
459 | 485 | |
460 | 486 | // 'Print' the topic info. |
461 | 487 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -536,8 +562,9 @@ discard block |
||
536 | 562 | $smcFunc['db_free_result']($result); |
537 | 563 | |
538 | 564 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
539 | - if ($fake_ascending) |
|
540 | - $context['topics'] = array_reverse($context['topics'], true); |
|
565 | + if ($fake_ascending) { |
|
566 | + $context['topics'] = array_reverse($context['topics'], true); |
|
567 | + } |
|
541 | 568 | |
542 | 569 | |
543 | 570 | $context['jump_to'] = array( |
@@ -560,9 +587,9 @@ discard block |
||
560 | 587 | // Can we restore topics? |
561 | 588 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
562 | 589 | |
563 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
564 | - $context['can_move_any'] = true; |
|
565 | - else |
|
590 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
591 | + $context['can_move_any'] = true; |
|
592 | + } else |
|
566 | 593 | { |
567 | 594 | // We'll use this in a minute |
568 | 595 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -589,11 +616,13 @@ discard block |
||
589 | 616 | } |
590 | 617 | |
591 | 618 | // Can we use quick moderation checkboxes? |
592 | - if ($options['display_quick_mod'] == 1) |
|
593 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
619 | + if ($options['display_quick_mod'] == 1) { |
|
620 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
621 | + } |
|
594 | 622 | // Or the icons? |
595 | - else |
|
596 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
623 | + else { |
|
624 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
625 | + } |
|
597 | 626 | } |
598 | 627 | |
599 | 628 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -627,13 +656,15 @@ discard block |
||
627 | 656 | ); |
628 | 657 | |
629 | 658 | // We've seen all these boards now! |
630 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
631 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
659 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
660 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
632 | 661 | unset($_SESSION['topicseen_cache'][$k]); |
662 | + } |
|
633 | 663 | } |
634 | 664 | |
635 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
636 | - unset($_SESSION['topicseen_cache'][$board]); |
|
665 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
666 | + unset($_SESSION['topicseen_cache'][$board]); |
|
667 | + } |
|
637 | 668 | |
638 | 669 | $request = $smcFunc['db_query']('', ' |
639 | 670 | SELECT id_topic, id_board, sent |
@@ -654,8 +685,9 @@ discard block |
||
654 | 685 | $context['is_marked_notify'] = true; |
655 | 686 | $board_sent = $row['sent']; |
656 | 687 | } |
657 | - if (!empty($row['id_topic'])) |
|
658 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
688 | + if (!empty($row['id_topic'])) { |
|
689 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
690 | + } |
|
659 | 691 | } |
660 | 692 | $smcFunc['db_free_result']($request); |
661 | 693 | |
@@ -679,8 +711,7 @@ discard block |
||
679 | 711 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
680 | 712 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
681 | 713 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
682 | - } |
|
683 | - else |
|
714 | + } else |
|
684 | 715 | { |
685 | 716 | $context['is_marked_notify'] = false; |
686 | 717 | $context['board_notification_mode'] = 1; |
@@ -693,23 +724,27 @@ discard block |
||
693 | 724 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
694 | 725 | |
695 | 726 | // Don't want to show this forever... |
696 | - if ($context['becomesUnapproved']) |
|
697 | - unset($_SESSION['becomesUnapproved']); |
|
727 | + if ($context['becomesUnapproved']) { |
|
728 | + unset($_SESSION['becomesUnapproved']); |
|
729 | + } |
|
698 | 730 | |
699 | 731 | // Build the message index button array. |
700 | 732 | $context['normal_buttons'] = array(); |
701 | 733 | |
702 | - if ($context['can_post_new']) |
|
703 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
734 | + if ($context['can_post_new']) { |
|
735 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
736 | + } |
|
704 | 737 | |
705 | - if ($context['can_post_poll']) |
|
706 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
738 | + if ($context['can_post_poll']) { |
|
739 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
740 | + } |
|
707 | 741 | |
708 | - if ($context['user']['is_logged']) |
|
709 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
742 | + if ($context['user']['is_logged']) { |
|
743 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
744 | + } |
|
710 | 745 | |
711 | - if ($context['can_mark_notify']) |
|
712 | - $context['normal_buttons']['notify'] = array( |
|
746 | + if ($context['can_mark_notify']) { |
|
747 | + $context['normal_buttons']['notify'] = array( |
|
713 | 748 | 'lang' => true, |
714 | 749 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
715 | 750 | 'sub_buttons' => array( |
@@ -727,6 +762,7 @@ discard block |
||
727 | 762 | ), |
728 | 763 | ), |
729 | 764 | ); |
765 | + } |
|
730 | 766 | |
731 | 767 | // Javascript for inline editing. |
732 | 768 | loadJavaScriptFile('topic.js', array('defer' => false, 'minimize' => true), 'smf_topic'); |
@@ -748,18 +784,21 @@ discard block |
||
748 | 784 | checkSession('request'); |
749 | 785 | |
750 | 786 | // Lets go straight to the restore area. |
751 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
752 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
787 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
788 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
789 | + } |
|
753 | 790 | |
754 | - if (isset($_SESSION['topicseen_cache'])) |
|
755 | - $_SESSION['topicseen_cache'] = array(); |
|
791 | + if (isset($_SESSION['topicseen_cache'])) { |
|
792 | + $_SESSION['topicseen_cache'] = array(); |
|
793 | + } |
|
756 | 794 | |
757 | 795 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
758 | 796 | require_once($sourcedir . '/Subs-Post.php'); |
759 | 797 | |
760 | 798 | // Remember the last board they moved things to. |
761 | - if (isset($_REQUEST['move_to'])) |
|
762 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
799 | + if (isset($_REQUEST['move_to'])) { |
|
800 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
801 | + } |
|
763 | 802 | |
764 | 803 | // Only a few possible actions. |
765 | 804 | $possibleActions = array(); |
@@ -779,8 +818,7 @@ discard block |
||
779 | 818 | ); |
780 | 819 | |
781 | 820 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
782 | - } |
|
783 | - else |
|
821 | + } else |
|
784 | 822 | { |
785 | 823 | /** |
786 | 824 | * @todo Ugly. There's no getting around this, is there? |
@@ -798,8 +836,7 @@ discard block |
||
798 | 836 | if (!empty($board)) |
799 | 837 | { |
800 | 838 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
801 | - } |
|
802 | - else |
|
839 | + } else |
|
803 | 840 | { |
804 | 841 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
805 | 842 | } |
@@ -810,55 +847,67 @@ discard block |
||
810 | 847 | } |
811 | 848 | } |
812 | 849 | |
813 | - if (!$user_info['is_guest']) |
|
814 | - $possibleActions[] = 'markread'; |
|
815 | - if (!empty($boards_can['make_sticky'])) |
|
816 | - $possibleActions[] = 'sticky'; |
|
817 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
818 | - $possibleActions[] = 'move'; |
|
819 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
820 | - $possibleActions[] = 'remove'; |
|
821 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
822 | - $possibleActions[] = 'lock'; |
|
823 | - if (!empty($boards_can['merge_any'])) |
|
824 | - $possibleActions[] = 'merge'; |
|
825 | - if (!empty($boards_can['approve_posts'])) |
|
826 | - $possibleActions[] = 'approve'; |
|
850 | + if (!$user_info['is_guest']) { |
|
851 | + $possibleActions[] = 'markread'; |
|
852 | + } |
|
853 | + if (!empty($boards_can['make_sticky'])) { |
|
854 | + $possibleActions[] = 'sticky'; |
|
855 | + } |
|
856 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
857 | + $possibleActions[] = 'move'; |
|
858 | + } |
|
859 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
860 | + $possibleActions[] = 'remove'; |
|
861 | + } |
|
862 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
863 | + $possibleActions[] = 'lock'; |
|
864 | + } |
|
865 | + if (!empty($boards_can['merge_any'])) { |
|
866 | + $possibleActions[] = 'merge'; |
|
867 | + } |
|
868 | + if (!empty($boards_can['approve_posts'])) { |
|
869 | + $possibleActions[] = 'approve'; |
|
870 | + } |
|
827 | 871 | |
828 | 872 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
829 | 873 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
830 | 874 | if (!empty($_REQUEST['topics'])) |
831 | 875 | { |
832 | 876 | // If the action isn't valid, just quit now. |
833 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
834 | - redirectexit($redirect_url); |
|
877 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
878 | + redirectexit($redirect_url); |
|
879 | + } |
|
835 | 880 | |
836 | 881 | // Merge requires all topics as one parameter and can be done at once. |
837 | 882 | if ($_REQUEST['qaction'] == 'merge') |
838 | 883 | { |
839 | 884 | // Merge requires at least two topics. |
840 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
841 | - redirectexit($redirect_url); |
|
885 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
886 | + redirectexit($redirect_url); |
|
887 | + } |
|
842 | 888 | |
843 | 889 | require_once($sourcedir . '/SplitTopics.php'); |
844 | 890 | return MergeExecute($_REQUEST['topics']); |
845 | 891 | } |
846 | 892 | |
847 | 893 | // Just convert to the other method, to make it easier. |
848 | - foreach ($_REQUEST['topics'] as $topic) |
|
849 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
894 | + foreach ($_REQUEST['topics'] as $topic) { |
|
895 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
896 | + } |
|
850 | 897 | } |
851 | 898 | |
852 | 899 | // Weird... how'd you get here? |
853 | - if (empty($_REQUEST['actions'])) |
|
854 | - redirectexit($redirect_url); |
|
900 | + if (empty($_REQUEST['actions'])) { |
|
901 | + redirectexit($redirect_url); |
|
902 | + } |
|
855 | 903 | |
856 | 904 | // Validate each action. |
857 | 905 | $temp = array(); |
858 | 906 | foreach ($_REQUEST['actions'] as $topic => $action) |
859 | 907 | { |
860 | - if (in_array($action, $possibleActions)) |
|
861 | - $temp[(int) $topic] = $action; |
|
908 | + if (in_array($action, $possibleActions)) { |
|
909 | + $temp[(int) $topic] = $action; |
|
910 | + } |
|
862 | 911 | } |
863 | 912 | $_REQUEST['actions'] = $temp; |
864 | 913 | |
@@ -879,27 +928,31 @@ discard block |
||
879 | 928 | { |
880 | 929 | if (!empty($board)) |
881 | 930 | { |
882 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
883 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
884 | - } |
|
885 | - else |
|
931 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
932 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
933 | + } |
|
934 | + } else |
|
886 | 935 | { |
887 | 936 | // Don't allow them to act on unapproved posts they can't see... |
888 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
889 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
937 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
938 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
939 | + } |
|
890 | 940 | // Goodness, this is fun. We need to validate the action. |
891 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
892 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
893 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
894 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
895 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
896 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
941 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
942 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
943 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
944 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
945 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
946 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
947 | + } |
|
897 | 948 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
898 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
899 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
949 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
950 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
951 | + } |
|
900 | 952 | // If the topic is approved then you need permission to approve the posts within. |
901 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
902 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
953 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
954 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
955 | + } |
|
903 | 956 | } |
904 | 957 | } |
905 | 958 | $smcFunc['db_free_result']($request); |
@@ -917,11 +970,11 @@ discard block |
||
917 | 970 | { |
918 | 971 | $topic = (int) $topic; |
919 | 972 | |
920 | - if ($action == 'markread') |
|
921 | - $markCache[] = $topic; |
|
922 | - elseif ($action == 'sticky') |
|
923 | - $stickyCache[] = $topic; |
|
924 | - elseif ($action == 'move') |
|
973 | + if ($action == 'markread') { |
|
974 | + $markCache[] = $topic; |
|
975 | + } elseif ($action == 'sticky') { |
|
976 | + $stickyCache[] = $topic; |
|
977 | + } elseif ($action == 'move') |
|
925 | 978 | { |
926 | 979 | require_once($sourcedir . '/MoveTopic.php'); |
927 | 980 | moveTopicConcurrence(); |
@@ -929,23 +982,25 @@ discard block |
||
929 | 982 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
930 | 983 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
931 | 984 | |
932 | - if (empty($moveCache[1][$topic])) |
|
933 | - continue; |
|
985 | + if (empty($moveCache[1][$topic])) { |
|
986 | + continue; |
|
987 | + } |
|
934 | 988 | |
935 | 989 | $moveCache[0][] = $topic; |
990 | + } elseif ($action == 'remove') { |
|
991 | + $removeCache[] = $topic; |
|
992 | + } elseif ($action == 'lock') { |
|
993 | + $lockCache[] = $topic; |
|
994 | + } elseif ($action == 'approve') { |
|
995 | + $approveCache[] = $topic; |
|
936 | 996 | } |
937 | - elseif ($action == 'remove') |
|
938 | - $removeCache[] = $topic; |
|
939 | - elseif ($action == 'lock') |
|
940 | - $lockCache[] = $topic; |
|
941 | - elseif ($action == 'approve') |
|
942 | - $approveCache[] = $topic; |
|
943 | 997 | } |
944 | 998 | |
945 | - if (empty($board)) |
|
946 | - $affectedBoards = array(); |
|
947 | - else |
|
948 | - $affectedBoards = array($board => array(0, 0)); |
|
999 | + if (empty($board)) { |
|
1000 | + $affectedBoards = array(); |
|
1001 | + } else { |
|
1002 | + $affectedBoards = array($board => array(0, 0)); |
|
1003 | + } |
|
949 | 1004 | |
950 | 1005 | // Do all the stickies... |
951 | 1006 | if (!empty($stickyCache)) |
@@ -1005,14 +1060,16 @@ discard block |
||
1005 | 1060 | { |
1006 | 1061 | $to = $moveCache[1][$row['id_topic']]; |
1007 | 1062 | |
1008 | - if (empty($to)) |
|
1009 | - continue; |
|
1063 | + if (empty($to)) { |
|
1064 | + continue; |
|
1065 | + } |
|
1010 | 1066 | |
1011 | 1067 | // Does this topic's board count the posts or not? |
1012 | 1068 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
1013 | 1069 | |
1014 | - if (!isset($moveTos[$to])) |
|
1015 | - $moveTos[$to] = array(); |
|
1070 | + if (!isset($moveTos[$to])) { |
|
1071 | + $moveTos[$to] = array(); |
|
1072 | + } |
|
1016 | 1073 | |
1017 | 1074 | $moveTos[$to][] = $row['id_topic']; |
1018 | 1075 | |
@@ -1026,8 +1083,9 @@ discard block |
||
1026 | 1083 | require_once($sourcedir . '/MoveTopic.php'); |
1027 | 1084 | |
1028 | 1085 | // Do the actual moves... |
1029 | - foreach ($moveTos as $to => $topics) |
|
1030 | - moveTopics($topics, $to); |
|
1086 | + foreach ($moveTos as $to => $topics) { |
|
1087 | + moveTopics($topics, $to); |
|
1088 | + } |
|
1031 | 1089 | |
1032 | 1090 | // Does the post counts need to be updated? |
1033 | 1091 | if (!empty($moveTos)) |
@@ -1076,20 +1134,23 @@ discard block |
||
1076 | 1134 | |
1077 | 1135 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1078 | 1136 | { |
1079 | - if (!isset($members[$row['id_member']])) |
|
1080 | - $members[$row['id_member']] = 0; |
|
1137 | + if (!isset($members[$row['id_member']])) { |
|
1138 | + $members[$row['id_member']] = 0; |
|
1139 | + } |
|
1081 | 1140 | |
1082 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
1083 | - $members[$row['id_member']] += 1; |
|
1084 | - else |
|
1085 | - $members[$row['id_member']] -= 1; |
|
1141 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
1142 | + $members[$row['id_member']] += 1; |
|
1143 | + } else { |
|
1144 | + $members[$row['id_member']] -= 1; |
|
1145 | + } |
|
1086 | 1146 | } |
1087 | 1147 | |
1088 | 1148 | $smcFunc['db_free_result']($request); |
1089 | 1149 | |
1090 | 1150 | // And now update them member's post counts |
1091 | - foreach ($members as $id_member => $post_adj) |
|
1092 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1151 | + foreach ($members as $id_member => $post_adj) { |
|
1152 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1153 | + } |
|
1093 | 1154 | } |
1094 | 1155 | } |
1095 | 1156 | } |
@@ -1168,8 +1229,9 @@ discard block |
||
1168 | 1229 | approveTopics($approveCache); |
1169 | 1230 | |
1170 | 1231 | // Time for some logging! |
1171 | - foreach ($approveCache as $topic) |
|
1172 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1232 | + foreach ($approveCache as $topic) { |
|
1233 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1234 | + } |
|
1173 | 1235 | } |
1174 | 1236 | } |
1175 | 1237 | |
@@ -1204,8 +1266,7 @@ discard block |
||
1204 | 1266 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
1205 | 1267 | } |
1206 | 1268 | $smcFunc['db_free_result']($result); |
1207 | - } |
|
1208 | - else |
|
1269 | + } else |
|
1209 | 1270 | { |
1210 | 1271 | $result = $smcFunc['db_query']('', ' |
1211 | 1272 | SELECT id_topic, locked, id_board |
@@ -1255,13 +1316,15 @@ discard block |
||
1255 | 1316 | ) |
1256 | 1317 | ); |
1257 | 1318 | $logged_topics = array(); |
1258 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1259 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1319 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1320 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1321 | + } |
|
1260 | 1322 | $smcFunc['db_free_result']($request); |
1261 | 1323 | |
1262 | 1324 | $markArray = array(); |
1263 | - foreach ($markCache as $topic) |
|
1264 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1325 | + foreach ($markCache as $topic) { |
|
1326 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1327 | + } |
|
1265 | 1328 | |
1266 | 1329 | $smcFunc['db_insert']('replace', |
1267 | 1330 | '{db_prefix}log_topics', |
@@ -1274,8 +1337,9 @@ discard block |
||
1274 | 1337 | foreach ($moveCache as $topic) |
1275 | 1338 | { |
1276 | 1339 | // Didn't actually move anything! |
1277 | - if (!isset($topic[0])) |
|
1278 | - break; |
|
1340 | + if (!isset($topic[0])) { |
|
1341 | + break; |
|
1342 | + } |
|
1279 | 1343 | |
1280 | 1344 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
1281 | 1345 | sendNotifications($topic[0], 'move'); |
@@ -1297,8 +1361,9 @@ discard block |
||
1297 | 1361 | 'calendar_updated' => time(), |
1298 | 1362 | )); |
1299 | 1363 | |
1300 | - if (!empty($affectedBoards)) |
|
1301 | - updateLastMessages(array_keys($affectedBoards)); |
|
1364 | + if (!empty($affectedBoards)) { |
|
1365 | + updateLastMessages(array_keys($affectedBoards)); |
|
1366 | + } |
|
1302 | 1367 | |
1303 | 1368 | redirectexit($redirect_url); |
1304 | 1369 | } |
@@ -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 | * Ban center. The main entrance point for all ban center functions. |
@@ -120,10 +121,11 @@ discard block |
||
120 | 121 | } |
121 | 122 | |
122 | 123 | // Create a date string so we don't overload them with date info. |
123 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
124 | - $context['ban_time_format'] = $user_info['time_format']; |
|
125 | - else |
|
126 | - $context['ban_time_format'] = $matches[0]; |
|
124 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
125 | + $context['ban_time_format'] = $user_info['time_format']; |
|
126 | + } else { |
|
127 | + $context['ban_time_format'] = $matches[0]; |
|
128 | + } |
|
127 | 129 | |
128 | 130 | $listOptions = array( |
129 | 131 | 'id' => 'ban_list', |
@@ -201,16 +203,19 @@ discard block |
||
201 | 203 | 'function' => function($rowData) use ($txt) |
202 | 204 | { |
203 | 205 | // This ban never expires...whahaha. |
204 | - if ($rowData['expire_time'] === null) |
|
205 | - return $txt['never']; |
|
206 | + if ($rowData['expire_time'] === null) { |
|
207 | + return $txt['never']; |
|
208 | + } |
|
206 | 209 | |
207 | 210 | // This ban has already expired. |
208 | - elseif ($rowData['expire_time'] < time()) |
|
209 | - return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
211 | + elseif ($rowData['expire_time'] < time()) { |
|
212 | + return sprintf('<span class="red">%1$s</span>', $txt['ban_expired']); |
|
213 | + } |
|
210 | 214 | |
211 | 215 | // Still need to wait a few days for this ban to expire. |
212 | - else |
|
213 | - return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
216 | + else { |
|
217 | + return sprintf('%1$d %2$s', ceil(($rowData['expire_time'] - time()) / (60 * 60 * 24)), $txt['ban_days']); |
|
218 | + } |
|
214 | 219 | }, |
215 | 220 | ), |
216 | 221 | 'sort' => array( |
@@ -320,8 +325,9 @@ discard block |
||
320 | 325 | ) |
321 | 326 | ); |
322 | 327 | $bans = array(); |
323 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
324 | - $bans[] = $row; |
|
328 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
329 | + $bans[] = $row; |
|
330 | + } |
|
325 | 331 | |
326 | 332 | $smcFunc['db_free_result']($request); |
327 | 333 | |
@@ -363,8 +369,9 @@ discard block |
||
363 | 369 | { |
364 | 370 | global $txt, $modSettings, $context, $scripturl, $smcFunc, $sourcedir; |
365 | 371 | |
366 | - if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) |
|
367 | - BanEdit2(); |
|
372 | + if ((isset($_POST['add_ban']) || isset($_POST['modify_ban']) || isset($_POST['remove_selection'])) && empty($context['ban_errors'])) { |
|
373 | + BanEdit2(); |
|
374 | + } |
|
368 | 375 | |
369 | 376 | $ban_group_id = isset($context['ban']['id']) ? $context['ban']['id'] : (isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0); |
370 | 377 | |
@@ -373,11 +380,10 @@ discard block |
||
373 | 380 | createToken('admin-bet'); |
374 | 381 | $context['form_url'] = $scripturl . '?action=admin;area=ban;sa=edit'; |
375 | 382 | |
376 | - if (!empty($context['ban_errors'])) |
|
377 | - foreach ($context['ban_errors'] as $error) |
|
383 | + if (!empty($context['ban_errors'])) { |
|
384 | + foreach ($context['ban_errors'] as $error) |
|
378 | 385 | $context['error_messages'][$error] = $txt[$error]; |
379 | - |
|
380 | - else |
|
386 | + } else |
|
381 | 387 | { |
382 | 388 | // If we're editing an existing ban, get it from the database. |
383 | 389 | if (!empty($ban_group_id)) |
@@ -413,12 +419,13 @@ discard block |
||
413 | 419 | 'data' => array( |
414 | 420 | 'function' => function($ban_item) use ($txt) |
415 | 421 | { |
416 | - if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) |
|
417 | - return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
418 | - elseif ($ban_item['type'] == 'user') |
|
419 | - return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
420 | - else |
|
421 | - return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
422 | + if (in_array($ban_item['type'], array('ip', 'hostname', 'email'))) { |
|
423 | + return '<strong>' . $txt[$ban_item['type']] . ':</strong> ' . $ban_item[$ban_item['type']]; |
|
424 | + } elseif ($ban_item['type'] == 'user') { |
|
425 | + return '<strong>' . $txt['username'] . ':</strong> ' . $ban_item['user']['link']; |
|
426 | + } else { |
|
427 | + return '<strong>' . $txt['unknown'] . ':</strong> ' . $ban_item['no_bantype_selected']; |
|
428 | + } |
|
422 | 429 | }, |
423 | 430 | 'style' => 'text-align: left;', |
424 | 431 | ), |
@@ -556,8 +563,9 @@ discard block |
||
556 | 563 | $context['ban']['from_user'] = true; |
557 | 564 | |
558 | 565 | // Would be nice if we could also ban the hostname. |
559 | - if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) |
|
560 | - $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
566 | + if ((preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $context['ban_suggestions']['main_ip']) == 1 || isValidIPv6($context['ban_suggestions']['main_ip'])) && empty($modSettings['disableHostnameLookup'])) { |
|
567 | + $context['ban_suggestions']['hostname'] = host_from_ip($context['ban_suggestions']['main_ip']); |
|
568 | + } |
|
561 | 569 | |
562 | 570 | $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
563 | 571 | } |
@@ -625,8 +633,9 @@ discard block |
||
625 | 633 | 'items_per_page' => $items_per_page, |
626 | 634 | ) |
627 | 635 | ); |
628 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
629 | - fatal_lang_error('ban_not_found', false); |
|
636 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
637 | + fatal_lang_error('ban_not_found', false); |
|
638 | + } |
|
630 | 639 | |
631 | 640 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
632 | 641 | { |
@@ -663,18 +672,15 @@ discard block |
||
663 | 672 | { |
664 | 673 | $ban_items[$row['id_ban']]['type'] = 'ip'; |
665 | 674 | $ban_items[$row['id_ban']]['ip'] = range2ip($row['ip_low'], $row['ip_high']); |
666 | - } |
|
667 | - elseif (!empty($row['hostname'])) |
|
675 | + } elseif (!empty($row['hostname'])) |
|
668 | 676 | { |
669 | 677 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
670 | 678 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
671 | - } |
|
672 | - elseif (!empty($row['email_address'])) |
|
679 | + } elseif (!empty($row['email_address'])) |
|
673 | 680 | { |
674 | 681 | $ban_items[$row['id_ban']]['type'] = 'email'; |
675 | 682 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
676 | - } |
|
677 | - elseif (!empty($row['id_member'])) |
|
683 | + } elseif (!empty($row['id_member'])) |
|
678 | 684 | { |
679 | 685 | $ban_items[$row['id_ban']]['type'] = 'user'; |
680 | 686 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -740,9 +746,10 @@ discard block |
||
740 | 746 | $search_list += array('ips_in_messages' => 'banLoadAdditionalIPsMember', 'ips_in_errors' => 'banLoadAdditionalIPsError'); |
741 | 747 | |
742 | 748 | $return = array(); |
743 | - foreach ($search_list as $key => $callable) |
|
744 | - if (is_callable($callable)) |
|
749 | + foreach ($search_list as $key => $callable) { |
|
750 | + if (is_callable($callable)) |
|
745 | 751 | $return[$key] = call_user_func($callable, $member_id); |
752 | + } |
|
746 | 753 | |
747 | 754 | return $return; |
748 | 755 | } |
@@ -767,8 +774,9 @@ discard block |
||
767 | 774 | 'current_user' => $member_id, |
768 | 775 | ) |
769 | 776 | ); |
770 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
771 | - $message_ips[] = inet_dtop($row['poster_ip']); |
|
777 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
778 | + $message_ips[] = inet_dtop($row['poster_ip']); |
|
779 | + } |
|
772 | 780 | $smcFunc['db_free_result']($request); |
773 | 781 | |
774 | 782 | return $message_ips; |
@@ -793,8 +801,9 @@ discard block |
||
793 | 801 | 'current_user' => $member_id, |
794 | 802 | ) |
795 | 803 | ); |
796 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
797 | - $error_ips[] = inet_dtop($row['ip']); |
|
804 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
805 | + $error_ips[] = inet_dtop($row['ip']); |
|
806 | + } |
|
798 | 807 | $smcFunc['db_free_result']($request); |
799 | 808 | |
800 | 809 | return $error_ips; |
@@ -835,11 +844,13 @@ discard block |
||
835 | 844 | $ban_info['cannot']['login'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_login']) ? 0 : 1; |
836 | 845 | |
837 | 846 | // Adding a new ban group |
838 | - if (empty($_REQUEST['bg'])) |
|
839 | - $ban_group_id = insertBanGroup($ban_info); |
|
847 | + if (empty($_REQUEST['bg'])) { |
|
848 | + $ban_group_id = insertBanGroup($ban_info); |
|
849 | + } |
|
840 | 850 | // Editing an existing ban group |
841 | - else |
|
842 | - $ban_group_id = updateBanGroup($ban_info); |
|
851 | + else { |
|
852 | + $ban_group_id = updateBanGroup($ban_info); |
|
853 | + } |
|
843 | 854 | |
844 | 855 | if (is_numeric($ban_group_id)) |
845 | 856 | { |
@@ -850,9 +861,10 @@ discard block |
||
850 | 861 | $context['ban'] = $ban_info; |
851 | 862 | } |
852 | 863 | |
853 | - if (isset($_POST['ban_suggestions'])) |
|
854 | - // @TODO: is $_REQUEST['bi'] ever set? |
|
864 | + if (isset($_POST['ban_suggestions'])) { |
|
865 | + // @TODO: is $_REQUEST['bi'] ever set? |
|
855 | 866 | $saved_triggers = saveTriggers($_POST['ban_suggestions'], $ban_info['id'], isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : 0, isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0); |
867 | + } |
|
856 | 868 | |
857 | 869 | // Something went wrong somewhere... Oh well, let's go back. |
858 | 870 | if (!empty($context['ban_errors'])) |
@@ -862,8 +874,9 @@ discard block |
||
862 | 874 | $context['ban_suggestions'] = array_merge($context['ban_suggestions'], getMemberData((int) $_REQUEST['u'])); |
863 | 875 | |
864 | 876 | // Not strictly necessary, but it's nice |
865 | - if (!empty($context['ban_suggestions']['member']['id'])) |
|
866 | - $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
877 | + if (!empty($context['ban_suggestions']['member']['id'])) { |
|
878 | + $context['ban_suggestions']['other_ips'] = banLoadAdditionalIPs($context['ban_suggestions']['member']['id']); |
|
879 | + } |
|
867 | 880 | return BanEdit(); |
868 | 881 | } |
869 | 882 | $context['ban_suggestions']['saved_triggers'] = !empty($saved_triggers) ? $saved_triggers : array(); |
@@ -910,10 +923,11 @@ discard block |
||
910 | 923 | |
911 | 924 | foreach ($suggestions as $key => $value) |
912 | 925 | { |
913 | - if (is_array($value)) |
|
914 | - $triggers[$key] = $value; |
|
915 | - else |
|
916 | - $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
926 | + if (is_array($value)) { |
|
927 | + $triggers[$key] = $value; |
|
928 | + } else { |
|
929 | + $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; |
|
930 | + } |
|
917 | 931 | } |
918 | 932 | |
919 | 933 | $ban_triggers = validateTriggers($triggers); |
@@ -921,16 +935,18 @@ discard block |
||
921 | 935 | // Time to save! |
922 | 936 | if (!empty($ban_triggers['ban_triggers']) && empty($context['ban_errors'])) |
923 | 937 | { |
924 | - if (empty($ban_id)) |
|
925 | - addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
926 | - else |
|
927 | - updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
938 | + if (empty($ban_id)) { |
|
939 | + addTriggers($ban_group, $ban_triggers['ban_triggers'], $ban_triggers['log_info']); |
|
940 | + } else { |
|
941 | + updateTriggers($ban_id, $ban_group, array_shift($ban_triggers['ban_triggers']), $ban_triggers['log_info']); |
|
942 | + } |
|
943 | + } |
|
944 | + if (!empty($context['ban_errors'])) { |
|
945 | + return $triggers; |
|
946 | + } else { |
|
947 | + return false; |
|
948 | + } |
|
928 | 949 | } |
929 | - if (!empty($context['ban_errors'])) |
|
930 | - return $triggers; |
|
931 | - else |
|
932 | - return false; |
|
933 | -} |
|
934 | 950 | |
935 | 951 | /** |
936 | 952 | * This function removes a bunch of triggers based on ids |
@@ -944,14 +960,17 @@ discard block |
||
944 | 960 | { |
945 | 961 | global $smcFunc, $scripturl; |
946 | 962 | |
947 | - if ($group_id !== false) |
|
948 | - $group_id = (int) $group_id; |
|
963 | + if ($group_id !== false) { |
|
964 | + $group_id = (int) $group_id; |
|
965 | + } |
|
949 | 966 | |
950 | - if (empty($group_id) && empty($items_ids)) |
|
951 | - return false; |
|
967 | + if (empty($group_id) && empty($items_ids)) { |
|
968 | + return false; |
|
969 | + } |
|
952 | 970 | |
953 | - if (!is_array($items_ids)) |
|
954 | - $items_ids = array($items_ids); |
|
971 | + if (!is_array($items_ids)) { |
|
972 | + $items_ids = array($items_ids); |
|
973 | + } |
|
955 | 974 | |
956 | 975 | $log_info = array(); |
957 | 976 | $ban_items = array(); |
@@ -989,8 +1008,7 @@ discard block |
||
989 | 1008 | 'bantype' => ($is_range ? 'ip_range' : 'main_ip'), |
990 | 1009 | 'value' => $ban_items[$row['id_ban']]['ip'], |
991 | 1010 | ); |
992 | - } |
|
993 | - elseif (!empty($row['hostname'])) |
|
1011 | + } elseif (!empty($row['hostname'])) |
|
994 | 1012 | { |
995 | 1013 | $ban_items[$row['id_ban']]['type'] = 'hostname'; |
996 | 1014 | $ban_items[$row['id_ban']]['hostname'] = str_replace('%', '*', $row['hostname']); |
@@ -998,8 +1016,7 @@ discard block |
||
998 | 1016 | 'bantype' => 'hostname', |
999 | 1017 | 'value' => $row['hostname'], |
1000 | 1018 | ); |
1001 | - } |
|
1002 | - elseif (!empty($row['email_address'])) |
|
1019 | + } elseif (!empty($row['email_address'])) |
|
1003 | 1020 | { |
1004 | 1021 | $ban_items[$row['id_ban']]['type'] = 'email'; |
1005 | 1022 | $ban_items[$row['id_ban']]['email'] = str_replace('%', '*', $row['email_address']); |
@@ -1007,8 +1024,7 @@ discard block |
||
1007 | 1024 | 'bantype' => 'email', |
1008 | 1025 | 'value' => $ban_items[$row['id_ban']]['email'], |
1009 | 1026 | ); |
1010 | - } |
|
1011 | - elseif (!empty($row['id_member'])) |
|
1027 | + } elseif (!empty($row['id_member'])) |
|
1012 | 1028 | { |
1013 | 1029 | $ban_items[$row['id_ban']]['type'] = 'user'; |
1014 | 1030 | $ban_items[$row['id_ban']]['user'] = array( |
@@ -1041,8 +1057,7 @@ discard block |
||
1041 | 1057 | 'ban_group' => $group_id, |
1042 | 1058 | ) |
1043 | 1059 | ); |
1044 | - } |
|
1045 | - elseif (!empty($items_ids)) |
|
1060 | + } elseif (!empty($items_ids)) |
|
1046 | 1061 | { |
1047 | 1062 | $smcFunc['db_query']('', ' |
1048 | 1063 | DELETE FROM {db_prefix}ban_items |
@@ -1067,13 +1082,15 @@ discard block |
||
1067 | 1082 | { |
1068 | 1083 | global $smcFunc; |
1069 | 1084 | |
1070 | - if (!is_array($group_ids)) |
|
1071 | - $group_ids = array($group_ids); |
|
1085 | + if (!is_array($group_ids)) { |
|
1086 | + $group_ids = array($group_ids); |
|
1087 | + } |
|
1072 | 1088 | |
1073 | 1089 | $group_ids = array_unique($group_ids); |
1074 | 1090 | |
1075 | - if (empty($group_ids)) |
|
1076 | - return false; |
|
1091 | + if (empty($group_ids)) { |
|
1092 | + return false; |
|
1093 | + } |
|
1077 | 1094 | |
1078 | 1095 | $smcFunc['db_query']('', ' |
1079 | 1096 | DELETE FROM {db_prefix}ban_groups |
@@ -1097,21 +1114,23 @@ discard block |
||
1097 | 1114 | { |
1098 | 1115 | global $smcFunc; |
1099 | 1116 | |
1100 | - if (empty($ids)) |
|
1101 | - $smcFunc['db_query']('truncate_table', ' |
|
1117 | + if (empty($ids)) { |
|
1118 | + $smcFunc['db_query']('truncate_table', ' |
|
1102 | 1119 | TRUNCATE {db_prefix}log_banned', |
1103 | 1120 | array( |
1104 | 1121 | ) |
1105 | 1122 | ); |
1106 | - else |
|
1123 | + } else |
|
1107 | 1124 | { |
1108 | - if (!is_array($ids)) |
|
1109 | - $ids = array($ids); |
|
1125 | + if (!is_array($ids)) { |
|
1126 | + $ids = array($ids); |
|
1127 | + } |
|
1110 | 1128 | |
1111 | 1129 | $ids = array_unique($ids); |
1112 | 1130 | |
1113 | - if (empty($ids)) |
|
1114 | - return false; |
|
1131 | + if (empty($ids)) { |
|
1132 | + return false; |
|
1133 | + } |
|
1115 | 1134 | |
1116 | 1135 | $smcFunc['db_query']('', ' |
1117 | 1136 | DELETE FROM {db_prefix}log_banned |
@@ -1137,8 +1156,9 @@ discard block |
||
1137 | 1156 | { |
1138 | 1157 | global $context, $smcFunc; |
1139 | 1158 | |
1140 | - if (empty($triggers)) |
|
1141 | - $context['ban_erros'][] = 'ban_empty_triggers'; |
|
1159 | + if (empty($triggers)) { |
|
1160 | + $context['ban_erros'][] = 'ban_empty_triggers'; |
|
1161 | + } |
|
1142 | 1162 | |
1143 | 1163 | $ban_triggers = array(); |
1144 | 1164 | $log_info = array(); |
@@ -1147,39 +1167,39 @@ discard block |
||
1147 | 1167 | { |
1148 | 1168 | if (!empty($value)) |
1149 | 1169 | { |
1150 | - if ($key == 'member') |
|
1151 | - continue; |
|
1170 | + if ($key == 'member') { |
|
1171 | + continue; |
|
1172 | + } |
|
1152 | 1173 | |
1153 | 1174 | if ($key == 'main_ip') |
1154 | 1175 | { |
1155 | 1176 | $value = trim($value); |
1156 | 1177 | $ip_parts = ip2range($value); |
1157 | - if (!checkExistingTriggerIP($ip_parts, $value)) |
|
1158 | - $context['ban_erros'][] = 'invalid_ip'; |
|
1159 | - else |
|
1178 | + if (!checkExistingTriggerIP($ip_parts, $value)) { |
|
1179 | + $context['ban_erros'][] = 'invalid_ip'; |
|
1180 | + } else |
|
1160 | 1181 | { |
1161 | 1182 | $ban_triggers['main_ip'] = array( |
1162 | 1183 | 'ip_low' => $ip_parts['low'], |
1163 | 1184 | 'ip_high' => $ip_parts['high'] |
1164 | 1185 | ); |
1165 | 1186 | } |
1166 | - } |
|
1167 | - elseif ($key == 'hostname') |
|
1187 | + } elseif ($key == 'hostname') |
|
1168 | 1188 | { |
1169 | - if (preg_match('/[^\w.\-*]/', $value) == 1) |
|
1170 | - $context['ban_erros'][] = 'invalid_hostname'; |
|
1171 | - else |
|
1189 | + if (preg_match('/[^\w.\-*]/', $value) == 1) { |
|
1190 | + $context['ban_erros'][] = 'invalid_hostname'; |
|
1191 | + } else |
|
1172 | 1192 | { |
1173 | 1193 | // Replace the * wildcard by a MySQL wildcard %. |
1174 | 1194 | $value = substr(str_replace('*', '%', $value), 0, 255); |
1175 | 1195 | |
1176 | 1196 | $ban_triggers['hostname']['hostname'] = $value; |
1177 | 1197 | } |
1178 | - } |
|
1179 | - elseif ($key == 'email') |
|
1198 | + } elseif ($key == 'email') |
|
1180 | 1199 | { |
1181 | - if (preg_match('/[^\w.\-\+*@]/', $value) == 1) |
|
1182 | - $context['ban_erros'][] = 'invalid_email'; |
|
1200 | + if (preg_match('/[^\w.\-\+*@]/', $value) == 1) { |
|
1201 | + $context['ban_erros'][] = 'invalid_email'; |
|
1202 | + } |
|
1183 | 1203 | |
1184 | 1204 | // Check the user is not banning an admin. |
1185 | 1205 | $request = $smcFunc['db_query']('', ' |
@@ -1193,15 +1213,15 @@ discard block |
||
1193 | 1213 | 'email' => $value, |
1194 | 1214 | ) |
1195 | 1215 | ); |
1196 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1197 | - $context['ban_erros'][] = 'no_ban_admin'; |
|
1216 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1217 | + $context['ban_erros'][] = 'no_ban_admin'; |
|
1218 | + } |
|
1198 | 1219 | $smcFunc['db_free_result']($request); |
1199 | 1220 | |
1200 | 1221 | $value = substr(strtolower(str_replace('*', '%', $value)), 0, 255); |
1201 | 1222 | |
1202 | 1223 | $ban_triggers['email']['email_address'] = $value; |
1203 | - } |
|
1204 | - elseif ($key == 'user') |
|
1224 | + } elseif ($key == 'user') |
|
1205 | 1225 | { |
1206 | 1226 | $user = preg_replace('~&#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', $smcFunc['htmlspecialchars']($value, ENT_QUOTES)); |
1207 | 1227 | |
@@ -1215,8 +1235,9 @@ discard block |
||
1215 | 1235 | 'username' => $user, |
1216 | 1236 | ) |
1217 | 1237 | ); |
1218 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1219 | - $context['ban_erros'][] = 'invalid_username'; |
|
1238 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1239 | + $context['ban_erros'][] = 'invalid_username'; |
|
1240 | + } |
|
1220 | 1241 | list ($value, $isAdmin) = $smcFunc['db_fetch_row']($request); |
1221 | 1242 | $smcFunc['db_free_result']($request); |
1222 | 1243 | |
@@ -1224,25 +1245,25 @@ discard block |
||
1224 | 1245 | { |
1225 | 1246 | unset($value); |
1226 | 1247 | $context['ban_erros'][] = 'no_ban_admin'; |
1248 | + } else { |
|
1249 | + $ban_triggers['user']['id_member'] = $value; |
|
1227 | 1250 | } |
1228 | - else |
|
1229 | - $ban_triggers['user']['id_member'] = $value; |
|
1230 | - } |
|
1231 | - elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
1251 | + } elseif (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
1232 | 1252 | { |
1233 | 1253 | // Special case, those two are arrays themselves |
1234 | 1254 | $values = array_unique($value); |
1235 | 1255 | // Don't add the main IP again. |
1236 | - if (isset($triggers['main_ip'])) |
|
1237 | - $values = array_diff($values, array($triggers['main_ip'])); |
|
1256 | + if (isset($triggers['main_ip'])) { |
|
1257 | + $values = array_diff($values, array($triggers['main_ip'])); |
|
1258 | + } |
|
1238 | 1259 | unset($value); |
1239 | 1260 | foreach ($values as $val) |
1240 | 1261 | { |
1241 | 1262 | $val = trim($val); |
1242 | 1263 | $ip_parts = ip2range($val); |
1243 | - if (!checkExistingTriggerIP($ip_parts, $val)) |
|
1244 | - $context['ban_erros'][] = 'invalid_ip'; |
|
1245 | - else |
|
1264 | + if (!checkExistingTriggerIP($ip_parts, $val)) { |
|
1265 | + $context['ban_erros'][] = 'invalid_ip'; |
|
1266 | + } else |
|
1246 | 1267 | { |
1247 | 1268 | $ban_triggers[$key][] = array( |
1248 | 1269 | 'ip_low' => $ip_parts['low'], |
@@ -1255,15 +1276,16 @@ discard block |
||
1255 | 1276 | ); |
1256 | 1277 | } |
1257 | 1278 | } |
1279 | + } else { |
|
1280 | + $context['ban_erros'][] = 'no_bantype_selected'; |
|
1258 | 1281 | } |
1259 | - else |
|
1260 | - $context['ban_erros'][] = 'no_bantype_selected'; |
|
1261 | 1282 | |
1262 | - if (isset($value) && !is_array($value)) |
|
1263 | - $log_info[] = array( |
|
1283 | + if (isset($value) && !is_array($value)) { |
|
1284 | + $log_info[] = array( |
|
1264 | 1285 | 'value' => $value, |
1265 | 1286 | 'bantype' => $key, |
1266 | 1287 | ); |
1288 | + } |
|
1267 | 1289 | } |
1268 | 1290 | } |
1269 | 1291 | return array('ban_triggers' => $ban_triggers, 'log_info' => $log_info); |
@@ -1283,8 +1305,9 @@ discard block |
||
1283 | 1305 | { |
1284 | 1306 | global $smcFunc, $context; |
1285 | 1307 | |
1286 | - if (empty($group_id)) |
|
1287 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
1308 | + if (empty($group_id)) { |
|
1309 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
1310 | + } |
|
1288 | 1311 | |
1289 | 1312 | // Preset all values that are required. |
1290 | 1313 | $values = array( |
@@ -1309,18 +1332,21 @@ discard block |
||
1309 | 1332 | foreach ($triggers as $key => $trigger) |
1310 | 1333 | { |
1311 | 1334 | // Exceptions, exceptions, exceptions...always exceptions... :P |
1312 | - if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) |
|
1313 | - foreach ($trigger as $real_trigger) |
|
1335 | + if (in_array($key, array('ips_in_messages', 'ips_in_errors'))) { |
|
1336 | + foreach ($trigger as $real_trigger) |
|
1314 | 1337 | $insertTriggers[] = array_merge($values, $real_trigger); |
1315 | - else |
|
1316 | - $insertTriggers[] = array_merge($values, $trigger); |
|
1338 | + } else { |
|
1339 | + $insertTriggers[] = array_merge($values, $trigger); |
|
1340 | + } |
|
1317 | 1341 | } |
1318 | 1342 | |
1319 | - if (empty($insertTriggers)) |
|
1320 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
1343 | + if (empty($insertTriggers)) { |
|
1344 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
1345 | + } |
|
1321 | 1346 | |
1322 | - if (!empty($context['ban_errors'])) |
|
1323 | - return false; |
|
1347 | + if (!empty($context['ban_errors'])) { |
|
1348 | + return false; |
|
1349 | + } |
|
1324 | 1350 | |
1325 | 1351 | $smcFunc['db_insert']('', |
1326 | 1352 | '{db_prefix}ban_items', |
@@ -1348,15 +1374,19 @@ discard block |
||
1348 | 1374 | { |
1349 | 1375 | global $smcFunc, $context; |
1350 | 1376 | |
1351 | - if (empty($ban_item)) |
|
1352 | - $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
1353 | - if (empty($group_id)) |
|
1354 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
1355 | - if (empty($trigger)) |
|
1356 | - $context['ban_errors'][] = 'ban_no_triggers'; |
|
1377 | + if (empty($ban_item)) { |
|
1378 | + $context['ban_errors'][] = 'ban_ban_item_empty'; |
|
1379 | + } |
|
1380 | + if (empty($group_id)) { |
|
1381 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
1382 | + } |
|
1383 | + if (empty($trigger)) { |
|
1384 | + $context['ban_errors'][] = 'ban_no_triggers'; |
|
1385 | + } |
|
1357 | 1386 | |
1358 | - if (!empty($context['ban_errors'])) |
|
1359 | - return; |
|
1387 | + if (!empty($context['ban_errors'])) { |
|
1388 | + return; |
|
1389 | + } |
|
1360 | 1390 | |
1361 | 1391 | // Preset all values that are required. |
1362 | 1392 | $values = array( |
@@ -1397,8 +1427,9 @@ discard block |
||
1397 | 1427 | */ |
1398 | 1428 | function logTriggersUpdates($logs, $new = true, $removal = false) |
1399 | 1429 | { |
1400 | - if (empty($logs)) |
|
1401 | - return; |
|
1430 | + if (empty($logs)) { |
|
1431 | + return; |
|
1432 | + } |
|
1402 | 1433 | |
1403 | 1434 | $log_name_map = array( |
1404 | 1435 | 'main_ip' => 'ip_range', |
@@ -1409,14 +1440,15 @@ discard block |
||
1409 | 1440 | ); |
1410 | 1441 | |
1411 | 1442 | // Log the addion of the ban entries into the moderation log. |
1412 | - foreach ($logs as $log) |
|
1413 | - logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
1443 | + foreach ($logs as $log) { |
|
1444 | + logAction('ban' . ($removal == true ? 'remove' : ''), array( |
|
1414 | 1445 | $log_name_map[$log['bantype']] => $log['value'], |
1415 | 1446 | 'new' => empty($new) ? 0 : 1, |
1416 | 1447 | 'remove' => empty($removal) ? 0 : 1, |
1417 | 1448 | 'type' => $log['bantype'], |
1418 | 1449 | )); |
1419 | -} |
|
1450 | + } |
|
1451 | + } |
|
1420 | 1452 | |
1421 | 1453 | /** |
1422 | 1454 | * Updates an existing ban group |
@@ -1430,12 +1462,15 @@ discard block |
||
1430 | 1462 | { |
1431 | 1463 | global $smcFunc, $context; |
1432 | 1464 | |
1433 | - if (empty($ban_info['name'])) |
|
1434 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
1435 | - if (empty($ban_info['id'])) |
|
1436 | - $context['ban_errors'][] = 'ban_id_empty'; |
|
1437 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
1438 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1465 | + if (empty($ban_info['name'])) { |
|
1466 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
1467 | + } |
|
1468 | + if (empty($ban_info['id'])) { |
|
1469 | + $context['ban_errors'][] = 'ban_id_empty'; |
|
1470 | + } |
|
1471 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
1472 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1473 | + } |
|
1439 | 1474 | |
1440 | 1475 | if (!empty($ban_info['id'])) |
1441 | 1476 | { |
@@ -1450,8 +1485,9 @@ discard block |
||
1450 | 1485 | ) |
1451 | 1486 | ); |
1452 | 1487 | |
1453 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1454 | - $context['ban_errors'][] = 'ban_not_found'; |
|
1488 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1489 | + $context['ban_errors'][] = 'ban_not_found'; |
|
1490 | + } |
|
1455 | 1491 | $smcFunc['db_free_result']($request); |
1456 | 1492 | } |
1457 | 1493 | |
@@ -1469,13 +1505,15 @@ discard block |
||
1469 | 1505 | 'new_ban_name' => $ban_info['name'], |
1470 | 1506 | ) |
1471 | 1507 | ); |
1472 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1473 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
1508 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1509 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
1510 | + } |
|
1474 | 1511 | $smcFunc['db_free_result']($request); |
1475 | 1512 | } |
1476 | 1513 | |
1477 | - if (!empty($context['ban_errors'])) |
|
1478 | - return $ban_info['id']; |
|
1514 | + if (!empty($context['ban_errors'])) { |
|
1515 | + return $ban_info['id']; |
|
1516 | + } |
|
1479 | 1517 | |
1480 | 1518 | $smcFunc['db_query']('', ' |
1481 | 1519 | UPDATE {db_prefix}ban_groups |
@@ -1519,10 +1557,12 @@ discard block |
||
1519 | 1557 | { |
1520 | 1558 | global $smcFunc, $context; |
1521 | 1559 | |
1522 | - if (empty($ban_info['name'])) |
|
1523 | - $context['ban_errors'][] = 'ban_name_empty'; |
|
1524 | - if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) |
|
1525 | - $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1560 | + if (empty($ban_info['name'])) { |
|
1561 | + $context['ban_errors'][] = 'ban_name_empty'; |
|
1562 | + } |
|
1563 | + if (empty($ban_info['cannot']['access']) && empty($ban_info['cannot']['register']) && empty($ban_info['cannot']['post']) && empty($ban_info['cannot']['login'])) { |
|
1564 | + $context['ban_errors'][] = 'ban_unknown_restriction_type'; |
|
1565 | + } |
|
1526 | 1566 | |
1527 | 1567 | if (!empty($ban_info['name'])) |
1528 | 1568 | { |
@@ -1537,13 +1577,15 @@ discard block |
||
1537 | 1577 | ) |
1538 | 1578 | ); |
1539 | 1579 | |
1540 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
1541 | - $context['ban_errors'][] = 'ban_name_exists'; |
|
1580 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
1581 | + $context['ban_errors'][] = 'ban_name_exists'; |
|
1582 | + } |
|
1542 | 1583 | $smcFunc['db_free_result']($request); |
1543 | 1584 | } |
1544 | 1585 | |
1545 | - if (!empty($context['ban_errors'])) |
|
1546 | - return; |
|
1586 | + if (!empty($context['ban_errors'])) { |
|
1587 | + return; |
|
1588 | + } |
|
1547 | 1589 | |
1548 | 1590 | // Yes yes, we're ready to add now. |
1549 | 1591 | $ban_info['id'] = $smcFunc['db_insert']('', |
@@ -1560,8 +1602,9 @@ discard block |
||
1560 | 1602 | 1 |
1561 | 1603 | ); |
1562 | 1604 | |
1563 | - if (empty($ban_info['id'])) |
|
1564 | - $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
1605 | + if (empty($ban_info['id'])) { |
|
1606 | + $context['ban_errors'][] = 'impossible_insert_new_bangroup'; |
|
1607 | + } |
|
1565 | 1608 | |
1566 | 1609 | return $ban_info['id']; |
1567 | 1610 | } |
@@ -1586,24 +1629,24 @@ discard block |
||
1586 | 1629 | $ban_group = isset($_REQUEST['bg']) ? (int) $_REQUEST['bg'] : 0; |
1587 | 1630 | $ban_id = isset($_REQUEST['bi']) ? (int) $_REQUEST['bi'] : 0; |
1588 | 1631 | |
1589 | - if (empty($ban_group)) |
|
1590 | - fatal_lang_error('ban_not_found', false); |
|
1632 | + if (empty($ban_group)) { |
|
1633 | + fatal_lang_error('ban_not_found', false); |
|
1634 | + } |
|
1591 | 1635 | |
1592 | 1636 | if (isset($_POST['add_new_trigger']) && !empty($_POST['ban_suggestions'])) |
1593 | 1637 | { |
1594 | 1638 | saveTriggers($_POST['ban_suggestions'], $ban_group, 0, $ban_id); |
1595 | 1639 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
1596 | - } |
|
1597 | - elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
1640 | + } elseif (isset($_POST['edit_trigger']) && !empty($_POST['ban_suggestions'])) |
|
1598 | 1641 | { |
1599 | 1642 | // The first replaces the old one, the others are added new (simplification, otherwise it would require another query and some work...) |
1600 | 1643 | saveTriggers(array_shift($_POST['ban_suggestions']), $ban_group, 0, $ban_id); |
1601 | - if (!empty($_POST['ban_suggestions'])) |
|
1602 | - saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
1644 | + if (!empty($_POST['ban_suggestions'])) { |
|
1645 | + saveTriggers($_POST['ban_suggestions'], $ban_group); |
|
1646 | + } |
|
1603 | 1647 | |
1604 | 1648 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
1605 | - } |
|
1606 | - elseif (isset($_POST['edit_trigger'])) |
|
1649 | + } elseif (isset($_POST['edit_trigger'])) |
|
1607 | 1650 | { |
1608 | 1651 | removeBanTriggers($ban_id); |
1609 | 1652 | redirectexit('action=admin;area=ban;sa=edit' . (!empty($ban_group) ? ';bg=' . $ban_group : '')); |
@@ -1634,8 +1677,7 @@ discard block |
||
1634 | 1677 | ), |
1635 | 1678 | 'is_new' => true, |
1636 | 1679 | ); |
1637 | - } |
|
1638 | - else |
|
1680 | + } else |
|
1639 | 1681 | { |
1640 | 1682 | $request = $smcFunc['db_query']('', ' |
1641 | 1683 | SELECT |
@@ -1652,8 +1694,9 @@ discard block |
||
1652 | 1694 | 'ban_group' => $ban_group, |
1653 | 1695 | ) |
1654 | 1696 | ); |
1655 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1656 | - fatal_lang_error('ban_not_found', false); |
|
1697 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1698 | + fatal_lang_error('ban_not_found', false); |
|
1699 | + } |
|
1657 | 1700 | $row = $smcFunc['db_fetch_assoc']($request); |
1658 | 1701 | $smcFunc['db_free_result']($request); |
1659 | 1702 | |
@@ -1702,8 +1745,9 @@ discard block |
||
1702 | 1745 | removeBanTriggers($_POST['remove']); |
1703 | 1746 | |
1704 | 1747 | // Rehabilitate some members. |
1705 | - if ($_REQUEST['entity'] == 'member') |
|
1706 | - updateBanMembers(); |
|
1748 | + if ($_REQUEST['entity'] == 'member') { |
|
1749 | + updateBanMembers(); |
|
1750 | + } |
|
1707 | 1751 | |
1708 | 1752 | // Make sure the ban cache is refreshed. |
1709 | 1753 | updateSettings(array('banLastUpdated' => time())); |
@@ -1816,8 +1860,7 @@ discard block |
||
1816 | 1860 | 'default' => 'bi.ip_low, bi.ip_high, bi.ip_low', |
1817 | 1861 | 'reverse' => 'bi.ip_low DESC, bi.ip_high DESC', |
1818 | 1862 | ); |
1819 | - } |
|
1820 | - elseif ($context['selected_entity'] === 'hostname') |
|
1863 | + } elseif ($context['selected_entity'] === 'hostname') |
|
1821 | 1864 | { |
1822 | 1865 | $listOptions['columns']['banned_entity']['data'] = array( |
1823 | 1866 | 'function' => function($rowData) use ($smcFunc) |
@@ -1829,8 +1872,7 @@ discard block |
||
1829 | 1872 | 'default' => 'bi.hostname', |
1830 | 1873 | 'reverse' => 'bi.hostname DESC', |
1831 | 1874 | ); |
1832 | - } |
|
1833 | - elseif ($context['selected_entity'] === 'email') |
|
1875 | + } elseif ($context['selected_entity'] === 'email') |
|
1834 | 1876 | { |
1835 | 1877 | $listOptions['columns']['banned_entity']['data'] = array( |
1836 | 1878 | 'function' => function($rowData) use ($smcFunc) |
@@ -1842,8 +1884,7 @@ discard block |
||
1842 | 1884 | 'default' => 'bi.email_address', |
1843 | 1885 | 'reverse' => 'bi.email_address DESC', |
1844 | 1886 | ); |
1845 | - } |
|
1846 | - elseif ($context['selected_entity'] === 'member') |
|
1887 | + } elseif ($context['selected_entity'] === 'member') |
|
1847 | 1888 | { |
1848 | 1889 | $listOptions['columns']['banned_entity']['data'] = array( |
1849 | 1890 | 'sprintf' => array( |
@@ -1907,8 +1948,9 @@ discard block |
||
1907 | 1948 | ) |
1908 | 1949 | ); |
1909 | 1950 | $ban_triggers = array(); |
1910 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1911 | - $ban_triggers[] = $row; |
|
1951 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1952 | + $ban_triggers[] = $row; |
|
1953 | + } |
|
1912 | 1954 | $smcFunc['db_free_result']($request); |
1913 | 1955 | |
1914 | 1956 | return $ban_triggers; |
@@ -1964,8 +2006,9 @@ discard block |
||
1964 | 2006 | validateToken('admin-bl'); |
1965 | 2007 | |
1966 | 2008 | // 'Delete all entries' button was pressed. |
1967 | - if (!empty($_POST['removeAll'])) |
|
1968 | - removeBanLogs(); |
|
2009 | + if (!empty($_POST['removeAll'])) { |
|
2010 | + removeBanLogs(); |
|
2011 | + } |
|
1969 | 2012 | // 'Delete selection' button was pressed. |
1970 | 2013 | else |
1971 | 2014 | { |
@@ -2174,12 +2217,15 @@ discard block |
||
2174 | 2217 | $low = inet_dtop($low); |
2175 | 2218 | $high = inet_dtop($high); |
2176 | 2219 | |
2177 | - if ($low == '255.255.255.255') return 'unknown'; |
|
2178 | - if ($low == $high) |
|
2179 | - return $low; |
|
2180 | - else |
|
2181 | - return $low . '-' . $high; |
|
2182 | -} |
|
2220 | + if ($low == '255.255.255.255') { |
|
2221 | + return 'unknown'; |
|
2222 | + } |
|
2223 | + if ($low == $high) { |
|
2224 | + return $low; |
|
2225 | + } else { |
|
2226 | + return $low . '-' . $high; |
|
2227 | + } |
|
2228 | + } |
|
2183 | 2229 | |
2184 | 2230 | /** |
2185 | 2231 | * Checks whether a given IP range already exists in the trigger list. |
@@ -2255,15 +2301,17 @@ discard block |
||
2255 | 2301 | $memberEmailWild = array(); |
2256 | 2302 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2257 | 2303 | { |
2258 | - if ($row['id_member']) |
|
2259 | - $memberIDs[$row['id_member']] = $row['id_member']; |
|
2304 | + if ($row['id_member']) { |
|
2305 | + $memberIDs[$row['id_member']] = $row['id_member']; |
|
2306 | + } |
|
2260 | 2307 | if ($row['email_address']) |
2261 | 2308 | { |
2262 | 2309 | // Does it have a wildcard - if so we can't do a IN on it. |
2263 | - if (strpos($row['email_address'], '%') !== false) |
|
2264 | - $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
2265 | - else |
|
2266 | - $memberEmails[$row['email_address']] = $row['email_address']; |
|
2310 | + if (strpos($row['email_address'], '%') !== false) { |
|
2311 | + $memberEmailWild[$row['email_address']] = $row['email_address']; |
|
2312 | + } else { |
|
2313 | + $memberEmails[$row['email_address']] = $row['email_address']; |
|
2314 | + } |
|
2267 | 2315 | } |
2268 | 2316 | } |
2269 | 2317 | $smcFunc['db_free_result']($request); |
@@ -2314,14 +2362,15 @@ discard block |
||
2314 | 2362 | } |
2315 | 2363 | |
2316 | 2364 | // We welcome our new members in the realm of the banned. |
2317 | - if (!empty($newMembers)) |
|
2318 | - $smcFunc['db_query']('', ' |
|
2365 | + if (!empty($newMembers)) { |
|
2366 | + $smcFunc['db_query']('', ' |
|
2319 | 2367 | DELETE FROM {db_prefix}log_online |
2320 | 2368 | WHERE id_member IN ({array_int:new_banned_members})', |
2321 | 2369 | array( |
2322 | 2370 | 'new_banned_members' => $newMembers, |
2323 | 2371 | ) |
2324 | 2372 | ); |
2373 | + } |
|
2325 | 2374 | |
2326 | 2375 | // Find members that are wrongfully marked as banned. |
2327 | 2376 | $request = $smcFunc['db_query']('', ' |
@@ -2348,9 +2397,10 @@ discard block |
||
2348 | 2397 | } |
2349 | 2398 | $smcFunc['db_free_result']($request); |
2350 | 2399 | |
2351 | - if (!empty($updates)) |
|
2352 | - foreach ($updates as $newStatus => $members) |
|
2400 | + if (!empty($updates)) { |
|
2401 | + foreach ($updates as $newStatus => $members) |
|
2353 | 2402 | updateMemberData($members, array('is_activated' => $newStatus)); |
2403 | + } |
|
2354 | 2404 | |
2355 | 2405 | // Update the latest member and our total members as banning may change them. |
2356 | 2406 | updateStats('member'); |
@@ -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 | { |