@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * 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,34 +173,39 @@ 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 | 195 | } |
190 | - if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
191 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
192 | - elseif (!empty($stack)) |
|
193 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
196 | + if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
197 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
198 | + } elseif (!empty($stack)) { |
|
199 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
200 | + } |
|
194 | 201 | |
195 | - if (empty($boardList[$catid])) |
|
196 | - $context['categories'][$catid]['move_link'] = array( |
|
202 | + if (empty($boardList[$catid])) { |
|
203 | + $context['categories'][$catid]['move_link'] = array( |
|
197 | 204 | 'child_level' => 0, |
198 | 205 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'', |
199 | 206 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
200 | 207 | ); |
208 | + } |
|
201 | 209 | } |
202 | 210 | } |
203 | 211 | |
@@ -253,9 +261,9 @@ discard block |
||
253 | 261 | ); |
254 | 262 | } |
255 | 263 | // Category doesn't exist, man... sorry. |
256 | - elseif (!isset($cat_tree[$_REQUEST['cat']])) |
|
257 | - redirectexit('action=admin;area=manageboards'); |
|
258 | - else |
|
264 | + elseif (!isset($cat_tree[$_REQUEST['cat']])) { |
|
265 | + redirectexit('action=admin;area=manageboards'); |
|
266 | + } else |
|
259 | 267 | { |
260 | 268 | $context['category'] = array( |
261 | 269 | 'id' => $_REQUEST['cat'], |
@@ -267,30 +275,31 @@ discard block |
||
267 | 275 | 'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children']) |
268 | 276 | ); |
269 | 277 | |
270 | - foreach ($boardList[$_REQUEST['cat']] as $child_board) |
|
271 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
278 | + foreach ($boardList[$_REQUEST['cat']] as $child_board) { |
|
279 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
280 | + } |
|
272 | 281 | } |
273 | 282 | |
274 | 283 | $prevCat = 0; |
275 | 284 | foreach ($cat_tree as $catid => $tree) |
276 | 285 | { |
277 | - if ($catid == $_REQUEST['cat'] && $prevCat > 0) |
|
278 | - $context['category_order'][$prevCat]['selected'] = true; |
|
279 | - elseif ($catid != $_REQUEST['cat']) |
|
280 | - $context['category_order'][$catid] = array( |
|
286 | + if ($catid == $_REQUEST['cat'] && $prevCat > 0) { |
|
287 | + $context['category_order'][$prevCat]['selected'] = true; |
|
288 | + } elseif ($catid != $_REQUEST['cat']) { |
|
289 | + $context['category_order'][$catid] = array( |
|
281 | 290 | 'id' => $catid, |
282 | 291 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
283 | 292 | 'selected' => false, |
284 | 293 | 'true_name' => $tree['node']['name'] |
285 | 294 | ); |
295 | + } |
|
286 | 296 | $prevCat = $catid; |
287 | 297 | } |
288 | 298 | if (!isset($_REQUEST['delete'])) |
289 | 299 | { |
290 | 300 | $context['sub_template'] = 'modify_category'; |
291 | 301 | $context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit']; |
292 | - } |
|
293 | - else |
|
302 | + } else |
|
294 | 303 | { |
295 | 304 | $context['sub_template'] = 'confirm_category_delete'; |
296 | 305 | $context['page_title'] = $txt['mboards_delete_cat']; |
@@ -327,8 +336,9 @@ discard block |
||
327 | 336 | { |
328 | 337 | $catOptions = array(); |
329 | 338 | |
330 | - if (isset($_POST['cat_order'])) |
|
331 | - $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
339 | + if (isset($_POST['cat_order'])) { |
|
340 | + $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
341 | + } |
|
332 | 342 | |
333 | 343 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
334 | 344 | $catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']); |
@@ -336,10 +346,11 @@ discard block |
||
336 | 346 | |
337 | 347 | $catOptions['is_collapsible'] = isset($_POST['collapse']); |
338 | 348 | |
339 | - if (isset($_POST['add'])) |
|
340 | - createCategory($catOptions); |
|
341 | - else |
|
342 | - modifyCategory($_POST['cat'], $catOptions); |
|
349 | + if (isset($_POST['add'])) { |
|
350 | + createCategory($catOptions); |
|
351 | + } else { |
|
352 | + modifyCategory($_POST['cat'], $catOptions); |
|
353 | + } |
|
343 | 354 | } |
344 | 355 | // If they want to delete - first give them confirmation. |
345 | 356 | elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) |
@@ -353,13 +364,14 @@ discard block |
||
353 | 364 | // First off - check if we are moving all the current boards first - before we start deleting! |
354 | 365 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
355 | 366 | { |
356 | - if (empty($_POST['cat_to'])) |
|
357 | - fatal_lang_error('mboards_delete_error'); |
|
367 | + if (empty($_POST['cat_to'])) { |
|
368 | + fatal_lang_error('mboards_delete_error'); |
|
369 | + } |
|
358 | 370 | |
359 | 371 | deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); |
372 | + } else { |
|
373 | + deleteCategories(array($_POST['cat'])); |
|
360 | 374 | } |
361 | - else |
|
362 | - deleteCategories(array($_POST['cat'])); |
|
363 | 375 | } |
364 | 376 | |
365 | 377 | redirectexit('action=admin;area=manageboards'); |
@@ -404,8 +416,9 @@ discard block |
||
404 | 416 | if ($_REQUEST['sa'] == 'newboard') |
405 | 417 | { |
406 | 418 | // Category doesn't exist, man... sorry. |
407 | - if (empty($_REQUEST['cat'])) |
|
408 | - redirectexit('action=admin;area=manageboards'); |
|
419 | + if (empty($_REQUEST['cat'])) { |
|
420 | + redirectexit('action=admin;area=manageboards'); |
|
421 | + } |
|
409 | 422 | |
410 | 423 | // Some things that need to be setup for a new board. |
411 | 424 | $curBoard = array( |
@@ -429,8 +442,7 @@ discard block |
||
429 | 442 | 'category' => (int) $_REQUEST['cat'], |
430 | 443 | 'no_children' => true, |
431 | 444 | ); |
432 | - } |
|
433 | - else |
|
445 | + } else |
|
434 | 446 | { |
435 | 447 | // Just some easy shortcuts. |
436 | 448 | $curBoard = &$boards[$_REQUEST['boardid']]; |
@@ -478,8 +490,9 @@ discard block |
||
478 | 490 | ); |
479 | 491 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
480 | 492 | { |
481 | - if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) |
|
482 | - $curBoard['member_groups'][] = $row['id_group']; |
|
493 | + if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) { |
|
494 | + $curBoard['member_groups'][] = $row['id_group']; |
|
495 | + } |
|
483 | 496 | |
484 | 497 | $context['groups'][(int) $row['id_group']] = array( |
485 | 498 | 'id' => $row['id_group'], |
@@ -492,8 +505,9 @@ discard block |
||
492 | 505 | $smcFunc['db_free_result']($request); |
493 | 506 | |
494 | 507 | // Category doesn't exist, man... sorry. |
495 | - if (!isset($boardList[$curBoard['category']])) |
|
496 | - redirectexit('action=admin;area=manageboards'); |
|
508 | + if (!isset($boardList[$curBoard['category']])) { |
|
509 | + redirectexit('action=admin;area=manageboards'); |
|
510 | + } |
|
497 | 511 | |
498 | 512 | foreach ($boardList[$curBoard['category']] as $boardid) |
499 | 513 | { |
@@ -507,8 +521,7 @@ discard block |
||
507 | 521 | 'is_child' => false, |
508 | 522 | 'selected' => true |
509 | 523 | ); |
510 | - } |
|
511 | - else |
|
524 | + } else |
|
512 | 525 | { |
513 | 526 | $context['board_order'][] = array( |
514 | 527 | 'id' => $boardid, |
@@ -525,19 +538,21 @@ discard block |
||
525 | 538 | $context['can_move_children'] = false; |
526 | 539 | $context['children'] = $boards[$_REQUEST['boardid']]['tree']['children']; |
527 | 540 | |
528 | - foreach ($context['board_order'] as $lBoard) |
|
529 | - if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
541 | + foreach ($context['board_order'] as $lBoard) { |
|
542 | + if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
530 | 543 | $context['can_move_children'] = true; |
544 | + } |
|
531 | 545 | } |
532 | 546 | |
533 | 547 | // Get other available categories. |
534 | 548 | $context['categories'] = array(); |
535 | - foreach ($cat_tree as $catID => $tree) |
|
536 | - $context['categories'][] = array( |
|
549 | + foreach ($cat_tree as $catID => $tree) { |
|
550 | + $context['categories'][] = array( |
|
537 | 551 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
538 | 552 | 'name' => $tree['node']['name'], |
539 | 553 | 'selected' => $catID == $curBoard['category'] |
540 | 554 | ); |
555 | + } |
|
541 | 556 | |
542 | 557 | $request = $smcFunc['db_query']('', ' |
543 | 558 | SELECT mem.id_member, mem.real_name |
@@ -549,14 +564,16 @@ discard block |
||
549 | 564 | ) |
550 | 565 | ); |
551 | 566 | $context['board']['moderators'] = array(); |
552 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
553 | - $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
567 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
568 | + $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
569 | + } |
|
554 | 570 | $smcFunc['db_free_result']($request); |
555 | 571 | |
556 | 572 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
557 | 573 | |
558 | - if (!empty($context['board']['moderators'])) |
|
559 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
574 | + if (!empty($context['board']['moderators'])) { |
|
575 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
576 | + } |
|
560 | 577 | |
561 | 578 | // Get all the groups assigned as moderators |
562 | 579 | $request = $smcFunc['db_query']('', ' |
@@ -568,14 +585,16 @@ discard block |
||
568 | 585 | ) |
569 | 586 | ); |
570 | 587 | $context['board']['moderator_groups'] = array(); |
571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
572 | - $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
589 | + $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
590 | + } |
|
573 | 591 | $smcFunc['db_free_result']($request); |
574 | 592 | |
575 | 593 | $context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '"' . implode('", &qout;', $context['board']['moderator_groups']) . '"'; |
576 | 594 | |
577 | - if (!empty($context['board']['moderator_groups'])) |
|
578 | - list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
595 | + if (!empty($context['board']['moderator_groups'])) { |
|
596 | + list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
597 | + } |
|
579 | 598 | |
580 | 599 | // Get all the themes... |
581 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +606,9 @@ discard block |
||
587 | 606 | ) |
588 | 607 | ); |
589 | 608 | $context['themes'] = array(); |
590 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
591 | - $context['themes'][] = $row; |
|
609 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
610 | + $context['themes'][] = $row; |
|
611 | + } |
|
592 | 612 | $smcFunc['db_free_result']($request); |
593 | 613 | |
594 | 614 | if (!isset($_REQUEST['delete'])) |
@@ -596,8 +616,7 @@ discard block |
||
596 | 616 | $context['sub_template'] = 'modify_board'; |
597 | 617 | $context['page_title'] = $txt['boardsEdit']; |
598 | 618 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
599 | - } |
|
600 | - else |
|
619 | + } else |
|
601 | 620 | { |
602 | 621 | $context['sub_template'] = 'confirm_board_delete'; |
603 | 622 | $context['page_title'] = $txt['mboards_delete_board']; |
@@ -641,8 +660,9 @@ discard block |
||
641 | 660 | // Change the boardorder of this board? |
642 | 661 | elseif (!empty($_POST['placement']) && !empty($_POST['board_order'])) |
643 | 662 | { |
644 | - if (!in_array($_POST['placement'], array('before', 'after', 'child'))) |
|
645 | - fatal_lang_error('mangled_post', false); |
|
663 | + if (!in_array($_POST['placement'], array('before', 'after', 'child'))) { |
|
664 | + fatal_lang_error('mangled_post', false); |
|
665 | + } |
|
646 | 666 | |
647 | 667 | $boardOptions['move_to'] = $_POST['placement']; |
648 | 668 | $boardOptions['target_board'] = (int) $_POST['board_order']; |
@@ -655,13 +675,14 @@ discard block |
||
655 | 675 | $boardOptions['access_groups'] = array(); |
656 | 676 | $boardOptions['deny_groups'] = array(); |
657 | 677 | |
658 | - if (!empty($_POST['groups'])) |
|
659 | - foreach ($_POST['groups'] as $group => $action) |
|
678 | + if (!empty($_POST['groups'])) { |
|
679 | + foreach ($_POST['groups'] as $group => $action) |
|
660 | 680 | { |
661 | 681 | if ($action == 'allow') |
662 | 682 | $boardOptions['access_groups'][] = (int) $group; |
663 | - elseif ($action == 'deny') |
|
664 | - $boardOptions['deny_groups'][] = (int) $group; |
|
683 | + } elseif ($action == 'deny') { |
|
684 | + $boardOptions['deny_groups'][] = (int) $group; |
|
685 | + } |
|
665 | 686 | } |
666 | 687 | |
667 | 688 | // People with manage-boards are special. |
@@ -673,8 +694,9 @@ discard block |
||
673 | 694 | // Secondly, make sure those with super cow powers (like apt-get, or in this case manage boards) are upgraded. |
674 | 695 | $boardOptions['access_groups'] = array_unique(array_merge($boardOptions['access_groups'], $board_managers)); |
675 | 696 | |
676 | - if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
|
677 | - fatal_lang_error('too_many_groups', false); |
|
697 | + if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) { |
|
698 | + fatal_lang_error('too_many_groups', false); |
|
699 | + } |
|
678 | 700 | |
679 | 701 | // Do not allow HTML tags. Parse the string. |
680 | 702 | $boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']); |
@@ -685,8 +707,9 @@ discard block |
||
685 | 707 | if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list'])) |
686 | 708 | { |
687 | 709 | $moderators = array(); |
688 | - foreach ($_POST['moderator_list'] as $moderator) |
|
689 | - $moderators[(int) $moderator] = (int) $moderator; |
|
710 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
711 | + $moderators[(int) $moderator] = (int) $moderator; |
|
712 | + } |
|
690 | 713 | $boardOptions['moderators'] = $moderators; |
691 | 714 | } |
692 | 715 | |
@@ -695,8 +718,9 @@ discard block |
||
695 | 718 | if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list'])) |
696 | 719 | { |
697 | 720 | $moderator_groups = array(); |
698 | - foreach ($_POST['moderator_group_list'] as $moderator_group) |
|
699 | - $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
721 | + foreach ($_POST['moderator_group_list'] as $moderator_group) { |
|
722 | + $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
723 | + } |
|
700 | 724 | $boardOptions['moderator_groups'] = $moderator_groups; |
701 | 725 | } |
702 | 726 | |
@@ -722,56 +746,62 @@ discard block |
||
722 | 746 | $smcFunc['db_free_result']($request); |
723 | 747 | |
724 | 748 | // 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. |
725 | - if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) |
|
726 | - unset($boardOptions['redirect']); |
|
749 | + if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) { |
|
750 | + unset($boardOptions['redirect']); |
|
751 | + } |
|
727 | 752 | // Reset the redirection count when switching on/off. |
728 | - elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) |
|
729 | - $boardOptions['num_posts'] = 0; |
|
753 | + elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) { |
|
754 | + $boardOptions['num_posts'] = 0; |
|
755 | + } |
|
730 | 756 | // Resetting the count? |
731 | - elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) |
|
732 | - $boardOptions['num_posts'] = 0; |
|
757 | + elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) { |
|
758 | + $boardOptions['num_posts'] = 0; |
|
759 | + } |
|
733 | 760 | } |
734 | 761 | |
735 | 762 | // Create a new board... |
736 | 763 | if (isset($_POST['add'])) |
737 | 764 | { |
738 | 765 | // New boards by default go to the bottom of the category. |
739 | - if (empty($_POST['new_cat'])) |
|
740 | - $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
741 | - if (!isset($boardOptions['move_to'])) |
|
742 | - $boardOptions['move_to'] = 'bottom'; |
|
766 | + if (empty($_POST['new_cat'])) { |
|
767 | + $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
768 | + } |
|
769 | + if (!isset($boardOptions['move_to'])) { |
|
770 | + $boardOptions['move_to'] = 'bottom'; |
|
771 | + } |
|
743 | 772 | |
744 | 773 | createBoard($boardOptions); |
745 | 774 | } |
746 | 775 | |
747 | 776 | // ...or update an existing board. |
748 | - else |
|
749 | - modifyBoard($_POST['boardid'], $boardOptions); |
|
750 | - } |
|
751 | - elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
777 | + else { |
|
778 | + modifyBoard($_POST['boardid'], $boardOptions); |
|
779 | + } |
|
780 | + } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
752 | 781 | { |
753 | 782 | EditBoard(); |
754 | 783 | return; |
755 | - } |
|
756 | - elseif (isset($_POST['delete'])) |
|
784 | + } elseif (isset($_POST['delete'])) |
|
757 | 785 | { |
758 | 786 | // First off - check if we are moving all the current child boards first - before we start deleting! |
759 | 787 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
760 | 788 | { |
761 | - if (empty($_POST['board_to'])) |
|
762 | - fatal_lang_error('mboards_delete_board_error'); |
|
789 | + if (empty($_POST['board_to'])) { |
|
790 | + fatal_lang_error('mboards_delete_board_error'); |
|
791 | + } |
|
763 | 792 | |
764 | 793 | deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']); |
794 | + } else { |
|
795 | + deleteBoards(array($_POST['boardid']), 0); |
|
765 | 796 | } |
766 | - else |
|
767 | - deleteBoards(array($_POST['boardid']), 0); |
|
768 | 797 | } |
769 | 798 | |
770 | - if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') |
|
771 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
772 | - else |
|
773 | - redirectexit('action=admin;area=manageboards'); |
|
774 | -} |
|
799 | + if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') { |
|
800 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
801 | + } else { |
|
802 | + redirectexit('action=admin;area=manageboards'); |
|
803 | + } |
|
804 | + } |
|
775 | 805 | |
776 | 806 | /** |
777 | 807 | * Used to retrieve data for modifying a board category |
@@ -808,8 +838,9 @@ discard block |
||
808 | 838 | $smcFunc['db_free_result']($request); |
809 | 839 | |
810 | 840 | // This would probably never happen, but just to be sure. |
811 | - if ($cat .= $allowed_sa[1]) |
|
812 | - die(str_replace(',', ' to', $cat)); |
|
841 | + if ($cat .= $allowed_sa[1]) { |
|
842 | + die(str_replace(',', ' to', $cat)); |
|
843 | + } |
|
813 | 844 | |
814 | 845 | redirectexit(); |
815 | 846 | } |
@@ -835,8 +866,9 @@ discard block |
||
835 | 866 | 'empty_string' => '', |
836 | 867 | ) |
837 | 868 | ); |
838 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
839 | - $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
869 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
870 | + $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
871 | + } |
|
840 | 872 | $smcFunc['db_free_result']($request); |
841 | 873 | |
842 | 874 | require_once($sourcedir . '/Subs-Boards.php'); |
@@ -860,8 +892,9 @@ discard block |
||
860 | 892 | |
861 | 893 | call_integration_hook('integrate_modify_board_settings', array(&$config_vars)); |
862 | 894 | |
863 | - if ($return_config) |
|
864 | - return $config_vars; |
|
895 | + if ($return_config) { |
|
896 | + return $config_vars; |
|
897 | + } |
|
865 | 898 | |
866 | 899 | // Needed for the settings template. |
867 | 900 | require_once($sourcedir . '/ManageServer.php'); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Updates a report with the given parameters. Logs each action via logAction() |
@@ -28,19 +29,20 @@ discard block |
||
28 | 29 | global $smcFunc, $user_info, $context; |
29 | 30 | |
30 | 31 | // Don't bother. |
31 | - if (empty($action) || empty($report_id)) |
|
32 | - return false; |
|
32 | + if (empty($action) || empty($report_id)) { |
|
33 | + return false; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | // Add the "_all" thingy. |
35 | - if ($action == 'ignore') |
|
36 | - $action = 'ignore_all'; |
|
37 | + if ($action == 'ignore') { |
|
38 | + $action = 'ignore_all'; |
|
39 | + } |
|
37 | 40 | |
38 | 41 | // We don't need the board query for reported members |
39 | 42 | if ($context['report_type'] == 'members') |
40 | 43 | { |
41 | 44 | $board_query = ''; |
42 | - } |
|
43 | - else |
|
45 | + } else |
|
44 | 46 | { |
45 | 47 | $board_query = ' AND ' . $user_info['mod_cache']['bq']; |
46 | 48 | } |
@@ -76,17 +78,17 @@ discard block |
||
76 | 78 | ) |
77 | 79 | ); |
78 | 80 | |
79 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
80 | - $extra[$row['id_report']] = array( |
|
81 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
82 | + $extra[$row['id_report']] = array( |
|
81 | 83 | 'report' => $row['id_report'], |
82 | 84 | 'board' => $row['id_board'], |
83 | 85 | 'message' => $row['id_msg'], |
84 | 86 | 'topic' => $row['id_topic'], |
85 | 87 | ); |
88 | + } |
|
86 | 89 | |
87 | 90 | $smcFunc['db_free_result']($request); |
88 | - } |
|
89 | - else |
|
91 | + } else |
|
90 | 92 | { |
91 | 93 | $request = $smcFunc['db_query']('', ' |
92 | 94 | SELECT id_report, id_member, membername |
@@ -97,28 +99,32 @@ discard block |
||
97 | 99 | ) |
98 | 100 | ); |
99 | 101 | |
100 | - while($row = $smcFunc['db_fetch_assoc']($request)) |
|
101 | - $extra[$row['id_report']] = array( |
|
102 | + while($row = $smcFunc['db_fetch_assoc']($request)) { |
|
103 | + $extra[$row['id_report']] = array( |
|
102 | 104 | 'report' => $row['id_report'], |
103 | 105 | 'member' => $row['id_member'], |
104 | 106 | ); |
107 | + } |
|
105 | 108 | |
106 | 109 | $smcFunc['db_free_result']($request); |
107 | 110 | } |
108 | 111 | |
109 | 112 | // Back to "ignore". |
110 | - if ($action == 'ignore_all') |
|
111 | - $action = 'ignore'; |
|
113 | + if ($action == 'ignore_all') { |
|
114 | + $action = 'ignore'; |
|
115 | + } |
|
112 | 116 | |
113 | 117 | $log_report = $action == 'ignore' ? (!empty($value) ? 'ignore' : 'unignore') : (!empty($value) ? 'close' : 'open'); |
114 | 118 | |
115 | - if ($context['report_type'] == 'members') |
|
116 | - $log_report .= '_user'; |
|
119 | + if ($context['report_type'] == 'members') { |
|
120 | + $log_report .= '_user'; |
|
121 | + } |
|
117 | 122 | |
118 | 123 | // Log this action. |
119 | - if (!empty($extra)) |
|
120 | - foreach ($extra as $report) |
|
124 | + if (!empty($extra)) { |
|
125 | + foreach ($extra as $report) |
|
121 | 126 | logAction($log_report . '_report', $report); |
127 | + } |
|
122 | 128 | |
123 | 129 | // Time to update. |
124 | 130 | updateSettings(array('last_mod_report_action' => time())); |
@@ -142,14 +148,12 @@ discard block |
||
142 | 148 | if ($context['report_type'] == 'members') |
143 | 149 | { |
144 | 150 | $and = 'lr.id_board = 0'; |
145 | - } |
|
146 | - else |
|
151 | + } else |
|
147 | 152 | { |
148 | 153 | if ($user_info['mod_cache']['bq'] == '1=1' || $user_info['mod_cache']['bq'] == '0=1') |
149 | 154 | { |
150 | 155 | $bq = $user_info['mod_cache']['bq']; |
151 | - } |
|
152 | - else |
|
156 | + } else |
|
153 | 157 | { |
154 | 158 | $bq = 'lr.' . $user_info['mod_cache']['bq']; |
155 | 159 | } |
@@ -205,8 +209,7 @@ discard block |
||
205 | 209 | 'max' => 10, |
206 | 210 | ) |
207 | 211 | ); |
208 | - } |
|
209 | - else |
|
212 | + } else |
|
210 | 213 | { |
211 | 214 | $request = $smcFunc['db_query']('', ' |
212 | 215 | SELECT lr.id_report, lr.id_msg, lr.id_topic, lr.id_board, lr.id_member, lr.subject, lr.body, |
@@ -254,8 +257,7 @@ discard block |
||
254 | 257 | 'href' => $scripturl . '?action=profile;u=' . $row['id_user'], |
255 | 258 | ), |
256 | 259 | ); |
257 | - } |
|
258 | - else |
|
260 | + } else |
|
259 | 261 | { |
260 | 262 | $report_boards_ids[] = $row['id_board']; |
261 | 263 | $extraDetails = array( |
@@ -295,14 +297,16 @@ discard block |
||
295 | 297 | ) |
296 | 298 | ); |
297 | 299 | |
298 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
299 | - $board_names[$row['id_board']] = $row['name']; |
|
300 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
301 | + $board_names[$row['id_board']] = $row['name']; |
|
302 | + } |
|
300 | 303 | |
301 | 304 | $smcFunc['db_free_result']($request); |
302 | 305 | |
303 | - foreach ($reports as $id_report => $report) |
|
304 | - if (!empty($board_names[$report['topic']['id_board']])) |
|
306 | + foreach ($reports as $id_report => $report) { |
|
307 | + if (!empty($board_names[$report['topic']['id_board']])) |
|
305 | 308 | $reports[$id_report]['topic']['board_name'] = $board_names[$report['topic']['id_board']]; |
309 | + } |
|
306 | 310 | } |
307 | 311 | |
308 | 312 | // Now get all the people who reported it. |
@@ -352,10 +356,11 @@ discard block |
||
352 | 356 | { |
353 | 357 | global $user_info, $smcFunc; |
354 | 358 | |
355 | - if ($type == 'members') |
|
356 | - $bq = ''; |
|
357 | - else |
|
358 | - $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
359 | + if ($type == 'members') { |
|
360 | + $bq = ''; |
|
361 | + } else { |
|
362 | + $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
363 | + } |
|
359 | 364 | |
360 | 365 | $request = $smcFunc['db_query']('', ' |
361 | 366 | SELECT COUNT(*) |
@@ -394,8 +399,9 @@ discard block |
||
394 | 399 | { |
395 | 400 | global $smcFunc, $user_info, $context; |
396 | 401 | |
397 | - if (empty($report_id)) |
|
398 | - return false; |
|
402 | + if (empty($report_id)) { |
|
403 | + return false; |
|
404 | + } |
|
399 | 405 | |
400 | 406 | // We don't need all this info if we're only getting user info |
401 | 407 | if ($context['report_type'] == 'members') |
@@ -413,8 +419,7 @@ discard block |
||
413 | 419 | 'id_report' => $report_id, |
414 | 420 | ) |
415 | 421 | ); |
416 | - } |
|
417 | - else |
|
422 | + } else |
|
418 | 423 | { |
419 | 424 | // Get the report details, need this so we can limit access to a particular board. |
420 | 425 | $request = $smcFunc['db_query']('', ' |
@@ -433,8 +438,9 @@ discard block |
||
433 | 438 | } |
434 | 439 | |
435 | 440 | // So did we find anything? |
436 | - if (!$smcFunc['db_num_rows']($request)) |
|
437 | - return false; |
|
441 | + if (!$smcFunc['db_num_rows']($request)) { |
|
442 | + return false; |
|
443 | + } |
|
438 | 444 | |
439 | 445 | // Woohoo we found a report and they can see it! |
440 | 446 | $row = $smcFunc['db_fetch_assoc']($request); |
@@ -453,8 +459,9 @@ discard block |
||
453 | 459 | { |
454 | 460 | global $smcFunc, $scripturl, $user_info, $txt; |
455 | 461 | |
456 | - if (empty($report_id)) |
|
457 | - return false; |
|
462 | + if (empty($report_id)) { |
|
463 | + return false; |
|
464 | + } |
|
458 | 465 | |
459 | 466 | $report = array( |
460 | 467 | 'comments' => array(), |
@@ -537,8 +544,9 @@ discard block |
||
537 | 544 | |
538 | 545 | $comment = array(); |
539 | 546 | |
540 | - if (empty($comment_id)) |
|
541 | - return false; |
|
547 | + if (empty($comment_id)) { |
|
548 | + return false; |
|
549 | + } |
|
542 | 550 | |
543 | 551 | $request = $smcFunc['db_query']('', ' |
544 | 552 | SELECT id_comment, id_notice, log_time, body, id_member |
@@ -555,8 +563,9 @@ discard block |
||
555 | 563 | $smcFunc['db_free_result']($request); |
556 | 564 | |
557 | 565 | // Add the permission |
558 | - if (!empty($comment)) |
|
559 | - $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
566 | + if (!empty($comment)) { |
|
567 | + $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
568 | + } |
|
560 | 569 | |
561 | 570 | return $comment; |
562 | 571 | } |
@@ -572,8 +581,9 @@ discard block |
||
572 | 581 | { |
573 | 582 | global $smcFunc, $user_info, $context; |
574 | 583 | |
575 | - if (empty($data)) |
|
576 | - return false; |
|
584 | + if (empty($data)) { |
|
585 | + return false; |
|
586 | + } |
|
577 | 587 | |
578 | 588 | $data = array_merge(array($user_info['id'], $user_info['name'], 'reportc', ''), $data); |
579 | 589 | |
@@ -602,8 +612,7 @@ discard block |
||
602 | 612 | 'comment_id' => $last_comment, |
603 | 613 | 'time' => time(), |
604 | 614 | ); |
605 | - } |
|
606 | - else |
|
615 | + } else |
|
607 | 616 | { |
608 | 617 | $prefix = 'Msg'; |
609 | 618 | $data = array( |
@@ -619,14 +628,15 @@ discard block |
||
619 | 628 | } |
620 | 629 | |
621 | 630 | // And get ready to notify people. |
622 | - if (!empty($report)) |
|
623 | - $smcFunc['db_insert']('insert', |
|
631 | + if (!empty($report)) { |
|
632 | + $smcFunc['db_insert']('insert', |
|
624 | 633 | '{db_prefix}background_tasks', |
625 | 634 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
626 | 635 | array('$sourcedir/tasks/' . $prefix . 'ReportReply-Notify.php', $prefix . 'ReportReply_Notify_Background', json_encode($data), 0), |
627 | 636 | array('id_task') |
628 | 637 | ); |
629 | -} |
|
638 | + } |
|
639 | + } |
|
630 | 640 | |
631 | 641 | /** |
632 | 642 | * Saves the new information whenever a moderator comment is edited. |
@@ -639,8 +649,9 @@ discard block |
||
639 | 649 | { |
640 | 650 | global $smcFunc; |
641 | 651 | |
642 | - if (empty($comment_id) || empty($edited_comment)) |
|
643 | - return false; |
|
652 | + if (empty($comment_id) || empty($edited_comment)) { |
|
653 | + return false; |
|
654 | + } |
|
644 | 655 | |
645 | 656 | $smcFunc['db_query']('', ' |
646 | 657 | UPDATE {db_prefix}log_comments |
@@ -663,8 +674,9 @@ discard block |
||
663 | 674 | { |
664 | 675 | global $smcFunc; |
665 | 676 | |
666 | - if (empty($comment_id)) |
|
667 | - return false; |
|
677 | + if (empty($comment_id)) { |
|
678 | + return false; |
|
679 | + } |
|
668 | 680 | |
669 | 681 | $smcFunc['db_query']('', ' |
670 | 682 | DELETE FROM {db_prefix}log_comments |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Converts the given UTF-8 string into lowercase. |
@@ -569,8 +570,8 @@ discard block |
||
569 | 570 | ); |
570 | 571 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
571 | 572 | { |
572 | - if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
573 | - $smcFunc['db_query']('', ' |
|
573 | + if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
574 | + $smcFunc['db_query']('', ' |
|
574 | 575 | UPDATE {db_prefix}log_actions |
575 | 576 | SET extra = {string:extra} |
576 | 577 | WHERE id_action = {int:current_action}', |
@@ -579,6 +580,7 @@ discard block |
||
579 | 580 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
580 | 581 | ) |
581 | 582 | ); |
583 | + } |
|
582 | 584 | } |
583 | 585 | $smcFunc['db_free_result']($request); |
584 | 586 |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | |
30 | 31 | $supported = function_exists('apc_fetch') && function_exists('apc_store'); |
31 | 32 | |
32 | - if ($test) |
|
33 | - return $supported; |
|
33 | + if ($test) { |
|
34 | + return $supported; |
|
35 | + } |
|
34 | 36 | return parent::isSupported() && $supported; |
35 | 37 | } |
36 | 38 | |
@@ -52,10 +54,11 @@ discard block |
||
52 | 54 | $key = $this->prefix . strtr($key, ':/', '-_'); |
53 | 55 | |
54 | 56 | // An extended key is needed to counteract a bug in APC. |
55 | - if ($value === null) |
|
56 | - return apc_delete($key . 'smf'); |
|
57 | - else |
|
58 | - return apc_store($key . 'smf', $value, $ttl); |
|
57 | + if ($value === null) { |
|
58 | + return apc_delete($key . 'smf'); |
|
59 | + } else { |
|
60 | + return apc_store($key . 'smf', $value, $ttl); |
|
61 | + } |
|
59 | 62 | } |
60 | 63 | |
61 | 64 | /** |
@@ -69,9 +72,9 @@ discard block |
||
69 | 72 | // Always returns true. |
70 | 73 | apc_clear_cache('user'); |
71 | 74 | apc_clear_cache('system'); |
75 | + } elseif ($type === 'user') { |
|
76 | + apc_clear_cache('user'); |
|
72 | 77 | } |
73 | - elseif ($type === 'user') |
|
74 | - apc_clear_cache('user'); |
|
75 | 78 | |
76 | 79 | $this->invalidateCache(); |
77 | 80 | return true; |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | |
30 | 31 | $supported = function_exists('apcu_fetch') && function_exists('apcu_store'); |
31 | 32 | |
32 | - if ($test) |
|
33 | - return $supported; |
|
33 | + if ($test) { |
|
34 | + return $supported; |
|
35 | + } |
|
34 | 36 | return parent::isSupported() && $supported; |
35 | 37 | } |
36 | 38 | |
@@ -52,10 +54,11 @@ discard block |
||
52 | 54 | $key = $this->prefix . strtr($key, ':/', '-_'); |
53 | 55 | |
54 | 56 | // An extended key is needed to counteract a bug in APC. |
55 | - if ($value === null) |
|
56 | - return apcu_delete($key . 'smf'); |
|
57 | - else |
|
58 | - return apcu_store($key . 'smf', $value, $ttl); |
|
57 | + if ($value === null) { |
|
58 | + return apcu_delete($key . 'smf'); |
|
59 | + } else { |
|
60 | + return apcu_store($key . 'smf', $value, $ttl); |
|
61 | + } |
|
59 | 62 | } |
60 | 63 | |
61 | 64 | /** |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | $supported = class_exists('memcached'); |
36 | 37 | |
37 | - if ($test) |
|
38 | - return $supported; |
|
38 | + if ($test) { |
|
39 | + return $supported; |
|
40 | + } |
|
39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
40 | 42 | } |
41 | 43 | |
@@ -54,9 +56,9 @@ discard block |
||
54 | 56 | $currentServers = $this->memcached->getServerList(); |
55 | 57 | foreach ($servers as $server) |
56 | 58 | { |
57 | - if (strpos($server,'/') !== false) |
|
58 | - $tempServer = array($server, 0); |
|
59 | - else |
|
59 | + if (strpos($server,'/') !== false) { |
|
60 | + $tempServer = array($server, 0); |
|
61 | + } else |
|
60 | 62 | { |
61 | 63 | $server = explode(':', $server); |
62 | 64 | $tempServer = array($server[0], isset($server[1]) ? $server[1] : 11211); |
@@ -74,8 +76,9 @@ discard block |
||
74 | 76 | } |
75 | 77 | |
76 | 78 | // Found it? |
77 | - if (empty($foundServer)) |
|
78 | - $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
79 | + if (empty($foundServer)) { |
|
80 | + $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
81 | + } |
|
79 | 82 | } |
80 | 83 | |
81 | 84 | // Best guess is this worked. |
@@ -92,8 +95,9 @@ discard block |
||
92 | 95 | $value = $this->memcached->get($key); |
93 | 96 | |
94 | 97 | // $value should return either data or false (from failure, key not found or empty array). |
95 | - if ($value === false) |
|
96 | - return null; |
|
98 | + if ($value === false) { |
|
99 | + return null; |
|
100 | + } |
|
97 | 101 | return $value; |
98 | 102 | } |
99 | 103 | |
@@ -136,8 +140,9 @@ discard block |
||
136 | 140 | $config_vars[] = $txt['cache_memcache_settings']; |
137 | 141 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
138 | 142 | |
139 | - if (!isset($context['settings_post_javascript'])) |
|
140 | - $context['settings_post_javascript'] = ''; |
|
143 | + if (!isset($context['settings_post_javascript'])) { |
|
144 | + $context['settings_post_javascript'] = ''; |
|
145 | + } |
|
141 | 146 | |
142 | 147 | $context['settings_post_javascript'] .= ' |
143 | 148 | $("#cache_accelerator").change(function (e) { |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | // This won't be dedicated without this - this must exist in each gateway! |
15 | 15 | // SMF Payment Gateway: paypal |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Class for returning available form data for this gateway |
@@ -118,8 +119,7 @@ discard block |
||
118 | 119 | { |
119 | 120 | $return_data['hidden']['p3'] = 1; |
120 | 121 | $return_data['hidden']['t3'] = strtoupper(substr($period, 0, 1)); |
121 | - } |
|
122 | - else |
|
122 | + } else |
|
123 | 123 | { |
124 | 124 | preg_match('~(\d*)(\w)~', $sub_data['real_length'], $match); |
125 | 125 | $unit = $match[1]; |
@@ -130,14 +130,15 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | // If it's repeatable do some javascript to respect this idea. |
133 | - if (!empty($sub_data['repeatable'])) |
|
134 | - $return_data['javascript'] = ' |
|
133 | + if (!empty($sub_data['repeatable'])) { |
|
134 | + $return_data['javascript'] = ' |
|
135 | 135 | document.write(\'<label for="do_paypal_recur"><input type="checkbox" name="do_paypal_recur" id="do_paypal_recur" checked onclick="switchPaypalRecur();" class="input_check">' . $txt['paid_make_recurring'] . '</label><br>\'); |
136 | 136 | |
137 | 137 | function switchPaypalRecur() |
138 | 138 | { |
139 | 139 | document.getElementById("paypal_cmd").value = document.getElementById("do_paypal_recur").checked ? "_xclick-subscriptions" : "_xclick"; |
140 | 140 | }'; |
141 | + } |
|
141 | 142 | |
142 | 143 | return $return_data; |
143 | 144 | } |
@@ -160,20 +161,24 @@ discard block |
||
160 | 161 | global $modSettings; |
161 | 162 | |
162 | 163 | // Has the user set up an email address? |
163 | - if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) |
|
164 | - return false; |
|
164 | + if ((empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_email'])) || (!empty($modSettings['paidsubs_test']) && empty($modSettings['paypal_sandbox_email']))) { |
|
165 | + return false; |
|
166 | + } |
|
165 | 167 | // Check the correct transaction types are even here. |
166 | - if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) |
|
167 | - return false; |
|
168 | + if ((!isset($_POST['txn_type']) && !isset($_POST['payment_status'])) || (!isset($_POST['business']) && !isset($_POST['receiver_email']))) { |
|
169 | + return false; |
|
170 | + } |
|
168 | 171 | // Correct email address? |
169 | - if (!isset($_POST['business'])) |
|
170 | - $_POST['business'] = $_POST['receiver_email']; |
|
172 | + if (!isset($_POST['business'])) { |
|
173 | + $_POST['business'] = $_POST['receiver_email']; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | // Are we testing? |
173 | - if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
174 | - return false; |
|
175 | - elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) |
|
176 | - return false; |
|
177 | + if (empty($modSettings['paidsubs_test']) && strtolower($modSettings['paypal_sandbox_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
178 | + return false; |
|
179 | + } elseif (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', $modSettings['paypal_additional_emails'])))) { |
|
180 | + return false; |
|
181 | + } |
|
177 | 182 | return true; |
178 | 183 | } |
179 | 184 | |
@@ -192,15 +197,17 @@ discard block |
||
192 | 197 | global $modSettings, $txt; |
193 | 198 | |
194 | 199 | // Put this to some default value. |
195 | - if (!isset($_POST['txn_type'])) |
|
196 | - $_POST['txn_type'] = ''; |
|
200 | + if (!isset($_POST['txn_type'])) { |
|
201 | + $_POST['txn_type'] = ''; |
|
202 | + } |
|
197 | 203 | |
198 | 204 | // Build the request string - starting with the minimum requirement. |
199 | 205 | $requestString = 'cmd=_notify-validate'; |
200 | 206 | |
201 | 207 | // Now my dear, add all the posted bits in the order we got them |
202 | - foreach ($_POST as $k => $v) |
|
203 | - $requestString .= '&' . $k . '=' . urlencode($v); |
|
208 | + foreach ($_POST as $k => $v) { |
|
209 | + $requestString .= '&' . $k . '=' . urlencode($v); |
|
210 | + } |
|
204 | 211 | |
205 | 212 | // Can we use curl? |
206 | 213 | if (function_exists('curl_init') && $curl = curl_init((!empty($modSettings['paidsubs_test']) ? 'https://www.sandbox.' : 'http://www.') . 'paypal.com/cgi-bin/webscr')) |
@@ -240,14 +247,16 @@ discard block |
||
240 | 247 | $header .= 'Connection: close' . "\r\n\r\n"; |
241 | 248 | |
242 | 249 | // Open the connection. |
243 | - if (!empty($modSettings['paidsubs_test'])) |
|
244 | - $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
245 | - else |
|
246 | - $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
250 | + if (!empty($modSettings['paidsubs_test'])) { |
|
251 | + $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); |
|
252 | + } else { |
|
253 | + $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); |
|
254 | + } |
|
247 | 255 | |
248 | 256 | // Did it work? |
249 | - if (!$fp) |
|
250 | - generateSubscriptionError($txt['paypal_could_not_connect']); |
|
257 | + if (!$fp) { |
|
258 | + generateSubscriptionError($txt['paypal_could_not_connect']); |
|
259 | + } |
|
251 | 260 | |
252 | 261 | // Put the data to the port. |
253 | 262 | fputs($fp, $header . $requestString); |
@@ -256,8 +265,9 @@ discard block |
||
256 | 265 | while (!feof($fp)) |
257 | 266 | { |
258 | 267 | $this->return_data = fgets($fp, 1024); |
259 | - if (strcmp(trim($this->return_data), 'VERIFIED') === 0) |
|
260 | - break; |
|
268 | + if (strcmp(trim($this->return_data), 'VERIFIED') === 0) { |
|
269 | + break; |
|
270 | + } |
|
261 | 271 | } |
262 | 272 | |
263 | 273 | // Clean up. |
@@ -265,28 +275,34 @@ discard block |
||
265 | 275 | } |
266 | 276 | |
267 | 277 | // If this isn't verified then give up... |
268 | - if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) |
|
269 | - exit; |
|
278 | + if (strcmp(trim($this->return_data), 'VERIFIED') !== 0) { |
|
279 | + exit; |
|
280 | + } |
|
270 | 281 | |
271 | 282 | // Check that this is intended for us. |
272 | - if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) |
|
273 | - exit; |
|
283 | + if (strtolower($modSettings['paypal_email']) != strtolower($_POST['business']) && (empty($modSettings['paypal_additional_emails']) || !in_array(strtolower($_POST['business']), explode(',', strtolower($modSettings['paypal_additional_emails']))))) { |
|
284 | + exit; |
|
285 | + } |
|
274 | 286 | |
275 | 287 | // Is this a subscription - and if so is it a secondary payment that we need to process? |
276 | 288 | // If so, make sure we get it in the expected format. Seems PayPal sometimes sends it without urlencoding. |
277 | - if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) |
|
278 | - $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
279 | - if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) |
|
280 | - // Calculate the subscription it relates to! |
|
289 | + if (!empty($_POST['item_number']) && strpos($_POST['item_number'], ' ') !== false) { |
|
290 | + $_POST['item_number'] = str_replace(' ', '+', $_POST['item_number']); |
|
291 | + } |
|
292 | + if ($this->isSubscription() && (empty($_POST['item_number']) || strpos($_POST['item_number'], '+') === false)) { |
|
293 | + // Calculate the subscription it relates to! |
|
281 | 294 | $this->_findSubscription(); |
295 | + } |
|
282 | 296 | |
283 | 297 | // Verify the currency! |
284 | - if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) |
|
285 | - exit; |
|
298 | + if (strtolower($_POST['mc_currency']) !== strtolower($modSettings['paid_currency_code'])) { |
|
299 | + exit; |
|
300 | + } |
|
286 | 301 | |
287 | 302 | // Can't exist if it doesn't contain anything. |
288 | - if (empty($_POST['item_number'])) |
|
289 | - exit; |
|
303 | + if (empty($_POST['item_number'])) { |
|
304 | + exit; |
|
305 | + } |
|
290 | 306 | |
291 | 307 | // Return the id_sub and id_member |
292 | 308 | return explode('+', $_POST['item_number']); |
@@ -299,10 +315,11 @@ discard block |
||
299 | 315 | */ |
300 | 316 | public function isRefund() |
301 | 317 | { |
302 | - if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) |
|
303 | - return true; |
|
304 | - else |
|
305 | - return false; |
|
318 | + if ($_POST['payment_status'] === 'Refunded' || $_POST['payment_status'] === 'Reversed' || $_POST['txn_type'] === 'Refunded' || ($_POST['txn_type'] === 'reversal' && $_POST['payment_status'] === 'Completed')) { |
|
319 | + return true; |
|
320 | + } else { |
|
321 | + return false; |
|
322 | + } |
|
306 | 323 | } |
307 | 324 | |
308 | 325 | /** |
@@ -312,10 +329,11 @@ discard block |
||
312 | 329 | */ |
313 | 330 | public function isSubscription() |
314 | 331 | { |
315 | - if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') |
|
316 | - return true; |
|
317 | - else |
|
318 | - return false; |
|
332 | + if (substr($_POST['txn_type'], 0, 14) === 'subscr_payment' && $_POST['payment_status'] === 'Completed') { |
|
333 | + return true; |
|
334 | + } else { |
|
335 | + return false; |
|
336 | + } |
|
319 | 337 | } |
320 | 338 | |
321 | 339 | /** |
@@ -325,10 +343,11 @@ discard block |
||
325 | 343 | */ |
326 | 344 | public function isPayment() |
327 | 345 | { |
328 | - if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') |
|
329 | - return true; |
|
330 | - else |
|
331 | - return false; |
|
346 | + if ($_POST['payment_status'] === 'Completed' && $_POST['txn_type'] === 'web_accept') { |
|
347 | + return true; |
|
348 | + } else { |
|
349 | + return false; |
|
350 | + } |
|
332 | 351 | } |
333 | 352 | |
334 | 353 | /** |
@@ -341,10 +360,11 @@ discard block |
||
341 | 360 | // subscr_cancel is sent when the user cancels, subscr_eot is sent when the subscription reaches final payment |
342 | 361 | // Neither require us to *do* anything as per performCancel(). |
343 | 362 | // subscr_eot, if sent, indicates an end of payments term. |
344 | - if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') |
|
345 | - return true; |
|
346 | - else |
|
347 | - return false; |
|
363 | + if (substr($_POST['txn_type'], 0, 13) === 'subscr_cancel' || substr($_POST['txn_type'], 0, 10) === 'subscr_eot') { |
|
364 | + return true; |
|
365 | + } else { |
|
366 | + return false; |
|
367 | + } |
|
348 | 368 | } |
349 | 369 | |
350 | 370 | /** |
@@ -409,8 +429,9 @@ discard block |
||
409 | 429 | global $smcFunc; |
410 | 430 | |
411 | 431 | // Assume we have this? |
412 | - if (empty($_POST['subscr_id'])) |
|
413 | - return false; |
|
432 | + if (empty($_POST['subscr_id'])) { |
|
433 | + return false; |
|
434 | + } |
|
414 | 435 | |
415 | 436 | // Do we have this in the database? |
416 | 437 | $request = $smcFunc['db_query']('', ' |
@@ -439,11 +460,12 @@ discard block |
||
439 | 460 | 'payer_email' => $_POST['payer_email'], |
440 | 461 | ) |
441 | 462 | ); |
442 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
443 | - return false; |
|
463 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
464 | + return false; |
|
465 | + } |
|
466 | + } else { |
|
467 | + return false; |
|
444 | 468 | } |
445 | - else |
|
446 | - return false; |
|
447 | 469 | } |
448 | 470 | list ($member_id, $subscription_id) = $smcFunc['db_fetch_row']($request); |
449 | 471 | $_POST['item_number'] = $member_id . '+' . $subscription_id; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * 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( |
@@ -220,8 +225,9 @@ discard block |
||
220 | 225 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
221 | 226 | ); |
222 | 227 | |
223 | - if ($max_num_posts < $row_members['posts']) |
|
224 | - $max_num_posts = $row_members['posts']; |
|
228 | + if ($max_num_posts < $row_members['posts']) { |
|
229 | + $max_num_posts = $row_members['posts']; |
|
230 | + } |
|
225 | 231 | } |
226 | 232 | $smcFunc['db_free_result']($members_result); |
227 | 233 | |
@@ -257,8 +263,9 @@ discard block |
||
257 | 263 | 'link' => '<a href="' . $scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['name'] . '</a>' |
258 | 264 | ); |
259 | 265 | |
260 | - if ($max_num_posts < $row_board['num_posts']) |
|
261 | - $max_num_posts = $row_board['num_posts']; |
|
266 | + if ($max_num_posts < $row_board['num_posts']) { |
|
267 | + $max_num_posts = $row_board['num_posts']; |
|
268 | + } |
|
262 | 269 | } |
263 | 270 | $smcFunc['db_free_result']($boards_result); |
264 | 271 | |
@@ -284,12 +291,13 @@ discard block |
||
284 | 291 | ) |
285 | 292 | ); |
286 | 293 | $topic_ids = array(); |
287 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
288 | - $topic_ids[] = $row['id_topic']; |
|
294 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
295 | + $topic_ids[] = $row['id_topic']; |
|
296 | + } |
|
289 | 297 | $smcFunc['db_free_result']($request); |
298 | + } else { |
|
299 | + $topic_ids = array(); |
|
290 | 300 | } |
291 | - else |
|
292 | - $topic_ids = array(); |
|
293 | 301 | |
294 | 302 | // Topic replies top 10. |
295 | 303 | $topic_reply_result = $smcFunc['db_query']('', ' |
@@ -329,8 +337,9 @@ discard block |
||
329 | 337 | 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_reply['id_topic'] . '.0">' . $row_topic_reply['subject'] . '</a>' |
330 | 338 | ); |
331 | 339 | |
332 | - if ($max_num_replies < $row_topic_reply['num_replies']) |
|
333 | - $max_num_replies = $row_topic_reply['num_replies']; |
|
340 | + if ($max_num_replies < $row_topic_reply['num_replies']) { |
|
341 | + $max_num_replies = $row_topic_reply['num_replies']; |
|
342 | + } |
|
334 | 343 | } |
335 | 344 | $smcFunc['db_free_result']($topic_reply_result); |
336 | 345 | |
@@ -354,12 +363,13 @@ discard block |
||
354 | 363 | ) |
355 | 364 | ); |
356 | 365 | $topic_ids = array(); |
357 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
358 | - $topic_ids[] = $row['id_topic']; |
|
366 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
367 | + $topic_ids[] = $row['id_topic']; |
|
368 | + } |
|
359 | 369 | $smcFunc['db_free_result']($request); |
370 | + } else { |
|
371 | + $topic_ids = array(); |
|
360 | 372 | } |
361 | - else |
|
362 | - $topic_ids = array(); |
|
363 | 373 | |
364 | 374 | // Topic views top 10. |
365 | 375 | $topic_view_result = $smcFunc['db_query']('', ' |
@@ -399,8 +409,9 @@ discard block |
||
399 | 409 | 'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . $row_topic_views['subject'] . '</a>' |
400 | 410 | ); |
401 | 411 | |
402 | - if ($max_num < $row_topic_views['num_views']) |
|
403 | - $max_num = $row_topic_views['num_views']; |
|
412 | + if ($max_num < $row_topic_views['num_views']) { |
|
413 | + $max_num = $row_topic_views['num_views']; |
|
414 | + } |
|
404 | 415 | } |
405 | 416 | $smcFunc['db_free_result']($topic_view_result); |
406 | 417 | |
@@ -425,15 +436,17 @@ discard block |
||
425 | 436 | ) |
426 | 437 | ); |
427 | 438 | $members = array(); |
428 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
429 | - $members[$row['id_member_started']] = $row['hits']; |
|
439 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
440 | + $members[$row['id_member_started']] = $row['hits']; |
|
441 | + } |
|
430 | 442 | $smcFunc['db_free_result']($request); |
431 | 443 | |
432 | 444 | cache_put_data('stats_top_starters', $members, 360); |
433 | 445 | } |
434 | 446 | |
435 | - if (empty($members)) |
|
436 | - $members = array(0 => 0); |
|
447 | + if (empty($members)) { |
|
448 | + $members = array(0 => 0); |
|
449 | + } |
|
437 | 450 | |
438 | 451 | // Topic poster top 10. |
439 | 452 | $members_result = $smcFunc['db_query']('', ' |
@@ -458,8 +471,9 @@ discard block |
||
458 | 471 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
459 | 472 | ); |
460 | 473 | |
461 | - if ($max_num < $members[$row_members['id_member']]) |
|
462 | - $max_num = $members[$row_members['id_member']]; |
|
474 | + if ($max_num < $members[$row_members['id_member']]) { |
|
475 | + $max_num = $members[$row_members['id_member']]; |
|
476 | + } |
|
463 | 477 | } |
464 | 478 | ksort($context['stats_blocks']['starters']); |
465 | 479 | $smcFunc['db_free_result']($members_result); |
@@ -488,8 +502,9 @@ discard block |
||
488 | 502 | while ($row_members = $smcFunc['db_fetch_assoc']($members_result)) |
489 | 503 | { |
490 | 504 | $temp2[] = (int) $row_members['id_member']; |
491 | - if (count($context['stats_blocks']['time_online']) >= 10) |
|
492 | - continue; |
|
505 | + if (count($context['stats_blocks']['time_online']) >= 10) { |
|
506 | + continue; |
|
507 | + } |
|
493 | 508 | |
494 | 509 | // Figure out the days, hours and minutes. |
495 | 510 | $timeDays = floor($row_members['total_time_logged_in'] / 86400); |
@@ -497,10 +512,12 @@ discard block |
||
497 | 512 | |
498 | 513 | // Figure out which things to show... (days, hours, minutes, etc.) |
499 | 514 | $timelogged = ''; |
500 | - if ($timeDays > 0) |
|
501 | - $timelogged .= $timeDays . $txt['totalTimeLogged5']; |
|
502 | - if ($timeHours > 0) |
|
503 | - $timelogged .= $timeHours . $txt['totalTimeLogged6']; |
|
515 | + if ($timeDays > 0) { |
|
516 | + $timelogged .= $timeDays . $txt['totalTimeLogged5']; |
|
517 | + } |
|
518 | + if ($timeHours > 0) { |
|
519 | + $timelogged .= $timeHours . $txt['totalTimeLogged6']; |
|
520 | + } |
|
504 | 521 | $timelogged .= floor(($row_members['total_time_logged_in'] % 3600) / 60) . $txt['totalTimeLogged7']; |
505 | 522 | |
506 | 523 | $context['stats_blocks']['time_online'][] = array( |
@@ -512,17 +529,20 @@ discard block |
||
512 | 529 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>' |
513 | 530 | ); |
514 | 531 | |
515 | - if ($max_time_online < $row_members['total_time_logged_in']) |
|
516 | - $max_time_online = $row_members['total_time_logged_in']; |
|
532 | + if ($max_time_online < $row_members['total_time_logged_in']) { |
|
533 | + $max_time_online = $row_members['total_time_logged_in']; |
|
534 | + } |
|
517 | 535 | } |
518 | 536 | $smcFunc['db_free_result']($members_result); |
519 | 537 | |
520 | - foreach ($context['stats_blocks']['time_online'] as $i => $member) |
|
521 | - $context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online); |
|
538 | + foreach ($context['stats_blocks']['time_online'] as $i => $member) { |
|
539 | + $context['stats_blocks']['time_online'][$i]['percent'] = round(($member['seconds_online'] * 100) / $max_time_online); |
|
540 | + } |
|
522 | 541 | |
523 | 542 | // Cache the ones we found for a bit, just so we don't have to look again. |
524 | - if ($temp !== $temp2) |
|
525 | - cache_put_data('stats_total_time_members', $temp2, 480); |
|
543 | + if ($temp !== $temp2) { |
|
544 | + cache_put_data('stats_total_time_members', $temp2, 480); |
|
545 | + } |
|
526 | 546 | |
527 | 547 | // Likes. |
528 | 548 | if (!empty($modSettings['enable_likes'])) |
@@ -558,13 +578,15 @@ discard block |
||
558 | 578 | 'link' => '<a href="' . $scripturl . '?msg=' . $row_liked_message['id_msg'] .'">' . $row_liked_message['subject'] . '</a>' |
559 | 579 | ); |
560 | 580 | |
561 | - if ($max_liked_message < $row_liked_message['likes']) |
|
562 | - $max_liked_message = $row_liked_message['likes']; |
|
581 | + if ($max_liked_message < $row_liked_message['likes']) { |
|
582 | + $max_liked_message = $row_liked_message['likes']; |
|
583 | + } |
|
563 | 584 | } |
564 | 585 | $smcFunc['db_free_result']($liked_messages); |
565 | 586 | |
566 | - foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) |
|
567 | - $context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message); |
|
587 | + foreach ($context['stats_blocks']['liked_messages'] as $i => $liked_messages) { |
|
588 | + $context['stats_blocks']['liked_messages'][$i]['percent'] = round(($liked_messages['num'] * 100) / $max_liked_message); |
|
589 | + } |
|
568 | 590 | |
569 | 591 | // Liked users top 10. |
570 | 592 | $context['stats_blocks']['liked_users'] = array(); |
@@ -595,14 +617,16 @@ discard block |
||
595 | 617 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_liked_users['liked_user'] . '">' . $row_liked_users['real_name'] . '</a>', |
596 | 618 | ); |
597 | 619 | |
598 | - if ($max_liked_users < $row_liked_users['count']) |
|
599 | - $max_liked_users = $row_liked_users['count']; |
|
620 | + if ($max_liked_users < $row_liked_users['count']) { |
|
621 | + $max_liked_users = $row_liked_users['count']; |
|
622 | + } |
|
600 | 623 | } |
601 | 624 | |
602 | 625 | $smcFunc['db_free_result']($liked_users); |
603 | 626 | |
604 | - foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) |
|
605 | - $context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users); |
|
627 | + foreach ($context['stats_blocks']['liked_users'] as $i => $liked_users) { |
|
628 | + $context['stats_blocks']['liked_users'][$i]['percent'] = round(($liked_users['num'] * 100) / $max_liked_users); |
|
629 | + } |
|
606 | 630 | } |
607 | 631 | |
608 | 632 | // Activity by month. |
@@ -620,8 +644,8 @@ discard block |
||
620 | 644 | $ID_MONTH = $row_months['stats_year'] . sprintf('%02d', $row_months['stats_month']); |
621 | 645 | $expanded = !empty($_SESSION['expanded_stats'][$row_months['stats_year']]) && in_array($row_months['stats_month'], $_SESSION['expanded_stats'][$row_months['stats_year']]); |
622 | 646 | |
623 | - if (!isset($context['yearly'][$row_months['stats_year']])) |
|
624 | - $context['yearly'][$row_months['stats_year']] = array( |
|
647 | + if (!isset($context['yearly'][$row_months['stats_year']])) { |
|
648 | + $context['yearly'][$row_months['stats_year']] = array( |
|
625 | 649 | 'year' => $row_months['stats_year'], |
626 | 650 | 'new_topics' => 0, |
627 | 651 | 'new_posts' => 0, |
@@ -633,6 +657,7 @@ discard block |
||
633 | 657 | 'expanded' => false, |
634 | 658 | 'current_year' => $row_months['stats_year'] == date('Y'), |
635 | 659 | ); |
660 | + } |
|
636 | 661 | |
637 | 662 | $context['yearly'][$row_months['stats_year']]['months'][(int) $row_months['stats_month']] = array( |
638 | 663 | 'id' => $ID_MONTH, |
@@ -678,26 +703,30 @@ discard block |
||
678 | 703 | $context['yearly'][$year]['hits'] = comma_format($data['hits']); |
679 | 704 | |
680 | 705 | // Keep a list of collapsed years. |
681 | - if (!$data['expanded'] && !$data['current_year']) |
|
682 | - $context['collapsed_years'][] = $year; |
|
706 | + if (!$data['expanded'] && !$data['current_year']) { |
|
707 | + $context['collapsed_years'][] = $year; |
|
708 | + } |
|
683 | 709 | } |
684 | 710 | |
685 | - if (empty($_SESSION['expanded_stats'])) |
|
686 | - return; |
|
711 | + if (empty($_SESSION['expanded_stats'])) { |
|
712 | + return; |
|
713 | + } |
|
687 | 714 | |
688 | 715 | $condition_text = array(); |
689 | 716 | $condition_params = array(); |
690 | - foreach ($_SESSION['expanded_stats'] as $year => $months) |
|
691 | - if (!empty($months)) |
|
717 | + foreach ($_SESSION['expanded_stats'] as $year => $months) { |
|
718 | + if (!empty($months)) |
|
692 | 719 | { |
693 | 720 | $condition_text[] = 'YEAR(date) = {int:year_' . $year . '} AND MONTH(date) IN ({array_int:months_' . $year . '})'; |
721 | + } |
|
694 | 722 | $condition_params['year_' . $year] = $year; |
695 | 723 | $condition_params['months_' . $year] = $months; |
696 | 724 | } |
697 | 725 | |
698 | 726 | // No daily stats to even look at? |
699 | - if (empty($condition_text)) |
|
700 | - return; |
|
727 | + if (empty($condition_text)) { |
|
728 | + return; |
|
729 | + } |
|
701 | 730 | |
702 | 731 | getDailyStats(implode(' OR ', $condition_text), $condition_params); |
703 | 732 | |
@@ -723,8 +752,8 @@ discard block |
||
723 | 752 | ORDER BY stats_day ASC', |
724 | 753 | $condition_parameters |
725 | 754 | ); |
726 | - while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) |
|
727 | - $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array( |
|
755 | + while ($row_days = $smcFunc['db_fetch_assoc']($days_result)) { |
|
756 | + $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array( |
|
728 | 757 | 'day' => sprintf('%02d', $row_days['stats_day']), |
729 | 758 | 'month' => sprintf('%02d', $row_days['stats_month']), |
730 | 759 | 'year' => $row_days['stats_year'], |
@@ -734,6 +763,7 @@ discard block |
||
734 | 763 | 'most_members_online' => comma_format($row_days['most_on']), |
735 | 764 | 'hits' => comma_format($row_days['hits']) |
736 | 765 | ); |
766 | + } |
|
737 | 767 | $smcFunc['db_free_result']($days_result); |
738 | 768 | } |
739 | 769 | |
@@ -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['allow_sm_stats'])) |
|
756 | - die(); |
|
785 | + if (empty($modSettings['allow_sm_stats'])) { |
|
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['allow_sm_stats'])) |
|
760 | - die(); |
|
790 | + if (!$user_info['is_admin'] && (!isset($_GET['sid']) || $_GET['sid'] != $modSettings['allow_sm_stats'])) { |
|
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); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * View the forum's error log. |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc; |
31 | 32 | |
32 | 33 | // Viewing contents of a file? |
33 | - if (isset($_GET['file'])) |
|
34 | - return ViewFile(); |
|
34 | + if (isset($_GET['file'])) { |
|
35 | + return ViewFile(); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Check for the administrative permission to do this. |
37 | 39 | isAllowedTo('admin_forum'); |
@@ -85,8 +87,8 @@ discard block |
||
85 | 87 | ); |
86 | 88 | |
87 | 89 | // Set up the filtering... |
88 | - if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) |
|
89 | - $filter = array( |
|
90 | + if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { |
|
91 | + $filter = array( |
|
90 | 92 | 'variable' => $_GET['filter'], |
91 | 93 | 'value' => array( |
92 | 94 | 'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']), |
@@ -94,10 +96,12 @@ discard block |
||
94 | 96 | 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], |
95 | 97 | 'entity' => $filters[$_GET['filter']]['txt'] |
96 | 98 | ); |
99 | + } |
|
97 | 100 | |
98 | 101 | // Deleting, are we? |
99 | - if (isset($_POST['delall']) || isset($_POST['delete'])) |
|
100 | - deleteErrors(); |
|
102 | + if (isset($_POST['delall']) || isset($_POST['delete'])) { |
|
103 | + deleteErrors(); |
|
104 | + } |
|
101 | 105 | |
102 | 106 | // Just how many errors are there? |
103 | 107 | $result = $smcFunc['db_query']('', ' |
@@ -112,12 +116,14 @@ discard block |
||
112 | 116 | $smcFunc['db_free_result']($result); |
113 | 117 | |
114 | 118 | // If this filter is empty... |
115 | - if ($num_errors == 0 && isset($filter)) |
|
116 | - redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
119 | + if ($num_errors == 0 && isset($filter)) { |
|
120 | + redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
121 | + } |
|
117 | 122 | |
118 | 123 | // Clean up start. |
119 | - if (!isset($_GET['start']) || $_GET['start'] < 0) |
|
120 | - $_GET['start'] = 0; |
|
124 | + if (!isset($_GET['start']) || $_GET['start'] < 0) { |
|
125 | + $_GET['start'] = 0; |
|
126 | + } |
|
121 | 127 | |
122 | 128 | // Do we want to reverse error listing? |
123 | 129 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
@@ -127,9 +133,9 @@ discard block |
||
127 | 133 | $context['start'] = $_GET['start']; |
128 | 134 | |
129 | 135 | // Update the error count |
130 | - if (!isset($filter)) |
|
131 | - $context['num_errors'] = $num_errors; |
|
132 | - else |
|
136 | + if (!isset($filter)) { |
|
137 | + $context['num_errors'] = $num_errors; |
|
138 | + } else |
|
133 | 139 | { |
134 | 140 | // We want all errors, not just the number of filtered messages... |
135 | 141 | $query = $smcFunc['db_query']('', ' |
@@ -161,8 +167,9 @@ discard block |
||
161 | 167 | for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++) |
162 | 168 | { |
163 | 169 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
164 | - if ($search_message == $filter['value']['sql']) |
|
165 | - $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
170 | + if ($search_message == $filter['value']['sql']) { |
|
171 | + $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
172 | + } |
|
166 | 173 | $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br>')); |
167 | 174 | |
168 | 175 | $context['errors'][$row['id_error']] = array( |
@@ -221,8 +228,9 @@ discard block |
||
221 | 228 | 'members' => count($members), |
222 | 229 | ) |
223 | 230 | ); |
224 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
225 | - $members[$row['id_member']] = $row; |
|
231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
232 | + $members[$row['id_member']] = $row; |
|
233 | + } |
|
226 | 234 | $smcFunc['db_free_result']($request); |
227 | 235 | |
228 | 236 | // This is a guest... |
@@ -254,20 +262,18 @@ discard block |
||
254 | 262 | $id = $filter['value']['sql']; |
255 | 263 | loadMemberData($id, false, 'minimal'); |
256 | 264 | $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; |
257 | - } |
|
258 | - elseif ($filter['variable'] == 'url') |
|
259 | - $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
260 | - elseif ($filter['variable'] == 'message') |
|
265 | + } elseif ($filter['variable'] == 'url') { |
|
266 | + $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
267 | + } elseif ($filter['variable'] == 'message') |
|
261 | 268 | { |
262 | 269 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
263 | 270 | $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); |
264 | - } |
|
265 | - elseif ($filter['variable'] == 'error_type') |
|
271 | + } elseif ($filter['variable'] == 'error_type') |
|
266 | 272 | { |
267 | 273 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
274 | + } else { |
|
275 | + $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
268 | 276 | } |
269 | - else |
|
270 | - $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
271 | 277 | } |
272 | 278 | |
273 | 279 | $context['error_types'] = array(); |
@@ -308,10 +314,11 @@ discard block |
||
308 | 314 | $context['error_types']['all']['label'] .= ' (' . $sum . ')'; |
309 | 315 | |
310 | 316 | // Finally, work out what is the last tab! |
311 | - if (isset($context['error_types'][$sum])) |
|
312 | - $context['error_types'][$sum]['is_last'] = true; |
|
313 | - else |
|
314 | - $context['error_types']['all']['is_last'] = true; |
|
317 | + if (isset($context['error_types'][$sum])) { |
|
318 | + $context['error_types'][$sum]['is_last'] = true; |
|
319 | + } else { |
|
320 | + $context['error_types']['all']['is_last'] = true; |
|
321 | + } |
|
315 | 322 | |
316 | 323 | // And this is pretty basic ;). |
317 | 324 | $context['page_title'] = $txt['errlog']; |
@@ -337,21 +344,23 @@ discard block |
||
337 | 344 | validateToken('admin-el'); |
338 | 345 | |
339 | 346 | // Delete all or just some? |
340 | - if (isset($_POST['delall']) && !isset($filter)) |
|
341 | - $smcFunc['db_query']('truncate_table', ' |
|
347 | + if (isset($_POST['delall']) && !isset($filter)) { |
|
348 | + $smcFunc['db_query']('truncate_table', ' |
|
342 | 349 | TRUNCATE {db_prefix}log_errors', |
343 | 350 | array( |
344 | 351 | ) |
345 | 352 | ); |
353 | + } |
|
346 | 354 | // Deleting all with a filter? |
347 | - elseif (isset($_POST['delall']) && isset($filter)) |
|
348 | - $smcFunc['db_query']('', ' |
|
355 | + elseif (isset($_POST['delall']) && isset($filter)) { |
|
356 | + $smcFunc['db_query']('', ' |
|
349 | 357 | DELETE FROM {db_prefix}log_errors |
350 | 358 | WHERE ' . $filter['variable'] . ' LIKE {string:filter}', |
351 | 359 | array( |
352 | 360 | 'filter' => $filter['value']['sql'], |
353 | 361 | ) |
354 | 362 | ); |
363 | + } |
|
355 | 364 | // Just specific errors? |
356 | 365 | elseif (!empty($_POST['delete'])) |
357 | 366 | { |
@@ -397,15 +406,17 @@ discard block |
||
397 | 406 | $line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0; |
398 | 407 | |
399 | 408 | // Make sure the file we are looking for is one they are allowed to look at |
400 | - if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) |
|
401 | - fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
409 | + if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) { |
|
410 | + fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
411 | + } |
|
402 | 412 | |
403 | 413 | // get the min and max lines |
404 | 414 | $min = $line - 20 <= 0 ? 1 : $line - 20; |
405 | 415 | $max = $line + 21; // One additional line to make everything work out correctly |
406 | 416 | |
407 | - if ($max <= 0 || $min >= $max) |
|
408 | - fatal_lang_error('error_bad_line'); |
|
417 | + if ($max <= 0 || $min >= $max) { |
|
418 | + fatal_lang_error('error_bad_line'); |
|
419 | + } |
|
409 | 420 | |
410 | 421 | $file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file))))); |
411 | 422 |