@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | if (!empty($board_info['moderators'])) |
| 134 | 134 | { |
| 135 | 135 | foreach ($board_info['moderators'] as $mod) |
| 136 | - $context['link_moderators'][] ='<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 136 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 137 | 137 | } |
| 138 | 138 | if (!empty($board_info['moderator_groups'])) |
| 139 | 139 | { |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | COALESCE(memf.real_name, mf.poster_name) AS first_display_name, ' . (!empty($modSettings['preview_characters']) ? ' |
| 343 | 343 | SUBSTRING(ml.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS last_body, |
| 344 | 344 | SUBSTRING(mf.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS first_body,' : '') . 'ml.smileys_enabled AS last_smileys, mf.smileys_enabled AS first_smileys |
| 345 | - ' . (!empty($message_index_selects) ? (', '. implode(', ', $message_index_selects)) : '') . ' |
|
| 345 | + ' . (!empty($message_index_selects) ? (', ' . implode(', ', $message_index_selects)) : '') . ' |
|
| 346 | 346 | FROM {db_prefix}topics AS t |
| 347 | 347 | INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg) |
| 348 | 348 | INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg) |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
| 728 | 728 | |
| 729 | 729 | if (!$context['user']['is_logged']) |
| 730 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 730 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 731 | 731 | |
| 732 | 732 | if ($context['can_mark_notify']) |
| 733 | 733 | $context['normal_buttons']['notify'] = array( |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
| 56 | 57 | |
| 57 | 58 | $context['name'] = $board_info['name']; |
| 58 | 59 | $context['description'] = $board_info['description']; |
| 59 | - if (!empty($board_info['description'])) |
|
| 60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
| 60 | + if (!empty($board_info['description'])) { |
|
| 61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | // How many topics do we have in total? |
| 63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
| 73 | 75 | $session_name = session_name(); |
| 74 | 76 | foreach ($_GET as $k => $v) |
| 75 | 77 | { |
| 76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
| 77 | - $context['robot_no_index'] = true; |
|
| 78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
| 79 | + $context['robot_no_index'] = true; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | } |
| 80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 81 | - $context['robot_no_index'] = true; |
|
| 83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 84 | + $context['robot_no_index'] = true; |
|
| 85 | + } |
|
| 82 | 86 | |
| 83 | 87 | // If we can view unapproved messages and there are some build up a list. |
| 84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
| 89 | 93 | } |
| 90 | 94 | |
| 91 | 95 | // We only know these. |
| 92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
| 93 | - $_REQUEST['sort'] = 'last_post'; |
|
| 96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
| 97 | + $_REQUEST['sort'] = 'last_post'; |
|
| 98 | + } |
|
| 94 | 99 | |
| 95 | 100 | // Make sure the starting place makes sense and construct the page index. |
| 96 | - if (isset($_REQUEST['sort'])) |
|
| 97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 98 | - else |
|
| 99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 101 | + if (isset($_REQUEST['sort'])) { |
|
| 102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 103 | + } else { |
|
| 104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 105 | + } |
|
| 100 | 106 | $context['start'] = &$_REQUEST['start']; |
| 101 | 107 | |
| 102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
| 132 | 138 | $context['link_moderators'] = array(); |
| 133 | 139 | if (!empty($board_info['moderators'])) |
| 134 | 140 | { |
| 135 | - foreach ($board_info['moderators'] as $mod) |
|
| 136 | - $context['link_moderators'][] ='<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 141 | + foreach ($board_info['moderators'] as $mod) { |
|
| 142 | + $context['link_moderators'][] ='<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 143 | + } |
|
| 137 | 144 | } |
| 138 | 145 | if (!empty($board_info['moderator_groups'])) |
| 139 | 146 | { |
| 140 | 147 | // By default just tack the moderator groups onto the end of the members |
| 141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 150 | + } |
|
| 143 | 151 | } |
| 144 | 152 | |
| 145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
| 191 | 199 | ); |
| 192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 193 | 201 | { |
| 194 | - if (empty($row['id_member'])) |
|
| 195 | - continue; |
|
| 202 | + if (empty($row['id_member'])) { |
|
| 203 | + continue; |
|
| 204 | + } |
|
| 196 | 205 | |
| 197 | - if (!empty($row['online_color'])) |
|
| 198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 199 | - else |
|
| 200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 206 | + if (!empty($row['online_color'])) { |
|
| 207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 208 | + } else { |
|
| 209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 210 | + } |
|
| 201 | 211 | |
| 202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 203 | - if ($is_buddy) |
|
| 204 | - $link = '<strong>' . $link . '</strong>'; |
|
| 213 | + if ($is_buddy) { |
|
| 214 | + $link = '<strong>' . $link . '</strong>'; |
|
| 215 | + } |
|
| 205 | 216 | |
| 206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 219 | + } |
|
| 208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
| 209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
| 217 | 229 | 'hidden' => empty($row['show_online']), |
| 218 | 230 | ); |
| 219 | 231 | |
| 220 | - if (empty($row['show_online'])) |
|
| 221 | - $context['view_num_hidden']++; |
|
| 232 | + if (empty($row['show_online'])) { |
|
| 233 | + $context['view_num_hidden']++; |
|
| 234 | + } |
|
| 222 | 235 | } |
| 223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
| 224 | 237 | $smcFunc['db_free_result']($request); |
@@ -257,8 +270,9 @@ discard block |
||
| 257 | 270 | $context['sort_direction'] = $ascending ? 'up' : 'down'; |
| 258 | 271 | $txt['starter'] = $txt['started_by']; |
| 259 | 272 | |
| 260 | - foreach ($sort_methods as $key => $val) |
|
| 261 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 273 | + foreach ($sort_methods as $key => $val) { |
|
| 274 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 275 | + } |
|
| 262 | 276 | |
| 263 | 277 | // Calculate the fastest way to get the topics. |
| 264 | 278 | $start = (int) $_REQUEST['start']; |
@@ -268,14 +282,15 @@ discard block |
||
| 268 | 282 | $fake_ascending = true; |
| 269 | 283 | $maxindex = $board_info['total_topics'] < $start + $maxindex + 1 ? $board_info['total_topics'] - $start : $maxindex; |
| 270 | 284 | $start = $board_info['total_topics'] < $start + $maxindex + 1 ? 0 : $board_info['total_topics'] - $start - $maxindex; |
| 285 | + } else { |
|
| 286 | + $fake_ascending = false; |
|
| 271 | 287 | } |
| 272 | - else |
|
| 273 | - $fake_ascending = false; |
|
| 274 | 288 | |
| 275 | 289 | // Setup the default topic icons... |
| 276 | 290 | $context['icon_sources'] = array(); |
| 277 | - foreach ($context['stable_icons'] as $icon) |
|
| 278 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 291 | + foreach ($context['stable_icons'] as $icon) { |
|
| 292 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 293 | + } |
|
| 279 | 294 | |
| 280 | 295 | $topic_ids = array(); |
| 281 | 296 | $context['topics'] = array(); |
@@ -306,8 +321,9 @@ discard block |
||
| 306 | 321 | ) |
| 307 | 322 | ); |
| 308 | 323 | $topic_ids = array(); |
| 309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 310 | - $topic_ids[] = $row['id_topic']; |
|
| 324 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 325 | + $topic_ids[] = $row['id_topic']; |
|
| 326 | + } |
|
| 311 | 327 | } |
| 312 | 328 | |
| 313 | 329 | // Grab the appropriate topic information... |
@@ -363,11 +379,13 @@ discard block |
||
| 363 | 379 | // Begin 'printing' the message index for current board. |
| 364 | 380 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 365 | 381 | { |
| 366 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 367 | - continue; |
|
| 382 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 383 | + continue; |
|
| 384 | + } |
|
| 368 | 385 | |
| 369 | - if (!$pre_query) |
|
| 370 | - $topic_ids[] = $row['id_topic']; |
|
| 386 | + if (!$pre_query) { |
|
| 387 | + $topic_ids[] = $row['id_topic']; |
|
| 388 | + } |
|
| 371 | 389 | |
| 372 | 390 | // Reference the main color class. |
| 373 | 391 | $colorClass = 'windowbg'; |
@@ -377,8 +395,9 @@ discard block |
||
| 377 | 395 | { |
| 378 | 396 | // Limit them to $modSettings['preview_characters'] characters |
| 379 | 397 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 380 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
| 381 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 398 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
| 399 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 400 | + } |
|
| 382 | 401 | |
| 383 | 402 | // Censor the subject and message preview. |
| 384 | 403 | censorText($row['first_subject']); |
@@ -389,27 +408,27 @@ discard block |
||
| 389 | 408 | { |
| 390 | 409 | $row['last_subject'] = $row['first_subject']; |
| 391 | 410 | $row['last_body'] = $row['first_body']; |
| 392 | - } |
|
| 393 | - else |
|
| 411 | + } else |
|
| 394 | 412 | { |
| 395 | 413 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 396 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
| 397 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 414 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
| 415 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 416 | + } |
|
| 398 | 417 | |
| 399 | 418 | censorText($row['last_subject']); |
| 400 | 419 | censorText($row['last_body']); |
| 401 | 420 | } |
| 402 | - } |
|
| 403 | - else |
|
| 421 | + } else |
|
| 404 | 422 | { |
| 405 | 423 | $row['first_body'] = ''; |
| 406 | 424 | $row['last_body'] = ''; |
| 407 | 425 | censorText($row['first_subject']); |
| 408 | 426 | |
| 409 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 410 | - $row['last_subject'] = $row['first_subject']; |
|
| 411 | - else |
|
| 412 | - censorText($row['last_subject']); |
|
| 427 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 428 | + $row['last_subject'] = $row['first_subject']; |
|
| 429 | + } else { |
|
| 430 | + censorText($row['last_subject']); |
|
| 431 | + } |
|
| 413 | 432 | } |
| 414 | 433 | |
| 415 | 434 | // Decide how many pages the topic should have. |
@@ -420,42 +439,50 @@ discard block |
||
| 420 | 439 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
| 421 | 440 | |
| 422 | 441 | // If we can use all, show all. |
| 423 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
| 424 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 442 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
| 443 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 444 | + } |
|
| 445 | + } else { |
|
| 446 | + $pages = ''; |
|
| 425 | 447 | } |
| 426 | - else |
|
| 427 | - $pages = ''; |
|
| 428 | 448 | |
| 429 | 449 | // We need to check the topic icons exist... |
| 430 | 450 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 431 | 451 | { |
| 432 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 433 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 434 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 435 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 436 | - } |
|
| 437 | - else |
|
| 452 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 453 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 454 | + } |
|
| 455 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 456 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 457 | + } |
|
| 458 | + } else |
|
| 438 | 459 | { |
| 439 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 440 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 441 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 442 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 460 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 461 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 462 | + } |
|
| 463 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 464 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 465 | + } |
|
| 443 | 466 | } |
| 444 | 467 | |
| 445 | - if (!empty($board_info['recycle'])) |
|
| 446 | - $row['first_icon'] = 'recycled'; |
|
| 468 | + if (!empty($board_info['recycle'])) { |
|
| 469 | + $row['first_icon'] = 'recycled'; |
|
| 470 | + } |
|
| 447 | 471 | |
| 448 | 472 | // Is this topic pending approval, or does it have any posts pending approval? |
| 449 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
| 450 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 473 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
| 474 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 475 | + } |
|
| 451 | 476 | |
| 452 | 477 | // Sticky topics should get a different color, too. |
| 453 | - if ($row['is_sticky']) |
|
| 454 | - $colorClass .= ' sticky'; |
|
| 478 | + if ($row['is_sticky']) { |
|
| 479 | + $colorClass .= ' sticky'; |
|
| 480 | + } |
|
| 455 | 481 | |
| 456 | 482 | // Locked topics get special treatment as well. |
| 457 | - if ($row['locked']) |
|
| 458 | - $colorClass .= ' locked'; |
|
| 483 | + if ($row['locked']) { |
|
| 484 | + $colorClass .= ' locked'; |
|
| 485 | + } |
|
| 459 | 486 | |
| 460 | 487 | // 'Print' the topic info. |
| 461 | 488 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -536,8 +563,9 @@ discard block |
||
| 536 | 563 | $smcFunc['db_free_result']($result); |
| 537 | 564 | |
| 538 | 565 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
| 539 | - if ($fake_ascending) |
|
| 540 | - $context['topics'] = array_reverse($context['topics'], true); |
|
| 566 | + if ($fake_ascending) { |
|
| 567 | + $context['topics'] = array_reverse($context['topics'], true); |
|
| 568 | + } |
|
| 541 | 569 | |
| 542 | 570 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) |
| 543 | 571 | { |
@@ -554,8 +582,9 @@ discard block |
||
| 554 | 582 | 'limit' => count($topic_ids), |
| 555 | 583 | ) |
| 556 | 584 | ); |
| 557 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 558 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 585 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 586 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 587 | + } |
|
| 559 | 588 | $smcFunc['db_free_result']($result); |
| 560 | 589 | } |
| 561 | 590 | } |
@@ -580,9 +609,9 @@ discard block |
||
| 580 | 609 | // Can we restore topics? |
| 581 | 610 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
| 582 | 611 | |
| 583 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
| 584 | - $context['can_move_any'] = true; |
|
| 585 | - else |
|
| 612 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
| 613 | + $context['can_move_any'] = true; |
|
| 614 | + } else |
|
| 586 | 615 | { |
| 587 | 616 | // We'll use this in a minute |
| 588 | 617 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -609,11 +638,13 @@ discard block |
||
| 609 | 638 | } |
| 610 | 639 | |
| 611 | 640 | // Can we use quick moderation checkboxes? |
| 612 | - if ($options['display_quick_mod'] == 1) |
|
| 613 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 641 | + if ($options['display_quick_mod'] == 1) { |
|
| 642 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 643 | + } |
|
| 614 | 644 | // Or the icons? |
| 615 | - else |
|
| 616 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 645 | + else { |
|
| 646 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 647 | + } |
|
| 617 | 648 | } |
| 618 | 649 | |
| 619 | 650 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -647,13 +678,15 @@ discard block |
||
| 647 | 678 | ); |
| 648 | 679 | |
| 649 | 680 | // We've seen all these boards now! |
| 650 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
| 651 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 681 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
| 682 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 652 | 683 | unset($_SESSION['topicseen_cache'][$k]); |
| 684 | + } |
|
| 653 | 685 | } |
| 654 | 686 | |
| 655 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
| 656 | - unset($_SESSION['topicseen_cache'][$board]); |
|
| 687 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 688 | + unset($_SESSION['topicseen_cache'][$board]); |
|
| 689 | + } |
|
| 657 | 690 | |
| 658 | 691 | $request = $smcFunc['db_query']('', ' |
| 659 | 692 | SELECT id_topic, id_board, sent |
@@ -675,8 +708,9 @@ discard block |
||
| 675 | 708 | $context['is_marked_notify'] = true; |
| 676 | 709 | $board_sent = $row['sent']; |
| 677 | 710 | } |
| 678 | - if (!empty($row['id_topic'])) |
|
| 679 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 711 | + if (!empty($row['id_topic'])) { |
|
| 712 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 713 | + } |
|
| 680 | 714 | } |
| 681 | 715 | $smcFunc['db_free_result']($request); |
| 682 | 716 | |
@@ -700,8 +734,7 @@ discard block |
||
| 700 | 734 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
| 701 | 735 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
| 702 | 736 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
| 703 | - } |
|
| 704 | - else |
|
| 737 | + } else |
|
| 705 | 738 | { |
| 706 | 739 | $context['is_marked_notify'] = false; |
| 707 | 740 | $context['board_notification_mode'] = 1; |
@@ -714,23 +747,27 @@ discard block |
||
| 714 | 747 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 715 | 748 | |
| 716 | 749 | // Don't want to show this forever... |
| 717 | - if ($context['becomesUnapproved']) |
|
| 718 | - unset($_SESSION['becomesUnapproved']); |
|
| 750 | + if ($context['becomesUnapproved']) { |
|
| 751 | + unset($_SESSION['becomesUnapproved']); |
|
| 752 | + } |
|
| 719 | 753 | |
| 720 | 754 | // Build the message index button array. |
| 721 | 755 | $context['normal_buttons'] = array(); |
| 722 | 756 | |
| 723 | - if ($context['can_post_new']) |
|
| 724 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 757 | + if ($context['can_post_new']) { |
|
| 758 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 759 | + } |
|
| 725 | 760 | |
| 726 | - if ($context['can_post_poll']) |
|
| 727 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 761 | + if ($context['can_post_poll']) { |
|
| 762 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 763 | + } |
|
| 728 | 764 | |
| 729 | - if (!$context['user']['is_logged']) |
|
| 730 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 765 | + if (!$context['user']['is_logged']) { |
|
| 766 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 767 | + } |
|
| 731 | 768 | |
| 732 | - if ($context['can_mark_notify']) |
|
| 733 | - $context['normal_buttons']['notify'] = array( |
|
| 769 | + if ($context['can_mark_notify']) { |
|
| 770 | + $context['normal_buttons']['notify'] = array( |
|
| 734 | 771 | 'lang' => true, |
| 735 | 772 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
| 736 | 773 | 'sub_buttons' => array( |
@@ -748,6 +785,7 @@ discard block |
||
| 748 | 785 | ), |
| 749 | 786 | ), |
| 750 | 787 | ); |
| 788 | + } |
|
| 751 | 789 | |
| 752 | 790 | // Javascript for inline editing. |
| 753 | 791 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -769,18 +807,21 @@ discard block |
||
| 769 | 807 | checkSession('request'); |
| 770 | 808 | |
| 771 | 809 | // Lets go straight to the restore area. |
| 772 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
| 773 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 810 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
| 811 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 812 | + } |
|
| 774 | 813 | |
| 775 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 776 | - $_SESSION['topicseen_cache'] = array(); |
|
| 814 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 815 | + $_SESSION['topicseen_cache'] = array(); |
|
| 816 | + } |
|
| 777 | 817 | |
| 778 | 818 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
| 779 | 819 | require_once($sourcedir . '/Subs-Post.php'); |
| 780 | 820 | |
| 781 | 821 | // Remember the last board they moved things to. |
| 782 | - if (isset($_REQUEST['move_to'])) |
|
| 783 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 822 | + if (isset($_REQUEST['move_to'])) { |
|
| 823 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 824 | + } |
|
| 784 | 825 | |
| 785 | 826 | // Only a few possible actions. |
| 786 | 827 | $possibleActions = array(); |
@@ -800,8 +841,7 @@ discard block |
||
| 800 | 841 | ); |
| 801 | 842 | |
| 802 | 843 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
| 803 | - } |
|
| 804 | - else |
|
| 844 | + } else |
|
| 805 | 845 | { |
| 806 | 846 | /** |
| 807 | 847 | * @todo Ugly. There's no getting around this, is there? |
@@ -819,8 +859,7 @@ discard block |
||
| 819 | 859 | if (!empty($board)) |
| 820 | 860 | { |
| 821 | 861 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
| 822 | - } |
|
| 823 | - else |
|
| 862 | + } else |
|
| 824 | 863 | { |
| 825 | 864 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
| 826 | 865 | } |
@@ -831,55 +870,67 @@ discard block |
||
| 831 | 870 | } |
| 832 | 871 | } |
| 833 | 872 | |
| 834 | - if (!$user_info['is_guest']) |
|
| 835 | - $possibleActions[] = 'markread'; |
|
| 836 | - if (!empty($boards_can['make_sticky'])) |
|
| 837 | - $possibleActions[] = 'sticky'; |
|
| 838 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
| 839 | - $possibleActions[] = 'move'; |
|
| 840 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
| 841 | - $possibleActions[] = 'remove'; |
|
| 842 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
| 843 | - $possibleActions[] = 'lock'; |
|
| 844 | - if (!empty($boards_can['merge_any'])) |
|
| 845 | - $possibleActions[] = 'merge'; |
|
| 846 | - if (!empty($boards_can['approve_posts'])) |
|
| 847 | - $possibleActions[] = 'approve'; |
|
| 873 | + if (!$user_info['is_guest']) { |
|
| 874 | + $possibleActions[] = 'markread'; |
|
| 875 | + } |
|
| 876 | + if (!empty($boards_can['make_sticky'])) { |
|
| 877 | + $possibleActions[] = 'sticky'; |
|
| 878 | + } |
|
| 879 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
| 880 | + $possibleActions[] = 'move'; |
|
| 881 | + } |
|
| 882 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
| 883 | + $possibleActions[] = 'remove'; |
|
| 884 | + } |
|
| 885 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
| 886 | + $possibleActions[] = 'lock'; |
|
| 887 | + } |
|
| 888 | + if (!empty($boards_can['merge_any'])) { |
|
| 889 | + $possibleActions[] = 'merge'; |
|
| 890 | + } |
|
| 891 | + if (!empty($boards_can['approve_posts'])) { |
|
| 892 | + $possibleActions[] = 'approve'; |
|
| 893 | + } |
|
| 848 | 894 | |
| 849 | 895 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
| 850 | 896 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
| 851 | 897 | if (!empty($_REQUEST['topics'])) |
| 852 | 898 | { |
| 853 | 899 | // If the action isn't valid, just quit now. |
| 854 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
| 855 | - redirectexit($redirect_url); |
|
| 900 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
| 901 | + redirectexit($redirect_url); |
|
| 902 | + } |
|
| 856 | 903 | |
| 857 | 904 | // Merge requires all topics as one parameter and can be done at once. |
| 858 | 905 | if ($_REQUEST['qaction'] == 'merge') |
| 859 | 906 | { |
| 860 | 907 | // Merge requires at least two topics. |
| 861 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
| 862 | - redirectexit($redirect_url); |
|
| 908 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
| 909 | + redirectexit($redirect_url); |
|
| 910 | + } |
|
| 863 | 911 | |
| 864 | 912 | require_once($sourcedir . '/SplitTopics.php'); |
| 865 | 913 | return MergeExecute($_REQUEST['topics']); |
| 866 | 914 | } |
| 867 | 915 | |
| 868 | 916 | // Just convert to the other method, to make it easier. |
| 869 | - foreach ($_REQUEST['topics'] as $topic) |
|
| 870 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 917 | + foreach ($_REQUEST['topics'] as $topic) { |
|
| 918 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 919 | + } |
|
| 871 | 920 | } |
| 872 | 921 | |
| 873 | 922 | // Weird... how'd you get here? |
| 874 | - if (empty($_REQUEST['actions'])) |
|
| 875 | - redirectexit($redirect_url); |
|
| 923 | + if (empty($_REQUEST['actions'])) { |
|
| 924 | + redirectexit($redirect_url); |
|
| 925 | + } |
|
| 876 | 926 | |
| 877 | 927 | // Validate each action. |
| 878 | 928 | $temp = array(); |
| 879 | 929 | foreach ($_REQUEST['actions'] as $topic => $action) |
| 880 | 930 | { |
| 881 | - if (in_array($action, $possibleActions)) |
|
| 882 | - $temp[(int) $topic] = $action; |
|
| 931 | + if (in_array($action, $possibleActions)) { |
|
| 932 | + $temp[(int) $topic] = $action; |
|
| 933 | + } |
|
| 883 | 934 | } |
| 884 | 935 | $_REQUEST['actions'] = $temp; |
| 885 | 936 | |
@@ -900,27 +951,31 @@ discard block |
||
| 900 | 951 | { |
| 901 | 952 | if (!empty($board)) |
| 902 | 953 | { |
| 903 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
| 904 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 905 | - } |
|
| 906 | - else |
|
| 954 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
| 955 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 956 | + } |
|
| 957 | + } else |
|
| 907 | 958 | { |
| 908 | 959 | // Don't allow them to act on unapproved posts they can't see... |
| 909 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
| 910 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 960 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
| 961 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 962 | + } |
|
| 911 | 963 | // Goodness, this is fun. We need to validate the action. |
| 912 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
| 913 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 914 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
| 915 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 916 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
| 917 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 964 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
| 965 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 966 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
| 967 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 968 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
| 969 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 970 | + } |
|
| 918 | 971 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
| 919 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
| 920 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 972 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
| 973 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 974 | + } |
|
| 921 | 975 | // If the topic is approved then you need permission to approve the posts within. |
| 922 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
| 923 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 976 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
| 977 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 978 | + } |
|
| 924 | 979 | } |
| 925 | 980 | } |
| 926 | 981 | $smcFunc['db_free_result']($request); |
@@ -938,11 +993,11 @@ discard block |
||
| 938 | 993 | { |
| 939 | 994 | $topic = (int) $topic; |
| 940 | 995 | |
| 941 | - if ($action == 'markread') |
|
| 942 | - $markCache[] = $topic; |
|
| 943 | - elseif ($action == 'sticky') |
|
| 944 | - $stickyCache[] = $topic; |
|
| 945 | - elseif ($action == 'move') |
|
| 996 | + if ($action == 'markread') { |
|
| 997 | + $markCache[] = $topic; |
|
| 998 | + } elseif ($action == 'sticky') { |
|
| 999 | + $stickyCache[] = $topic; |
|
| 1000 | + } elseif ($action == 'move') |
|
| 946 | 1001 | { |
| 947 | 1002 | require_once($sourcedir . '/MoveTopic.php'); |
| 948 | 1003 | moveTopicConcurrence(); |
@@ -950,23 +1005,25 @@ discard block |
||
| 950 | 1005 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
| 951 | 1006 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
| 952 | 1007 | |
| 953 | - if (empty($moveCache[1][$topic])) |
|
| 954 | - continue; |
|
| 1008 | + if (empty($moveCache[1][$topic])) { |
|
| 1009 | + continue; |
|
| 1010 | + } |
|
| 955 | 1011 | |
| 956 | 1012 | $moveCache[0][] = $topic; |
| 1013 | + } elseif ($action == 'remove') { |
|
| 1014 | + $removeCache[] = $topic; |
|
| 1015 | + } elseif ($action == 'lock') { |
|
| 1016 | + $lockCache[] = $topic; |
|
| 1017 | + } elseif ($action == 'approve') { |
|
| 1018 | + $approveCache[] = $topic; |
|
| 957 | 1019 | } |
| 958 | - elseif ($action == 'remove') |
|
| 959 | - $removeCache[] = $topic; |
|
| 960 | - elseif ($action == 'lock') |
|
| 961 | - $lockCache[] = $topic; |
|
| 962 | - elseif ($action == 'approve') |
|
| 963 | - $approveCache[] = $topic; |
|
| 964 | 1020 | } |
| 965 | 1021 | |
| 966 | - if (empty($board)) |
|
| 967 | - $affectedBoards = array(); |
|
| 968 | - else |
|
| 969 | - $affectedBoards = array($board => array(0, 0)); |
|
| 1022 | + if (empty($board)) { |
|
| 1023 | + $affectedBoards = array(); |
|
| 1024 | + } else { |
|
| 1025 | + $affectedBoards = array($board => array(0, 0)); |
|
| 1026 | + } |
|
| 970 | 1027 | |
| 971 | 1028 | // Do all the stickies... |
| 972 | 1029 | if (!empty($stickyCache)) |
@@ -1026,14 +1083,16 @@ discard block |
||
| 1026 | 1083 | { |
| 1027 | 1084 | $to = $moveCache[1][$row['id_topic']]; |
| 1028 | 1085 | |
| 1029 | - if (empty($to)) |
|
| 1030 | - continue; |
|
| 1086 | + if (empty($to)) { |
|
| 1087 | + continue; |
|
| 1088 | + } |
|
| 1031 | 1089 | |
| 1032 | 1090 | // Does this topic's board count the posts or not? |
| 1033 | 1091 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
| 1034 | 1092 | |
| 1035 | - if (!isset($moveTos[$to])) |
|
| 1036 | - $moveTos[$to] = array(); |
|
| 1093 | + if (!isset($moveTos[$to])) { |
|
| 1094 | + $moveTos[$to] = array(); |
|
| 1095 | + } |
|
| 1037 | 1096 | |
| 1038 | 1097 | $moveTos[$to][] = $row['id_topic']; |
| 1039 | 1098 | |
@@ -1047,8 +1106,9 @@ discard block |
||
| 1047 | 1106 | require_once($sourcedir . '/MoveTopic.php'); |
| 1048 | 1107 | |
| 1049 | 1108 | // Do the actual moves... |
| 1050 | - foreach ($moveTos as $to => $topics) |
|
| 1051 | - moveTopics($topics, $to); |
|
| 1109 | + foreach ($moveTos as $to => $topics) { |
|
| 1110 | + moveTopics($topics, $to); |
|
| 1111 | + } |
|
| 1052 | 1112 | |
| 1053 | 1113 | // Does the post counts need to be updated? |
| 1054 | 1114 | if (!empty($moveTos)) |
@@ -1097,20 +1157,23 @@ discard block |
||
| 1097 | 1157 | |
| 1098 | 1158 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1099 | 1159 | { |
| 1100 | - if (!isset($members[$row['id_member']])) |
|
| 1101 | - $members[$row['id_member']] = 0; |
|
| 1160 | + if (!isset($members[$row['id_member']])) { |
|
| 1161 | + $members[$row['id_member']] = 0; |
|
| 1162 | + } |
|
| 1102 | 1163 | |
| 1103 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
| 1104 | - $members[$row['id_member']] += 1; |
|
| 1105 | - else |
|
| 1106 | - $members[$row['id_member']] -= 1; |
|
| 1164 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
| 1165 | + $members[$row['id_member']] += 1; |
|
| 1166 | + } else { |
|
| 1167 | + $members[$row['id_member']] -= 1; |
|
| 1168 | + } |
|
| 1107 | 1169 | } |
| 1108 | 1170 | |
| 1109 | 1171 | $smcFunc['db_free_result']($request); |
| 1110 | 1172 | |
| 1111 | 1173 | // And now update them member's post counts |
| 1112 | - foreach ($members as $id_member => $post_adj) |
|
| 1113 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1174 | + foreach ($members as $id_member => $post_adj) { |
|
| 1175 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1176 | + } |
|
| 1114 | 1177 | |
| 1115 | 1178 | } |
| 1116 | 1179 | } |
@@ -1190,8 +1253,9 @@ discard block |
||
| 1190 | 1253 | approveTopics($approveCache); |
| 1191 | 1254 | |
| 1192 | 1255 | // Time for some logging! |
| 1193 | - foreach ($approveCache as $topic) |
|
| 1194 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1256 | + foreach ($approveCache as $topic) { |
|
| 1257 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1258 | + } |
|
| 1195 | 1259 | } |
| 1196 | 1260 | } |
| 1197 | 1261 | |
@@ -1226,8 +1290,7 @@ discard block |
||
| 1226 | 1290 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
| 1227 | 1291 | } |
| 1228 | 1292 | $smcFunc['db_free_result']($result); |
| 1229 | - } |
|
| 1230 | - else |
|
| 1293 | + } else |
|
| 1231 | 1294 | { |
| 1232 | 1295 | $result = $smcFunc['db_query']('', ' |
| 1233 | 1296 | SELECT id_topic, locked, id_board |
@@ -1277,13 +1340,15 @@ discard block |
||
| 1277 | 1340 | ) |
| 1278 | 1341 | ); |
| 1279 | 1342 | $logged_topics = array(); |
| 1280 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1281 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1343 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1344 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1345 | + } |
|
| 1282 | 1346 | $smcFunc['db_free_result']($request); |
| 1283 | 1347 | |
| 1284 | 1348 | $markArray = array(); |
| 1285 | - foreach ($markCache as $topic) |
|
| 1286 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1349 | + foreach ($markCache as $topic) { |
|
| 1350 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1351 | + } |
|
| 1287 | 1352 | |
| 1288 | 1353 | $smcFunc['db_insert']('replace', |
| 1289 | 1354 | '{db_prefix}log_topics', |
@@ -1296,8 +1361,9 @@ discard block |
||
| 1296 | 1361 | foreach ($moveCache as $topic) |
| 1297 | 1362 | { |
| 1298 | 1363 | // Didn't actually move anything! |
| 1299 | - if (!isset($topic[0])) |
|
| 1300 | - break; |
|
| 1364 | + if (!isset($topic[0])) { |
|
| 1365 | + break; |
|
| 1366 | + } |
|
| 1301 | 1367 | |
| 1302 | 1368 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
| 1303 | 1369 | sendNotifications($topic[0], 'move'); |
@@ -1319,8 +1385,9 @@ discard block |
||
| 1319 | 1385 | 'calendar_updated' => time(), |
| 1320 | 1386 | )); |
| 1321 | 1387 | |
| 1322 | - if (!empty($affectedBoards)) |
|
| 1323 | - updateLastMessages(array_keys($affectedBoards)); |
|
| 1388 | + if (!empty($affectedBoards)) { |
|
| 1389 | + updateLastMessages(array_keys($affectedBoards)); |
|
| 1390 | + } |
|
| 1324 | 1391 | |
| 1325 | 1392 | redirectexit($redirect_url); |
| 1326 | 1393 | } |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Converts the given UTF-8 string into lowercase. |
@@ -569,8 +570,8 @@ discard block |
||
| 569 | 570 | ); |
| 570 | 571 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 571 | 572 | { |
| 572 | - if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
| 573 | - $smcFunc['db_query']('', ' |
|
| 573 | + if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
| 574 | + $smcFunc['db_query']('', ' |
|
| 574 | 575 | UPDATE {db_prefix}log_actions |
| 575 | 576 | SET extra = {string:extra} |
| 576 | 577 | WHERE id_action = {int:current_action}', |
@@ -579,6 +580,7 @@ discard block |
||
| 579 | 580 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
| 580 | 581 | ) |
| 581 | 582 | ); |
| 583 | + } |
|
| 582 | 584 | } |
| 583 | 585 | $smcFunc['db_free_result']($request); |
| 584 | 586 | |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * This function works out what to do! |
@@ -24,9 +25,9 @@ discard block |
||
| 24 | 25 | global $time_start, $smcFunc, $modSettings; |
| 25 | 26 | |
| 26 | 27 | // Special case for doing the mail queue. |
| 27 | - if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') |
|
| 28 | - ReduceMailQueue(); |
|
| 29 | - else |
|
| 28 | + if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') { |
|
| 29 | + ReduceMailQueue(); |
|
| 30 | + } else |
|
| 30 | 31 | { |
| 31 | 32 | $task_string = ''; |
| 32 | 33 | |
@@ -53,18 +54,20 @@ discard block |
||
| 53 | 54 | |
| 54 | 55 | // How long in seconds it the gap? |
| 55 | 56 | $duration = $row['time_regularity']; |
| 56 | - if ($row['time_unit'] == 'm') |
|
| 57 | - $duration *= 60; |
|
| 58 | - elseif ($row['time_unit'] == 'h') |
|
| 59 | - $duration *= 3600; |
|
| 60 | - elseif ($row['time_unit'] == 'd') |
|
| 61 | - $duration *= 86400; |
|
| 62 | - elseif ($row['time_unit'] == 'w') |
|
| 63 | - $duration *= 604800; |
|
| 57 | + if ($row['time_unit'] == 'm') { |
|
| 58 | + $duration *= 60; |
|
| 59 | + } elseif ($row['time_unit'] == 'h') { |
|
| 60 | + $duration *= 3600; |
|
| 61 | + } elseif ($row['time_unit'] == 'd') { |
|
| 62 | + $duration *= 86400; |
|
| 63 | + } elseif ($row['time_unit'] == 'w') { |
|
| 64 | + $duration *= 604800; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // If we were really late running this task actually skip the next one. |
| 66 | - if (time() + ($duration / 2) > $next_time) |
|
| 67 | - $next_time += $duration; |
|
| 68 | + if (time() + ($duration / 2) > $next_time) { |
|
| 69 | + $next_time += $duration; |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | // Update it now, so no others run this! |
| 70 | 73 | $smcFunc['db_query']('', ' |
@@ -81,16 +84,19 @@ discard block |
||
| 81 | 84 | $affected_rows = $smcFunc['db_affected_rows'](); |
| 82 | 85 | |
| 83 | 86 | // What kind of task are we handling? |
| 84 | - if (!empty($row['callable'])) |
|
| 85 | - $task_string = $row['callable']; |
|
| 87 | + if (!empty($row['callable'])) { |
|
| 88 | + $task_string = $row['callable']; |
|
| 89 | + } |
|
| 86 | 90 | |
| 87 | 91 | // Default SMF task or old mods? |
| 88 | - elseif (function_exists('scheduled_' . $row['task'])) |
|
| 89 | - $task_string = 'scheduled_' . $row['task']; |
|
| 92 | + elseif (function_exists('scheduled_' . $row['task'])) { |
|
| 93 | + $task_string = 'scheduled_' . $row['task']; |
|
| 94 | + } |
|
| 90 | 95 | |
| 91 | 96 | // One last resource, the task name. |
| 92 | - elseif (!empty($row['task'])) |
|
| 93 | - $task_string = $row['task']; |
|
| 97 | + elseif (!empty($row['task'])) { |
|
| 98 | + $task_string = $row['task']; |
|
| 99 | + } |
|
| 94 | 100 | |
| 95 | 101 | // The function must exist or we are wasting our time, plus do some timestamp checking, and database check! |
| 96 | 102 | if (!empty($task_string) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) |
@@ -101,11 +107,11 @@ discard block |
||
| 101 | 107 | $callable_task = call_helper($task_string, true); |
| 102 | 108 | |
| 103 | 109 | // Perform the task. |
| 104 | - if (!empty($callable_task)) |
|
| 105 | - $completed = call_user_func($callable_task); |
|
| 106 | - |
|
| 107 | - else |
|
| 108 | - $completed = false; |
|
| 110 | + if (!empty($callable_task)) { |
|
| 111 | + $completed = call_user_func($callable_task); |
|
| 112 | + } else { |
|
| 113 | + $completed = false; |
|
| 114 | + } |
|
| 109 | 115 | |
| 110 | 116 | // Log that we did it ;) |
| 111 | 117 | if ($completed) |
@@ -138,18 +144,20 @@ discard block |
||
| 138 | 144 | ) |
| 139 | 145 | ); |
| 140 | 146 | // No new task scheduled yet? |
| 141 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 142 | - $nextEvent = time() + 86400; |
|
| 143 | - else |
|
| 144 | - list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
| 147 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 148 | + $nextEvent = time() + 86400; |
|
| 149 | + } else { |
|
| 150 | + list ($nextEvent) = $smcFunc['db_fetch_row']($request); |
|
| 151 | + } |
|
| 145 | 152 | $smcFunc['db_free_result']($request); |
| 146 | 153 | |
| 147 | 154 | updateSettings(array('next_task_time' => $nextEvent)); |
| 148 | 155 | } |
| 149 | 156 | |
| 150 | 157 | // Shall we return? |
| 151 | - if (!isset($_GET['scheduled'])) |
|
| 152 | - return true; |
|
| 158 | + if (!isset($_GET['scheduled'])) { |
|
| 159 | + return true; |
|
| 160 | + } |
|
| 153 | 161 | |
| 154 | 162 | // Finally, send some stuff... |
| 155 | 163 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -181,16 +189,18 @@ discard block |
||
| 181 | 189 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 182 | 190 | { |
| 183 | 191 | // If this is no longer around we'll ignore it. |
| 184 | - if (empty($row['id_topic'])) |
|
| 185 | - continue; |
|
| 192 | + if (empty($row['id_topic'])) { |
|
| 193 | + continue; |
|
| 194 | + } |
|
| 186 | 195 | |
| 187 | 196 | // What type is it? |
| 188 | - if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) |
|
| 189 | - $type = 'topic'; |
|
| 190 | - elseif ($row['id_attach']) |
|
| 191 | - $type = 'attach'; |
|
| 192 | - else |
|
| 193 | - $type = 'msg'; |
|
| 197 | + if ($row['id_first_msg'] && $row['id_first_msg'] == $row['id_msg']) { |
|
| 198 | + $type = 'topic'; |
|
| 199 | + } elseif ($row['id_attach']) { |
|
| 200 | + $type = 'attach'; |
|
| 201 | + } else { |
|
| 202 | + $type = 'msg'; |
|
| 203 | + } |
|
| 194 | 204 | |
| 195 | 205 | // Add it to the array otherwise. |
| 196 | 206 | $notices[$row['id_board']][$type][] = array( |
@@ -211,8 +221,9 @@ discard block |
||
| 211 | 221 | ); |
| 212 | 222 | |
| 213 | 223 | // If nothing quit now. |
| 214 | - if (empty($notices)) |
|
| 215 | - return true; |
|
| 224 | + if (empty($notices)) { |
|
| 225 | + return true; |
|
| 226 | + } |
|
| 216 | 227 | |
| 217 | 228 | // Now we need to think about finding out *who* can approve - this is hard! |
| 218 | 229 | |
@@ -231,14 +242,16 @@ discard block |
||
| 231 | 242 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 232 | 243 | { |
| 233 | 244 | // Sorry guys, but we have to ignore guests AND members - it would be too many otherwise. |
| 234 | - if ($row['id_group'] < 2) |
|
| 235 | - continue; |
|
| 245 | + if ($row['id_group'] < 2) { |
|
| 246 | + continue; |
|
| 247 | + } |
|
| 236 | 248 | |
| 237 | 249 | $perms[$row['id_profile']][$row['add_deny'] ? 'add' : 'deny'][] = $row['id_group']; |
| 238 | 250 | |
| 239 | 251 | // Anyone who can access has to be considered. |
| 240 | - if ($row['add_deny']) |
|
| 241 | - $addGroups[] = $row['id_group']; |
|
| 252 | + if ($row['add_deny']) { |
|
| 253 | + $addGroups[] = $row['id_group']; |
|
| 254 | + } |
|
| 242 | 255 | } |
| 243 | 256 | $smcFunc['db_free_result']($request); |
| 244 | 257 | |
@@ -283,8 +296,9 @@ discard block |
||
| 283 | 296 | if (!empty($row['mod_prefs'])) |
| 284 | 297 | { |
| 285 | 298 | list(,, $pref_binary) = explode('|', $row['mod_prefs']); |
| 286 | - if (!($pref_binary & 4)) |
|
| 287 | - continue; |
|
| 299 | + if (!($pref_binary & 4)) { |
|
| 300 | + continue; |
|
| 301 | + } |
|
| 288 | 302 | } |
| 289 | 303 | |
| 290 | 304 | $members[$row['id_member']] = array( |
@@ -309,8 +323,9 @@ discard block |
||
| 309 | 323 | $emailbody = ''; |
| 310 | 324 | |
| 311 | 325 | // Load the language file as required. |
| 312 | - if (empty($current_language) || $current_language != $member['language']) |
|
| 313 | - $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
| 326 | + if (empty($current_language) || $current_language != $member['language']) { |
|
| 327 | + $current_language = loadLanguage('EmailTemplates', $member['language'], false); |
|
| 328 | + } |
|
| 314 | 329 | |
| 315 | 330 | // Loop through each notice... |
| 316 | 331 | foreach ($notices as $board => $notice) |
@@ -318,29 +333,34 @@ discard block |
||
| 318 | 333 | $access = false; |
| 319 | 334 | |
| 320 | 335 | // Can they mod in this board? |
| 321 | - if (isset($mods[$id][$board])) |
|
| 322 | - $access = true; |
|
| 336 | + if (isset($mods[$id][$board])) { |
|
| 337 | + $access = true; |
|
| 338 | + } |
|
| 323 | 339 | |
| 324 | 340 | // Do the group check... |
| 325 | 341 | if (!$access && isset($perms[$profiles[$board]]['add'])) |
| 326 | 342 | { |
| 327 | 343 | // They can access?! |
| 328 | - if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) |
|
| 329 | - $access = true; |
|
| 344 | + if (array_intersect($perms[$profiles[$board]]['add'], $member['groups'])) { |
|
| 345 | + $access = true; |
|
| 346 | + } |
|
| 330 | 347 | |
| 331 | 348 | // If they have deny rights don't consider them! |
| 332 | - if (isset($perms[$profiles[$board]]['deny'])) |
|
| 333 | - if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
| 349 | + if (isset($perms[$profiles[$board]]['deny'])) { |
|
| 350 | + if (array_intersect($perms[$profiles[$board]]['deny'], $member['groups'])) |
|
| 334 | 351 | $access = false; |
| 352 | + } |
|
| 335 | 353 | } |
| 336 | 354 | |
| 337 | 355 | // Finally, fix it for admins! |
| 338 | - if (in_array(1, $member['groups'])) |
|
| 339 | - $access = true; |
|
| 356 | + if (in_array(1, $member['groups'])) { |
|
| 357 | + $access = true; |
|
| 358 | + } |
|
| 340 | 359 | |
| 341 | 360 | // If they can't access it then give it a break! |
| 342 | - if (!$access) |
|
| 343 | - continue; |
|
| 361 | + if (!$access) { |
|
| 362 | + continue; |
|
| 363 | + } |
|
| 344 | 364 | |
| 345 | 365 | foreach ($notice as $type => $items) |
| 346 | 366 | { |
@@ -348,15 +368,17 @@ discard block |
||
| 348 | 368 | $emailbody .= $txt['scheduled_approval_email_' . $type] . "\n" . |
| 349 | 369 | '------------------------------------------------------' . "\n"; |
| 350 | 370 | |
| 351 | - foreach ($items as $item) |
|
| 352 | - $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
| 371 | + foreach ($items as $item) { |
|
| 372 | + $emailbody .= $item['subject'] . ' - ' . $item['href'] . "\n"; |
|
| 373 | + } |
|
| 353 | 374 | |
| 354 | 375 | $emailbody .= "\n"; |
| 355 | 376 | } |
| 356 | 377 | } |
| 357 | 378 | |
| 358 | - if ($emailbody == '') |
|
| 359 | - continue; |
|
| 379 | + if ($emailbody == '') { |
|
| 380 | + continue; |
|
| 381 | + } |
|
| 360 | 382 | |
| 361 | 383 | $replacements = array( |
| 362 | 384 | 'REALNAME' => $member['name'], |
@@ -397,8 +419,9 @@ discard block |
||
| 397 | 419 | ) |
| 398 | 420 | ); |
| 399 | 421 | $members = array(); |
| 400 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 401 | - $members[$row['id_member']] = $row['warning']; |
|
| 422 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 423 | + $members[$row['id_member']] = $row['warning']; |
|
| 424 | + } |
|
| 402 | 425 | $smcFunc['db_free_result']($request); |
| 403 | 426 | |
| 404 | 427 | // Have some members to check? |
@@ -420,17 +443,18 @@ discard block |
||
| 420 | 443 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 421 | 444 | { |
| 422 | 445 | // More than 24 hours ago? |
| 423 | - if ($row['last_warning'] <= time() - 86400) |
|
| 424 | - $member_changes[] = array( |
|
| 446 | + if ($row['last_warning'] <= time() - 86400) { |
|
| 447 | + $member_changes[] = array( |
|
| 425 | 448 | 'id' => $row['id_recipient'], |
| 426 | 449 | 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0, |
| 427 | 450 | ); |
| 451 | + } |
|
| 428 | 452 | } |
| 429 | 453 | $smcFunc['db_free_result']($request); |
| 430 | 454 | |
| 431 | 455 | // Have some members to change? |
| 432 | - if (!empty($member_changes)) |
|
| 433 | - foreach ($member_changes as $change) |
|
| 456 | + if (!empty($member_changes)) { |
|
| 457 | + foreach ($member_changes as $change) |
|
| 434 | 458 | $smcFunc['db_query']('', ' |
| 435 | 459 | UPDATE {db_prefix}members |
| 436 | 460 | SET warning = {int:warning} |
@@ -440,6 +464,7 @@ discard block |
||
| 440 | 464 | 'id_member' => $change['id'], |
| 441 | 465 | ) |
| 442 | 466 | ); |
| 467 | + } |
|
| 443 | 468 | } |
| 444 | 469 | } |
| 445 | 470 | |
@@ -452,16 +477,17 @@ discard block |
||
| 452 | 477 | |
| 453 | 478 | // Check the database version - for some buggy MySQL version. |
| 454 | 479 | $server_version = $smcFunc['db_server_info'](); |
| 455 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 456 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 457 | - elseif (!empty($modSettings['db_mysql_group_by_fix'])) |
|
| 458 | - $smcFunc['db_query']('', ' |
|
| 480 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 481 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 482 | + } elseif (!empty($modSettings['db_mysql_group_by_fix'])) { |
|
| 483 | + $smcFunc['db_query']('', ' |
|
| 459 | 484 | DELETE FROM {db_prefix}settings |
| 460 | 485 | WHERE variable = {string:mysql_fix}', |
| 461 | 486 | array( |
| 462 | 487 | 'mysql_fix' => 'db_mysql_group_by_fix', |
| 463 | 488 | ) |
| 464 | 489 | ); |
| 490 | + } |
|
| 465 | 491 | |
| 466 | 492 | // Clean up some old login history information. |
| 467 | 493 | $smcFunc['db_query']('', ' |
@@ -519,15 +545,17 @@ discard block |
||
| 519 | 545 | |
| 520 | 546 | // Store this useful data! |
| 521 | 547 | $boards[$row['id_board']] = $row['id_board']; |
| 522 | - if ($row['id_topic']) |
|
| 523 | - $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
| 524 | - else |
|
| 525 | - $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
| 548 | + if ($row['id_topic']) { |
|
| 549 | + $notify['topics'][$row['id_topic']][] = $row['id_member']; |
|
| 550 | + } else { |
|
| 551 | + $notify['boards'][$row['id_board']][] = $row['id_member']; |
|
| 552 | + } |
|
| 526 | 553 | } |
| 527 | 554 | $smcFunc['db_free_result']($request); |
| 528 | 555 | |
| 529 | - if (empty($boards)) |
|
| 530 | - return true; |
|
| 556 | + if (empty($boards)) { |
|
| 557 | + return true; |
|
| 558 | + } |
|
| 531 | 559 | |
| 532 | 560 | // Just get the board names. |
| 533 | 561 | $request = $smcFunc['db_query']('', ' |
@@ -539,12 +567,14 @@ discard block |
||
| 539 | 567 | ) |
| 540 | 568 | ); |
| 541 | 569 | $boards = array(); |
| 542 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 543 | - $boards[$row['id_board']] = $row['name']; |
|
| 570 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 571 | + $boards[$row['id_board']] = $row['name']; |
|
| 572 | + } |
|
| 544 | 573 | $smcFunc['db_free_result']($request); |
| 545 | 574 | |
| 546 | - if (empty($boards)) |
|
| 547 | - return true; |
|
| 575 | + if (empty($boards)) { |
|
| 576 | + return true; |
|
| 577 | + } |
|
| 548 | 578 | |
| 549 | 579 | // Get the actual topics... |
| 550 | 580 | $request = $smcFunc['db_query']('', ' |
@@ -564,52 +594,57 @@ discard block |
||
| 564 | 594 | $types = array(); |
| 565 | 595 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 566 | 596 | { |
| 567 | - if (!isset($types[$row['note_type']][$row['id_board']])) |
|
| 568 | - $types[$row['note_type']][$row['id_board']] = array( |
|
| 597 | + if (!isset($types[$row['note_type']][$row['id_board']])) { |
|
| 598 | + $types[$row['note_type']][$row['id_board']] = array( |
|
| 569 | 599 | 'lines' => array(), |
| 570 | 600 | 'name' => $row['board_name'], |
| 571 | 601 | 'id' => $row['id_board'], |
| 572 | 602 | ); |
| 603 | + } |
|
| 573 | 604 | |
| 574 | 605 | if ($row['note_type'] == 'reply') |
| 575 | 606 | { |
| 576 | - if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 577 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
| 578 | - else |
|
| 579 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 607 | + if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 608 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++; |
|
| 609 | + } else { |
|
| 610 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 580 | 611 | 'id' => $row['id_topic'], |
| 581 | 612 | 'subject' => un_htmlspecialchars($row['subject']), |
| 582 | 613 | 'count' => 1, |
| 583 | 614 | ); |
| 584 | - } |
|
| 585 | - elseif ($row['note_type'] == 'topic') |
|
| 615 | + } |
|
| 616 | + } elseif ($row['note_type'] == 'topic') |
|
| 586 | 617 | { |
| 587 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 588 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 618 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 619 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 589 | 620 | 'id' => $row['id_topic'], |
| 590 | 621 | 'subject' => un_htmlspecialchars($row['subject']), |
| 591 | 622 | ); |
| 592 | - } |
|
| 593 | - else |
|
| 623 | + } |
|
| 624 | + } else |
|
| 594 | 625 | { |
| 595 | - if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) |
|
| 596 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 626 | + if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) { |
|
| 627 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array( |
|
| 597 | 628 | 'id' => $row['id_topic'], |
| 598 | 629 | 'subject' => un_htmlspecialchars($row['subject']), |
| 599 | 630 | 'starter' => $row['id_member_started'], |
| 600 | 631 | ); |
| 632 | + } |
|
| 601 | 633 | } |
| 602 | 634 | |
| 603 | 635 | $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array(); |
| 604 | - if (!empty($notify['topics'][$row['id_topic']])) |
|
| 605 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
| 606 | - if (!empty($notify['boards'][$row['id_board']])) |
|
| 607 | - $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
| 636 | + if (!empty($notify['topics'][$row['id_topic']])) { |
|
| 637 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['topics'][$row['id_topic']]); |
|
| 638 | + } |
|
| 639 | + if (!empty($notify['boards'][$row['id_board']])) { |
|
| 640 | + $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'] = array_merge($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['members'], $notify['boards'][$row['id_board']]); |
|
| 641 | + } |
|
| 608 | 642 | } |
| 609 | 643 | $smcFunc['db_free_result']($request); |
| 610 | 644 | |
| 611 | - if (empty($types)) |
|
| 612 | - return true; |
|
| 645 | + if (empty($types)) { |
|
| 646 | + return true; |
|
| 647 | + } |
|
| 613 | 648 | |
| 614 | 649 | // Let's load all the languages into a cache thingy. |
| 615 | 650 | $langtxt = array(); |
@@ -651,8 +686,9 @@ discard block |
||
| 651 | 686 | $notify_types = !empty($prefs[$mid]['msg_notify_type']) ? $prefs[$mid]['msg_notify_type'] : 1; |
| 652 | 687 | |
| 653 | 688 | // Did they not elect to choose this? |
| 654 | - if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) |
|
| 655 | - continue; |
|
| 689 | + if ($frequency == 4 && !$is_weekly || $frequency == 3 && $is_weekly || $notify_types == 4) { |
|
| 690 | + continue; |
|
| 691 | + } |
|
| 656 | 692 | |
| 657 | 693 | // Right character set! |
| 658 | 694 | $context['character_set'] = empty($modSettings['global_character_set']) ? $langtxt[$lang]['char_set'] : $modSettings['global_character_set']; |
@@ -668,39 +704,43 @@ discard block |
||
| 668 | 704 | if (isset($types['topic'])) |
| 669 | 705 | { |
| 670 | 706 | $titled = false; |
| 671 | - foreach ($types['topic'] as $id => $board) |
|
| 672 | - foreach ($board['lines'] as $topic) |
|
| 707 | + foreach ($types['topic'] as $id => $board) { |
|
| 708 | + foreach ($board['lines'] as $topic) |
|
| 673 | 709 | if (in_array($mid, $topic['members'])) |
| 674 | 710 | { |
| 675 | 711 | if (!$titled) |
| 676 | 712 | { |
| 677 | 713 | $email['body'] .= "\n" . $langtxt[$lang]['new_topics'] . ':' . "\n" . '-----------------------------------------------'; |
| 714 | + } |
|
| 678 | 715 | $titled = true; |
| 679 | 716 | } |
| 680 | 717 | $email['body'] .= "\n" . sprintf($langtxt[$lang]['topic_lines'], $topic['subject'], $board['name']); |
| 681 | 718 | } |
| 682 | - if ($titled) |
|
| 683 | - $email['body'] .= "\n"; |
|
| 719 | + if ($titled) { |
|
| 720 | + $email['body'] .= "\n"; |
|
| 721 | + } |
|
| 684 | 722 | } |
| 685 | 723 | |
| 686 | 724 | // What about replies? |
| 687 | 725 | if (isset($types['reply'])) |
| 688 | 726 | { |
| 689 | 727 | $titled = false; |
| 690 | - foreach ($types['reply'] as $id => $board) |
|
| 691 | - foreach ($board['lines'] as $topic) |
|
| 728 | + foreach ($types['reply'] as $id => $board) { |
|
| 729 | + foreach ($board['lines'] as $topic) |
|
| 692 | 730 | if (in_array($mid, $topic['members'])) |
| 693 | 731 | { |
| 694 | 732 | if (!$titled) |
| 695 | 733 | { |
| 696 | 734 | $email['body'] .= "\n" . $langtxt[$lang]['new_replies'] . ':' . "\n" . '-----------------------------------------------'; |
| 735 | + } |
|
| 697 | 736 | $titled = true; |
| 698 | 737 | } |
| 699 | 738 | $email['body'] .= "\n" . ($topic['count'] == 1 ? sprintf($langtxt[$lang]['replies_one'], $topic['subject']) : sprintf($langtxt[$lang]['replies_many'], $topic['count'], $topic['subject'])); |
| 700 | 739 | } |
| 701 | 740 | |
| 702 | - if ($titled) |
|
| 703 | - $email['body'] .= "\n"; |
|
| 741 | + if ($titled) { |
|
| 742 | + $email['body'] .= "\n"; |
|
| 743 | + } |
|
| 704 | 744 | } |
| 705 | 745 | |
| 706 | 746 | // Finally, moderation actions! |
@@ -709,24 +749,27 @@ discard block |
||
| 709 | 749 | $titled = false; |
| 710 | 750 | foreach ($types as $note_type => $type) |
| 711 | 751 | { |
| 712 | - if ($note_type == 'topic' || $note_type == 'reply') |
|
| 713 | - continue; |
|
| 752 | + if ($note_type == 'topic' || $note_type == 'reply') { |
|
| 753 | + continue; |
|
| 754 | + } |
|
| 714 | 755 | |
| 715 | - foreach ($type as $id => $board) |
|
| 716 | - foreach ($board['lines'] as $topic) |
|
| 756 | + foreach ($type as $id => $board) { |
|
| 757 | + foreach ($board['lines'] as $topic) |
|
| 717 | 758 | if (in_array($mid, $topic['members'])) |
| 718 | 759 | { |
| 719 | 760 | if (!$titled) |
| 720 | 761 | { |
| 721 | 762 | $email['body'] .= "\n" . $langtxt[$lang]['mod_actions'] . ':' . "\n" . '-----------------------------------------------'; |
| 763 | + } |
|
| 722 | 764 | $titled = true; |
| 723 | 765 | } |
| 724 | 766 | $email['body'] .= "\n" . sprintf($langtxt[$lang][$note_type], $topic['subject']); |
| 725 | 767 | } |
| 726 | 768 | } |
| 727 | 769 | } |
| 728 | - if ($titled) |
|
| 729 | - $email['body'] .= "\n"; |
|
| 770 | + if ($titled) { |
|
| 771 | + $email['body'] .= "\n"; |
|
| 772 | + } |
|
| 730 | 773 | |
| 731 | 774 | // Then just say our goodbyes! |
| 732 | 775 | $email['body'] .= "\n\n" . $txt['regards_team']; |
@@ -754,8 +797,7 @@ discard block |
||
| 754 | 797 | 'not_daily' => 0, |
| 755 | 798 | ) |
| 756 | 799 | ); |
| 757 | - } |
|
| 758 | - else |
|
| 800 | + } else |
|
| 759 | 801 | { |
| 760 | 802 | // Clear any only weekly ones, and stop us from sending daily again. |
| 761 | 803 | $smcFunc['db_query']('', ' |
@@ -817,16 +859,19 @@ discard block |
||
| 817 | 859 | global $modSettings, $smcFunc, $sourcedir; |
| 818 | 860 | |
| 819 | 861 | // Are we intending another script to be sending out the queue? |
| 820 | - if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) |
|
| 821 | - return false; |
|
| 862 | + if (!empty($modSettings['mail_queue_use_cron']) && empty($force_send)) { |
|
| 863 | + return false; |
|
| 864 | + } |
|
| 822 | 865 | |
| 823 | 866 | // By default send 5 at once. |
| 824 | - if (!$number) |
|
| 825 | - $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
| 867 | + if (!$number) { |
|
| 868 | + $number = empty($modSettings['mail_quantity']) ? 5 : $modSettings['mail_quantity']; |
|
| 869 | + } |
|
| 826 | 870 | |
| 827 | 871 | // If we came with a timestamp, and that doesn't match the next event, then someone else has beaten us. |
| 828 | - if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) |
|
| 829 | - return false; |
|
| 872 | + if (isset($_GET['ts']) && $_GET['ts'] != $modSettings['mail_next_send'] && empty($force_send)) { |
|
| 873 | + return false; |
|
| 874 | + } |
|
| 830 | 875 | |
| 831 | 876 | // By default move the next sending on by 10 seconds, and require an affected row. |
| 832 | 877 | if (!$override_limit) |
@@ -843,8 +888,9 @@ discard block |
||
| 843 | 888 | 'last_send' => $modSettings['mail_next_send'], |
| 844 | 889 | ) |
| 845 | 890 | ); |
| 846 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 847 | - return false; |
|
| 891 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 892 | + return false; |
|
| 893 | + } |
|
| 848 | 894 | $modSettings['mail_next_send'] = time() + $delay; |
| 849 | 895 | } |
| 850 | 896 | |
@@ -865,8 +911,9 @@ discard block |
||
| 865 | 911 | $mn += $number; |
| 866 | 912 | } |
| 867 | 913 | // No more I'm afraid, return! |
| 868 | - else |
|
| 869 | - return false; |
|
| 914 | + else { |
|
| 915 | + return false; |
|
| 916 | + } |
|
| 870 | 917 | |
| 871 | 918 | // Reflect that we're about to send some, do it now to be safe. |
| 872 | 919 | updateSettings(array('mail_recent' => $mt . '|' . $mn)); |
@@ -901,14 +948,15 @@ discard block |
||
| 901 | 948 | $smcFunc['db_free_result']($request); |
| 902 | 949 | |
| 903 | 950 | // Delete, delete, delete!!! |
| 904 | - if (!empty($ids)) |
|
| 905 | - $smcFunc['db_query']('', ' |
|
| 951 | + if (!empty($ids)) { |
|
| 952 | + $smcFunc['db_query']('', ' |
|
| 906 | 953 | DELETE FROM {db_prefix}mail_queue |
| 907 | 954 | WHERE id_mail IN ({array_int:mail_list})', |
| 908 | 955 | array( |
| 909 | 956 | 'mail_list' => $ids, |
| 910 | 957 | ) |
| 911 | 958 | ); |
| 959 | + } |
|
| 912 | 960 | |
| 913 | 961 | // Don't believe we have any left? |
| 914 | 962 | if (count($ids) < $number) |
@@ -926,11 +974,13 @@ discard block |
||
| 926 | 974 | ); |
| 927 | 975 | } |
| 928 | 976 | |
| 929 | - if (empty($ids)) |
|
| 930 | - return false; |
|
| 977 | + if (empty($ids)) { |
|
| 978 | + return false; |
|
| 979 | + } |
|
| 931 | 980 | |
| 932 | - if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') |
|
| 933 | - require_once($sourcedir . '/Subs-Post.php'); |
|
| 981 | + if (!empty($modSettings['mail_type']) && $modSettings['smtp_host'] != '') { |
|
| 982 | + require_once($sourcedir . '/Subs-Post.php'); |
|
| 983 | + } |
|
| 934 | 984 | |
| 935 | 985 | // Send each email, yea! |
| 936 | 986 | $failed_emails = array(); |
@@ -950,15 +1000,17 @@ discard block |
||
| 950 | 1000 | |
| 951 | 1001 | // Try to stop a timeout, this would be bad... |
| 952 | 1002 | @set_time_limit(300); |
| 953 | - if (function_exists('apache_reset_timeout')) |
|
| 954 | - @apache_reset_timeout(); |
|
| 1003 | + if (function_exists('apache_reset_timeout')) { |
|
| 1004 | + @apache_reset_timeout(); |
|
| 1005 | + } |
|
| 1006 | + } else { |
|
| 1007 | + $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
| 955 | 1008 | } |
| 956 | - else |
|
| 957 | - $result = smtp_mail(array($email['to']), $email['subject'], $email['body'], $email['headers']); |
|
| 958 | 1009 | |
| 959 | 1010 | // Hopefully it sent? |
| 960 | - if (!$result) |
|
| 961 | - $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
| 1011 | + if (!$result) { |
|
| 1012 | + $failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private']); |
|
| 1013 | + } |
|
| 962 | 1014 | } |
| 963 | 1015 | |
| 964 | 1016 | // Any emails that didn't send? |
@@ -973,8 +1025,8 @@ discard block |
||
| 973 | 1025 | ); |
| 974 | 1026 | |
| 975 | 1027 | // If we have failed to many times, tell mail to wait a bit and try again. |
| 976 | - if ($modSettings['mail_failed_attempts'] > 5) |
|
| 977 | - $smcFunc['db_query']('', ' |
|
| 1028 | + if ($modSettings['mail_failed_attempts'] > 5) { |
|
| 1029 | + $smcFunc['db_query']('', ' |
|
| 978 | 1030 | UPDATE {db_prefix}settings |
| 979 | 1031 | SET value = {string:next_mail_send} |
| 980 | 1032 | WHERE variable = {literal:mail_next_send} |
@@ -983,6 +1035,7 @@ discard block |
||
| 983 | 1035 | 'next_mail_send' => time() + 60, |
| 984 | 1036 | 'last_send' => $modSettings['mail_next_send'], |
| 985 | 1037 | )); |
| 1038 | + } |
|
| 986 | 1039 | |
| 987 | 1040 | // Add our email back to the queue, manually. |
| 988 | 1041 | $smcFunc['db_insert']('insert', |
@@ -995,8 +1048,8 @@ discard block |
||
| 995 | 1048 | return false; |
| 996 | 1049 | } |
| 997 | 1050 | // We where unable to send the email, clear our failed attempts. |
| 998 | - elseif (!empty($modSettings['mail_failed_attempts'])) |
|
| 999 | - $smcFunc['db_query']('', ' |
|
| 1051 | + elseif (!empty($modSettings['mail_failed_attempts'])) { |
|
| 1052 | + $smcFunc['db_query']('', ' |
|
| 1000 | 1053 | UPDATE {db_prefix}settings |
| 1001 | 1054 | SET value = {string:zero} |
| 1002 | 1055 | WHERE variable = {string:mail_failed_attempts}', |
@@ -1004,6 +1057,7 @@ discard block |
||
| 1004 | 1057 | 'zero' => '0', |
| 1005 | 1058 | 'mail_failed_attempts' => 'mail_failed_attempts', |
| 1006 | 1059 | )); |
| 1060 | + } |
|
| 1007 | 1061 | |
| 1008 | 1062 | // Had something to send... |
| 1009 | 1063 | return true; |
@@ -1020,16 +1074,18 @@ discard block |
||
| 1020 | 1074 | global $modSettings, $smcFunc; |
| 1021 | 1075 | |
| 1022 | 1076 | $task_query = ''; |
| 1023 | - if (!is_array($tasks)) |
|
| 1024 | - $tasks = array($tasks); |
|
| 1077 | + if (!is_array($tasks)) { |
|
| 1078 | + $tasks = array($tasks); |
|
| 1079 | + } |
|
| 1025 | 1080 | |
| 1026 | 1081 | // Actually have something passed? |
| 1027 | 1082 | if (!empty($tasks)) |
| 1028 | 1083 | { |
| 1029 | - if (!isset($tasks[0]) || is_numeric($tasks[0])) |
|
| 1030 | - $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
| 1031 | - else |
|
| 1032 | - $task_query = ' AND task IN ({array_string:tasks})'; |
|
| 1084 | + if (!isset($tasks[0]) || is_numeric($tasks[0])) { |
|
| 1085 | + $task_query = ' AND id_task IN ({array_int:tasks})'; |
|
| 1086 | + } else { |
|
| 1087 | + $task_query = ' AND task IN ({array_string:tasks})'; |
|
| 1088 | + } |
|
| 1033 | 1089 | } |
| 1034 | 1090 | $nextTaskTime = empty($tasks) ? time() + 86400 : $modSettings['next_task_time']; |
| 1035 | 1091 | |
@@ -1050,20 +1106,22 @@ discard block |
||
| 1050 | 1106 | $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']); |
| 1051 | 1107 | |
| 1052 | 1108 | // Only bother moving the task if it's out of place or we're forcing it! |
| 1053 | - if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) |
|
| 1054 | - $tasks[$row['id_task']] = $next_time; |
|
| 1055 | - else |
|
| 1056 | - $next_time = $row['next_time']; |
|
| 1109 | + if ($forceUpdate || $next_time < $row['next_time'] || $row['next_time'] < time()) { |
|
| 1110 | + $tasks[$row['id_task']] = $next_time; |
|
| 1111 | + } else { |
|
| 1112 | + $next_time = $row['next_time']; |
|
| 1113 | + } |
|
| 1057 | 1114 | |
| 1058 | 1115 | // If this is sooner than the current next task, make this the next task. |
| 1059 | - if ($next_time < $nextTaskTime) |
|
| 1060 | - $nextTaskTime = $next_time; |
|
| 1116 | + if ($next_time < $nextTaskTime) { |
|
| 1117 | + $nextTaskTime = $next_time; |
|
| 1118 | + } |
|
| 1061 | 1119 | } |
| 1062 | 1120 | $smcFunc['db_free_result']($request); |
| 1063 | 1121 | |
| 1064 | 1122 | // Now make the changes! |
| 1065 | - foreach ($tasks as $id => $time) |
|
| 1066 | - $smcFunc['db_query']('', ' |
|
| 1123 | + foreach ($tasks as $id => $time) { |
|
| 1124 | + $smcFunc['db_query']('', ' |
|
| 1067 | 1125 | UPDATE {db_prefix}scheduled_tasks |
| 1068 | 1126 | SET next_time = {int:next_time} |
| 1069 | 1127 | WHERE id_task = {int:id_task}', |
@@ -1072,11 +1130,13 @@ discard block |
||
| 1072 | 1130 | 'id_task' => $id, |
| 1073 | 1131 | ) |
| 1074 | 1132 | ); |
| 1133 | + } |
|
| 1075 | 1134 | |
| 1076 | 1135 | // If the next task is now different update. |
| 1077 | - if ($modSettings['next_task_time'] != $nextTaskTime) |
|
| 1078 | - updateSettings(array('next_task_time' => $nextTaskTime)); |
|
| 1079 | -} |
|
| 1136 | + if ($modSettings['next_task_time'] != $nextTaskTime) { |
|
| 1137 | + updateSettings(array('next_task_time' => $nextTaskTime)); |
|
| 1138 | + } |
|
| 1139 | + } |
|
| 1080 | 1140 | |
| 1081 | 1141 | /** |
| 1082 | 1142 | * Simply returns a time stamp of the next instance of these time parameters. |
@@ -1089,8 +1149,9 @@ discard block |
||
| 1089 | 1149 | function next_time($regularity, $unit, $offset) |
| 1090 | 1150 | { |
| 1091 | 1151 | // Just in case! |
| 1092 | - if ($regularity == 0) |
|
| 1093 | - $regularity = 2; |
|
| 1152 | + if ($regularity == 0) { |
|
| 1153 | + $regularity = 2; |
|
| 1154 | + } |
|
| 1094 | 1155 | |
| 1095 | 1156 | $curHour = date('H', time()); |
| 1096 | 1157 | $curMin = date('i', time()); |
@@ -1102,15 +1163,16 @@ discard block |
||
| 1102 | 1163 | $off = date('i', $offset); |
| 1103 | 1164 | |
| 1104 | 1165 | // If it's now just pretend it ain't, |
| 1105 | - if ($off == $curMin) |
|
| 1106 | - $next_time = time() + $regularity; |
|
| 1107 | - else |
|
| 1166 | + if ($off == $curMin) { |
|
| 1167 | + $next_time = time() + $regularity; |
|
| 1168 | + } else |
|
| 1108 | 1169 | { |
| 1109 | 1170 | // Make sure that the offset is always in the past. |
| 1110 | 1171 | $off = $off > $curMin ? $off - 60 : $off; |
| 1111 | 1172 | |
| 1112 | - while ($off <= $curMin) |
|
| 1113 | - $off += $regularity; |
|
| 1173 | + while ($off <= $curMin) { |
|
| 1174 | + $off += $regularity; |
|
| 1175 | + } |
|
| 1114 | 1176 | |
| 1115 | 1177 | // Now we know when the time should be! |
| 1116 | 1178 | $next_time = time() + 60 * ($off - $curMin); |
@@ -1130,11 +1192,13 @@ discard block |
||
| 1130 | 1192 | // Default we'll jump in hours. |
| 1131 | 1193 | $applyOffset = 3600; |
| 1132 | 1194 | // 24 hours = 1 day. |
| 1133 | - if ($unit == 'd') |
|
| 1134 | - $applyOffset = 86400; |
|
| 1195 | + if ($unit == 'd') { |
|
| 1196 | + $applyOffset = 86400; |
|
| 1197 | + } |
|
| 1135 | 1198 | // Otherwise a week. |
| 1136 | - if ($unit == 'w') |
|
| 1137 | - $applyOffset = 604800; |
|
| 1199 | + if ($unit == 'w') { |
|
| 1200 | + $applyOffset = 604800; |
|
| 1201 | + } |
|
| 1138 | 1202 | |
| 1139 | 1203 | $applyOffset *= $regularity; |
| 1140 | 1204 | |
@@ -1171,8 +1235,9 @@ discard block |
||
| 1171 | 1235 | $settings[$row['variable']] = $row['value']; |
| 1172 | 1236 | |
| 1173 | 1237 | // Is this the default theme? |
| 1174 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') |
|
| 1175 | - $settings['default_' . $row['variable']] = $row['value']; |
|
| 1238 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1') { |
|
| 1239 | + $settings['default_' . $row['variable']] = $row['value']; |
|
| 1240 | + } |
|
| 1176 | 1241 | } |
| 1177 | 1242 | $smcFunc['db_free_result']($result); |
| 1178 | 1243 | |
@@ -1182,12 +1247,14 @@ discard block |
||
| 1182 | 1247 | $settings['template_dirs'] = array($settings['theme_dir']); |
| 1183 | 1248 | |
| 1184 | 1249 | // Based on theme (if there is one). |
| 1185 | - if (!empty($settings['base_theme_dir'])) |
|
| 1186 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1250 | + if (!empty($settings['base_theme_dir'])) { |
|
| 1251 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
| 1252 | + } |
|
| 1187 | 1253 | |
| 1188 | 1254 | // Lastly the default theme. |
| 1189 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
| 1190 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1255 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
| 1256 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
| 1257 | + } |
|
| 1191 | 1258 | } |
| 1192 | 1259 | |
| 1193 | 1260 | // Assume we want this. |
@@ -1333,8 +1400,9 @@ discard block |
||
| 1333 | 1400 | // Ok should we prune the logs? |
| 1334 | 1401 | if (!empty($modSettings['pruningOptions'])) |
| 1335 | 1402 | { |
| 1336 | - if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) |
|
| 1337 | - list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 1403 | + if (!empty($modSettings['pruningOptions']) && strpos($modSettings['pruningOptions'], ',') !== false) { |
|
| 1404 | + list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
| 1405 | + } |
|
| 1338 | 1406 | |
| 1339 | 1407 | if (!empty($modSettings['pruneErrorLog'])) |
| 1340 | 1408 | { |
@@ -1400,8 +1468,9 @@ discard block |
||
| 1400 | 1468 | ) |
| 1401 | 1469 | ); |
| 1402 | 1470 | |
| 1403 | - while ($row = $smcFunc['db_fetch_row']($result)) |
|
| 1404 | - $reports[] = $row[0]; |
|
| 1471 | + while ($row = $smcFunc['db_fetch_row']($result)) { |
|
| 1472 | + $reports[] = $row[0]; |
|
| 1473 | + } |
|
| 1405 | 1474 | |
| 1406 | 1475 | $smcFunc['db_free_result']($result); |
| 1407 | 1476 | |
@@ -1557,8 +1626,9 @@ discard block |
||
| 1557 | 1626 | $emaildata = loadEmailTemplate('paid_subscription_reminder', $replacements, empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']); |
| 1558 | 1627 | |
| 1559 | 1628 | // Send the actual email. |
| 1560 | - if ($notifyPrefs[$row['id_member']] & 0x02) |
|
| 1561 | - sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
| 1629 | + if ($notifyPrefs[$row['id_member']] & 0x02) { |
|
| 1630 | + sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2); |
|
| 1631 | + } |
|
| 1562 | 1632 | |
| 1563 | 1633 | if ($notifyPrefs[$row['id_member']] & 0x01) |
| 1564 | 1634 | { |
@@ -1581,18 +1651,19 @@ discard block |
||
| 1581 | 1651 | } |
| 1582 | 1652 | |
| 1583 | 1653 | // Insert the alerts if any |
| 1584 | - if (!empty($alert_rows)) |
|
| 1585 | - $smcFunc['db_insert']('', |
|
| 1654 | + if (!empty($alert_rows)) { |
|
| 1655 | + $smcFunc['db_insert']('', |
|
| 1586 | 1656 | '{db_prefix}user_alerts', |
| 1587 | 1657 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 1588 | 1658 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 1589 | 1659 | $alert_rows, |
| 1590 | 1660 | array() |
| 1591 | 1661 | ); |
| 1662 | + } |
|
| 1592 | 1663 | |
| 1593 | 1664 | // Mark the reminder as sent. |
| 1594 | - if (!empty($subs_reminded)) |
|
| 1595 | - $smcFunc['db_query']('', ' |
|
| 1665 | + if (!empty($subs_reminded)) { |
|
| 1666 | + $smcFunc['db_query']('', ' |
|
| 1596 | 1667 | UPDATE {db_prefix}log_subscribed |
| 1597 | 1668 | SET reminder_sent = {int:reminder_sent} |
| 1598 | 1669 | WHERE id_sublog IN ({array_int:subscription_list})', |
@@ -1601,6 +1672,7 @@ discard block |
||
| 1601 | 1672 | 'reminder_sent' => 1, |
| 1602 | 1673 | ) |
| 1603 | 1674 | ); |
| 1675 | + } |
|
| 1604 | 1676 | |
| 1605 | 1677 | return true; |
| 1606 | 1678 | } |
@@ -1616,13 +1688,13 @@ discard block |
||
| 1616 | 1688 | // We need to know where this thing is going. |
| 1617 | 1689 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
| 1618 | 1690 | { |
| 1619 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 1620 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 1691 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 1692 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 1693 | + } |
|
| 1621 | 1694 | |
| 1622 | 1695 | // Just use the current path for temp files. |
| 1623 | 1696 | $attach_dirs = $modSettings['attachmentUploadDir']; |
| 1624 | - } |
|
| 1625 | - else |
|
| 1697 | + } else |
|
| 1626 | 1698 | { |
| 1627 | 1699 | $attach_dirs = array($modSettings['attachmentUploadDir']); |
| 1628 | 1700 | } |
@@ -1641,14 +1713,16 @@ discard block |
||
| 1641 | 1713 | |
| 1642 | 1714 | while ($file = readdir($dir)) |
| 1643 | 1715 | { |
| 1644 | - if ($file == '.' || $file == '..') |
|
| 1645 | - continue; |
|
| 1716 | + if ($file == '.' || $file == '..') { |
|
| 1717 | + continue; |
|
| 1718 | + } |
|
| 1646 | 1719 | |
| 1647 | 1720 | if (strpos($file, 'post_tmp_') !== false) |
| 1648 | 1721 | { |
| 1649 | 1722 | // Temp file is more than 5 hours old! |
| 1650 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
| 1651 | - @unlink($attach_dir . '/' . $file); |
|
| 1723 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
| 1724 | + @unlink($attach_dir . '/' . $file); |
|
| 1725 | + } |
|
| 1652 | 1726 | } |
| 1653 | 1727 | } |
| 1654 | 1728 | closedir($dir); |
@@ -1681,8 +1755,9 @@ discard block |
||
| 1681 | 1755 | ) |
| 1682 | 1756 | ); |
| 1683 | 1757 | |
| 1684 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1685 | - $topics[] = $row[0]; |
|
| 1758 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1759 | + $topics[] = $row[0]; |
|
| 1760 | + } |
|
| 1686 | 1761 | $smcFunc['db_free_result']($request); |
| 1687 | 1762 | |
| 1688 | 1763 | // Zap, your gone |
@@ -1702,8 +1777,9 @@ discard block |
||
| 1702 | 1777 | { |
| 1703 | 1778 | global $smcFunc, $sourcedir, $modSettings; |
| 1704 | 1779 | |
| 1705 | - if (empty($modSettings['drafts_keep_days'])) |
|
| 1706 | - return true; |
|
| 1780 | + if (empty($modSettings['drafts_keep_days'])) { |
|
| 1781 | + return true; |
|
| 1782 | + } |
|
| 1707 | 1783 | |
| 1708 | 1784 | // init |
| 1709 | 1785 | $drafts = array(); |
@@ -1721,8 +1797,9 @@ discard block |
||
| 1721 | 1797 | ) |
| 1722 | 1798 | ); |
| 1723 | 1799 | |
| 1724 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1725 | - $drafts[] = (int) $row[0]; |
|
| 1800 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1801 | + $drafts[] = (int) $row[0]; |
|
| 1802 | + } |
|
| 1726 | 1803 | $smcFunc['db_free_result']($request); |
| 1727 | 1804 | |
| 1728 | 1805 | // If we have old one, remove them |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
| 23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
| 24 | 25 | |
| 25 | 26 | // Attempt to load the member's profile data. |
| 26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
| 27 | - fatal_lang_error('not_a_user', false, 404); |
|
| 27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
| 28 | + fatal_lang_error('not_a_user', false, 404); |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | // Set up the stuff and load the user. |
| 30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
| 49 | 51 | |
| 50 | 52 | // See if they have broken any warning levels... |
| 51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
| 52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
| 53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
| 54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
| 55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
| 56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
| 57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
| 54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
| 55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
| 56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
| 57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
| 58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
| 59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | // They haven't even been registered for a full day!? |
| 60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
| 61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
| 62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
| 63 | - else |
|
| 64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
| 64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
| 65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
| 66 | + } else { |
|
| 67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | // Set the age... |
| 67 | 71 | if (empty($context['member']['birth_date'])) |
@@ -70,8 +74,7 @@ discard block |
||
| 70 | 74 | 'age' => $txt['not_applicable'], |
| 71 | 75 | 'today_is_birthday' => false |
| 72 | 76 | ); |
| 73 | - } |
|
| 74 | - else |
|
| 77 | + } else |
|
| 75 | 78 | { |
| 76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
| 77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
| 84 | 87 | if (allowedTo('moderate_forum')) |
| 85 | 88 | { |
| 86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
| 87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
| 88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
| 89 | - else |
|
| 90 | - $context['member']['hostname'] = ''; |
|
| 90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
| 91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
| 92 | + } else { |
|
| 93 | + $context['member']['hostname'] = ''; |
|
| 94 | + } |
|
| 91 | 95 | |
| 92 | 96 | $context['can_see_ip'] = true; |
| 97 | + } else { |
|
| 98 | + $context['can_see_ip'] = false; |
|
| 93 | 99 | } |
| 94 | - else |
|
| 95 | - $context['can_see_ip'] = false; |
|
| 96 | 100 | |
| 97 | 101 | // Are they hidden? |
| 98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
| 103 | 107 | include_once($sourcedir . '/Who.php'); |
| 104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
| 105 | 109 | |
| 106 | - if ($action !== false) |
|
| 107 | - $context['member']['action'] = $action; |
|
| 110 | + if ($action !== false) { |
|
| 111 | + $context['member']['action'] = $action; |
|
| 112 | + } |
|
| 108 | 113 | } |
| 109 | 114 | |
| 110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
| 167 | 172 | { |
| 168 | 173 | // Work out what restrictions we actually have. |
| 169 | 174 | $ban_restrictions = array(); |
| 170 | - foreach (array('access', 'register', 'login', 'post') as $type) |
|
| 171 | - if ($row['cannot_' . $type]) |
|
| 175 | + foreach (array('access', 'register', 'login', 'post') as $type) { |
|
| 176 | + if ($row['cannot_' . $type]) |
|
| 172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
| 178 | + } |
|
| 173 | 179 | |
| 174 | 180 | // No actual ban in place? |
| 175 | - if (empty($ban_restrictions)) |
|
| 176 | - continue; |
|
| 181 | + if (empty($ban_restrictions)) { |
|
| 182 | + continue; |
|
| 183 | + } |
|
| 177 | 184 | |
| 178 | 185 | // Prepare the link for context. |
| 179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -196,9 +203,10 @@ discard block |
||
| 196 | 203 | $context['print_custom_fields'] = array(); |
| 197 | 204 | |
| 198 | 205 | // Any custom profile fields? |
| 199 | - if (!empty($context['custom_fields'])) |
|
| 200 | - foreach ($context['custom_fields'] as $custom) |
|
| 206 | + if (!empty($context['custom_fields'])) { |
|
| 207 | + foreach ($context['custom_fields'] as $custom) |
|
| 201 | 208 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 209 | + } |
|
| 202 | 210 | |
| 203 | 211 | } |
| 204 | 212 | |
@@ -242,14 +250,16 @@ discard block |
||
| 242 | 250 | $row['extra'] = !empty($row['extra']) ? smf_json_decode($row['extra'], true) : array(); |
| 243 | 251 | $alerts[$id_alert] = $row; |
| 244 | 252 | |
| 245 | - if (!empty($row['sender_id'])) |
|
| 246 | - $senders[] = $row['sender_id']; |
|
| 253 | + if (!empty($row['sender_id'])) { |
|
| 254 | + $senders[] = $row['sender_id']; |
|
| 255 | + } |
|
| 247 | 256 | } |
| 248 | 257 | $smcFunc['db_free_result']($request); |
| 249 | 258 | |
| 250 | 259 | $senders = loadMemberData($senders); |
| 251 | - foreach ($senders as $member) |
|
| 252 | - loadMemberContext($member); |
|
| 260 | + foreach ($senders as $member) { |
|
| 261 | + loadMemberContext($member); |
|
| 262 | + } |
|
| 253 | 263 | |
| 254 | 264 | // Now go through and actually make with the text. |
| 255 | 265 | loadLanguage('Alerts'); |
@@ -263,12 +273,15 @@ discard block |
||
| 263 | 273 | $msgs = array(); |
| 264 | 274 | foreach ($alerts as $id_alert => $alert) |
| 265 | 275 | { |
| 266 | - if (isset($alert['extra']['board'])) |
|
| 267 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 268 | - if (isset($alert['extra']['topic'])) |
|
| 269 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 270 | - if ($alert['content_type'] == 'msg') |
|
| 271 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 276 | + if (isset($alert['extra']['board'])) { |
|
| 277 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 278 | + } |
|
| 279 | + if (isset($alert['extra']['topic'])) { |
|
| 280 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 281 | + } |
|
| 282 | + if ($alert['content_type'] == 'msg') { |
|
| 283 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 284 | + } |
|
| 272 | 285 | } |
| 273 | 286 | |
| 274 | 287 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -283,8 +296,9 @@ discard block |
||
| 283 | 296 | 'boards' => array_keys($boards), |
| 284 | 297 | ) |
| 285 | 298 | ); |
| 286 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 287 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 299 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 300 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 301 | + } |
|
| 288 | 302 | } |
| 289 | 303 | if (!empty($topics)) |
| 290 | 304 | { |
@@ -299,8 +313,9 @@ discard block |
||
| 299 | 313 | 'topics' => array_keys($topics), |
| 300 | 314 | ) |
| 301 | 315 | ); |
| 302 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 303 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 317 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 318 | + } |
|
| 304 | 319 | } |
| 305 | 320 | if (!empty($msgs)) |
| 306 | 321 | { |
@@ -315,26 +330,33 @@ discard block |
||
| 315 | 330 | 'msgs' => array_keys($msgs), |
| 316 | 331 | ) |
| 317 | 332 | ); |
| 318 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 319 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 333 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 334 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 335 | + } |
|
| 320 | 336 | } |
| 321 | 337 | |
| 322 | 338 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
| 323 | 339 | foreach ($alerts as $id_alert => $alert) |
| 324 | 340 | { |
| 325 | - if (!empty($alert['text'])) |
|
| 326 | - continue; |
|
| 327 | - if (isset($alert['extra']['board'])) |
|
| 328 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 329 | - if (isset($alert['extra']['topic'])) |
|
| 330 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 331 | - if ($alert['content_type'] == 'msg') |
|
| 332 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 333 | - if ($alert['content_type'] == 'profile') |
|
| 334 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 335 | - |
|
| 336 | - if (!empty($memberContext[$alert['sender_id']])) |
|
| 337 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 341 | + if (!empty($alert['text'])) { |
|
| 342 | + continue; |
|
| 343 | + } |
|
| 344 | + if (isset($alert['extra']['board'])) { |
|
| 345 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 346 | + } |
|
| 347 | + if (isset($alert['extra']['topic'])) { |
|
| 348 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 349 | + } |
|
| 350 | + if ($alert['content_type'] == 'msg') { |
|
| 351 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 352 | + } |
|
| 353 | + if ($alert['content_type'] == 'profile') { |
|
| 354 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
| 358 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 359 | + } |
|
| 338 | 360 | |
| 339 | 361 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
| 340 | 362 | if (isset($txt[$string])) |
@@ -422,11 +444,11 @@ discard block |
||
| 422 | 444 | checkSession('request'); |
| 423 | 445 | |
| 424 | 446 | // Call it! |
| 425 | - if ($action == 'remove') |
|
| 426 | - alert_delete($toMark, $memID); |
|
| 427 | - |
|
| 428 | - else |
|
| 429 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 447 | + if ($action == 'remove') { |
|
| 448 | + alert_delete($toMark, $memID); |
|
| 449 | + } else { |
|
| 450 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 451 | + } |
|
| 430 | 452 | |
| 431 | 453 | // Set a nice update message. |
| 432 | 454 | $_SESSION['update_message'] = true; |
@@ -476,23 +498,27 @@ discard block |
||
| 476 | 498 | ); |
| 477 | 499 | |
| 478 | 500 | // Set the page title |
| 479 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
| 480 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 481 | - else |
|
| 482 | - $context['page_title'] = $txt['showPosts']; |
|
| 501 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
| 502 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 503 | + } else { |
|
| 504 | + $context['page_title'] = $txt['showPosts']; |
|
| 505 | + } |
|
| 483 | 506 | |
| 484 | 507 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
| 485 | 508 | |
| 486 | 509 | // Is the load average too high to allow searching just now? |
| 487 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
| 488 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 510 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
| 511 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 512 | + } |
|
| 489 | 513 | |
| 490 | 514 | // If we're specifically dealing with attachments use that function! |
| 491 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
| 492 | - return showAttachments($memID); |
|
| 515 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
| 516 | + return showAttachments($memID); |
|
| 517 | + } |
|
| 493 | 518 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
| 494 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
| 495 | - return showUnwatched($memID); |
|
| 519 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
| 520 | + return showUnwatched($memID); |
|
| 521 | + } |
|
| 496 | 522 | |
| 497 | 523 | // Are we just viewing topics? |
| 498 | 524 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -515,27 +541,30 @@ discard block |
||
| 515 | 541 | $smcFunc['db_free_result']($request); |
| 516 | 542 | |
| 517 | 543 | // Trying to remove a message that doesn't exist. |
| 518 | - if (empty($info)) |
|
| 519 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 544 | + if (empty($info)) { |
|
| 545 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 546 | + } |
|
| 520 | 547 | |
| 521 | 548 | // We can be lazy, since removeMessage() will check the permissions for us. |
| 522 | 549 | require_once($sourcedir . '/RemoveTopic.php'); |
| 523 | 550 | removeMessage((int) $_GET['delete']); |
| 524 | 551 | |
| 525 | 552 | // Add it to the mod log. |
| 526 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 527 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 553 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 554 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 555 | + } |
|
| 528 | 556 | |
| 529 | 557 | // Back to... where we are now ;). |
| 530 | 558 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
| 531 | 559 | } |
| 532 | 560 | |
| 533 | 561 | // Default to 10. |
| 534 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 535 | - $_REQUEST['viewscount'] = '10'; |
|
| 562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 563 | + $_REQUEST['viewscount'] = '10'; |
|
| 564 | + } |
|
| 536 | 565 | |
| 537 | - if ($context['is_topics']) |
|
| 538 | - $request = $smcFunc['db_query']('', ' |
|
| 566 | + if ($context['is_topics']) { |
|
| 567 | + $request = $smcFunc['db_query']('', ' |
|
| 539 | 568 | SELECT COUNT(*) |
| 540 | 569 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 541 | 570 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -548,8 +577,8 @@ discard block |
||
| 548 | 577 | 'board' => $board, |
| 549 | 578 | ) |
| 550 | 579 | ); |
| 551 | - else |
|
| 552 | - $request = $smcFunc['db_query']('', ' |
|
| 580 | + } else { |
|
| 581 | + $request = $smcFunc['db_query']('', ' |
|
| 553 | 582 | SELECT COUNT(*) |
| 554 | 583 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 555 | 584 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -562,6 +591,7 @@ discard block |
||
| 562 | 591 | 'board' => $board, |
| 563 | 592 | ) |
| 564 | 593 | ); |
| 594 | + } |
|
| 565 | 595 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
| 566 | 596 | $smcFunc['db_free_result']($request); |
| 567 | 597 | |
@@ -583,10 +613,11 @@ discard block |
||
| 583 | 613 | $reverse = false; |
| 584 | 614 | $range_limit = ''; |
| 585 | 615 | |
| 586 | - if ($context['is_topics']) |
|
| 587 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 588 | - else |
|
| 589 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 616 | + if ($context['is_topics']) { |
|
| 617 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 618 | + } else { |
|
| 619 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 620 | + } |
|
| 590 | 621 | |
| 591 | 622 | $maxIndex = $maxPerPage; |
| 592 | 623 | |
@@ -612,9 +643,9 @@ discard block |
||
| 612 | 643 | { |
| 613 | 644 | $margin *= 5; |
| 614 | 645 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
| 646 | + } else { |
|
| 647 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 615 | 648 | } |
| 616 | - else |
|
| 617 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 618 | 649 | } |
| 619 | 650 | |
| 620 | 651 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -646,8 +677,7 @@ discard block |
||
| 646 | 677 | 'max' => $maxIndex, |
| 647 | 678 | ) |
| 648 | 679 | ); |
| 649 | - } |
|
| 650 | - else |
|
| 680 | + } else |
|
| 651 | 681 | { |
| 652 | 682 | $request = $smcFunc['db_query']('', ' |
| 653 | 683 | SELECT |
@@ -676,8 +706,9 @@ discard block |
||
| 676 | 706 | } |
| 677 | 707 | |
| 678 | 708 | // Make sure we quit this loop. |
| 679 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
| 680 | - break; |
|
| 709 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
| 710 | + break; |
|
| 711 | + } |
|
| 681 | 712 | $looped = true; |
| 682 | 713 | $range_limit = ''; |
| 683 | 714 | } |
@@ -721,19 +752,21 @@ discard block |
||
| 721 | 752 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
| 722 | 753 | ); |
| 723 | 754 | |
| 724 | - if ($user_info['id'] == $row['id_member_started']) |
|
| 725 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
| 755 | + if ($user_info['id'] == $row['id_member_started']) { |
|
| 756 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
| 757 | + } |
|
| 726 | 758 | $board_ids['any'][$row['id_board']][] = $counter; |
| 727 | 759 | } |
| 728 | 760 | $smcFunc['db_free_result']($request); |
| 729 | 761 | |
| 730 | 762 | // All posts were retrieved in reverse order, get them right again. |
| 731 | - if ($reverse) |
|
| 732 | - $context['posts'] = array_reverse($context['posts'], true); |
|
| 763 | + if ($reverse) { |
|
| 764 | + $context['posts'] = array_reverse($context['posts'], true); |
|
| 765 | + } |
|
| 733 | 766 | |
| 734 | 767 | // These are all the permissions that are different from board to board.. |
| 735 | - if ($context['is_topics']) |
|
| 736 | - $permissions = array( |
|
| 768 | + if ($context['is_topics']) { |
|
| 769 | + $permissions = array( |
|
| 737 | 770 | 'own' => array( |
| 738 | 771 | 'post_reply_own' => 'can_reply', |
| 739 | 772 | ), |
@@ -741,8 +774,8 @@ discard block |
||
| 741 | 774 | 'post_reply_any' => 'can_reply', |
| 742 | 775 | ) |
| 743 | 776 | ); |
| 744 | - else |
|
| 745 | - $permissions = array( |
|
| 777 | + } else { |
|
| 778 | + $permissions = array( |
|
| 746 | 779 | 'own' => array( |
| 747 | 780 | 'post_reply_own' => 'can_reply', |
| 748 | 781 | 'delete_own' => 'can_delete', |
@@ -752,6 +785,7 @@ discard block |
||
| 752 | 785 | 'delete_any' => 'can_delete', |
| 753 | 786 | ) |
| 754 | 787 | ); |
| 788 | + } |
|
| 755 | 789 | |
| 756 | 790 | // For every permission in the own/any lists... |
| 757 | 791 | foreach ($permissions as $type => $list) |
@@ -762,19 +796,22 @@ discard block |
||
| 762 | 796 | $boards = boardsAllowedTo($permission); |
| 763 | 797 | |
| 764 | 798 | // Hmm, they can do it on all boards, can they? |
| 765 | - if (!empty($boards) && $boards[0] == 0) |
|
| 766 | - $boards = array_keys($board_ids[$type]); |
|
| 799 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 800 | + $boards = array_keys($board_ids[$type]); |
|
| 801 | + } |
|
| 767 | 802 | |
| 768 | 803 | // Now go through each board they can do the permission on. |
| 769 | 804 | foreach ($boards as $board_id) |
| 770 | 805 | { |
| 771 | 806 | // There aren't any posts displayed from this board. |
| 772 | - if (!isset($board_ids[$type][$board_id])) |
|
| 773 | - continue; |
|
| 807 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 808 | + continue; |
|
| 809 | + } |
|
| 774 | 810 | |
| 775 | 811 | // Set the permission to true ;). |
| 776 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 777 | - $context['posts'][$counter][$allowed] = true; |
|
| 812 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 813 | + $context['posts'][$counter][$allowed] = true; |
|
| 814 | + } |
|
| 778 | 815 | } |
| 779 | 816 | } |
| 780 | 817 | } |
@@ -805,8 +842,9 @@ discard block |
||
| 805 | 842 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
| 806 | 843 | |
| 807 | 844 | // Make sure we can't actually see anything... |
| 808 | - if (empty($boardsAllowed)) |
|
| 809 | - $boardsAllowed = array(-1); |
|
| 845 | + if (empty($boardsAllowed)) { |
|
| 846 | + $boardsAllowed = array(-1); |
|
| 847 | + } |
|
| 810 | 848 | |
| 811 | 849 | require_once($sourcedir . '/Subs-List.php'); |
| 812 | 850 | |
@@ -957,8 +995,8 @@ discard block |
||
| 957 | 995 | ) |
| 958 | 996 | ); |
| 959 | 997 | $attachments = array(); |
| 960 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 961 | - $attachments[] = array( |
|
| 998 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 999 | + $attachments[] = array( |
|
| 962 | 1000 | 'id' => $row['id_attach'], |
| 963 | 1001 | 'filename' => $row['filename'], |
| 964 | 1002 | 'downloads' => $row['downloads'], |
@@ -970,6 +1008,7 @@ discard block |
||
| 970 | 1008 | 'board_name' => $row['name'], |
| 971 | 1009 | 'approved' => $row['approved'], |
| 972 | 1010 | ); |
| 1011 | + } |
|
| 973 | 1012 | |
| 974 | 1013 | $smcFunc['db_free_result']($request); |
| 975 | 1014 | |
@@ -1024,8 +1063,9 @@ discard block |
||
| 1024 | 1063 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
| 1025 | 1064 | |
| 1026 | 1065 | // Only the owner can see the list (if the function is enabled of course) |
| 1027 | - if ($user_info['id'] != $memID) |
|
| 1028 | - return; |
|
| 1066 | + if ($user_info['id'] != $memID) { |
|
| 1067 | + return; |
|
| 1068 | + } |
|
| 1029 | 1069 | |
| 1030 | 1070 | require_once($sourcedir . '/Subs-List.php'); |
| 1031 | 1071 | |
@@ -1171,8 +1211,9 @@ discard block |
||
| 1171 | 1211 | ); |
| 1172 | 1212 | |
| 1173 | 1213 | $topics = array(); |
| 1174 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1175 | - $topics[] = $row['id_topic']; |
|
| 1214 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1215 | + $topics[] = $row['id_topic']; |
|
| 1216 | + } |
|
| 1176 | 1217 | |
| 1177 | 1218 | $smcFunc['db_free_result']($request); |
| 1178 | 1219 | |
@@ -1192,8 +1233,9 @@ discard block |
||
| 1192 | 1233 | 'topics' => $topics, |
| 1193 | 1234 | ) |
| 1194 | 1235 | ); |
| 1195 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1196 | - $topicsInfo[] = $row; |
|
| 1236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1237 | + $topicsInfo[] = $row; |
|
| 1238 | + } |
|
| 1197 | 1239 | $smcFunc['db_free_result']($request); |
| 1198 | 1240 | } |
| 1199 | 1241 | |
@@ -1241,8 +1283,9 @@ discard block |
||
| 1241 | 1283 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
| 1242 | 1284 | |
| 1243 | 1285 | // Is the load average too high to allow searching just now? |
| 1244 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
| 1245 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1286 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
| 1287 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1288 | + } |
|
| 1246 | 1289 | |
| 1247 | 1290 | // General user statistics. |
| 1248 | 1291 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1400,11 +1443,13 @@ discard block |
||
| 1400 | 1443 | } |
| 1401 | 1444 | $smcFunc['db_free_result']($result); |
| 1402 | 1445 | |
| 1403 | - if ($maxPosts > 0) |
|
| 1404 | - for ($hour = 0; $hour < 24; $hour++) |
|
| 1446 | + if ($maxPosts > 0) { |
|
| 1447 | + for ($hour = 0; |
|
| 1448 | + } |
|
| 1449 | + $hour < 24; $hour++) |
|
| 1405 | 1450 | { |
| 1406 | - if (!isset($context['posts_by_time'][$hour])) |
|
| 1407 | - $context['posts_by_time'][$hour] = array( |
|
| 1451 | + if (!isset($context['posts_by_time'][$hour])) { |
|
| 1452 | + $context['posts_by_time'][$hour] = array( |
|
| 1408 | 1453 | 'hour' => $hour, |
| 1409 | 1454 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
| 1410 | 1455 | 'posts' => 0, |
@@ -1412,7 +1457,7 @@ discard block |
||
| 1412 | 1457 | 'relative_percent' => 0, |
| 1413 | 1458 | 'is_last' => $hour == 23, |
| 1414 | 1459 | ); |
| 1415 | - else |
|
| 1460 | + } else |
|
| 1416 | 1461 | { |
| 1417 | 1462 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
| 1418 | 1463 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1445,8 +1490,9 @@ discard block |
||
| 1445 | 1490 | |
| 1446 | 1491 | foreach ($subActions as $sa => $action) |
| 1447 | 1492 | { |
| 1448 | - if (!allowedTo($action[2])) |
|
| 1449 | - unset($subActions[$sa]); |
|
| 1493 | + if (!allowedTo($action[2])) { |
|
| 1494 | + unset($subActions[$sa]); |
|
| 1495 | + } |
|
| 1450 | 1496 | } |
| 1451 | 1497 | |
| 1452 | 1498 | // Create the tabs for the template. |
@@ -1464,15 +1510,18 @@ discard block |
||
| 1464 | 1510 | ); |
| 1465 | 1511 | |
| 1466 | 1512 | // Moderation must be on to track edits. |
| 1467 | - if (empty($modSettings['userlog_enabled'])) |
|
| 1468 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1513 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 1514 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1515 | + } |
|
| 1469 | 1516 | |
| 1470 | 1517 | // Group requests must be active to show it... |
| 1471 | - if (empty($modSettings['show_group_membership'])) |
|
| 1472 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1518 | + if (empty($modSettings['show_group_membership'])) { |
|
| 1519 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1520 | + } |
|
| 1473 | 1521 | |
| 1474 | - if (empty($subActions)) |
|
| 1475 | - fatal_lang_error('no_access', false); |
|
| 1522 | + if (empty($subActions)) { |
|
| 1523 | + fatal_lang_error('no_access', false); |
|
| 1524 | + } |
|
| 1476 | 1525 | |
| 1477 | 1526 | $keys = array_keys($subActions); |
| 1478 | 1527 | $default = array_shift($keys); |
@@ -1485,9 +1534,10 @@ discard block |
||
| 1485 | 1534 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
| 1486 | 1535 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
| 1487 | 1536 | |
| 1488 | - if (!empty($call)) |
|
| 1489 | - call_user_func($call, $memID); |
|
| 1490 | -} |
|
| 1537 | + if (!empty($call)) { |
|
| 1538 | + call_user_func($call, $memID); |
|
| 1539 | + } |
|
| 1540 | + } |
|
| 1491 | 1541 | |
| 1492 | 1542 | /** |
| 1493 | 1543 | * Handles tracking a user's activity |
@@ -1503,8 +1553,9 @@ discard block |
||
| 1503 | 1553 | isAllowedTo('moderate_forum'); |
| 1504 | 1554 | |
| 1505 | 1555 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
| 1506 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
| 1507 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1556 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
| 1557 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1558 | + } |
|
| 1508 | 1559 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
| 1509 | 1560 | |
| 1510 | 1561 | // Set the options for the list component. |
@@ -1670,8 +1721,9 @@ discard block |
||
| 1670 | 1721 | ) |
| 1671 | 1722 | ); |
| 1672 | 1723 | $message_members = array(); |
| 1673 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1674 | - $message_members[] = $row['id_member']; |
|
| 1724 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1725 | + $message_members[] = $row['id_member']; |
|
| 1726 | + } |
|
| 1675 | 1727 | $smcFunc['db_free_result']($request); |
| 1676 | 1728 | |
| 1677 | 1729 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1686,8 +1738,9 @@ discard block |
||
| 1686 | 1738 | 'ip_list' => $ips, |
| 1687 | 1739 | ) |
| 1688 | 1740 | ); |
| 1689 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1690 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1741 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1742 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1743 | + } |
|
| 1691 | 1744 | $smcFunc['db_free_result']($request); |
| 1692 | 1745 | } |
| 1693 | 1746 | |
@@ -1701,8 +1754,9 @@ discard block |
||
| 1701 | 1754 | 'ip_list' => $ips, |
| 1702 | 1755 | ) |
| 1703 | 1756 | ); |
| 1704 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1705 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1757 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1758 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1759 | + } |
|
| 1706 | 1760 | $smcFunc['db_free_result']($request); |
| 1707 | 1761 | } |
| 1708 | 1762 | } |
@@ -1762,8 +1816,8 @@ discard block |
||
| 1762 | 1816 | )) |
| 1763 | 1817 | ); |
| 1764 | 1818 | $error_messages = array(); |
| 1765 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1766 | - $error_messages[] = array( |
|
| 1819 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1820 | + $error_messages[] = array( |
|
| 1767 | 1821 | 'ip' => inet_dtop($row['ip']), |
| 1768 | 1822 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
| 1769 | 1823 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1771,6 +1825,7 @@ discard block |
||
| 1771 | 1825 | 'time' => timeformat($row['log_time']), |
| 1772 | 1826 | 'timestamp' => forum_time(true, $row['log_time']), |
| 1773 | 1827 | ); |
| 1828 | + } |
|
| 1774 | 1829 | $smcFunc['db_free_result']($request); |
| 1775 | 1830 | |
| 1776 | 1831 | return $error_messages; |
@@ -1833,8 +1888,8 @@ discard block |
||
| 1833 | 1888 | )) |
| 1834 | 1889 | ); |
| 1835 | 1890 | $messages = array(); |
| 1836 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1837 | - $messages[] = array( |
|
| 1891 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1892 | + $messages[] = array( |
|
| 1838 | 1893 | 'ip' => inet_dtop($row['poster_ip']), |
| 1839 | 1894 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
| 1840 | 1895 | 'board' => array( |
@@ -1847,6 +1902,7 @@ discard block |
||
| 1847 | 1902 | 'time' => timeformat($row['poster_time']), |
| 1848 | 1903 | 'timestamp' => forum_time(true, $row['poster_time']) |
| 1849 | 1904 | ); |
| 1905 | + } |
|
| 1850 | 1906 | $smcFunc['db_free_result']($request); |
| 1851 | 1907 | |
| 1852 | 1908 | return $messages; |
@@ -1873,19 +1929,20 @@ discard block |
||
| 1873 | 1929 | $context['sub_template'] = 'trackIP'; |
| 1874 | 1930 | $context['page_title'] = $txt['profile']; |
| 1875 | 1931 | $context['base_url'] = $scripturl . '?action=trackip'; |
| 1876 | - } |
|
| 1877 | - else |
|
| 1932 | + } else |
|
| 1878 | 1933 | { |
| 1879 | 1934 | $context['ip'] = $user_profile[$memID]['member_ip']; |
| 1880 | 1935 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
| 1881 | 1936 | } |
| 1882 | 1937 | |
| 1883 | 1938 | // Searching? |
| 1884 | - if (isset($_REQUEST['searchip'])) |
|
| 1885 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1939 | + if (isset($_REQUEST['searchip'])) { |
|
| 1940 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1941 | + } |
|
| 1886 | 1942 | |
| 1887 | - if (isValidIP($context['ip']) === false) |
|
| 1888 | - fatal_lang_error('invalid_tracking_ip', false); |
|
| 1943 | + if (isValidIP($context['ip']) === false) { |
|
| 1944 | + fatal_lang_error('invalid_tracking_ip', false); |
|
| 1945 | + } |
|
| 1889 | 1946 | |
| 1890 | 1947 | //mysql didn't support like search with varbinary |
| 1891 | 1948 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1893,8 +1950,9 @@ discard block |
||
| 1893 | 1950 | $ip_var = $context['ip']; |
| 1894 | 1951 | $ip_string = '= {inet:ip_address}'; |
| 1895 | 1952 | |
| 1896 | - if (empty($context['tracking_area'])) |
|
| 1897 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1953 | + if (empty($context['tracking_area'])) { |
|
| 1954 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1955 | + } |
|
| 1898 | 1956 | |
| 1899 | 1957 | $request = $smcFunc['db_query']('', ' |
| 1900 | 1958 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1905,8 +1963,9 @@ discard block |
||
| 1905 | 1963 | ) |
| 1906 | 1964 | ); |
| 1907 | 1965 | $context['ips'] = array(); |
| 1908 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1909 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1966 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1967 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1968 | + } |
|
| 1910 | 1969 | $smcFunc['db_free_result']($request); |
| 1911 | 1970 | |
| 1912 | 1971 | ksort($context['ips']); |
@@ -2135,8 +2194,9 @@ discard block |
||
| 2135 | 2194 | foreach ($context['whois_servers'] as $whois) |
| 2136 | 2195 | { |
| 2137 | 2196 | // Strip off the "decimal point" and anything following... |
| 2138 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
| 2139 | - $context['auto_whois_server'] = $whois; |
|
| 2197 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
| 2198 | + $context['auto_whois_server'] = $whois; |
|
| 2199 | + } |
|
| 2140 | 2200 | } |
| 2141 | 2201 | } |
| 2142 | 2202 | } |
@@ -2153,10 +2213,11 @@ discard block |
||
| 2153 | 2213 | // Gonna want this for the list. |
| 2154 | 2214 | require_once($sourcedir . '/Subs-List.php'); |
| 2155 | 2215 | |
| 2156 | - if ($memID == 0) |
|
| 2157 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2158 | - else |
|
| 2159 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2216 | + if ($memID == 0) { |
|
| 2217 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2218 | + } else { |
|
| 2219 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2220 | + } |
|
| 2160 | 2221 | |
| 2161 | 2222 | // Start with the user messages. |
| 2162 | 2223 | $listOptions = array( |
@@ -2266,12 +2327,13 @@ discard block |
||
| 2266 | 2327 | ) |
| 2267 | 2328 | ); |
| 2268 | 2329 | $logins = array(); |
| 2269 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2270 | - $logins[] = array( |
|
| 2330 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2331 | + $logins[] = array( |
|
| 2271 | 2332 | 'time' => timeformat($row['time']), |
| 2272 | 2333 | 'ip' => inet_dtop($row['ip']), |
| 2273 | 2334 | 'ip2' => inet_dtop($row['ip2']), |
| 2274 | 2335 | ); |
| 2336 | + } |
|
| 2275 | 2337 | $smcFunc['db_free_result']($request); |
| 2276 | 2338 | |
| 2277 | 2339 | return $logins; |
@@ -2296,11 +2358,12 @@ discard block |
||
| 2296 | 2358 | ) |
| 2297 | 2359 | ); |
| 2298 | 2360 | $context['custom_field_titles'] = array(); |
| 2299 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2300 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2362 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2301 | 2363 | 'title' => $row['field_name'], |
| 2302 | 2364 | 'parse_bbc' => $row['bbc'], |
| 2303 | 2365 | ); |
| 2366 | + } |
|
| 2304 | 2367 | $smcFunc['db_free_result']($request); |
| 2305 | 2368 | |
| 2306 | 2369 | // Set the options for the error lists. |
@@ -2439,19 +2502,22 @@ discard block |
||
| 2439 | 2502 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2440 | 2503 | { |
| 2441 | 2504 | $extra = smf_json_decode($row['extra'], true); |
| 2442 | - if (!empty($extra['applicator'])) |
|
| 2443 | - $members[] = $extra['applicator']; |
|
| 2505 | + if (!empty($extra['applicator'])) { |
|
| 2506 | + $members[] = $extra['applicator']; |
|
| 2507 | + } |
|
| 2444 | 2508 | |
| 2445 | 2509 | // Work out what the name of the action is. |
| 2446 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
| 2447 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2448 | - elseif (isset($txt[$row['action']])) |
|
| 2449 | - $action_text = $txt[$row['action']]; |
|
| 2510 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
| 2511 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2512 | + } elseif (isset($txt[$row['action']])) { |
|
| 2513 | + $action_text = $txt[$row['action']]; |
|
| 2514 | + } |
|
| 2450 | 2515 | // Custom field? |
| 2451 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
| 2452 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2453 | - else |
|
| 2454 | - $action_text = $row['action']; |
|
| 2516 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
| 2517 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2518 | + } else { |
|
| 2519 | + $action_text = $row['action']; |
|
| 2520 | + } |
|
| 2455 | 2521 | |
| 2456 | 2522 | // Parse BBC? |
| 2457 | 2523 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2483,13 +2549,15 @@ discard block |
||
| 2483 | 2549 | ) |
| 2484 | 2550 | ); |
| 2485 | 2551 | $members = array(); |
| 2486 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2487 | - $members[$row['id_member']] = $row['real_name']; |
|
| 2552 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2553 | + $members[$row['id_member']] = $row['real_name']; |
|
| 2554 | + } |
|
| 2488 | 2555 | $smcFunc['db_free_result']($request); |
| 2489 | 2556 | |
| 2490 | - foreach ($edits as $key => $value) |
|
| 2491 | - if (isset($members[$value['id_member']])) |
|
| 2557 | + foreach ($edits as $key => $value) { |
|
| 2558 | + if (isset($members[$value['id_member']])) |
|
| 2492 | 2559 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
| 2560 | + } |
|
| 2493 | 2561 | } |
| 2494 | 2562 | |
| 2495 | 2563 | return $edits; |
@@ -2690,10 +2758,11 @@ discard block |
||
| 2690 | 2758 | $context['board'] = $board; |
| 2691 | 2759 | |
| 2692 | 2760 | // Determine which groups this user is in. |
| 2693 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
| 2694 | - $curGroups = array(); |
|
| 2695 | - else |
|
| 2696 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2761 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
| 2762 | + $curGroups = array(); |
|
| 2763 | + } else { |
|
| 2764 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2765 | + } |
|
| 2697 | 2766 | $curGroups[] = $user_profile[$memID]['id_group']; |
| 2698 | 2767 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
| 2699 | 2768 | |
@@ -2713,28 +2782,30 @@ discard block |
||
| 2713 | 2782 | $context['no_access_boards'] = array(); |
| 2714 | 2783 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2715 | 2784 | { |
| 2716 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
| 2717 | - $context['no_access_boards'][] = array( |
|
| 2785 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
| 2786 | + $context['no_access_boards'][] = array( |
|
| 2718 | 2787 | 'id' => $row['id_board'], |
| 2719 | 2788 | 'name' => $row['name'], |
| 2720 | 2789 | 'is_last' => false, |
| 2721 | 2790 | ); |
| 2722 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
| 2723 | - $context['boards'][$row['id_board']] = array( |
|
| 2791 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
| 2792 | + $context['boards'][$row['id_board']] = array( |
|
| 2724 | 2793 | 'id' => $row['id_board'], |
| 2725 | 2794 | 'name' => $row['name'], |
| 2726 | 2795 | 'selected' => $board == $row['id_board'], |
| 2727 | 2796 | 'profile' => $row['id_profile'], |
| 2728 | 2797 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
| 2729 | 2798 | ); |
| 2799 | + } |
|
| 2730 | 2800 | } |
| 2731 | 2801 | $smcFunc['db_free_result']($request); |
| 2732 | 2802 | |
| 2733 | 2803 | require_once($sourcedir . '/Subs-Boards.php'); |
| 2734 | 2804 | sortBoards($context['boards']); |
| 2735 | 2805 | |
| 2736 | - if (!empty($context['no_access_boards'])) |
|
| 2737 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2806 | + if (!empty($context['no_access_boards'])) { |
|
| 2807 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2808 | + } |
|
| 2738 | 2809 | |
| 2739 | 2810 | $context['member']['permissions'] = array( |
| 2740 | 2811 | 'general' => array(), |
@@ -2743,8 +2814,9 @@ discard block |
||
| 2743 | 2814 | |
| 2744 | 2815 | // If you're an admin we know you can do everything, we might as well leave. |
| 2745 | 2816 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
| 2746 | - if ($context['member']['has_all_permissions']) |
|
| 2747 | - return; |
|
| 2817 | + if ($context['member']['has_all_permissions']) { |
|
| 2818 | + return; |
|
| 2819 | + } |
|
| 2748 | 2820 | |
| 2749 | 2821 | $denied = array(); |
| 2750 | 2822 | |
@@ -2763,21 +2835,24 @@ discard block |
||
| 2763 | 2835 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2764 | 2836 | { |
| 2765 | 2837 | // We don't know about this permission, it doesn't exist :P. |
| 2766 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2767 | - continue; |
|
| 2838 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2839 | + continue; |
|
| 2840 | + } |
|
| 2768 | 2841 | |
| 2769 | - if (empty($row['add_deny'])) |
|
| 2770 | - $denied[] = $row['permission']; |
|
| 2842 | + if (empty($row['add_deny'])) { |
|
| 2843 | + $denied[] = $row['permission']; |
|
| 2844 | + } |
|
| 2771 | 2845 | |
| 2772 | 2846 | // Permissions that end with _own or _any consist of two parts. |
| 2773 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2774 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2775 | - else |
|
| 2776 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2847 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2848 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2849 | + } else { |
|
| 2850 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2851 | + } |
|
| 2777 | 2852 | |
| 2778 | 2853 | // Add this permission if it doesn't exist yet. |
| 2779 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
| 2780 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2854 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
| 2855 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2781 | 2856 | 'id' => $row['permission'], |
| 2782 | 2857 | 'groups' => array( |
| 2783 | 2858 | 'allowed' => array(), |
@@ -2787,6 +2862,7 @@ discard block |
||
| 2787 | 2862 | 'is_denied' => false, |
| 2788 | 2863 | 'is_global' => true, |
| 2789 | 2864 | ); |
| 2865 | + } |
|
| 2790 | 2866 | |
| 2791 | 2867 | // Add the membergroup to either the denied or the allowed groups. |
| 2792 | 2868 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2820,18 +2896,20 @@ discard block |
||
| 2820 | 2896 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2821 | 2897 | { |
| 2822 | 2898 | // We don't know about this permission, it doesn't exist :P. |
| 2823 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2824 | - continue; |
|
| 2899 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2900 | + continue; |
|
| 2901 | + } |
|
| 2825 | 2902 | |
| 2826 | 2903 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
| 2827 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2828 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2829 | - else |
|
| 2830 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2904 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2905 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2906 | + } else { |
|
| 2907 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2908 | + } |
|
| 2831 | 2909 | |
| 2832 | 2910 | // Create the structure for this permission. |
| 2833 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
| 2834 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2911 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
| 2912 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2835 | 2913 | 'id' => $row['permission'], |
| 2836 | 2914 | 'groups' => array( |
| 2837 | 2915 | 'allowed' => array(), |
@@ -2841,6 +2919,7 @@ discard block |
||
| 2841 | 2919 | 'is_denied' => false, |
| 2842 | 2920 | 'is_global' => empty($board), |
| 2843 | 2921 | ); |
| 2922 | + } |
|
| 2844 | 2923 | |
| 2845 | 2924 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
| 2846 | 2925 | |
@@ -2859,8 +2938,9 @@ discard block |
||
| 2859 | 2938 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
| 2860 | 2939 | |
| 2861 | 2940 | // Firstly, can we actually even be here? |
| 2862 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
| 2863 | - fatal_lang_error('no_access', false); |
|
| 2941 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
| 2942 | + fatal_lang_error('no_access', false); |
|
| 2943 | + } |
|
| 2864 | 2944 | |
| 2865 | 2945 | // Make sure things which are disabled stay disabled. |
| 2866 | 2946 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2947,9 +3027,10 @@ discard block |
||
| 2947 | 3027 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
| 2948 | 3028 | ); |
| 2949 | 3029 | $context['current_level'] = 0; |
| 2950 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
| 2951 | - if ($context['member']['warning'] >= $limit) |
|
| 3030 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
| 3031 | + if ($context['member']['warning'] >= $limit) |
|
| 2952 | 3032 | $context['current_level'] = $limit; |
| 2953 | -} |
|
| 3033 | + } |
|
| 3034 | + } |
|
| 2954 | 3035 | |
| 2955 | 3036 | ?> |
| 2956 | 3037 | \ No newline at end of file |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | ) |
| 51 | 51 | ); |
| 52 | 52 | $members = array(); |
| 53 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 54 | - $members[$row['id_member']] = array( |
|
| 53 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 54 | + $members[$row['id_member']] = array( |
|
| 55 | 55 | 'id' => $row['id_member'], |
| 56 | 56 | 'real_name' => $row['real_name'], |
| 57 | 57 | 'email_address' => $row['email_address'], |
@@ -62,6 +62,7 @@ discard block |
||
| 62 | 62 | ), |
| 63 | 63 | 'lngfile' => $row['lngfile'], |
| 64 | 64 | ); |
| 65 | + } |
|
| 65 | 66 | $smcFunc['db_free_result']($request); |
| 66 | 67 | |
| 67 | 68 | return $members; |
@@ -83,13 +84,14 @@ discard block |
||
| 83 | 84 | |
| 84 | 85 | call_integration_hook('mention_insert_' . $content_type, array($content_id, &$members)); |
| 85 | 86 | |
| 86 | - foreach ($members as $member) |
|
| 87 | - $smcFunc['db_insert']('ignore', |
|
| 87 | + foreach ($members as $member) { |
|
| 88 | + $smcFunc['db_insert']('ignore', |
|
| 88 | 89 | '{db_prefix}mentions', |
| 89 | 90 | array('content_id' => 'int', 'content_type' => 'string', 'id_member' => 'int', 'id_mentioned' => 'int', 'time' => 'int'), |
| 90 | 91 | array((int) $content_id, $content_type, $id_member, $member['id'], time()), |
| 91 | 92 | array('content_id', 'content_type', 'id_mentioned') |
| 92 | 93 | ); |
| 94 | + } |
|
| 93 | 95 | } |
| 94 | 96 | |
| 95 | 97 | /** |
@@ -103,8 +105,9 @@ discard block |
||
| 103 | 105 | */ |
| 104 | 106 | public static function getBody($body, array $members) |
| 105 | 107 | { |
| 106 | - foreach ($members as $member) |
|
| 107 | - $body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body); |
|
| 108 | + foreach ($members as $member) { |
|
| 109 | + $body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body); |
|
| 110 | + } |
|
| 108 | 111 | |
| 109 | 112 | return $body; |
| 110 | 113 | } |
@@ -123,8 +126,9 @@ discard block |
||
| 123 | 126 | |
| 124 | 127 | $possible_names = self::getPossibleMentions($body); |
| 125 | 128 | |
| 126 | - if (empty($possible_names) || !allowedTo('mention')) |
|
| 127 | - return array(); |
|
| 129 | + if (empty($possible_names) || !allowedTo('mention')) { |
|
| 130 | + return array(); |
|
| 131 | + } |
|
| 128 | 132 | |
| 129 | 133 | $request = $smcFunc['db_query']('', ' |
| 130 | 134 | SELECT id_member, real_name |
@@ -140,8 +144,9 @@ discard block |
||
| 140 | 144 | $members = array(); |
| 141 | 145 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 142 | 146 | { |
| 143 | - if (stripos($body, static::$char . $row['real_name']) === false) |
|
| 144 | - continue; |
|
| 147 | + if (stripos($body, static::$char . $row['real_name']) === false) { |
|
| 148 | + continue; |
|
| 149 | + } |
|
| 145 | 150 | |
| 146 | 151 | $members[$row['id_member']] = array( |
| 147 | 152 | 'id' => $row['id_member'], |
@@ -185,8 +190,9 @@ discard block |
||
| 185 | 190 | $body = htmlspecialchars_decode(preg_replace('~<br\s*/?\>~', "\n", str_replace(' ', ' ', $body)), ENT_QUOTES); |
| 186 | 191 | |
| 187 | 192 | // Remove quotes, we don't want to get double mentions. |
| 188 | - while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) |
|
| 189 | - $body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body); |
|
| 193 | + while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) { |
|
| 194 | + $body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body); |
|
| 195 | + } |
|
| 190 | 196 | |
| 191 | 197 | $matches = array(); |
| 192 | 198 | $string = str_split($body); |
@@ -197,9 +203,9 @@ discard block |
||
| 197 | 203 | { |
| 198 | 204 | $depth++; |
| 199 | 205 | $matches[] = array(); |
| 206 | + } elseif ($char == "\n") { |
|
| 207 | + $depth = 0; |
|
| 200 | 208 | } |
| 201 | - elseif ($char == "\n") |
|
| 202 | - $depth = 0; |
|
| 203 | 209 | |
| 204 | 210 | for ($i = $depth; $i > 0; $i--) |
| 205 | 211 | { |
@@ -212,8 +218,9 @@ discard block |
||
| 212 | 218 | } |
| 213 | 219 | } |
| 214 | 220 | |
| 215 | - foreach ($matches as $k => $match) |
|
| 216 | - $matches[$k] = substr(implode('', $match), 1); |
|
| 221 | + foreach ($matches as $k => $match) { |
|
| 222 | + $matches[$k] = substr(implode('', $match), 1); |
|
| 223 | + } |
|
| 217 | 224 | |
| 218 | 225 | // Names can have spaces, other breaks, or they can't...we try to match every possible |
| 219 | 226 | // combination. |
@@ -222,8 +229,9 @@ discard block |
||
| 222 | 229 | { |
| 223 | 230 | $match = preg_split('/([^\w])/', $match, -1, PREG_SPLIT_DELIM_CAPTURE); |
| 224 | 231 | |
| 225 | - for ($i = 1; $i <= count($match); $i++) |
|
| 226 | - $names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i)))); |
|
| 232 | + for ($i = 1; $i <= count($match); $i++) { |
|
| 233 | + $names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i)))); |
|
| 234 | + } |
|
| 227 | 235 | } |
| 228 | 236 | |
| 229 | 237 | $names = array_unique($names); |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 3 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Begin the registration process. |
@@ -29,19 +30,23 @@ discard block |
||
| 29 | 30 | global $language, $scripturl, $smcFunc, $sourcedir, $cur_profile; |
| 30 | 31 | |
| 31 | 32 | // Is this an incoming AJAX check? |
| 32 | - if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') |
|
| 33 | - return RegisterCheckUsername(); |
|
| 33 | + if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') { |
|
| 34 | + return RegisterCheckUsername(); |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | // Check if the administrator has it disabled. |
| 36 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') |
|
| 37 | - fatal_lang_error('registration_disabled', false); |
|
| 38 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') { |
|
| 39 | + fatal_lang_error('registration_disabled', false); |
|
| 40 | + } |
|
| 38 | 41 | |
| 39 | 42 | // If this user is an admin - redirect them to the admin registration page. |
| 40 | - if (allowedTo('moderate_forum') && !$user_info['is_guest']) |
|
| 41 | - redirectexit('action=admin;area=regcenter;sa=register'); |
|
| 43 | + if (allowedTo('moderate_forum') && !$user_info['is_guest']) { |
|
| 44 | + redirectexit('action=admin;area=regcenter;sa=register'); |
|
| 45 | + } |
|
| 42 | 46 | // You are not a guest, so you are a member - and members don't get to register twice! |
| 43 | - elseif (empty($user_info['is_guest'])) |
|
| 44 | - redirectexit(); |
|
| 47 | + elseif (empty($user_info['is_guest'])) { |
|
| 48 | + redirectexit(); |
|
| 49 | + } |
|
| 45 | 50 | |
| 46 | 51 | loadLanguage('Login'); |
| 47 | 52 | loadTemplate('Register'); |
@@ -82,16 +87,18 @@ discard block |
||
| 82 | 87 | } |
| 83 | 88 | } |
| 84 | 89 | // Make sure they don't squeeze through without agreeing. |
| 85 | - elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) |
|
| 86 | - $current_step = 1; |
|
| 90 | + elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) { |
|
| 91 | + $current_step = 1; |
|
| 92 | + } |
|
| 87 | 93 | |
| 88 | 94 | // Show the user the right form. |
| 89 | 95 | $context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form'; |
| 90 | 96 | $context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form']; |
| 91 | 97 | |
| 92 | 98 | // Kinda need this. |
| 93 | - if ($context['sub_template'] == 'registration_form') |
|
| 94 | - loadJavaScriptFile('register.js', array('defer' => false), 'smf_register'); |
|
| 99 | + if ($context['sub_template'] == 'registration_form') { |
|
| 100 | + loadJavaScriptFile('register.js', array('defer' => false), 'smf_register'); |
|
| 101 | + } |
|
| 95 | 102 | |
| 96 | 103 | // Add the register chain to the link tree. |
| 97 | 104 | $context['linktree'][] = array( |
@@ -100,24 +107,26 @@ discard block |
||
| 100 | 107 | ); |
| 101 | 108 | |
| 102 | 109 | // Prepare the time gate! Do it like so, in case later steps want to reset the limit for any reason, but make sure the time is the current one. |
| 103 | - if (!isset($_SESSION['register'])) |
|
| 104 | - $_SESSION['register'] = array( |
|
| 110 | + if (!isset($_SESSION['register'])) { |
|
| 111 | + $_SESSION['register'] = array( |
|
| 105 | 112 | 'timenow' => time(), |
| 106 | 113 | 'limit' => 10, // minimum number of seconds required on this page for registration |
| 107 | 114 | ); |
| 108 | - else |
|
| 109 | - $_SESSION['register']['timenow'] = time(); |
|
| 115 | + } else { |
|
| 116 | + $_SESSION['register']['timenow'] = time(); |
|
| 117 | + } |
|
| 110 | 118 | |
| 111 | 119 | // If you have to agree to the agreement, it needs to be fetched from the file. |
| 112 | 120 | if ($context['require_agreement']) |
| 113 | 121 | { |
| 114 | 122 | // Have we got a localized one? |
| 115 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
| 116 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 117 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
| 118 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 119 | - else |
|
| 120 | - $context['agreement'] = ''; |
|
| 123 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
| 124 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 125 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
| 126 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 127 | + } else { |
|
| 128 | + $context['agreement'] = ''; |
|
| 129 | + } |
|
| 121 | 130 | |
| 122 | 131 | // Nothing to show, lets disable registration and inform the admin of this error |
| 123 | 132 | if (empty($context['agreement'])) |
@@ -133,8 +142,9 @@ discard block |
||
| 133 | 142 | $selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language']; |
| 134 | 143 | |
| 135 | 144 | // Do we have any languages? |
| 136 | - if (empty($context['languages'])) |
|
| 137 | - getLanguages(); |
|
| 145 | + if (empty($context['languages'])) { |
|
| 146 | + getLanguages(); |
|
| 147 | + } |
|
| 138 | 148 | |
| 139 | 149 | // Try to find our selected language. |
| 140 | 150 | foreach ($context['languages'] as $key => $lang) |
@@ -142,8 +152,9 @@ discard block |
||
| 142 | 152 | $context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => '')); |
| 143 | 153 | |
| 144 | 154 | // Found it! |
| 145 | - if ($selectedLanguage == $lang['filename']) |
|
| 146 | - $context['languages'][$key]['selected'] = true; |
|
| 155 | + if ($selectedLanguage == $lang['filename']) { |
|
| 156 | + $context['languages'][$key]['selected'] = true; |
|
| 157 | + } |
|
| 147 | 158 | } |
| 148 | 159 | } |
| 149 | 160 | |
@@ -167,9 +178,10 @@ discard block |
||
| 167 | 178 | $reg_fields = explode(',', $modSettings['registration_fields']); |
| 168 | 179 | |
| 169 | 180 | // We might have had some submissions on this front - go check. |
| 170 | - foreach ($reg_fields as $field) |
|
| 171 | - if (isset($_POST[$field])) |
|
| 181 | + foreach ($reg_fields as $field) { |
|
| 182 | + if (isset($_POST[$field])) |
|
| 172 | 183 | $cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]); |
| 184 | + } |
|
| 173 | 185 | |
| 174 | 186 | // Load all the fields in question. |
| 175 | 187 | setupProfileContext($reg_fields); |
@@ -186,8 +198,9 @@ discard block |
||
| 186 | 198 | $context['visual_verification_id'] = $verificationOptions['id']; |
| 187 | 199 | } |
| 188 | 200 | // Otherwise we have nothing to show. |
| 189 | - else |
|
| 190 | - $context['visual_verification'] = false; |
|
| 201 | + else { |
|
| 202 | + $context['visual_verification'] = false; |
|
| 203 | + } |
|
| 191 | 204 | |
| 192 | 205 | |
| 193 | 206 | $context += array( |
@@ -198,8 +211,9 @@ discard block |
||
| 198 | 211 | |
| 199 | 212 | // Were there any errors? |
| 200 | 213 | $context['registration_errors'] = array(); |
| 201 | - if (!empty($reg_errors)) |
|
| 202 | - $context['registration_errors'] = $reg_errors; |
|
| 214 | + if (!empty($reg_errors)) { |
|
| 215 | + $context['registration_errors'] = $reg_errors; |
|
| 216 | + } |
|
| 203 | 217 | |
| 204 | 218 | createToken('register'); |
| 205 | 219 | } |
@@ -216,27 +230,32 @@ discard block |
||
| 216 | 230 | validateToken('register'); |
| 217 | 231 | |
| 218 | 232 | // Check to ensure we're forcing SSL for authentication |
| 219 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 220 | - fatal_lang_error('register_ssl_required'); |
|
| 233 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 234 | + fatal_lang_error('register_ssl_required'); |
|
| 235 | + } |
|
| 221 | 236 | |
| 222 | 237 | // Start collecting together any errors. |
| 223 | 238 | $reg_errors = array(); |
| 224 | 239 | |
| 225 | 240 | // You can't register if it's disabled. |
| 226 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) |
|
| 227 | - fatal_lang_error('registration_disabled', false); |
|
| 241 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) { |
|
| 242 | + fatal_lang_error('registration_disabled', false); |
|
| 243 | + } |
|
| 228 | 244 | |
| 229 | 245 | // Well, if you don't agree, you can't register. |
| 230 | - if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) |
|
| 231 | - redirectexit(); |
|
| 246 | + if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) { |
|
| 247 | + redirectexit(); |
|
| 248 | + } |
|
| 232 | 249 | |
| 233 | 250 | // Make sure they came from *somewhere*, have a session. |
| 234 | - if (!isset($_SESSION['old_url'])) |
|
| 235 | - redirectexit('action=signup'); |
|
| 251 | + if (!isset($_SESSION['old_url'])) { |
|
| 252 | + redirectexit('action=signup'); |
|
| 253 | + } |
|
| 236 | 254 | |
| 237 | 255 | // If we don't require an agreement, we need a extra check for coppa. |
| 238 | - if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) |
|
| 239 | - $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
| 256 | + if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) { |
|
| 257 | + $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
| 258 | + } |
|
| 240 | 259 | // Are they under age, and under age users are banned? |
| 241 | 260 | if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) |
| 242 | 261 | { |
@@ -245,8 +264,9 @@ discard block |
||
| 245 | 264 | } |
| 246 | 265 | |
| 247 | 266 | // Check the time gate for miscreants. First make sure they came from somewhere that actually set it up. |
| 248 | - if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) |
|
| 249 | - redirectexit('action=signup'); |
|
| 267 | + if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) { |
|
| 268 | + redirectexit('action=signup'); |
|
| 269 | + } |
|
| 250 | 270 | // Failing that, check the time on it. |
| 251 | 271 | if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit']) |
| 252 | 272 | { |
@@ -266,15 +286,17 @@ discard block |
||
| 266 | 286 | if (is_array($context['visual_verification'])) |
| 267 | 287 | { |
| 268 | 288 | loadLanguage('Errors'); |
| 269 | - foreach ($context['visual_verification'] as $error) |
|
| 270 | - $reg_errors[] = $txt['error_' . $error]; |
|
| 289 | + foreach ($context['visual_verification'] as $error) { |
|
| 290 | + $reg_errors[] = $txt['error_' . $error]; |
|
| 291 | + } |
|
| 271 | 292 | } |
| 272 | 293 | } |
| 273 | 294 | |
| 274 | 295 | foreach ($_POST as $key => $value) |
| 275 | 296 | { |
| 276 | - if (!is_array($_POST[$key])) |
|
| 277 | - $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
| 297 | + if (!is_array($_POST[$key])) { |
|
| 298 | + $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
| 299 | + } |
|
| 278 | 300 | } |
| 279 | 301 | |
| 280 | 302 | // Collect all extra registration fields someone might have filled in. |
@@ -304,12 +326,14 @@ discard block |
||
| 304 | 326 | $reg_fields = explode(',', $modSettings['registration_fields']); |
| 305 | 327 | |
| 306 | 328 | // Website is a little different |
| 307 | - if (in_array('website', $reg_fields)) |
|
| 308 | - $possible_strings += array('website_url', 'website_title'); |
|
| 329 | + if (in_array('website', $reg_fields)) { |
|
| 330 | + $possible_strings += array('website_url', 'website_title'); |
|
| 331 | + } |
|
| 309 | 332 | } |
| 310 | 333 | |
| 311 | - if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') |
|
| 312 | - $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
| 334 | + if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') { |
|
| 335 | + $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
| 336 | + } |
|
| 313 | 337 | |
| 314 | 338 | // Needed for isReservedName() and registerMember(). |
| 315 | 339 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -318,32 +342,37 @@ discard block |
||
| 318 | 342 | if (isset($_POST['real_name']) && (allowedTo('profile_displayed_name') || allowedTo('moderate_forum'))) |
| 319 | 343 | { |
| 320 | 344 | $_POST['real_name'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name'])); |
| 321 | - if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) |
|
| 322 | - $possible_strings[] = 'real_name'; |
|
| 345 | + if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) { |
|
| 346 | + $possible_strings[] = 'real_name'; |
|
| 347 | + } |
|
| 323 | 348 | } |
| 324 | 349 | |
| 325 | 350 | // Handle a string as a birthdate... |
| 326 | - if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') |
|
| 327 | - $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
| 351 | + if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') { |
|
| 352 | + $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
| 353 | + } |
|
| 328 | 354 | // Or birthdate parts... |
| 329 | - elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) |
|
| 330 | - $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
| 355 | + elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) { |
|
| 356 | + $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
| 357 | + } |
|
| 331 | 358 | |
| 332 | 359 | // Validate the passed language file. |
| 333 | 360 | if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage'])) |
| 334 | 361 | { |
| 335 | 362 | // Do we have any languages? |
| 336 | - if (empty($context['languages'])) |
|
| 337 | - getLanguages(); |
|
| 363 | + if (empty($context['languages'])) { |
|
| 364 | + getLanguages(); |
|
| 365 | + } |
|
| 338 | 366 | |
| 339 | 367 | // Did we find it? |
| 340 | - if (isset($context['languages'][$_POST['lngfile']])) |
|
| 341 | - $_SESSION['language'] = $_POST['lngfile']; |
|
| 342 | - else |
|
| 368 | + if (isset($context['languages'][$_POST['lngfile']])) { |
|
| 369 | + $_SESSION['language'] = $_POST['lngfile']; |
|
| 370 | + } else { |
|
| 371 | + unset($_POST['lngfile']); |
|
| 372 | + } |
|
| 373 | + } else { |
|
| 343 | 374 | unset($_POST['lngfile']); |
| 344 | 375 | } |
| 345 | - else |
|
| 346 | - unset($_POST['lngfile']); |
|
| 347 | 376 | |
| 348 | 377 | // Set the options needed for registration. |
| 349 | 378 | $regOptions = array( |
@@ -363,22 +392,27 @@ discard block |
||
| 363 | 392 | ); |
| 364 | 393 | |
| 365 | 394 | // Include the additional options that might have been filled in. |
| 366 | - foreach ($possible_strings as $var) |
|
| 367 | - if (isset($_POST[$var])) |
|
| 395 | + foreach ($possible_strings as $var) { |
|
| 396 | + if (isset($_POST[$var])) |
|
| 368 | 397 | $regOptions['extra_register_vars'][$var] = $smcFunc['htmlspecialchars']($_POST[$var], ENT_QUOTES); |
| 369 | - foreach ($possible_ints as $var) |
|
| 370 | - if (isset($_POST[$var])) |
|
| 398 | + } |
|
| 399 | + foreach ($possible_ints as $var) { |
|
| 400 | + if (isset($_POST[$var])) |
|
| 371 | 401 | $regOptions['extra_register_vars'][$var] = (int) $_POST[$var]; |
| 372 | - foreach ($possible_floats as $var) |
|
| 373 | - if (isset($_POST[$var])) |
|
| 402 | + } |
|
| 403 | + foreach ($possible_floats as $var) { |
|
| 404 | + if (isset($_POST[$var])) |
|
| 374 | 405 | $regOptions['extra_register_vars'][$var] = (float) $_POST[$var]; |
| 375 | - foreach ($possible_bools as $var) |
|
| 376 | - if (isset($_POST[$var])) |
|
| 406 | + } |
|
| 407 | + foreach ($possible_bools as $var) { |
|
| 408 | + if (isset($_POST[$var])) |
|
| 377 | 409 | $regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1; |
| 410 | + } |
|
| 378 | 411 | |
| 379 | 412 | // Registration options are always default options... |
| 380 | - if (isset($_POST['default_options'])) |
|
| 381 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 413 | + if (isset($_POST['default_options'])) { |
|
| 414 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 415 | + } |
|
| 382 | 416 | $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array(); |
| 383 | 417 | |
| 384 | 418 | // Make sure they are clean, dammit! |
@@ -398,12 +432,14 @@ discard block |
||
| 398 | 432 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 399 | 433 | { |
| 400 | 434 | // Don't allow overriding of the theme variables. |
| 401 | - if (isset($regOptions['theme_vars'][$row['col_name']])) |
|
| 402 | - unset($regOptions['theme_vars'][$row['col_name']]); |
|
| 435 | + if (isset($regOptions['theme_vars'][$row['col_name']])) { |
|
| 436 | + unset($regOptions['theme_vars'][$row['col_name']]); |
|
| 437 | + } |
|
| 403 | 438 | |
| 404 | 439 | // Not actually showing it then? |
| 405 | - if (!$row['show_reg']) |
|
| 406 | - continue; |
|
| 440 | + if (!$row['show_reg']) { |
|
| 441 | + continue; |
|
| 442 | + } |
|
| 407 | 443 | |
| 408 | 444 | // Prepare the value! |
| 409 | 445 | $value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : ''; |
@@ -412,24 +448,27 @@ discard block |
||
| 412 | 448 | if (!in_array($row['field_type'], array('check', 'select', 'radio'))) |
| 413 | 449 | { |
| 414 | 450 | // Is it too long? |
| 415 | - if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) |
|
| 416 | - $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
| 451 | + if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) { |
|
| 452 | + $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
| 453 | + } |
|
| 417 | 454 | |
| 418 | 455 | // Any masks to apply? |
| 419 | 456 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
| 420 | 457 | { |
| 421 | - if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
| 422 | - $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
| 423 | - elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) |
|
| 424 | - $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
| 425 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 426 | - $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
| 458 | + if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) { |
|
| 459 | + $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
| 460 | + } elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) { |
|
| 461 | + $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
| 462 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) { |
|
| 463 | + $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
| 464 | + } |
|
| 427 | 465 | } |
| 428 | 466 | } |
| 429 | 467 | |
| 430 | 468 | // Is this required but not there? |
| 431 | - if (trim($value) == '' && $row['show_reg'] > 1) |
|
| 432 | - $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
| 469 | + if (trim($value) == '' && $row['show_reg'] > 1) { |
|
| 470 | + $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
| 471 | + } |
|
| 433 | 472 | } |
| 434 | 473 | $smcFunc['db_free_result']($request); |
| 435 | 474 | |
@@ -437,8 +476,9 @@ discard block |
||
| 437 | 476 | if (!empty($custom_field_errors)) |
| 438 | 477 | { |
| 439 | 478 | loadLanguage('Errors'); |
| 440 | - foreach ($custom_field_errors as $error) |
|
| 441 | - $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
| 479 | + foreach ($custom_field_errors as $error) { |
|
| 480 | + $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
| 481 | + } |
|
| 442 | 482 | } |
| 443 | 483 | |
| 444 | 484 | // Lets check for other errors before trying to register the member. |
@@ -483,8 +523,9 @@ discard block |
||
| 483 | 523 | } |
| 484 | 524 | |
| 485 | 525 | // If COPPA has been selected then things get complicated, setup the template. |
| 486 | - if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) |
|
| 487 | - redirectexit('action=coppa;member=' . $memberID); |
|
| 526 | + if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) { |
|
| 527 | + redirectexit('action=coppa;member=' . $memberID); |
|
| 528 | + } |
|
| 488 | 529 | // Basic template variable setup. |
| 489 | 530 | elseif (!empty($modSettings['registration_method'])) |
| 490 | 531 | { |
@@ -496,8 +537,7 @@ discard block |
||
| 496 | 537 | 'sub_template' => 'after', |
| 497 | 538 | 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration'] |
| 498 | 539 | ); |
| 499 | - } |
|
| 500 | - else |
|
| 540 | + } else |
|
| 501 | 541 | { |
| 502 | 542 | call_integration_hook('integrate_activate', array($regOptions['username'])); |
| 503 | 543 | |
@@ -517,16 +557,18 @@ discard block |
||
| 517 | 557 | global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $language, $user_info; |
| 518 | 558 | |
| 519 | 559 | // Logged in users should not bother to activate their accounts |
| 520 | - if (!empty($user_info['id'])) |
|
| 521 | - redirectexit(); |
|
| 560 | + if (!empty($user_info['id'])) { |
|
| 561 | + redirectexit(); |
|
| 562 | + } |
|
| 522 | 563 | |
| 523 | 564 | loadLanguage('Login'); |
| 524 | 565 | loadTemplate('Login'); |
| 525 | 566 | |
| 526 | 567 | if (empty($_REQUEST['u']) && empty($_POST['user'])) |
| 527 | 568 | { |
| 528 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') |
|
| 529 | - fatal_lang_error('no_access', false); |
|
| 569 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') { |
|
| 570 | + fatal_lang_error('no_access', false); |
|
| 571 | + } |
|
| 530 | 572 | |
| 531 | 573 | $context['member_id'] = 0; |
| 532 | 574 | $context['sub_template'] = 'resend'; |
@@ -566,11 +608,13 @@ discard block |
||
| 566 | 608 | // Change their email address? (they probably tried a fake one first :P.) |
| 567 | 609 | if (isset($_POST['new_email'], $_REQUEST['passwd']) && hash_password($row['member_name'], $_REQUEST['passwd']) == $row['passwd'] && ($row['is_activated'] == 0 || $row['is_activated'] == 2)) |
| 568 | 610 | { |
| 569 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) |
|
| 570 | - fatal_lang_error('no_access', false); |
|
| 611 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) { |
|
| 612 | + fatal_lang_error('no_access', false); |
|
| 613 | + } |
|
| 571 | 614 | |
| 572 | - if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) |
|
| 573 | - fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
| 615 | + if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) { |
|
| 616 | + fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
| 617 | + } |
|
| 574 | 618 | |
| 575 | 619 | // Make sure their email isn't banned. |
| 576 | 620 | isBannedEmail($_POST['new_email'], 'cannot_register', $txt['ban_register_prohibited']); |
@@ -586,8 +630,9 @@ discard block |
||
| 586 | 630 | ) |
| 587 | 631 | ); |
| 588 | 632 | |
| 589 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 590 | - fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
| 633 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 634 | + fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
| 635 | + } |
|
| 591 | 636 | $smcFunc['db_free_result']($request); |
| 592 | 637 | |
| 593 | 638 | updateMemberData($row['id_member'], array('email_address' => $_POST['new_email'])); |
@@ -625,9 +670,9 @@ discard block |
||
| 625 | 670 | // Quit if this code is not right. |
| 626 | 671 | if (empty($_REQUEST['code']) || $row['validation_code'] != $_REQUEST['code']) |
| 627 | 672 | { |
| 628 | - if (!empty($row['is_activated'])) |
|
| 629 | - fatal_lang_error('already_activated', false); |
|
| 630 | - elseif ($row['validation_code'] == '') |
|
| 673 | + if (!empty($row['is_activated'])) { |
|
| 674 | + fatal_lang_error('already_activated', false); |
|
| 675 | + } elseif ($row['validation_code'] == '') |
|
| 631 | 676 | { |
| 632 | 677 | loadLanguage('Profile'); |
| 633 | 678 | fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $row['member_name']), false); |
@@ -677,8 +722,9 @@ discard block |
||
| 677 | 722 | loadTemplate('Register'); |
| 678 | 723 | |
| 679 | 724 | // No User ID?? |
| 680 | - if (!isset($_GET['member'])) |
|
| 681 | - fatal_lang_error('no_access', false); |
|
| 725 | + if (!isset($_GET['member'])) { |
|
| 726 | + fatal_lang_error('no_access', false); |
|
| 727 | + } |
|
| 682 | 728 | |
| 683 | 729 | // Get the user details... |
| 684 | 730 | $request = $smcFunc['db_query']('', ' |
@@ -691,8 +737,9 @@ discard block |
||
| 691 | 737 | 'is_coppa' => 5, |
| 692 | 738 | ) |
| 693 | 739 | ); |
| 694 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 695 | - fatal_lang_error('no_access', false); |
|
| 740 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 741 | + fatal_lang_error('no_access', false); |
|
| 742 | + } |
|
| 696 | 743 | list ($username) = $smcFunc['db_fetch_row']($request); |
| 697 | 744 | $smcFunc['db_free_result']($request); |
| 698 | 745 | |
@@ -730,8 +777,7 @@ discard block |
||
| 730 | 777 | echo $data; |
| 731 | 778 | obExit(false); |
| 732 | 779 | } |
| 733 | - } |
|
| 734 | - else |
|
| 780 | + } else |
|
| 735 | 781 | { |
| 736 | 782 | $context += array( |
| 737 | 783 | 'page_title' => $txt['coppa_title'], |
@@ -784,8 +830,9 @@ discard block |
||
| 784 | 830 | { |
| 785 | 831 | require_once($sourcedir . '/Subs-Graphics.php'); |
| 786 | 832 | |
| 787 | - if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) |
|
| 788 | - header('HTTP/1.1 400 Bad Request'); |
|
| 833 | + if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) { |
|
| 834 | + header('HTTP/1.1 400 Bad Request'); |
|
| 835 | + } |
|
| 789 | 836 | |
| 790 | 837 | // Otherwise just show a pre-defined letter. |
| 791 | 838 | elseif (isset($_REQUEST['letter'])) |
@@ -803,14 +850,13 @@ discard block |
||
| 803 | 850 | header('Content-Type: image/gif'); |
| 804 | 851 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
| 805 | 852 | } |
| 806 | - } |
|
| 807 | - |
|
| 808 | - elseif ($_REQUEST['format'] === '.wav') |
|
| 853 | + } elseif ($_REQUEST['format'] === '.wav') |
|
| 809 | 854 | { |
| 810 | 855 | require_once($sourcedir . '/Subs-Sound.php'); |
| 811 | 856 | |
| 812 | - if (!createWaveFile($code)) |
|
| 813 | - header('HTTP/1.1 400 Bad Request'); |
|
| 857 | + if (!createWaveFile($code)) { |
|
| 858 | + header('HTTP/1.1 400 Bad Request'); |
|
| 859 | + } |
|
| 814 | 860 | } |
| 815 | 861 | |
| 816 | 862 | // We all die one day... |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,12 +46,14 @@ discard block |
||
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | // Not allowed sort method? Bang! Error! |
| 48 | - elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) |
|
| 49 | - trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 49 | + elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) { |
|
| 50 | + trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | // Get it from the cache and send it back. |
| 52 | - if (($temp = cache_get_data('membersOnlineStats-' . $membersOnlineOptions['sort'], 240)) !== null) |
|
| 53 | - return $temp; |
|
| 54 | + if (($temp = cache_get_data('membersOnlineStats-' . $membersOnlineOptions['sort'], 240)) !== null) { |
|
| 55 | + return $temp; |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Initialize the array that'll be returned later on. |
| 56 | 59 | $membersOnlineStats = array( |
@@ -67,8 +70,9 @@ discard block |
||
| 67 | 70 | // Get any spiders if enabled. |
| 68 | 71 | $spiders = array(); |
| 69 | 72 | $spider_finds = array(); |
| 70 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
| 71 | - $spiders = smf_json_decode($modSettings['spider_name_cache'], true); |
|
| 73 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
| 74 | + $spiders = smf_json_decode($modSettings['spider_name_cache'], true); |
|
| 75 | + } |
|
| 72 | 76 | |
| 73 | 77 | // Load the users online right now. |
| 74 | 78 | $request = $smcFunc['db_query']('', ' |
@@ -96,9 +100,7 @@ discard block |
||
| 96 | 100 | $membersOnlineStats['num_guests']++; |
| 97 | 101 | |
| 98 | 102 | continue; |
| 99 | - } |
|
| 100 | - |
|
| 101 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 103 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 102 | 104 | { |
| 103 | 105 | // Just increase the stats and don't add this hidden user to any list. |
| 104 | 106 | $membersOnlineStats['num_users_hidden']++; |
@@ -106,10 +108,11 @@ discard block |
||
| 106 | 108 | } |
| 107 | 109 | |
| 108 | 110 | // Some basic color coding... |
| 109 | - if (!empty($row['online_color'])) |
|
| 110 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 111 | - else |
|
| 112 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 111 | + if (!empty($row['online_color'])) { |
|
| 112 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 113 | + } else { |
|
| 114 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 115 | + } |
|
| 113 | 116 | |
| 114 | 117 | // Buddies get counted and highlighted. |
| 115 | 118 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -136,12 +139,13 @@ discard block |
||
| 136 | 139 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
| 137 | 140 | |
| 138 | 141 | // Store all distinct (primary) membergroups that are shown. |
| 139 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
| 140 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 142 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
| 143 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 141 | 144 | 'id' => $row['id_group'], |
| 142 | 145 | 'name' => $row['group_name'], |
| 143 | 146 | 'color' => $row['online_color'] |
| 144 | 147 | ); |
| 148 | + } |
|
| 145 | 149 | } |
| 146 | 150 | $smcFunc['db_free_result']($request); |
| 147 | 151 | |
@@ -204,11 +208,12 @@ discard block |
||
| 204 | 208 | $settingsToUpdate = array(); |
| 205 | 209 | |
| 206 | 210 | // More members on now than ever were? Update it! |
| 207 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
| 208 | - $settingsToUpdate = array( |
|
| 211 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
| 212 | + $settingsToUpdate = array( |
|
| 209 | 213 | 'mostOnline' => $total_users_online, |
| 210 | 214 | 'mostDate' => time() |
| 211 | 215 | ); |
| 216 | + } |
|
| 212 | 217 | |
| 213 | 218 | $date = strftime('%Y-%m-%d', forum_time(false)); |
| 214 | 219 | |
@@ -240,8 +245,9 @@ discard block |
||
| 240 | 245 | { |
| 241 | 246 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
| 242 | 247 | |
| 243 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
| 244 | - trackStats(array('most_on' => $total_users_online)); |
|
| 248 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
| 249 | + trackStats(array('most_on' => $total_users_online)); |
|
| 250 | + } |
|
| 245 | 251 | |
| 246 | 252 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
| 247 | 253 | } |
@@ -258,8 +264,9 @@ discard block |
||
| 258 | 264 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
| 259 | 265 | } |
| 260 | 266 | |
| 261 | - if (!empty($settingsToUpdate)) |
|
| 262 | - updateSettings($settingsToUpdate); |
|
| 263 | -} |
|
| 267 | + if (!empty($settingsToUpdate)) { |
|
| 268 | + updateSettings($settingsToUpdate); |
|
| 269 | + } |
|
| 270 | + } |
|
| 264 | 271 | |
| 265 | 272 | ?> |
| 266 | 273 | \ No newline at end of file |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | $context['valid_upload_dir'] = is_dir($context['attachmentUploadDir']) && is_writable($context['attachmentUploadDir']); |
| 105 | 105 | |
| 106 | 106 | if (!empty($modSettings['automanage_attachments'])) |
| 107 | - $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
| 107 | + $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
| 108 | 108 | |
| 109 | 109 | else |
| 110 | 110 | $context['valid_basedirectory'] = true; |
| 111 | 111 | |
| 112 | 112 | // A bit of razzle dazzle with the $txt strings. :) |
| 113 | 113 | $txt['attachment_path'] = $context['attachmentUploadDir']; |
| 114 | - $txt['basedirectory_for_attachments_path']= isset($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : ''; |
|
| 114 | + $txt['basedirectory_for_attachments_path'] = isset($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : ''; |
|
| 115 | 115 | $txt['use_subdirectories_for_attachments_note'] = empty($modSettings['attachment_basedirectories']) || empty($modSettings['use_subdirectories_for_attachments']) ? $txt['use_subdirectories_for_attachments_note'] : ''; |
| 116 | 116 | $txt['attachmentUploadDir_multiple_configure'] = '<a href="' . $scripturl . '?action=admin;area=manageattachments;sa=attachpaths">[' . $txt['attachmentUploadDir_multiple_configure'] . ']</a>'; |
| 117 | 117 | $txt['attach_current_dir'] = empty($modSettings['automanage_attachments']) ? $txt['attach_current_dir'] : $txt['attach_last_dir']; |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | array('select', 'automanage_attachments', array(0 => $txt['attachments_normal'], 1 => $txt['attachments_auto_space'], 2 => $txt['attachments_auto_years'], 3 => $txt['attachments_auto_months'], 4 => $txt['attachments_auto_16'])), |
| 137 | 137 | array('check', 'use_subdirectories_for_attachments', 'subtext' => $txt['use_subdirectories_for_attachments_note']), |
| 138 | 138 | (empty($modSettings['attachment_basedirectories']) ? array('text', 'basedirectory_for_attachments', 40,) : array('var_message', 'basedirectory_for_attachments', 'message' => 'basedirectory_for_attachments_path', 'invalid' => empty($context['valid_basedirectory']), 'text_label' => (!empty($context['valid_basedirectory']) ? $txt['basedirectory_for_attachments_current'] : $txt['basedirectory_for_attachments_warning']))), |
| 139 | - empty($modSettings['attachment_basedirectories']) && $modSettings['currentAttachmentUploadDir'] == 1 && count($modSettings['attachmentUploadDir']) == 1 ? array('json', 'attachmentUploadDir', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 40, 'invalid' => !$context['valid_upload_dir'], 'disabled' => true) : array('var_message', 'attach_current_directory', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 'message' => 'attachment_path', 'invalid' => empty($context['valid_upload_dir']), 'text_label' => (!empty($context['valid_upload_dir']) ? $txt['attach_current_dir'] : $txt['attach_current_dir_warning'])), |
|
| 139 | + empty($modSettings['attachment_basedirectories']) && $modSettings['currentAttachmentUploadDir'] == 1 && count($modSettings['attachmentUploadDir']) == 1 ? array('json', 'attachmentUploadDir', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 40, 'invalid' => !$context['valid_upload_dir'], 'disabled' => true) : array('var_message', 'attach_current_directory', 'subtext' => $txt['attachmentUploadDir_multiple_configure'], 'message' => 'attachment_path', 'invalid' => empty($context['valid_upload_dir']), 'text_label' => (!empty($context['valid_upload_dir']) ? $txt['attach_current_dir'] : $txt['attach_current_dir_warning'])), |
|
| 140 | 140 | array('int', 'attachmentDirFileLimit', 'subtext' => $txt['zero_for_no_limit'], 6), |
| 141 | 141 | array('int', 'attachmentDirSizeLimit', 'subtext' => $txt['zero_for_no_limit'], 6, 'postinput' => $txt['kilobyte']), |
| 142 | 142 | array('check', 'dont_show_attach_under_post', 'subtext' => $txt['dont_show_attach_under_post_sub']), |
@@ -349,16 +349,16 @@ discard block |
||
| 349 | 349 | |
| 350 | 350 | // These settings cannot be left empty! |
| 351 | 351 | if (empty($_POST['custom_avatar_dir'])) |
| 352 | - $_POST['custom_avatar_dir'] = $boarddir .'/custom_avatar'; |
|
| 352 | + $_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar'; |
|
| 353 | 353 | |
| 354 | 354 | if (empty($_POST['custom_avatar_url'])) |
| 355 | - $_POST['custom_avatar_url'] = $boardurl .'/custom_avatar'; |
|
| 355 | + $_POST['custom_avatar_url'] = $boardurl . '/custom_avatar'; |
|
| 356 | 356 | |
| 357 | 357 | if (empty($_POST['avatar_directory'])) |
| 358 | - $_POST['avatar_directory'] = $boarddir .'/avatars'; |
|
| 358 | + $_POST['avatar_directory'] = $boarddir . '/avatars'; |
|
| 359 | 359 | |
| 360 | 360 | if (empty($_POST['avatar_url'])) |
| 361 | - $_POST['avatar_url'] = $boardurl .'/avatars'; |
|
| 361 | + $_POST['avatar_url'] = $boardurl . '/avatars'; |
|
| 362 | 362 | |
| 363 | 363 | call_integration_hook('integrate_save_avatar_settings'); |
| 364 | 364 | |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | 'items_per_page' => $modSettings['defaultMaxListItems'], |
| 423 | 423 | 'base_href' => $scripturl . '?action=admin;area=manageattachments;sa=browse' . ($context['browse_type'] === 'avatars' ? ';avatars' : ($context['browse_type'] === 'thumbs' ? ';thumbs' : '')), |
| 424 | 424 | 'default_sort_col' => 'name', |
| 425 | - 'no_items_label' => $txt['attachment_manager_' . ($context['browse_type'] === 'avatars' ? 'avatars' : ( $context['browse_type'] === 'thumbs' ? 'thumbs' : 'attachments')) . '_no_entries'], |
|
| 425 | + 'no_items_label' => $txt['attachment_manager_' . ($context['browse_type'] === 'avatars' ? 'avatars' : ($context['browse_type'] === 'thumbs' ? 'thumbs' : 'attachments')) . '_no_entries'], |
|
| 426 | 426 | 'get_items' => array( |
| 427 | 427 | 'function' => 'list_getFiles', |
| 428 | 428 | 'params' => array( |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | 'value' => $txt['attachment_name'], |
| 442 | 442 | ), |
| 443 | 443 | 'data' => array( |
| 444 | - 'function' => function ($rowData) use ($modSettings, $context, $scripturl, $smcFunc) |
|
| 444 | + 'function' => function($rowData) use ($modSettings, $context, $scripturl, $smcFunc) |
|
| 445 | 445 | { |
| 446 | 446 | $link = '<a href="'; |
| 447 | 447 | |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | 'value' => $txt['attachment_file_size'], |
| 483 | 483 | ), |
| 484 | 484 | 'data' => array( |
| 485 | - 'function' => function ($rowData) use ($txt) |
|
| 485 | + 'function' => function($rowData) use ($txt) |
|
| 486 | 486 | { |
| 487 | 487 | return sprintf('%1$s%2$s', round($rowData['size'] / 1024, 2), $txt['kilobyte']); |
| 488 | 488 | }, |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | 'value' => $context['browse_type'] == 'avatars' ? $txt['attachment_manager_member'] : $txt['posted_by'], |
| 498 | 498 | ), |
| 499 | 499 | 'data' => array( |
| 500 | - 'function' => function ($rowData) use ($scripturl, $smcFunc) |
|
| 500 | + 'function' => function($rowData) use ($scripturl, $smcFunc) |
|
| 501 | 501 | { |
| 502 | 502 | // In case of an attachment, return the poster of the attachment. |
| 503 | 503 | if (empty($rowData['id_member'])) |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | 'value' => $context['browse_type'] == 'avatars' ? $txt['attachment_manager_last_active'] : $txt['date'], |
| 519 | 519 | ), |
| 520 | 520 | 'data' => array( |
| 521 | - 'function' => function ($rowData) use ($txt, $context, $scripturl) |
|
| 521 | + 'function' => function($rowData) use ($txt, $context, $scripturl) |
|
| 522 | 522 | { |
| 523 | 523 | // The date the message containing the attachment was posted or the owner of the avatar was active. |
| 524 | 524 | $date = empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']); |
@@ -1336,7 +1336,7 @@ discard block |
||
| 1336 | 1336 | if (!empty($modSettings['currentAttachmentUploadDir'])) |
| 1337 | 1337 | { |
| 1338 | 1338 | // Get the attachment name with out the folder. |
| 1339 | - $attachment_name = $row['id_attach'] . '_' . $row['file_hash'] .'.dat'; |
|
| 1339 | + $attachment_name = $row['id_attach'] . '_' . $row['file_hash'] . '.dat'; |
|
| 1340 | 1340 | |
| 1341 | 1341 | // Loop through the other folders. |
| 1342 | 1342 | foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
@@ -1952,7 +1952,7 @@ discard block |
||
| 1952 | 1952 | if (automanage_attachments_create_directory($path)) |
| 1953 | 1953 | $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
| 1954 | 1954 | else |
| 1955 | - $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
| 1955 | + $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | 1958 | // Changing a directory name? |
@@ -2074,7 +2074,7 @@ discard block |
||
| 2074 | 2074 | } |
| 2075 | 2075 | |
| 2076 | 2076 | // If the user wishes to go back, update the last_dir array |
| 2077 | - if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir']&& !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0]))) |
|
| 2077 | + if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir'] && !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0]))) |
|
| 2078 | 2078 | { |
| 2079 | 2079 | if (!is_array($modSettings['last_attachments_directory'])) |
| 2080 | 2080 | $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
@@ -2087,7 +2087,7 @@ discard block |
||
| 2087 | 2087 | $use_subdirectories_for_attachments = 0; |
| 2088 | 2088 | if (!empty($modSettings['attachment_basedirectories'])) |
| 2089 | 2089 | foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
| 2090 | - if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !==false) |
|
| 2090 | + if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !== false) |
|
| 2091 | 2091 | { |
| 2092 | 2092 | $use_subdirectories_for_attachments = 1; |
| 2093 | 2093 | break; |
@@ -2263,7 +2263,7 @@ discard block |
||
| 2263 | 2263 | 'class' => 'centercol', |
| 2264 | 2264 | ), |
| 2265 | 2265 | 'data' => array( |
| 2266 | - 'function' => function ($rowData) |
|
| 2266 | + 'function' => function($rowData) |
|
| 2267 | 2267 | { |
| 2268 | 2268 | return '<input type="radio" name="current_dir" value="' . $rowData['id'] . '"' . ($rowData['current'] ? ' checked' : '') . (!empty($rowData['disable_current']) ? ' disabled' : '') . ' class="input_radio">'; |
| 2269 | 2269 | }, |
@@ -2276,7 +2276,7 @@ discard block |
||
| 2276 | 2276 | 'value' => $txt['attach_path'], |
| 2277 | 2277 | ), |
| 2278 | 2278 | 'data' => array( |
| 2279 | - 'function' => function ($rowData) |
|
| 2279 | + 'function' => function($rowData) |
|
| 2280 | 2280 | { |
| 2281 | 2281 | return '<input type="hidden" name="dirs[' . $rowData['id'] . ']" value="' . $rowData['path'] . '"><input type="text" size="40" name="dirs[' . $rowData['id'] . ']" value="' . $rowData['path'] . '"' . (!empty($rowData['disable_base_dir']) ? ' disabled' : '') . ' class="input_text" style="width: 100%">'; |
| 2282 | 2282 | }, |
@@ -2356,7 +2356,7 @@ discard block |
||
| 2356 | 2356 | 'class' => 'centercol', |
| 2357 | 2357 | ), |
| 2358 | 2358 | 'data' => array( |
| 2359 | - 'function' => function ($rowData) |
|
| 2359 | + 'function' => function($rowData) |
|
| 2360 | 2360 | { |
| 2361 | 2361 | return '<input type="radio" name="current_base_dir" value="' . $rowData['id'] . '"' . ($rowData['current'] ? ' checked' : '') . ' class="input_radio">'; |
| 2362 | 2362 | }, |
@@ -2727,7 +2727,7 @@ discard block |
||
| 2727 | 2727 | $dir_size += !empty($row['size']) ? $row['size'] : filesize($source); |
| 2728 | 2728 | |
| 2729 | 2729 | // If we've reached a limit. Do something. |
| 2730 | - if (!empty($modSettings['attachmentDirSizeLimit']) && $dir_size > $modSettings['attachmentDirSizeLimit'] * 1024 || (!empty($modSettings['attachmentDirFileLimit']) && $dir_files > $modSettings['attachmentDirFileLimit'])) |
|
| 2730 | + if (!empty($modSettings['attachmentDirSizeLimit']) && $dir_size > $modSettings['attachmentDirSizeLimit'] * 1024 || (!empty($modSettings['attachmentDirFileLimit']) && $dir_files > $modSettings['attachmentDirFileLimit'])) |
|
| 2731 | 2731 | { |
| 2732 | 2732 | if (!empty($_POST['auto'])) |
| 2733 | 2733 | { |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * The main 'Attachments and Avatars' management function. |
@@ -63,10 +64,11 @@ discard block |
||
| 63 | 64 | call_integration_hook('integrate_manage_attachments', array(&$subActions)); |
| 64 | 65 | |
| 65 | 66 | // Pick the correct sub-action. |
| 66 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 67 | - $context['sub_action'] = $_REQUEST['sa']; |
|
| 68 | - else |
|
| 69 | - $context['sub_action'] = 'browse'; |
|
| 67 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 68 | + $context['sub_action'] = $_REQUEST['sa']; |
|
| 69 | + } else { |
|
| 70 | + $context['sub_action'] = 'browse'; |
|
| 71 | + } |
|
| 70 | 72 | |
| 71 | 73 | // Default page title is good. |
| 72 | 74 | $context['page_title'] = $txt['attachments_avatars']; |
@@ -94,20 +96,20 @@ discard block |
||
| 94 | 96 | $context['attachmentUploadDir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
| 95 | 97 | |
| 96 | 98 | // If not set, show a default path for the base directory |
| 97 | - if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) |
|
| 98 | - if (is_dir($modSettings['attachmentUploadDir'][1])) |
|
| 99 | + if (!isset($_GET['save']) && empty($modSettings['basedirectory_for_attachments'])) { |
|
| 100 | + if (is_dir($modSettings['attachmentUploadDir'][1])) |
|
| 99 | 101 | $modSettings['basedirectory_for_attachments'] = $modSettings['attachmentUploadDir'][1]; |
| 100 | - |
|
| 101 | - else |
|
| 102 | - $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
| 102 | + } else { |
|
| 103 | + $modSettings['basedirectory_for_attachments'] = $context['attachmentUploadDir']; |
|
| 104 | + } |
|
| 103 | 105 | |
| 104 | 106 | $context['valid_upload_dir'] = is_dir($context['attachmentUploadDir']) && is_writable($context['attachmentUploadDir']); |
| 105 | 107 | |
| 106 | - if (!empty($modSettings['automanage_attachments'])) |
|
| 107 | - $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
| 108 | - |
|
| 109 | - else |
|
| 110 | - $context['valid_basedirectory'] = true; |
|
| 108 | + if (!empty($modSettings['automanage_attachments'])) { |
|
| 109 | + $context['valid_basedirectory'] = !empty($modSettings['basedirectory_for_attachments']) && is_writable($modSettings['basedirectory_for_attachments']); |
|
| 110 | + } else { |
|
| 111 | + $context['valid_basedirectory'] = true; |
|
| 112 | + } |
|
| 111 | 113 | |
| 112 | 114 | // A bit of razzle dazzle with the $txt strings. :) |
| 113 | 115 | $txt['attachment_path'] = $context['attachmentUploadDir']; |
@@ -185,8 +187,9 @@ discard block |
||
| 185 | 187 | |
| 186 | 188 | call_integration_hook('integrate_modify_attachment_settings', array(&$config_vars)); |
| 187 | 189 | |
| 188 | - if ($return_config) |
|
| 189 | - return $config_vars; |
|
| 190 | + if ($return_config) { |
|
| 191 | + return $config_vars; |
|
| 192 | + } |
|
| 190 | 193 | |
| 191 | 194 | // These are very likely to come in handy! (i.e. without them we're doomed!) |
| 192 | 195 | require_once($sourcedir . '/ManagePermissions.php'); |
@@ -197,21 +200,24 @@ discard block |
||
| 197 | 200 | { |
| 198 | 201 | checkSession(); |
| 199 | 202 | |
| 200 | - if (isset($_POST['attachmentUploadDir'])) |
|
| 201 | - unset($_POST['attachmentUploadDir']); |
|
| 203 | + if (isset($_POST['attachmentUploadDir'])) { |
|
| 204 | + unset($_POST['attachmentUploadDir']); |
|
| 205 | + } |
|
| 202 | 206 | |
| 203 | 207 | if (!empty($_POST['use_subdirectories_for_attachments'])) |
| 204 | 208 | { |
| 205 | - if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) |
|
| 206 | - $_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
|
| 209 | + if (isset($_POST['use_subdirectories_for_attachments']) && empty($_POST['basedirectory_for_attachments'])) { |
|
| 210 | + $_POST['basedirectory_for_attachments'] = (!empty($modSettings['basedirectory_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir); |
|
| 211 | + } |
|
| 207 | 212 | |
| 208 | 213 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($modSettings['attachment_basedirectories'])) |
| 209 | 214 | { |
| 210 | - if (!is_array($modSettings['attachment_basedirectories'])) |
|
| 211 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
| 215 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
| 216 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
| 217 | + } |
|
| 218 | + } else { |
|
| 219 | + $modSettings['attachment_basedirectories'] = array(); |
|
| 212 | 220 | } |
| 213 | - else |
|
| 214 | - $modSettings['attachment_basedirectories'] = array(); |
|
| 215 | 221 | |
| 216 | 222 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($_POST['basedirectory_for_attachments']) && !in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
| 217 | 223 | { |
@@ -219,8 +225,9 @@ discard block |
||
| 219 | 225 | |
| 220 | 226 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachmentUploadDir'])) |
| 221 | 227 | { |
| 222 | - if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) |
|
| 223 | - $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
| 228 | + if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) { |
|
| 229 | + $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
| 230 | + } |
|
| 224 | 231 | } |
| 225 | 232 | |
| 226 | 233 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
@@ -336,8 +343,9 @@ discard block |
||
| 336 | 343 | |
| 337 | 344 | call_integration_hook('integrate_modify_avatar_settings', array(&$config_vars)); |
| 338 | 345 | |
| 339 | - if ($return_config) |
|
| 340 | - return $config_vars; |
|
| 346 | + if ($return_config) { |
|
| 347 | + return $config_vars; |
|
| 348 | + } |
|
| 341 | 349 | |
| 342 | 350 | // We need this file for the settings template. |
| 343 | 351 | require_once($sourcedir . '/ManageServer.php'); |
@@ -348,17 +356,21 @@ discard block |
||
| 348 | 356 | checkSession(); |
| 349 | 357 | |
| 350 | 358 | // These settings cannot be left empty! |
| 351 | - if (empty($_POST['custom_avatar_dir'])) |
|
| 352 | - $_POST['custom_avatar_dir'] = $boarddir .'/custom_avatar'; |
|
| 359 | + if (empty($_POST['custom_avatar_dir'])) { |
|
| 360 | + $_POST['custom_avatar_dir'] = $boarddir .'/custom_avatar'; |
|
| 361 | + } |
|
| 353 | 362 | |
| 354 | - if (empty($_POST['custom_avatar_url'])) |
|
| 355 | - $_POST['custom_avatar_url'] = $boardurl .'/custom_avatar'; |
|
| 363 | + if (empty($_POST['custom_avatar_url'])) { |
|
| 364 | + $_POST['custom_avatar_url'] = $boardurl .'/custom_avatar'; |
|
| 365 | + } |
|
| 356 | 366 | |
| 357 | - if (empty($_POST['avatar_directory'])) |
|
| 358 | - $_POST['avatar_directory'] = $boarddir .'/avatars'; |
|
| 367 | + if (empty($_POST['avatar_directory'])) { |
|
| 368 | + $_POST['avatar_directory'] = $boarddir .'/avatars'; |
|
| 369 | + } |
|
| 359 | 370 | |
| 360 | - if (empty($_POST['avatar_url'])) |
|
| 361 | - $_POST['avatar_url'] = $boardurl .'/avatars'; |
|
| 371 | + if (empty($_POST['avatar_url'])) { |
|
| 372 | + $_POST['avatar_url'] = $boardurl .'/avatars'; |
|
| 373 | + } |
|
| 362 | 374 | |
| 363 | 375 | call_integration_hook('integrate_save_avatar_settings'); |
| 364 | 376 | |
@@ -406,11 +418,13 @@ discard block |
||
| 406 | 418 | $list_title = $txt['attachment_manager_browse_files'] . ': '; |
| 407 | 419 | foreach ($titles as $browse_type => $details) |
| 408 | 420 | { |
| 409 | - if ($browse_type != 'attachments') |
|
| 410 | - $list_title .= ' | '; |
|
| 421 | + if ($browse_type != 'attachments') { |
|
| 422 | + $list_title .= ' | '; |
|
| 423 | + } |
|
| 411 | 424 | |
| 412 | - if ($context['browse_type'] == $browse_type) |
|
| 413 | - $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
| 425 | + if ($context['browse_type'] == $browse_type) { |
|
| 426 | + $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
| 427 | + } |
|
| 414 | 428 | |
| 415 | 429 | $list_title .= '<a href="' . $scripturl . $details[0] . '">' . $details[1] . '</a>'; |
| 416 | 430 | } |
@@ -446,28 +460,33 @@ discard block |
||
| 446 | 460 | $link = '<a href="'; |
| 447 | 461 | |
| 448 | 462 | // In case of a custom avatar URL attachments have a fixed directory. |
| 449 | - if ($rowData['attachment_type'] == 1) |
|
| 450 | - $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
| 463 | + if ($rowData['attachment_type'] == 1) { |
|
| 464 | + $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
| 465 | + } |
|
| 451 | 466 | |
| 452 | 467 | // By default avatars are downloaded almost as attachments. |
| 453 | - elseif ($context['browse_type'] == 'avatars') |
|
| 454 | - $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
| 468 | + elseif ($context['browse_type'] == 'avatars') { |
|
| 469 | + $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
| 470 | + } |
|
| 455 | 471 | |
| 456 | 472 | // Normal attachments are always linked to a topic ID. |
| 457 | - else |
|
| 458 | - $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
| 473 | + else { |
|
| 474 | + $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
| 475 | + } |
|
| 459 | 476 | |
| 460 | 477 | $link .= '"'; |
| 461 | 478 | |
| 462 | 479 | // Show a popup on click if it's a picture and we know its dimensions. |
| 463 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
| 464 | - $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
| 480 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
| 481 | + $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
| 482 | + } |
|
| 465 | 483 | |
| 466 | 484 | $link .= sprintf('>%1$s</a>', preg_replace('~&#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\\\1;', $smcFunc['htmlspecialchars']($rowData['filename']))); |
| 467 | 485 | |
| 468 | 486 | // Show the dimensions. |
| 469 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
| 470 | - $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
| 487 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
| 488 | + $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
| 489 | + } |
|
| 471 | 490 | |
| 472 | 491 | return $link; |
| 473 | 492 | }, |
@@ -500,12 +519,14 @@ discard block |
||
| 500 | 519 | 'function' => function ($rowData) use ($scripturl, $smcFunc) |
| 501 | 520 | { |
| 502 | 521 | // In case of an attachment, return the poster of the attachment. |
| 503 | - if (empty($rowData['id_member'])) |
|
| 504 | - return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
| 522 | + if (empty($rowData['id_member'])) { |
|
| 523 | + return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
| 524 | + } |
|
| 505 | 525 | |
| 506 | 526 | // Otherwise it must be an avatar, return the link to the owner of it. |
| 507 | - else |
|
| 508 | - return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
| 527 | + else { |
|
| 528 | + return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
| 529 | + } |
|
| 509 | 530 | }, |
| 510 | 531 | ), |
| 511 | 532 | 'sort' => array( |
@@ -524,8 +545,9 @@ discard block |
||
| 524 | 545 | $date = empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']); |
| 525 | 546 | |
| 526 | 547 | // Add a link to the topic in case of an attachment. |
| 527 | - if ($context['browse_type'] !== 'avatars') |
|
| 528 | - $date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
| 548 | + if ($context['browse_type'] !== 'avatars') { |
|
| 549 | + $date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
| 550 | + } |
|
| 529 | 551 | |
| 530 | 552 | return $date; |
| 531 | 553 | }, |
@@ -610,8 +632,8 @@ discard block |
||
| 610 | 632 | global $smcFunc, $txt; |
| 611 | 633 | |
| 612 | 634 | // Choose a query depending on what we are viewing. |
| 613 | - if ($browse_type === 'avatars') |
|
| 614 | - $request = $smcFunc['db_query']('', ' |
|
| 635 | + if ($browse_type === 'avatars') { |
|
| 636 | + $request = $smcFunc['db_query']('', ' |
|
| 615 | 637 | SELECT |
| 616 | 638 | {string:blank_text} AS id_msg, COALESCE(mem.real_name, {string:not_applicable_text}) AS poster_name, |
| 617 | 639 | mem.last_login AS poster_time, 0 AS id_topic, a.id_member, a.id_attach, a.filename, a.file_hash, a.attachment_type, |
@@ -630,8 +652,8 @@ discard block |
||
| 630 | 652 | 'per_page' => $items_per_page, |
| 631 | 653 | ) |
| 632 | 654 | ); |
| 633 | - else |
|
| 634 | - $request = $smcFunc['db_query']('', ' |
|
| 655 | + } else { |
|
| 656 | + $request = $smcFunc['db_query']('', ' |
|
| 635 | 657 | SELECT |
| 636 | 658 | m.id_msg, COALESCE(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_topic, m.id_member, |
| 637 | 659 | a.id_attach, a.filename, a.file_hash, a.attachment_type, a.size, a.width, a.height, a.downloads, mf.subject, t.id_board |
@@ -650,9 +672,11 @@ discard block |
||
| 650 | 672 | 'per_page' => $items_per_page, |
| 651 | 673 | ) |
| 652 | 674 | ); |
| 675 | + } |
|
| 653 | 676 | $files = array(); |
| 654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 655 | - $files[] = $row; |
|
| 677 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 678 | + $files[] = $row; |
|
| 679 | + } |
|
| 656 | 680 | $smcFunc['db_free_result']($request); |
| 657 | 681 | |
| 658 | 682 | return $files; |
@@ -670,8 +694,8 @@ discard block |
||
| 670 | 694 | global $smcFunc; |
| 671 | 695 | |
| 672 | 696 | // Depending on the type of file, different queries are used. |
| 673 | - if ($browse_type === 'avatars') |
|
| 674 | - $request = $smcFunc['db_query']('', ' |
|
| 697 | + if ($browse_type === 'avatars') { |
|
| 698 | + $request = $smcFunc['db_query']('', ' |
|
| 675 | 699 | SELECT COUNT(*) |
| 676 | 700 | FROM {db_prefix}attachments |
| 677 | 701 | WHERE id_member != {int:guest_id_member}', |
@@ -679,8 +703,8 @@ discard block |
||
| 679 | 703 | 'guest_id_member' => 0, |
| 680 | 704 | ) |
| 681 | 705 | ); |
| 682 | - else |
|
| 683 | - $request = $smcFunc['db_query']('', ' |
|
| 706 | + } else { |
|
| 707 | + $request = $smcFunc['db_query']('', ' |
|
| 684 | 708 | SELECT COUNT(*) AS num_attach |
| 685 | 709 | FROM {db_prefix}attachments AS a |
| 686 | 710 | INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) |
@@ -693,6 +717,7 @@ discard block |
||
| 693 | 717 | 'guest_id_member' => 0, |
| 694 | 718 | ) |
| 695 | 719 | ); |
| 720 | + } |
|
| 696 | 721 | |
| 697 | 722 | list ($num_files) = $smcFunc['db_fetch_row']($request); |
| 698 | 723 | $smcFunc['db_free_result']($request); |
@@ -775,12 +800,14 @@ discard block |
||
| 775 | 800 | $current_dir_size /= 1024; |
| 776 | 801 | |
| 777 | 802 | // If they specified a limit only.... |
| 778 | - if (!empty($modSettings['attachmentDirSizeLimit'])) |
|
| 779 | - $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
| 803 | + if (!empty($modSettings['attachmentDirSizeLimit'])) { |
|
| 804 | + $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
| 805 | + } |
|
| 780 | 806 | $context['attachment_current_size'] = comma_format($current_dir_size, 2); |
| 781 | 807 | |
| 782 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
| 783 | - $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
| 808 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
| 809 | + $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
| 810 | + } |
|
| 784 | 811 | $context['attachment_current_files'] = comma_format($current_dir_files, 0); |
| 785 | 812 | |
| 786 | 813 | $context['attach_multiple_dirs'] = count($attach_dirs) > 1 ? true : false; |
@@ -817,8 +844,8 @@ discard block |
||
| 817 | 844 | $messages = removeAttachments(array('attachment_type' => 0, 'poster_time' => (time() - 24 * 60 * 60 * $_POST['age'])), 'messages', true); |
| 818 | 845 | |
| 819 | 846 | // Update the messages to reflect the change. |
| 820 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
| 821 | - $smcFunc['db_query']('', ' |
|
| 847 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
| 848 | + $smcFunc['db_query']('', ' |
|
| 822 | 849 | UPDATE {db_prefix}messages |
| 823 | 850 | SET body = CONCAT(body, {string:notice}) |
| 824 | 851 | WHERE id_msg IN ({array_int:messages})', |
@@ -827,8 +854,8 @@ discard block |
||
| 827 | 854 | 'notice' => '<br><br>' . $_POST['notice'], |
| 828 | 855 | ) |
| 829 | 856 | ); |
| 830 | - } |
|
| 831 | - else |
|
| 857 | + } |
|
| 858 | + } else |
|
| 832 | 859 | { |
| 833 | 860 | // Remove all the old avatars. |
| 834 | 861 | removeAttachments(array('not_id_member' => 0, 'last_login' => (time() - 24 * 60 * 60 * $_POST['age'])), 'members'); |
@@ -853,8 +880,8 @@ discard block |
||
| 853 | 880 | $messages = removeAttachments(array('attachment_type' => 0, 'size' => 1024 * $_POST['size']), 'messages', true); |
| 854 | 881 | |
| 855 | 882 | // And make a note on the post. |
| 856 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
| 857 | - $smcFunc['db_query']('', ' |
|
| 883 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
| 884 | + $smcFunc['db_query']('', ' |
|
| 858 | 885 | UPDATE {db_prefix}messages |
| 859 | 886 | SET body = CONCAT(body, {string:notice}) |
| 860 | 887 | WHERE id_msg IN ({array_int:messages})', |
@@ -863,6 +890,7 @@ discard block |
||
| 863 | 890 | 'notice' => '<br><br>' . $_POST['notice'], |
| 864 | 891 | ) |
| 865 | 892 | ); |
| 893 | + } |
|
| 866 | 894 | |
| 867 | 895 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
| 868 | 896 | } |
@@ -882,16 +910,17 @@ discard block |
||
| 882 | 910 | { |
| 883 | 911 | $attachments = array(); |
| 884 | 912 | // There must be a quicker way to pass this safety test?? |
| 885 | - foreach ($_POST['remove'] as $removeID => $dummy) |
|
| 886 | - $attachments[] = (int) $removeID; |
|
| 913 | + foreach ($_POST['remove'] as $removeID => $dummy) { |
|
| 914 | + $attachments[] = (int) $removeID; |
|
| 915 | + } |
|
| 887 | 916 | |
| 888 | 917 | // If the attachments are from a 3rd party, let them remove it. Hooks should remove their ids from the array. |
| 889 | 918 | $filesRemoved = false; |
| 890 | 919 | call_integration_hook('integrate_attachment_remove', array(&$filesRemoved, $attachments)); |
| 891 | 920 | |
| 892 | - if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) |
|
| 893 | - removeAttachments(array('id_attach' => $attachments)); |
|
| 894 | - else if (!empty($attachments)) |
|
| 921 | + if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) { |
|
| 922 | + removeAttachments(array('id_attach' => $attachments)); |
|
| 923 | + } else if (!empty($attachments)) |
|
| 895 | 924 | { |
| 896 | 925 | $messages = removeAttachments(array('id_attach' => $attachments), 'messages', true); |
| 897 | 926 | |
@@ -930,12 +959,13 @@ discard block |
||
| 930 | 959 | |
| 931 | 960 | $messages = removeAttachments(array('attachment_type' => 0), '', true); |
| 932 | 961 | |
| 933 | - if (!isset($_POST['notice'])) |
|
| 934 | - $_POST['notice'] = $txt['attachment_delete_admin']; |
|
| 962 | + if (!isset($_POST['notice'])) { |
|
| 963 | + $_POST['notice'] = $txt['attachment_delete_admin']; |
|
| 964 | + } |
|
| 935 | 965 | |
| 936 | 966 | // Add the notice on the end of the changed messages. |
| 937 | - if (!empty($messages)) |
|
| 938 | - $smcFunc['db_query']('', ' |
|
| 967 | + if (!empty($messages)) { |
|
| 968 | + $smcFunc['db_query']('', ' |
|
| 939 | 969 | UPDATE {db_prefix}messages |
| 940 | 970 | SET body = CONCAT(body, {string:deleted_message}) |
| 941 | 971 | WHERE id_msg IN ({array_int:messages})', |
@@ -944,6 +974,7 @@ discard block |
||
| 944 | 974 | 'deleted_message' => '<br><br>' . $_POST['notice'], |
| 945 | 975 | ) |
| 946 | 976 | ); |
| 977 | + } |
|
| 947 | 978 | |
| 948 | 979 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
| 949 | 980 | } |
@@ -982,24 +1013,26 @@ discard block |
||
| 982 | 1013 | $is_not = substr($real_type, 0, 4) == 'not_'; |
| 983 | 1014 | $type = $is_not ? substr($real_type, 4) : $real_type; |
| 984 | 1015 | |
| 985 | - if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) |
|
| 986 | - $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 987 | - elseif ($type == 'attachment_type') |
|
| 988 | - $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
| 989 | - elseif ($type == 'poster_time') |
|
| 990 | - $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
| 991 | - elseif ($type == 'last_login') |
|
| 992 | - $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
| 993 | - elseif ($type == 'size') |
|
| 994 | - $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
| 995 | - elseif ($type == 'id_topic') |
|
| 996 | - $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 1016 | + if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) { |
|
| 1017 | + $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 1018 | + } elseif ($type == 'attachment_type') { |
|
| 1019 | + $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
| 1020 | + } elseif ($type == 'poster_time') { |
|
| 1021 | + $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
| 1022 | + } elseif ($type == 'last_login') { |
|
| 1023 | + $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
| 1024 | + } elseif ($type == 'size') { |
|
| 1025 | + $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
| 1026 | + } elseif ($type == 'id_topic') { |
|
| 1027 | + $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 1028 | + } |
|
| 997 | 1029 | |
| 998 | 1030 | // Add the parameter! |
| 999 | 1031 | $query_parameter[$real_type] = $restriction; |
| 1000 | 1032 | |
| 1001 | - if ($type == 'do_logging') |
|
| 1002 | - $do_logging = $condition['id_attach']; |
|
| 1033 | + if ($type == 'do_logging') { |
|
| 1034 | + $do_logging = $condition['id_attach']; |
|
| 1035 | + } |
|
| 1003 | 1036 | } |
| 1004 | 1037 | $condition = implode(' AND ', $new_condition); |
| 1005 | 1038 | } |
@@ -1031,15 +1064,15 @@ discard block |
||
| 1031 | 1064 | // wasn't it obvious? :P |
| 1032 | 1065 | // @todo look again at this. |
| 1033 | 1066 | @unlink($modSettings['custom_avatar_dir'] . '/' . $row['filename']); |
| 1034 | - } |
|
| 1035 | - else |
|
| 1067 | + } else |
|
| 1036 | 1068 | { |
| 1037 | 1069 | $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
| 1038 | 1070 | @unlink($filename); |
| 1039 | 1071 | |
| 1040 | 1072 | // If this was a thumb, the parent attachment should know about it. |
| 1041 | - if (!empty($row['id_parent'])) |
|
| 1042 | - $parents[] = $row['id_parent']; |
|
| 1073 | + if (!empty($row['id_parent'])) { |
|
| 1074 | + $parents[] = $row['id_parent']; |
|
| 1075 | + } |
|
| 1043 | 1076 | |
| 1044 | 1077 | // If this attachments has a thumb, remove it as well. |
| 1045 | 1078 | if (!empty($row['id_thumb']) && $autoThumbRemoval) |
@@ -1051,8 +1084,9 @@ discard block |
||
| 1051 | 1084 | } |
| 1052 | 1085 | |
| 1053 | 1086 | // Make a list. |
| 1054 | - if ($return_affected_messages && empty($row['attachment_type'])) |
|
| 1055 | - $msgs[] = $row['id_msg']; |
|
| 1087 | + if ($return_affected_messages && empty($row['attachment_type'])) { |
|
| 1088 | + $msgs[] = $row['id_msg']; |
|
| 1089 | + } |
|
| 1056 | 1090 | |
| 1057 | 1091 | $attach[] = $row['id_attach']; |
| 1058 | 1092 | } |
@@ -1060,8 +1094,8 @@ discard block |
||
| 1060 | 1094 | |
| 1061 | 1095 | // Removed attachments don't have to be updated anymore. |
| 1062 | 1096 | $parents = array_diff($parents, $attach); |
| 1063 | - if (!empty($parents)) |
|
| 1064 | - $smcFunc['db_query']('', ' |
|
| 1097 | + if (!empty($parents)) { |
|
| 1098 | + $smcFunc['db_query']('', ' |
|
| 1065 | 1099 | UPDATE {db_prefix}attachments |
| 1066 | 1100 | SET id_thumb = {int:no_thumb} |
| 1067 | 1101 | WHERE id_attach IN ({array_int:parent_attachments})', |
@@ -1070,6 +1104,7 @@ discard block |
||
| 1070 | 1104 | 'no_thumb' => 0, |
| 1071 | 1105 | ) |
| 1072 | 1106 | ); |
| 1107 | + } |
|
| 1073 | 1108 | |
| 1074 | 1109 | if (!empty($do_logging)) |
| 1075 | 1110 | { |
@@ -1086,31 +1121,34 @@ discard block |
||
| 1086 | 1121 | ) |
| 1087 | 1122 | ); |
| 1088 | 1123 | |
| 1089 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1090 | - logAction( |
|
| 1124 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1125 | + logAction( |
|
| 1091 | 1126 | 'remove_attach', |
| 1092 | 1127 | array( |
| 1093 | 1128 | 'message' => $row['id_msg'], |
| 1094 | 1129 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
| 1095 | 1130 | ) |
| 1096 | 1131 | ); |
| 1132 | + } |
|
| 1097 | 1133 | $smcFunc['db_free_result']($request); |
| 1098 | 1134 | } |
| 1099 | 1135 | |
| 1100 | - if (!empty($attach)) |
|
| 1101 | - $smcFunc['db_query']('', ' |
|
| 1136 | + if (!empty($attach)) { |
|
| 1137 | + $smcFunc['db_query']('', ' |
|
| 1102 | 1138 | DELETE FROM {db_prefix}attachments |
| 1103 | 1139 | WHERE id_attach IN ({array_int:attachment_list})', |
| 1104 | 1140 | array( |
| 1105 | 1141 | 'attachment_list' => $attach, |
| 1106 | 1142 | ) |
| 1107 | 1143 | ); |
| 1144 | + } |
|
| 1108 | 1145 | |
| 1109 | 1146 | call_integration_hook('integrate_remove_attachments', array($attach)); |
| 1110 | 1147 | |
| 1111 | - if ($return_affected_messages) |
|
| 1112 | - return array_unique($msgs); |
|
| 1113 | -} |
|
| 1148 | + if ($return_affected_messages) { |
|
| 1149 | + return array_unique($msgs); |
|
| 1150 | + } |
|
| 1151 | + } |
|
| 1114 | 1152 | |
| 1115 | 1153 | /** |
| 1116 | 1154 | * This function should find attachments in the database that no longer exist and clear them, and fix filesize issues. |
@@ -1122,8 +1160,9 @@ discard block |
||
| 1122 | 1160 | checkSession('get'); |
| 1123 | 1161 | |
| 1124 | 1162 | // If we choose cancel, redirect right back. |
| 1125 | - if (isset($_POST['cancel'])) |
|
| 1126 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1163 | + if (isset($_POST['cancel'])) { |
|
| 1164 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1165 | + } |
|
| 1127 | 1166 | |
| 1128 | 1167 | // Try give us a while to sort this out... |
| 1129 | 1168 | @set_time_limit(600); |
@@ -1140,13 +1179,15 @@ discard block |
||
| 1140 | 1179 | if (isset($_GET['fixErrors'])) |
| 1141 | 1180 | { |
| 1142 | 1181 | // Nothing? |
| 1143 | - if (empty($_POST['to_fix'])) |
|
| 1144 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1182 | + if (empty($_POST['to_fix'])) { |
|
| 1183 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1184 | + } |
|
| 1145 | 1185 | |
| 1146 | 1186 | $_SESSION['attachments_to_fix'] = array(); |
| 1147 | 1187 | // @todo No need to do this I think. |
| 1148 | - foreach ($_POST['to_fix'] as $value) |
|
| 1149 | - $_SESSION['attachments_to_fix'][] = $value; |
|
| 1188 | + foreach ($_POST['to_fix'] as $value) { |
|
| 1189 | + $_SESSION['attachments_to_fix'][] = $value; |
|
| 1190 | + } |
|
| 1150 | 1191 | } |
| 1151 | 1192 | } |
| 1152 | 1193 | |
@@ -1213,13 +1254,14 @@ discard block |
||
| 1213 | 1254 | } |
| 1214 | 1255 | } |
| 1215 | 1256 | } |
| 1216 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1217 | - $to_fix[] = 'missing_thumbnail_parent'; |
|
| 1257 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1258 | + $to_fix[] = 'missing_thumbnail_parent'; |
|
| 1259 | + } |
|
| 1218 | 1260 | $smcFunc['db_free_result']($result); |
| 1219 | 1261 | |
| 1220 | 1262 | // Do we need to delete what we have? |
| 1221 | - if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) |
|
| 1222 | - $smcFunc['db_query']('', ' |
|
| 1263 | + if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) { |
|
| 1264 | + $smcFunc['db_query']('', ' |
|
| 1223 | 1265 | DELETE FROM {db_prefix}attachments |
| 1224 | 1266 | WHERE id_attach IN ({array_int:to_remove}) |
| 1225 | 1267 | AND attachment_type = {int:attachment_type}', |
@@ -1228,6 +1270,7 @@ discard block |
||
| 1228 | 1270 | 'attachment_type' => 3, |
| 1229 | 1271 | ) |
| 1230 | 1272 | ); |
| 1273 | + } |
|
| 1231 | 1274 | |
| 1232 | 1275 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1233 | 1276 | } |
@@ -1272,13 +1315,14 @@ discard block |
||
| 1272 | 1315 | $to_update[] = $row['id_attach']; |
| 1273 | 1316 | $context['repair_errors']['parent_missing_thumbnail']++; |
| 1274 | 1317 | } |
| 1275 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1276 | - $to_fix[] = 'parent_missing_thumbnail'; |
|
| 1318 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1319 | + $to_fix[] = 'parent_missing_thumbnail'; |
|
| 1320 | + } |
|
| 1277 | 1321 | $smcFunc['db_free_result']($result); |
| 1278 | 1322 | |
| 1279 | 1323 | // Do we need to delete what we have? |
| 1280 | - if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) |
|
| 1281 | - $smcFunc['db_query']('', ' |
|
| 1324 | + if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) { |
|
| 1325 | + $smcFunc['db_query']('', ' |
|
| 1282 | 1326 | UPDATE {db_prefix}attachments |
| 1283 | 1327 | SET id_thumb = {int:no_thumb} |
| 1284 | 1328 | WHERE id_attach IN ({array_int:to_update})', |
@@ -1287,6 +1331,7 @@ discard block |
||
| 1287 | 1331 | 'no_thumb' => 0, |
| 1288 | 1332 | ) |
| 1289 | 1333 | ); |
| 1334 | + } |
|
| 1290 | 1335 | |
| 1291 | 1336 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1292 | 1337 | } |
@@ -1324,10 +1369,11 @@ discard block |
||
| 1324 | 1369 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1325 | 1370 | { |
| 1326 | 1371 | // Get the filename. |
| 1327 | - if ($row['attachment_type'] == 1) |
|
| 1328 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1329 | - else |
|
| 1330 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1372 | + if ($row['attachment_type'] == 1) { |
|
| 1373 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1374 | + } else { |
|
| 1375 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1376 | + } |
|
| 1331 | 1377 | |
| 1332 | 1378 | // File doesn't exist? |
| 1333 | 1379 | if (!file_exists($filename)) |
@@ -1339,15 +1385,16 @@ discard block |
||
| 1339 | 1385 | $attachment_name = $row['id_attach'] . '_' . $row['file_hash'] .'.dat'; |
| 1340 | 1386 | |
| 1341 | 1387 | // Loop through the other folders. |
| 1342 | - foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
|
| 1343 | - if (file_exists($dir . '/' . $attachment_name)) |
|
| 1388 | + foreach ($modSettings['attachmentUploadDir'] as $id => $dir) { |
|
| 1389 | + if (file_exists($dir . '/' . $attachment_name)) |
|
| 1344 | 1390 | { |
| 1345 | 1391 | $context['repair_errors']['wrong_folder']++; |
| 1392 | + } |
|
| 1346 | 1393 | $errors_found[] = 'wrong_folder'; |
| 1347 | 1394 | |
| 1348 | 1395 | // Are we going to fix this now? |
| 1349 | - if ($fix_errors && in_array('wrong_folder', $to_fix)) |
|
| 1350 | - $smcFunc['db_query']('', ' |
|
| 1396 | + if ($fix_errors && in_array('wrong_folder', $to_fix)) { |
|
| 1397 | + $smcFunc['db_query']('', ' |
|
| 1351 | 1398 | UPDATE {db_prefix}attachments |
| 1352 | 1399 | SET id_folder = {int:new_folder} |
| 1353 | 1400 | WHERE id_attach = {int:id_attach}', |
@@ -1356,6 +1403,7 @@ discard block |
||
| 1356 | 1403 | 'id_attach' => $row['id_attach'], |
| 1357 | 1404 | ) |
| 1358 | 1405 | ); |
| 1406 | + } |
|
| 1359 | 1407 | |
| 1360 | 1408 | continue 2; |
| 1361 | 1409 | } |
@@ -1364,8 +1412,7 @@ discard block |
||
| 1364 | 1412 | $to_remove[] = $row['id_attach']; |
| 1365 | 1413 | $context['repair_errors']['file_missing_on_disk']++; |
| 1366 | 1414 | $errors_found[] = 'file_missing_on_disk'; |
| 1367 | - } |
|
| 1368 | - elseif (filesize($filename) == 0) |
|
| 1415 | + } elseif (filesize($filename) == 0) |
|
| 1369 | 1416 | { |
| 1370 | 1417 | $context['repair_errors']['file_size_of_zero']++; |
| 1371 | 1418 | $errors_found[] = 'file_size_of_zero'; |
@@ -1376,8 +1423,7 @@ discard block |
||
| 1376 | 1423 | $to_remove[] = $row['id_attach']; |
| 1377 | 1424 | @unlink($filename); |
| 1378 | 1425 | } |
| 1379 | - } |
|
| 1380 | - elseif (filesize($filename) != $row['size']) |
|
| 1426 | + } elseif (filesize($filename) != $row['size']) |
|
| 1381 | 1427 | { |
| 1382 | 1428 | $context['repair_errors']['file_wrong_size']++; |
| 1383 | 1429 | $errors_found[] = 'file_wrong_size'; |
@@ -1398,14 +1444,18 @@ discard block |
||
| 1398 | 1444 | } |
| 1399 | 1445 | } |
| 1400 | 1446 | |
| 1401 | - if (in_array('file_missing_on_disk', $errors_found)) |
|
| 1402 | - $to_fix[] = 'file_missing_on_disk'; |
|
| 1403 | - if (in_array('file_size_of_zero', $errors_found)) |
|
| 1404 | - $to_fix[] = 'file_size_of_zero'; |
|
| 1405 | - if (in_array('file_wrong_size', $errors_found)) |
|
| 1406 | - $to_fix[] = 'file_wrong_size'; |
|
| 1407 | - if (in_array('wrong_folder', $errors_found)) |
|
| 1408 | - $to_fix[] = 'wrong_folder'; |
|
| 1447 | + if (in_array('file_missing_on_disk', $errors_found)) { |
|
| 1448 | + $to_fix[] = 'file_missing_on_disk'; |
|
| 1449 | + } |
|
| 1450 | + if (in_array('file_size_of_zero', $errors_found)) { |
|
| 1451 | + $to_fix[] = 'file_size_of_zero'; |
|
| 1452 | + } |
|
| 1453 | + if (in_array('file_wrong_size', $errors_found)) { |
|
| 1454 | + $to_fix[] = 'file_wrong_size'; |
|
| 1455 | + } |
|
| 1456 | + if (in_array('wrong_folder', $errors_found)) { |
|
| 1457 | + $to_fix[] = 'wrong_folder'; |
|
| 1458 | + } |
|
| 1409 | 1459 | $smcFunc['db_free_result']($result); |
| 1410 | 1460 | |
| 1411 | 1461 | // Do we need to delete what we have? |
@@ -1475,20 +1525,22 @@ discard block |
||
| 1475 | 1525 | // If we are repairing remove the file from disk now. |
| 1476 | 1526 | if ($fix_errors && in_array('avatar_no_member', $to_fix)) |
| 1477 | 1527 | { |
| 1478 | - if ($row['attachment_type'] == 1) |
|
| 1479 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1480 | - else |
|
| 1481 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1528 | + if ($row['attachment_type'] == 1) { |
|
| 1529 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1530 | + } else { |
|
| 1531 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1532 | + } |
|
| 1482 | 1533 | @unlink($filename); |
| 1483 | 1534 | } |
| 1484 | 1535 | } |
| 1485 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1486 | - $to_fix[] = 'avatar_no_member'; |
|
| 1536 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1537 | + $to_fix[] = 'avatar_no_member'; |
|
| 1538 | + } |
|
| 1487 | 1539 | $smcFunc['db_free_result']($result); |
| 1488 | 1540 | |
| 1489 | 1541 | // Do we need to delete what we have? |
| 1490 | - if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) |
|
| 1491 | - $smcFunc['db_query']('', ' |
|
| 1542 | + if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) { |
|
| 1543 | + $smcFunc['db_query']('', ' |
|
| 1492 | 1544 | DELETE FROM {db_prefix}attachments |
| 1493 | 1545 | WHERE id_attach IN ({array_int:to_remove}) |
| 1494 | 1546 | AND id_member != {int:no_member} |
@@ -1499,6 +1551,7 @@ discard block |
||
| 1499 | 1551 | 'no_msg' => 0, |
| 1500 | 1552 | ) |
| 1501 | 1553 | ); |
| 1554 | + } |
|
| 1502 | 1555 | |
| 1503 | 1556 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1504 | 1557 | } |
@@ -1554,13 +1607,14 @@ discard block |
||
| 1554 | 1607 | @unlink($filename); |
| 1555 | 1608 | } |
| 1556 | 1609 | } |
| 1557 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1558 | - $to_fix[] = 'attachment_no_msg'; |
|
| 1610 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1611 | + $to_fix[] = 'attachment_no_msg'; |
|
| 1612 | + } |
|
| 1559 | 1613 | $smcFunc['db_free_result']($result); |
| 1560 | 1614 | |
| 1561 | 1615 | // Do we need to delete what we have? |
| 1562 | - if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) |
|
| 1563 | - $smcFunc['db_query']('', ' |
|
| 1616 | + if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) { |
|
| 1617 | + $smcFunc['db_query']('', ' |
|
| 1564 | 1618 | DELETE FROM {db_prefix}attachments |
| 1565 | 1619 | WHERE id_attach IN ({array_int:to_remove}) |
| 1566 | 1620 | AND id_member = {int:no_member} |
@@ -1571,6 +1625,7 @@ discard block |
||
| 1571 | 1625 | 'no_msg' => 0, |
| 1572 | 1626 | ) |
| 1573 | 1627 | ); |
| 1628 | + } |
|
| 1574 | 1629 | |
| 1575 | 1630 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1576 | 1631 | } |
@@ -1594,8 +1649,9 @@ discard block |
||
| 1594 | 1649 | { |
| 1595 | 1650 | while ($file = readdir($dir)) |
| 1596 | 1651 | { |
| 1597 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
| 1598 | - continue; |
|
| 1652 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
| 1653 | + continue; |
|
| 1654 | + } |
|
| 1599 | 1655 | |
| 1600 | 1656 | if ($files_checked <= $current_check) |
| 1601 | 1657 | { |
@@ -1603,8 +1659,9 @@ discard block |
||
| 1603 | 1659 | if (strpos($file, 'post_tmp_') !== false) |
| 1604 | 1660 | { |
| 1605 | 1661 | // Temp file is more than 5 hours old! |
| 1606 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
| 1607 | - @unlink($attach_dir . '/' . $file); |
|
| 1662 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
| 1663 | + @unlink($attach_dir . '/' . $file); |
|
| 1664 | + } |
|
| 1608 | 1665 | } |
| 1609 | 1666 | // That should be an attachment, let's check if we have it in the database |
| 1610 | 1667 | elseif (strpos($file, '_') !== false) |
@@ -1626,8 +1683,7 @@ discard block |
||
| 1626 | 1683 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
| 1627 | 1684 | { |
| 1628 | 1685 | @unlink($attach_dir . '/' . $file); |
| 1629 | - } |
|
| 1630 | - else |
|
| 1686 | + } else |
|
| 1631 | 1687 | { |
| 1632 | 1688 | $context['repair_errors']['files_without_attachment']++; |
| 1633 | 1689 | $to_fix[] = 'files_without_attachment'; |
@@ -1635,14 +1691,12 @@ discard block |
||
| 1635 | 1691 | } |
| 1636 | 1692 | $smcFunc['db_free_result']($request); |
| 1637 | 1693 | } |
| 1638 | - } |
|
| 1639 | - else |
|
| 1694 | + } else |
|
| 1640 | 1695 | { |
| 1641 | 1696 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
| 1642 | 1697 | { |
| 1643 | 1698 | @unlink($attach_dir . '/' . $file); |
| 1644 | - } |
|
| 1645 | - else |
|
| 1699 | + } else |
|
| 1646 | 1700 | { |
| 1647 | 1701 | $context['repair_errors']['files_without_attachment']++; |
| 1648 | 1702 | $to_fix[] = 'files_without_attachment'; |
@@ -1651,8 +1705,9 @@ discard block |
||
| 1651 | 1705 | } |
| 1652 | 1706 | $current_check++; |
| 1653 | 1707 | $_GET['substep'] = $current_check; |
| 1654 | - if ($current_check - $files_checked >= $max_checks) |
|
| 1655 | - pauseAttachmentMaintenance($to_fix); |
|
| 1708 | + if ($current_check - $files_checked >= $max_checks) { |
|
| 1709 | + pauseAttachmentMaintenance($to_fix); |
|
| 1710 | + } |
|
| 1656 | 1711 | } |
| 1657 | 1712 | closedir($dir); |
| 1658 | 1713 | } |
@@ -1688,12 +1743,14 @@ discard block |
||
| 1688 | 1743 | |
| 1689 | 1744 | // Try get more time... |
| 1690 | 1745 | @set_time_limit(600); |
| 1691 | - if (function_exists('apache_reset_timeout')) |
|
| 1692 | - @apache_reset_timeout(); |
|
| 1746 | + if (function_exists('apache_reset_timeout')) { |
|
| 1747 | + @apache_reset_timeout(); |
|
| 1748 | + } |
|
| 1693 | 1749 | |
| 1694 | 1750 | // Have we already used our maximum time? |
| 1695 | - if (time() - array_sum(explode(' ', $time_start)) < 3 || $context['starting_substep'] == $_GET['substep']) |
|
| 1696 | - return; |
|
| 1751 | + if (time() - array_sum(explode(' ', $time_start)) < 3 || $context['starting_substep'] == $_GET['substep']) { |
|
| 1752 | + return; |
|
| 1753 | + } |
|
| 1697 | 1754 | |
| 1698 | 1755 | $context['continue_get_data'] = '?action=admin;area=manageattachments;sa=repair' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1699 | 1756 | $context['page_title'] = $txt['not_done_title']; |
@@ -1705,10 +1762,11 @@ discard block |
||
| 1705 | 1762 | $context[$context['admin_menu_name']]['current_subsection'] = 'maintenance'; |
| 1706 | 1763 | |
| 1707 | 1764 | // Change these two if more steps are added! |
| 1708 | - if (empty($max_substep)) |
|
| 1709 | - $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
| 1710 | - else |
|
| 1711 | - $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
| 1765 | + if (empty($max_substep)) { |
|
| 1766 | + $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
| 1767 | + } else { |
|
| 1768 | + $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
| 1769 | + } |
|
| 1712 | 1770 | |
| 1713 | 1771 | // Never more than 100%! |
| 1714 | 1772 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -1750,15 +1808,17 @@ discard block |
||
| 1750 | 1808 | 'attachment_type' => 0, |
| 1751 | 1809 | ) |
| 1752 | 1810 | ); |
| 1753 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1754 | - $attachments[] = $row['id_attach']; |
|
| 1811 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1812 | + $attachments[] = $row['id_attach']; |
|
| 1813 | + } |
|
| 1755 | 1814 | $smcFunc['db_free_result']($request); |
| 1815 | + } elseif (!empty($_GET['aid'])) { |
|
| 1816 | + $attachments[] = (int) $_GET['aid']; |
|
| 1756 | 1817 | } |
| 1757 | - elseif (!empty($_GET['aid'])) |
|
| 1758 | - $attachments[] = (int) $_GET['aid']; |
|
| 1759 | 1818 | |
| 1760 | - if (empty($attachments)) |
|
| 1761 | - fatal_lang_error('no_access', false); |
|
| 1819 | + if (empty($attachments)) { |
|
| 1820 | + fatal_lang_error('no_access', false); |
|
| 1821 | + } |
|
| 1762 | 1822 | |
| 1763 | 1823 | // Now we have some ID's cleaned and ready to approve, but first - let's check we have permission! |
| 1764 | 1824 | $allowed_boards = boardsAllowedTo('approve_posts'); |
@@ -1791,17 +1851,18 @@ discard block |
||
| 1791 | 1851 | } |
| 1792 | 1852 | $smcFunc['db_free_result']($request); |
| 1793 | 1853 | |
| 1794 | - if (empty($attachments)) |
|
| 1795 | - fatal_lang_error('no_access', false); |
|
| 1854 | + if (empty($attachments)) { |
|
| 1855 | + fatal_lang_error('no_access', false); |
|
| 1856 | + } |
|
| 1796 | 1857 | |
| 1797 | 1858 | // Finally, we are there. Follow through! |
| 1798 | 1859 | if ($is_approve) |
| 1799 | 1860 | { |
| 1800 | 1861 | // Checked and deemed worthy. |
| 1801 | 1862 | ApproveAttachments($attachments); |
| 1863 | + } else { |
|
| 1864 | + removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
| 1802 | 1865 | } |
| 1803 | - else |
|
| 1804 | - removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
| 1805 | 1866 | |
| 1806 | 1867 | // Return to the topic.... |
| 1807 | 1868 | redirectexit($redirect); |
@@ -1817,8 +1878,9 @@ discard block |
||
| 1817 | 1878 | { |
| 1818 | 1879 | global $smcFunc; |
| 1819 | 1880 | |
| 1820 | - if (empty($attachments)) |
|
| 1821 | - return 0; |
|
| 1881 | + if (empty($attachments)) { |
|
| 1882 | + return 0; |
|
| 1883 | + } |
|
| 1822 | 1884 | |
| 1823 | 1885 | // For safety, check for thumbnails... |
| 1824 | 1886 | $request = $smcFunc['db_query']('', ' |
@@ -1837,15 +1899,17 @@ discard block |
||
| 1837 | 1899 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1838 | 1900 | { |
| 1839 | 1901 | // Update the thumbnail too... |
| 1840 | - if (!empty($row['id_thumb'])) |
|
| 1841 | - $attachments[] = $row['id_thumb']; |
|
| 1902 | + if (!empty($row['id_thumb'])) { |
|
| 1903 | + $attachments[] = $row['id_thumb']; |
|
| 1904 | + } |
|
| 1842 | 1905 | |
| 1843 | 1906 | $attachments[] = $row['id_attach']; |
| 1844 | 1907 | } |
| 1845 | 1908 | $smcFunc['db_free_result']($request); |
| 1846 | 1909 | |
| 1847 | - if (empty($attachments)) |
|
| 1848 | - return 0; |
|
| 1910 | + if (empty($attachments)) { |
|
| 1911 | + return 0; |
|
| 1912 | + } |
|
| 1849 | 1913 | |
| 1850 | 1914 | // Approving an attachment is not hard - it's easy. |
| 1851 | 1915 | $smcFunc['db_query']('', ' |
@@ -1871,14 +1935,15 @@ discard block |
||
| 1871 | 1935 | ) |
| 1872 | 1936 | ); |
| 1873 | 1937 | |
| 1874 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1875 | - logAction( |
|
| 1938 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1939 | + logAction( |
|
| 1876 | 1940 | 'approve_attach', |
| 1877 | 1941 | array( |
| 1878 | 1942 | 'message' => $row['id_msg'], |
| 1879 | 1943 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
| 1880 | 1944 | ) |
| 1881 | 1945 | ); |
| 1946 | + } |
|
| 1882 | 1947 | $smcFunc['db_free_result']($request); |
| 1883 | 1948 | |
| 1884 | 1949 | // Remove from the approval queue. |
@@ -1901,11 +1966,11 @@ discard block |
||
| 1901 | 1966 | global $modSettings, $scripturl, $context, $txt, $sourcedir, $boarddir, $smcFunc, $settings; |
| 1902 | 1967 | |
| 1903 | 1968 | // Since this needs to be done eventually. |
| 1904 | - if (!isset($modSettings['attachment_basedirectories'])) |
|
| 1905 | - $modSettings['attachment_basedirectories'] = array(); |
|
| 1906 | - |
|
| 1907 | - elseif (!is_array($modSettings['attachment_basedirectories'])) |
|
| 1908 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
| 1969 | + if (!isset($modSettings['attachment_basedirectories'])) { |
|
| 1970 | + $modSettings['attachment_basedirectories'] = array(); |
|
| 1971 | + } elseif (!is_array($modSettings['attachment_basedirectories'])) { |
|
| 1972 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
| 1973 | + } |
|
| 1909 | 1974 | |
| 1910 | 1975 | $errors = array(); |
| 1911 | 1976 | |
@@ -1920,8 +1985,9 @@ discard block |
||
| 1920 | 1985 | { |
| 1921 | 1986 | $error = ''; |
| 1922 | 1987 | $id = (int) $id; |
| 1923 | - if ($id < 1) |
|
| 1924 | - continue; |
|
| 1988 | + if ($id < 1) { |
|
| 1989 | + continue; |
|
| 1990 | + } |
|
| 1925 | 1991 | |
| 1926 | 1992 | // Sorry, these dirs are NOT valid |
| 1927 | 1993 | $invalid_dirs = array($boarddir, $settings['default_theme_dir'], $sourcedir); |
@@ -1940,8 +2006,7 @@ discard block |
||
| 1940 | 2006 | { |
| 1941 | 2007 | $errors[] = $path . ': ' . $txt['attach_dir_duplicate_msg']; |
| 1942 | 2008 | continue; |
| 1943 | - } |
|
| 1944 | - elseif (empty($path)) |
|
| 2009 | + } elseif (empty($path)) |
|
| 1945 | 2010 | { |
| 1946 | 2011 | // Ignore this and set $id to one less |
| 1947 | 2012 | continue; |
@@ -1949,10 +2014,11 @@ discard block |
||
| 1949 | 2014 | |
| 1950 | 2015 | // OK, so let's try to create it then. |
| 1951 | 2016 | require_once($sourcedir . '/Subs-Attachments.php'); |
| 1952 | - if (automanage_attachments_create_directory($path)) |
|
| 1953 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 1954 | - else |
|
| 1955 | - $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
| 2017 | + if (automanage_attachments_create_directory($path)) { |
|
| 2018 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2019 | + } else { |
|
| 2020 | + $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
| 2021 | + } |
|
| 1956 | 2022 | } |
| 1957 | 2023 | |
| 1958 | 2024 | // Changing a directory name? |
@@ -1965,8 +2031,7 @@ discard block |
||
| 1965 | 2031 | $errors[] = $path . ': ' . $txt['attach_dir_no_rename']; |
| 1966 | 2032 | $path = $modSettings['attachmentUploadDir'][$id]; |
| 1967 | 2033 | } |
| 1968 | - } |
|
| 1969 | - else |
|
| 2034 | + } else |
|
| 1970 | 2035 | { |
| 1971 | 2036 | $errors[] = $path . ': ' . $txt['attach_dir_exists_msg']; |
| 1972 | 2037 | $path = $modSettings['attachmentUploadDir'][$id]; |
@@ -1991,12 +2056,13 @@ discard block |
||
| 1991 | 2056 | $path = $modSettings['attachmentUploadDir'][$id]; |
| 1992 | 2057 | |
| 1993 | 2058 | // It's not a good idea to delete the current directory. |
| 1994 | - if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) |
|
| 1995 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
| 2059 | + if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) { |
|
| 2060 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
| 2061 | + } |
|
| 1996 | 2062 | // Or the current base directory |
| 1997 | - elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) |
|
| 1998 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
| 1999 | - else |
|
| 2063 | + elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) { |
|
| 2064 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
| 2065 | + } else |
|
| 2000 | 2066 | { |
| 2001 | 2067 | // Let's not try to delete a path with files in it. |
| 2002 | 2068 | $request = $smcFunc['db_query']('', ' |
@@ -2015,17 +2081,18 @@ discard block |
||
| 2015 | 2081 | if (!empty($modSettings['attachment_basedirectories'])) |
| 2016 | 2082 | { |
| 2017 | 2083 | // Count any sub-folders. |
| 2018 | - foreach ($modSettings['attachmentUploadDir'] as $sub) |
|
| 2019 | - if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
| 2084 | + foreach ($modSettings['attachmentUploadDir'] as $sub) { |
|
| 2085 | + if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
| 2020 | 2086 | $num_attach++; |
| 2087 | + } |
|
| 2021 | 2088 | } |
| 2022 | 2089 | |
| 2023 | 2090 | // It's safe to delete. So try to delete the folder also |
| 2024 | 2091 | if ($num_attach == 0) |
| 2025 | 2092 | { |
| 2026 | - if (is_dir($path)) |
|
| 2027 | - $doit = true; |
|
| 2028 | - elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
| 2093 | + if (is_dir($path)) { |
|
| 2094 | + $doit = true; |
|
| 2095 | + } elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
| 2029 | 2096 | { |
| 2030 | 2097 | $doit = true; |
| 2031 | 2098 | $path = $boarddir . DIRECTORY_SEPARATOR . $path; |
@@ -2035,8 +2102,9 @@ discard block |
||
| 2035 | 2102 | { |
| 2036 | 2103 | unlink($path . '/.htaccess'); |
| 2037 | 2104 | unlink($path . '/index.php'); |
| 2038 | - if (!@rmdir($path)) |
|
| 2039 | - $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
| 2105 | + if (!@rmdir($path)) { |
|
| 2106 | + $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
| 2107 | + } |
|
| 2040 | 2108 | } |
| 2041 | 2109 | |
| 2042 | 2110 | // Remove it from the base directory list. |
@@ -2046,14 +2114,15 @@ discard block |
||
| 2046 | 2114 | updateSettings(array('attachment_basedirectories' => json_encode($modSettings['attachment_basedirectories']))); |
| 2047 | 2115 | $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
| 2048 | 2116 | } |
| 2117 | + } else { |
|
| 2118 | + $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
| 2049 | 2119 | } |
| 2050 | - else |
|
| 2051 | - $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
| 2052 | 2120 | |
| 2053 | - if (empty($error)) |
|
| 2054 | - continue; |
|
| 2055 | - else |
|
| 2056 | - $errors[] = $error; |
|
| 2121 | + if (empty($error)) { |
|
| 2122 | + continue; |
|
| 2123 | + } else { |
|
| 2124 | + $errors[] = $error; |
|
| 2125 | + } |
|
| 2057 | 2126 | } |
| 2058 | 2127 | } |
| 2059 | 2128 | |
@@ -2061,23 +2130,26 @@ discard block |
||
| 2061 | 2130 | } |
| 2062 | 2131 | |
| 2063 | 2132 | // We need to make sure the current directory is right. |
| 2064 | - if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) |
|
| 2065 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2133 | + if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 2134 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2135 | + } |
|
| 2066 | 2136 | |
| 2067 | 2137 | // Find the current directory if there's no value carried, |
| 2068 | 2138 | if (empty($_POST['current_dir']) || empty($new_dirs[$_POST['current_dir']])) |
| 2069 | 2139 | { |
| 2070 | - if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) |
|
| 2071 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2072 | - else |
|
| 2073 | - $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
| 2140 | + if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) { |
|
| 2141 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2142 | + } else { |
|
| 2143 | + $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
| 2144 | + } |
|
| 2074 | 2145 | } |
| 2075 | 2146 | |
| 2076 | 2147 | // If the user wishes to go back, update the last_dir array |
| 2077 | 2148 | if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir']&& !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0]))) |
| 2078 | 2149 | { |
| 2079 | - if (!is_array($modSettings['last_attachments_directory'])) |
|
| 2080 | - $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
|
| 2150 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
| 2151 | + $modSettings['last_attachments_directory'] = smf_json_decode($modSettings['last_attachments_directory'], true); |
|
| 2152 | + } |
|
| 2081 | 2153 | $num = substr(strrchr($modSettings['attachmentUploadDir'][$_POST['current_dir']], '_'), 1); |
| 2082 | 2154 | |
| 2083 | 2155 | if (is_numeric($num)) |
@@ -2085,16 +2157,18 @@ discard block |
||
| 2085 | 2157 | // Need to find the base folder. |
| 2086 | 2158 | $bid = -1; |
| 2087 | 2159 | $use_subdirectories_for_attachments = 0; |
| 2088 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
| 2089 | - foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
| 2160 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
| 2161 | + foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
| 2090 | 2162 | if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !==false) |
| 2091 | 2163 | { |
| 2092 | 2164 | $use_subdirectories_for_attachments = 1; |
| 2165 | + } |
|
| 2093 | 2166 | break; |
| 2094 | 2167 | } |
| 2095 | 2168 | |
| 2096 | - if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) |
|
| 2097 | - $bid = 0; |
|
| 2169 | + if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) { |
|
| 2170 | + $bid = 0; |
|
| 2171 | + } |
|
| 2098 | 2172 | |
| 2099 | 2173 | $modSettings['last_attachments_directory'][$bid] = (int) $num; |
| 2100 | 2174 | $modSettings['basedirectory_for_attachments'] = !empty($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : ''; |
@@ -2113,8 +2187,8 @@ discard block |
||
| 2113 | 2187 | // We might need to reset the paths. This loop will just loop through once. |
| 2114 | 2188 | foreach ($new_dirs as $id => $dir) |
| 2115 | 2189 | { |
| 2116 | - if ($id != 1) |
|
| 2117 | - $smcFunc['db_query']('', ' |
|
| 2190 | + if ($id != 1) { |
|
| 2191 | + $smcFunc['db_query']('', ' |
|
| 2118 | 2192 | UPDATE {db_prefix}attachments |
| 2119 | 2193 | SET id_folder = {int:default_folder} |
| 2120 | 2194 | WHERE id_folder = {int:current_folder}', |
@@ -2123,14 +2197,14 @@ discard block |
||
| 2123 | 2197 | 'current_folder' => $id, |
| 2124 | 2198 | ) |
| 2125 | 2199 | ); |
| 2200 | + } |
|
| 2126 | 2201 | |
| 2127 | 2202 | $update = array( |
| 2128 | 2203 | 'currentAttachmentUploadDir' => 1, |
| 2129 | 2204 | 'attachmentUploadDir' => json_encode(array(1 => $dir)), |
| 2130 | 2205 | ); |
| 2131 | 2206 | } |
| 2132 | - } |
|
| 2133 | - else |
|
| 2207 | + } else |
|
| 2134 | 2208 | { |
| 2135 | 2209 | // Save it to the database. |
| 2136 | 2210 | $update = array( |
@@ -2139,11 +2213,13 @@ discard block |
||
| 2139 | 2213 | ); |
| 2140 | 2214 | } |
| 2141 | 2215 | |
| 2142 | - if (!empty($update)) |
|
| 2143 | - updateSettings($update); |
|
| 2216 | + if (!empty($update)) { |
|
| 2217 | + updateSettings($update); |
|
| 2218 | + } |
|
| 2144 | 2219 | |
| 2145 | - if (!empty($errors)) |
|
| 2146 | - $_SESSION['errors']['dir'] = $errors; |
|
| 2220 | + if (!empty($errors)) { |
|
| 2221 | + $_SESSION['errors']['dir'] = $errors; |
|
| 2222 | + } |
|
| 2147 | 2223 | |
| 2148 | 2224 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
| 2149 | 2225 | } |
@@ -2157,10 +2233,11 @@ discard block |
||
| 2157 | 2233 | $_POST['current_base_dir'] = isset($_POST['current_base_dir']) ? (int) $_POST['current_base_dir'] : 1; |
| 2158 | 2234 | if (empty($_POST['new_base_dir']) && !empty($_POST['current_base_dir'])) |
| 2159 | 2235 | { |
| 2160 | - if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) |
|
| 2161 | - $update = (array( |
|
| 2236 | + if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) { |
|
| 2237 | + $update = (array( |
|
| 2162 | 2238 | 'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$_POST['current_base_dir']], |
| 2163 | 2239 | )); |
| 2240 | + } |
|
| 2164 | 2241 | } |
| 2165 | 2242 | |
| 2166 | 2243 | if (isset($_POST['base_dir'])) |
@@ -2208,13 +2285,15 @@ discard block |
||
| 2208 | 2285 | |
| 2209 | 2286 | if (!in_array($_POST['new_base_dir'], $modSettings['attachmentUploadDir'])) |
| 2210 | 2287 | { |
| 2211 | - if (!automanage_attachments_create_directory($_POST['new_base_dir'])) |
|
| 2212 | - $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
| 2288 | + if (!automanage_attachments_create_directory($_POST['new_base_dir'])) { |
|
| 2289 | + $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
| 2290 | + } |
|
| 2213 | 2291 | } |
| 2214 | 2292 | |
| 2215 | 2293 | $modSettings['currentAttachmentUploadDir'] = array_search($_POST['new_base_dir'], $modSettings['attachmentUploadDir']); |
| 2216 | - if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) |
|
| 2217 | - $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
| 2294 | + if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) { |
|
| 2295 | + $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
| 2296 | + } |
|
| 2218 | 2297 | ksort($modSettings['attachment_basedirectories']); |
| 2219 | 2298 | |
| 2220 | 2299 | $update = (array( |
@@ -2224,11 +2303,13 @@ discard block |
||
| 2224 | 2303 | )); |
| 2225 | 2304 | } |
| 2226 | 2305 | |
| 2227 | - if (!empty($errors)) |
|
| 2228 | - $_SESSION['errors']['base'] = $errors; |
|
| 2306 | + if (!empty($errors)) { |
|
| 2307 | + $_SESSION['errors']['base'] = $errors; |
|
| 2308 | + } |
|
| 2229 | 2309 | |
| 2230 | - if (!empty($update)) |
|
| 2231 | - updateSettings($update); |
|
| 2310 | + if (!empty($update)) { |
|
| 2311 | + updateSettings($update); |
|
| 2312 | + } |
|
| 2232 | 2313 | |
| 2233 | 2314 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
| 2234 | 2315 | } |
@@ -2238,13 +2319,15 @@ discard block |
||
| 2238 | 2319 | if (is_array($_SESSION['errors'])) |
| 2239 | 2320 | { |
| 2240 | 2321 | $errors = array(); |
| 2241 | - if (!empty($_SESSION['errors']['dir'])) |
|
| 2242 | - foreach ($_SESSION['errors']['dir'] as $error) |
|
| 2322 | + if (!empty($_SESSION['errors']['dir'])) { |
|
| 2323 | + foreach ($_SESSION['errors']['dir'] as $error) |
|
| 2243 | 2324 | $errors['dir'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
| 2325 | + } |
|
| 2244 | 2326 | |
| 2245 | - if (!empty($_SESSION['errors']['base'])) |
|
| 2246 | - foreach ($_SESSION['errors']['base'] as $error) |
|
| 2327 | + if (!empty($_SESSION['errors']['base'])) { |
|
| 2328 | + foreach ($_SESSION['errors']['base'] as $error) |
|
| 2247 | 2329 | $errors['base'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
| 2330 | + } |
|
| 2248 | 2331 | } |
| 2249 | 2332 | unset($_SESSION['errors']); |
| 2250 | 2333 | } |
@@ -2455,8 +2538,9 @@ discard block |
||
| 2455 | 2538 | foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
| 2456 | 2539 | { |
| 2457 | 2540 | // If there aren't any attachments in this directory this won't exist. |
| 2458 | - if (!isset($expected_files[$id])) |
|
| 2459 | - $expected_files[$id] = 0; |
|
| 2541 | + if (!isset($expected_files[$id])) { |
|
| 2542 | + $expected_files[$id] = 0; |
|
| 2543 | + } |
|
| 2460 | 2544 | |
| 2461 | 2545 | // Check if the directory is doing okay. |
| 2462 | 2546 | list ($status, $error, $files) = attachDirStatus($dir, $expected_files[$id]); |
@@ -2469,10 +2553,11 @@ discard block |
||
| 2469 | 2553 | $is_base_dir = in_array($dir, $modSettings['attachment_basedirectories']); |
| 2470 | 2554 | |
| 2471 | 2555 | // Count any sub-folders. |
| 2472 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
| 2473 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2556 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
| 2557 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2474 | 2558 | { |
| 2475 | 2559 | $expected_files[$id]++; |
| 2560 | + } |
|
| 2476 | 2561 | $sub_dirs++; |
| 2477 | 2562 | } |
| 2478 | 2563 | } |
@@ -2490,8 +2575,8 @@ discard block |
||
| 2490 | 2575 | } |
| 2491 | 2576 | |
| 2492 | 2577 | // Just stick a new directory on at the bottom. |
| 2493 | - if (isset($_REQUEST['new_path'])) |
|
| 2494 | - $attachdirs[] = array( |
|
| 2578 | + if (isset($_REQUEST['new_path'])) { |
|
| 2579 | + $attachdirs[] = array( |
|
| 2495 | 2580 | 'id' => max(array_merge(array_keys($expected_files), array_keys($modSettings['attachmentUploadDir']))) + 1, |
| 2496 | 2581 | 'current' => false, |
| 2497 | 2582 | 'path' => '', |
@@ -2499,6 +2584,7 @@ discard block |
||
| 2499 | 2584 | 'num_files' => '', |
| 2500 | 2585 | 'status' => '', |
| 2501 | 2586 | ); |
| 2587 | + } |
|
| 2502 | 2588 | |
| 2503 | 2589 | return $attachdirs; |
| 2504 | 2590 | } |
@@ -2511,8 +2597,9 @@ discard block |
||
| 2511 | 2597 | { |
| 2512 | 2598 | global $modSettings, $txt; |
| 2513 | 2599 | |
| 2514 | - if (empty($modSettings['attachment_basedirectories'])) |
|
| 2515 | - return; |
|
| 2600 | + if (empty($modSettings['attachment_basedirectories'])) { |
|
| 2601 | + return; |
|
| 2602 | + } |
|
| 2516 | 2603 | |
| 2517 | 2604 | $basedirs = array(); |
| 2518 | 2605 | // Get a list of the base directories. |
@@ -2520,16 +2607,18 @@ discard block |
||
| 2520 | 2607 | { |
| 2521 | 2608 | // Loop through the attach directory array to count any sub-directories |
| 2522 | 2609 | $expected_dirs = 0; |
| 2523 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
| 2524 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2610 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
| 2611 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2525 | 2612 | $expected_dirs++; |
| 2613 | + } |
|
| 2526 | 2614 | |
| 2527 | - if (!is_dir($dir)) |
|
| 2528 | - $status = 'does_not_exist'; |
|
| 2529 | - elseif (!is_writeable($dir)) |
|
| 2530 | - $status = 'not_writable'; |
|
| 2531 | - else |
|
| 2532 | - $status = 'ok'; |
|
| 2615 | + if (!is_dir($dir)) { |
|
| 2616 | + $status = 'does_not_exist'; |
|
| 2617 | + } elseif (!is_writeable($dir)) { |
|
| 2618 | + $status = 'not_writable'; |
|
| 2619 | + } else { |
|
| 2620 | + $status = 'ok'; |
|
| 2621 | + } |
|
| 2533 | 2622 | |
| 2534 | 2623 | $basedirs[] = array( |
| 2535 | 2624 | 'id' => $id, |
@@ -2540,14 +2629,15 @@ discard block |
||
| 2540 | 2629 | ); |
| 2541 | 2630 | } |
| 2542 | 2631 | |
| 2543 | - if (isset($_REQUEST['new_base_path'])) |
|
| 2544 | - $basedirs[] = array( |
|
| 2632 | + if (isset($_REQUEST['new_base_path'])) { |
|
| 2633 | + $basedirs[] = array( |
|
| 2545 | 2634 | 'id' => '', |
| 2546 | 2635 | 'current' => false, |
| 2547 | 2636 | 'path' => '<input type="text" name="new_base_dir" value="" size="40">', |
| 2548 | 2637 | 'num_dirs' => '', |
| 2549 | 2638 | 'status' => '', |
| 2550 | 2639 | ); |
| 2640 | + } |
|
| 2551 | 2641 | |
| 2552 | 2642 | return $basedirs; |
| 2553 | 2643 | } |
@@ -2563,10 +2653,11 @@ discard block |
||
| 2563 | 2653 | */ |
| 2564 | 2654 | function attachDirStatus($dir, $expected_files) |
| 2565 | 2655 | { |
| 2566 | - if (!is_dir($dir)) |
|
| 2567 | - return array('does_not_exist', true, ''); |
|
| 2568 | - elseif (!is_writable($dir)) |
|
| 2569 | - return array('not_writable', true, ''); |
|
| 2656 | + if (!is_dir($dir)) { |
|
| 2657 | + return array('does_not_exist', true, ''); |
|
| 2658 | + } elseif (!is_writable($dir)) { |
|
| 2659 | + return array('not_writable', true, ''); |
|
| 2660 | + } |
|
| 2570 | 2661 | |
| 2571 | 2662 | // Everything is okay so far, start to scan through the directory. |
| 2572 | 2663 | $num_files = 0; |
@@ -2574,22 +2665,26 @@ discard block |
||
| 2574 | 2665 | while ($file = $dir_handle->read()) |
| 2575 | 2666 | { |
| 2576 | 2667 | // Now do we have a real file here? |
| 2577 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
| 2578 | - continue; |
|
| 2668 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
| 2669 | + continue; |
|
| 2670 | + } |
|
| 2579 | 2671 | |
| 2580 | 2672 | $num_files++; |
| 2581 | 2673 | } |
| 2582 | 2674 | $dir_handle->close(); |
| 2583 | 2675 | |
| 2584 | - if ($num_files < $expected_files) |
|
| 2585 | - return array('files_missing', true, $num_files); |
|
| 2676 | + if ($num_files < $expected_files) { |
|
| 2677 | + return array('files_missing', true, $num_files); |
|
| 2678 | + } |
|
| 2586 | 2679 | // Empty? |
| 2587 | - elseif ($expected_files == 0) |
|
| 2588 | - return array('unused', false, $num_files); |
|
| 2680 | + elseif ($expected_files == 0) { |
|
| 2681 | + return array('unused', false, $num_files); |
|
| 2682 | + } |
|
| 2589 | 2683 | // All good! |
| 2590 | - else |
|
| 2591 | - return array('ok', false, $num_files); |
|
| 2592 | -} |
|
| 2684 | + else { |
|
| 2685 | + return array('ok', false, $num_files); |
|
| 2686 | + } |
|
| 2687 | + } |
|
| 2593 | 2688 | |
| 2594 | 2689 | /** |
| 2595 | 2690 | * Maintance function to move attachments from one directory to another |
@@ -2601,10 +2696,11 @@ discard block |
||
| 2601 | 2696 | checkSession(); |
| 2602 | 2697 | |
| 2603 | 2698 | $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
| 2604 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
| 2605 | - $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
| 2606 | - else |
|
| 2607 | - $modSettings['basedirectory_for_attachments'] = array(); |
|
| 2699 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
| 2700 | + $modSettings['attachment_basedirectories'] = smf_json_decode($modSettings['attachment_basedirectories'], true); |
|
| 2701 | + } else { |
|
| 2702 | + $modSettings['basedirectory_for_attachments'] = array(); |
|
| 2703 | + } |
|
| 2608 | 2704 | |
| 2609 | 2705 | $_POST['from'] = (int) $_POST['from']; |
| 2610 | 2706 | $_POST['auto'] = !empty($_POST['auto']) ? (int) $_POST['auto'] : 0; |
@@ -2618,11 +2714,13 @@ discard block |
||
| 2618 | 2714 | $total_moved = 0; |
| 2619 | 2715 | $total_not_moved = 0; |
| 2620 | 2716 | |
| 2621 | - if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) |
|
| 2622 | - $results[] = $txt['attachment_transfer_no_dir']; |
|
| 2717 | + if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) { |
|
| 2718 | + $results[] = $txt['attachment_transfer_no_dir']; |
|
| 2719 | + } |
|
| 2623 | 2720 | |
| 2624 | - if ($_POST['from'] == $_POST['to']) |
|
| 2625 | - $results[] = $txt['attachment_transfer_same_dir']; |
|
| 2721 | + if ($_POST['from'] == $_POST['to']) { |
|
| 2722 | + $results[] = $txt['attachment_transfer_same_dir']; |
|
| 2723 | + } |
|
| 2626 | 2724 | |
| 2627 | 2725 | if (empty($results)) |
| 2628 | 2726 | { |
@@ -2641,8 +2739,9 @@ discard block |
||
| 2641 | 2739 | $smcFunc['db_free_result']($request); |
| 2642 | 2740 | $total_progress -= $start; |
| 2643 | 2741 | |
| 2644 | - if ($total_progress < 1) |
|
| 2645 | - $results[] = $txt['attachment_transfer_no_find']; |
|
| 2742 | + if ($total_progress < 1) { |
|
| 2743 | + $results[] = $txt['attachment_transfer_no_find']; |
|
| 2744 | + } |
|
| 2646 | 2745 | } |
| 2647 | 2746 | |
| 2648 | 2747 | if (empty($results)) |
@@ -2658,9 +2757,9 @@ discard block |
||
| 2658 | 2757 | |
| 2659 | 2758 | automanage_attachments_check_directory(); |
| 2660 | 2759 | $new_dir = $modSettings['currentAttachmentUploadDir']; |
| 2760 | + } else { |
|
| 2761 | + $new_dir = $_POST['to']; |
|
| 2661 | 2762 | } |
| 2662 | - else |
|
| 2663 | - $new_dir = $_POST['to']; |
|
| 2664 | 2763 | |
| 2665 | 2764 | $modSettings['currentAttachmentUploadDir'] = $new_dir; |
| 2666 | 2765 | |
@@ -2668,8 +2767,9 @@ discard block |
||
| 2668 | 2767 | while ($break == false) |
| 2669 | 2768 | { |
| 2670 | 2769 | @set_time_limit(300); |
| 2671 | - if (function_exists('apache_reset_timeout')) |
|
| 2672 | - @apache_reset_timeout(); |
|
| 2770 | + if (function_exists('apache_reset_timeout')) { |
|
| 2771 | + @apache_reset_timeout(); |
|
| 2772 | + } |
|
| 2673 | 2773 | |
| 2674 | 2774 | // If limits are set, get the file count and size for the destination folder |
| 2675 | 2775 | if ($dir_files <= 0 && (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit']))) |
@@ -2705,13 +2805,15 @@ discard block |
||
| 2705 | 2805 | |
| 2706 | 2806 | if ($smcFunc['db_num_rows']($request) === 0) |
| 2707 | 2807 | { |
| 2708 | - if (empty($current_progress)) |
|
| 2709 | - $results[] = $txt['attachment_transfer_no_find']; |
|
| 2808 | + if (empty($current_progress)) { |
|
| 2809 | + $results[] = $txt['attachment_transfer_no_find']; |
|
| 2810 | + } |
|
| 2710 | 2811 | break; |
| 2711 | 2812 | } |
| 2712 | 2813 | |
| 2713 | - if ($smcFunc['db_num_rows']($request) < $limit) |
|
| 2714 | - $break = true; |
|
| 2814 | + if ($smcFunc['db_num_rows']($request) < $limit) { |
|
| 2815 | + $break = true; |
|
| 2816 | + } |
|
| 2715 | 2817 | |
| 2716 | 2818 | // Move them |
| 2717 | 2819 | $moved = array(); |
@@ -2735,8 +2837,9 @@ discard block |
||
| 2735 | 2837 | automanage_attachments_by_space(); |
| 2736 | 2838 | |
| 2737 | 2839 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
| 2738 | - if (!empty($total_not_moved)) |
|
| 2739 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2840 | + if (!empty($total_not_moved)) { |
|
| 2841 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2842 | + } |
|
| 2740 | 2843 | |
| 2741 | 2844 | $dir_files = 0; |
| 2742 | 2845 | $total_moved = 0; |
@@ -2744,8 +2847,7 @@ discard block |
||
| 2744 | 2847 | |
| 2745 | 2848 | $break = false; |
| 2746 | 2849 | break; |
| 2747 | - } |
|
| 2748 | - else |
|
| 2850 | + } else |
|
| 2749 | 2851 | { |
| 2750 | 2852 | // Hmm, not in auto. Time to bail out then... |
| 2751 | 2853 | $results[] = $txt['attachment_transfer_no_room']; |
@@ -2760,9 +2862,9 @@ discard block |
||
| 2760 | 2862 | $total_moved++; |
| 2761 | 2863 | $current_progress++; |
| 2762 | 2864 | $moved[] = $row['id_attach']; |
| 2865 | + } else { |
|
| 2866 | + $total_not_moved++; |
|
| 2763 | 2867 | } |
| 2764 | - else |
|
| 2765 | - $total_not_moved++; |
|
| 2766 | 2868 | } |
| 2767 | 2869 | $smcFunc['db_free_result']($request); |
| 2768 | 2870 | |
@@ -2801,13 +2903,15 @@ discard block |
||
| 2801 | 2903 | } |
| 2802 | 2904 | |
| 2803 | 2905 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
| 2804 | - if (!empty($total_not_moved)) |
|
| 2805 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2906 | + if (!empty($total_not_moved)) { |
|
| 2907 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2908 | + } |
|
| 2806 | 2909 | } |
| 2807 | 2910 | |
| 2808 | 2911 | $_SESSION['results'] = $results; |
| 2809 | - if (file_exists($boarddir . '/progress.php')) |
|
| 2810 | - unlink($boarddir . '/progress.php'); |
|
| 2912 | + if (file_exists($boarddir . '/progress.php')) { |
|
| 2913 | + unlink($boarddir . '/progress.php'); |
|
| 2914 | + } |
|
| 2811 | 2915 | |
| 2812 | 2916 | redirectexit('action=admin;area=manageattachments;sa=maintenance#transfer'); |
| 2813 | 2917 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * The central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | global $attachments, $messages_request, $language, $smcFunc; |
| 35 | 36 | |
| 36 | 37 | // What are you gonna display if these are empty?! |
| 37 | - if (empty($topic)) |
|
| 38 | - fatal_lang_error('no_board', false); |
|
| 38 | + if (empty($topic)) { |
|
| 39 | + fatal_lang_error('no_board', false); |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | // Load the proper template. |
| 41 | 43 | loadTemplate('Display'); |
@@ -52,15 +54,17 @@ discard block |
||
| 52 | 54 | $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
| 53 | 55 | |
| 54 | 56 | // Let's do some work on what to search index. |
| 55 | - if (count($_GET) > 2) |
|
| 56 | - foreach ($_GET as $k => $v) |
|
| 57 | + if (count($_GET) > 2) { |
|
| 58 | + foreach ($_GET as $k => $v) |
|
| 57 | 59 | { |
| 58 | 60 | if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
| 59 | 61 | $context['robot_no_index'] = true; |
| 62 | + } |
|
| 60 | 63 | } |
| 61 | 64 | |
| 62 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 63 | - $context['robot_no_index'] = true; |
|
| 65 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 66 | + $context['robot_no_index'] = true; |
|
| 67 | + } |
|
| 64 | 68 | |
| 65 | 69 | // Find the previous or next topic. Make a fuss if there are no more. |
| 66 | 70 | if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
@@ -172,8 +176,9 @@ discard block |
||
| 172 | 176 | $topic_parameters |
| 173 | 177 | ); |
| 174 | 178 | |
| 175 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 176 | - fatal_lang_error('not_a_topic', false, 404); |
|
| 179 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 180 | + fatal_lang_error('not_a_topic', false, 404); |
|
| 181 | + } |
|
| 177 | 182 | $context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
| 178 | 183 | $smcFunc['db_free_result']($request); |
| 179 | 184 | |
@@ -210,8 +215,9 @@ discard block |
||
| 210 | 215 | $context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
| 211 | 216 | |
| 212 | 217 | // Add up unapproved replies to get real number of replies... |
| 213 | - if ($modSettings['postmod_active'] && $approve_posts) |
|
| 214 | - $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
| 218 | + if ($modSettings['postmod_active'] && $approve_posts) { |
|
| 219 | + $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
| 220 | + } |
|
| 215 | 221 | |
| 216 | 222 | // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
| 217 | 223 | if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
@@ -231,11 +237,11 @@ discard block |
||
| 231 | 237 | $smcFunc['db_free_result']($request); |
| 232 | 238 | |
| 233 | 239 | $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
| 240 | + } elseif ($user_info['is_guest']) { |
|
| 241 | + $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 242 | + } else { |
|
| 243 | + $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 234 | 244 | } |
| 235 | - elseif ($user_info['is_guest']) |
|
| 236 | - $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 237 | - else |
|
| 238 | - $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 239 | 245 | |
| 240 | 246 | // The start isn't a number; it's information about what to do, where to go. |
| 241 | 247 | if (!is_numeric($_REQUEST['start'])) |
@@ -248,8 +254,7 @@ discard block |
||
| 248 | 254 | { |
| 249 | 255 | $context['start_from'] = $context['total_visible_posts'] - 1; |
| 250 | 256 | $_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
| 251 | - } |
|
| 252 | - else |
|
| 257 | + } else |
|
| 253 | 258 | { |
| 254 | 259 | // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
| 255 | 260 | $request = $smcFunc['db_query']('', ' |
@@ -277,9 +282,9 @@ discard block |
||
| 277 | 282 | if (substr($_REQUEST['start'], 0, 4) == 'from') |
| 278 | 283 | { |
| 279 | 284 | $timestamp = (int) substr($_REQUEST['start'], 4); |
| 280 | - if ($timestamp === 0) |
|
| 281 | - $_REQUEST['start'] = 0; |
|
| 282 | - else |
|
| 285 | + if ($timestamp === 0) { |
|
| 286 | + $_REQUEST['start'] = 0; |
|
| 287 | + } else |
|
| 283 | 288 | { |
| 284 | 289 | // Find the number of messages posted before said time... |
| 285 | 290 | $request = $smcFunc['db_query']('', ' |
@@ -307,11 +312,11 @@ discard block |
||
| 307 | 312 | elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
| 308 | 313 | { |
| 309 | 314 | $virtual_msg = (int) substr($_REQUEST['start'], 3); |
| 310 | - if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
| 311 | - $context['start_from'] = $context['total_visible_posts'] - 1; |
|
| 312 | - elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
| 313 | - $context['start_from'] = 0; |
|
| 314 | - else |
|
| 315 | + if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
| 316 | + $context['start_from'] = $context['total_visible_posts'] - 1; |
|
| 317 | + } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
| 318 | + $context['start_from'] = 0; |
|
| 319 | + } else |
|
| 315 | 320 | { |
| 316 | 321 | // Find the start value for that message...... |
| 317 | 322 | $request = $smcFunc['db_query']('', ' |
@@ -394,21 +399,25 @@ discard block |
||
| 394 | 399 | ); |
| 395 | 400 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 396 | 401 | { |
| 397 | - if (empty($row['id_member'])) |
|
| 398 | - continue; |
|
| 402 | + if (empty($row['id_member'])) { |
|
| 403 | + continue; |
|
| 404 | + } |
|
| 399 | 405 | |
| 400 | - if (!empty($row['online_color'])) |
|
| 401 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 402 | - else |
|
| 403 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 406 | + if (!empty($row['online_color'])) { |
|
| 407 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 408 | + } else { |
|
| 409 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 410 | + } |
|
| 404 | 411 | |
| 405 | 412 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 406 | - if ($is_buddy) |
|
| 407 | - $link = '<strong>' . $link . '</strong>'; |
|
| 413 | + if ($is_buddy) { |
|
| 414 | + $link = '<strong>' . $link . '</strong>'; |
|
| 415 | + } |
|
| 408 | 416 | |
| 409 | 417 | // Add them both to the list and to the more detailed list. |
| 410 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 411 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 418 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 419 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 420 | + } |
|
| 412 | 421 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 413 | 422 | 'id' => $row['id_member'], |
| 414 | 423 | 'username' => $row['member_name'], |
@@ -420,8 +429,9 @@ discard block |
||
| 420 | 429 | 'hidden' => empty($row['show_online']), |
| 421 | 430 | ); |
| 422 | 431 | |
| 423 | - if (empty($row['show_online'])) |
|
| 424 | - $context['view_num_hidden']++; |
|
| 432 | + if (empty($row['show_online'])) { |
|
| 433 | + $context['view_num_hidden']++; |
|
| 434 | + } |
|
| 425 | 435 | } |
| 426 | 436 | |
| 427 | 437 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -435,11 +445,13 @@ discard block |
||
| 435 | 445 | |
| 436 | 446 | // If all is set, but not allowed... just unset it. |
| 437 | 447 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
| 438 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
| 439 | - unset($_REQUEST['all']); |
|
| 448 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
| 449 | + unset($_REQUEST['all']); |
|
| 450 | + } |
|
| 440 | 451 | // Otherwise, it must be allowed... so pretend start was -1. |
| 441 | - elseif (isset($_REQUEST['all'])) |
|
| 442 | - $_REQUEST['start'] = -1; |
|
| 452 | + elseif (isset($_REQUEST['all'])) { |
|
| 453 | + $_REQUEST['start'] = -1; |
|
| 454 | + } |
|
| 443 | 455 | |
| 444 | 456 | // Construct the page index, allowing for the .START method... |
| 445 | 457 | $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
@@ -476,8 +488,9 @@ discard block |
||
| 476 | 488 | $_REQUEST['start'] = 0; |
| 477 | 489 | } |
| 478 | 490 | // They aren't using it, but the *option* is there, at least. |
| 479 | - else |
|
| 480 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
| 491 | + else { |
|
| 492 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
| 493 | + } |
|
| 481 | 494 | } |
| 482 | 495 | |
| 483 | 496 | // Build the link tree. |
@@ -493,14 +506,16 @@ discard block |
||
| 493 | 506 | if (!empty($board_info['moderators'])) |
| 494 | 507 | { |
| 495 | 508 | // Add a link for each moderator... |
| 496 | - foreach ($board_info['moderators'] as $mod) |
|
| 497 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 509 | + foreach ($board_info['moderators'] as $mod) { |
|
| 510 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 511 | + } |
|
| 498 | 512 | } |
| 499 | 513 | if (!empty($board_info['moderator_groups'])) |
| 500 | 514 | { |
| 501 | 515 | // Add a link for each moderator group as well... |
| 502 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 503 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 516 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 517 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 518 | + } |
|
| 504 | 519 | } |
| 505 | 520 | |
| 506 | 521 | if (!empty($context['link_moderators'])) |
@@ -531,9 +546,9 @@ discard block |
||
| 531 | 546 | // For quick reply we need a response prefix in the default forum language. |
| 532 | 547 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
| 533 | 548 | { |
| 534 | - if ($language === $user_info['language']) |
|
| 535 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 536 | - else |
|
| 549 | + if ($language === $user_info['language']) { |
|
| 550 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 551 | + } else |
|
| 537 | 552 | { |
| 538 | 553 | loadLanguage('index', $language, false); |
| 539 | 554 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -546,10 +561,11 @@ discard block |
||
| 546 | 561 | if (allowedTo('calendar_view') && !empty($modSettings['cal_showInTopic']) && !empty($modSettings['cal_enabled'])) |
| 547 | 562 | { |
| 548 | 563 | // First, try create a better time format, ignoring the "time" elements. |
| 549 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 550 | - $date_string = $user_info['time_format']; |
|
| 551 | - else |
|
| 552 | - $date_string = $matches[0]; |
|
| 564 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 565 | + $date_string = $user_info['time_format']; |
|
| 566 | + } else { |
|
| 567 | + $date_string = $matches[0]; |
|
| 568 | + } |
|
| 553 | 569 | |
| 554 | 570 | // Any calendar information for this topic? |
| 555 | 571 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +603,9 @@ discard block |
||
| 587 | 603 | } |
| 588 | 604 | $smcFunc['db_free_result']($request); |
| 589 | 605 | |
| 590 | - if (!empty($context['linked_calendar_events'])) |
|
| 591 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
| 606 | + if (!empty($context['linked_calendar_events'])) { |
|
| 607 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
| 608 | + } |
|
| 592 | 609 | } |
| 593 | 610 | |
| 594 | 611 | // Create the poll info if it exists. |
@@ -661,20 +678,21 @@ discard block |
||
| 661 | 678 | foreach ($guestinfo as $i => $guestvoted) |
| 662 | 679 | { |
| 663 | 680 | $guestvoted = explode(',', $guestvoted); |
| 664 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
| 665 | - break; |
|
| 681 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
| 682 | + break; |
|
| 683 | + } |
|
| 666 | 684 | } |
| 667 | 685 | // Has the poll been reset since guest voted? |
| 668 | 686 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
| 669 | 687 | { |
| 670 | 688 | // Remove the poll info from the cookie to allow guest to vote again |
| 671 | 689 | unset($guestinfo[$i]); |
| 672 | - if (!empty($guestinfo)) |
|
| 673 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 674 | - else |
|
| 675 | - unset($_COOKIE['guest_poll_vote']); |
|
| 676 | - } |
|
| 677 | - else |
|
| 690 | + if (!empty($guestinfo)) { |
|
| 691 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 692 | + } else { |
|
| 693 | + unset($_COOKIE['guest_poll_vote']); |
|
| 694 | + } |
|
| 695 | + } else |
|
| 678 | 696 | { |
| 679 | 697 | // What did they vote for? |
| 680 | 698 | unset($guestvoted[0], $guestvoted[1]); |
@@ -786,23 +804,29 @@ discard block |
||
| 786 | 804 | // Build the poll moderation button array. |
| 787 | 805 | $context['poll_buttons'] = array(); |
| 788 | 806 | |
| 789 | - if ($context['allow_return_vote']) |
|
| 790 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 807 | + if ($context['allow_return_vote']) { |
|
| 808 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 809 | + } |
|
| 791 | 810 | |
| 792 | - if ($context['show_view_results_button']) |
|
| 793 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
| 811 | + if ($context['show_view_results_button']) { |
|
| 812 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
| 813 | + } |
|
| 794 | 814 | |
| 795 | - if ($context['allow_change_vote']) |
|
| 796 | - $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 815 | + if ($context['allow_change_vote']) { |
|
| 816 | + $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 817 | + } |
|
| 797 | 818 | |
| 798 | - if ($context['allow_lock_poll']) |
|
| 799 | - $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 819 | + if ($context['allow_lock_poll']) { |
|
| 820 | + $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 821 | + } |
|
| 800 | 822 | |
| 801 | - if ($context['allow_edit_poll']) |
|
| 802 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 823 | + if ($context['allow_edit_poll']) { |
|
| 824 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 825 | + } |
|
| 803 | 826 | |
| 804 | - if ($context['can_remove_poll']) |
|
| 805 | - $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 827 | + if ($context['can_remove_poll']) { |
|
| 828 | + $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 829 | + } |
|
| 806 | 830 | |
| 807 | 831 | // Allow mods to add additional buttons here |
| 808 | 832 | call_integration_hook('integrate_poll_buttons'); |
@@ -843,8 +867,9 @@ discard block |
||
| 843 | 867 | $all_posters = array(); |
| 844 | 868 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 845 | 869 | { |
| 846 | - if (!empty($row['id_member'])) |
|
| 847 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 870 | + if (!empty($row['id_member'])) { |
|
| 871 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 872 | + } |
|
| 848 | 873 | $messages[] = $row['id_msg']; |
| 849 | 874 | } |
| 850 | 875 | $smcFunc['db_free_result']($request); |
@@ -856,8 +881,9 @@ discard block |
||
| 856 | 881 | if (!$user_info['is_guest'] && !empty($messages)) |
| 857 | 882 | { |
| 858 | 883 | $mark_at_msg = max($messages); |
| 859 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
| 860 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
| 884 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
| 885 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
| 886 | + } |
|
| 861 | 887 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
| 862 | 888 | { |
| 863 | 889 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -889,8 +915,9 @@ discard block |
||
| 889 | 915 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 890 | 916 | { |
| 891 | 917 | // Find if this topic is marked for notification... |
| 892 | - if (!empty($row['id_topic'])) |
|
| 893 | - $context['is_marked_notify'] = true; |
|
| 918 | + if (!empty($row['id_topic'])) { |
|
| 919 | + $context['is_marked_notify'] = true; |
|
| 920 | + } |
|
| 894 | 921 | |
| 895 | 922 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
| 896 | 923 | if (!empty($row['sent']) && $do_once) |
@@ -912,8 +939,9 @@ discard block |
||
| 912 | 939 | } |
| 913 | 940 | |
| 914 | 941 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
| 915 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
| 916 | - $_SESSION['topicseen_cache'][$board]--; |
|
| 942 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
| 943 | + $_SESSION['topicseen_cache'][$board]--; |
|
| 944 | + } |
|
| 917 | 945 | // Mark board as seen if this is the only new topic. |
| 918 | 946 | elseif (isset($_REQUEST['topicseen'])) |
| 919 | 947 | { |
@@ -937,14 +965,16 @@ discard block |
||
| 937 | 965 | $smcFunc['db_free_result']($request); |
| 938 | 966 | |
| 939 | 967 | // If there're no real new topics in this board, mark the board as seen. |
| 940 | - if (empty($numNewTopics)) |
|
| 941 | - $_REQUEST['boardseen'] = true; |
|
| 942 | - else |
|
| 943 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
| 968 | + if (empty($numNewTopics)) { |
|
| 969 | + $_REQUEST['boardseen'] = true; |
|
| 970 | + } else { |
|
| 971 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
| 972 | + } |
|
| 944 | 973 | } |
| 945 | 974 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
| 946 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
| 947 | - $_SESSION['topicseen_cache'][$board]--; |
|
| 975 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 976 | + $_SESSION['topicseen_cache'][$board]--; |
|
| 977 | + } |
|
| 948 | 978 | |
| 949 | 979 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
| 950 | 980 | if (isset($_REQUEST['boardseen'])) |
@@ -1001,23 +1031,26 @@ discard block |
||
| 1001 | 1031 | $temp = array(); |
| 1002 | 1032 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1003 | 1033 | { |
| 1004 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
| 1005 | - continue; |
|
| 1034 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
| 1035 | + continue; |
|
| 1036 | + } |
|
| 1006 | 1037 | |
| 1007 | 1038 | $temp[$row['id_attach']] = $row; |
| 1008 | 1039 | $temp[$row['id_attach']]['topic'] = $topic; |
| 1009 | 1040 | $temp[$row['id_attach']]['board'] = $board; |
| 1010 | 1041 | |
| 1011 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
| 1012 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
| 1042 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
| 1043 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
| 1044 | + } |
|
| 1013 | 1045 | } |
| 1014 | 1046 | $smcFunc['db_free_result']($request); |
| 1015 | 1047 | |
| 1016 | 1048 | // This is better than sorting it with the query... |
| 1017 | 1049 | ksort($temp); |
| 1018 | 1050 | |
| 1019 | - foreach ($temp as $row) |
|
| 1020 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
| 1051 | + foreach ($temp as $row) { |
|
| 1052 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
| 1053 | + } |
|
| 1021 | 1054 | } |
| 1022 | 1055 | |
| 1023 | 1056 | $msg_parameters = array( |
@@ -1044,21 +1077,23 @@ discard block |
||
| 1044 | 1077 | ); |
| 1045 | 1078 | |
| 1046 | 1079 | // And the likes |
| 1047 | - if (!empty($modSettings['enable_likes'])) |
|
| 1048 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
| 1080 | + if (!empty($modSettings['enable_likes'])) { |
|
| 1081 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
| 1082 | + } |
|
| 1049 | 1083 | |
| 1050 | 1084 | // Go to the last message if the given time is beyond the time of the last message. |
| 1051 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
| 1052 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
| 1085 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
| 1086 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
| 1087 | + } |
|
| 1053 | 1088 | |
| 1054 | 1089 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
| 1055 | 1090 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
| 1056 | - if (empty($options['view_newest_first'])) |
|
| 1057 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
| 1058 | - else |
|
| 1059 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
| 1060 | - } |
|
| 1061 | - else |
|
| 1091 | + if (empty($options['view_newest_first'])) { |
|
| 1092 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
| 1093 | + } else { |
|
| 1094 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
| 1095 | + } |
|
| 1096 | + } else |
|
| 1062 | 1097 | { |
| 1063 | 1098 | $messages_request = false; |
| 1064 | 1099 | $context['first_message'] = 0; |
@@ -1094,8 +1129,9 @@ discard block |
||
| 1094 | 1129 | 'can_see_likes' => 'likes_view', |
| 1095 | 1130 | 'can_like' => 'likes_like', |
| 1096 | 1131 | ); |
| 1097 | - foreach ($common_permissions as $contextual => $perm) |
|
| 1098 | - $context[$contextual] = allowedTo($perm); |
|
| 1132 | + foreach ($common_permissions as $contextual => $perm) { |
|
| 1133 | + $context[$contextual] = allowedTo($perm); |
|
| 1134 | + } |
|
| 1099 | 1135 | |
| 1100 | 1136 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
| 1101 | 1137 | $anyown_permissions = array( |
@@ -1108,8 +1144,9 @@ discard block |
||
| 1108 | 1144 | 'can_reply_unapproved' => 'post_unapproved_replies', |
| 1109 | 1145 | 'can_view_warning' => 'profile_warning', |
| 1110 | 1146 | ); |
| 1111 | - foreach ($anyown_permissions as $contextual => $perm) |
|
| 1112 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 1147 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
| 1148 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 1149 | + } |
|
| 1113 | 1150 | |
| 1114 | 1151 | if (!$user_info['is_admin'] && !$modSettings['topic_move_any']) |
| 1115 | 1152 | { |
@@ -1155,8 +1192,9 @@ discard block |
||
| 1155 | 1192 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
| 1156 | 1193 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
| 1157 | 1194 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
| 1158 | - if (!empty($context['drafts_save'])) |
|
| 1159 | - loadLanguage('Drafts'); |
|
| 1195 | + if (!empty($context['drafts_save'])) { |
|
| 1196 | + loadLanguage('Drafts'); |
|
| 1197 | + } |
|
| 1160 | 1198 | |
| 1161 | 1199 | // When was the last time this topic was replied to? Should we warn them about it? |
| 1162 | 1200 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1217,26 +1255,31 @@ discard block |
||
| 1217 | 1255 | // Message icons - customized icons are off? |
| 1218 | 1256 | $context['icons'] = getMessageIcons($board); |
| 1219 | 1257 | |
| 1220 | - if (!empty($context['icons'])) |
|
| 1221 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1258 | + if (!empty($context['icons'])) { |
|
| 1259 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1260 | + } |
|
| 1222 | 1261 | |
| 1223 | 1262 | // Build the normal button array. |
| 1224 | 1263 | $context['normal_buttons'] = array(); |
| 1225 | 1264 | |
| 1226 | - if ($context['can_reply']) |
|
| 1227 | - $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
| 1265 | + if ($context['can_reply']) { |
|
| 1266 | + $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
| 1267 | + } |
|
| 1228 | 1268 | |
| 1229 | - if ($context['can_add_poll']) |
|
| 1230 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 1269 | + if ($context['can_add_poll']) { |
|
| 1270 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 1271 | + } |
|
| 1231 | 1272 | |
| 1232 | - if ($context['can_mark_unread']) |
|
| 1233 | - $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1273 | + if ($context['can_mark_unread']) { |
|
| 1274 | + $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1275 | + } |
|
| 1234 | 1276 | |
| 1235 | - if ($context['can_print']) |
|
| 1236 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
| 1277 | + if ($context['can_print']) { |
|
| 1278 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
| 1279 | + } |
|
| 1237 | 1280 | |
| 1238 | - if ($context['can_set_notify']) |
|
| 1239 | - $context['normal_buttons']['notify'] = array( |
|
| 1281 | + if ($context['can_set_notify']) { |
|
| 1282 | + $context['normal_buttons']['notify'] = array( |
|
| 1240 | 1283 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
| 1241 | 1284 | 'sub_buttons' => array( |
| 1242 | 1285 | array( |
@@ -1258,38 +1301,47 @@ discard block |
||
| 1258 | 1301 | ), |
| 1259 | 1302 | ), |
| 1260 | 1303 | ); |
| 1304 | + } |
|
| 1261 | 1305 | |
| 1262 | 1306 | // Build the mod button array |
| 1263 | 1307 | $context['mod_buttons'] = array(); |
| 1264 | 1308 | |
| 1265 | - if ($context['can_move']) |
|
| 1266 | - $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1309 | + if ($context['can_move']) { |
|
| 1310 | + $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1311 | + } |
|
| 1267 | 1312 | |
| 1268 | - if ($context['can_delete']) |
|
| 1269 | - $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1313 | + if ($context['can_delete']) { |
|
| 1314 | + $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1315 | + } |
|
| 1270 | 1316 | |
| 1271 | - if ($context['can_lock']) |
|
| 1272 | - $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1317 | + if ($context['can_lock']) { |
|
| 1318 | + $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1319 | + } |
|
| 1273 | 1320 | |
| 1274 | - if ($context['can_sticky']) |
|
| 1275 | - $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1321 | + if ($context['can_sticky']) { |
|
| 1322 | + $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1323 | + } |
|
| 1276 | 1324 | |
| 1277 | - if ($context['can_merge']) |
|
| 1278 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
| 1325 | + if ($context['can_merge']) { |
|
| 1326 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
| 1327 | + } |
|
| 1279 | 1328 | |
| 1280 | - if ($context['calendar_post']) |
|
| 1281 | - $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1329 | + if ($context['calendar_post']) { |
|
| 1330 | + $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1331 | + } |
|
| 1282 | 1332 | |
| 1283 | 1333 | // Restore topic. eh? No monkey business. |
| 1284 | - if ($context['can_restore_topic']) |
|
| 1285 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1334 | + if ($context['can_restore_topic']) { |
|
| 1335 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1336 | + } |
|
| 1286 | 1337 | |
| 1287 | 1338 | // Show a message in case a recently posted message became unapproved. |
| 1288 | 1339 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 1289 | 1340 | |
| 1290 | 1341 | // Don't want to show this forever... |
| 1291 | - if ($context['becomesUnapproved']) |
|
| 1292 | - unset($_SESSION['becomesUnapproved']); |
|
| 1342 | + if ($context['becomesUnapproved']) { |
|
| 1343 | + unset($_SESSION['becomesUnapproved']); |
|
| 1344 | + } |
|
| 1293 | 1345 | |
| 1294 | 1346 | // Allow adding new mod buttons easily. |
| 1295 | 1347 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1298,12 +1350,14 @@ discard block |
||
| 1298 | 1350 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
| 1299 | 1351 | |
| 1300 | 1352 | // Load the drafts js file |
| 1301 | - if ($context['drafts_autosave']) |
|
| 1302 | - loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
| 1353 | + if ($context['drafts_autosave']) { |
|
| 1354 | + loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
| 1355 | + } |
|
| 1303 | 1356 | |
| 1304 | 1357 | // Spellcheck |
| 1305 | - if ($context['show_spellchecking']) |
|
| 1306 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 1358 | + if ($context['show_spellchecking']) { |
|
| 1359 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 1360 | + } |
|
| 1307 | 1361 | |
| 1308 | 1362 | // topic.js |
| 1309 | 1363 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -1337,16 +1391,19 @@ discard block |
||
| 1337 | 1391 | static $counter = null; |
| 1338 | 1392 | |
| 1339 | 1393 | // If the query returned false, bail. |
| 1340 | - if ($messages_request == false) |
|
| 1341 | - return false; |
|
| 1394 | + if ($messages_request == false) { |
|
| 1395 | + return false; |
|
| 1396 | + } |
|
| 1342 | 1397 | |
| 1343 | 1398 | // Remember which message this is. (ie. reply #83) |
| 1344 | - if ($counter === null || $reset) |
|
| 1345 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
| 1399 | + if ($counter === null || $reset) { |
|
| 1400 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
| 1401 | + } |
|
| 1346 | 1402 | |
| 1347 | 1403 | // Start from the beginning... |
| 1348 | - if ($reset) |
|
| 1349 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1404 | + if ($reset) { |
|
| 1405 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1406 | + } |
|
| 1350 | 1407 | |
| 1351 | 1408 | // Attempt to get the next message. |
| 1352 | 1409 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1360,19 +1417,21 @@ discard block |
||
| 1360 | 1417 | if (empty($context['icon_sources'])) |
| 1361 | 1418 | { |
| 1362 | 1419 | $context['icon_sources'] = array(); |
| 1363 | - foreach ($context['stable_icons'] as $icon) |
|
| 1364 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 1420 | + foreach ($context['stable_icons'] as $icon) { |
|
| 1421 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 1422 | + } |
|
| 1365 | 1423 | } |
| 1366 | 1424 | |
| 1367 | 1425 | // Message Icon Management... check the images exist. |
| 1368 | 1426 | if (empty($modSettings['messageIconChecks_disable'])) |
| 1369 | 1427 | { |
| 1370 | 1428 | // If the current icon isn't known, then we need to do something... |
| 1371 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
| 1372 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1429 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
| 1430 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1431 | + } |
|
| 1432 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
| 1433 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 1373 | 1434 | } |
| 1374 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
| 1375 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 1376 | 1435 | |
| 1377 | 1436 | // If you're a lazy bum, you probably didn't give a subject... |
| 1378 | 1437 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1397,8 +1456,7 @@ discard block |
||
| 1397 | 1456 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
| 1398 | 1457 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
| 1399 | 1458 | $memberContext[$message['id_member']]['is_guest'] = true; |
| 1400 | - } |
|
| 1401 | - else |
|
| 1459 | + } else |
|
| 1402 | 1460 | { |
| 1403 | 1461 | // Define this here to make things a bit more readable |
| 1404 | 1462 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1421,8 +1479,9 @@ discard block |
||
| 1421 | 1479 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
| 1422 | 1480 | |
| 1423 | 1481 | // If it's in the recycle bin we need to override whatever icon we did have. |
| 1424 | - if (!empty($board_info['recycle'])) |
|
| 1425 | - $message['icon'] = 'recycled'; |
|
| 1482 | + if (!empty($board_info['recycle'])) { |
|
| 1483 | + $message['icon'] = 'recycled'; |
|
| 1484 | + } |
|
| 1426 | 1485 | |
| 1427 | 1486 | require_once($sourcedir . '/Subs-Attachments.php'); |
| 1428 | 1487 | |
@@ -1466,32 +1525,36 @@ discard block |
||
| 1466 | 1525 | } |
| 1467 | 1526 | |
| 1468 | 1527 | // Are likes enable? |
| 1469 | - if (!empty($modSettings['enable_likes'])) |
|
| 1470 | - $output['likes'] = array( |
|
| 1528 | + if (!empty($modSettings['enable_likes'])) { |
|
| 1529 | + $output['likes'] = array( |
|
| 1471 | 1530 | 'count' => $message['likes'], |
| 1472 | 1531 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
| 1473 | 1532 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
| 1474 | 1533 | ); |
| 1534 | + } |
|
| 1475 | 1535 | |
| 1476 | 1536 | // Is this user the message author? |
| 1477 | 1537 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
| 1478 | - if (!empty($output['modified']['name'])) |
|
| 1479 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
| 1538 | + if (!empty($output['modified']['name'])) { |
|
| 1539 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
| 1540 | + } |
|
| 1480 | 1541 | |
| 1481 | 1542 | // Did they give a reason for editing? |
| 1482 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
| 1483 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
| 1543 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
| 1544 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
| 1545 | + } |
|
| 1484 | 1546 | |
| 1485 | 1547 | // Any custom profile fields? |
| 1486 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
| 1487 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
| 1548 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
| 1549 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
| 1488 | 1550 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 1551 | + } |
|
| 1489 | 1552 | |
| 1490 | - if (empty($options['view_newest_first'])) |
|
| 1491 | - $counter++; |
|
| 1492 | - |
|
| 1493 | - else |
|
| 1494 | - $counter--; |
|
| 1553 | + if (empty($options['view_newest_first'])) { |
|
| 1554 | + $counter++; |
|
| 1555 | + } else { |
|
| 1556 | + $counter--; |
|
| 1557 | + } |
|
| 1495 | 1558 | |
| 1496 | 1559 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
| 1497 | 1560 | |
@@ -1517,21 +1580,23 @@ discard block |
||
| 1517 | 1580 | $context['no_last_modified'] = true; |
| 1518 | 1581 | |
| 1519 | 1582 | // Prevent a preview image from being displayed twice. |
| 1520 | - if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) |
|
| 1521 | - return; |
|
| 1583 | + if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) { |
|
| 1584 | + return; |
|
| 1585 | + } |
|
| 1522 | 1586 | |
| 1523 | 1587 | // Make sure some attachment was requested! |
| 1524 | - if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) |
|
| 1525 | - fatal_lang_error('no_access', false); |
|
| 1588 | + if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) { |
|
| 1589 | + fatal_lang_error('no_access', false); |
|
| 1590 | + } |
|
| 1526 | 1591 | |
| 1527 | 1592 | $_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id']; |
| 1528 | 1593 | |
| 1529 | 1594 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
| 1530 | 1595 | $attachRequest = null; |
| 1531 | 1596 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
| 1532 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
| 1533 | - $request = $attachRequest; |
|
| 1534 | - else |
|
| 1597 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
| 1598 | + $request = $attachRequest; |
|
| 1599 | + } else |
|
| 1535 | 1600 | { |
| 1536 | 1601 | // This checks only the current board for $board/$topic's permissions. |
| 1537 | 1602 | isAllowedTo('view_attachments'); |
@@ -1552,19 +1617,21 @@ discard block |
||
| 1552 | 1617 | ); |
| 1553 | 1618 | } |
| 1554 | 1619 | |
| 1555 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1556 | - fatal_lang_error('no_access', false); |
|
| 1620 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1621 | + fatal_lang_error('no_access', false); |
|
| 1622 | + } |
|
| 1557 | 1623 | |
| 1558 | 1624 | list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request); |
| 1559 | 1625 | $smcFunc['db_free_result']($request); |
| 1560 | 1626 | |
| 1561 | 1627 | // If it isn't yet approved, do they have permission to view it? |
| 1562 | - if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) |
|
| 1563 | - isAllowedTo('approve_posts'); |
|
| 1628 | + if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) { |
|
| 1629 | + isAllowedTo('approve_posts'); |
|
| 1630 | + } |
|
| 1564 | 1631 | |
| 1565 | 1632 | // Update the download counter (unless it's a thumbnail). |
| 1566 | - if ($attachment_type != 3) |
|
| 1567 | - $smcFunc['db_query']('attach_download_increase', ' |
|
| 1633 | + if ($attachment_type != 3) { |
|
| 1634 | + $smcFunc['db_query']('attach_download_increase', ' |
|
| 1568 | 1635 | UPDATE LOW_PRIORITY {db_prefix}attachments |
| 1569 | 1636 | SET downloads = downloads + 1 |
| 1570 | 1637 | WHERE id_attach = {int:id_attach}', |
@@ -1572,15 +1639,15 @@ discard block |
||
| 1572 | 1639 | 'id_attach' => $id_attach, |
| 1573 | 1640 | ) |
| 1574 | 1641 | ); |
| 1642 | + } |
|
| 1575 | 1643 | |
| 1576 | 1644 | $filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash); |
| 1577 | 1645 | |
| 1578 | 1646 | // This is done to clear any output that was made before now. |
| 1579 | 1647 | ob_end_clean(); |
| 1580 | - if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) |
|
| 1581 | - @ob_start('ob_gzhandler'); |
|
| 1582 | - |
|
| 1583 | - else |
|
| 1648 | + if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) { |
|
| 1649 | + @ob_start('ob_gzhandler'); |
|
| 1650 | + } else |
|
| 1584 | 1651 | { |
| 1585 | 1652 | ob_start(); |
| 1586 | 1653 | header('Content-Encoding: none'); |
@@ -1623,8 +1690,9 @@ discard block |
||
| 1623 | 1690 | // Send the attachment headers. |
| 1624 | 1691 | header('Pragma: '); |
| 1625 | 1692 | |
| 1626 | - if (!isBrowser('gecko')) |
|
| 1627 | - header('Content-Transfer-Encoding: binary'); |
|
| 1693 | + if (!isBrowser('gecko')) { |
|
| 1694 | + header('Content-Transfer-Encoding: binary'); |
|
| 1695 | + } |
|
| 1628 | 1696 | |
| 1629 | 1697 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 1630 | 1698 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT'); |
@@ -1633,18 +1701,19 @@ discard block |
||
| 1633 | 1701 | header('ETag: ' . $eTag); |
| 1634 | 1702 | |
| 1635 | 1703 | // Make sure the mime type warrants an inline display. |
| 1636 | - if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) |
|
| 1637 | - unset($_REQUEST['image']); |
|
| 1704 | + if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) { |
|
| 1705 | + unset($_REQUEST['image']); |
|
| 1706 | + } |
|
| 1638 | 1707 | |
| 1639 | 1708 | // Does this have a mime type? |
| 1640 | - elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
| 1641 | - header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 1642 | - |
|
| 1643 | - else |
|
| 1709 | + elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
| 1710 | + header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 1711 | + } else |
|
| 1644 | 1712 | { |
| 1645 | 1713 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
| 1646 | - if (isset($_REQUEST['image'])) |
|
| 1647 | - unset($_REQUEST['image']); |
|
| 1714 | + if (isset($_REQUEST['image'])) { |
|
| 1715 | + unset($_REQUEST['image']); |
|
| 1716 | + } |
|
| 1648 | 1717 | } |
| 1649 | 1718 | |
| 1650 | 1719 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -1652,23 +1721,22 @@ discard block |
||
| 1652 | 1721 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
| 1653 | 1722 | |
| 1654 | 1723 | // Different browsers like different standards... |
| 1655 | - if (isBrowser('firefox')) |
|
| 1656 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 1657 | - |
|
| 1658 | - elseif (isBrowser('opera')) |
|
| 1659 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 1660 | - |
|
| 1661 | - elseif (isBrowser('ie')) |
|
| 1662 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 1663 | - |
|
| 1664 | - else |
|
| 1665 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 1724 | + if (isBrowser('firefox')) { |
|
| 1725 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 1726 | + } elseif (isBrowser('opera')) { |
|
| 1727 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 1728 | + } elseif (isBrowser('ie')) { |
|
| 1729 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 1730 | + } else { |
|
| 1731 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 1732 | + } |
|
| 1666 | 1733 | |
| 1667 | 1734 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
| 1668 | - if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
| 1669 | - header('Cache-Control: no-cache'); |
|
| 1670 | - else |
|
| 1671 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 1735 | + if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
| 1736 | + header('Cache-Control: no-cache'); |
|
| 1737 | + } else { |
|
| 1738 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 1739 | + } |
|
| 1672 | 1740 | |
| 1673 | 1741 | header('Content-Length: ' . filesize($filename)); |
| 1674 | 1742 | |
@@ -1678,20 +1746,23 @@ discard block |
||
| 1678 | 1746 | // Recode line endings for text files, if enabled. |
| 1679 | 1747 | if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml'))) |
| 1680 | 1748 | { |
| 1681 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) |
|
| 1682 | - $callback = function ($buffer) |
|
| 1749 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) { |
|
| 1750 | + $callback = function ($buffer) |
|
| 1683 | 1751 | { |
| 1684 | 1752 | return preg_replace('~[\r]?\n~', "\r\n", $buffer); |
| 1753 | + } |
|
| 1685 | 1754 | }; |
| 1686 | - elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) |
|
| 1687 | - $callback = function ($buffer) |
|
| 1755 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { |
|
| 1756 | + $callback = function ($buffer) |
|
| 1688 | 1757 | { |
| 1689 | 1758 | return preg_replace('~[\r]?\n~', "\r", $buffer); |
| 1759 | + } |
|
| 1690 | 1760 | }; |
| 1691 | - else |
|
| 1692 | - $callback = function ($buffer) |
|
| 1761 | + else { |
|
| 1762 | + $callback = function ($buffer) |
|
| 1693 | 1763 | { |
| 1694 | 1764 | return preg_replace('~[\r]?\n~', "\n", $buffer); |
| 1765 | + } |
|
| 1695 | 1766 | }; |
| 1696 | 1767 | } |
| 1697 | 1768 | |
@@ -1699,23 +1770,26 @@ discard block |
||
| 1699 | 1770 | if (filesize($filename) > 4194304) |
| 1700 | 1771 | { |
| 1701 | 1772 | // Forcibly end any output buffering going on. |
| 1702 | - while (@ob_get_level() > 0) |
|
| 1703 | - @ob_end_clean(); |
|
| 1773 | + while (@ob_get_level() > 0) { |
|
| 1774 | + @ob_end_clean(); |
|
| 1775 | + } |
|
| 1704 | 1776 | |
| 1705 | 1777 | $fp = fopen($filename, 'rb'); |
| 1706 | 1778 | while (!feof($fp)) |
| 1707 | 1779 | { |
| 1708 | - if (isset($callback)) |
|
| 1709 | - echo $callback(fread($fp, 8192)); |
|
| 1710 | - else |
|
| 1711 | - echo fread($fp, 8192); |
|
| 1780 | + if (isset($callback)) { |
|
| 1781 | + echo $callback(fread($fp, 8192)); |
|
| 1782 | + } else { |
|
| 1783 | + echo fread($fp, 8192); |
|
| 1784 | + } |
|
| 1712 | 1785 | flush(); |
| 1713 | 1786 | } |
| 1714 | 1787 | fclose($fp); |
| 1715 | 1788 | } |
| 1716 | 1789 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
| 1717 | - elseif (isset($callback) || @readfile($filename) === null) |
|
| 1718 | - echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
| 1790 | + elseif (isset($callback) || @readfile($filename) === null) { |
|
| 1791 | + echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
| 1792 | + } |
|
| 1719 | 1793 | |
| 1720 | 1794 | obExit(false); |
| 1721 | 1795 | } |
@@ -1728,8 +1802,9 @@ discard block |
||
| 1728 | 1802 | */ |
| 1729 | 1803 | function approved_attach_sort($a, $b) |
| 1730 | 1804 | { |
| 1731 | - if ($a['is_approved'] == $b['is_approved']) |
|
| 1732 | - return 0; |
|
| 1805 | + if ($a['is_approved'] == $b['is_approved']) { |
|
| 1806 | + return 0; |
|
| 1807 | + } |
|
| 1733 | 1808 | |
| 1734 | 1809 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
| 1735 | 1810 | } |
@@ -1746,16 +1821,19 @@ discard block |
||
| 1746 | 1821 | |
| 1747 | 1822 | require_once($sourcedir . '/RemoveTopic.php'); |
| 1748 | 1823 | |
| 1749 | - if (empty($_REQUEST['msgs'])) |
|
| 1750 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 1824 | + if (empty($_REQUEST['msgs'])) { |
|
| 1825 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 1826 | + } |
|
| 1751 | 1827 | |
| 1752 | 1828 | $messages = array(); |
| 1753 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
| 1754 | - $messages[] = (int) $dummy; |
|
| 1829 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
| 1830 | + $messages[] = (int) $dummy; |
|
| 1831 | + } |
|
| 1755 | 1832 | |
| 1756 | 1833 | // We are restoring messages. We handle this in another place. |
| 1757 | - if (isset($_REQUEST['restore_selected'])) |
|
| 1758 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1834 | + if (isset($_REQUEST['restore_selected'])) { |
|
| 1835 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1836 | + } |
|
| 1759 | 1837 | if (isset($_REQUEST['split_selection'])) |
| 1760 | 1838 | { |
| 1761 | 1839 | $request = $smcFunc['db_query']('', ' |
@@ -1774,8 +1852,9 @@ discard block |
||
| 1774 | 1852 | } |
| 1775 | 1853 | |
| 1776 | 1854 | // Allowed to delete any message? |
| 1777 | - if (allowedTo('delete_any')) |
|
| 1778 | - $allowed_all = true; |
|
| 1855 | + if (allowedTo('delete_any')) { |
|
| 1856 | + $allowed_all = true; |
|
| 1857 | + } |
|
| 1779 | 1858 | // Allowed to delete replies to their messages? |
| 1780 | 1859 | elseif (allowedTo('delete_replies')) |
| 1781 | 1860 | { |
@@ -1792,13 +1871,14 @@ discard block |
||
| 1792 | 1871 | $smcFunc['db_free_result']($request); |
| 1793 | 1872 | |
| 1794 | 1873 | $allowed_all = $starter == $user_info['id']; |
| 1874 | + } else { |
|
| 1875 | + $allowed_all = false; |
|
| 1795 | 1876 | } |
| 1796 | - else |
|
| 1797 | - $allowed_all = false; |
|
| 1798 | 1877 | |
| 1799 | 1878 | // Make sure they're allowed to delete their own messages, if not any. |
| 1800 | - if (!$allowed_all) |
|
| 1801 | - isAllowedTo('delete_own'); |
|
| 1879 | + if (!$allowed_all) { |
|
| 1880 | + isAllowedTo('delete_own'); |
|
| 1881 | + } |
|
| 1802 | 1882 | |
| 1803 | 1883 | // Allowed to remove which messages? |
| 1804 | 1884 | $request = $smcFunc['db_query']('', ' |
@@ -1818,8 +1898,9 @@ discard block |
||
| 1818 | 1898 | $messages = array(); |
| 1819 | 1899 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1820 | 1900 | { |
| 1821 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
| 1822 | - continue; |
|
| 1901 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
| 1902 | + continue; |
|
| 1903 | + } |
|
| 1823 | 1904 | |
| 1824 | 1905 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
| 1825 | 1906 | } |
@@ -1842,17 +1923,20 @@ discard block |
||
| 1842 | 1923 | foreach ($messages as $message => $info) |
| 1843 | 1924 | { |
| 1844 | 1925 | // Just skip the first message - if it's not the last. |
| 1845 | - if ($message == $first_message && $message != $last_message) |
|
| 1846 | - continue; |
|
| 1926 | + if ($message == $first_message && $message != $last_message) { |
|
| 1927 | + continue; |
|
| 1928 | + } |
|
| 1847 | 1929 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
| 1848 | - elseif ($message == $first_message) |
|
| 1849 | - $topicGone = true; |
|
| 1930 | + elseif ($message == $first_message) { |
|
| 1931 | + $topicGone = true; |
|
| 1932 | + } |
|
| 1850 | 1933 | |
| 1851 | 1934 | removeMessage($message); |
| 1852 | 1935 | |
| 1853 | 1936 | // Log this moderation action ;). |
| 1854 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 1855 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
| 1937 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 1938 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
| 1939 | + } |
|
| 1856 | 1940 | } |
| 1857 | 1941 | |
| 1858 | 1942 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |