@@ -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 | /* The contents of this file handle the deletion of topics, posts, and related |
21 | 22 | paraphernalia. It has the following functions: |
@@ -37,8 +38,9 @@ discard block |
||
37 | 38 | require_once($sourcedir . '/Subs-Post.php'); |
38 | 39 | |
39 | 40 | // Trying to fool us around, are we? |
40 | - if (empty($topic)) |
|
41 | - redirectexit(); |
|
41 | + if (empty($topic)) { |
|
42 | + redirectexit(); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | removeDeleteConcurrence(); |
44 | 46 | |
@@ -55,20 +57,23 @@ discard block |
||
55 | 57 | list ($starter, $subject, $approved, $locked) = $smcFunc['db_fetch_row']($request); |
56 | 58 | $smcFunc['db_free_result']($request); |
57 | 59 | |
58 | - if ($starter == $user_info['id'] && !allowedTo('remove_any')) |
|
59 | - isAllowedTo('remove_own'); |
|
60 | - else |
|
61 | - isAllowedTo('remove_any'); |
|
60 | + if ($starter == $user_info['id'] && !allowedTo('remove_any')) { |
|
61 | + isAllowedTo('remove_own'); |
|
62 | + } else { |
|
63 | + isAllowedTo('remove_any'); |
|
64 | + } |
|
62 | 65 | |
63 | 66 | // Can they see the topic? |
64 | - if ($modSettings['postmod_active'] && !$approved && $starter != $user_info['id']) |
|
65 | - isAllowedTo('approve_posts'); |
|
67 | + if ($modSettings['postmod_active'] && !$approved && $starter != $user_info['id']) { |
|
68 | + isAllowedTo('approve_posts'); |
|
69 | + } |
|
66 | 70 | |
67 | 71 | // Ok, we got that far, but is it locked? |
68 | 72 | if ($locked) |
69 | 73 | { |
70 | - if (!($locked == 1 && $starter == $user_info['id'] || allowedTo('lock_any'))) |
|
71 | - fatal_lang_error('cannot_remove_locked', 'user'); |
|
74 | + if (!($locked == 1 && $starter == $user_info['id'] || allowedTo('lock_any'))) { |
|
75 | + fatal_lang_error('cannot_remove_locked', 'user'); |
|
76 | + } |
|
72 | 77 | } |
73 | 78 | |
74 | 79 | // Notify people that this topic has been removed. |
@@ -77,8 +82,9 @@ discard block |
||
77 | 82 | removeTopics($topic); |
78 | 83 | |
79 | 84 | // Note, only log topic ID in native form if it's not gone forever. |
80 | - if (allowedTo('remove_any') || (allowedTo('remove_own') && $starter == $user_info['id'])) |
|
81 | - logAction('remove', array((empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $board ? 'topic' : 'old_topic_id') => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board)); |
|
85 | + if (allowedTo('remove_any') || (allowedTo('remove_own') && $starter == $user_info['id'])) { |
|
86 | + logAction('remove', array((empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $board ? 'topic' : 'old_topic_id') => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board)); |
|
87 | + } |
|
82 | 88 | |
83 | 89 | redirectexit('board=' . $board . '.0'); |
84 | 90 | } |
@@ -96,8 +102,9 @@ discard block |
||
96 | 102 | $_REQUEST['msg'] = (int) $_REQUEST['msg']; |
97 | 103 | |
98 | 104 | // Is $topic set? |
99 | - if (empty($topic) && isset($_REQUEST['topic'])) |
|
100 | - $topic = (int) $_REQUEST['topic']; |
|
105 | + if (empty($topic) && isset($_REQUEST['topic'])) { |
|
106 | + $topic = (int) $_REQUEST['topic']; |
|
107 | + } |
|
101 | 108 | |
102 | 109 | removeDeleteConcurrence(); |
103 | 110 | |
@@ -116,44 +123,48 @@ discard block |
||
116 | 123 | $smcFunc['db_free_result']($request); |
117 | 124 | |
118 | 125 | // Verify they can see this! |
119 | - if ($modSettings['postmod_active'] && !$approved && !empty($poster) && $poster != $user_info['id']) |
|
120 | - isAllowedTo('approve_posts'); |
|
126 | + if ($modSettings['postmod_active'] && !$approved && !empty($poster) && $poster != $user_info['id']) { |
|
127 | + isAllowedTo('approve_posts'); |
|
128 | + } |
|
121 | 129 | |
122 | 130 | if ($poster == $user_info['id']) |
123 | 131 | { |
124 | 132 | if (!allowedTo('delete_own')) |
125 | 133 | { |
126 | - if ($starter == $user_info['id'] && !allowedTo('delete_any')) |
|
127 | - isAllowedTo('delete_replies'); |
|
128 | - elseif (!allowedTo('delete_any')) |
|
129 | - isAllowedTo('delete_own'); |
|
134 | + if ($starter == $user_info['id'] && !allowedTo('delete_any')) { |
|
135 | + isAllowedTo('delete_replies'); |
|
136 | + } elseif (!allowedTo('delete_any')) { |
|
137 | + isAllowedTo('delete_own'); |
|
138 | + } |
|
139 | + } elseif (!allowedTo('delete_any') && ($starter != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $post_time + $modSettings['edit_disable_time'] * 60 < time()) { |
|
140 | + fatal_lang_error('modify_post_time_passed', false); |
|
130 | 141 | } |
131 | - elseif (!allowedTo('delete_any') && ($starter != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $post_time + $modSettings['edit_disable_time'] * 60 < time()) |
|
132 | - fatal_lang_error('modify_post_time_passed', false); |
|
142 | + } elseif ($starter == $user_info['id'] && !allowedTo('delete_any')) { |
|
143 | + isAllowedTo('delete_replies'); |
|
144 | + } else { |
|
145 | + isAllowedTo('delete_any'); |
|
133 | 146 | } |
134 | - elseif ($starter == $user_info['id'] && !allowedTo('delete_any')) |
|
135 | - isAllowedTo('delete_replies'); |
|
136 | - else |
|
137 | - isAllowedTo('delete_any'); |
|
138 | 147 | |
139 | 148 | // If the full topic was removed go back to the board. |
140 | 149 | $full_topic = removeMessage($_REQUEST['msg']); |
141 | 150 | |
142 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $poster != $user_info['id'])) |
|
143 | - logAction('delete', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board)); |
|
151 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $poster != $user_info['id'])) { |
|
152 | + logAction('delete', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board)); |
|
153 | + } |
|
144 | 154 | |
145 | 155 | // We want to redirect back to recent action. |
146 | - if (isset($_REQUEST['modcenter'])) |
|
147 | - redirectexit('action=moderate;area=reportedposts;done'); |
|
148 | - elseif (isset($_REQUEST['recent'])) |
|
149 | - redirectexit('action=recent'); |
|
150 | - elseif (isset($_REQUEST['profile'], $_REQUEST['start'], $_REQUEST['u'])) |
|
151 | - redirectexit('action=profile;u=' . $_REQUEST['u'] . ';area=showposts;start=' . $_REQUEST['start']); |
|
152 | - elseif ($full_topic) |
|
153 | - redirectexit('board=' . $board . '.0'); |
|
154 | - else |
|
155 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
156 | -} |
|
156 | + if (isset($_REQUEST['modcenter'])) { |
|
157 | + redirectexit('action=moderate;area=reportedposts;done'); |
|
158 | + } elseif (isset($_REQUEST['recent'])) { |
|
159 | + redirectexit('action=recent'); |
|
160 | + } elseif (isset($_REQUEST['profile'], $_REQUEST['start'], $_REQUEST['u'])) { |
|
161 | + redirectexit('action=profile;u=' . $_REQUEST['u'] . ';area=showposts;start=' . $_REQUEST['start']); |
|
162 | + } elseif ($full_topic) { |
|
163 | + redirectexit('board=' . $board . '.0'); |
|
164 | + } else { |
|
165 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
166 | + } |
|
167 | + } |
|
157 | 168 | |
158 | 169 | /** |
159 | 170 | * So long as you are sure... all old posts will be gone. |
@@ -167,8 +178,9 @@ discard block |
||
167 | 178 | checkSession('post', 'admin'); |
168 | 179 | |
169 | 180 | // No boards at all? Forget it then :/. |
170 | - if (empty($_POST['boards'])) |
|
171 | - redirectexit('action=admin;area=maintain;sa=topics'); |
|
181 | + if (empty($_POST['boards'])) { |
|
182 | + redirectexit('action=admin;area=maintain;sa=topics'); |
|
183 | + } |
|
172 | 184 | |
173 | 185 | // This should exist, but we can make sure. |
174 | 186 | $_POST['delete_type'] = isset($_POST['delete_type']) ? $_POST['delete_type'] : 'nothing'; |
@@ -222,8 +234,9 @@ discard block |
||
222 | 234 | $condition_params |
223 | 235 | ); |
224 | 236 | $topics = array(); |
225 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
226 | - $topics[] = $row['id_topic']; |
|
237 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
238 | + $topics[] = $row['id_topic']; |
|
239 | + } |
|
227 | 240 | $smcFunc['db_free_result']($request); |
228 | 241 | |
229 | 242 | removeTopics($topics, false, true); |
@@ -247,11 +260,13 @@ discard block |
||
247 | 260 | global $sourcedir, $modSettings, $smcFunc; |
248 | 261 | |
249 | 262 | // Nothing to do? |
250 | - if (empty($topics)) |
|
251 | - return; |
|
263 | + if (empty($topics)) { |
|
264 | + return; |
|
265 | + } |
|
252 | 266 | // Only a single topic. |
253 | - if (is_numeric($topics)) |
|
254 | - $topics = array($topics); |
|
267 | + if (is_numeric($topics)) { |
|
268 | + $topics = array($topics); |
|
269 | + } |
|
255 | 270 | |
256 | 271 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
257 | 272 | |
@@ -276,8 +291,9 @@ discard block |
||
276 | 291 | ); |
277 | 292 | if ($smcFunc['db_num_rows']($requestMembers) > 0) |
278 | 293 | { |
279 | - while ($rowMembers = $smcFunc['db_fetch_assoc']($requestMembers)) |
|
280 | - updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts'])); |
|
294 | + while ($rowMembers = $smcFunc['db_fetch_assoc']($requestMembers)) { |
|
295 | + updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts'])); |
|
296 | + } |
|
281 | 297 | } |
282 | 298 | $smcFunc['db_free_result']($requestMembers); |
283 | 299 | } |
@@ -303,8 +319,9 @@ discard block |
||
303 | 319 | $recycleTopics = array(); |
304 | 320 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
305 | 321 | { |
306 | - if (function_exists('apache_reset_timeout')) |
|
307 | - @apache_reset_timeout(); |
|
322 | + if (function_exists('apache_reset_timeout')) { |
|
323 | + @apache_reset_timeout(); |
|
324 | + } |
|
308 | 325 | |
309 | 326 | $recycleTopics[] = $row['id_topic']; |
310 | 327 | |
@@ -346,20 +363,22 @@ discard block |
||
346 | 363 | |
347 | 364 | // Topics that were recycled don't need to be deleted, so subtract them. |
348 | 365 | $topics = array_diff($topics, $recycleTopics); |
366 | + } else { |
|
367 | + $smcFunc['db_free_result']($request); |
|
349 | 368 | } |
350 | - else |
|
351 | - $smcFunc['db_free_result']($request); |
|
352 | 369 | } |
353 | 370 | |
354 | 371 | // Still topics left to delete? |
355 | - if (empty($topics)) |
|
356 | - return; |
|
372 | + if (empty($topics)) { |
|
373 | + return; |
|
374 | + } |
|
357 | 375 | |
358 | 376 | // Callback for search APIs to do their thing |
359 | 377 | require_once($sourcedir . '/Search.php'); |
360 | 378 | $searchAPI = findSearchAPI(); |
361 | - if ($searchAPI->supportsMethod('topicsRemoved')) |
|
362 | - $searchAPI->topicsRemoved($topics); |
|
379 | + if ($searchAPI->supportsMethod('topicsRemoved')) { |
|
380 | + $searchAPI->topicsRemoved($topics); |
|
381 | + } |
|
363 | 382 | |
364 | 383 | $adjustBoards = array(); |
365 | 384 | |
@@ -391,10 +410,11 @@ discard block |
||
391 | 410 | $adjustBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
392 | 411 | |
393 | 412 | // Add the topics to the right type. |
394 | - if ($row['approved']) |
|
395 | - $adjustBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
396 | - else |
|
397 | - $adjustBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
413 | + if ($row['approved']) { |
|
414 | + $adjustBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
415 | + } else { |
|
416 | + $adjustBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
417 | + } |
|
398 | 418 | } |
399 | 419 | $smcFunc['db_free_result']($request); |
400 | 420 | |
@@ -403,8 +423,9 @@ discard block |
||
403 | 423 | // Decrease the posts/topics... |
404 | 424 | foreach ($adjustBoards as $stats) |
405 | 425 | { |
406 | - if (function_exists('apache_reset_timeout')) |
|
407 | - @apache_reset_timeout(); |
|
426 | + if (function_exists('apache_reset_timeout')) { |
|
427 | + @apache_reset_timeout(); |
|
428 | + } |
|
408 | 429 | |
409 | 430 | $smcFunc['db_query']('', ' |
410 | 431 | UPDATE {db_prefix}boards |
@@ -438,8 +459,9 @@ discard block |
||
438 | 459 | ) |
439 | 460 | ); |
440 | 461 | $polls = array(); |
441 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
442 | - $polls[] = $row['id_poll']; |
|
462 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
463 | + $polls[] = $row['id_poll']; |
|
464 | + } |
|
443 | 465 | $smcFunc['db_free_result']($request); |
444 | 466 | |
445 | 467 | if (!empty($polls)) |
@@ -492,8 +514,9 @@ discard block |
||
492 | 514 | ); |
493 | 515 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
494 | 516 | { |
495 | - if (function_exists('apache_reset_timeout')) |
|
496 | - @apache_reset_timeout(); |
|
517 | + if (function_exists('apache_reset_timeout')) { |
|
518 | + @apache_reset_timeout(); |
|
519 | + } |
|
497 | 520 | |
498 | 521 | $words = array_merge($words, text2words($row['body'], $customIndexSettings['bytes_per_word'], true)); |
499 | 522 | $messages[] = $row['id_msg']; |
@@ -501,8 +524,8 @@ discard block |
||
501 | 524 | $smcFunc['db_free_result']($request); |
502 | 525 | $words = array_unique($words); |
503 | 526 | |
504 | - if (!empty($words) && !empty($messages)) |
|
505 | - $smcFunc['db_query']('', ' |
|
527 | + if (!empty($words) && !empty($messages)) { |
|
528 | + $smcFunc['db_query']('', ' |
|
506 | 529 | DELETE FROM {db_prefix}log_search_words |
507 | 530 | WHERE id_word IN ({array_int:word_list}) |
508 | 531 | AND id_msg IN ({array_int:message_list})', |
@@ -511,6 +534,7 @@ discard block |
||
511 | 534 | 'message_list' => $messages, |
512 | 535 | ) |
513 | 536 | ); |
537 | + } |
|
514 | 538 | } |
515 | 539 | |
516 | 540 | // Delete anything related to the topic. |
@@ -569,8 +593,9 @@ discard block |
||
569 | 593 | |
570 | 594 | require_once($sourcedir . '/Subs-Post.php'); |
571 | 595 | $updates = array(); |
572 | - foreach ($adjustBoards as $stats) |
|
573 | - $updates[] = $stats['id_board']; |
|
596 | + foreach ($adjustBoards as $stats) { |
|
597 | + $updates[] = $stats['id_board']; |
|
598 | + } |
|
574 | 599 | updateLastMessages($updates); |
575 | 600 | } |
576 | 601 | |
@@ -587,8 +612,9 @@ discard block |
||
587 | 612 | { |
588 | 613 | global $board, $sourcedir, $modSettings, $user_info, $smcFunc; |
589 | 614 | |
590 | - if (empty($message) || !is_numeric($message)) |
|
591 | - return false; |
|
615 | + if (empty($message) || !is_numeric($message)) { |
|
616 | + return false; |
|
617 | + } |
|
592 | 618 | |
593 | 619 | $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
594 | 620 | |
@@ -607,8 +633,9 @@ discard block |
||
607 | 633 | 'id_msg' => $message, |
608 | 634 | ) |
609 | 635 | ); |
610 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
611 | - return false; |
|
636 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
637 | + return false; |
|
638 | + } |
|
612 | 639 | $row = $smcFunc['db_fetch_assoc']($request); |
613 | 640 | $smcFunc['db_free_result']($request); |
614 | 641 | |
@@ -629,54 +656,57 @@ discard block |
||
629 | 656 | { |
630 | 657 | if ($row['id_member_poster'] == $user_info['id']) |
631 | 658 | { |
632 | - if (!$delete_replies) |
|
633 | - fatal_lang_error('cannot_delete_replies', 'permission'); |
|
659 | + if (!$delete_replies) { |
|
660 | + fatal_lang_error('cannot_delete_replies', 'permission'); |
|
661 | + } |
|
662 | + } else { |
|
663 | + fatal_lang_error('cannot_delete_own', 'permission'); |
|
634 | 664 | } |
635 | - else |
|
636 | - fatal_lang_error('cannot_delete_own', 'permission'); |
|
665 | + } elseif (($row['id_member_poster'] != $user_info['id'] || !$delete_replies) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
666 | + fatal_lang_error('modify_post_time_passed', false); |
|
637 | 667 | } |
638 | - elseif (($row['id_member_poster'] != $user_info['id'] || !$delete_replies) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
639 | - fatal_lang_error('modify_post_time_passed', false); |
|
640 | - } |
|
641 | - elseif ($row['id_member_poster'] == $user_info['id']) |
|
668 | + } elseif ($row['id_member_poster'] == $user_info['id']) |
|
642 | 669 | { |
643 | - if (!$delete_replies) |
|
644 | - fatal_lang_error('cannot_delete_replies', 'permission'); |
|
670 | + if (!$delete_replies) { |
|
671 | + fatal_lang_error('cannot_delete_replies', 'permission'); |
|
672 | + } |
|
673 | + } else { |
|
674 | + fatal_lang_error('cannot_delete_any', 'permission'); |
|
645 | 675 | } |
646 | - else |
|
647 | - fatal_lang_error('cannot_delete_any', 'permission'); |
|
648 | 676 | } |
649 | 677 | |
650 | 678 | // Can't delete an unapproved message, if you can't see it! |
651 | 679 | if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !(in_array(0, $delete_any) || in_array($row['id_board'], $delete_any))) |
652 | 680 | { |
653 | 681 | $approve_posts = boardsAllowedTo('approve_posts'); |
654 | - if (!in_array(0, $approve_posts) && !in_array($row['id_board'], $approve_posts)) |
|
655 | - return false; |
|
682 | + if (!in_array(0, $approve_posts) && !in_array($row['id_board'], $approve_posts)) { |
|
683 | + return false; |
|
684 | + } |
|
656 | 685 | } |
657 | - } |
|
658 | - else |
|
686 | + } else |
|
659 | 687 | { |
660 | 688 | // Check permissions to delete this message. |
661 | 689 | if ($row['id_member'] == $user_info['id']) |
662 | 690 | { |
663 | 691 | if (!allowedTo('delete_own')) |
664 | 692 | { |
665 | - if ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) |
|
666 | - isAllowedTo('delete_replies'); |
|
667 | - elseif (!allowedTo('delete_any')) |
|
668 | - isAllowedTo('delete_own'); |
|
693 | + if ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) { |
|
694 | + isAllowedTo('delete_replies'); |
|
695 | + } elseif (!allowedTo('delete_any')) { |
|
696 | + isAllowedTo('delete_own'); |
|
697 | + } |
|
698 | + } elseif (!allowedTo('delete_any') && ($row['id_member_poster'] != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
699 | + fatal_lang_error('modify_post_time_passed', false); |
|
669 | 700 | } |
670 | - elseif (!allowedTo('delete_any') && ($row['id_member_poster'] != $user_info['id'] || !allowedTo('delete_replies')) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
671 | - fatal_lang_error('modify_post_time_passed', false); |
|
701 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) { |
|
702 | + isAllowedTo('delete_replies'); |
|
703 | + } else { |
|
704 | + isAllowedTo('delete_any'); |
|
672 | 705 | } |
673 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('delete_any')) |
|
674 | - isAllowedTo('delete_replies'); |
|
675 | - else |
|
676 | - isAllowedTo('delete_any'); |
|
677 | 706 | |
678 | - if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !allowedTo('delete_own')) |
|
679 | - isAllowedTo('approve_posts'); |
|
707 | + if ($modSettings['postmod_active'] && !$row['approved'] && $row['id_member'] != $user_info['id'] && !allowedTo('delete_own')) { |
|
708 | + isAllowedTo('approve_posts'); |
|
709 | + } |
|
680 | 710 | } |
681 | 711 | |
682 | 712 | // Delete the *whole* topic, but only if the topic consists of one message. |
@@ -692,31 +722,34 @@ discard block |
||
692 | 722 | $remove_own = in_array(0, $remove_own) || in_array($row['id_board'], $remove_own); |
693 | 723 | } |
694 | 724 | |
695 | - if ($row['id_member'] != $user_info['id'] && !$remove_any) |
|
696 | - fatal_lang_error('cannot_remove_any', 'permission'); |
|
697 | - elseif (!$remove_any && !$remove_own) |
|
698 | - fatal_lang_error('cannot_remove_own', 'permission'); |
|
699 | - } |
|
700 | - else |
|
725 | + if ($row['id_member'] != $user_info['id'] && !$remove_any) { |
|
726 | + fatal_lang_error('cannot_remove_any', 'permission'); |
|
727 | + } elseif (!$remove_any && !$remove_own) { |
|
728 | + fatal_lang_error('cannot_remove_own', 'permission'); |
|
729 | + } |
|
730 | + } else |
|
701 | 731 | { |
702 | 732 | // Check permissions to delete a whole topic. |
703 | - if ($row['id_member'] != $user_info['id']) |
|
704 | - isAllowedTo('remove_any'); |
|
705 | - elseif (!allowedTo('remove_any')) |
|
706 | - isAllowedTo('remove_own'); |
|
733 | + if ($row['id_member'] != $user_info['id']) { |
|
734 | + isAllowedTo('remove_any'); |
|
735 | + } elseif (!allowedTo('remove_any')) { |
|
736 | + isAllowedTo('remove_own'); |
|
737 | + } |
|
707 | 738 | } |
708 | 739 | |
709 | 740 | // ...if there is only one post. |
710 | - if (!empty($row['num_replies'])) |
|
711 | - fatal_lang_error('delFirstPost', false); |
|
741 | + if (!empty($row['num_replies'])) { |
|
742 | + fatal_lang_error('delFirstPost', false); |
|
743 | + } |
|
712 | 744 | |
713 | 745 | removeTopics($row['id_topic']); |
714 | 746 | return true; |
715 | 747 | } |
716 | 748 | |
717 | 749 | // Deleting a recycled message can not lower anyone's post count. |
718 | - if (!empty($recycle_board) && $row['id_board'] == $recycle_board) |
|
719 | - $decreasePostCount = false; |
|
750 | + if (!empty($recycle_board) && $row['id_board'] == $recycle_board) { |
|
751 | + $decreasePostCount = false; |
|
752 | + } |
|
720 | 753 | |
721 | 754 | // This is the last post, update the last post on the board. |
722 | 755 | if ($row['id_last_msg'] == $message) |
@@ -755,8 +788,8 @@ discard block |
||
755 | 788 | ); |
756 | 789 | } |
757 | 790 | // Only decrease post counts. |
758 | - else |
|
759 | - $smcFunc['db_query']('', ' |
|
791 | + else { |
|
792 | + $smcFunc['db_query']('', ' |
|
760 | 793 | UPDATE {db_prefix}topics |
761 | 794 | SET ' . ($row['approved'] ? ' |
762 | 795 | num_replies = CASE WHEN num_replies = {int:no_replies} THEN 0 ELSE num_replies - 1 END' : ' |
@@ -768,6 +801,7 @@ discard block |
||
768 | 801 | 'id_topic' => $row['id_topic'], |
769 | 802 | ) |
770 | 803 | ); |
804 | + } |
|
771 | 805 | |
772 | 806 | // Default recycle to false. |
773 | 807 | $recycle = false; |
@@ -787,8 +821,9 @@ discard block |
||
787 | 821 | 'recycle_board' => $modSettings['recycle_board'], |
788 | 822 | ) |
789 | 823 | ); |
790 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
791 | - fatal_lang_error('recycle_no_valid_board'); |
|
824 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
825 | + fatal_lang_error('recycle_no_valid_board'); |
|
826 | + } |
|
792 | 827 | list ($isRead, $last_board_msg) = $smcFunc['db_fetch_row']($request); |
793 | 828 | $smcFunc['db_free_result']($request); |
794 | 829 | |
@@ -807,8 +842,8 @@ discard block |
||
807 | 842 | $smcFunc['db_free_result']($request); |
808 | 843 | |
809 | 844 | // Insert a new topic in the recycle board if $id_recycle_topic is empty. |
810 | - if (empty($id_recycle_topic)) |
|
811 | - $id_topic = $smcFunc['db_insert']('', |
|
845 | + if (empty($id_recycle_topic)) { |
|
846 | + $id_topic = $smcFunc['db_insert']('', |
|
812 | 847 | '{db_prefix}topics', |
813 | 848 | array( |
814 | 849 | 'id_board' => 'int', 'id_member_started' => 'int', 'id_member_updated' => 'int', 'id_first_msg' => 'int', |
@@ -821,6 +856,7 @@ discard block |
||
821 | 856 | array('id_topic'), |
822 | 857 | 1 |
823 | 858 | ); |
859 | + } |
|
824 | 860 | |
825 | 861 | // Capture the ID of the new topic... |
826 | 862 | $topicID = empty($id_recycle_topic) ? $id_topic : $id_recycle_topic; |
@@ -858,22 +894,24 @@ discard block |
||
858 | 894 | ); |
859 | 895 | |
860 | 896 | // Mark recycled topic as read. |
861 | - if (!$user_info['is_guest']) |
|
862 | - $smcFunc['db_insert']('replace', |
|
897 | + if (!$user_info['is_guest']) { |
|
898 | + $smcFunc['db_insert']('replace', |
|
863 | 899 | '{db_prefix}log_topics', |
864 | 900 | array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int', 'unwatched' => 'int'), |
865 | 901 | array($topicID, $user_info['id'], $modSettings['maxMsgID'], 0), |
866 | 902 | array('id_topic', 'id_member') |
867 | 903 | ); |
904 | + } |
|
868 | 905 | |
869 | 906 | // Mark recycle board as seen, if it was marked as seen before. |
870 | - if (!empty($isRead) && !$user_info['is_guest']) |
|
871 | - $smcFunc['db_insert']('replace', |
|
907 | + if (!empty($isRead) && !$user_info['is_guest']) { |
|
908 | + $smcFunc['db_insert']('replace', |
|
872 | 909 | '{db_prefix}log_boards', |
873 | 910 | array('id_board' => 'int', 'id_member' => 'int', 'id_msg' => 'int'), |
874 | 911 | array($modSettings['recycle_board'], $user_info['id'], $modSettings['maxMsgID']), |
875 | 912 | array('id_board', 'id_member') |
876 | 913 | ); |
914 | + } |
|
877 | 915 | |
878 | 916 | // Add one topic and post to the recycle bin board. |
879 | 917 | $smcFunc['db_query']('', ' |
@@ -891,8 +929,8 @@ discard block |
||
891 | 929 | ); |
892 | 930 | |
893 | 931 | // Lets increase the num_replies, and the first/last message ID as appropriate. |
894 | - if (!empty($id_recycle_topic)) |
|
895 | - $smcFunc['db_query']('', ' |
|
932 | + if (!empty($id_recycle_topic)) { |
|
933 | + $smcFunc['db_query']('', ' |
|
896 | 934 | UPDATE {db_prefix}topics |
897 | 935 | SET num_replies = num_replies + 1' . |
898 | 936 | ($message > $last_topic_msg ? ', id_last_msg = {int:id_merged_msg}' : '') . |
@@ -903,6 +941,7 @@ discard block |
||
903 | 941 | 'id_merged_msg' => $message, |
904 | 942 | ) |
905 | 943 | ); |
944 | + } |
|
906 | 945 | |
907 | 946 | // Make sure this message isn't getting deleted later on. |
908 | 947 | $recycle = true; |
@@ -912,8 +951,8 @@ discard block |
||
912 | 951 | } |
913 | 952 | |
914 | 953 | // If it wasn't approved don't keep it in the queue. |
915 | - if (!$row['approved']) |
|
916 | - $smcFunc['db_query']('', ' |
|
954 | + if (!$row['approved']) { |
|
955 | + $smcFunc['db_query']('', ' |
|
917 | 956 | DELETE FROM {db_prefix}approval_queue |
918 | 957 | WHERE id_msg = {int:id_msg} |
919 | 958 | AND id_attach = {int:id_attach}', |
@@ -922,6 +961,7 @@ discard block |
||
922 | 961 | 'id_attach' => 0, |
923 | 962 | ) |
924 | 963 | ); |
964 | + } |
|
925 | 965 | } |
926 | 966 | |
927 | 967 | $smcFunc['db_query']('', ' |
@@ -939,8 +979,9 @@ discard block |
||
939 | 979 | |
940 | 980 | // If the poster was registered and the board this message was on incremented |
941 | 981 | // the member's posts when it was posted, decrease his or her post count. |
942 | - if (!empty($row['id_member']) && $decreasePostCount && empty($row['count_posts']) && $row['approved']) |
|
943 | - updateMemberData($row['id_member'], array('posts' => '-')); |
|
982 | + if (!empty($row['id_member']) && $decreasePostCount && empty($row['count_posts']) && $row['approved']) { |
|
983 | + updateMemberData($row['id_member'], array('posts' => '-')); |
|
984 | + } |
|
944 | 985 | |
945 | 986 | // Only remove posts if they're not recycled. |
946 | 987 | if (!$recycle) |
@@ -948,8 +989,9 @@ discard block |
||
948 | 989 | // Callback for search APIs to do their thing |
949 | 990 | require_once($sourcedir . '/Search.php'); |
950 | 991 | $searchAPI = findSearchAPI(); |
951 | - if ($searchAPI->supportsMethod('postRemoved')) |
|
952 | - $searchAPI->postRemoved($message); |
|
992 | + if ($searchAPI->supportsMethod('postRemoved')) { |
|
993 | + $searchAPI->postRemoved($message); |
|
994 | + } |
|
953 | 995 | |
954 | 996 | // Remove the message! |
955 | 997 | $smcFunc['db_query']('', ' |
@@ -964,8 +1006,8 @@ discard block |
||
964 | 1006 | { |
965 | 1007 | $customIndexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
966 | 1008 | $words = text2words($row['body'], $customIndexSettings['bytes_per_word'], true); |
967 | - if (!empty($words)) |
|
968 | - $smcFunc['db_query']('', ' |
|
1009 | + if (!empty($words)) { |
|
1010 | + $smcFunc['db_query']('', ' |
|
969 | 1011 | DELETE FROM {db_prefix}log_search_words |
970 | 1012 | WHERE id_word IN ({array_int:word_list}) |
971 | 1013 | AND id_msg = {int:id_msg}', |
@@ -974,6 +1016,7 @@ discard block |
||
974 | 1016 | 'id_msg' => $message, |
975 | 1017 | ) |
976 | 1018 | ); |
1019 | + } |
|
977 | 1020 | } |
978 | 1021 | |
979 | 1022 | // Delete attachment(s) if they exist. |
@@ -997,10 +1040,11 @@ discard block |
||
997 | 1040 | |
998 | 1041 | // And now to update the last message of each board we messed with. |
999 | 1042 | require_once($sourcedir . '/Subs-Post.php'); |
1000 | - if ($recycle) |
|
1001 | - updateLastMessages(array($row['id_board'], $modSettings['recycle_board'])); |
|
1002 | - else |
|
1003 | - updateLastMessages($row['id_board']); |
|
1043 | + if ($recycle) { |
|
1044 | + updateLastMessages(array($row['id_board'], $modSettings['recycle_board'])); |
|
1045 | + } else { |
|
1046 | + updateLastMessages($row['id_board']); |
|
1047 | + } |
|
1004 | 1048 | |
1005 | 1049 | // Close any moderation reports for this message. |
1006 | 1050 | $smcFunc['db_query']('', ' |
@@ -1033,8 +1077,9 @@ discard block |
||
1033 | 1077 | checkSession('get'); |
1034 | 1078 | |
1035 | 1079 | // Is recycled board enabled? |
1036 | - if (empty($modSettings['recycle_enable'])) |
|
1037 | - fatal_lang_error('restored_disabled', 'critical'); |
|
1080 | + if (empty($modSettings['recycle_enable'])) { |
|
1081 | + fatal_lang_error('restored_disabled', 'critical'); |
|
1082 | + } |
|
1038 | 1083 | |
1039 | 1084 | // Can we be in here? |
1040 | 1085 | isAllowedTo('move_any', $modSettings['recycle_board']); |
@@ -1049,8 +1094,9 @@ discard block |
||
1049 | 1094 | if (!empty($_REQUEST['msgs'])) |
1050 | 1095 | { |
1051 | 1096 | $msgs = explode(',', $_REQUEST['msgs']); |
1052 | - foreach ($msgs as $k => $msg) |
|
1053 | - $msgs[$k] = (int) $msg; |
|
1097 | + foreach ($msgs as $k => $msg) { |
|
1098 | + $msgs[$k] = (int) $msg; |
|
1099 | + } |
|
1054 | 1100 | |
1055 | 1101 | // Get the id_previous_board and id_previous_topic. |
1056 | 1102 | $request = $smcFunc['db_query']('', ' |
@@ -1084,8 +1130,8 @@ discard block |
||
1084 | 1130 | } |
1085 | 1131 | |
1086 | 1132 | $previous_topics[] = $row['id_previous_topic']; |
1087 | - if (empty($actioned_messages[$row['id_previous_topic']])) |
|
1088 | - $actioned_messages[$row['id_previous_topic']] = array( |
|
1133 | + if (empty($actioned_messages[$row['id_previous_topic']])) { |
|
1134 | + $actioned_messages[$row['id_previous_topic']] = array( |
|
1089 | 1135 | 'msgs' => array(), |
1090 | 1136 | 'count_posts' => $row['count_posts'], |
1091 | 1137 | 'subject' => $row['subject'], |
@@ -1095,17 +1141,20 @@ discard block |
||
1095 | 1141 | 'current_board' => $row['id_board'], |
1096 | 1142 | 'members' => array(), |
1097 | 1143 | ); |
1144 | + } |
|
1098 | 1145 | |
1099 | 1146 | $actioned_messages[$row['id_previous_topic']]['msgs'][$row['id_msg']] = $row['subject']; |
1100 | - if ($row['id_member']) |
|
1101 | - $actioned_messages[$row['id_previous_topic']]['members'][] = $row['id_member']; |
|
1147 | + if ($row['id_member']) { |
|
1148 | + $actioned_messages[$row['id_previous_topic']]['members'][] = $row['id_member']; |
|
1149 | + } |
|
1102 | 1150 | } |
1103 | 1151 | $smcFunc['db_free_result']($request); |
1104 | 1152 | |
1105 | 1153 | // Check for topics we are going to fully restore. |
1106 | - foreach ($actioned_messages as $topic => $data) |
|
1107 | - if (in_array($topic, $topics_to_restore)) |
|
1154 | + foreach ($actioned_messages as $topic => $data) { |
|
1155 | + if (in_array($topic, $topics_to_restore)) |
|
1108 | 1156 | unset($actioned_messages[$topic]); |
1157 | + } |
|
1109 | 1158 | |
1110 | 1159 | // Load any previous topics to check they exist. |
1111 | 1160 | if (!empty($previous_topics)) |
@@ -1120,11 +1169,12 @@ discard block |
||
1120 | 1169 | ) |
1121 | 1170 | ); |
1122 | 1171 | $previous_topics = array(); |
1123 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1124 | - $previous_topics[$row['id_topic']] = array( |
|
1172 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1173 | + $previous_topics[$row['id_topic']] = array( |
|
1125 | 1174 | 'board' => $row['id_board'], |
1126 | 1175 | 'subject' => $row['subject'], |
1127 | 1176 | ); |
1177 | + } |
|
1128 | 1178 | $smcFunc['db_free_result']($request); |
1129 | 1179 | } |
1130 | 1180 | |
@@ -1146,11 +1196,11 @@ discard block |
||
1146 | 1196 | // Log em. |
1147 | 1197 | logAction('restore_posts', array('topic' => $topic, 'subject' => $previous_topics[$topic]['subject'], 'board' => empty($data['previous_board']) ? $data['possible_prev_board'] : $data['previous_board'])); |
1148 | 1198 | $messages = array_merge(array_keys($data['msgs']), $messages); |
1149 | - } |
|
1150 | - else |
|
1199 | + } else |
|
1151 | 1200 | { |
1152 | - foreach ($data['msgs'] as $msg) |
|
1153 | - $unfound_messages[$msg['id']] = $msg['subject']; |
|
1201 | + foreach ($data['msgs'] as $msg) { |
|
1202 | + $unfound_messages[$msg['id']] = $msg['subject']; |
|
1203 | + } |
|
1154 | 1204 | } |
1155 | 1205 | } |
1156 | 1206 | } |
@@ -1159,8 +1209,9 @@ discard block |
||
1159 | 1209 | if (!empty($_REQUEST['topics'])) |
1160 | 1210 | { |
1161 | 1211 | $topics = explode(',', $_REQUEST['topics']); |
1162 | - foreach ($topics as $id) |
|
1163 | - $topics_to_restore[] = (int) $id; |
|
1212 | + foreach ($topics as $id) { |
|
1213 | + $topics_to_restore[] = (int) $id; |
|
1214 | + } |
|
1164 | 1215 | } |
1165 | 1216 | |
1166 | 1217 | if (!empty($topics_to_restore)) |
@@ -1214,8 +1265,9 @@ discard block |
||
1214 | 1265 | ) |
1215 | 1266 | ); |
1216 | 1267 | |
1217 | - while ($member = $smcFunc['db_fetch_assoc']($request2)) |
|
1218 | - updateMemberData($member['id_member'], array('posts' => 'posts + ' . $member['post_count'])); |
|
1268 | + while ($member = $smcFunc['db_fetch_assoc']($request2)) { |
|
1269 | + updateMemberData($member['id_member'], array('posts' => 'posts + ' . $member['post_count'])); |
|
1270 | + } |
|
1219 | 1271 | $smcFunc['db_free_result']($request2); |
1220 | 1272 | } |
1221 | 1273 | |
@@ -1226,8 +1278,9 @@ discard block |
||
1226 | 1278 | } |
1227 | 1279 | |
1228 | 1280 | // Didn't find some things? |
1229 | - if (!empty($unfound_messages)) |
|
1230 | - fatal_lang_error('restore_not_found', false, array(implode('<br>', $unfound_messages))); |
|
1281 | + if (!empty($unfound_messages)) { |
|
1282 | + fatal_lang_error('restore_not_found', false, array(implode('<br>', $unfound_messages))); |
|
1283 | + } |
|
1231 | 1284 | |
1232 | 1285 | // Just send them to the index if they get here. |
1233 | 1286 | redirectexit(); |
@@ -1247,12 +1300,14 @@ discard block |
||
1247 | 1300 | //!!! This really needs to be rewritten to take a load of messages from ANY topic, it's also inefficient. |
1248 | 1301 | |
1249 | 1302 | // Is it an array? |
1250 | - if (!is_array($msgs)) |
|
1251 | - $msgs = array($msgs); |
|
1303 | + if (!is_array($msgs)) { |
|
1304 | + $msgs = array($msgs); |
|
1305 | + } |
|
1252 | 1306 | |
1253 | 1307 | // Lets make sure they are int. |
1254 | - foreach ($msgs as $key => $msg) |
|
1255 | - $msgs[$key] = (int) $msg; |
|
1308 | + foreach ($msgs as $key => $msg) { |
|
1309 | + $msgs[$key] = (int) $msg; |
|
1310 | + } |
|
1256 | 1311 | |
1257 | 1312 | // Get the source information. |
1258 | 1313 | $request = $smcFunc['db_query']('', ' |
@@ -1295,8 +1350,9 @@ discard block |
||
1295 | 1350 | ) |
1296 | 1351 | ); |
1297 | 1352 | |
1298 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1299 | - updateMemberData($row['id_member'], array('posts' => '+')); |
|
1353 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1354 | + updateMemberData($row['id_member'], array('posts' => '+')); |
|
1355 | + } |
|
1300 | 1356 | } |
1301 | 1357 | |
1302 | 1358 | // Time to move the messages. |
@@ -1332,13 +1388,15 @@ discard block |
||
1332 | 1388 | ); |
1333 | 1389 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1334 | 1390 | { |
1335 | - if ($row['id_first_msg'] < $target_topic_data['id_first_msg']) |
|
1336 | - $target_topic_data['id_first_msg'] = $row['id_first_msg']; |
|
1391 | + if ($row['id_first_msg'] < $target_topic_data['id_first_msg']) { |
|
1392 | + $target_topic_data['id_first_msg'] = $row['id_first_msg']; |
|
1393 | + } |
|
1337 | 1394 | $target_topic_data['id_last_msg'] = $row['id_last_msg']; |
1338 | - if (!$row['approved']) |
|
1339 | - $target_topic_data['unapproved_posts'] = $row['message_count']; |
|
1340 | - else |
|
1341 | - $target_topic_data['num_replies'] = max(0, $row['message_count'] - 1); |
|
1395 | + if (!$row['approved']) { |
|
1396 | + $target_topic_data['unapproved_posts'] = $row['message_count']; |
|
1397 | + } else { |
|
1398 | + $target_topic_data['num_replies'] = max(0, $row['message_count'] - 1); |
|
1399 | + } |
|
1342 | 1400 | } |
1343 | 1401 | $smcFunc['db_free_result']($request); |
1344 | 1402 | |
@@ -1397,13 +1455,15 @@ discard block |
||
1397 | 1455 | ); |
1398 | 1456 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1399 | 1457 | { |
1400 | - if ($row['id_first_msg'] < $source_topic_data['id_first_msg']) |
|
1401 | - $source_topic_data['id_first_msg'] = $row['id_first_msg']; |
|
1458 | + if ($row['id_first_msg'] < $source_topic_data['id_first_msg']) { |
|
1459 | + $source_topic_data['id_first_msg'] = $row['id_first_msg']; |
|
1460 | + } |
|
1402 | 1461 | $source_topic_data['id_last_msg'] = $row['id_last_msg']; |
1403 | - if (!$row['approved']) |
|
1404 | - $source_topic_data['unapproved_posts'] = $row['message_count']; |
|
1405 | - else |
|
1406 | - $source_topic_data['num_replies'] = max(0, $row['message_count'] - 1); |
|
1462 | + if (!$row['approved']) { |
|
1463 | + $source_topic_data['unapproved_posts'] = $row['message_count']; |
|
1464 | + } else { |
|
1465 | + $source_topic_data['num_replies'] = max(0, $row['message_count'] - 1); |
|
1466 | + } |
|
1407 | 1467 | } |
1408 | 1468 | $smcFunc['db_free_result']($request); |
1409 | 1469 | |
@@ -1467,10 +1527,12 @@ discard block |
||
1467 | 1527 | |
1468 | 1528 | // Subject cache? |
1469 | 1529 | $cache_updates = array(); |
1470 | - if ($target_first_msg != $target_topic_data['id_first_msg']) |
|
1471 | - $cache_updates[] = $target_topic_data['id_first_msg']; |
|
1472 | - if (!empty($source_topic_data['id_first_msg']) && $from_first_msg != $source_topic_data['id_first_msg']) |
|
1473 | - $cache_updates[] = $source_topic_data['id_first_msg']; |
|
1530 | + if ($target_first_msg != $target_topic_data['id_first_msg']) { |
|
1531 | + $cache_updates[] = $target_topic_data['id_first_msg']; |
|
1532 | + } |
|
1533 | + if (!empty($source_topic_data['id_first_msg']) && $from_first_msg != $source_topic_data['id_first_msg']) { |
|
1534 | + $cache_updates[] = $source_topic_data['id_first_msg']; |
|
1535 | + } |
|
1474 | 1536 | |
1475 | 1537 | if (!empty($cache_updates)) |
1476 | 1538 | { |
@@ -1482,8 +1544,9 @@ discard block |
||
1482 | 1544 | 'first_messages' => $cache_updates, |
1483 | 1545 | ) |
1484 | 1546 | ); |
1485 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1486 | - updateStats('subject', $row['id_topic'], $row['subject']); |
|
1547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1548 | + updateStats('subject', $row['id_topic'], $row['subject']); |
|
1549 | + } |
|
1487 | 1550 | $smcFunc['db_free_result']($request); |
1488 | 1551 | } |
1489 | 1552 | |
@@ -1499,22 +1562,26 @@ discard block |
||
1499 | 1562 | global $modSettings, $board, $scripturl, $context; |
1500 | 1563 | |
1501 | 1564 | // No recycle no need to go further |
1502 | - if (empty($modSettings['recycle_enable']) || empty($modSettings['recycle_board'])) |
|
1503 | - return false; |
|
1565 | + if (empty($modSettings['recycle_enable']) || empty($modSettings['recycle_board'])) { |
|
1566 | + return false; |
|
1567 | + } |
|
1504 | 1568 | |
1505 | 1569 | // If it's confirmed go on and delete (from recycle) |
1506 | - if (isset($_GET['confirm_delete'])) |
|
1507 | - return true; |
|
1570 | + if (isset($_GET['confirm_delete'])) { |
|
1571 | + return true; |
|
1572 | + } |
|
1508 | 1573 | |
1509 | - if (empty($board)) |
|
1510 | - return false; |
|
1574 | + if (empty($board)) { |
|
1575 | + return false; |
|
1576 | + } |
|
1511 | 1577 | |
1512 | - if ($modSettings['recycle_board'] != $board) |
|
1513 | - return true; |
|
1514 | - elseif (isset($_REQUEST['msg'])) |
|
1515 | - $confirm_url = $scripturl . '?action=deletemsg;confirm_delete;topic=' . $context['current_topic'] . '.0;msg=' . $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
|
1516 | - else |
|
1517 | - $confirm_url = $scripturl . '?action=removetopic2;confirm_delete;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']; |
|
1578 | + if ($modSettings['recycle_board'] != $board) { |
|
1579 | + return true; |
|
1580 | + } elseif (isset($_REQUEST['msg'])) { |
|
1581 | + $confirm_url = $scripturl . '?action=deletemsg;confirm_delete;topic=' . $context['current_topic'] . '.0;msg=' . $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
|
1582 | + } else { |
|
1583 | + $confirm_url = $scripturl . '?action=removetopic2;confirm_delete;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']; |
|
1584 | + } |
|
1518 | 1585 | |
1519 | 1586 | fatal_lang_error('post_already_deleted', false, array($confirm_url)); |
1520 | 1587 | } |
@@ -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', $smcFunc['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 |
@@ -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 | * Gets a single theme's info. |
@@ -27,8 +28,9 @@ discard block |
||
27 | 28 | global $smcFunc, $modSettings; |
28 | 29 | |
29 | 30 | // No data, no fun! |
30 | - if (empty($id)) |
|
31 | - return false; |
|
31 | + if (empty($id)) { |
|
32 | + return false; |
|
33 | + } |
|
32 | 34 | |
33 | 35 | // Make sure $id is an int. |
34 | 36 | $id = (int) $id; |
@@ -171,8 +173,9 @@ discard block |
||
171 | 173 | global $smcFunc, $sourcedir, $forum_version, $txt, $scripturl, $context; |
172 | 174 | global $explicit_images; |
173 | 175 | |
174 | - if (empty($path)) |
|
175 | - return false; |
|
176 | + if (empty($path)) { |
|
177 | + return false; |
|
178 | + } |
|
176 | 179 | |
177 | 180 | $xml_data = array(); |
178 | 181 | $explicit_images = false; |
@@ -229,9 +232,10 @@ discard block |
||
229 | 232 | ); |
230 | 233 | |
231 | 234 | // Assign the values to be stored. |
232 | - foreach ($xml_elements as $var => $name) |
|
233 | - if (!empty($theme_info_xml[$name])) |
|
235 | + foreach ($xml_elements as $var => $name) { |
|
236 | + if (!empty($theme_info_xml[$name])) |
|
234 | 237 | $xml_data[$var] = $theme_info_xml[$name]; |
238 | + } |
|
235 | 239 | |
236 | 240 | // Add the supported versions. |
237 | 241 | $xml_data['install_for'] = $install_versions; |
@@ -243,8 +247,9 @@ discard block |
||
243 | 247 | $explicit_images = true; |
244 | 248 | } |
245 | 249 | |
246 | - if (!empty($theme_info_xml['extra'])) |
|
247 | - $xml_data += $smcFunc['json_decode']($theme_info_xml['extra'], true); |
|
250 | + if (!empty($theme_info_xml['extra'])) { |
|
251 | + $xml_data += $smcFunc['json_decode']($theme_info_xml['extra'], true); |
|
252 | + } |
|
248 | 253 | |
249 | 254 | return $xml_data; |
250 | 255 | } |
@@ -262,12 +267,14 @@ discard block |
||
262 | 267 | global $settings, $explicit_images; |
263 | 268 | |
264 | 269 | // External use? no problem! |
265 | - if ($to_install) |
|
266 | - $context['to_install'] = $to_install; |
|
270 | + if ($to_install) { |
|
271 | + $context['to_install'] = $to_install; |
|
272 | + } |
|
267 | 273 | |
268 | 274 | // One last check. |
269 | - if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') |
|
270 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
275 | + if (empty($context['to_install']['theme_dir']) || basename($context['to_install']['theme_dir']) == 'Themes') { |
|
276 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
277 | + } |
|
271 | 278 | |
272 | 279 | // OK, is this a newer version of an already installed theme? |
273 | 280 | if (!empty($context['to_install']['version'])) |
@@ -291,8 +298,8 @@ discard block |
||
291 | 298 | $smcFunc['db_free_result']($request); |
292 | 299 | |
293 | 300 | // Got something, lets figure it out what to do next. |
294 | - if (!empty($to_update) && !empty($to_update['version'])) |
|
295 | - switch (compareVersions($context['to_install']['version'], $to_update['version'])) |
|
301 | + if (!empty($to_update) && !empty($to_update['version'])) { |
|
302 | + switch (compareVersions($context['to_install']['version'], $to_update['version'])) |
|
296 | 303 | { |
297 | 304 | case 1: // Got a newer version, update the old entry. |
298 | 305 | $smcFunc['db_query']('', ' |
@@ -306,6 +313,7 @@ discard block |
||
306 | 313 | 'id_theme' => $to_update['id_theme'], |
307 | 314 | ) |
308 | 315 | ); |
316 | + } |
|
309 | 317 | |
310 | 318 | // Done with the update, tell the user about it. |
311 | 319 | $context['to_install']['updated'] = true; |
@@ -371,13 +379,15 @@ discard block |
||
371 | 379 | $context['to_install']['base_theme_url'] = $temp['theme_url']; |
372 | 380 | $context['to_install']['base_theme_dir'] = $temp['theme_dir']; |
373 | 381 | |
374 | - if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) |
|
375 | - $context['to_install']['theme_url'] = $context['to_install']['base_theme_url']; |
|
382 | + if (empty($explicit_images) && !empty($context['to_install']['base_theme_url'])) { |
|
383 | + $context['to_install']['theme_url'] = $context['to_install']['base_theme_url']; |
|
384 | + } |
|
376 | 385 | } |
377 | 386 | |
378 | 387 | // Nope, sorry, couldn't find any theme already installed. |
379 | - else |
|
380 | - fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']); |
|
388 | + else { |
|
389 | + fatal_lang_error('package_get_error_theme_no_based_on_found', false, $context['to_install']['based_on']); |
|
390 | + } |
|
381 | 391 | } |
382 | 392 | |
383 | 393 | unset($context['to_install']['based_on']); |
@@ -400,16 +410,18 @@ discard block |
||
400 | 410 | call_integration_hook('integrate_theme_install', array(&$context['to_install'], $id_theme)); |
401 | 411 | |
402 | 412 | $inserts = array(); |
403 | - foreach ($context['to_install'] as $var => $val) |
|
404 | - $inserts[] = array($id_theme, $var, $val); |
|
413 | + foreach ($context['to_install'] as $var => $val) { |
|
414 | + $inserts[] = array($id_theme, $var, $val); |
|
415 | + } |
|
405 | 416 | |
406 | - if (!empty($inserts)) |
|
407 | - $smcFunc['db_insert']('insert', |
|
417 | + if (!empty($inserts)) { |
|
418 | + $smcFunc['db_insert']('insert', |
|
408 | 419 | '{db_prefix}themes', |
409 | 420 | array('id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), |
410 | 421 | $inserts, |
411 | 422 | array('id_theme', 'variable') |
412 | 423 | ); |
424 | + } |
|
413 | 425 | |
414 | 426 | // Update the known and enable Theme's settings. |
415 | 427 | $known = strtr($modSettings['knownThemes'] . ',' . $id_theme, array(',,' => ',')); |
@@ -428,21 +440,24 @@ discard block |
||
428 | 440 | */ |
429 | 441 | function remove_dir($path) |
430 | 442 | { |
431 | - if (empty($path)) |
|
432 | - return false; |
|
443 | + if (empty($path)) { |
|
444 | + return false; |
|
445 | + } |
|
433 | 446 | |
434 | 447 | if (is_dir($path)) |
435 | 448 | { |
436 | 449 | $objects = scandir($path); |
437 | 450 | |
438 | - foreach ($objects as $object) |
|
439 | - if ($object != '.' && $object != '..') |
|
451 | + foreach ($objects as $object) { |
|
452 | + if ($object != '.' && $object != '..') |
|
440 | 453 | { |
441 | 454 | if (filetype($path . '/' . $object) == 'dir') |
442 | 455 | remove_dir($path . '/' . $object); |
456 | + } |
|
443 | 457 | |
444 | - else |
|
445 | - unlink($path . '/' . $object); |
|
458 | + else { |
|
459 | + unlink($path . '/' . $object); |
|
460 | + } |
|
446 | 461 | } |
447 | 462 | } |
448 | 463 | |
@@ -461,8 +476,9 @@ discard block |
||
461 | 476 | global $smcFunc, $modSettings; |
462 | 477 | |
463 | 478 | // Can't delete the default theme, sorry! |
464 | - if (empty($themeID) || $themeID == 1) |
|
465 | - return false; |
|
479 | + if (empty($themeID) || $themeID == 1) { |
|
480 | + return false; |
|
481 | + } |
|
466 | 482 | |
467 | 483 | $known = explode(',', $modSettings['knownThemes']); |
468 | 484 | $enable = explode(',', $modSettings['enableThemes']); |
@@ -512,8 +528,9 @@ discard block |
||
512 | 528 | updateSettings(array('enableThemes' => $enable, 'knownThemes' => $known)); |
513 | 529 | |
514 | 530 | // Fix it if the theme was the overall default theme. |
515 | - if ($modSettings['theme_guests'] == $themeID) |
|
516 | - updateSettings(array('theme_guests' => '1')); |
|
531 | + if ($modSettings['theme_guests'] == $themeID) { |
|
532 | + updateSettings(array('theme_guests' => '1')); |
|
533 | + } |
|
517 | 534 | |
518 | 535 | return true; |
519 | 536 | } |
@@ -530,13 +547,15 @@ discard block |
||
530 | 547 | global $scripturl, $txt, $context; |
531 | 548 | |
532 | 549 | // Is it even a directory? |
533 | - if (!is_dir($path)) |
|
534 | - fatal_lang_error('error_invalid_dir', 'critical'); |
|
550 | + if (!is_dir($path)) { |
|
551 | + fatal_lang_error('error_invalid_dir', 'critical'); |
|
552 | + } |
|
535 | 553 | |
536 | 554 | $dir = dir($path); |
537 | 555 | $entries = array(); |
538 | - while ($entry = $dir->read()) |
|
539 | - $entries[] = $entry; |
|
556 | + while ($entry = $dir->read()) { |
|
557 | + $entries[] = $entry; |
|
558 | + } |
|
540 | 559 | $dir->close(); |
541 | 560 | |
542 | 561 | natcasesort($entries); |
@@ -547,11 +566,12 @@ discard block |
||
547 | 566 | foreach ($entries as $entry) |
548 | 567 | { |
549 | 568 | // Skip all dot files, including .htaccess. |
550 | - if (substr($entry, 0, 1) == '.' || $entry == 'CVS') |
|
551 | - continue; |
|
569 | + if (substr($entry, 0, 1) == '.' || $entry == 'CVS') { |
|
570 | + continue; |
|
571 | + } |
|
552 | 572 | |
553 | - if (is_dir($path . '/' . $entry)) |
|
554 | - $listing1[] = array( |
|
573 | + if (is_dir($path . '/' . $entry)) { |
|
574 | + $listing1[] = array( |
|
555 | 575 | 'filename' => $entry, |
556 | 576 | 'is_writable' => is_writable($path . '/' . $entry), |
557 | 577 | 'is_directory' => true, |
@@ -561,13 +581,14 @@ discard block |
||
561 | 581 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $relative . $entry, |
562 | 582 | 'size' => '', |
563 | 583 | ); |
564 | - else |
|
584 | + } else |
|
565 | 585 | { |
566 | 586 | $size = filesize($path . '/' . $entry); |
567 | - if ($size > 2048 || $size == 1024) |
|
568 | - $size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes']; |
|
569 | - else |
|
570 | - $size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes']; |
|
587 | + if ($size > 2048 || $size == 1024) { |
|
588 | + $size = comma_format($size / 1024) . ' ' . $txt['themeadmin_edit_kilobytes']; |
|
589 | + } else { |
|
590 | + $size = comma_format($size) . ' ' . $txt['themeadmin_edit_bytes']; |
|
591 | + } |
|
571 | 592 | |
572 | 593 | $listing2[] = array( |
573 | 594 | 'filename' => $entry, |
@@ -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 = $smcFunc['json_decode']($draft_info['to_list'], true); |
|
207 | 216 | } |
208 | - elseif (!empty($draft_info['to_list']) && empty($recipientList)) |
|
209 | - $recipientList = $smcFunc['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']; |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | // Start things rolling by getting SMF alive... |
18 | 18 | $ssi_guest_access = true; |
19 | -if (!file_exists(dirname(__FILE__) . '/SSI.php')) |
|
19 | +if (!file_exists(dirname(__FILE__) . '/SSI.php')) { |
|
20 | 20 | die('Cannot find SSI.php'); |
21 | +} |
|
21 | 22 | |
22 | 23 | require_once(dirname(__FILE__) . '/SSI.php'); |
23 | 24 | require_once($sourcedir . '/ManagePaid.php'); |
@@ -35,20 +36,22 @@ discard block |
||
35 | 36 | } |
36 | 37 | |
37 | 38 | // I assume we're even active? |
38 | -if (empty($modSettings['paid_enabled'])) |
|
39 | +if (empty($modSettings['paid_enabled'])) { |
|
39 | 40 | exit; |
41 | +} |
|
40 | 42 | |
41 | 43 | // If we have some custom people who find out about problems load them here. |
42 | 44 | $notify_users = array(); |
43 | 45 | if (!empty($modSettings['paid_email_to'])) |
44 | 46 | { |
45 | - foreach (explode(',', $modSettings['paid_email_to']) as $email) |
|
46 | - $notify_users[] = array( |
|
47 | + foreach (explode(',', $modSettings['paid_email_to']) as $email) { |
|
48 | + $notify_users[] = array( |
|
47 | 49 | 'email' => $email, |
48 | 50 | 'name' => $txt['who_member'], |
49 | 51 | 'id' => 0, |
50 | 52 | ); |
51 | -} |
|
53 | + } |
|
54 | + } |
|
52 | 55 | |
53 | 56 | // We need to see whether we can find the correct payment gateway, |
54 | 57 | // we'll going to go through all our gateway scripts and find out |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | } |
66 | 69 | } |
67 | 70 | |
68 | -if (empty($txnType)) |
|
71 | +if (empty($txnType)) { |
|
69 | 72 | generateSubscriptionError($txt['paid_unknown_transaction_type']); |
73 | +} |
|
70 | 74 | |
71 | 75 | // Get the subscription and member ID amoungst others... |
72 | 76 | @list($subscription_id, $member_id) = $gatewayClass->precheck(); |
@@ -76,8 +80,9 @@ discard block |
||
76 | 80 | $member_id = (int) $member_id; |
77 | 81 | |
78 | 82 | // This would be bad... |
79 | -if (empty($member_id)) |
|
83 | +if (empty($member_id)) { |
|
80 | 84 | generateSubscriptionError($txt['paid_empty_member']); |
85 | +} |
|
81 | 86 | |
82 | 87 | // Verify the member. |
83 | 88 | $request = $smcFunc['db_query']('', ' |
@@ -89,8 +94,9 @@ discard block |
||
89 | 94 | ) |
90 | 95 | ); |
91 | 96 | // Didn't find them? |
92 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
97 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
93 | 98 | generateSubscriptionError(sprintf($txt['paid_could_not_find_member'], $member_id)); |
99 | +} |
|
94 | 100 | $member_info = $smcFunc['db_fetch_assoc']($request); |
95 | 101 | $smcFunc['db_free_result']($request); |
96 | 102 | |
@@ -105,8 +111,9 @@ discard block |
||
105 | 111 | ); |
106 | 112 | |
107 | 113 | // Didn't find it? |
108 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
114 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
109 | 115 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription'], $member_id, $subscription_id)); |
116 | +} |
|
110 | 117 | |
111 | 118 | $subscription_info = $smcFunc['db_fetch_assoc']($request); |
112 | 119 | $smcFunc['db_free_result']($request); |
@@ -123,8 +130,9 @@ discard block |
||
123 | 130 | 'current_member' => $member_id, |
124 | 131 | ) |
125 | 132 | ); |
126 | -if ($smcFunc['db_num_rows']($request) === 0) |
|
133 | +if ($smcFunc['db_num_rows']($request) === 0) { |
|
127 | 134 | generateSubscriptionError(sprintf($txt['paid_count_not_find_subscription_log'], $member_id, $subscription_id)); |
135 | +} |
|
128 | 136 | $subscription_info += $smcFunc['db_fetch_assoc']($request); |
129 | 137 | $smcFunc['db_free_result']($request); |
130 | 138 | |
@@ -139,8 +147,7 @@ discard block |
||
139 | 147 | removeSubscription($subscription_id, $member_id); |
140 | 148 | $subscription_act = time(); |
141 | 149 | $status = 0; |
142 | - } |
|
143 | - else |
|
150 | + } else |
|
144 | 151 | { |
145 | 152 | loadSubscriptions(); |
146 | 153 | $subscription_act = $subscription_info['end_time'] - $context['subscriptions'][$subscription_id]['num_length']; |
@@ -188,16 +195,18 @@ discard block |
||
188 | 195 | if (!$gatewayClass->isSubscription()) |
189 | 196 | { |
190 | 197 | $real_details = $smcFunc['json_decode']($subscription_info['pending_details'], true); |
191 | - if (empty($real_details)) |
|
192 | - generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
198 | + if (empty($real_details)) { |
|
199 | + generateSubscriptionError(sprintf($txt['paid_count_not_find_outstanding_payment'], $member_id, $subscription_id)); |
|
200 | + } |
|
193 | 201 | |
194 | 202 | // Now we just try to find anything pending. |
195 | 203 | // We don't really care which it is as security happens later. |
196 | 204 | foreach ($real_details as $id => $detail) |
197 | 205 | { |
198 | 206 | unset($real_details[$id]); |
199 | - if ($detail[3] == 'payback' && $subscription_info['payments_pending']) |
|
200 | - $subscription_info['payments_pending']--; |
|
207 | + if ($detail[3] == 'payback' && $subscription_info['payments_pending']) { |
|
208 | + $subscription_info['payments_pending']--; |
|
209 | + } |
|
201 | 210 | break; |
202 | 211 | } |
203 | 212 | |
@@ -223,10 +232,11 @@ discard block |
||
223 | 232 | // This is a little harder, can we find the right duration? |
224 | 233 | foreach ($cost as $duration => $value) |
225 | 234 | { |
226 | - if ($duration == 'fixed') |
|
227 | - continue; |
|
228 | - elseif ((float) $value == (float) $total_cost) |
|
229 | - $found_duration = strtoupper(substr($duration, 0, 1)); |
|
235 | + if ($duration == 'fixed') { |
|
236 | + continue; |
|
237 | + } elseif ((float) $value == (float) $total_cost) { |
|
238 | + $found_duration = strtoupper(substr($duration, 0, 1)); |
|
239 | + } |
|
230 | 240 | } |
231 | 241 | |
232 | 242 | // If we have the duration then we're done. |
@@ -235,8 +245,7 @@ discard block |
||
235 | 245 | $notify = true; |
236 | 246 | addSubscription($subscription_id, $member_id, $found_duration); |
237 | 247 | } |
238 | - } |
|
239 | - else |
|
248 | + } else |
|
240 | 249 | { |
241 | 250 | $actual_cost = $cost['fixed']; |
242 | 251 | |
@@ -268,10 +277,10 @@ discard block |
||
268 | 277 | // Maybe they're cancelling. Some subscriptions may require actively doing something, but PayPal doesn't, for example. |
269 | 278 | elseif ($gatewayClass->isCancellation()) |
270 | 279 | { |
271 | - if (method_exists($gatewayClass, 'performCancel')) |
|
272 | - $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
273 | -} |
|
274 | -else |
|
280 | + if (method_exists($gatewayClass, 'performCancel')) { |
|
281 | + $gatewayClass->performCancel($subscription_id, $member_id, $subscription_info); |
|
282 | + } |
|
283 | + } else |
|
275 | 284 | { |
276 | 285 | // Some other "valid" transaction such as: |
277 | 286 | // |
@@ -308,8 +317,9 @@ discard block |
||
308 | 317 | // Maybe we can try to give them the post data? |
309 | 318 | if (!empty($_POST)) |
310 | 319 | { |
311 | - foreach ($_POST as $key => $val) |
|
312 | - $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
320 | + foreach ($_POST as $key => $val) { |
|
321 | + $text .= '<br>' . $smcFunc['htmlspecialchars']($key) . ': ' . $smcFunc['htmlspecialchars']($val); |
|
322 | + } |
|
313 | 323 | } |
314 | 324 | |
315 | 325 | // Then just log and die. |
@@ -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('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | $supported = class_exists('memcached'); |
36 | 37 | |
37 | - if ($test) |
|
38 | - return $supported; |
|
38 | + if ($test) { |
|
39 | + return $supported; |
|
40 | + } |
|
39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
40 | 42 | } |
41 | 43 | |
@@ -53,9 +55,9 @@ discard block |
||
53 | 55 | $currentServers = $this->memcached->getServerList(); |
54 | 56 | foreach ($servers as $server) |
55 | 57 | { |
56 | - if (strpos($server,'/') !== false) |
|
57 | - $tempServer = array($server, 0); |
|
58 | - else |
|
58 | + if (strpos($server,'/') !== false) { |
|
59 | + $tempServer = array($server, 0); |
|
60 | + } else |
|
59 | 61 | { |
60 | 62 | $server = explode(':', $server); |
61 | 63 | $tempServer = array($server[0], isset($server[1]) ? $server[1] : 11211); |
@@ -73,8 +75,9 @@ discard block |
||
73 | 75 | } |
74 | 76 | |
75 | 77 | // Found it? |
76 | - if (empty($foundServer)) |
|
77 | - $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
78 | + if (empty($foundServer)) { |
|
79 | + $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | |
80 | 83 | // Best guess is this worked. |
@@ -91,8 +94,9 @@ discard block |
||
91 | 94 | $value = $this->memcached->get($key); |
92 | 95 | |
93 | 96 | // $value should return either data or false (from failure, key not found or empty array). |
94 | - if ($value === false) |
|
95 | - return null; |
|
97 | + if ($value === false) { |
|
98 | + return null; |
|
99 | + } |
|
96 | 100 | return $value; |
97 | 101 | } |
98 | 102 | |
@@ -135,8 +139,9 @@ discard block |
||
135 | 139 | $config_vars[] = $txt['cache_memcache_settings']; |
136 | 140 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
137 | 141 | |
138 | - if (!isset($context['settings_post_javascript'])) |
|
139 | - $context['settings_post_javascript'] = ''; |
|
142 | + if (!isset($context['settings_post_javascript'])) { |
|
143 | + $context['settings_post_javascript'] = ''; |
|
144 | + } |
|
140 | 145 | |
141 | 146 | $context['settings_post_javascript'] .= ' |
142 | 147 | $("#cache_accelerator").change(function (e) { |
@@ -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('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | $supported = class_exists('memcache'); |
36 | 37 | |
37 | - if ($test) |
|
38 | - return $supported; |
|
38 | + if ($test) { |
|
39 | + return $supported; |
|
40 | + } |
|
39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
40 | 42 | } |
41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
61 | 63 | $server = trim($servers[array_rand($servers)]); |
62 | 64 | |
63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
64 | - if (strpos($server,'/') !== false) |
|
65 | - $host = $server; |
|
66 | - else |
|
66 | + if (strpos($server,'/') !== false) { |
|
67 | + $host = $server; |
|
68 | + } else |
|
67 | 69 | { |
68 | 70 | $server = explode(':', $server); |
69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
71 | 73 | } |
72 | 74 | |
73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
74 | - if (empty($db_persist)) |
|
75 | - $connected = $this->memcache->connect($host, $port); |
|
76 | - else |
|
77 | - $connected = $this->memcache->pconnect($host, $port); |
|
76 | + if (empty($db_persist)) { |
|
77 | + $connected = $this->memcache->connect($host, $port); |
|
78 | + } else { |
|
79 | + $connected = $this->memcache->pconnect($host, $port); |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | |
80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
90 | 93 | $value = $this->memcache->get($key); |
91 | 94 | |
92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
93 | - if ($value === false) |
|
94 | - return null; |
|
96 | + if ($value === false) { |
|
97 | + return null; |
|
98 | + } |
|
95 | 99 | return $value; |
96 | 100 | } |
97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
134 | 138 | |
135 | - if (!isset($context['settings_post_javascript'])) |
|
136 | - $context['settings_post_javascript'] = ''; |
|
139 | + if (!isset($context['settings_post_javascript'])) { |
|
140 | + $context['settings_post_javascript'] = ''; |
|
141 | + } |
|
137 | 142 | |
138 | 143 | $context['settings_post_javascript'] .= ' |
139 | 144 | $("#cache_accelerator").change(function (e) { |
@@ -32,16 +32,18 @@ discard block |
||
32 | 32 | ob_start(); |
33 | 33 | |
34 | 34 | // Do some cleaning, just in case. |
35 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
35 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
36 | 36 | if (isset($GLOBALS[$variable])) |
37 | 37 | unset($GLOBALS[$variable], $GLOBALS[$variable]); |
38 | +} |
|
38 | 39 | |
39 | 40 | // Load the settings... |
40 | 41 | require_once(dirname(__FILE__) . '/Settings.php'); |
41 | 42 | |
42 | 43 | // Make absolutely sure the cache directory is defined. |
43 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
44 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
44 | 45 | $cachedir = $boarddir . '/cache'; |
46 | +} |
|
45 | 47 | |
46 | 48 | // Without those we can't go anywhere |
47 | 49 | require_once($sourcedir . '/QueryString.php'); |
@@ -51,8 +53,9 @@ discard block |
||
51 | 53 | require_once($sourcedir . '/Load.php'); |
52 | 54 | |
53 | 55 | // If $maintenance is set specifically to 2, then we're upgrading or something. |
54 | -if (!empty($maintenance) && $maintenance == 2) |
|
56 | +if (!empty($maintenance) && $maintenance == 2) { |
|
55 | 57 | display_maintenance_message(); |
58 | +} |
|
56 | 59 | |
57 | 60 | // Create a variable to store some SMF specific functions in. |
58 | 61 | $smcFunc = array(); |
@@ -67,8 +70,9 @@ discard block |
||
67 | 70 | cleanRequest(); |
68 | 71 | |
69 | 72 | // Seed the random generator. |
70 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
73 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
71 | 74 | smf_seed_generator(); |
75 | +} |
|
72 | 76 | |
73 | 77 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
74 | 78 | if (isset($_GET['scheduled'])) |
@@ -88,9 +92,9 @@ discard block |
||
88 | 92 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
89 | 93 | { |
90 | 94 | // If zlib is being used, turn off output compression. |
91 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
92 | - $modSettings['enableCompressedOutput'] = '0'; |
|
93 | - else |
|
95 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') { |
|
96 | + $modSettings['enableCompressedOutput'] = '0'; |
|
97 | + } else |
|
94 | 98 | { |
95 | 99 | ob_end_clean(); |
96 | 100 | ob_start('ob_gzhandler'); |
@@ -182,18 +186,21 @@ discard block |
||
182 | 186 | loadPermissions(); |
183 | 187 | |
184 | 188 | // Attachments don't require the entire theme to be loaded. |
185 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') |
|
186 | - detectBrowser(); |
|
189 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') { |
|
190 | + detectBrowser(); |
|
191 | + } |
|
187 | 192 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
188 | - else |
|
189 | - loadTheme(); |
|
193 | + else { |
|
194 | + loadTheme(); |
|
195 | + } |
|
190 | 196 | |
191 | 197 | // Check if the user should be disallowed access. |
192 | 198 | is_not_banned(); |
193 | 199 | |
194 | 200 | // If we are in a topic and don't have permission to approve it then duck out now. |
195 | - if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) |
|
196 | - fatal_lang_error('not_a_topic', false); |
|
201 | + if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) { |
|
202 | + fatal_lang_error('not_a_topic', false); |
|
203 | + } |
|
197 | 204 | |
198 | 205 | $no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'); |
199 | 206 | call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions)); |
@@ -204,8 +211,9 @@ discard block |
||
204 | 211 | writeLog(); |
205 | 212 | |
206 | 213 | // Track forum statistics and hits...? |
207 | - if (!empty($modSettings['hitStats'])) |
|
208 | - trackStats(array('hits' => '+')); |
|
214 | + if (!empty($modSettings['hitStats'])) { |
|
215 | + trackStats(array('hits' => '+')); |
|
216 | + } |
|
209 | 217 | } |
210 | 218 | unset($no_stat_actions); |
211 | 219 | |
@@ -219,13 +227,14 @@ discard block |
||
219 | 227 | return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout')); |
220 | 228 | } |
221 | 229 | // Don't even try it, sonny. |
222 | - else |
|
223 | - return 'InMaintenance'; |
|
230 | + else { |
|
231 | + return 'InMaintenance'; |
|
232 | + } |
|
224 | 233 | } |
225 | 234 | // If guest access is off, a guest can only do one of the very few following actions. |
226 | - elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) |
|
227 | - return 'KickGuest'; |
|
228 | - elseif (empty($_REQUEST['action'])) |
|
235 | + elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) { |
|
236 | + return 'KickGuest'; |
|
237 | + } elseif (empty($_REQUEST['action'])) |
|
229 | 238 | { |
230 | 239 | // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. |
231 | 240 | if (empty($board) && empty($topic)) |
@@ -239,8 +248,9 @@ discard block |
||
239 | 248 | |
240 | 249 | $call = call_helper($defaultAction, true); |
241 | 250 | |
242 | - if (!empty($call)) |
|
243 | - return $call; |
|
251 | + if (!empty($call)) { |
|
252 | + return $call; |
|
253 | + } |
|
244 | 254 | } |
245 | 255 | |
246 | 256 | // No default action huh? then go to our good old BoardIndex. |
@@ -370,8 +380,9 @@ discard block |
||
370 | 380 | |
371 | 381 | $call = call_helper($fallbackAction, true); |
372 | 382 | |
373 | - if (!empty($call)) |
|
374 | - return $call; |
|
383 | + if (!empty($call)) { |
|
384 | + return $call; |
|
385 | + } |
|
375 | 386 | } |
376 | 387 | |
377 | 388 | // No fallback action, huh? |
@@ -382,8 +393,9 @@ discard block |
||
382 | 393 | } |
383 | 394 | |
384 | 395 | // Otherwise, it was set - so let's go to that action. |
385 | - if (!empty($actionArray[$_REQUEST['action']][0])) |
|
386 | - require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
396 | + if (!empty($actionArray[$_REQUEST['action']][0])) { |
|
397 | + require_once($sourcedir . '/' . $actionArray[$_REQUEST['action']][0]); |
|
398 | + } |
|
387 | 399 | |
388 | 400 | // Do the right thing. |
389 | 401 | return call_helper($actionArray[$_REQUEST['action']][1], true); |
@@ -11,8 +11,9 @@ |
||
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. |