@@ -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 | * The main 'Attachments and Avatars' management function. |
@@ -63,10 +64,11 @@ discard block |
||
63 | 64 | call_integration_hook('integrate_manage_attachments', array(&$subActions)); |
64 | 65 | |
65 | 66 | // Pick the correct sub-action. |
66 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
67 | - $context['sub_action'] = $_REQUEST['sa']; |
|
68 | - else |
|
69 | - $context['sub_action'] = 'browse'; |
|
67 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
68 | + $context['sub_action'] = $_REQUEST['sa']; |
|
69 | + } else { |
|
70 | + $context['sub_action'] = 'browse'; |
|
71 | + } |
|
70 | 72 | |
71 | 73 | // Default page title is good. |
72 | 74 | $context['page_title'] = $txt['attachments_avatars']; |
@@ -94,20 +96,20 @@ discard block |
||
94 | 96 | $context['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
95 | 97 | |
96 | 98 | // If not set, show a default path for the base directory |
97 | - if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) |
|
98 | - if (is_dir($modSettings['attachmentUploadDir'][1])) |
|
99 | + if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) { |
|
100 | + if (is_dir($modSettings['attachmentUploadDir'][1])) |
|
99 | 101 | $modSettings['basedirectory_for_attachments'] = $modSettings['attachmentUploadDir'][1]; |
100 | - |
|
101 | - else |
|
102 | - $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
102 | + } else { |
|
103 | + $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | $context['valid_upload_dir'] = is_dir($context['attachmentUploadDir']) && is_writable($context['attachmentUploadDir']); |
105 | 107 | |
106 | - if (!empty($modSettings['automanage_attachments'])) |
|
107 | - $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
108 | - |
|
109 | - else |
|
110 | - $context['valid_basedirectory'] = true; |
|
108 | + if (!empty($modSettings['automanage_attachments'])) { |
|
109 | + $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
110 | + } else { |
|
111 | + $context['valid_basedirectory'] = true; |
|
112 | + } |
|
111 | 113 | |
112 | 114 | // A bit of razzle dazzle with the $txt strings. :) |
113 | 115 | $txt['attachment_path'] = $context['attachmentUploadDir']; |
@@ -185,8 +187,9 @@ discard block |
||
185 | 187 | |
186 | 188 | call_integration_hook('integrate_modify_attachment_settings', array(&$config_vars)); |
187 | 189 | |
188 | - if ($return_config) |
|
189 | - return $config_vars; |
|
190 | + if ($return_config) { |
|
191 | + return $config_vars; |
|
192 | + } |
|
190 | 193 | |
191 | 194 | // These are very likely to come in handy! (i.e. without them we're doomed!) |
192 | 195 | require_once($sourcedir . '/ManagePermissions.php'); |
@@ -197,21 +200,24 @@ discard block |
||
197 | 200 | { |
198 | 201 | checkSession(); |
199 | 202 | |
200 | - if (isset($_POST['attachmentUploadDir'])) |
|
201 | - unset($_POST['attachmentUploadDir']); |
|
203 | + if (isset($_POST['attachmentUploadDir'])) { |
|
204 | + unset($_POST['attachmentUploadDir']); |
|
205 | + } |
|
202 | 206 | |
203 | 207 | if (!empty($_POST['use_subdirectories_for_attachments'])) |
204 | 208 | { |
205 | - if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) |
|
206 | - $_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
|
209 | + if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) { |
|
210 | + $_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
|
211 | + } |
|
207 | 212 | |
208 | 213 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($modSettings['attachment_basedirectories'])) |
209 | 214 | { |
210 | - if (!is_array($modSettings['attachment_basedirectories'])) |
|
211 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
215 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
216 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
217 | + } |
|
218 | + } else { |
|
219 | + $modSettings['attachment_basedirectories'] = array(); |
|
212 | 220 | } |
213 | - else |
|
214 | - $modSettings['attachment_basedirectories'] = array(); |
|
215 | 221 | |
216 | 222 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($_POST['basedirectory_for_attachments']) && !in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
217 | 223 | { |
@@ -219,8 +225,9 @@ discard block |
||
219 | 225 | |
220 | 226 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachmentUploadDir'])) |
221 | 227 | { |
222 | - if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) |
|
223 | - $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
228 | + if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) { |
|
229 | + $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
230 | + } |
|
224 | 231 | } |
225 | 232 | |
226 | 233 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
@@ -336,8 +343,9 @@ discard block |
||
336 | 343 | |
337 | 344 | call_integration_hook('integrate_modify_avatar_settings', array(&$config_vars)); |
338 | 345 | |
339 | - if ($return_config) |
|
340 | - return $config_vars; |
|
346 | + if ($return_config) { |
|
347 | + return $config_vars; |
|
348 | + } |
|
341 | 349 | |
342 | 350 | // We need this file for the settings template. |
343 | 351 | require_once($sourcedir . '/ManageServer.php'); |
@@ -348,17 +356,21 @@ discard block |
||
348 | 356 | checkSession(); |
349 | 357 | |
350 | 358 | // These settings cannot be left empty! |
351 | - if (empty($_POST['custom_avatar_dir'])) |
|
352 | - $_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar'; |
|
359 | + if (empty($_POST['custom_avatar_dir'])) { |
|
360 | + $_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar'; |
|
361 | + } |
|
353 | 362 | |
354 | - if (empty($_POST['custom_avatar_url'])) |
|
355 | - $_POST['custom_avatar_url'] = $boardurl . '/custom_avatar'; |
|
363 | + if (empty($_POST['custom_avatar_url'])) { |
|
364 | + $_POST['custom_avatar_url'] = $boardurl . '/custom_avatar'; |
|
365 | + } |
|
356 | 366 | |
357 | - if (empty($_POST['avatar_directory'])) |
|
358 | - $_POST['avatar_directory'] = $boarddir . '/avatars'; |
|
367 | + if (empty($_POST['avatar_directory'])) { |
|
368 | + $_POST['avatar_directory'] = $boarddir . '/avatars'; |
|
369 | + } |
|
359 | 370 | |
360 | - if (empty($_POST['avatar_url'])) |
|
361 | - $_POST['avatar_url'] = $boardurl . '/avatars'; |
|
371 | + if (empty($_POST['avatar_url'])) { |
|
372 | + $_POST['avatar_url'] = $boardurl . '/avatars'; |
|
373 | + } |
|
362 | 374 | |
363 | 375 | call_integration_hook('integrate_save_avatar_settings'); |
364 | 376 | |
@@ -406,11 +418,13 @@ discard block |
||
406 | 418 | $list_title = $txt['attachment_manager_browse_files'] . ': '; |
407 | 419 | foreach ($titles as $browse_type => $details) |
408 | 420 | { |
409 | - if ($browse_type != 'attachments') |
|
410 | - $list_title .= ' | '; |
|
421 | + if ($browse_type != 'attachments') { |
|
422 | + $list_title .= ' | '; |
|
423 | + } |
|
411 | 424 | |
412 | - if ($context['browse_type'] == $browse_type) |
|
413 | - $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
425 | + if ($context['browse_type'] == $browse_type) { |
|
426 | + $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
427 | + } |
|
414 | 428 | |
415 | 429 | $list_title .= '<a href="' . $scripturl . $details[0] . '">' . $details[1] . '</a>'; |
416 | 430 | } |
@@ -446,28 +460,33 @@ discard block |
||
446 | 460 | $link = '<a href="'; |
447 | 461 | |
448 | 462 | // In case of a custom avatar URL attachments have a fixed directory. |
449 | - if ($rowData['attachment_type'] == 1) |
|
450 | - $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
463 | + if ($rowData['attachment_type'] == 1) { |
|
464 | + $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
465 | + } |
|
451 | 466 | |
452 | 467 | // By default avatars are downloaded almost as attachments. |
453 | - elseif ($context['browse_type'] == 'avatars') |
|
454 | - $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
468 | + elseif ($context['browse_type'] == 'avatars') { |
|
469 | + $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
470 | + } |
|
455 | 471 | |
456 | 472 | // Normal attachments are always linked to a topic ID. |
457 | - else |
|
458 | - $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
473 | + else { |
|
474 | + $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
475 | + } |
|
459 | 476 | |
460 | 477 | $link .= '"'; |
461 | 478 | |
462 | 479 | // Show a popup on click if it's a picture and we know its dimensions. |
463 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
464 | - $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
480 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
481 | + $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
482 | + } |
|
465 | 483 | |
466 | 484 | $link .= sprintf('>%1$s</a>', preg_replace('~&#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\\\1;', $smcFunc['htmlspecialchars']($rowData['filename']))); |
467 | 485 | |
468 | 486 | // Show the dimensions. |
469 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
470 | - $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
487 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
488 | + $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
489 | + } |
|
471 | 490 | |
472 | 491 | return $link; |
473 | 492 | }, |
@@ -500,12 +519,14 @@ discard block |
||
500 | 519 | 'function' => function($rowData) use ($scripturl, $smcFunc) |
501 | 520 | { |
502 | 521 | // In case of an attachment, return the poster of the attachment. |
503 | - if (empty($rowData['id_member'])) |
|
504 | - return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
522 | + if (empty($rowData['id_member'])) { |
|
523 | + return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
524 | + } |
|
505 | 525 | |
506 | 526 | // Otherwise it must be an avatar, return the link to the owner of it. |
507 | - else |
|
508 | - return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
527 | + else { |
|
528 | + return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
529 | + } |
|
509 | 530 | }, |
510 | 531 | ), |
511 | 532 | 'sort' => array( |
@@ -524,8 +545,9 @@ discard block |
||
524 | 545 | $date = empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']); |
525 | 546 | |
526 | 547 | // Add a link to the topic in case of an attachment. |
527 | - if ($context['browse_type'] !== 'avatars') |
|
528 | - $date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
548 | + if ($context['browse_type'] !== 'avatars') { |
|
549 | + $date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
550 | + } |
|
529 | 551 | |
530 | 552 | return $date; |
531 | 553 | }, |
@@ -610,8 +632,8 @@ discard block |
||
610 | 632 | global $smcFunc, $txt; |
611 | 633 | |
612 | 634 | // Choose a query depending on what we are viewing. |
613 | - if ($browse_type === 'avatars') |
|
614 | - $request = $smcFunc['db_query']('', ' |
|
635 | + if ($browse_type === 'avatars') { |
|
636 | + $request = $smcFunc['db_query']('', ' |
|
615 | 637 | SELECT |
616 | 638 | {string:blank_text} AS id_msg, COALESCE(mem.real_name, {string:not_applicable_text}) AS poster_name, |
617 | 639 | mem.last_login AS poster_time, 0 AS id_topic, a.id_member, a.id_attach, a.filename, a.file_hash, a.attachment_type, |
@@ -630,8 +652,8 @@ discard block |
||
630 | 652 | 'per_page' => $items_per_page, |
631 | 653 | ) |
632 | 654 | ); |
633 | - else |
|
634 | - $request = $smcFunc['db_query']('', ' |
|
655 | + } else { |
|
656 | + $request = $smcFunc['db_query']('', ' |
|
635 | 657 | SELECT |
636 | 658 | m.id_msg, COALESCE(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_topic, m.id_member, |
637 | 659 | a.id_attach, a.filename, a.file_hash, a.attachment_type, a.size, a.width, a.height, a.downloads, mf.subject, t.id_board |
@@ -650,9 +672,11 @@ discard block |
||
650 | 672 | 'per_page' => $items_per_page, |
651 | 673 | ) |
652 | 674 | ); |
675 | + } |
|
653 | 676 | $files = array(); |
654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
655 | - $files[] = $row; |
|
677 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
678 | + $files[] = $row; |
|
679 | + } |
|
656 | 680 | $smcFunc['db_free_result']($request); |
657 | 681 | |
658 | 682 | return $files; |
@@ -670,8 +694,8 @@ discard block |
||
670 | 694 | global $smcFunc; |
671 | 695 | |
672 | 696 | // Depending on the type of file, different queries are used. |
673 | - if ($browse_type === 'avatars') |
|
674 | - $request = $smcFunc['db_query']('', ' |
|
697 | + if ($browse_type === 'avatars') { |
|
698 | + $request = $smcFunc['db_query']('', ' |
|
675 | 699 | SELECT COUNT(*) |
676 | 700 | FROM {db_prefix}attachments |
677 | 701 | WHERE id_member != {int:guest_id_member}', |
@@ -679,8 +703,8 @@ discard block |
||
679 | 703 | 'guest_id_member' => 0, |
680 | 704 | ) |
681 | 705 | ); |
682 | - else |
|
683 | - $request = $smcFunc['db_query']('', ' |
|
706 | + } else { |
|
707 | + $request = $smcFunc['db_query']('', ' |
|
684 | 708 | SELECT COUNT(*) AS num_attach |
685 | 709 | FROM {db_prefix}attachments AS a |
686 | 710 | INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) |
@@ -693,6 +717,7 @@ discard block |
||
693 | 717 | 'guest_id_member' => 0, |
694 | 718 | ) |
695 | 719 | ); |
720 | + } |
|
696 | 721 | |
697 | 722 | list ($num_files) = $smcFunc['db_fetch_row']($request); |
698 | 723 | $smcFunc['db_free_result']($request); |
@@ -775,12 +800,14 @@ discard block |
||
775 | 800 | $current_dir_size /= 1024; |
776 | 801 | |
777 | 802 | // If they specified a limit only.... |
778 | - if (!empty($modSettings['attachmentDirSizeLimit'])) |
|
779 | - $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
803 | + if (!empty($modSettings['attachmentDirSizeLimit'])) { |
|
804 | + $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
805 | + } |
|
780 | 806 | $context['attachment_current_size'] = comma_format($current_dir_size, 2); |
781 | 807 | |
782 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
783 | - $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
808 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
809 | + $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
810 | + } |
|
784 | 811 | $context['attachment_current_files'] = comma_format($current_dir_files, 0); |
785 | 812 | |
786 | 813 | $context['attach_multiple_dirs'] = count($attach_dirs) > 1 ? true : false; |
@@ -817,8 +844,8 @@ discard block |
||
817 | 844 | $messages = removeAttachments(array('attachment_type' => 0, 'poster_time' => (time() - 24 * 60 * 60 * $_POST['age'])), 'messages', true); |
818 | 845 | |
819 | 846 | // Update the messages to reflect the change. |
820 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
821 | - $smcFunc['db_query']('', ' |
|
847 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
848 | + $smcFunc['db_query']('', ' |
|
822 | 849 | UPDATE {db_prefix}messages |
823 | 850 | SET body = CONCAT(body, {string:notice}) |
824 | 851 | WHERE id_msg IN ({array_int:messages})', |
@@ -827,8 +854,8 @@ discard block |
||
827 | 854 | 'notice' => '<br><br>' . $_POST['notice'], |
828 | 855 | ) |
829 | 856 | ); |
830 | - } |
|
831 | - else |
|
857 | + } |
|
858 | + } else |
|
832 | 859 | { |
833 | 860 | // Remove all the old avatars. |
834 | 861 | removeAttachments(array('not_id_member' => 0, 'last_login' => (time() - 24 * 60 * 60 * $_POST['age'])), 'members'); |
@@ -853,8 +880,8 @@ discard block |
||
853 | 880 | $messages = removeAttachments(array('attachment_type' => 0, 'size' => 1024 * $_POST['size']), 'messages', true); |
854 | 881 | |
855 | 882 | // And make a note on the post. |
856 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
857 | - $smcFunc['db_query']('', ' |
|
883 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
884 | + $smcFunc['db_query']('', ' |
|
858 | 885 | UPDATE {db_prefix}messages |
859 | 886 | SET body = CONCAT(body, {string:notice}) |
860 | 887 | WHERE id_msg IN ({array_int:messages})', |
@@ -863,6 +890,7 @@ discard block |
||
863 | 890 | 'notice' => '<br><br>' . $_POST['notice'], |
864 | 891 | ) |
865 | 892 | ); |
893 | + } |
|
866 | 894 | |
867 | 895 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
868 | 896 | } |
@@ -882,16 +910,17 @@ discard block |
||
882 | 910 | { |
883 | 911 | $attachments = array(); |
884 | 912 | // There must be a quicker way to pass this safety test?? |
885 | - foreach ($_POST['remove'] as $removeID => $dummy) |
|
886 | - $attachments[] = (int) $removeID; |
|
913 | + foreach ($_POST['remove'] as $removeID => $dummy) { |
|
914 | + $attachments[] = (int) $removeID; |
|
915 | + } |
|
887 | 916 | |
888 | 917 | // If the attachments are from a 3rd party, let them remove it. Hooks should remove their ids from the array. |
889 | 918 | $filesRemoved = false; |
890 | 919 | call_integration_hook('integrate_attachment_remove', array(&$filesRemoved, $attachments)); |
891 | 920 | |
892 | - if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) |
|
893 | - removeAttachments(array('id_attach' => $attachments)); |
|
894 | - else if (!empty($attachments)) |
|
921 | + if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) { |
|
922 | + removeAttachments(array('id_attach' => $attachments)); |
|
923 | + } else if (!empty($attachments)) |
|
895 | 924 | { |
896 | 925 | $messages = removeAttachments(array('id_attach' => $attachments), 'messages', true); |
897 | 926 | |
@@ -930,12 +959,13 @@ discard block |
||
930 | 959 | |
931 | 960 | $messages = removeAttachments(array('attachment_type' => 0), '', true); |
932 | 961 | |
933 | - if (!isset($_POST['notice'])) |
|
934 | - $_POST['notice'] = $txt['attachment_delete_admin']; |
|
962 | + if (!isset($_POST['notice'])) { |
|
963 | + $_POST['notice'] = $txt['attachment_delete_admin']; |
|
964 | + } |
|
935 | 965 | |
936 | 966 | // Add the notice on the end of the changed messages. |
937 | - if (!empty($messages)) |
|
938 | - $smcFunc['db_query']('', ' |
|
967 | + if (!empty($messages)) { |
|
968 | + $smcFunc['db_query']('', ' |
|
939 | 969 | UPDATE {db_prefix}messages |
940 | 970 | SET body = CONCAT(body, {string:deleted_message}) |
941 | 971 | WHERE id_msg IN ({array_int:messages})', |
@@ -944,6 +974,7 @@ discard block |
||
944 | 974 | 'deleted_message' => '<br><br>' . $_POST['notice'], |
945 | 975 | ) |
946 | 976 | ); |
977 | + } |
|
947 | 978 | |
948 | 979 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
949 | 980 | } |
@@ -982,24 +1013,26 @@ discard block |
||
982 | 1013 | $is_not = substr($real_type, 0, 4) == 'not_'; |
983 | 1014 | $type = $is_not ? substr($real_type, 4) : $real_type; |
984 | 1015 | |
985 | - if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) |
|
986 | - $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
987 | - elseif ($type == 'attachment_type') |
|
988 | - $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
989 | - elseif ($type == 'poster_time') |
|
990 | - $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
991 | - elseif ($type == 'last_login') |
|
992 | - $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
993 | - elseif ($type == 'size') |
|
994 | - $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
995 | - elseif ($type == 'id_topic') |
|
996 | - $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
1016 | + if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) { |
|
1017 | + $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
1018 | + } elseif ($type == 'attachment_type') { |
|
1019 | + $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
1020 | + } elseif ($type == 'poster_time') { |
|
1021 | + $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
1022 | + } elseif ($type == 'last_login') { |
|
1023 | + $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
1024 | + } elseif ($type == 'size') { |
|
1025 | + $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
1026 | + } elseif ($type == 'id_topic') { |
|
1027 | + $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
1028 | + } |
|
997 | 1029 | |
998 | 1030 | // Add the parameter! |
999 | 1031 | $query_parameter[$real_type] = $restriction; |
1000 | 1032 | |
1001 | - if ($type == 'do_logging') |
|
1002 | - $do_logging = $condition['id_attach']; |
|
1033 | + if ($type == 'do_logging') { |
|
1034 | + $do_logging = $condition['id_attach']; |
|
1035 | + } |
|
1003 | 1036 | } |
1004 | 1037 | $condition = implode(' AND ', $new_condition); |
1005 | 1038 | } |
@@ -1031,15 +1064,15 @@ discard block |
||
1031 | 1064 | // wasn't it obvious? :P |
1032 | 1065 | // @todo look again at this. |
1033 | 1066 | @unlink($modSettings['custom_avatar_dir'] . '/' . $row['filename']); |
1034 | - } |
|
1035 | - else |
|
1067 | + } else |
|
1036 | 1068 | { |
1037 | 1069 | $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
1038 | 1070 | @unlink($filename); |
1039 | 1071 | |
1040 | 1072 | // If this was a thumb, the parent attachment should know about it. |
1041 | - if (!empty($row['id_parent'])) |
|
1042 | - $parents[] = $row['id_parent']; |
|
1073 | + if (!empty($row['id_parent'])) { |
|
1074 | + $parents[] = $row['id_parent']; |
|
1075 | + } |
|
1043 | 1076 | |
1044 | 1077 | // If this attachments has a thumb, remove it as well. |
1045 | 1078 | if (!empty($row['id_thumb']) && $autoThumbRemoval) |
@@ -1051,8 +1084,9 @@ discard block |
||
1051 | 1084 | } |
1052 | 1085 | |
1053 | 1086 | // Make a list. |
1054 | - if ($return_affected_messages && empty($row['attachment_type'])) |
|
1055 | - $msgs[] = $row['id_msg']; |
|
1087 | + if ($return_affected_messages && empty($row['attachment_type'])) { |
|
1088 | + $msgs[] = $row['id_msg']; |
|
1089 | + } |
|
1056 | 1090 | |
1057 | 1091 | $attach[] = $row['id_attach']; |
1058 | 1092 | } |
@@ -1060,8 +1094,8 @@ discard block |
||
1060 | 1094 | |
1061 | 1095 | // Removed attachments don't have to be updated anymore. |
1062 | 1096 | $parents = array_diff($parents, $attach); |
1063 | - if (!empty($parents)) |
|
1064 | - $smcFunc['db_query']('', ' |
|
1097 | + if (!empty($parents)) { |
|
1098 | + $smcFunc['db_query']('', ' |
|
1065 | 1099 | UPDATE {db_prefix}attachments |
1066 | 1100 | SET id_thumb = {int:no_thumb} |
1067 | 1101 | WHERE id_attach IN ({array_int:parent_attachments})', |
@@ -1070,6 +1104,7 @@ discard block |
||
1070 | 1104 | 'no_thumb' => 0, |
1071 | 1105 | ) |
1072 | 1106 | ); |
1107 | + } |
|
1073 | 1108 | |
1074 | 1109 | if (!empty($do_logging)) |
1075 | 1110 | { |
@@ -1086,31 +1121,34 @@ discard block |
||
1086 | 1121 | ) |
1087 | 1122 | ); |
1088 | 1123 | |
1089 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1090 | - logAction( |
|
1124 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1125 | + logAction( |
|
1091 | 1126 | 'remove_attach', |
1092 | 1127 | array( |
1093 | 1128 | 'message' => $row['id_msg'], |
1094 | 1129 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
1095 | 1130 | ) |
1096 | 1131 | ); |
1132 | + } |
|
1097 | 1133 | $smcFunc['db_free_result']($request); |
1098 | 1134 | } |
1099 | 1135 | |
1100 | - if (!empty($attach)) |
|
1101 | - $smcFunc['db_query']('', ' |
|
1136 | + if (!empty($attach)) { |
|
1137 | + $smcFunc['db_query']('', ' |
|
1102 | 1138 | DELETE FROM {db_prefix}attachments |
1103 | 1139 | WHERE id_attach IN ({array_int:attachment_list})', |
1104 | 1140 | array( |
1105 | 1141 | 'attachment_list' => $attach, |
1106 | 1142 | ) |
1107 | 1143 | ); |
1144 | + } |
|
1108 | 1145 | |
1109 | 1146 | call_integration_hook('integrate_remove_attachments', array($attach)); |
1110 | 1147 | |
1111 | - if ($return_affected_messages) |
|
1112 | - return array_unique($msgs); |
|
1113 | -} |
|
1148 | + if ($return_affected_messages) { |
|
1149 | + return array_unique($msgs); |
|
1150 | + } |
|
1151 | + } |
|
1114 | 1152 | |
1115 | 1153 | /** |
1116 | 1154 | * This function should find attachments in the database that no longer exist and clear them, and fix filesize issues. |
@@ -1122,8 +1160,9 @@ discard block |
||
1122 | 1160 | checkSession('get'); |
1123 | 1161 | |
1124 | 1162 | // If we choose cancel, redirect right back. |
1125 | - if (isset($_POST['cancel'])) |
|
1126 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
1163 | + if (isset($_POST['cancel'])) { |
|
1164 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
1165 | + } |
|
1127 | 1166 | |
1128 | 1167 | // Try give us a while to sort this out... |
1129 | 1168 | @set_time_limit(600); |
@@ -1140,13 +1179,15 @@ discard block |
||
1140 | 1179 | if (isset($_GET['fixErrors'])) |
1141 | 1180 | { |
1142 | 1181 | // Nothing? |
1143 | - if (empty($_POST['to_fix'])) |
|
1144 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
1182 | + if (empty($_POST['to_fix'])) { |
|
1183 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
1184 | + } |
|
1145 | 1185 | |
1146 | 1186 | $_SESSION['attachments_to_fix'] = array(); |
1147 | 1187 | // @todo No need to do this I think. |
1148 | - foreach ($_POST['to_fix'] as $value) |
|
1149 | - $_SESSION['attachments_to_fix'][] = $value; |
|
1188 | + foreach ($_POST['to_fix'] as $value) { |
|
1189 | + $_SESSION['attachments_to_fix'][] = $value; |
|
1190 | + } |
|
1150 | 1191 | } |
1151 | 1192 | } |
1152 | 1193 | |
@@ -1213,13 +1254,14 @@ discard block |
||
1213 | 1254 | } |
1214 | 1255 | } |
1215 | 1256 | } |
1216 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1217 | - $to_fix[] = 'missing_thumbnail_parent'; |
|
1257 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1258 | + $to_fix[] = 'missing_thumbnail_parent'; |
|
1259 | + } |
|
1218 | 1260 | $smcFunc['db_free_result']($result); |
1219 | 1261 | |
1220 | 1262 | // Do we need to delete what we have? |
1221 | - if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) |
|
1222 | - $smcFunc['db_query']('', ' |
|
1263 | + if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) { |
|
1264 | + $smcFunc['db_query']('', ' |
|
1223 | 1265 | DELETE FROM {db_prefix}attachments |
1224 | 1266 | WHERE id_attach IN ({array_int:to_remove}) |
1225 | 1267 | AND attachment_type = {int:attachment_type}', |
@@ -1228,6 +1270,7 @@ discard block |
||
1228 | 1270 | 'attachment_type' => 3, |
1229 | 1271 | ) |
1230 | 1272 | ); |
1273 | + } |
|
1231 | 1274 | |
1232 | 1275 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
1233 | 1276 | } |
@@ -1272,13 +1315,14 @@ discard block |
||
1272 | 1315 | $to_update[] = $row['id_attach']; |
1273 | 1316 | $context['repair_errors']['parent_missing_thumbnail']++; |
1274 | 1317 | } |
1275 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1276 | - $to_fix[] = 'parent_missing_thumbnail'; |
|
1318 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1319 | + $to_fix[] = 'parent_missing_thumbnail'; |
|
1320 | + } |
|
1277 | 1321 | $smcFunc['db_free_result']($result); |
1278 | 1322 | |
1279 | 1323 | // Do we need to delete what we have? |
1280 | - if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) |
|
1281 | - $smcFunc['db_query']('', ' |
|
1324 | + if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) { |
|
1325 | + $smcFunc['db_query']('', ' |
|
1282 | 1326 | UPDATE {db_prefix}attachments |
1283 | 1327 | SET id_thumb = {int:no_thumb} |
1284 | 1328 | WHERE id_attach IN ({array_int:to_update})', |
@@ -1287,6 +1331,7 @@ discard block |
||
1287 | 1331 | 'no_thumb' => 0, |
1288 | 1332 | ) |
1289 | 1333 | ); |
1334 | + } |
|
1290 | 1335 | |
1291 | 1336 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
1292 | 1337 | } |
@@ -1324,10 +1369,11 @@ discard block |
||
1324 | 1369 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1325 | 1370 | { |
1326 | 1371 | // Get the filename. |
1327 | - if ($row['attachment_type'] == 1) |
|
1328 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
1329 | - else |
|
1330 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
1372 | + if ($row['attachment_type'] == 1) { |
|
1373 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
1374 | + } else { |
|
1375 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
1376 | + } |
|
1331 | 1377 | |
1332 | 1378 | // File doesn't exist? |
1333 | 1379 | if (!file_exists($filename)) |
@@ -1339,15 +1385,16 @@ discard block |
||
1339 | 1385 | $attachment_name = $row['id_attach'] . '_' . $row['file_hash'] . '.dat'; |
1340 | 1386 | |
1341 | 1387 | // Loop through the other folders. |
1342 | - foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
|
1343 | - if (file_exists($dir . '/' . $attachment_name)) |
|
1388 | + foreach ($modSettings['attachmentUploadDir'] as $id => $dir) { |
|
1389 | + if (file_exists($dir . '/' . $attachment_name)) |
|
1344 | 1390 | { |
1345 | 1391 | $context['repair_errors']['wrong_folder']++; |
1392 | + } |
|
1346 | 1393 | $errors_found[] = 'wrong_folder'; |
1347 | 1394 | |
1348 | 1395 | // Are we going to fix this now? |
1349 | - if ($fix_errors && in_array('wrong_folder', $to_fix)) |
|
1350 | - $smcFunc['db_query']('', ' |
|
1396 | + if ($fix_errors && in_array('wrong_folder', $to_fix)) { |
|
1397 | + $smcFunc['db_query']('', ' |
|
1351 | 1398 | UPDATE {db_prefix}attachments |
1352 | 1399 | SET id_folder = {int:new_folder} |
1353 | 1400 | WHERE id_attach = {int:id_attach}', |
@@ -1356,6 +1403,7 @@ discard block |
||
1356 | 1403 | 'id_attach' => $row['id_attach'], |
1357 | 1404 | ) |
1358 | 1405 | ); |
1406 | + } |
|
1359 | 1407 | |
1360 | 1408 | continue 2; |
1361 | 1409 | } |
@@ -1364,8 +1412,7 @@ discard block |
||
1364 | 1412 | $to_remove[] = $row['id_attach']; |
1365 | 1413 | $context['repair_errors']['file_missing_on_disk']++; |
1366 | 1414 | $errors_found[] = 'file_missing_on_disk'; |
1367 | - } |
|
1368 | - elseif (filesize($filename) == 0) |
|
1415 | + } elseif (filesize($filename) == 0) |
|
1369 | 1416 | { |
1370 | 1417 | $context['repair_errors']['file_size_of_zero']++; |
1371 | 1418 | $errors_found[] = 'file_size_of_zero'; |
@@ -1376,8 +1423,7 @@ discard block |
||
1376 | 1423 | $to_remove[] = $row['id_attach']; |
1377 | 1424 | @unlink($filename); |
1378 | 1425 | } |
1379 | - } |
|
1380 | - elseif (filesize($filename) != $row['size']) |
|
1426 | + } elseif (filesize($filename) != $row['size']) |
|
1381 | 1427 | { |
1382 | 1428 | $context['repair_errors']['file_wrong_size']++; |
1383 | 1429 | $errors_found[] = 'file_wrong_size'; |
@@ -1398,14 +1444,18 @@ discard block |
||
1398 | 1444 | } |
1399 | 1445 | } |
1400 | 1446 | |
1401 | - if (in_array('file_missing_on_disk', $errors_found)) |
|
1402 | - $to_fix[] = 'file_missing_on_disk'; |
|
1403 | - if (in_array('file_size_of_zero', $errors_found)) |
|
1404 | - $to_fix[] = 'file_size_of_zero'; |
|
1405 | - if (in_array('file_wrong_size', $errors_found)) |
|
1406 | - $to_fix[] = 'file_wrong_size'; |
|
1407 | - if (in_array('wrong_folder', $errors_found)) |
|
1408 | - $to_fix[] = 'wrong_folder'; |
|
1447 | + if (in_array('file_missing_on_disk', $errors_found)) { |
|
1448 | + $to_fix[] = 'file_missing_on_disk'; |
|
1449 | + } |
|
1450 | + if (in_array('file_size_of_zero', $errors_found)) { |
|
1451 | + $to_fix[] = 'file_size_of_zero'; |
|
1452 | + } |
|
1453 | + if (in_array('file_wrong_size', $errors_found)) { |
|
1454 | + $to_fix[] = 'file_wrong_size'; |
|
1455 | + } |
|
1456 | + if (in_array('wrong_folder', $errors_found)) { |
|
1457 | + $to_fix[] = 'wrong_folder'; |
|
1458 | + } |
|
1409 | 1459 | $smcFunc['db_free_result']($result); |
1410 | 1460 | |
1411 | 1461 | // Do we need to delete what we have? |
@@ -1475,20 +1525,22 @@ discard block |
||
1475 | 1525 | // If we are repairing remove the file from disk now. |
1476 | 1526 | if ($fix_errors && in_array('avatar_no_member', $to_fix)) |
1477 | 1527 | { |
1478 | - if ($row['attachment_type'] == 1) |
|
1479 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
1480 | - else |
|
1481 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
1528 | + if ($row['attachment_type'] == 1) { |
|
1529 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
1530 | + } else { |
|
1531 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
1532 | + } |
|
1482 | 1533 | @unlink($filename); |
1483 | 1534 | } |
1484 | 1535 | } |
1485 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1486 | - $to_fix[] = 'avatar_no_member'; |
|
1536 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1537 | + $to_fix[] = 'avatar_no_member'; |
|
1538 | + } |
|
1487 | 1539 | $smcFunc['db_free_result']($result); |
1488 | 1540 | |
1489 | 1541 | // Do we need to delete what we have? |
1490 | - if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) |
|
1491 | - $smcFunc['db_query']('', ' |
|
1542 | + if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) { |
|
1543 | + $smcFunc['db_query']('', ' |
|
1492 | 1544 | DELETE FROM {db_prefix}attachments |
1493 | 1545 | WHERE id_attach IN ({array_int:to_remove}) |
1494 | 1546 | AND id_member != {int:no_member} |
@@ -1499,6 +1551,7 @@ discard block |
||
1499 | 1551 | 'no_msg' => 0, |
1500 | 1552 | ) |
1501 | 1553 | ); |
1554 | + } |
|
1502 | 1555 | |
1503 | 1556 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
1504 | 1557 | } |
@@ -1558,13 +1611,14 @@ discard block |
||
1558 | 1611 | @unlink($filename); |
1559 | 1612 | } |
1560 | 1613 | } |
1561 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1562 | - $to_fix[] = 'attachment_no_msg'; |
|
1614 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1615 | + $to_fix[] = 'attachment_no_msg'; |
|
1616 | + } |
|
1563 | 1617 | $smcFunc['db_free_result']($result); |
1564 | 1618 | |
1565 | 1619 | // Do we need to delete what we have? |
1566 | - if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) |
|
1567 | - $smcFunc['db_query']('', ' |
|
1620 | + if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) { |
|
1621 | + $smcFunc['db_query']('', ' |
|
1568 | 1622 | DELETE FROM {db_prefix}attachments |
1569 | 1623 | WHERE id_attach IN ({array_int:to_remove}) |
1570 | 1624 | AND id_member = {int:no_member} |
@@ -1575,6 +1629,7 @@ discard block |
||
1575 | 1629 | 'attach_thumb' => array(0,3), |
1576 | 1630 | ) |
1577 | 1631 | ); |
1632 | + } |
|
1578 | 1633 | |
1579 | 1634 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
1580 | 1635 | } |
@@ -1598,8 +1653,9 @@ discard block |
||
1598 | 1653 | { |
1599 | 1654 | while ($file = readdir($dir)) |
1600 | 1655 | { |
1601 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
1602 | - continue; |
|
1656 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
1657 | + continue; |
|
1658 | + } |
|
1603 | 1659 | |
1604 | 1660 | if ($files_checked <= $current_check) |
1605 | 1661 | { |
@@ -1607,8 +1663,9 @@ discard block |
||
1607 | 1663 | if (strpos($file, 'post_tmp_') !== false) |
1608 | 1664 | { |
1609 | 1665 | // Temp file is more than 5 hours old! |
1610 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
1611 | - @unlink($attach_dir . '/' . $file); |
|
1666 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
1667 | + @unlink($attach_dir . '/' . $file); |
|
1668 | + } |
|
1612 | 1669 | } |
1613 | 1670 | // That should be an attachment, let's check if we have it in the database |
1614 | 1671 | elseif (strpos($file, '_') !== false) |
@@ -1630,8 +1687,7 @@ discard block |
||
1630 | 1687 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
1631 | 1688 | { |
1632 | 1689 | @unlink($attach_dir . '/' . $file); |
1633 | - } |
|
1634 | - else |
|
1690 | + } else |
|
1635 | 1691 | { |
1636 | 1692 | $context['repair_errors']['files_without_attachment']++; |
1637 | 1693 | $to_fix[] = 'files_without_attachment'; |
@@ -1639,14 +1695,12 @@ discard block |
||
1639 | 1695 | } |
1640 | 1696 | $smcFunc['db_free_result']($request); |
1641 | 1697 | } |
1642 | - } |
|
1643 | - else |
|
1698 | + } else |
|
1644 | 1699 | { |
1645 | 1700 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
1646 | 1701 | { |
1647 | 1702 | @unlink($attach_dir . '/' . $file); |
1648 | - } |
|
1649 | - else |
|
1703 | + } else |
|
1650 | 1704 | { |
1651 | 1705 | $context['repair_errors']['files_without_attachment']++; |
1652 | 1706 | $to_fix[] = 'files_without_attachment'; |
@@ -1655,8 +1709,9 @@ discard block |
||
1655 | 1709 | } |
1656 | 1710 | $current_check++; |
1657 | 1711 | $_GET['substep'] = $current_check; |
1658 | - if ($current_check - $files_checked >= $max_checks) |
|
1659 | - pauseAttachmentMaintenance($to_fix); |
|
1712 | + if ($current_check - $files_checked >= $max_checks) { |
|
1713 | + pauseAttachmentMaintenance($to_fix); |
|
1714 | + } |
|
1660 | 1715 | } |
1661 | 1716 | closedir($dir); |
1662 | 1717 | } |
@@ -1692,12 +1747,14 @@ discard block |
||
1692 | 1747 | |
1693 | 1748 | // Try get more time... |
1694 | 1749 | @set_time_limit(600); |
1695 | - if (function_exists('apache_reset_timeout')) |
|
1696 | - @apache_reset_timeout(); |
|
1750 | + if (function_exists('apache_reset_timeout')) { |
|
1751 | + @apache_reset_timeout(); |
|
1752 | + } |
|
1697 | 1753 | |
1698 | 1754 | // Have we already used our maximum time? |
1699 | - if (time() - array_sum(explode(' ', $time_start)) < 3 || $context['starting_substep'] == $_GET['substep']) |
|
1700 | - return; |
|
1755 | + if (time() - array_sum(explode(' ', $time_start)) < 3 || $context['starting_substep'] == $_GET['substep']) { |
|
1756 | + return; |
|
1757 | + } |
|
1701 | 1758 | |
1702 | 1759 | $context['continue_get_data'] = '?action=admin;area=manageattachments;sa=repair' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1703 | 1760 | $context['page_title'] = $txt['not_done_title']; |
@@ -1709,10 +1766,11 @@ discard block |
||
1709 | 1766 | $context[$context['admin_menu_name']]['current_subsection'] = 'maintenance'; |
1710 | 1767 | |
1711 | 1768 | // Change these two if more steps are added! |
1712 | - if (empty($max_substep)) |
|
1713 | - $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
1714 | - else |
|
1715 | - $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
1769 | + if (empty($max_substep)) { |
|
1770 | + $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
1771 | + } else { |
|
1772 | + $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
1773 | + } |
|
1716 | 1774 | |
1717 | 1775 | // Never more than 100%! |
1718 | 1776 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -1754,15 +1812,17 @@ discard block |
||
1754 | 1812 | 'attachment_type' => 0, |
1755 | 1813 | ) |
1756 | 1814 | ); |
1757 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1758 | - $attachments[] = $row['id_attach']; |
|
1815 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1816 | + $attachments[] = $row['id_attach']; |
|
1817 | + } |
|
1759 | 1818 | $smcFunc['db_free_result']($request); |
1819 | + } elseif (!empty($_GET['aid'])) { |
|
1820 | + $attachments[] = (int) $_GET['aid']; |
|
1760 | 1821 | } |
1761 | - elseif (!empty($_GET['aid'])) |
|
1762 | - $attachments[] = (int) $_GET['aid']; |
|
1763 | 1822 | |
1764 | - if (empty($attachments)) |
|
1765 | - fatal_lang_error('no_access', false); |
|
1823 | + if (empty($attachments)) { |
|
1824 | + fatal_lang_error('no_access', false); |
|
1825 | + } |
|
1766 | 1826 | |
1767 | 1827 | // Now we have some ID's cleaned and ready to approve, but first - let's check we have permission! |
1768 | 1828 | $allowed_boards = boardsAllowedTo('approve_posts'); |
@@ -1795,17 +1855,18 @@ discard block |
||
1795 | 1855 | } |
1796 | 1856 | $smcFunc['db_free_result']($request); |
1797 | 1857 | |
1798 | - if (empty($attachments)) |
|
1799 | - fatal_lang_error('no_access', false); |
|
1858 | + if (empty($attachments)) { |
|
1859 | + fatal_lang_error('no_access', false); |
|
1860 | + } |
|
1800 | 1861 | |
1801 | 1862 | // Finally, we are there. Follow through! |
1802 | 1863 | if ($is_approve) |
1803 | 1864 | { |
1804 | 1865 | // Checked and deemed worthy. |
1805 | 1866 | ApproveAttachments($attachments); |
1867 | + } else { |
|
1868 | + removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
1806 | 1869 | } |
1807 | - else |
|
1808 | - removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
1809 | 1870 | |
1810 | 1871 | // Return to the topic.... |
1811 | 1872 | redirectexit($redirect); |
@@ -1821,8 +1882,9 @@ discard block |
||
1821 | 1882 | { |
1822 | 1883 | global $smcFunc; |
1823 | 1884 | |
1824 | - if (empty($attachments)) |
|
1825 | - return 0; |
|
1885 | + if (empty($attachments)) { |
|
1886 | + return 0; |
|
1887 | + } |
|
1826 | 1888 | |
1827 | 1889 | // For safety, check for thumbnails... |
1828 | 1890 | $request = $smcFunc['db_query']('', ' |
@@ -1841,15 +1903,17 @@ discard block |
||
1841 | 1903 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1842 | 1904 | { |
1843 | 1905 | // Update the thumbnail too... |
1844 | - if (!empty($row['id_thumb'])) |
|
1845 | - $attachments[] = $row['id_thumb']; |
|
1906 | + if (!empty($row['id_thumb'])) { |
|
1907 | + $attachments[] = $row['id_thumb']; |
|
1908 | + } |
|
1846 | 1909 | |
1847 | 1910 | $attachments[] = $row['id_attach']; |
1848 | 1911 | } |
1849 | 1912 | $smcFunc['db_free_result']($request); |
1850 | 1913 | |
1851 | - if (empty($attachments)) |
|
1852 | - return 0; |
|
1914 | + if (empty($attachments)) { |
|
1915 | + return 0; |
|
1916 | + } |
|
1853 | 1917 | |
1854 | 1918 | // Approving an attachment is not hard - it's easy. |
1855 | 1919 | $smcFunc['db_query']('', ' |
@@ -1875,14 +1939,15 @@ discard block |
||
1875 | 1939 | ) |
1876 | 1940 | ); |
1877 | 1941 | |
1878 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1879 | - logAction( |
|
1942 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1943 | + logAction( |
|
1880 | 1944 | 'approve_attach', |
1881 | 1945 | array( |
1882 | 1946 | 'message' => $row['id_msg'], |
1883 | 1947 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
1884 | 1948 | ) |
1885 | 1949 | ); |
1950 | + } |
|
1886 | 1951 | $smcFunc['db_free_result']($request); |
1887 | 1952 | |
1888 | 1953 | // Remove from the approval queue. |
@@ -1905,11 +1970,11 @@ discard block |
||
1905 | 1970 | global $modSettings, $scripturl, $context, $txt, $sourcedir, $boarddir, $smcFunc, $settings; |
1906 | 1971 | |
1907 | 1972 | // Since this needs to be done eventually. |
1908 | - if (!isset($modSettings['attachment_basedirectories'])) |
|
1909 | - $modSettings['attachment_basedirectories'] = array(); |
|
1910 | - |
|
1911 | - elseif (!is_array($modSettings['attachment_basedirectories'])) |
|
1912 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
1973 | + if (!isset($modSettings['attachment_basedirectories'])) { |
|
1974 | + $modSettings['attachment_basedirectories'] = array(); |
|
1975 | + } elseif (!is_array($modSettings['attachment_basedirectories'])) { |
|
1976 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
1977 | + } |
|
1913 | 1978 | |
1914 | 1979 | $errors = array(); |
1915 | 1980 | |
@@ -1924,8 +1989,9 @@ discard block |
||
1924 | 1989 | { |
1925 | 1990 | $error = ''; |
1926 | 1991 | $id = (int) $id; |
1927 | - if ($id < 1) |
|
1928 | - continue; |
|
1992 | + if ($id < 1) { |
|
1993 | + continue; |
|
1994 | + } |
|
1929 | 1995 | |
1930 | 1996 | // Sorry, these dirs are NOT valid |
1931 | 1997 | $invalid_dirs = array($boarddir, $settings['default_theme_dir'], $sourcedir); |
@@ -1944,8 +2010,7 @@ discard block |
||
1944 | 2010 | { |
1945 | 2011 | $errors[] = $path . ': ' . $txt['attach_dir_duplicate_msg']; |
1946 | 2012 | continue; |
1947 | - } |
|
1948 | - elseif (empty($path)) |
|
2013 | + } elseif (empty($path)) |
|
1949 | 2014 | { |
1950 | 2015 | // Ignore this and set $id to one less |
1951 | 2016 | continue; |
@@ -1953,10 +2018,11 @@ discard block |
||
1953 | 2018 | |
1954 | 2019 | // OK, so let's try to create it then. |
1955 | 2020 | require_once($sourcedir . '/Subs-Attachments.php'); |
1956 | - if (automanage_attachments_create_directory($path)) |
|
1957 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
1958 | - else |
|
1959 | - $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
2021 | + if (automanage_attachments_create_directory($path)) { |
|
2022 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2023 | + } else { |
|
2024 | + $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
2025 | + } |
|
1960 | 2026 | } |
1961 | 2027 | |
1962 | 2028 | // Changing a directory name? |
@@ -1969,8 +2035,7 @@ discard block |
||
1969 | 2035 | $errors[] = $path . ': ' . $txt['attach_dir_no_rename']; |
1970 | 2036 | $path = $modSettings['attachmentUploadDir'][$id]; |
1971 | 2037 | } |
1972 | - } |
|
1973 | - else |
|
2038 | + } else |
|
1974 | 2039 | { |
1975 | 2040 | $errors[] = $path . ': ' . $txt['attach_dir_exists_msg']; |
1976 | 2041 | $path = $modSettings['attachmentUploadDir'][$id]; |
@@ -1995,12 +2060,13 @@ discard block |
||
1995 | 2060 | $path = $modSettings['attachmentUploadDir'][$id]; |
1996 | 2061 | |
1997 | 2062 | // It's not a good idea to delete the current directory. |
1998 | - if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) |
|
1999 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
2063 | + if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) { |
|
2064 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
2065 | + } |
|
2000 | 2066 | // Or the current base directory |
2001 | - elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) |
|
2002 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
2003 | - else |
|
2067 | + elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) { |
|
2068 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
2069 | + } else |
|
2004 | 2070 | { |
2005 | 2071 | // Let's not try to delete a path with files in it. |
2006 | 2072 | $request = $smcFunc['db_query']('', ' |
@@ -2019,17 +2085,18 @@ discard block |
||
2019 | 2085 | if (!empty($modSettings['attachment_basedirectories'])) |
2020 | 2086 | { |
2021 | 2087 | // Count any sub-folders. |
2022 | - foreach ($modSettings['attachmentUploadDir'] as $sub) |
|
2023 | - if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
2088 | + foreach ($modSettings['attachmentUploadDir'] as $sub) { |
|
2089 | + if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
2024 | 2090 | $num_attach++; |
2091 | + } |
|
2025 | 2092 | } |
2026 | 2093 | |
2027 | 2094 | // It's safe to delete. So try to delete the folder also |
2028 | 2095 | if ($num_attach == 0) |
2029 | 2096 | { |
2030 | - if (is_dir($path)) |
|
2031 | - $doit = true; |
|
2032 | - elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
2097 | + if (is_dir($path)) { |
|
2098 | + $doit = true; |
|
2099 | + } elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
2033 | 2100 | { |
2034 | 2101 | $doit = true; |
2035 | 2102 | $path = $boarddir . DIRECTORY_SEPARATOR . $path; |
@@ -2039,8 +2106,9 @@ discard block |
||
2039 | 2106 | { |
2040 | 2107 | unlink($path . '/.htaccess'); |
2041 | 2108 | unlink($path . '/index.php'); |
2042 | - if (!@rmdir($path)) |
|
2043 | - $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
2109 | + if (!@rmdir($path)) { |
|
2110 | + $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
2111 | + } |
|
2044 | 2112 | } |
2045 | 2113 | |
2046 | 2114 | // Remove it from the base directory list. |
@@ -2050,14 +2118,15 @@ discard block |
||
2050 | 2118 | updateSettings(array('attachment_basedirectories' => json_encode($modSettings['attachment_basedirectories']))); |
2051 | 2119 | $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
2052 | 2120 | } |
2121 | + } else { |
|
2122 | + $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
2053 | 2123 | } |
2054 | - else |
|
2055 | - $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
2056 | 2124 | |
2057 | - if (empty($error)) |
|
2058 | - continue; |
|
2059 | - else |
|
2060 | - $errors[] = $error; |
|
2125 | + if (empty($error)) { |
|
2126 | + continue; |
|
2127 | + } else { |
|
2128 | + $errors[] = $error; |
|
2129 | + } |
|
2061 | 2130 | } |
2062 | 2131 | } |
2063 | 2132 | |
@@ -2065,23 +2134,26 @@ discard block |
||
2065 | 2134 | } |
2066 | 2135 | |
2067 | 2136 | // We need to make sure the current directory is right. |
2068 | - if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) |
|
2069 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2137 | + if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) { |
|
2138 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2139 | + } |
|
2070 | 2140 | |
2071 | 2141 | // Find the current directory if there's no value carried, |
2072 | 2142 | if (empty($_POST['current_dir']) || empty($new_dirs[$_POST['current_dir']])) |
2073 | 2143 | { |
2074 | - if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) |
|
2075 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2076 | - else |
|
2077 | - $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
2144 | + if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) { |
|
2145 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
2146 | + } else { |
|
2147 | + $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
2148 | + } |
|
2078 | 2149 | } |
2079 | 2150 | |
2080 | 2151 | // If the user wishes to go back, update the last_dir array |
2081 | 2152 | if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir'] && !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0]))) |
2082 | 2153 | { |
2083 | - if (!is_array($modSettings['last_attachments_directory'])) |
|
2084 | - $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
|
2154 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
2155 | + $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
|
2156 | + } |
|
2085 | 2157 | $num = substr(strrchr($modSettings['attachmentUploadDir'][$_POST['current_dir']], '_'), 1); |
2086 | 2158 | |
2087 | 2159 | if (is_numeric($num)) |
@@ -2089,16 +2161,18 @@ discard block |
||
2089 | 2161 | // Need to find the base folder. |
2090 | 2162 | $bid = -1; |
2091 | 2163 | $use_subdirectories_for_attachments = 0; |
2092 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
2093 | - foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
2164 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
2165 | + foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
2094 | 2166 | if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !== false) |
2095 | 2167 | { |
2096 | 2168 | $use_subdirectories_for_attachments = 1; |
2169 | + } |
|
2097 | 2170 | break; |
2098 | 2171 | } |
2099 | 2172 | |
2100 | - if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) |
|
2101 | - $bid = 0; |
|
2173 | + if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) { |
|
2174 | + $bid = 0; |
|
2175 | + } |
|
2102 | 2176 | |
2103 | 2177 | $modSettings['last_attachments_directory'][$bid] = (int) $num; |
2104 | 2178 | $modSettings['basedirectory_for_attachments'] = !empty($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : ''; |
@@ -2117,8 +2191,8 @@ discard block |
||
2117 | 2191 | // We might need to reset the paths. This loop will just loop through once. |
2118 | 2192 | foreach ($new_dirs as $id => $dir) |
2119 | 2193 | { |
2120 | - if ($id != 1) |
|
2121 | - $smcFunc['db_query']('', ' |
|
2194 | + if ($id != 1) { |
|
2195 | + $smcFunc['db_query']('', ' |
|
2122 | 2196 | UPDATE {db_prefix}attachments |
2123 | 2197 | SET id_folder = {int:default_folder} |
2124 | 2198 | WHERE id_folder = {int:current_folder}', |
@@ -2127,14 +2201,14 @@ discard block |
||
2127 | 2201 | 'current_folder' => $id, |
2128 | 2202 | ) |
2129 | 2203 | ); |
2204 | + } |
|
2130 | 2205 | |
2131 | 2206 | $update = array( |
2132 | 2207 | 'currentAttachmentUploadDir' => 1, |
2133 | 2208 | 'attachmentUploadDir' => json_encode(array(1 => $dir)), |
2134 | 2209 | ); |
2135 | 2210 | } |
2136 | - } |
|
2137 | - else |
|
2211 | + } else |
|
2138 | 2212 | { |
2139 | 2213 | // Save it to the database. |
2140 | 2214 | $update = array( |
@@ -2143,11 +2217,13 @@ discard block |
||
2143 | 2217 | ); |
2144 | 2218 | } |
2145 | 2219 | |
2146 | - if (!empty($update)) |
|
2147 | - updateSettings($update); |
|
2220 | + if (!empty($update)) { |
|
2221 | + updateSettings($update); |
|
2222 | + } |
|
2148 | 2223 | |
2149 | - if (!empty($errors)) |
|
2150 | - $_SESSION['errors']['dir'] = $errors; |
|
2224 | + if (!empty($errors)) { |
|
2225 | + $_SESSION['errors']['dir'] = $errors; |
|
2226 | + } |
|
2151 | 2227 | |
2152 | 2228 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
2153 | 2229 | } |
@@ -2161,10 +2237,11 @@ discard block |
||
2161 | 2237 | $_POST['current_base_dir'] = isset($_POST['current_base_dir']) ? (int) $_POST['current_base_dir'] : 1; |
2162 | 2238 | if (empty($_POST['new_base_dir']) && !empty($_POST['current_base_dir'])) |
2163 | 2239 | { |
2164 | - if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) |
|
2165 | - $update = (array( |
|
2240 | + if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) { |
|
2241 | + $update = (array( |
|
2166 | 2242 | 'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$_POST['current_base_dir']], |
2167 | 2243 | )); |
2244 | + } |
|
2168 | 2245 | } |
2169 | 2246 | |
2170 | 2247 | if (isset($_POST['base_dir'])) |
@@ -2212,13 +2289,15 @@ discard block |
||
2212 | 2289 | |
2213 | 2290 | if (!in_array($_POST['new_base_dir'], $modSettings['attachmentUploadDir'])) |
2214 | 2291 | { |
2215 | - if (!automanage_attachments_create_directory($_POST['new_base_dir'])) |
|
2216 | - $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
2292 | + if (!automanage_attachments_create_directory($_POST['new_base_dir'])) { |
|
2293 | + $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
2294 | + } |
|
2217 | 2295 | } |
2218 | 2296 | |
2219 | 2297 | $modSettings['currentAttachmentUploadDir'] = array_search($_POST['new_base_dir'], $modSettings['attachmentUploadDir']); |
2220 | - if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) |
|
2221 | - $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
2298 | + if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) { |
|
2299 | + $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
2300 | + } |
|
2222 | 2301 | ksort($modSettings['attachment_basedirectories']); |
2223 | 2302 | |
2224 | 2303 | $update = (array( |
@@ -2228,11 +2307,13 @@ discard block |
||
2228 | 2307 | )); |
2229 | 2308 | } |
2230 | 2309 | |
2231 | - if (!empty($errors)) |
|
2232 | - $_SESSION['errors']['base'] = $errors; |
|
2310 | + if (!empty($errors)) { |
|
2311 | + $_SESSION['errors']['base'] = $errors; |
|
2312 | + } |
|
2233 | 2313 | |
2234 | - if (!empty($update)) |
|
2235 | - updateSettings($update); |
|
2314 | + if (!empty($update)) { |
|
2315 | + updateSettings($update); |
|
2316 | + } |
|
2236 | 2317 | |
2237 | 2318 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
2238 | 2319 | } |
@@ -2242,13 +2323,15 @@ discard block |
||
2242 | 2323 | if (is_array($_SESSION['errors'])) |
2243 | 2324 | { |
2244 | 2325 | $errors = array(); |
2245 | - if (!empty($_SESSION['errors']['dir'])) |
|
2246 | - foreach ($_SESSION['errors']['dir'] as $error) |
|
2326 | + if (!empty($_SESSION['errors']['dir'])) { |
|
2327 | + foreach ($_SESSION['errors']['dir'] as $error) |
|
2247 | 2328 | $errors['dir'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
2329 | + } |
|
2248 | 2330 | |
2249 | - if (!empty($_SESSION['errors']['base'])) |
|
2250 | - foreach ($_SESSION['errors']['base'] as $error) |
|
2331 | + if (!empty($_SESSION['errors']['base'])) { |
|
2332 | + foreach ($_SESSION['errors']['base'] as $error) |
|
2251 | 2333 | $errors['base'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
2334 | + } |
|
2252 | 2335 | } |
2253 | 2336 | unset($_SESSION['errors']); |
2254 | 2337 | } |
@@ -2458,8 +2541,9 @@ discard block |
||
2458 | 2541 | foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
2459 | 2542 | { |
2460 | 2543 | // If there aren't any attachments in this directory this won't exist. |
2461 | - if (!isset($expected_files[$id])) |
|
2462 | - $expected_files[$id] = 0; |
|
2544 | + if (!isset($expected_files[$id])) { |
|
2545 | + $expected_files[$id] = 0; |
|
2546 | + } |
|
2463 | 2547 | |
2464 | 2548 | // Check if the directory is doing okay. |
2465 | 2549 | list ($status, $error, $files) = attachDirStatus($dir, $expected_files[$id]); |
@@ -2472,10 +2556,11 @@ discard block |
||
2472 | 2556 | $is_base_dir = in_array($dir, $modSettings['attachment_basedirectories']); |
2473 | 2557 | |
2474 | 2558 | // Count any sub-folders. |
2475 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
2476 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
2559 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
2560 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
2477 | 2561 | { |
2478 | 2562 | $expected_files[$id]++; |
2563 | + } |
|
2479 | 2564 | $sub_dirs++; |
2480 | 2565 | } |
2481 | 2566 | } |
@@ -2493,8 +2578,8 @@ discard block |
||
2493 | 2578 | } |
2494 | 2579 | |
2495 | 2580 | // Just stick a new directory on at the bottom. |
2496 | - if (isset($_REQUEST['new_path'])) |
|
2497 | - $attachdirs[] = array( |
|
2581 | + if (isset($_REQUEST['new_path'])) { |
|
2582 | + $attachdirs[] = array( |
|
2498 | 2583 | 'id' => max(array_merge(array_keys($expected_files), array_keys($modSettings['attachmentUploadDir']))) + 1, |
2499 | 2584 | 'current' => false, |
2500 | 2585 | 'path' => '', |
@@ -2502,6 +2587,7 @@ discard block |
||
2502 | 2587 | 'num_files' => '', |
2503 | 2588 | 'status' => '', |
2504 | 2589 | ); |
2590 | + } |
|
2505 | 2591 | |
2506 | 2592 | return $attachdirs; |
2507 | 2593 | } |
@@ -2514,8 +2600,9 @@ discard block |
||
2514 | 2600 | { |
2515 | 2601 | global $modSettings, $txt; |
2516 | 2602 | |
2517 | - if (empty($modSettings['attachment_basedirectories'])) |
|
2518 | - return; |
|
2603 | + if (empty($modSettings['attachment_basedirectories'])) { |
|
2604 | + return; |
|
2605 | + } |
|
2519 | 2606 | |
2520 | 2607 | $basedirs = array(); |
2521 | 2608 | // Get a list of the base directories. |
@@ -2523,16 +2610,18 @@ discard block |
||
2523 | 2610 | { |
2524 | 2611 | // Loop through the attach directory array to count any sub-directories |
2525 | 2612 | $expected_dirs = 0; |
2526 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
2527 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
2613 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
2614 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
2528 | 2615 | $expected_dirs++; |
2616 | + } |
|
2529 | 2617 | |
2530 | - if (!is_dir($dir)) |
|
2531 | - $status = 'does_not_exist'; |
|
2532 | - elseif (!is_writeable($dir)) |
|
2533 | - $status = 'not_writable'; |
|
2534 | - else |
|
2535 | - $status = 'ok'; |
|
2618 | + if (!is_dir($dir)) { |
|
2619 | + $status = 'does_not_exist'; |
|
2620 | + } elseif (!is_writeable($dir)) { |
|
2621 | + $status = 'not_writable'; |
|
2622 | + } else { |
|
2623 | + $status = 'ok'; |
|
2624 | + } |
|
2536 | 2625 | |
2537 | 2626 | $basedirs[] = array( |
2538 | 2627 | 'id' => $id, |
@@ -2543,14 +2632,15 @@ discard block |
||
2543 | 2632 | ); |
2544 | 2633 | } |
2545 | 2634 | |
2546 | - if (isset($_REQUEST['new_base_path'])) |
|
2547 | - $basedirs[] = array( |
|
2635 | + if (isset($_REQUEST['new_base_path'])) { |
|
2636 | + $basedirs[] = array( |
|
2548 | 2637 | 'id' => '', |
2549 | 2638 | 'current' => false, |
2550 | 2639 | 'path' => '<input type="text" name="new_base_dir" value="" size="40">', |
2551 | 2640 | 'num_dirs' => '', |
2552 | 2641 | 'status' => '', |
2553 | 2642 | ); |
2643 | + } |
|
2554 | 2644 | |
2555 | 2645 | return $basedirs; |
2556 | 2646 | } |
@@ -2566,10 +2656,11 @@ discard block |
||
2566 | 2656 | */ |
2567 | 2657 | function attachDirStatus($dir, $expected_files) |
2568 | 2658 | { |
2569 | - if (!is_dir($dir)) |
|
2570 | - return array('does_not_exist', true, ''); |
|
2571 | - elseif (!is_writable($dir)) |
|
2572 | - return array('not_writable', true, ''); |
|
2659 | + if (!is_dir($dir)) { |
|
2660 | + return array('does_not_exist', true, ''); |
|
2661 | + } elseif (!is_writable($dir)) { |
|
2662 | + return array('not_writable', true, ''); |
|
2663 | + } |
|
2573 | 2664 | |
2574 | 2665 | // Everything is okay so far, start to scan through the directory. |
2575 | 2666 | $num_files = 0; |
@@ -2577,22 +2668,26 @@ discard block |
||
2577 | 2668 | while ($file = $dir_handle->read()) |
2578 | 2669 | { |
2579 | 2670 | // Now do we have a real file here? |
2580 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
2581 | - continue; |
|
2671 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
2672 | + continue; |
|
2673 | + } |
|
2582 | 2674 | |
2583 | 2675 | $num_files++; |
2584 | 2676 | } |
2585 | 2677 | $dir_handle->close(); |
2586 | 2678 | |
2587 | - if ($num_files < $expected_files) |
|
2588 | - return array('files_missing', true, $num_files); |
|
2679 | + if ($num_files < $expected_files) { |
|
2680 | + return array('files_missing', true, $num_files); |
|
2681 | + } |
|
2589 | 2682 | // Empty? |
2590 | - elseif ($expected_files == 0) |
|
2591 | - return array('unused', false, $num_files); |
|
2683 | + elseif ($expected_files == 0) { |
|
2684 | + return array('unused', false, $num_files); |
|
2685 | + } |
|
2592 | 2686 | // All good! |
2593 | - else |
|
2594 | - return array('ok', false, $num_files); |
|
2595 | -} |
|
2687 | + else { |
|
2688 | + return array('ok', false, $num_files); |
|
2689 | + } |
|
2690 | + } |
|
2596 | 2691 | |
2597 | 2692 | /** |
2598 | 2693 | * Maintance function to move attachments from one directory to another |
@@ -2604,10 +2699,11 @@ discard block |
||
2604 | 2699 | checkSession(); |
2605 | 2700 | |
2606 | 2701 | $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
2607 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
2608 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
2609 | - else |
|
2610 | - $modSettings['basedirectory_for_attachments'] = array(); |
|
2702 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
2703 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
2704 | + } else { |
|
2705 | + $modSettings['basedirectory_for_attachments'] = array(); |
|
2706 | + } |
|
2611 | 2707 | |
2612 | 2708 | $_POST['from'] = (int) $_POST['from']; |
2613 | 2709 | $_POST['auto'] = !empty($_POST['auto']) ? (int) $_POST['auto'] : 0; |
@@ -2621,11 +2717,13 @@ discard block |
||
2621 | 2717 | $total_moved = 0; |
2622 | 2718 | $total_not_moved = 0; |
2623 | 2719 | |
2624 | - if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) |
|
2625 | - $results[] = $txt['attachment_transfer_no_dir']; |
|
2720 | + if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) { |
|
2721 | + $results[] = $txt['attachment_transfer_no_dir']; |
|
2722 | + } |
|
2626 | 2723 | |
2627 | - if ($_POST['from'] == $_POST['to']) |
|
2628 | - $results[] = $txt['attachment_transfer_same_dir']; |
|
2724 | + if ($_POST['from'] == $_POST['to']) { |
|
2725 | + $results[] = $txt['attachment_transfer_same_dir']; |
|
2726 | + } |
|
2629 | 2727 | |
2630 | 2728 | if (empty($results)) |
2631 | 2729 | { |
@@ -2644,8 +2742,9 @@ discard block |
||
2644 | 2742 | $smcFunc['db_free_result']($request); |
2645 | 2743 | $total_progress -= $start; |
2646 | 2744 | |
2647 | - if ($total_progress < 1) |
|
2648 | - $results[] = $txt['attachment_transfer_no_find']; |
|
2745 | + if ($total_progress < 1) { |
|
2746 | + $results[] = $txt['attachment_transfer_no_find']; |
|
2747 | + } |
|
2649 | 2748 | } |
2650 | 2749 | |
2651 | 2750 | if (empty($results)) |
@@ -2661,9 +2760,9 @@ discard block |
||
2661 | 2760 | |
2662 | 2761 | automanage_attachments_check_directory(); |
2663 | 2762 | $new_dir = $modSettings['currentAttachmentUploadDir']; |
2763 | + } else { |
|
2764 | + $new_dir = $_POST['to']; |
|
2664 | 2765 | } |
2665 | - else |
|
2666 | - $new_dir = $_POST['to']; |
|
2667 | 2766 | |
2668 | 2767 | $modSettings['currentAttachmentUploadDir'] = $new_dir; |
2669 | 2768 | |
@@ -2671,8 +2770,9 @@ discard block |
||
2671 | 2770 | while ($break == false) |
2672 | 2771 | { |
2673 | 2772 | @set_time_limit(300); |
2674 | - if (function_exists('apache_reset_timeout')) |
|
2675 | - @apache_reset_timeout(); |
|
2773 | + if (function_exists('apache_reset_timeout')) { |
|
2774 | + @apache_reset_timeout(); |
|
2775 | + } |
|
2676 | 2776 | |
2677 | 2777 | // If limits are set, get the file count and size for the destination folder |
2678 | 2778 | if ($dir_files <= 0 && (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit']))) |
@@ -2708,13 +2808,15 @@ discard block |
||
2708 | 2808 | |
2709 | 2809 | if ($smcFunc['db_num_rows']($request) === 0) |
2710 | 2810 | { |
2711 | - if (empty($current_progress)) |
|
2712 | - $results[] = $txt['attachment_transfer_no_find']; |
|
2811 | + if (empty($current_progress)) { |
|
2812 | + $results[] = $txt['attachment_transfer_no_find']; |
|
2813 | + } |
|
2713 | 2814 | break; |
2714 | 2815 | } |
2715 | 2816 | |
2716 | - if ($smcFunc['db_num_rows']($request) < $limit) |
|
2717 | - $break = true; |
|
2817 | + if ($smcFunc['db_num_rows']($request) < $limit) { |
|
2818 | + $break = true; |
|
2819 | + } |
|
2718 | 2820 | |
2719 | 2821 | // Move them |
2720 | 2822 | $moved = array(); |
@@ -2738,8 +2840,9 @@ discard block |
||
2738 | 2840 | automanage_attachments_by_space(); |
2739 | 2841 | |
2740 | 2842 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
2741 | - if (!empty($total_not_moved)) |
|
2742 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
2843 | + if (!empty($total_not_moved)) { |
|
2844 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
2845 | + } |
|
2743 | 2846 | |
2744 | 2847 | $dir_files = 0; |
2745 | 2848 | $total_moved = 0; |
@@ -2747,8 +2850,7 @@ discard block |
||
2747 | 2850 | |
2748 | 2851 | $break = false; |
2749 | 2852 | break; |
2750 | - } |
|
2751 | - else |
|
2853 | + } else |
|
2752 | 2854 | { |
2753 | 2855 | // Hmm, not in auto. Time to bail out then... |
2754 | 2856 | $results[] = $txt['attachment_transfer_no_room']; |
@@ -2763,9 +2865,9 @@ discard block |
||
2763 | 2865 | $total_moved++; |
2764 | 2866 | $current_progress++; |
2765 | 2867 | $moved[] = $row['id_attach']; |
2868 | + } else { |
|
2869 | + $total_not_moved++; |
|
2766 | 2870 | } |
2767 | - else |
|
2768 | - $total_not_moved++; |
|
2769 | 2871 | } |
2770 | 2872 | $smcFunc['db_free_result']($request); |
2771 | 2873 | |
@@ -2803,13 +2905,15 @@ discard block |
||
2803 | 2905 | } |
2804 | 2906 | |
2805 | 2907 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
2806 | - if (!empty($total_not_moved)) |
|
2807 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
2908 | + if (!empty($total_not_moved)) { |
|
2909 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
2910 | + } |
|
2808 | 2911 | } |
2809 | 2912 | |
2810 | 2913 | $_SESSION['results'] = $results; |
2811 | - if (file_exists($boarddir . '/progress.php')) |
|
2812 | - unlink($boarddir . '/progress.php'); |
|
2914 | + if (file_exists($boarddir . '/progress.php')) { |
|
2915 | + unlink($boarddir . '/progress.php'); |
|
2916 | + } |
|
2813 | 2917 | |
2814 | 2918 | redirectexit('action=admin;area=manageattachments;sa=maintenance#transfer'); |
2815 | 2919 | } |
@@ -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 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | } |
46 | 47 | |
47 | 48 | // Not allowed sort method? Bang! Error! |
48 | - elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) |
|
49 | - trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
49 | + elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) { |
|
50 | + trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | // Initialize the array that'll be returned later on. |
52 | 54 | $membersOnlineStats = array( |
@@ -63,8 +65,9 @@ discard block |
||
63 | 65 | // Get any spiders if enabled. |
64 | 66 | $spiders = array(); |
65 | 67 | $spider_finds = array(); |
66 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
67 | - $spiders = smf_json_decode($modSettings['spider_name_cache'], true); |
|
68 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
69 | + $spiders = smf_json_decode($modSettings['spider_name_cache'], true); |
|
70 | + } |
|
68 | 71 | |
69 | 72 | // Load the users online right now. |
70 | 73 | $request = $smcFunc['db_query']('', ' |
@@ -92,9 +95,7 @@ discard block |
||
92 | 95 | $membersOnlineStats['num_guests']++; |
93 | 96 | |
94 | 97 | continue; |
95 | - } |
|
96 | - |
|
97 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
98 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
98 | 99 | { |
99 | 100 | // Just increase the stats and don't add this hidden user to any list. |
100 | 101 | $membersOnlineStats['num_users_hidden']++; |
@@ -102,10 +103,11 @@ discard block |
||
102 | 103 | } |
103 | 104 | |
104 | 105 | // Some basic color coding... |
105 | - if (!empty($row['online_color'])) |
|
106 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
107 | - else |
|
108 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
106 | + if (!empty($row['online_color'])) { |
|
107 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
108 | + } else { |
|
109 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
110 | + } |
|
109 | 111 | |
110 | 112 | // Buddies get counted and highlighted. |
111 | 113 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -132,12 +134,13 @@ discard block |
||
132 | 134 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
133 | 135 | |
134 | 136 | // Store all distinct (primary) membergroups that are shown. |
135 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
136 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
137 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
138 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
137 | 139 | 'id' => $row['id_group'], |
138 | 140 | 'name' => $row['group_name'], |
139 | 141 | 'color' => $row['online_color'] |
140 | 142 | ); |
143 | + } |
|
141 | 144 | } |
142 | 145 | $smcFunc['db_free_result']($request); |
143 | 146 | |
@@ -198,11 +201,12 @@ discard block |
||
198 | 201 | $settingsToUpdate = array(); |
199 | 202 | |
200 | 203 | // More members on now than ever were? Update it! |
201 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
202 | - $settingsToUpdate = array( |
|
204 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
205 | + $settingsToUpdate = array( |
|
203 | 206 | 'mostOnline' => $total_users_online, |
204 | 207 | 'mostDate' => time() |
205 | 208 | ); |
209 | + } |
|
206 | 210 | |
207 | 211 | $date = strftime('%Y-%m-%d', forum_time(false)); |
208 | 212 | |
@@ -234,8 +238,9 @@ discard block |
||
234 | 238 | { |
235 | 239 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
236 | 240 | |
237 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
238 | - trackStats(array('most_on' => $total_users_online)); |
|
241 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
242 | + trackStats(array('most_on' => $total_users_online)); |
|
243 | + } |
|
239 | 244 | |
240 | 245 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
241 | 246 | } |
@@ -252,8 +257,9 @@ discard block |
||
252 | 257 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
253 | 258 | } |
254 | 259 | |
255 | - if (!empty($settingsToUpdate)) |
|
256 | - updateSettings($settingsToUpdate); |
|
257 | -} |
|
260 | + if (!empty($settingsToUpdate)) { |
|
261 | + updateSettings($settingsToUpdate); |
|
262 | + } |
|
263 | + } |
|
258 | 264 | |
259 | 265 | ?> |
260 | 266 | \ No newline at end of file |
@@ -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 | * Mark a board or multiple boards read. |
@@ -28,14 +29,16 @@ discard block |
||
28 | 29 | global $user_info, $modSettings, $smcFunc; |
29 | 30 | |
30 | 31 | // Force $boards to be an array. |
31 | - if (!is_array($boards)) |
|
32 | - $boards = array($boards); |
|
33 | - else |
|
34 | - $boards = array_unique($boards); |
|
32 | + if (!is_array($boards)) { |
|
33 | + $boards = array($boards); |
|
34 | + } else { |
|
35 | + $boards = array_unique($boards); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // No boards, nothing to mark as read. |
37 | - if (empty($boards)) |
|
38 | - return; |
|
39 | + if (empty($boards)) { |
|
40 | + return; |
|
41 | + } |
|
39 | 42 | |
40 | 43 | // Allow the user to mark a board as unread. |
41 | 44 | if ($unread) |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | else |
66 | 69 | { |
67 | 70 | $markRead = array(); |
68 | - foreach ($boards as $board) |
|
69 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
71 | + foreach ($boards as $board) { |
|
72 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
73 | + } |
|
70 | 74 | |
71 | 75 | // Update log_mark_read and log_boards. |
72 | 76 | $smcFunc['db_insert']('replace', |
@@ -99,8 +103,9 @@ discard block |
||
99 | 103 | list ($lowest_topic) = $smcFunc['db_fetch_row']($result); |
100 | 104 | $smcFunc['db_free_result']($result); |
101 | 105 | |
102 | - if (empty($lowest_topic)) |
|
103 | - return; |
|
106 | + if (empty($lowest_topic)) { |
|
107 | + return; |
|
108 | + } |
|
104 | 109 | |
105 | 110 | // @todo SLOW This query seems to eat it sometimes. |
106 | 111 | $result = $smcFunc['db_query']('', ' |
@@ -118,12 +123,13 @@ discard block |
||
118 | 123 | ) |
119 | 124 | ); |
120 | 125 | $topics = array(); |
121 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
122 | - $topics[] = $row['id_topic']; |
|
126 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
127 | + $topics[] = $row['id_topic']; |
|
128 | + } |
|
123 | 129 | $smcFunc['db_free_result']($result); |
124 | 130 | |
125 | - if (!empty($topics)) |
|
126 | - $smcFunc['db_query']('', ' |
|
131 | + if (!empty($topics)) { |
|
132 | + $smcFunc['db_query']('', ' |
|
127 | 133 | DELETE FROM {db_prefix}log_topics |
128 | 134 | WHERE id_member = {int:current_member} |
129 | 135 | AND id_topic IN ({array_int:topic_list})', |
@@ -132,7 +138,8 @@ discard block |
||
132 | 138 | 'topic_list' => $topics, |
133 | 139 | ) |
134 | 140 | ); |
135 | -} |
|
141 | + } |
|
142 | + } |
|
136 | 143 | |
137 | 144 | /** |
138 | 145 | * Mark one or more boards as read. |
@@ -157,23 +164,26 @@ discard block |
||
157 | 164 | ) |
158 | 165 | ); |
159 | 166 | $boards = array(); |
160 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
161 | - $boards[] = $row['id_board']; |
|
167 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
168 | + $boards[] = $row['id_board']; |
|
169 | + } |
|
162 | 170 | $smcFunc['db_free_result']($result); |
163 | 171 | |
164 | - if (!empty($boards)) |
|
165 | - markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
172 | + if (!empty($boards)) { |
|
173 | + markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
174 | + } |
|
166 | 175 | |
167 | 176 | $_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID']; |
168 | - if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) |
|
169 | - redirectexit('action=unread'); |
|
177 | + if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) { |
|
178 | + redirectexit('action=unread'); |
|
179 | + } |
|
170 | 180 | |
171 | - if (isset($_SESSION['topicseen_cache'])) |
|
172 | - $_SESSION['topicseen_cache'] = array(); |
|
181 | + if (isset($_SESSION['topicseen_cache'])) { |
|
182 | + $_SESSION['topicseen_cache'] = array(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | redirectexit(); |
175 | - } |
|
176 | - elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
186 | + } elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
177 | 187 | { |
178 | 188 | // Make sure all the topics are integers! |
179 | 189 | $topics = array_map('intval', explode('-', $_REQUEST['topics'])); |
@@ -189,13 +199,15 @@ discard block |
||
189 | 199 | ) |
190 | 200 | ); |
191 | 201 | $logged_topics = array(); |
192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
193 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
203 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
204 | + } |
|
194 | 205 | $smcFunc['db_free_result']($request); |
195 | 206 | |
196 | 207 | $markRead = array(); |
197 | - foreach ($topics as $id_topic) |
|
198 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
208 | + foreach ($topics as $id_topic) { |
|
209 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
210 | + } |
|
199 | 211 | |
200 | 212 | $smcFunc['db_insert']('replace', |
201 | 213 | '{db_prefix}log_topics', |
@@ -204,8 +216,9 @@ discard block |
||
204 | 216 | array('id_member', 'id_topic') |
205 | 217 | ); |
206 | 218 | |
207 | - if (isset($_SESSION['topicseen_cache'])) |
|
208 | - $_SESSION['topicseen_cache'] = array(); |
|
219 | + if (isset($_SESSION['topicseen_cache'])) { |
|
220 | + $_SESSION['topicseen_cache'] = array(); |
|
221 | + } |
|
209 | 222 | |
210 | 223 | redirectexit('action=unreadreplies'); |
211 | 224 | } |
@@ -230,11 +243,13 @@ discard block |
||
230 | 243 | if (!empty($_GET['t'])) |
231 | 244 | { |
232 | 245 | // If they read the whole topic, go back to the beginning. |
233 | - if ($_GET['t'] >= $topicinfo['id_last_msg']) |
|
234 | - $earlyMsg = 0; |
|
246 | + if ($_GET['t'] >= $topicinfo['id_last_msg']) { |
|
247 | + $earlyMsg = 0; |
|
248 | + } |
|
235 | 249 | // If they want to mark the whole thing read, same. |
236 | - elseif ($_GET['t'] <= $topicinfo['id_first_msg']) |
|
237 | - $earlyMsg = 0; |
|
250 | + elseif ($_GET['t'] <= $topicinfo['id_first_msg']) { |
|
251 | + $earlyMsg = 0; |
|
252 | + } |
|
238 | 253 | // Otherwise, get the latest message before the named one. |
239 | 254 | else |
240 | 255 | { |
@@ -255,9 +270,9 @@ discard block |
||
255 | 270 | } |
256 | 271 | } |
257 | 272 | // Marking read from first page? That's the whole topic. |
258 | - elseif ($_REQUEST['start'] == 0) |
|
259 | - $earlyMsg = 0; |
|
260 | - else |
|
273 | + elseif ($_REQUEST['start'] == 0) { |
|
274 | + $earlyMsg = 0; |
|
275 | + } else |
|
261 | 276 | { |
262 | 277 | $result = $smcFunc['db_query']('', ' |
263 | 278 | SELECT id_msg |
@@ -285,8 +300,7 @@ discard block |
||
285 | 300 | ); |
286 | 301 | |
287 | 302 | redirectexit('board=' . $board . '.0'); |
288 | - } |
|
289 | - else |
|
303 | + } else |
|
290 | 304 | { |
291 | 305 | $categories = array(); |
292 | 306 | $boards = array(); |
@@ -294,17 +308,20 @@ discard block |
||
294 | 308 | if (isset($_REQUEST['c'])) |
295 | 309 | { |
296 | 310 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
297 | - foreach ($_REQUEST['c'] as $c) |
|
298 | - $categories[] = (int) $c; |
|
311 | + foreach ($_REQUEST['c'] as $c) { |
|
312 | + $categories[] = (int) $c; |
|
313 | + } |
|
299 | 314 | } |
300 | 315 | if (isset($_REQUEST['boards'])) |
301 | 316 | { |
302 | 317 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
303 | - foreach ($_REQUEST['boards'] as $b) |
|
304 | - $boards[] = (int) $b; |
|
318 | + foreach ($_REQUEST['boards'] as $b) { |
|
319 | + $boards[] = (int) $b; |
|
320 | + } |
|
321 | + } |
|
322 | + if (!empty($board)) { |
|
323 | + $boards[] = (int) $board; |
|
305 | 324 | } |
306 | - if (!empty($board)) |
|
307 | - $boards[] = (int) $board; |
|
308 | 325 | |
309 | 326 | if (isset($_REQUEST['children']) && !empty($boards)) |
310 | 327 | { |
@@ -324,9 +341,10 @@ discard block |
||
324 | 341 | 'board_list' => $boards, |
325 | 342 | ) |
326 | 343 | ); |
327 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
328 | - if (in_array($row['id_parent'], $boards)) |
|
344 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
345 | + if (in_array($row['id_parent'], $boards)) |
|
329 | 346 | $boards[] = $row['id_board']; |
347 | + } |
|
330 | 348 | $smcFunc['db_free_result']($request); |
331 | 349 | } |
332 | 350 | |
@@ -343,8 +361,9 @@ discard block |
||
343 | 361 | $clauseParameters['board_list'] = $boards; |
344 | 362 | } |
345 | 363 | |
346 | - if (empty($clauses)) |
|
347 | - redirectexit(); |
|
364 | + if (empty($clauses)) { |
|
365 | + redirectexit(); |
|
366 | + } |
|
348 | 367 | |
349 | 368 | $request = $smcFunc['db_query']('', ' |
350 | 369 | SELECT b.id_board |
@@ -355,19 +374,22 @@ discard block |
||
355 | 374 | )) |
356 | 375 | ); |
357 | 376 | $boards = array(); |
358 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
359 | - $boards[] = $row['id_board']; |
|
377 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
378 | + $boards[] = $row['id_board']; |
|
379 | + } |
|
360 | 380 | $smcFunc['db_free_result']($request); |
361 | 381 | |
362 | - if (empty($boards)) |
|
363 | - redirectexit(); |
|
382 | + if (empty($boards)) { |
|
383 | + redirectexit(); |
|
384 | + } |
|
364 | 385 | |
365 | 386 | markBoardsRead($boards, isset($_REQUEST['unread'])); |
366 | 387 | |
367 | 388 | foreach ($boards as $b) |
368 | 389 | { |
369 | - if (isset($_SESSION['topicseen_cache'][$b])) |
|
370 | - $_SESSION['topicseen_cache'][$b] = array(); |
|
390 | + if (isset($_SESSION['topicseen_cache'][$b])) { |
|
391 | + $_SESSION['topicseen_cache'][$b] = array(); |
|
392 | + } |
|
371 | 393 | } |
372 | 394 | |
373 | 395 | if (!isset($_REQUEST['unread'])) |
@@ -385,8 +407,9 @@ discard block |
||
385 | 407 | if ($smcFunc['db_num_rows']($result) > 0) |
386 | 408 | { |
387 | 409 | $logBoardInserts = array(); |
388 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
389 | - $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
410 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
411 | + $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
412 | + } |
|
390 | 413 | |
391 | 414 | $smcFunc['db_insert']('replace', |
392 | 415 | '{db_prefix}log_boards', |
@@ -397,17 +420,18 @@ discard block |
||
397 | 420 | } |
398 | 421 | $smcFunc['db_free_result']($result); |
399 | 422 | |
400 | - if (empty($board)) |
|
401 | - redirectexit(); |
|
402 | - else |
|
403 | - redirectexit('board=' . $board . '.0'); |
|
404 | - } |
|
405 | - else |
|
423 | + if (empty($board)) { |
|
424 | + redirectexit(); |
|
425 | + } else { |
|
426 | + redirectexit('board=' . $board . '.0'); |
|
427 | + } |
|
428 | + } else |
|
406 | 429 | { |
407 | - if (empty($board_info['parent'])) |
|
408 | - redirectexit(); |
|
409 | - else |
|
410 | - redirectexit('board=' . $board_info['parent'] . '.0'); |
|
430 | + if (empty($board_info['parent'])) { |
|
431 | + redirectexit(); |
|
432 | + } else { |
|
433 | + redirectexit('board=' . $board_info['parent'] . '.0'); |
|
434 | + } |
|
411 | 435 | } |
412 | 436 | } |
413 | 437 | } |
@@ -432,11 +456,13 @@ discard block |
||
432 | 456 | 'selected_message' => (int) $messageID, |
433 | 457 | ) |
434 | 458 | ); |
435 | - if ($smcFunc['db_num_rows']($result) > 0) |
|
436 | - list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
459 | + if ($smcFunc['db_num_rows']($result) > 0) { |
|
460 | + list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
461 | + } |
|
437 | 462 | // The message doesn't even exist. |
438 | - else |
|
439 | - $memberID = 0; |
|
463 | + else { |
|
464 | + $memberID = 0; |
|
465 | + } |
|
440 | 466 | $smcFunc['db_free_result']($result); |
441 | 467 | |
442 | 468 | return (int) $memberID; |
@@ -457,8 +483,9 @@ discard block |
||
457 | 483 | getBoardTree(); |
458 | 484 | |
459 | 485 | // Make sure given boards and categories exist. |
460 | - if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) |
|
461 | - fatal_lang_error('no_board'); |
|
486 | + if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) { |
|
487 | + fatal_lang_error('no_board'); |
|
488 | + } |
|
462 | 489 | |
463 | 490 | $id = $board_id; |
464 | 491 | call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions)); |
@@ -486,8 +513,9 @@ discard block |
||
486 | 513 | $child_level = 0; |
487 | 514 | $id_parent = 0; |
488 | 515 | $after = 0; |
489 | - foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) |
|
490 | - $after = max($after, $boards[$id_board]['order']); |
|
516 | + foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) { |
|
517 | + $after = max($after, $boards[$id_board]['order']); |
|
518 | + } |
|
491 | 519 | } |
492 | 520 | |
493 | 521 | // Make the board a child of a given board. |
@@ -498,17 +526,19 @@ discard block |
||
498 | 526 | $id_parent = $boardOptions['target_board']; |
499 | 527 | |
500 | 528 | // People can be creative, in many ways... |
501 | - if (isChildOf($id_parent, $board_id)) |
|
502 | - fatal_lang_error('mboards_parent_own_child_error', false); |
|
503 | - elseif ($id_parent == $board_id) |
|
504 | - fatal_lang_error('mboards_board_own_child_error', false); |
|
529 | + if (isChildOf($id_parent, $board_id)) { |
|
530 | + fatal_lang_error('mboards_parent_own_child_error', false); |
|
531 | + } elseif ($id_parent == $board_id) { |
|
532 | + fatal_lang_error('mboards_board_own_child_error', false); |
|
533 | + } |
|
505 | 534 | |
506 | 535 | $after = $boards[$boardOptions['target_board']]['order']; |
507 | 536 | |
508 | 537 | // Check if there are already children and (if so) get the max board order. |
509 | - if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) |
|
510 | - foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
538 | + if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) { |
|
539 | + foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
511 | 540 | $after = max($after, $boards[$childBoard_id]['order']); |
541 | + } |
|
512 | 542 | } |
513 | 543 | |
514 | 544 | // Place a board before or after another board, on the same child level. |
@@ -521,8 +551,9 @@ discard block |
||
521 | 551 | } |
522 | 552 | |
523 | 553 | // Oops...? |
524 | - else |
|
525 | - trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
554 | + else { |
|
555 | + trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
556 | + } |
|
526 | 557 | |
527 | 558 | // Get a list of children of this board. |
528 | 559 | $childList = array(); |
@@ -531,14 +562,16 @@ discard block |
||
531 | 562 | // See if there are changes that affect children. |
532 | 563 | $childUpdates = array(); |
533 | 564 | $levelDiff = $child_level - $boards[$board_id]['level']; |
534 | - if ($levelDiff != 0) |
|
535 | - $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
536 | - if ($id_cat != $boards[$board_id]['category']) |
|
537 | - $childUpdates[] = 'id_cat = {int:category}'; |
|
565 | + if ($levelDiff != 0) { |
|
566 | + $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
567 | + } |
|
568 | + if ($id_cat != $boards[$board_id]['category']) { |
|
569 | + $childUpdates[] = 'id_cat = {int:category}'; |
|
570 | + } |
|
538 | 571 | |
539 | 572 | // Fix the children of this board. |
540 | - if (!empty($childList) && !empty($childUpdates)) |
|
541 | - $smcFunc['db_query']('', ' |
|
573 | + if (!empty($childList) && !empty($childUpdates)) { |
|
574 | + $smcFunc['db_query']('', ' |
|
542 | 575 | UPDATE {db_prefix}boards |
543 | 576 | SET ' . implode(', |
544 | 577 | ', $childUpdates) . ' |
@@ -549,6 +582,7 @@ discard block |
||
549 | 582 | 'level_diff' => $levelDiff, |
550 | 583 | ) |
551 | 584 | ); |
585 | + } |
|
552 | 586 | |
553 | 587 | // Make some room for this spot. |
554 | 588 | $smcFunc['db_query']('', ' |
@@ -644,8 +678,8 @@ discard block |
||
644 | 678 | call_integration_hook('integrate_modify_board', array($id, $boardOptions, &$boardUpdates, &$boardUpdateParameters)); |
645 | 679 | |
646 | 680 | // Do the updates (if any). |
647 | - if (!empty($boardUpdates)) |
|
648 | - $smcFunc['db_query']('', ' |
|
681 | + if (!empty($boardUpdates)) { |
|
682 | + $smcFunc['db_query']('', ' |
|
649 | 683 | UPDATE {db_prefix}boards |
650 | 684 | SET |
651 | 685 | ' . implode(', |
@@ -655,6 +689,7 @@ discard block |
||
655 | 689 | 'selected_board' => $board_id, |
656 | 690 | )) |
657 | 691 | ); |
692 | + } |
|
658 | 693 | |
659 | 694 | // Set moderators of this board. |
660 | 695 | if (isset($boardOptions['moderators']) || isset($boardOptions['moderator_string']) || isset($boardOptions['moderator_groups']) || isset($boardOptions['moderator_group_string'])) |
@@ -679,13 +714,15 @@ discard block |
||
679 | 714 | { |
680 | 715 | $moderators[$k] = trim($moderators[$k]); |
681 | 716 | |
682 | - if (strlen($moderators[$k]) == 0) |
|
683 | - unset($moderators[$k]); |
|
717 | + if (strlen($moderators[$k]) == 0) { |
|
718 | + unset($moderators[$k]); |
|
719 | + } |
|
684 | 720 | } |
685 | 721 | |
686 | 722 | // Find all the id_member's for the member_name's in the list. |
687 | - if (empty($boardOptions['moderators'])) |
|
688 | - $boardOptions['moderators'] = array(); |
|
723 | + if (empty($boardOptions['moderators'])) { |
|
724 | + $boardOptions['moderators'] = array(); |
|
725 | + } |
|
689 | 726 | if (!empty($moderators)) |
690 | 727 | { |
691 | 728 | $request = $smcFunc['db_query']('', ' |
@@ -698,8 +735,9 @@ discard block |
||
698 | 735 | 'limit' => count($moderators), |
699 | 736 | ) |
700 | 737 | ); |
701 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
702 | - $boardOptions['moderators'][] = $row['id_member']; |
|
738 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
739 | + $boardOptions['moderators'][] = $row['id_member']; |
|
740 | + } |
|
703 | 741 | $smcFunc['db_free_result']($request); |
704 | 742 | } |
705 | 743 | } |
@@ -708,8 +746,9 @@ discard block |
||
708 | 746 | if (!empty($boardOptions['moderators'])) |
709 | 747 | { |
710 | 748 | $inserts = array(); |
711 | - foreach ($boardOptions['moderators'] as $moderator) |
|
712 | - $inserts[] = array($board_id, $moderator); |
|
749 | + foreach ($boardOptions['moderators'] as $moderator) { |
|
750 | + $inserts[] = array($board_id, $moderator); |
|
751 | + } |
|
713 | 752 | |
714 | 753 | $smcFunc['db_insert']('insert', |
715 | 754 | '{db_prefix}moderators', |
@@ -739,14 +778,16 @@ discard block |
||
739 | 778 | { |
740 | 779 | $moderator_groups[$k] = trim($moderator_groups[$k]); |
741 | 780 | |
742 | - if (strlen($moderator_groups[$k]) == 0) |
|
743 | - unset($moderator_groups[$k]); |
|
781 | + if (strlen($moderator_groups[$k]) == 0) { |
|
782 | + unset($moderator_groups[$k]); |
|
783 | + } |
|
744 | 784 | } |
745 | 785 | |
746 | 786 | /* Find all the id_group's for all the group names in the list |
747 | 787 | But skip any invalid ones (invisible/post groups/Administrator/Moderator) */ |
748 | - if (empty($boardOptions['moderator_groups'])) |
|
749 | - $boardOptions['moderator_groups'] = array(); |
|
788 | + if (empty($boardOptions['moderator_groups'])) { |
|
789 | + $boardOptions['moderator_groups'] = array(); |
|
790 | + } |
|
750 | 791 | if (!empty($moderator_groups)) |
751 | 792 | { |
752 | 793 | $request = $smcFunc['db_query']('', ' |
@@ -777,8 +818,9 @@ discard block |
||
777 | 818 | if (!empty($boardOptions['moderator_groups'])) |
778 | 819 | { |
779 | 820 | $inserts = array(); |
780 | - foreach ($boardOptions['moderator_groups'] as $moderator_group) |
|
781 | - $inserts[] = array($board_id, $moderator_group); |
|
821 | + foreach ($boardOptions['moderator_groups'] as $moderator_group) { |
|
822 | + $inserts[] = array($board_id, $moderator_group); |
|
823 | + } |
|
782 | 824 | |
783 | 825 | $smcFunc['db_insert']('insert', |
784 | 826 | '{db_prefix}moderator_groups', |
@@ -792,14 +834,16 @@ discard block |
||
792 | 834 | updateSettings(array('settings_updated' => time())); |
793 | 835 | } |
794 | 836 | |
795 | - if (isset($boardOptions['move_to'])) |
|
796 | - reorderBoards(); |
|
837 | + if (isset($boardOptions['move_to'])) { |
|
838 | + reorderBoards(); |
|
839 | + } |
|
797 | 840 | |
798 | 841 | clean_cache('data'); |
799 | 842 | |
800 | - if (empty($boardOptions['dont_log'])) |
|
801 | - logAction('edit_board', array('board' => $board_id), 'admin'); |
|
802 | -} |
|
843 | + if (empty($boardOptions['dont_log'])) { |
|
844 | + logAction('edit_board', array('board' => $board_id), 'admin'); |
|
845 | + } |
|
846 | + } |
|
803 | 847 | |
804 | 848 | /** |
805 | 849 | * Create a new board and set its properties and position. |
@@ -815,11 +859,13 @@ discard block |
||
815 | 859 | global $boards, $smcFunc; |
816 | 860 | |
817 | 861 | // Trigger an error if one of the required values is not set. |
818 | - if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) |
|
819 | - trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
862 | + if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) { |
|
863 | + trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
864 | + } |
|
820 | 865 | |
821 | - if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) |
|
822 | - trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
866 | + if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) { |
|
867 | + trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
868 | + } |
|
823 | 869 | |
824 | 870 | // Set every optional value to its default value. |
825 | 871 | $boardOptions += array( |
@@ -853,8 +899,9 @@ discard block |
||
853 | 899 | 1 |
854 | 900 | ); |
855 | 901 | |
856 | - if (empty($board_id)) |
|
857 | - return 0; |
|
902 | + if (empty($board_id)) { |
|
903 | + return 0; |
|
904 | + } |
|
858 | 905 | |
859 | 906 | // Change the board according to the given specifications. |
860 | 907 | modifyBoard($board_id, $boardOptions); |
@@ -917,8 +964,9 @@ discard block |
||
917 | 964 | global $sourcedir, $boards, $smcFunc; |
918 | 965 | |
919 | 966 | // No boards to delete? Return! |
920 | - if (empty($boards_to_remove)) |
|
921 | - return; |
|
967 | + if (empty($boards_to_remove)) { |
|
968 | + return; |
|
969 | + } |
|
922 | 970 | |
923 | 971 | getBoardTree(); |
924 | 972 | |
@@ -929,12 +977,14 @@ discard block |
||
929 | 977 | { |
930 | 978 | // Get a list of the child boards that will also be removed. |
931 | 979 | $child_boards_to_remove = array(); |
932 | - foreach ($boards_to_remove as $board_to_remove) |
|
933 | - recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
980 | + foreach ($boards_to_remove as $board_to_remove) { |
|
981 | + recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
982 | + } |
|
934 | 983 | |
935 | 984 | // Merge the children with their parents. |
936 | - if (!empty($child_boards_to_remove)) |
|
937 | - $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
985 | + if (!empty($child_boards_to_remove)) { |
|
986 | + $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
987 | + } |
|
938 | 988 | } |
939 | 989 | // Move the children to a safe home. |
940 | 990 | else |
@@ -942,10 +992,11 @@ discard block |
||
942 | 992 | foreach ($boards_to_remove as $id_board) |
943 | 993 | { |
944 | 994 | // @todo Separate category? |
945 | - if ($moveChildrenTo === 0) |
|
946 | - fixChildren($id_board, 0, 0); |
|
947 | - else |
|
948 | - fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
995 | + if ($moveChildrenTo === 0) { |
|
996 | + fixChildren($id_board, 0, 0); |
|
997 | + } else { |
|
998 | + fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
999 | + } |
|
949 | 1000 | } |
950 | 1001 | } |
951 | 1002 | |
@@ -959,8 +1010,9 @@ discard block |
||
959 | 1010 | ) |
960 | 1011 | ); |
961 | 1012 | $topics = array(); |
962 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
963 | - $topics[] = $row['id_topic']; |
|
1013 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1014 | + $topics[] = $row['id_topic']; |
|
1015 | + } |
|
964 | 1016 | $smcFunc['db_free_result']($request); |
965 | 1017 | |
966 | 1018 | require_once($sourcedir . '/RemoveTopic.php'); |
@@ -1048,8 +1100,9 @@ discard block |
||
1048 | 1100 | clean_cache('data'); |
1049 | 1101 | |
1050 | 1102 | // Let's do some serious logging. |
1051 | - foreach ($boards_to_remove as $id_board) |
|
1052 | - logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1103 | + foreach ($boards_to_remove as $id_board) { |
|
1104 | + logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1105 | + } |
|
1053 | 1106 | |
1054 | 1107 | reorderBoards(); |
1055 | 1108 | } |
@@ -1068,8 +1121,8 @@ discard block |
||
1068 | 1121 | $board_order = 0; |
1069 | 1122 | foreach ($cat_tree as $catID => $dummy) |
1070 | 1123 | { |
1071 | - foreach ($boardList[$catID] as $boardID) |
|
1072 | - if ($boards[$boardID]['order'] != ++$board_order) |
|
1124 | + foreach ($boardList[$catID] as $boardID) { |
|
1125 | + if ($boards[$boardID]['order'] != ++$board_order) |
|
1073 | 1126 | $smcFunc['db_query']('', ' |
1074 | 1127 | UPDATE {db_prefix}boards |
1075 | 1128 | SET board_order = {int:new_order} |
@@ -1079,6 +1132,7 @@ discard block |
||
1079 | 1132 | 'selected_board' => $boardID, |
1080 | 1133 | ) |
1081 | 1134 | ); |
1135 | + } |
|
1082 | 1136 | } |
1083 | 1137 | |
1084 | 1138 | // Empty the board order cache |
@@ -1107,8 +1161,9 @@ discard block |
||
1107 | 1161 | ) |
1108 | 1162 | ); |
1109 | 1163 | $children = array(); |
1110 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1111 | - $children[] = $row['id_board']; |
|
1164 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1165 | + $children[] = $row['id_board']; |
|
1166 | + } |
|
1112 | 1167 | $smcFunc['db_free_result']($result); |
1113 | 1168 | |
1114 | 1169 | // ...and set it to a new parent and child_level. |
@@ -1124,9 +1179,10 @@ discard block |
||
1124 | 1179 | ); |
1125 | 1180 | |
1126 | 1181 | // Recursively fix the children of the children. |
1127 | - foreach ($children as $child) |
|
1128 | - fixChildren($child, $newLevel + 1, $child); |
|
1129 | -} |
|
1182 | + foreach ($children as $child) { |
|
1183 | + fixChildren($child, $newLevel + 1, $child); |
|
1184 | + } |
|
1185 | + } |
|
1130 | 1186 | |
1131 | 1187 | /** |
1132 | 1188 | * Tries to load up the entire board order and category very very quickly |
@@ -1143,8 +1199,9 @@ discard block |
||
1143 | 1199 | 'boards' => array(), |
1144 | 1200 | ); |
1145 | 1201 | |
1146 | - if (!empty($tree_order['boards'])) |
|
1147 | - return $tree_order; |
|
1202 | + if (!empty($tree_order['boards'])) { |
|
1203 | + return $tree_order; |
|
1204 | + } |
|
1148 | 1205 | |
1149 | 1206 | if (($cached = cache_get_data('board_order', 86400)) !== null) |
1150 | 1207 | { |
@@ -1160,8 +1217,9 @@ discard block |
||
1160 | 1217 | ); |
1161 | 1218 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1162 | 1219 | { |
1163 | - if (!in_array($row['id_cat'], $tree_order['cats'])) |
|
1164 | - $tree_order['cats'][] = $row['id_cat']; |
|
1220 | + if (!in_array($row['id_cat'], $tree_order['cats'])) { |
|
1221 | + $tree_order['cats'][] = $row['id_cat']; |
|
1222 | + } |
|
1165 | 1223 | $tree_order['boards'][] = $row['id_board']; |
1166 | 1224 | } |
1167 | 1225 | $smcFunc['db_free_result']($request); |
@@ -1181,16 +1239,19 @@ discard block |
||
1181 | 1239 | $tree = getTreeOrder(); |
1182 | 1240 | |
1183 | 1241 | $ordered = array(); |
1184 | - foreach ($tree['boards'] as $board) |
|
1185 | - if (!empty($boards[$board])) |
|
1242 | + foreach ($tree['boards'] as $board) { |
|
1243 | + if (!empty($boards[$board])) |
|
1186 | 1244 | { |
1187 | 1245 | $ordered[$board] = $boards[$board]; |
1246 | + } |
|
1188 | 1247 | |
1189 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) |
|
1190 | - sortBoards($ordered[$board]['boards']); |
|
1248 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) { |
|
1249 | + sortBoards($ordered[$board]['boards']); |
|
1250 | + } |
|
1191 | 1251 | |
1192 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) |
|
1193 | - sortBoards($ordered[$board]['children']); |
|
1252 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) { |
|
1253 | + sortBoards($ordered[$board]['children']); |
|
1254 | + } |
|
1194 | 1255 | } |
1195 | 1256 | |
1196 | 1257 | $boards = $ordered; |
@@ -1206,12 +1267,14 @@ discard block |
||
1206 | 1267 | $tree = getTreeOrder(); |
1207 | 1268 | |
1208 | 1269 | $ordered = array(); |
1209 | - foreach ($tree['cats'] as $cat) |
|
1210 | - if (!empty($categories[$cat])) |
|
1270 | + foreach ($tree['cats'] as $cat) { |
|
1271 | + if (!empty($categories[$cat])) |
|
1211 | 1272 | { |
1212 | 1273 | $ordered[$cat] = $categories[$cat]; |
1213 | - if (!empty($ordered[$cat]['boards'])) |
|
1214 | - sortBoards($ordered[$cat]['boards']); |
|
1274 | + } |
|
1275 | + if (!empty($ordered[$cat]['boards'])) { |
|
1276 | + sortBoards($ordered[$cat]['boards']); |
|
1277 | + } |
|
1215 | 1278 | } |
1216 | 1279 | |
1217 | 1280 | $categories = $ordered; |
@@ -1227,8 +1290,9 @@ discard block |
||
1227 | 1290 | { |
1228 | 1291 | global $smcFunc, $scripturl, $txt; |
1229 | 1292 | |
1230 | - if (empty($boards)) |
|
1231 | - return array(); |
|
1293 | + if (empty($boards)) { |
|
1294 | + return array(); |
|
1295 | + } |
|
1232 | 1296 | |
1233 | 1297 | $request = $smcFunc['db_query']('', ' |
1234 | 1298 | SELECT mem.id_member, mem.real_name, mo.id_board |
@@ -1242,8 +1306,9 @@ discard block |
||
1242 | 1306 | $moderators = array(); |
1243 | 1307 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1244 | 1308 | { |
1245 | - if (empty($moderators[$row['id_board']])) |
|
1246 | - $moderators[$row['id_board']] = array(); |
|
1309 | + if (empty($moderators[$row['id_board']])) { |
|
1310 | + $moderators[$row['id_board']] = array(); |
|
1311 | + } |
|
1247 | 1312 | |
1248 | 1313 | $moderators[$row['id_board']][] = array( |
1249 | 1314 | 'id' => $row['id_member'], |
@@ -1267,8 +1332,9 @@ discard block |
||
1267 | 1332 | { |
1268 | 1333 | global $smcFunc, $scripturl, $txt; |
1269 | 1334 | |
1270 | - if (empty($boards)) |
|
1271 | - return array(); |
|
1335 | + if (empty($boards)) { |
|
1336 | + return array(); |
|
1337 | + } |
|
1272 | 1338 | |
1273 | 1339 | $request = $smcFunc['db_query']('', ' |
1274 | 1340 | SELECT mg.id_group, mg.group_name, bg.id_board |
@@ -1282,8 +1348,9 @@ discard block |
||
1282 | 1348 | $groups = array(); |
1283 | 1349 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1284 | 1350 | { |
1285 | - if (empty($groups[$row['id_board']])) |
|
1286 | - $groups[$row['id_board']] = array(); |
|
1351 | + if (empty($groups[$row['id_board']])) { |
|
1352 | + $groups[$row['id_board']] = array(); |
|
1353 | + } |
|
1287 | 1354 | |
1288 | 1355 | $groups[$row['id_board']][] = array( |
1289 | 1356 | 'id' => $row['id_group'], |
@@ -1358,8 +1425,9 @@ discard block |
||
1358 | 1425 | |
1359 | 1426 | if (!empty($row['id_board'])) |
1360 | 1427 | { |
1361 | - if ($row['child_level'] != $curLevel) |
|
1362 | - $prevBoard = 0; |
|
1428 | + if ($row['child_level'] != $curLevel) { |
|
1429 | + $prevBoard = 0; |
|
1430 | + } |
|
1363 | 1431 | |
1364 | 1432 | $boards[$row['id_board']] = array( |
1365 | 1433 | 'id' => $row['id_board'], |
@@ -1391,16 +1459,16 @@ discard block |
||
1391 | 1459 | 'children' => array() |
1392 | 1460 | ); |
1393 | 1461 | $boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']]; |
1394 | - } |
|
1395 | - else |
|
1462 | + } else |
|
1396 | 1463 | { |
1397 | 1464 | // Parent doesn't exist! |
1398 | - if (!isset($boards[$row['id_parent']]['tree'])) |
|
1399 | - fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1465 | + if (!isset($boards[$row['id_parent']]['tree'])) { |
|
1466 | + fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1467 | + } |
|
1400 | 1468 | |
1401 | 1469 | // Wrong childlevel...we can silently fix this... |
1402 | - if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) |
|
1403 | - $smcFunc['db_query']('', ' |
|
1470 | + if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) { |
|
1471 | + $smcFunc['db_query']('', ' |
|
1404 | 1472 | UPDATE {db_prefix}boards |
1405 | 1473 | SET child_level = {int:new_child_level} |
1406 | 1474 | WHERE id_board = {int:selected_board}', |
@@ -1409,6 +1477,7 @@ discard block |
||
1409 | 1477 | 'selected_board' => $row['id_board'], |
1410 | 1478 | ) |
1411 | 1479 | ); |
1480 | + } |
|
1412 | 1481 | |
1413 | 1482 | $boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array( |
1414 | 1483 | 'node' => &$boards[$row['id_board']], |
@@ -1442,8 +1511,9 @@ discard block |
||
1442 | 1511 | */ |
1443 | 1512 | function recursiveBoards(&$_boardList, &$_tree) |
1444 | 1513 | { |
1445 | - if (empty($_tree['children'])) |
|
1446 | - return; |
|
1514 | + if (empty($_tree['children'])) { |
|
1515 | + return; |
|
1516 | + } |
|
1447 | 1517 | |
1448 | 1518 | foreach ($_tree['children'] as $id => $node) |
1449 | 1519 | { |
@@ -1462,11 +1532,13 @@ discard block |
||
1462 | 1532 | { |
1463 | 1533 | global $boards; |
1464 | 1534 | |
1465 | - if (empty($boards[$child]['parent'])) |
|
1466 | - return false; |
|
1535 | + if (empty($boards[$child]['parent'])) { |
|
1536 | + return false; |
|
1537 | + } |
|
1467 | 1538 | |
1468 | - if ($boards[$child]['parent'] == $parent) |
|
1469 | - return true; |
|
1539 | + if ($boards[$child]['parent'] == $parent) { |
|
1540 | + return true; |
|
1541 | + } |
|
1470 | 1542 | |
1471 | 1543 | return isChildOf($boards[$child]['parent'], $parent); |
1472 | 1544 | } |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
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 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Updates a report with the given parameters. Logs each action via logAction() |
@@ -28,19 +29,20 @@ discard block |
||
28 | 29 | global $smcFunc, $user_info, $context; |
29 | 30 | |
30 | 31 | // Don't bother. |
31 | - if (empty($action) || empty($report_id)) |
|
32 | - return false; |
|
32 | + if (empty($action) || empty($report_id)) { |
|
33 | + return false; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | // Add the "_all" thingy. |
35 | - if ($action == 'ignore') |
|
36 | - $action = 'ignore_all'; |
|
37 | + if ($action == 'ignore') { |
|
38 | + $action = 'ignore_all'; |
|
39 | + } |
|
37 | 40 | |
38 | 41 | // We don't need the board query for reported members |
39 | 42 | if ($context['report_type'] == 'members') |
40 | 43 | { |
41 | 44 | $board_query = ''; |
42 | - } |
|
43 | - else |
|
45 | + } else |
|
44 | 46 | { |
45 | 47 | $board_query = ' AND ' . $user_info['mod_cache']['bq']; |
46 | 48 | } |
@@ -76,17 +78,17 @@ discard block |
||
76 | 78 | ) |
77 | 79 | ); |
78 | 80 | |
79 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
80 | - $extra[$row['id_report']] = array( |
|
81 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
82 | + $extra[$row['id_report']] = array( |
|
81 | 83 | 'report' => $row['id_report'], |
82 | 84 | 'board' => $row['id_board'], |
83 | 85 | 'message' => $row['id_msg'], |
84 | 86 | 'topic' => $row['id_topic'], |
85 | 87 | ); |
88 | + } |
|
86 | 89 | |
87 | 90 | $smcFunc['db_free_result']($request); |
88 | - } |
|
89 | - else |
|
91 | + } else |
|
90 | 92 | { |
91 | 93 | $request = $smcFunc['db_query']('', ' |
92 | 94 | SELECT id_report, id_member, membername |
@@ -97,28 +99,32 @@ discard block |
||
97 | 99 | ) |
98 | 100 | ); |
99 | 101 | |
100 | - while($row = $smcFunc['db_fetch_assoc']($request)) |
|
101 | - $extra[$row['id_report']] = array( |
|
102 | + while($row = $smcFunc['db_fetch_assoc']($request)) { |
|
103 | + $extra[$row['id_report']] = array( |
|
102 | 104 | 'report' => $row['id_report'], |
103 | 105 | 'member' => $row['id_member'], |
104 | 106 | ); |
107 | + } |
|
105 | 108 | |
106 | 109 | $smcFunc['db_free_result']($request); |
107 | 110 | } |
108 | 111 | |
109 | 112 | // Back to "ignore". |
110 | - if ($action == 'ignore_all') |
|
111 | - $action = 'ignore'; |
|
113 | + if ($action == 'ignore_all') { |
|
114 | + $action = 'ignore'; |
|
115 | + } |
|
112 | 116 | |
113 | 117 | $log_report = $action == 'ignore' ? (!empty($value) ? 'ignore' : 'unignore') : (!empty($value) ? 'close' : 'open'); |
114 | 118 | |
115 | - if ($context['report_type'] == 'members') |
|
116 | - $log_report .= '_user'; |
|
119 | + if ($context['report_type'] == 'members') { |
|
120 | + $log_report .= '_user'; |
|
121 | + } |
|
117 | 122 | |
118 | 123 | // Log this action. |
119 | - if (!empty($extra)) |
|
120 | - foreach ($extra as $report) |
|
124 | + if (!empty($extra)) { |
|
125 | + foreach ($extra as $report) |
|
121 | 126 | logAction($log_report . '_report', $report); |
127 | + } |
|
122 | 128 | |
123 | 129 | // Time to update. |
124 | 130 | updateSettings(array('last_mod_report_action' => time())); |
@@ -140,14 +146,12 @@ discard block |
||
140 | 146 | if ($context['report_type'] == 'members') |
141 | 147 | { |
142 | 148 | $and = 'lr.id_board = 0'; |
143 | - } |
|
144 | - else |
|
149 | + } else |
|
145 | 150 | { |
146 | 151 | if ($user_info['mod_cache']['bq'] == '1=1' || $user_info['mod_cache']['bq'] == '0=1') |
147 | 152 | { |
148 | 153 | $bq = $user_info['mod_cache']['bq']; |
149 | - } |
|
150 | - else |
|
154 | + } else |
|
151 | 155 | { |
152 | 156 | $bq = 'lr.' . $user_info['mod_cache']['bq']; |
153 | 157 | } |
@@ -203,8 +207,7 @@ discard block |
||
203 | 207 | 'max' => 10, |
204 | 208 | ) |
205 | 209 | ); |
206 | - } |
|
207 | - else |
|
210 | + } else |
|
208 | 211 | { |
209 | 212 | $request = $smcFunc['db_query']('', ' |
210 | 213 | SELECT lr.id_report, lr.id_msg, lr.id_topic, lr.id_board, lr.id_member, lr.subject, lr.body, |
@@ -252,8 +255,7 @@ discard block |
||
252 | 255 | 'href' => $scripturl . '?action=profile;u=' . $row['id_user'], |
253 | 256 | ), |
254 | 257 | ); |
255 | - } |
|
256 | - else |
|
258 | + } else |
|
257 | 259 | { |
258 | 260 | $report_boards_ids[] = $row['id_board']; |
259 | 261 | $extraDetails = array( |
@@ -293,14 +295,16 @@ discard block |
||
293 | 295 | ) |
294 | 296 | ); |
295 | 297 | |
296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
297 | - $board_names[$row['id_board']] = $row['name']; |
|
298 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
299 | + $board_names[$row['id_board']] = $row['name']; |
|
300 | + } |
|
298 | 301 | |
299 | 302 | $smcFunc['db_free_result']($request); |
300 | 303 | |
301 | - foreach ($reports as $id_report => $report) |
|
302 | - if (!empty($board_names[$report['topic']['id_board']])) |
|
304 | + foreach ($reports as $id_report => $report) { |
|
305 | + if (!empty($board_names[$report['topic']['id_board']])) |
|
303 | 306 | $reports[$id_report]['topic']['board_name'] = $board_names[$report['topic']['id_board']]; |
307 | + } |
|
304 | 308 | } |
305 | 309 | |
306 | 310 | // Now get all the people who reported it. |
@@ -350,10 +354,11 @@ discard block |
||
350 | 354 | { |
351 | 355 | global $user_info, $smcFunc; |
352 | 356 | |
353 | - if ($type == 'members') |
|
354 | - $bq = ''; |
|
355 | - else |
|
356 | - $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
357 | + if ($type == 'members') { |
|
358 | + $bq = ''; |
|
359 | + } else { |
|
360 | + $bq = ' AND ' . $user_info['mod_cache']['bq']; |
|
361 | + } |
|
357 | 362 | |
358 | 363 | $request = $smcFunc['db_query']('', ' |
359 | 364 | SELECT COUNT(*) |
@@ -392,8 +397,9 @@ discard block |
||
392 | 397 | { |
393 | 398 | global $smcFunc, $user_info, $context; |
394 | 399 | |
395 | - if (empty($report_id)) |
|
396 | - return false; |
|
400 | + if (empty($report_id)) { |
|
401 | + return false; |
|
402 | + } |
|
397 | 403 | |
398 | 404 | // We don't need all this info if we're only getting user info |
399 | 405 | if ($context['report_type'] == 'members') |
@@ -411,8 +417,7 @@ discard block |
||
411 | 417 | 'id_report' => $report_id, |
412 | 418 | ) |
413 | 419 | ); |
414 | - } |
|
415 | - else |
|
420 | + } else |
|
416 | 421 | { |
417 | 422 | // Get the report details, need this so we can limit access to a particular board. |
418 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -431,8 +436,9 @@ discard block |
||
431 | 436 | } |
432 | 437 | |
433 | 438 | // So did we find anything? |
434 | - if (!$smcFunc['db_num_rows']($request)) |
|
435 | - return false; |
|
439 | + if (!$smcFunc['db_num_rows']($request)) { |
|
440 | + return false; |
|
441 | + } |
|
436 | 442 | |
437 | 443 | // Woohoo we found a report and they can see it! |
438 | 444 | $row = $smcFunc['db_fetch_assoc']($request); |
@@ -451,8 +457,9 @@ discard block |
||
451 | 457 | { |
452 | 458 | global $smcFunc, $scripturl, $user_info, $txt; |
453 | 459 | |
454 | - if (empty($report_id)) |
|
455 | - return false; |
|
460 | + if (empty($report_id)) { |
|
461 | + return false; |
|
462 | + } |
|
456 | 463 | |
457 | 464 | $report = array( |
458 | 465 | 'comments' => array(), |
@@ -533,8 +540,9 @@ discard block |
||
533 | 540 | { |
534 | 541 | global $smcFunc, $user_info; |
535 | 542 | |
536 | - if (empty($comment_id)) |
|
537 | - return false; |
|
543 | + if (empty($comment_id)) { |
|
544 | + return false; |
|
545 | + } |
|
538 | 546 | |
539 | 547 | $request = $smcFunc['db_query']('', ' |
540 | 548 | SELECT id_comment, id_notice, log_time, body, id_member |
@@ -551,8 +559,9 @@ discard block |
||
551 | 559 | $smcFunc['db_free_result']($request); |
552 | 560 | |
553 | 561 | // Add the permission |
554 | - if (!empty($comment)) |
|
555 | - $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
562 | + if (!empty($comment)) { |
|
563 | + $comment['can_edit'] = allowedTo('admin_forum') || (($user_info['id'] == $comment['id_member'])); |
|
564 | + } |
|
556 | 565 | |
557 | 566 | return $comment; |
558 | 567 | } |
@@ -568,8 +577,9 @@ discard block |
||
568 | 577 | { |
569 | 578 | global $smcFunc, $user_info, $context; |
570 | 579 | |
571 | - if (empty($data)) |
|
572 | - return false; |
|
580 | + if (empty($data)) { |
|
581 | + return false; |
|
582 | + } |
|
573 | 583 | |
574 | 584 | $data = array_merge(array($user_info['id'], $user_info['name'], 'reportc', ''), $data); |
575 | 585 | |
@@ -598,8 +608,7 @@ discard block |
||
598 | 608 | 'comment_id' => $last_comment, |
599 | 609 | 'time' => time(), |
600 | 610 | ); |
601 | - } |
|
602 | - else |
|
611 | + } else |
|
603 | 612 | { |
604 | 613 | $prefix = 'Msg'; |
605 | 614 | $data = array( |
@@ -615,14 +624,15 @@ discard block |
||
615 | 624 | } |
616 | 625 | |
617 | 626 | // And get ready to notify people. |
618 | - if (!empty($report)) |
|
619 | - $smcFunc['db_insert']('insert', |
|
627 | + if (!empty($report)) { |
|
628 | + $smcFunc['db_insert']('insert', |
|
620 | 629 | '{db_prefix}background_tasks', |
621 | 630 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
622 | 631 | array('$sourcedir/tasks/' . $prefix . 'ReportReply-Notify.php', $prefix . 'ReportReply_Notify_Background', json_encode($data), 0), |
623 | 632 | array('id_task') |
624 | 633 | ); |
625 | -} |
|
634 | + } |
|
635 | + } |
|
626 | 636 | |
627 | 637 | /** |
628 | 638 | * Saves the new information whenever a moderator comment is edited. |
@@ -635,8 +645,9 @@ discard block |
||
635 | 645 | { |
636 | 646 | global $smcFunc; |
637 | 647 | |
638 | - if (empty($comment_id) || empty($edited_comment)) |
|
639 | - return false; |
|
648 | + if (empty($comment_id) || empty($edited_comment)) { |
|
649 | + return false; |
|
650 | + } |
|
640 | 651 | |
641 | 652 | $smcFunc['db_query']('', ' |
642 | 653 | UPDATE {db_prefix}log_comments |
@@ -659,8 +670,9 @@ discard block |
||
659 | 670 | { |
660 | 671 | global $smcFunc; |
661 | 672 | |
662 | - if (empty($comment_id)) |
|
663 | - return false; |
|
673 | + if (empty($comment_id)) { |
|
674 | + return false; |
|
675 | + } |
|
664 | 676 | |
665 | 677 | $smcFunc['db_query']('', ' |
666 | 678 | DELETE FROM {db_prefix}log_comments |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
32 | 33 | |
33 | 34 | // Are we looking at the moderation log or the administration log. |
34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
35 | - if ($context['log_type'] == 3) |
|
36 | - isAllowedTo('admin_forum'); |
|
36 | + if ($context['log_type'] == 3) { |
|
37 | + isAllowedTo('admin_forum'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
41 | - else |
|
42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
43 | + } else { |
|
44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
45 | + } |
|
43 | 46 | |
44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
69 | 72 | |
70 | - } |
|
71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
72 | 74 | { |
73 | 75 | checkSession(); |
74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
115 | 117 | ); |
116 | 118 | |
117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
119 | - else |
|
120 | - $search_params_string = $search_params['string']; |
|
119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
121 | + } else { |
|
122 | + $search_params_string = $search_params['string']; |
|
123 | + } |
|
121 | 124 | |
122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
124 | - else |
|
125 | - $search_params_type = $search_params['type']; |
|
125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
127 | + } else { |
|
128 | + $search_params_type = $search_params['type']; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
128 | 132 | $search_params = array( |
@@ -297,13 +301,14 @@ discard block |
||
297 | 301 | $context['sub_template'] = 'show_list'; |
298 | 302 | $context['default_list'] = 'moderation_log_list'; |
299 | 303 | |
300 | - if (isset($context['moderation_menu_name'])) |
|
301 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
304 | + if (isset($context['moderation_menu_name'])) { |
|
305 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
302 | 306 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
303 | 307 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
304 | 308 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
305 | 309 | ); |
306 | -} |
|
310 | + } |
|
311 | + } |
|
307 | 312 | |
308 | 313 | /** |
309 | 314 | * Get the number of mod log entries. |
@@ -407,30 +412,35 @@ discard block |
||
407 | 412 | // Add on some of the column stuff info |
408 | 413 | if (!empty($row['id_board'])) |
409 | 414 | { |
410 | - if ($row['action'] == 'move') |
|
411 | - $row['extra']['board_to'] = $row['id_board']; |
|
412 | - else |
|
413 | - $row['extra']['board'] = $row['id_board']; |
|
415 | + if ($row['action'] == 'move') { |
|
416 | + $row['extra']['board_to'] = $row['id_board']; |
|
417 | + } else { |
|
418 | + $row['extra']['board'] = $row['id_board']; |
|
419 | + } |
|
414 | 420 | } |
415 | 421 | |
416 | - if (!empty($row['id_topic'])) |
|
417 | - $row['extra']['topic'] = $row['id_topic']; |
|
418 | - if (!empty($row['id_msg'])) |
|
419 | - $row['extra']['message'] = $row['id_msg']; |
|
422 | + if (!empty($row['id_topic'])) { |
|
423 | + $row['extra']['topic'] = $row['id_topic']; |
|
424 | + } |
|
425 | + if (!empty($row['id_msg'])) { |
|
426 | + $row['extra']['message'] = $row['id_msg']; |
|
427 | + } |
|
420 | 428 | |
421 | 429 | // Is this associated with a topic? |
422 | - if (isset($row['extra']['topic'])) |
|
423 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
424 | - if (isset($row['extra']['new_topic'])) |
|
425 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
430 | + if (isset($row['extra']['topic'])) { |
|
431 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
432 | + } |
|
433 | + if (isset($row['extra']['new_topic'])) { |
|
434 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
435 | + } |
|
426 | 436 | |
427 | 437 | // How about a member? |
428 | 438 | if (isset($row['extra']['member'])) |
429 | 439 | { |
430 | 440 | // Guests don't have names! |
431 | - if (empty($row['extra']['member'])) |
|
432 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
433 | - else |
|
441 | + if (empty($row['extra']['member'])) { |
|
442 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
443 | + } else |
|
434 | 444 | { |
435 | 445 | // Try to find it... |
436 | 446 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -438,35 +448,42 @@ discard block |
||
438 | 448 | } |
439 | 449 | |
440 | 450 | // Associated with a board? |
441 | - if (isset($row['extra']['board_to'])) |
|
442 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
443 | - if (isset($row['extra']['board_from'])) |
|
444 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
445 | - if (isset($row['extra']['board'])) |
|
446 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
451 | + if (isset($row['extra']['board_to'])) { |
|
452 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
453 | + } |
|
454 | + if (isset($row['extra']['board_from'])) { |
|
455 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
456 | + } |
|
457 | + if (isset($row['extra']['board'])) { |
|
458 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
459 | + } |
|
447 | 460 | |
448 | 461 | // A message? |
449 | - if (isset($row['extra']['message'])) |
|
450 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
462 | + if (isset($row['extra']['message'])) { |
|
463 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
464 | + } |
|
451 | 465 | |
452 | 466 | // IP Info? |
453 | - if (isset($row['extra']['ip_range'])) |
|
454 | - if ($seeIP) |
|
467 | + if (isset($row['extra']['ip_range'])) { |
|
468 | + if ($seeIP) |
|
455 | 469 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
456 | - else |
|
457 | - $row['extra']['ip_range'] = $txt['logged']; |
|
470 | + } else { |
|
471 | + $row['extra']['ip_range'] = $txt['logged']; |
|
472 | + } |
|
458 | 473 | |
459 | 474 | // Email? |
460 | - if (isset($row['extra']['email'])) |
|
461 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
475 | + if (isset($row['extra']['email'])) { |
|
476 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
477 | + } |
|
462 | 478 | |
463 | 479 | // Bans are complex. |
464 | 480 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
465 | 481 | { |
466 | 482 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
467 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
468 | - if (isset($row['extra'][$type])) |
|
483 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
484 | + if (isset($row['extra'][$type])) |
|
469 | 485 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
486 | + } |
|
470 | 487 | } |
471 | 488 | |
472 | 489 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -502,12 +519,13 @@ discard block |
||
502 | 519 | foreach ($boards[$row['id_board']] as $action) |
503 | 520 | { |
504 | 521 | // Make the board number into a link - dealing with moving too. |
505 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
506 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
507 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
508 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
509 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
510 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
522 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
523 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
524 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
525 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
526 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
527 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
528 | + } |
|
511 | 529 | } |
512 | 530 | } |
513 | 531 | $smcFunc['db_free_result']($request); |
@@ -541,10 +559,11 @@ discard block |
||
541 | 559 | ); |
542 | 560 | |
543 | 561 | // Make the topic number into a link - dealing with splitting too. |
544 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
545 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
546 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
547 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
562 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
563 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
564 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
565 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
566 | + } |
|
548 | 567 | } |
549 | 568 | } |
550 | 569 | $smcFunc['db_free_result']($request); |
@@ -577,8 +596,9 @@ discard block |
||
577 | 596 | ); |
578 | 597 | |
579 | 598 | // Make the message number into a link. |
580 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
581 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
599 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
600 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
601 | + } |
|
582 | 602 | } |
583 | 603 | } |
584 | 604 | $smcFunc['db_free_result']($request); |
@@ -618,25 +638,29 @@ discard block |
||
618 | 638 | foreach ($entries as $k => $entry) |
619 | 639 | { |
620 | 640 | // Make any message info links so its easier to go find that message. |
621 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
622 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
641 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
642 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
643 | + } |
|
623 | 644 | |
624 | 645 | // Mark up any deleted members, topics and boards. |
625 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
626 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
646 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
647 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
627 | 648 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
649 | + } |
|
628 | 650 | |
629 | 651 | if (isset($entry['extra']['report'])) |
630 | 652 | { |
631 | 653 | // Member profile reports go in a different area |
632 | - if (stristr($entry['action'], 'user_report')) |
|
633 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
634 | - else |
|
635 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
654 | + if (stristr($entry['action'], 'user_report')) { |
|
655 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
656 | + } else { |
|
657 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
658 | + } |
|
636 | 659 | } |
637 | 660 | |
638 | - if (empty($entries[$k]['action_text'])) |
|
639 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
661 | + if (empty($entries[$k]['action_text'])) { |
|
662 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
663 | + } |
|
640 | 664 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
641 | 665 | function ($matches) use ($entries, $k) |
642 | 666 | { |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | loadLanguage('Drafts'); |
21 | 22 | |
@@ -33,8 +34,9 @@ discard block |
||
33 | 34 | global $context, $user_info, $smcFunc, $modSettings, $board; |
34 | 35 | |
35 | 36 | // can you be, should you be ... here? |
36 | - if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) |
|
37 | - return false; |
|
37 | + if (empty($modSettings['drafts_post_enabled']) || !allowedTo('post_draft') || !isset($_POST['save_draft']) || !isset($_POST['id_draft'])) { |
|
38 | + return false; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | // read in what they sent us, if anything |
40 | 42 | $id_draft = (int) $_POST['id_draft']; |
@@ -46,14 +48,16 @@ discard block |
||
46 | 48 | $context['draft_saved_on'] = $draft_info['poster_time']; |
47 | 49 | |
48 | 50 | // since we were called from the autosave function, send something back |
49 | - if (!empty($id_draft)) |
|
50 | - XmlDraft($id_draft); |
|
51 | + if (!empty($id_draft)) { |
|
52 | + XmlDraft($id_draft); |
|
53 | + } |
|
51 | 54 | |
52 | 55 | return true; |
53 | 56 | } |
54 | 57 | |
55 | - if (!isset($_POST['message'])) |
|
56 | - $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
58 | + if (!isset($_POST['message'])) { |
|
59 | + $_POST['message'] = isset($_POST['quickReply']) ? $_POST['quickReply'] : ''; |
|
60 | + } |
|
57 | 61 | |
58 | 62 | // prepare any data from the form |
59 | 63 | $topic_id = empty($_REQUEST['topic']) ? 0 : (int) $_REQUEST['topic']; |
@@ -66,8 +70,9 @@ discard block |
||
66 | 70 | |
67 | 71 | // message and subject still need a bit more work |
68 | 72 | preparsecode($draft['body']); |
69 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
70 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
73 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
74 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
75 | + } |
|
71 | 76 | |
72 | 77 | // Modifying an existing draft, like hitting the save draft button or autosave enabled? |
73 | 78 | if (!empty($id_draft) && !empty($draft_info)) |
@@ -148,9 +153,9 @@ discard block |
||
148 | 153 | { |
149 | 154 | $context['draft_saved'] = true; |
150 | 155 | $context['id_draft'] = $id_draft; |
156 | + } else { |
|
157 | + $post_errors[] = 'draft_not_saved'; |
|
151 | 158 | } |
152 | - else |
|
153 | - $post_errors[] = 'draft_not_saved'; |
|
154 | 159 | |
155 | 160 | // cleanup |
156 | 161 | unset($_POST['save_draft']); |
@@ -180,8 +185,9 @@ discard block |
||
180 | 185 | global $context, $user_info, $smcFunc, $modSettings; |
181 | 186 | |
182 | 187 | // PM survey says ... can you stay or must you go |
183 | - if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) |
|
184 | - return false; |
|
188 | + if (empty($modSettings['drafts_pm_enabled']) || !allowedTo('pm_draft') || !isset($_POST['save_draft'])) { |
|
189 | + return false; |
|
190 | + } |
|
185 | 191 | |
186 | 192 | // read in what you sent us |
187 | 193 | $id_pm_draft = (int) $_POST['id_pm_draft']; |
@@ -193,8 +199,9 @@ discard block |
||
193 | 199 | $context['draft_saved_on'] = $draft_info['poster_time']; |
194 | 200 | |
195 | 201 | // Send something back to the javascript caller |
196 | - if (!empty($id_draft)) |
|
197 | - XmlDraft($id_draft); |
|
202 | + if (!empty($id_draft)) { |
|
203 | + XmlDraft($id_draft); |
|
204 | + } |
|
198 | 205 | |
199 | 206 | return true; |
200 | 207 | } |
@@ -204,9 +211,9 @@ discard block |
||
204 | 211 | { |
205 | 212 | $recipientList['to'] = isset($_POST['recipient_to']) ? explode(',', $_POST['recipient_to']) : array(); |
206 | 213 | $recipientList['bcc'] = isset($_POST['recipient_bcc']) ? explode(',', $_POST['recipient_bcc']) : array(); |
214 | + } elseif (!empty($draft_info['to_list']) && empty($recipientList)) { |
|
215 | + $recipientList = smf_json_decode($draft_info['to_list'], true); |
|
207 | 216 | } |
208 | - elseif (!empty($draft_info['to_list']) && empty($recipientList)) |
|
209 | - $recipientList = smf_json_decode($draft_info['to_list'], true); |
|
210 | 217 | |
211 | 218 | // prepare the data we got from the form |
212 | 219 | $reply_id = empty($_POST['replied_to']) ? 0 : (int) $_POST['replied_to']; |
@@ -215,8 +222,9 @@ discard block |
||
215 | 222 | |
216 | 223 | // message and subject always need a bit more work |
217 | 224 | preparsecode($draft['body']); |
218 | - if ($smcFunc['strlen']($draft['subject']) > 100) |
|
219 | - $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
225 | + if ($smcFunc['strlen']($draft['subject']) > 100) { |
|
226 | + $draft['subject'] = $smcFunc['substr']($draft['subject'], 0, 100); |
|
227 | + } |
|
220 | 228 | |
221 | 229 | // Modifying an existing PM draft? |
222 | 230 | if (!empty($id_pm_draft) && !empty($draft_info)) |
@@ -280,9 +288,9 @@ discard block |
||
280 | 288 | { |
281 | 289 | $context['draft_saved'] = true; |
282 | 290 | $context['id_pm_draft'] = $id_pm_draft; |
291 | + } else { |
|
292 | + $post_errors[] = 'draft_not_saved'; |
|
283 | 293 | } |
284 | - else |
|
285 | - $post_errors[] = 'draft_not_saved'; |
|
286 | 294 | } |
287 | 295 | |
288 | 296 | // if we were called from the autosave function, send something back |
@@ -315,8 +323,9 @@ discard block |
||
315 | 323 | $type = (int) $type; |
316 | 324 | |
317 | 325 | // nothing to read, nothing to do |
318 | - if (empty($id_draft)) |
|
319 | - return false; |
|
326 | + if (empty($id_draft)) { |
|
327 | + return false; |
|
328 | + } |
|
320 | 329 | |
321 | 330 | // load in this draft from the DB |
322 | 331 | $request = $smcFunc['db_query']('', ' |
@@ -337,8 +346,9 @@ discard block |
||
337 | 346 | ); |
338 | 347 | |
339 | 348 | // no results? |
340 | - if (!$smcFunc['db_num_rows']($request)) |
|
341 | - return false; |
|
349 | + if (!$smcFunc['db_num_rows']($request)) { |
|
350 | + return false; |
|
351 | + } |
|
342 | 352 | |
343 | 353 | // load up the data |
344 | 354 | $draft_info = $smcFunc['db_fetch_assoc']($request); |
@@ -358,8 +368,7 @@ discard block |
||
358 | 368 | $context['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
359 | 369 | $context['board'] = !empty($draft_info['id_board']) ? $draft_info['id_board'] : ''; |
360 | 370 | $context['id_draft'] = !empty($draft_info['id_draft']) ? $draft_info['id_draft'] : 0; |
361 | - } |
|
362 | - elseif ($type === 1) |
|
371 | + } elseif ($type === 1) |
|
363 | 372 | { |
364 | 373 | // one of those pm drafts? then set it up like we have an error |
365 | 374 | $_REQUEST['subject'] = !empty($draft_info['subject']) ? stripslashes($draft_info['subject']) : ''; |
@@ -395,12 +404,14 @@ discard block |
||
395 | 404 | global $user_info, $smcFunc; |
396 | 405 | |
397 | 406 | // Only a single draft. |
398 | - if (is_numeric($id_draft)) |
|
399 | - $id_draft = array($id_draft); |
|
407 | + if (is_numeric($id_draft)) { |
|
408 | + $id_draft = array($id_draft); |
|
409 | + } |
|
400 | 410 | |
401 | 411 | // can't delete nothing |
402 | - if (empty($id_draft) || ($check && empty($user_info['id']))) |
|
403 | - return false; |
|
412 | + if (empty($id_draft) || ($check && empty($user_info['id']))) { |
|
413 | + return false; |
|
414 | + } |
|
404 | 415 | |
405 | 416 | $smcFunc['db_query']('', ' |
406 | 417 | DELETE FROM {db_prefix}user_drafts |
@@ -429,14 +440,16 @@ discard block |
||
429 | 440 | global $smcFunc, $scripturl, $context, $txt, $modSettings; |
430 | 441 | |
431 | 442 | // Permissions |
432 | - if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) |
|
433 | - return false; |
|
443 | + if (($draft_type === 0 && empty($context['drafts_save'])) || ($draft_type === 1 && empty($context['drafts_pm_save'])) || empty($member_id)) { |
|
444 | + return false; |
|
445 | + } |
|
434 | 446 | |
435 | 447 | $context['drafts'] = array(); |
436 | 448 | |
437 | 449 | // has a specific draft has been selected? Load it up if there is not a message already in the editor |
438 | - if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) |
|
439 | - ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
450 | + if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) { |
|
451 | + ReadDraft((int) $_REQUEST['id_draft'], $draft_type, true, true); |
|
452 | + } |
|
440 | 453 | |
441 | 454 | // load the drafts this user has available |
442 | 455 | $request = $smcFunc['db_query']('', ' |
@@ -459,8 +472,9 @@ discard block |
||
459 | 472 | // add them to the draft array for display |
460 | 473 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
461 | 474 | { |
462 | - if (empty($row['subject'])) |
|
463 | - $row['subject'] = $txt['no_subject']; |
|
475 | + if (empty($row['subject'])) { |
|
476 | + $row['subject'] = $txt['no_subject']; |
|
477 | + } |
|
464 | 478 | |
465 | 479 | // Post drafts |
466 | 480 | if ($draft_type === 0) |
@@ -545,8 +559,9 @@ discard block |
||
545 | 559 | } |
546 | 560 | |
547 | 561 | // Default to 10. |
548 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
549 | - $_REQUEST['viewscount'] = 10; |
|
562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
563 | + $_REQUEST['viewscount'] = 10; |
|
564 | + } |
|
550 | 565 | |
551 | 566 | // Get the count of applicable drafts on the boards they can (still) see ... |
552 | 567 | // @todo .. should we just let them see their drafts even if they have lost board access ? |
@@ -611,12 +626,14 @@ discard block |
||
611 | 626 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
612 | 627 | { |
613 | 628 | // Censor.... |
614 | - if (empty($row['body'])) |
|
615 | - $row['body'] = ''; |
|
629 | + if (empty($row['body'])) { |
|
630 | + $row['body'] = ''; |
|
631 | + } |
|
616 | 632 | |
617 | 633 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
618 | - if (empty($row['subject'])) |
|
619 | - $row['subject'] = $txt['no_subject']; |
|
634 | + if (empty($row['subject'])) { |
|
635 | + $row['subject'] = $txt['no_subject']; |
|
636 | + } |
|
620 | 637 | |
621 | 638 | censorText($row['body']); |
622 | 639 | censorText($row['subject']); |
@@ -648,8 +665,9 @@ discard block |
||
648 | 665 | $smcFunc['db_free_result']($request); |
649 | 666 | |
650 | 667 | // If the drafts were retrieved in reverse order, get them right again. |
651 | - if ($reverse) |
|
652 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
668 | + if ($reverse) { |
|
669 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
670 | + } |
|
653 | 671 | |
654 | 672 | // Menu tab |
655 | 673 | $context[$context['profile_menu_name']]['tab_data'] = array( |
@@ -707,8 +725,9 @@ discard block |
||
707 | 725 | } |
708 | 726 | |
709 | 727 | // Default to 10. |
710 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
711 | - $_REQUEST['viewscount'] = 10; |
|
728 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
729 | + $_REQUEST['viewscount'] = 10; |
|
730 | + } |
|
712 | 731 | |
713 | 732 | // Get the count of applicable drafts |
714 | 733 | $request = $smcFunc['db_query']('', ' |
@@ -767,12 +786,14 @@ discard block |
||
767 | 786 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
768 | 787 | { |
769 | 788 | // Censor.... |
770 | - if (empty($row['body'])) |
|
771 | - $row['body'] = ''; |
|
789 | + if (empty($row['body'])) { |
|
790 | + $row['body'] = ''; |
|
791 | + } |
|
772 | 792 | |
773 | 793 | $row['subject'] = $smcFunc['htmltrim']($row['subject']); |
774 | - if (empty($row['subject'])) |
|
775 | - $row['subject'] = $txt['no_subject']; |
|
794 | + if (empty($row['subject'])) { |
|
795 | + $row['subject'] = $txt['no_subject']; |
|
796 | + } |
|
776 | 797 | |
777 | 798 | censorText($row['body']); |
778 | 799 | censorText($row['subject']); |
@@ -827,8 +848,9 @@ discard block |
||
827 | 848 | $smcFunc['db_free_result']($request); |
828 | 849 | |
829 | 850 | // if the drafts were retrieved in reverse order, then put them in the right order again. |
830 | - if ($reverse) |
|
831 | - $context['drafts'] = array_reverse($context['drafts'], true); |
|
851 | + if ($reverse) { |
|
852 | + $context['drafts'] = array_reverse($context['drafts'], true); |
|
853 | + } |
|
832 | 854 | |
833 | 855 | // off to the template we go |
834 | 856 | $context['page_title'] = $txt['drafts']; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Finds or repairs errors in the database to fix possible problems. |
@@ -50,8 +51,9 @@ discard block |
||
50 | 51 | ); |
51 | 52 | |
52 | 53 | // Start displaying errors without fixing them. |
53 | - if (isset($_GET['fixErrors'])) |
|
54 | - checkSession('get'); |
|
54 | + if (isset($_GET['fixErrors'])) { |
|
55 | + checkSession('get'); |
|
56 | + } |
|
55 | 57 | |
56 | 58 | // Will want this. |
57 | 59 | loadForumTests(); |
@@ -69,11 +71,11 @@ discard block |
||
69 | 71 | $_SESSION['repairboards_to_fix'] = $context['to_fix']; |
70 | 72 | $_SESSION['repairboards_to_fix2'] = null; |
71 | 73 | |
72 | - if (empty($context['repair_errors'])) |
|
73 | - $context['repair_errors'][] = '???'; |
|
74 | + if (empty($context['repair_errors'])) { |
|
75 | + $context['repair_errors'][] = '???'; |
|
76 | + } |
|
74 | 77 | } |
75 | - } |
|
76 | - else |
|
78 | + } else |
|
77 | 79 | { |
78 | 80 | $context['error_search'] = false; |
79 | 81 | $context['to_fix'] = isset($_SESSION['repairboards_to_fix']) ? $_SESSION['repairboards_to_fix'] : array(); |
@@ -120,16 +122,19 @@ discard block |
||
120 | 122 | |
121 | 123 | // More time, I need more time! |
122 | 124 | @set_time_limit(600); |
123 | - if (function_exists('apache_reset_timeout')) |
|
124 | - @apache_reset_timeout(); |
|
125 | + if (function_exists('apache_reset_timeout')) { |
|
126 | + @apache_reset_timeout(); |
|
127 | + } |
|
125 | 128 | |
126 | 129 | // Errr, wait. How much time has this taken already? |
127 | - if (!$force && time() - array_sum(explode(' ', $time_start)) < 3) |
|
128 | - return; |
|
130 | + if (!$force && time() - array_sum(explode(' ', $time_start)) < 3) { |
|
131 | + return; |
|
132 | + } |
|
129 | 133 | |
130 | 134 | // Restore the query cache if interested. |
131 | - if (!empty($db_temp_cache)) |
|
132 | - $db_cache = $db_temp_cache; |
|
135 | + if (!empty($db_temp_cache)) { |
|
136 | + $db_cache = $db_temp_cache; |
|
137 | + } |
|
133 | 138 | |
134 | 139 | $context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
135 | 140 | $context['page_title'] = $txt['not_done_title']; |
@@ -138,10 +143,11 @@ discard block |
||
138 | 143 | $context['sub_template'] = 'not_done'; |
139 | 144 | |
140 | 145 | // Change these two if more steps are added! |
141 | - if (empty($max_substep)) |
|
142 | - $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
143 | - else |
|
144 | - $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
146 | + if (empty($max_substep)) { |
|
147 | + $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
148 | + } else { |
|
149 | + $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
150 | + } |
|
145 | 151 | |
146 | 152 | // Never more than 100%! |
147 | 153 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -612,8 +618,9 @@ discard block |
||
612 | 618 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
613 | 619 | |
614 | 620 | // Not really a problem? |
615 | - if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
616 | - return false; |
|
621 | + if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
622 | + return false; |
|
623 | + } |
|
617 | 624 | |
618 | 625 | $memberStartedID = (int) getMsgMemberID($row['myid_first_msg']); |
619 | 626 | $memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']); |
@@ -637,15 +644,19 @@ discard block |
||
637 | 644 | 'message_function' => function ($row) use ($txt, &$context) |
638 | 645 | { |
639 | 646 | // A pretend error? |
640 | - if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
641 | - return false; |
|
647 | + if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
648 | + return false; |
|
649 | + } |
|
642 | 650 | |
643 | - if ($row['id_first_msg'] != $row['myid_first_msg']) |
|
644 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
645 | - if ($row['id_last_msg'] != $row['myid_last_msg']) |
|
646 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
647 | - if ($row['approved'] != $row['firstmsg_approved']) |
|
648 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
651 | + if ($row['id_first_msg'] != $row['myid_first_msg']) { |
|
652 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
653 | + } |
|
654 | + if ($row['id_last_msg'] != $row['myid_last_msg']) { |
|
655 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
656 | + } |
|
657 | + if ($row['approved'] != $row['firstmsg_approved']) { |
|
658 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
659 | + } |
|
649 | 660 | |
650 | 661 | return true; |
651 | 662 | }, |
@@ -675,8 +686,9 @@ discard block |
||
675 | 686 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
676 | 687 | |
677 | 688 | // Not really a problem? |
678 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
679 | - return false; |
|
689 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
690 | + return false; |
|
691 | + } |
|
680 | 692 | |
681 | 693 | $smcFunc['db_query']('', ' |
682 | 694 | UPDATE {db_prefix}topics |
@@ -695,11 +707,13 @@ discard block |
||
695 | 707 | global $txt, $context; |
696 | 708 | |
697 | 709 | // Just joking? |
698 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
699 | - return false; |
|
710 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
711 | + return false; |
|
712 | + } |
|
700 | 713 | |
701 | - if ($row['num_replies'] != $row['my_num_replies']) |
|
702 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
714 | + if ($row['num_replies'] != $row['my_num_replies']) { |
|
715 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
716 | + } |
|
703 | 717 | |
704 | 718 | return true; |
705 | 719 | |
@@ -1290,8 +1304,9 @@ discard block |
||
1290 | 1304 | $inserts = array(); |
1291 | 1305 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1292 | 1306 | { |
1293 | - foreach (text2words($row['subject']) as $word) |
|
1294 | - $inserts[] = array($word, $row['id_topic']); |
|
1307 | + foreach (text2words($row['subject']) as $word) { |
|
1308 | + $inserts[] = array($word, $row['id_topic']); |
|
1309 | + } |
|
1295 | 1310 | if (count($inserts) > 500) |
1296 | 1311 | { |
1297 | 1312 | $smcFunc['db_insert']('ignore', |
@@ -1305,13 +1320,14 @@ discard block |
||
1305 | 1320 | |
1306 | 1321 | } |
1307 | 1322 | |
1308 | - if (!empty($inserts)) |
|
1309 | - $smcFunc['db_insert']('ignore', |
|
1323 | + if (!empty($inserts)) { |
|
1324 | + $smcFunc['db_insert']('ignore', |
|
1310 | 1325 | '{db_prefix}log_search_subjects', |
1311 | 1326 | array('word' => 'string', 'id_topic' => 'int'), |
1312 | 1327 | $inserts, |
1313 | 1328 | array('word', 'id_topic') |
1314 | 1329 | ); |
1330 | + } |
|
1315 | 1331 | |
1316 | 1332 | }, |
1317 | 1333 | 'message_function' => function ($row) |
@@ -1581,8 +1597,9 @@ discard block |
||
1581 | 1597 | $current_step++; |
1582 | 1598 | |
1583 | 1599 | // Already done this? |
1584 | - if ($_GET['step'] > $current_step) |
|
1585 | - continue; |
|
1600 | + if ($_GET['step'] > $current_step) { |
|
1601 | + continue; |
|
1602 | + } |
|
1586 | 1603 | |
1587 | 1604 | // If we're fixing it but it ain't broke why try? |
1588 | 1605 | if ($do_fix && !in_array($error_type, $to_fix)) |
@@ -1611,14 +1628,16 @@ discard block |
||
1611 | 1628 | while (!$done) |
1612 | 1629 | { |
1613 | 1630 | // Make sure there's at least one ID to test. |
1614 | - if (isset($test['substeps']) && empty($step_max)) |
|
1615 | - break; |
|
1631 | + if (isset($test['substeps']) && empty($step_max)) { |
|
1632 | + break; |
|
1633 | + } |
|
1616 | 1634 | |
1617 | 1635 | // What is the testing query (Changes if we are testing or fixing) |
1618 | - if (!$do_fix) |
|
1619 | - $test_query = 'check_query'; |
|
1620 | - else |
|
1621 | - $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
1636 | + if (!$do_fix) { |
|
1637 | + $test_query = 'check_query'; |
|
1638 | + } else { |
|
1639 | + $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
1640 | + } |
|
1622 | 1641 | |
1623 | 1642 | // Do the test... |
1624 | 1643 | $request = $smcFunc['db_query']('', |
@@ -1628,10 +1647,11 @@ discard block |
||
1628 | 1647 | ); |
1629 | 1648 | |
1630 | 1649 | // Does it need a fix? |
1631 | - if (!empty($test['check_type']) && $test['check_type'] == 'count') |
|
1632 | - list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
1633 | - else |
|
1634 | - $needs_fix = $smcFunc['db_num_rows']($request); |
|
1650 | + if (!empty($test['check_type']) && $test['check_type'] == 'count') { |
|
1651 | + list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
1652 | + } else { |
|
1653 | + $needs_fix = $smcFunc['db_num_rows']($request); |
|
1654 | + } |
|
1635 | 1655 | |
1636 | 1656 | $total_queries++; |
1637 | 1657 | |
@@ -1643,8 +1663,9 @@ discard block |
||
1643 | 1663 | // Assume need to fix. |
1644 | 1664 | $found_errors = true; |
1645 | 1665 | |
1646 | - if (isset($test['message'])) |
|
1647 | - $context['repair_errors'][] = $txt[$test['message']]; |
|
1666 | + if (isset($test['message'])) { |
|
1667 | + $context['repair_errors'][] = $txt[$test['message']]; |
|
1668 | + } |
|
1648 | 1669 | |
1649 | 1670 | // One per row! |
1650 | 1671 | elseif (isset($test['messages'])) |
@@ -1654,10 +1675,11 @@ discard block |
||
1654 | 1675 | $variables = $test['messages']; |
1655 | 1676 | foreach ($variables as $k => $v) |
1656 | 1677 | { |
1657 | - if ($k == 0 && isset($txt[$v])) |
|
1658 | - $variables[$k] = $txt[$v]; |
|
1659 | - elseif ($k > 0 && isset($row[$v])) |
|
1660 | - $variables[$k] = $row[$v]; |
|
1678 | + if ($k == 0 && isset($txt[$v])) { |
|
1679 | + $variables[$k] = $txt[$v]; |
|
1680 | + } elseif ($k > 0 && isset($row[$v])) { |
|
1681 | + $variables[$k] = $row[$v]; |
|
1682 | + } |
|
1661 | 1683 | } |
1662 | 1684 | $context['repair_errors'][] = call_user_func_array('sprintf', $variables); |
1663 | 1685 | } |
@@ -1668,13 +1690,15 @@ discard block |
||
1668 | 1690 | { |
1669 | 1691 | // Find out if there are actually errors. |
1670 | 1692 | $found_errors = false; |
1671 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1672 | - $found_errors |= $test['message_function']($row); |
|
1693 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1694 | + $found_errors |= $test['message_function']($row); |
|
1695 | + } |
|
1673 | 1696 | } |
1674 | 1697 | |
1675 | 1698 | // Actually have something to fix? |
1676 | - if ($found_errors) |
|
1677 | - $to_fix[] = $error_type; |
|
1699 | + if ($found_errors) { |
|
1700 | + $to_fix[] = $error_type; |
|
1701 | + } |
|
1678 | 1702 | } |
1679 | 1703 | |
1680 | 1704 | // We want to fix, we need to fix - so work out what exactly to do! |
@@ -1684,8 +1708,9 @@ discard block |
||
1684 | 1708 | if (isset($test['fix_collect'])) |
1685 | 1709 | { |
1686 | 1710 | $ids = array(); |
1687 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1688 | - $ids[] = $row[$test['fix_collect']['index']]; |
|
1711 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1712 | + $ids[] = $row[$test['fix_collect']['index']]; |
|
1713 | + } |
|
1689 | 1714 | if (!empty($ids)) |
1690 | 1715 | { |
1691 | 1716 | // Fix it! |
@@ -1694,30 +1719,34 @@ discard block |
||
1694 | 1719 | } |
1695 | 1720 | |
1696 | 1721 | // Simply executing a fix it query? |
1697 | - elseif (isset($test['fix_it_query'])) |
|
1698 | - $smcFunc['db_query']('', |
|
1722 | + elseif (isset($test['fix_it_query'])) { |
|
1723 | + $smcFunc['db_query']('', |
|
1699 | 1724 | $test['fix_it_query'], |
1700 | 1725 | array( |
1701 | 1726 | ) |
1702 | 1727 | ); |
1728 | + } |
|
1703 | 1729 | |
1704 | 1730 | // Do we have some processing to do? |
1705 | 1731 | elseif (isset($test['fix_processing'])) |
1706 | 1732 | { |
1707 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1708 | - $test['fix_processing']($row); |
|
1733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1734 | + $test['fix_processing']($row); |
|
1735 | + } |
|
1709 | 1736 | } |
1710 | 1737 | |
1711 | 1738 | // What about the full set of processing? |
1712 | - elseif (isset($test['fix_full_processing'])) |
|
1713 | - $test['fix_full_processing']($request); |
|
1739 | + elseif (isset($test['fix_full_processing'])) { |
|
1740 | + $test['fix_full_processing']($request); |
|
1741 | + } |
|
1714 | 1742 | |
1715 | 1743 | // Do we have other things we need to fix as a result? |
1716 | 1744 | if (!empty($test['force_fix'])) |
1717 | 1745 | { |
1718 | - foreach ($test['force_fix'] as $item) |
|
1719 | - if (!in_array($item, $to_fix)) |
|
1746 | + foreach ($test['force_fix'] as $item) { |
|
1747 | + if (!in_array($item, $to_fix)) |
|
1720 | 1748 | $to_fix[] = $item; |
1749 | + } |
|
1721 | 1750 | } |
1722 | 1751 | } |
1723 | 1752 | } |
@@ -1735,16 +1764,17 @@ discard block |
||
1735 | 1764 | if ($_GET['substep'] <= $step_max) |
1736 | 1765 | { |
1737 | 1766 | pauseRepairProcess($to_fix, $error_type, $step_max); |
1767 | + } else { |
|
1768 | + $done = true; |
|
1738 | 1769 | } |
1739 | - else |
|
1740 | - $done = true; |
|
1770 | + } else { |
|
1771 | + $done = true; |
|
1741 | 1772 | } |
1742 | - else |
|
1743 | - $done = true; |
|
1744 | 1773 | |
1745 | 1774 | // Don't allow more than 1000 queries at a time. |
1746 | - if ($total_queries >= 1000) |
|
1747 | - pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
1775 | + if ($total_queries >= 1000) { |
|
1776 | + pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
1777 | + } |
|
1748 | 1778 | } |
1749 | 1779 | |
1750 | 1780 | // Keep going. |
@@ -1757,8 +1787,9 @@ discard block |
||
1757 | 1787 | if ($do_fix) |
1758 | 1788 | { |
1759 | 1789 | $key = array_search($error_type, $to_fix); |
1760 | - if ($key !== false && isset($to_fix[$key])) |
|
1761 | - unset($to_fix[$key]); |
|
1790 | + if ($key !== false && isset($to_fix[$key])) { |
|
1791 | + unset($to_fix[$key]); |
|
1792 | + } |
|
1762 | 1793 | } |
1763 | 1794 | |
1764 | 1795 | // Are we done? |
@@ -1781,10 +1812,11 @@ discard block |
||
1781 | 1812 | static $createOnce = false; |
1782 | 1813 | |
1783 | 1814 | // Have we already created it? |
1784 | - if ($createOnce) |
|
1785 | - return; |
|
1786 | - else |
|
1787 | - $createOnce = true; |
|
1815 | + if ($createOnce) { |
|
1816 | + return; |
|
1817 | + } else { |
|
1818 | + $createOnce = true; |
|
1819 | + } |
|
1788 | 1820 | |
1789 | 1821 | // Back to the forum's default language. |
1790 | 1822 | loadLanguage('Admin', $language); |
@@ -1799,8 +1831,9 @@ discard block |
||
1799 | 1831 | 'cat_name' => $txt['salvaged_category_name'], |
1800 | 1832 | ) |
1801 | 1833 | ); |
1802 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1803 | - list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
1834 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1835 | + list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
1836 | + } |
|
1804 | 1837 | $smcFunc['db_free_result']($result); |
1805 | 1838 | |
1806 | 1839 | if (empty($salvageCatID)) |
@@ -1832,8 +1865,9 @@ discard block |
||
1832 | 1865 | 'board_name' => $txt['salvaged_board_name'], |
1833 | 1866 | ) |
1834 | 1867 | ); |
1835 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1836 | - list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
1868 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1869 | + list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
1870 | + } |
|
1837 | 1871 | $smcFunc['db_free_result']($result); |
1838 | 1872 | |
1839 | 1873 | if (empty($salvageBoardID)) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Entry point for the moderation center. |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | global $txt, $context, $scripturl, $modSettings, $user_info, $sourcedir, $options; |
27 | 28 | |
28 | 29 | // Don't run this twice... and don't conflict with the admin bar. |
29 | - if (isset($context['admin_area'])) |
|
30 | - return; |
|
30 | + if (isset($context['admin_area'])) { |
|
31 | + return; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1'; |
33 | 35 | $context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1'; |
@@ -35,8 +37,9 @@ discard block |
||
35 | 37 | $context['can_moderate_users'] = allowedTo('moderate_forum'); |
36 | 38 | |
37 | 39 | // Everyone using this area must be allowed here! |
38 | - if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) |
|
39 | - isAllowedTo('access_mod_center'); |
|
40 | + if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) { |
|
41 | + isAllowedTo('access_mod_center'); |
|
42 | + } |
|
40 | 43 | |
41 | 44 | // We're gonna want a menu of some kind. |
42 | 45 | require_once($sourcedir . '/Subs-Menu.php'); |
@@ -195,8 +198,9 @@ discard block |
||
195 | 198 | unset($moderation_areas); |
196 | 199 | |
197 | 200 | // We got something - didn't we? DIDN'T WE! |
198 | - if ($mod_include_data == false) |
|
199 | - fatal_lang_error('no_access', false); |
|
201 | + if ($mod_include_data == false) { |
|
202 | + fatal_lang_error('no_access', false); |
|
203 | + } |
|
200 | 204 | |
201 | 205 | // Retain the ID information in case required by a subaction. |
202 | 206 | $context['moderation_menu_id'] = $context['max_menu_id']; |
@@ -219,22 +223,25 @@ discard block |
||
219 | 223 | 'url' => $scripturl . '?action=moderate', |
220 | 224 | 'name' => $txt['moderation_center'], |
221 | 225 | ); |
222 | - if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') |
|
223 | - $context['linktree'][] = array( |
|
226 | + if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') { |
|
227 | + $context['linktree'][] = array( |
|
224 | 228 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'], |
225 | 229 | 'name' => $mod_include_data['label'], |
226 | 230 | ); |
227 | - if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) |
|
228 | - $context['linktree'][] = array( |
|
231 | + } |
|
232 | + if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) { |
|
233 | + $context['linktree'][] = array( |
|
229 | 234 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'], |
230 | 235 | 'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0], |
231 | 236 | ); |
237 | + } |
|
232 | 238 | |
233 | 239 | // Now - finally - the bit before the encore - the main performance of course! |
234 | 240 | if (!$dont_call) |
235 | 241 | { |
236 | - if (isset($mod_include_data['file'])) |
|
237 | - require_once($sourcedir . '/' . $mod_include_data['file']); |
|
242 | + if (isset($mod_include_data['file'])) { |
|
243 | + require_once($sourcedir . '/' . $mod_include_data['file']); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | call_helper($mod_include_data['function']); |
240 | 247 | } |
@@ -259,8 +266,9 @@ discard block |
||
259 | 266 | // Load what blocks the user actually can see... |
260 | 267 | $valid_blocks = array(); |
261 | 268 | |
262 | - if ($context['can_moderate_groups']) |
|
263 | - $valid_blocks['g'] = 'GroupRequests'; |
|
269 | + if ($context['can_moderate_groups']) { |
|
270 | + $valid_blocks['g'] = 'GroupRequests'; |
|
271 | + } |
|
264 | 272 | if ($context['can_moderate_boards']) |
265 | 273 | { |
266 | 274 | $valid_blocks['r'] = 'ReportedPosts'; |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | if ($context['can_moderate_users']) |
270 | 278 | { |
271 | 279 | // This falls under the category of moderating users as well... |
272 | - if (!$context['can_moderate_boards']) |
|
273 | - $valid_blocks['w'] = 'WatchedUsers'; |
|
280 | + if (!$context['can_moderate_boards']) { |
|
281 | + $valid_blocks['w'] = 'WatchedUsers'; |
|
282 | + } |
|
274 | 283 | |
275 | 284 | $valid_blocks['rm'] = 'ReportedMembers'; |
276 | 285 | } |
@@ -281,8 +290,9 @@ discard block |
||
281 | 290 | foreach ($valid_blocks as $k => $block) |
282 | 291 | { |
283 | 292 | $block = 'ModBlock' . $block; |
284 | - if (function_exists($block)) |
|
285 | - $context['mod_blocks'][] = $block(); |
|
293 | + if (function_exists($block)) { |
|
294 | + $context['mod_blocks'][] = $block(); |
|
295 | + } |
|
286 | 296 | } |
287 | 297 | |
288 | 298 | $context['admin_prefs'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
@@ -309,8 +319,9 @@ discard block |
||
309 | 319 | ) |
310 | 320 | ); |
311 | 321 | $watched_users = array(); |
312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
313 | - $watched_users[] = $row; |
|
322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
323 | + $watched_users[] = $row; |
|
324 | + } |
|
314 | 325 | $smcFunc['db_free_result']($request); |
315 | 326 | |
316 | 327 | cache_put_data('recent_user_watches', $watched_users, 240); |
@@ -402,8 +413,9 @@ discard block |
||
402 | 413 | $note_owner = $smcFunc['db_num_rows']($get_owner); |
403 | 414 | $smcFunc['db_free_result']($get_owner); |
404 | 415 | |
405 | - if (empty($note_owner)) |
|
406 | - fatal_lang_error('mc_notes_delete_own', false); |
|
416 | + if (empty($note_owner)) { |
|
417 | + fatal_lang_error('mc_notes_delete_own', false); |
|
418 | + } |
|
407 | 419 | } |
408 | 420 | |
409 | 421 | // Lets delete it. |
@@ -460,12 +472,14 @@ discard block |
||
460 | 472 | ) |
461 | 473 | ); |
462 | 474 | $moderator_notes = array(); |
463 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
464 | - $moderator_notes[] = $row; |
|
475 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
476 | + $moderator_notes[] = $row; |
|
477 | + } |
|
465 | 478 | $smcFunc['db_free_result']($request); |
466 | 479 | |
467 | - if ($offset == 0) |
|
468 | - cache_put_data('moderator_notes', $moderator_notes, 240); |
|
480 | + if ($offset == 0) { |
|
481 | + cache_put_data('moderator_notes', $moderator_notes, 240); |
|
482 | + } |
|
469 | 483 | } |
470 | 484 | |
471 | 485 | // Lets construct a page index. |
@@ -504,8 +518,9 @@ discard block |
||
504 | 518 | // Got the info already? |
505 | 519 | $cachekey = md5(json_encode($user_info['mod_cache']['bq'])); |
506 | 520 | $context['reported_posts'] = array(); |
507 | - if ($user_info['mod_cache']['bq'] == '0=1') |
|
508 | - return 'reported_posts_block'; |
|
521 | + if ($user_info['mod_cache']['bq'] == '0=1') { |
|
522 | + return 'reported_posts_block'; |
|
523 | + } |
|
509 | 524 | |
510 | 525 | if (($reported_posts = cache_get_data('reported_posts_' . $cachekey, 90)) === null) |
511 | 526 | { |
@@ -529,8 +544,9 @@ discard block |
||
529 | 544 | ) |
530 | 545 | ); |
531 | 546 | $reported_posts = array(); |
532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
533 | - $reported_posts[] = $row; |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + $reported_posts[] = $row; |
|
549 | + } |
|
534 | 550 | $smcFunc['db_free_result']($request); |
535 | 551 | |
536 | 552 | // Cache it. |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | |
569 | 585 | $context['group_requests'] = array(); |
570 | 586 | // Make sure they can even moderate someone! |
571 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
572 | - return 'group_requests_block'; |
|
587 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
588 | + return 'group_requests_block'; |
|
589 | + } |
|
573 | 590 | |
574 | 591 | // What requests are outstanding? |
575 | 592 | $request = $smcFunc['db_query']('', ' |
@@ -618,8 +635,9 @@ discard block |
||
618 | 635 | // Got the info already? |
619 | 636 | $cachekey = md5(json_encode((int) allowedTo('moderate_forum'))); |
620 | 637 | $context['reported_users'] = array(); |
621 | - if (!allowedTo('moderate_forum')) |
|
622 | - return 'reported_users_block'; |
|
638 | + if (!allowedTo('moderate_forum')) { |
|
639 | + return 'reported_users_block'; |
|
640 | + } |
|
623 | 641 | |
624 | 642 | if (($reported_users = cache_get_data('reported_users_' . $cachekey, 90)) === null) |
625 | 643 | { |
@@ -642,8 +660,9 @@ discard block |
||
642 | 660 | ) |
643 | 661 | ); |
644 | 662 | $reported_users = array(); |
645 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
646 | - $reported_users[] = $row; |
|
663 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
664 | + $reported_users[] = $row; |
|
665 | + } |
|
647 | 666 | $smcFunc['db_free_result']($request); |
648 | 667 | |
649 | 668 | // Cache it. |
@@ -691,8 +710,9 @@ discard block |
||
691 | 710 | isAllowedTo('moderate_forum'); |
692 | 711 | |
693 | 712 | // Are they wanting to view a particular report? |
694 | - if (!empty($_REQUEST['report'])) |
|
695 | - return MemberReport(); |
|
713 | + if (!empty($_REQUEST['report'])) { |
|
714 | + return MemberReport(); |
|
715 | + } |
|
696 | 716 | |
697 | 717 | // Set up the comforting bits... |
698 | 718 | $context['page_title'] = $txt['mc_reported_members']; |
@@ -746,15 +766,15 @@ discard block |
||
746 | 766 | // Time to update. |
747 | 767 | updateSettings(array('last_mod_report_action' => time())); |
748 | 768 | recountOpenReports('members'); |
749 | - } |
|
750 | - elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
769 | + } elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
751 | 770 | { |
752 | 771 | checkSession(); |
753 | 772 | |
754 | 773 | // All the ones to update... |
755 | 774 | $toClose = array(); |
756 | - foreach ($_POST['close'] as $rid) |
|
757 | - $toClose[] = (int) $rid; |
|
775 | + foreach ($_POST['close'] as $rid) { |
|
776 | + $toClose[] = (int) $rid; |
|
777 | + } |
|
758 | 778 | |
759 | 779 | if (!empty($toClose)) |
760 | 780 | { |
@@ -907,8 +927,9 @@ discard block |
||
907 | 927 | global $context, $user_info; |
908 | 928 | |
909 | 929 | // You need to be allowed to moderate groups... |
910 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
911 | - isAllowedTo('manage_membergroups'); |
|
930 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
931 | + isAllowedTo('manage_membergroups'); |
|
932 | + } |
|
912 | 933 | |
913 | 934 | // Load the group templates. |
914 | 935 | loadTemplate('ModerationCenter'); |
@@ -919,8 +940,9 @@ discard block |
||
919 | 940 | 'view' => 'ViewGroups', |
920 | 941 | ); |
921 | 942 | |
922 | - if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
923 | - $_GET['sa'] = 'view'; |
|
943 | + if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
944 | + $_GET['sa'] = 'view'; |
|
945 | + } |
|
924 | 946 | $context['sub_action'] = $_GET['sa']; |
925 | 947 | |
926 | 948 | // Call the relevant function. |
@@ -950,8 +972,9 @@ discard block |
||
950 | 972 | 'id_notice' => $id_notice, |
951 | 973 | ) |
952 | 974 | ); |
953 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
954 | - fatal_lang_error('no_access', false); |
|
975 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
976 | + fatal_lang_error('no_access', false); |
|
977 | + } |
|
955 | 978 | list ($context['notice_body'], $context['notice_subject']) = $smcFunc['db_fetch_row']($request); |
956 | 979 | $smcFunc['db_free_result']($request); |
957 | 980 | |
@@ -988,18 +1011,20 @@ discard block |
||
988 | 1011 | checkSession(!is_array($_REQUEST['delete']) ? 'get' : 'post'); |
989 | 1012 | |
990 | 1013 | $toDelete = array(); |
991 | - if (!is_array($_REQUEST['delete'])) |
|
992 | - $toDelete[] = (int) $_REQUEST['delete']; |
|
993 | - else |
|
994 | - foreach ($_REQUEST['delete'] as $did) |
|
1014 | + if (!is_array($_REQUEST['delete'])) { |
|
1015 | + $toDelete[] = (int) $_REQUEST['delete']; |
|
1016 | + } else { |
|
1017 | + foreach ($_REQUEST['delete'] as $did) |
|
995 | 1018 | $toDelete[] = (int) $did; |
1019 | + } |
|
996 | 1020 | |
997 | 1021 | if (!empty($toDelete)) |
998 | 1022 | { |
999 | 1023 | require_once($sourcedir . '/RemoveTopic.php'); |
1000 | 1024 | // If they don't have permission we'll let it error - either way no chance of a security slip here! |
1001 | - foreach ($toDelete as $did) |
|
1002 | - removeMessage($did); |
|
1025 | + foreach ($toDelete as $did) { |
|
1026 | + removeMessage($did); |
|
1027 | + } |
|
1003 | 1028 | } |
1004 | 1029 | } |
1005 | 1030 | |
@@ -1008,20 +1033,21 @@ discard block |
||
1008 | 1033 | { |
1009 | 1034 | $approve_query = ''; |
1010 | 1035 | $delete_boards = array(); |
1011 | - } |
|
1012 | - else |
|
1036 | + } else |
|
1013 | 1037 | { |
1014 | 1038 | // Still obey permissions! |
1015 | 1039 | $approve_boards = boardsAllowedTo('approve_posts'); |
1016 | 1040 | $delete_boards = boardsAllowedTo('delete_any'); |
1017 | 1041 | |
1018 | - if ($approve_boards == array(0)) |
|
1019 | - $approve_query = ''; |
|
1020 | - elseif (!empty($approve_boards)) |
|
1021 | - $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1042 | + if ($approve_boards == array(0)) { |
|
1043 | + $approve_query = ''; |
|
1044 | + } elseif (!empty($approve_boards)) { |
|
1045 | + $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1046 | + } |
|
1022 | 1047 | // Nada, zip, etc... |
1023 | - else |
|
1024 | - $approve_query = ' AND 1=0'; |
|
1048 | + else { |
|
1049 | + $approve_query = ' AND 1=0'; |
|
1050 | + } |
|
1025 | 1051 | } |
1026 | 1052 | |
1027 | 1053 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1120,10 +1146,11 @@ discard block |
||
1120 | 1146 | 'data' => array( |
1121 | 1147 | 'function' => function($member) use ($scripturl) |
1122 | 1148 | { |
1123 | - if ($member['last_post_id']) |
|
1124 | - return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1125 | - else |
|
1126 | - return $member['last_post']; |
|
1149 | + if ($member['last_post_id']) { |
|
1150 | + return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1151 | + } else { |
|
1152 | + return $member['last_post']; |
|
1153 | + } |
|
1127 | 1154 | }, |
1128 | 1155 | ), |
1129 | 1156 | ), |
@@ -1251,8 +1278,9 @@ discard block |
||
1251 | 1278 | ) |
1252 | 1279 | ); |
1253 | 1280 | $latest_posts = array(); |
1254 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1255 | - $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1281 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1282 | + $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1283 | + } |
|
1256 | 1284 | |
1257 | 1285 | if (!empty($latest_posts)) |
1258 | 1286 | { |
@@ -1443,15 +1471,17 @@ discard block |
||
1443 | 1471 | // Setup the direction stuff... |
1444 | 1472 | $context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'member'; |
1445 | 1473 | |
1446 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
1447 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1448 | - else |
|
1449 | - $search_params_string = $search_params['string']; |
|
1474 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
1475 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1476 | + } else { |
|
1477 | + $search_params_string = $search_params['string']; |
|
1478 | + } |
|
1450 | 1479 | |
1451 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
1452 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1453 | - else |
|
1454 | - $search_params_type = $search_params['type']; |
|
1480 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
1481 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1482 | + } else { |
|
1483 | + $search_params_type = $search_params['type']; |
|
1484 | + } |
|
1455 | 1485 | |
1456 | 1486 | $search_params = array( |
1457 | 1487 | 'string' => $search_params_string, |
@@ -1534,9 +1564,10 @@ discard block |
||
1534 | 1564 | ' . $rowData['reason'] . ' |
1535 | 1565 | </div>'; |
1536 | 1566 | |
1537 | - if (!empty($rowData['id_notice'])) |
|
1538 | - $output .= ' |
|
1567 | + if (!empty($rowData['id_notice'])) { |
|
1568 | + $output .= ' |
|
1539 | 1569 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $rowData['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>'; |
1570 | + } |
|
1540 | 1571 | return $output; |
1541 | 1572 | }, |
1542 | 1573 | ), |
@@ -1654,9 +1685,9 @@ discard block |
||
1654 | 1685 | global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info; |
1655 | 1686 | |
1656 | 1687 | // Submitting a new one? |
1657 | - if (isset($_POST['add'])) |
|
1658 | - return ModifyWarningTemplate(); |
|
1659 | - elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1688 | + if (isset($_POST['add'])) { |
|
1689 | + return ModifyWarningTemplate(); |
|
1690 | + } elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1660 | 1691 | { |
1661 | 1692 | checkSession(); |
1662 | 1693 | validateToken('mod-wt'); |
@@ -1675,8 +1706,9 @@ discard block |
||
1675 | 1706 | 'current_member' => $user_info['id'], |
1676 | 1707 | ) |
1677 | 1708 | ); |
1678 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1679 | - logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1709 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1710 | + logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1711 | + } |
|
1680 | 1712 | $smcFunc['db_free_result']($request); |
1681 | 1713 | |
1682 | 1714 | // Do the deletes. |
@@ -1967,16 +1999,18 @@ discard block |
||
1967 | 1999 | ); |
1968 | 2000 | |
1969 | 2001 | // If it wasn't visible and now is they've effectively added it. |
1970 | - if ($context['template_data']['personal'] && !$recipient_id) |
|
1971 | - logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2002 | + if ($context['template_data']['personal'] && !$recipient_id) { |
|
2003 | + logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2004 | + } |
|
1972 | 2005 | // Conversely if they made it personal it's a delete. |
1973 | - elseif (!$context['template_data']['personal'] && $recipient_id) |
|
1974 | - logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2006 | + elseif (!$context['template_data']['personal'] && $recipient_id) { |
|
2007 | + logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2008 | + } |
|
1975 | 2009 | // Otherwise just an edit. |
1976 | - else |
|
1977 | - logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
1978 | - } |
|
1979 | - else |
|
2010 | + else { |
|
2011 | + logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
2012 | + } |
|
2013 | + } else |
|
1980 | 2014 | { |
1981 | 2015 | $smcFunc['db_insert']('', |
1982 | 2016 | '{db_prefix}log_comments', |
@@ -1996,17 +2030,18 @@ discard block |
||
1996 | 2030 | |
1997 | 2031 | // Get out of town... |
1998 | 2032 | redirectexit('action=moderate;area=warnings;sa=templates'); |
1999 | - } |
|
2000 | - else |
|
2033 | + } else |
|
2001 | 2034 | { |
2002 | 2035 | $context['warning_errors'] = array(); |
2003 | 2036 | $context['template_data']['title'] = !empty($_POST['template_title']) ? $_POST['template_title'] : ''; |
2004 | 2037 | $context['template_data']['body'] = !empty($_POST['template_body']) ? $_POST['template_body'] : $txt['mc_warning_template_body_default']; |
2005 | 2038 | $context['template_data']['personal'] = !empty($_POST['make_personal']); |
2006 | - if (empty($_POST['template_title'])) |
|
2007 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2008 | - if (empty($_POST['template_body'])) |
|
2009 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2039 | + if (empty($_POST['template_title'])) { |
|
2040 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2041 | + } |
|
2042 | + if (empty($_POST['template_body'])) { |
|
2043 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2044 | + } |
|
2010 | 2045 | } |
2011 | 2046 | } |
2012 | 2047 | |
@@ -2051,8 +2086,9 @@ discard block |
||
2051 | 2086 | // Now check other options! |
2052 | 2087 | $pref_binary = 0; |
2053 | 2088 | |
2054 | - if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) |
|
2055 | - $pref_binary |= 4; |
|
2089 | + if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) { |
|
2090 | + $pref_binary |= 4; |
|
2091 | + } |
|
2056 | 2092 | |
2057 | 2093 | // Put it all together. |
2058 | 2094 | $mod_prefs = '0||' . $pref_binary; |
@@ -2076,9 +2112,10 @@ discard block |
||
2076 | 2112 | unset($_SESSION['moderate_time']); |
2077 | 2113 | |
2078 | 2114 | // Clean any moderator tokens as well. |
2079 | - foreach ($_SESSION['token'] as $key => $token) |
|
2080 | - if (strpos($key, '-mod') !== false) |
|
2115 | + foreach ($_SESSION['token'] as $key => $token) { |
|
2116 | + if (strpos($key, '-mod') !== false) |
|
2081 | 2117 | unset($_SESSION['token'][$key]); |
2118 | + } |
|
2082 | 2119 | |
2083 | 2120 | redirectexit(); |
2084 | 2121 | } |